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.

Neutral view backdrop, named backdrops on every surface, pixel-exact GPU sheets (#118)

Matthew Kissinger363b25ceb2ce
diff --git a/AGENTS.md b/AGENTS.md
index 08be89a4..e0a965fa 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -69,6 +69,18 @@ are indistinguishable after construction. Host telemetry rides `onViewsRendered`
be treated as material evidence. Keep the input schema stable unless the active change explicitly
versions it -- the tool definition is cached, and changing it invalidates that cache.
+Both producers paint one backdrop from one table. `src/views/background.ts` owns the three named
+backdrops and `render-service/src/backdrops.mjs` mirrors them; `backdrop.test.ts` fails if they
+drift. The default is the neutral studio grey, chosen by measuring silhouette-edge contrast over
+the whole example set. The GPU service clears to the linear colour that its tone mapping turns
+into exactly that value (`render-service/src/display-transform.mjs`), so a CPU fallback sheet and
+a GPU sheet share the backdrop pixel for pixel. A capture may name `neutral`, `dark` or `light`; it may never pass a
+free colour, because comparability across runs (arena, capture cache, reference comparison) assumes
+two sheets of one GLB differ only because the asset does, and a backdrop close to the asset colour
+hides the seams the model is meant to find. The chosen id is part of both capture-cache keys and is
+echoed as `capture.backdrop` in every render result. `kiln_save` paints its preview on the backdrop
+it is given and the manifest records it as `preview.backdrop`; a reader never guesses it.
+
**The GPU is a view producer only, never gate evidence.** `QaContext` is deliberately image-free so a
QA rule structurally cannot read a render buffer. Do not add pixels to it.
@@ -106,7 +118,7 @@ do not lower them without an explicit measured rationale. Live model tests are o
`bun run test` is `bun test src scripts`, so it does **not** reach `render-service/`, which is a
separate npm project. `bun run test:render-service` does; it needs `npm --prefix render-service ci
---ignore-scripts` once. All 37 of those tests are pure -- framing arithmetic, PNG readback packing,
+--ignore-scripts` once. All 49 of those tests are pure -- framing arithmetic, PNG readback packing,
cache identity, contract and preset validation -- so none of them needs a GPU or the native Dawn
build, which is why `--ignore-scripts` is enough. Run it whenever you change `render-service/`; CI
requires it.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b59b9f3e..e2d19b1d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,54 @@
Changes to `@kiln/engine`. Source and installable packages are distributed through
GitHub. The package is not published on the npm registry.
+## Unreleased: Neutral view backdrop, and a named backdrop per capture
+
+- **Every contact sheet is now painted on the neutral studio grey `#aab1bc` instead of near-black
+ `#1a1a1a`.** The old value was pinned in PR #13 for CPU/GPU parity and never revisited; a dark
+ asset on it lost the silhouette, tail and ground contact the render tool asks the model to check.
+ The new default was chosen by measuring silhouette-edge contrast over the 86 examples plus a
+ near-black test asset on the CPU rasterizer: near-black left 39.7% of edge pixels under a 1.5:1
+ contrast ratio, the studio grey 12.8%. It is also the GPU studio preset's background, so a CPU
+ fallback sheet and a GPU sheet of the same request now share one colour on every path,
+ including exact-camera captures, which used to come back grey from the GPU and near-black from
+ the CPU fallback.
+- **`capture.backdrop` accepts `neutral`, `dark` or `light`** on `kiln_render`, `kiln_edit` and
+ `kiln_view_interior`. Free colours are deliberately not accepted: comparability across runs
+ assumes two sheets of one GLB differ only because the asset does. The chosen id is part of both
+ capture-cache keys and is echoed as `capture.backdrop` in every render result. The render
+ service accepts the same `backdrop` field in both modes from a mirrored table that the engine
+ suite asserts against. The CLI takes it inside a `--capture` recipe or as `--backdrop <id>`,
+ which merges into the same capture object and overrides the recipe's own value, so one shared
+ recipe can be re-run on another backdrop without editing it.
+- **The GPU backdrop is pixel-exact.** The service clears the scene background into its HDR
+ framebuffer and tone-maps it with the asset, so the neutral `#aab1bc` used to read back as
+ `(203, 207, 213)` while the CPU rasterizer painted `(170, 177, 188)`. The service now sets the
+ backdrop as the linear colour that comes out of the output pass as exactly the table's bytes,
+ through an analytic inverse of three's ACES filmic curve and sRGB transfer in
+ `render-service/src/display-transform.mjs`, verified against pixels read back from a dawn-d3d12
+ device. A GPU sheet and a CPU sheet of the same request now agree on the backdrop pixel for
+ pixel. Compositing after the pass was rejected because multisampled edges would have kept a
+ one-pixel fringe.
+- **The render service's free-hex `background` field is gone**, in both modes, along with the
+ presets' own background colour: the named backdrop table is the only source, so nothing can
+ paint a colour the engine would not. `background` in a request is a 400 naming `backdrop`.
+- **`kiln render --render gpu` no longer hangs after starting the renderer itself.** The host
+ kills a service it started from an `exit` hook, which suits the long-lived MCP server, but a
+ one-shot command never reached `exit`: the child's piped stderr kept the loop alive, so the
+ CLI finished its render and then sat forever with a GPU process orphaned behind it. The CLI
+ now stops a service it started when the command settles and leaves one it merely found alone.
+ For a batch of CLI renders, start the service once by hand so each command joins it.
+- Occupancy `coverage` takes the backdrop it should measure against. Sheets cached from earlier
+ versions are keyed by the old request shape and are simply re-rendered once.
+- `kiln_view_interior` echoes `capture` too, so every image result now says which backdrop its
+ silhouettes sat on. The guidance in the schema and skills states one rule for every asset
+ colour: switch only after a sheet shows a part merging with the grey, to `light` when that part
+ is darker than the grey and to `dark` when it is lighter.
+- **`kiln_save` takes the same `backdrop` for the preview it stores**, as does the CLI's
+ `kiln save --backdrop <id>`, and the manifest records the one used as `preview.backdrop`. A
+ preview used to be painted on the default whatever sheet had been accepted, so a grey asset
+ reviewed on `dark` was stored merging with the grey it had just been moved off.
+
## Unreleased: Experimental community exporter and engine handoff
- The established GLB exporter remains the default. Builds containing this integration also
diff --git a/README.md b/README.md
index b2b01ef8..0b8e4e5d 100644
--- a/README.md
+++ b/README.md
@@ -82,7 +82,9 @@ A plain `git clone` also works and gives you the whole history up front.
This writes a GLB and a six-view image of an existing program. It makes no model call.
Rendering uses the CPU unless a compatible local GPU service is available.
-Use `--render cpu` to select the CPU explicitly.
+Use `--render cpu` to select the CPU explicitly. Sheets sit on a neutral grey; add
+`--backdrop dark` or `--backdrop light` when an asset's silhouette merges with it; `kiln save`
+takes the same flag for the preview it stores.
**Using assets in Blender or Unity?** Read the [handoff guide](docs/engine-handoff.md) for direct GLB import,
materials, backfaces, named pivots and animation checks. The established exporter remains
@@ -272,7 +274,10 @@ kiln_render({ programRef, capture: {
The close-up follows the part's local axes while retaining surrounding geometry.
You can also set explicit camera positions, return separate images, or sample
-animation frames. [Camera controls](docs/cameras.md).
+animation frames. Either capture shape also takes `backdrop: 'neutral' | 'dark' |
+'light'`, and every result echoes the one used as `capture.backdrop`. `kiln_save` takes the
+same field for the preview it stores, and the manifest records it as `preview.backdrop`.
+[Camera controls](docs/cameras.md).
## Tool reference
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index d3d17348..9d57ba2a 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -6599,9 +6599,30 @@ var init_evidence_history = __esm(() => {
});
// src/views/background.ts
-var GRID_BACKGROUND_RGB;
+function isBackdropId(value) {
+ return typeof value === "string" && BACKDROP_IDS.includes(value);
+}
+function resolveBackdrop(id) {
+ if (id === undefined)
+ return BACKDROPS[DEFAULT_BACKDROP_ID];
+ if (!isBackdropId(id))
+ throw new Error(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(id)}).`);
+ return BACKDROPS[id];
+}
+var BACKDROP_IDS, DEFAULT_BACKDROP_ID = "neutral", define = (id, rgb) => Object.freeze({
+ id,
+ rgb: Object.freeze([...rgb]),
+ hex: `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`
+}), BACKDROPS, GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX;
var init_background = __esm(() => {
- GRID_BACKGROUND_RGB = [26, 26, 26];
+ BACKDROP_IDS = ["neutral", "dark", "light"];
+ BACKDROPS = Object.freeze({
+ neutral: define("neutral", [170, 177, 188]),
+ dark: define("dark", [26, 26, 26]),
+ light: define("light", [223, 227, 232])
+ });
+ GRID_BACKGROUND_RGB = BACKDROPS[DEFAULT_BACKDROP_ID].rgb;
+ GRID_BACKGROUND_HEX = BACKDROPS[DEFAULT_BACKDROP_ID].hex;
});
// src/views/raster.ts
@@ -6734,6 +6755,7 @@ function linearToSrgb(c) {
function rasterizeView(root, dir, opts = {}) {
const size = opts.size ?? 256;
const cull = opts.backfaceCull ?? true;
+ const BG = resolveBackdrop(opts.backdrop).rgb;
const { tris, bbox } = collectTriangles(root);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++) {
@@ -6858,7 +6880,7 @@ function hideNodeInScene(root, match) {
});
return hidden;
}
-var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, BG, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
+var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
var init_raster = __esm(() => {
init_background();
SIX_VIEWS = [
@@ -6873,7 +6895,6 @@ var init_raster = __esm(() => {
...SIX_VIEWS.slice(0, 5),
{ name: "3/4 Rear", dir: [-0.7, 0.5, -0.7] }
];
- BG = GRID_BACKGROUND_RGB;
KEY_DIR = normalize([1.5, 2, 1]);
});
@@ -7127,14 +7148,15 @@ async function withCameraVisibility(root, shot, run) {
node.visible = visible;
}
}
-function rasterizeCamera(root, input, size = 384, backfaceCull = true) {
+function rasterizeCamera(root, input, size = 384, backfaceCull = true, backdrop) {
const camera = validateResolvedAssetCamera(input);
+ const bg = resolveBackdrop(backdrop).rgb;
if (!Number.isInteger(size) || size < 1 || size > 2048)
throw new Error("camera size must be an integer in 1..2048");
const z = vec(camera.position).sub(vec(camera.target)).normalize(), x = vec(camera.up).cross(z).normalize(), y = z.clone().cross(x), position = vec(camera.position);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++)
- out.set(GRID_BACKGROUND_RGB, i * 3);
+ out.set(bg, i * 3);
const depth = new Float64Array(size * size).fill(Infinity);
const clip = (points, plane, near) => {
const result = [];
@@ -7225,6 +7247,11 @@ function validatePbrRenderRequest(input) {
throw new TypeError("PbrRenderRequest.glb must be a non-empty Uint8Array");
}
const result = { glb: source.glb };
+ if (source.backdrop !== undefined) {
+ if (!isBackdropId(source.backdrop))
+ throw new TypeError(`PbrRenderRequest.backdrop must be one of ${BACKDROP_IDS.join(", ")}`);
+ result.backdrop = source.backdrop;
+ }
if (source.viewDirs !== undefined) {
if (!Array.isArray(source.viewDirs) || source.viewDirs.length < 1 || source.viewDirs.length > 12) {
throw new TypeError("PbrRenderRequest.viewDirs must contain 1..12 directions");
@@ -7343,7 +7370,9 @@ var PBR_REQUEST_KEYS;
var init_render_port = __esm(() => {
init_camera();
init_background();
+ init_background();
PBR_REQUEST_KEYS = new Set([
+ "backdrop",
"glb",
"viewDirs",
"size",
@@ -8050,7 +8079,8 @@ function createCachedRenderPort(port, options) {
size: request.size,
width: request.width,
height: request.height,
- lighting: request.lightingPresetId
+ lighting: request.lightingPresetId,
+ backdrop: request.backdrop
})));
const cells = [];
const missing = [];
@@ -8154,6 +8184,7 @@ import { z } from "zod";
import { zipSync, unzipSync } from "three/addons/libs/fflate.module.js";
var ASSET_LIMIT, assetIdSchema, hash, assetManifestSchema, allowedFiles;
var init_assets = __esm(() => {
+ init_background();
ASSET_LIMIT = 64 * 1024 * 1024;
assetIdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/);
hash = z.string().regex(/^sha256:[a-f0-9]{64}$/);
@@ -8183,7 +8214,11 @@ var init_assets = __esm(() => {
dependencies: z.array(z.unknown()).optional(),
rebuild: z.enum(["engine-required", "external-dependencies-required"])
}).optional(),
- preview: z.object({ fidelity: z.unknown().optional(), error: z.string().optional() }).optional()
+ preview: z.object({
+ fidelity: z.unknown().optional(),
+ error: z.string().optional(),
+ backdrop: z.enum(BACKDROP_IDS).optional()
+ }).optional()
});
allowedFiles = new Set(["asset.glb", "source.kiln.js", "preview.png"]);
});
@@ -22752,92 +22787,29 @@ var init_diagnostic = __esm(() => {
IDENTITY = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
});
-// src/views/camera-capture.ts
-function validateAdvancedCapture(config) {
- for (const key of Object.keys(config))
- if (!["version", "shots", "cols", "size", "output"].includes(key))
- throw new Error(`capture.${key} is unknown or incompatible with shots`);
- if (config.version !== "kiln.capture.v1")
- throw new Error("advanced capture requires version kiln.capture.v1");
- if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
- throw new Error("capture.shots must contain 1..9 shots");
- if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
- throw new Error("capture.cols must be 1..3");
- if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
- throw new Error("capture.size must be 128..1024");
- if (config.output !== undefined && !["grid", "separate"].includes(config.output))
- throw new Error("capture.output must be grid or separate");
-}
-async function renderCaptureGrid(root, config, render, limits) {
- validateAdvancedCapture(config);
- const shots = config.shots.map((s) => resolveAssetCamera(root, s));
- const size = config.size ?? 384;
- const cols = config.cols ?? Math.min(3, shots.length);
- enforceCapturePixels(shots.length, size, cols, limits);
- const cells = [];
- const perFramePngs = [];
- const derivativeReceipts = [];
- for (const shot of shots) {
- const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
- const view = { name: shot.name, dir };
- const png = await withCameraVisibility(root, shot, async () => {
- if (render) {
- const result = await render({ root, label: shot.name, view, size, camera: shot.camera });
- derivativeReceipts.push(result.receipt);
- return result.png;
- }
- return encodePng(rasterizeCamera(root, shot.camera, size), size, size);
- });
- const decoded = decodePng(png);
- if (decoded.width !== size || decoded.height !== size)
- throw new Error("capture cell dimensions do not match request");
- annotateViewCell(decoded.rgb, size, view);
- cells.push(decoded.rgb);
- perFramePngs.push(encodePng(decoded.rgb, size, size));
- }
- const { rgb, width, height } = compositeCellGrid(cells, size, cols);
- const png = encodePng(rgb, width, height);
- enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
- return {
- png,
- width,
- height,
- views: shots.map((s) => s.name),
- capture: { preset: `${cols}x${Math.ceil(shots.length / cols)}`, cols, cells: shots.length },
- cameraShots: shots,
- perFramePngs,
- derivativeReceipts,
- ...derivativeReceipts.length ? {
- captureCache: {
- hit: derivativeReceipts.every((r) => r.captureCache?.hit),
- reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
- total: derivativeReceipts.length
- }
- } : {}
- };
-}
-var init_camera_capture = __esm(() => {
- init_capture_limits();
- init_camera();
- init_png();
- init_grid();
- init_annotate();
-});
-
// src/views/capture.ts
function captureCellLabel(azimuthDeg, elevationDeg) {
const az = Math.round((azimuthDeg % 360 + 360) % 360);
const el = Math.round(elevationDeg);
return `A${az} ${el < 0 ? "D" : "U"}${Math.abs(el)}`;
}
+function resolveCaptureBackdrop(backdrop) {
+ if (backdrop === undefined)
+ return DEFAULT_BACKDROP_ID;
+ if (!isBackdropId(backdrop))
+ throw new CaptureConfigError(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(backdrop)}).`);
+ return backdrop;
+}
function resolveCapture(config) {
+ const backdrop = resolveCaptureBackdrop(config?.backdrop);
if (!config || config.preset === undefined && config.cells === undefined) {
return {
preset: DEFAULT_CAPTURE_PRESET,
views: PRESET_VIEWS[DEFAULT_CAPTURE_PRESET],
cols: PRESET_COLS[DEFAULT_CAPTURE_PRESET],
zooms: new Array(PRESET_CAPACITY[DEFAULT_CAPTURE_PRESET]).fill(undefined),
- isDefault: true
+ isDefault: true,
+ backdrop
};
}
const cells = config.cells;
@@ -22874,7 +22846,8 @@ function resolveCapture(config) {
})),
cols: PRESET_COLS[preset],
zooms: cells.map((c) => c.zoom),
- isDefault: false
+ isDefault: false,
+ backdrop
};
}
const chosen = preset;
@@ -22883,7 +22856,8 @@ function resolveCapture(config) {
views: PRESET_VIEWS[chosen],
cols: PRESET_COLS[chosen],
zooms: new Array(PRESET_VIEWS[chosen].length).fill(undefined),
- isDefault: chosen === DEFAULT_CAPTURE_PRESET
+ isDefault: chosen === DEFAULT_CAPTURE_PRESET,
+ backdrop
};
}
function resolveGridCapture(config, envVariant) {
@@ -22896,6 +22870,7 @@ function resolveGridCapture(config, envVariant) {
var CAPTURE_PRESETS, DEFAULT_CAPTURE_PRESET = "3x2", MAX_CAPTURE_CELLS = 9, PRESET_COLS, PRESET_CAPACITY, BOTTOM, THREE_QUARTER_REAR, THREE_QUARTER_LOW, PRESET_VIEWS, CaptureConfigError;
var init_capture = __esm(() => {
init_raster();
+ init_background();
CAPTURE_PRESETS = [
"1x1",
"1x2",
@@ -22939,6 +22914,93 @@ var init_capture = __esm(() => {
};
});
+// src/views/camera-capture.ts
+function validateAdvancedCapture(config) {
+ for (const key of Object.keys(config))
+ if (!["version", "shots", "cols", "size", "output", "backdrop"].includes(key))
+ throw new Error(`capture.${key} is unknown or incompatible with shots`);
+ if (config.version !== "kiln.capture.v1")
+ throw new Error("advanced capture requires version kiln.capture.v1");
+ if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
+ throw new Error("capture.shots must contain 1..9 shots");
+ if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
+ throw new Error("capture.cols must be 1..3");
+ if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
+ throw new Error("capture.size must be 128..1024");
+ if (config.output !== undefined && !["grid", "separate"].includes(config.output))
+ throw new Error("capture.output must be grid or separate");
+ resolveCaptureBackdrop(config.backdrop);
+}
+async function renderCaptureGrid(root, config, render, limits) {
+ validateAdvancedCapture(config);
+ const shots = config.shots.map((s) => resolveAssetCamera(root, s));
+ const size = config.size ?? 384;
+ const cols = config.cols ?? Math.min(3, shots.length);
+ const backdrop = resolveCaptureBackdrop(config.backdrop);
+ enforceCapturePixels(shots.length, size, cols, limits);
+ const cells = [];
+ const perFramePngs = [];
+ const derivativeReceipts = [];
+ for (const shot of shots) {
+ const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
+ const view = { name: shot.name, dir };
+ const png = await withCameraVisibility(root, shot, async () => {
+ if (render) {
+ const result = await render({
+ root,
+ label: shot.name,
+ view,
+ size,
+ camera: shot.camera,
+ backdrop
+ });
+ derivativeReceipts.push(result.receipt);
+ return result.png;
+ }
+ return encodePng(rasterizeCamera(root, shot.camera, size, true, backdrop), size, size);
+ });
+ const decoded = decodePng(png);
+ if (decoded.width !== size || decoded.height !== size)
+ throw new Error("capture cell dimensions do not match request");
+ annotateViewCell(decoded.rgb, size, view);
+ cells.push(decoded.rgb);
+ perFramePngs.push(encodePng(decoded.rgb, size, size));
+ }
+ const { rgb, width, height } = compositeCellGrid(cells, size, cols);
+ const png = encodePng(rgb, width, height);
+ enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
+ return {
+ png,
+ width,
+ height,
+ views: shots.map((s) => s.name),
+ capture: {
+ preset: `${cols}x${Math.ceil(shots.length / cols)}`,
+ cols,
+ cells: shots.length,
+ backdrop
+ },
+ cameraShots: shots,
+ perFramePngs,
+ derivativeReceipts,
+ ...derivativeReceipts.length ? {
+ captureCache: {
+ hit: derivativeReceipts.every((r) => r.captureCache?.hit),
+ reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
+ total: derivativeReceipts.length
+ }
+ } : {}
+ };
+}
+var init_camera_capture = __esm(() => {
+ init_capture_limits();
+ init_camera();
+ init_capture();
+ init_png();
+ init_grid();
+ init_annotate();
+});
+
// src/views/architecture.ts
function nodeRoles(node) {
return readSemanticMetadataV1FromExtras(node.userData ?? {})?.roles ?? [];
@@ -23875,6 +23937,7 @@ async function renderViewGrid(root, opts = {}) {
snapSceneToPalette(root, opts.snapPalette);
const wantsZoom = resolved.zooms.some((z) => z !== undefined);
const sceneBounds = wantsZoom ? measureBounds(root) : undefined;
+ const backdrop = opts.backdrop ?? resolved.backdrop;
const cache = opts.snapPalette?.length ? undefined : opts.captureCache;
let reused = 0;
const cells = [];
@@ -23883,6 +23946,7 @@ async function renderViewGrid(root, opts = {}) {
const rasterOptions = {
size,
backfaceCull: opts.backfaceCull,
+ backdrop,
...opts.frameBounds ? { frameBounds: opts.frameBounds } : {},
...sceneBounds && zoom !== undefined ? { frameBounds: expandFrameBounds(sceneBounds, zoom) } : {}
};
@@ -23895,7 +23959,8 @@ async function renderViewGrid(root, opts = {}) {
rendererId: `${CPU_RASTER_RENDERER_ID}/legacy-fit`,
camera: camera2,
size,
- backfaceCull: opts.backfaceCull ?? true
+ backfaceCull: opts.backfaceCull ?? true,
+ backdrop
}, async () => ({
png: encodePng(rasterizeView(root, views[vi].dir, rasterOptions), size, size),
width: size,
@@ -23921,7 +23986,7 @@ async function renderViewGrid(root, opts = {}) {
width,
height,
views: views.map((v) => v.name),
- capture: { preset: resolved.preset, cols, cells: views.length },
+ capture: { preset: resolved.preset, cols, cells: views.length, backdrop },
...cache && opts.artifactGlbSha256 ? { captureCache: { hit: reused === views.length, reused, total: views.length } } : {}
};
}
@@ -23934,8 +23999,9 @@ async function renderGlbViewCell(bytes, view, options = {}) {
const exactBytes = Uint8Array.from(bytes);
const loaded = await loadGlbGeometryFlatScene(exactBytes);
const size = options.size ?? 256;
- const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull) : rasterizeView(loaded.root, view.dir, {
+ const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull, options.backdrop) : rasterizeView(loaded.root, view.dir, {
size,
+ ...options.backdrop ? { backdrop: options.backdrop } : {},
...options.backfaceCull !== undefined ? { backfaceCull: options.backfaceCull } : {},
...options.frameBounds ? { frameBounds: options.frameBounds } : {}
});
@@ -24152,6 +24218,12 @@ async function renderInteriorGrid(root, opts = {}) {
width,
height,
views: INTERIOR_VIEWS.map((v) => v.name),
+ capture: {
+ preset: "interior",
+ cols: INTERIOR_VIEWS.length,
+ cells: INTERIOR_VIEWS.length,
+ backdrop: DEFAULT_BACKDROP_ID
+ },
roofsHidden,
wallsHidden,
...derivativeReceipts.length ? { derivativeReceipts } : {}
@@ -24160,6 +24232,7 @@ async function renderInteriorGrid(root, opts = {}) {
var ANIM_CAMERAS, ANIM_CAMERA_ALIASES, ROOM_WALL_NORMALS, INTERIOR_VIEWS;
var init_views = __esm(() => {
init_capture_limits();
+ init_background();
init_capture_limits();
init_capture_cache();
init_camera();
@@ -25395,7 +25468,7 @@ async function sha256Bytes(bytes) {
const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", input));
return `sha256:${[...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
}
-async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits) {
+async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits, backdrop) {
let timer;
try {
const exactCameras = cameras?.map(validateResolvedAssetCamera);
@@ -25409,6 +25482,7 @@ async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, came
const result = await Promise.race([
port({
glb: requestGlb,
+ ...backdrop ? { backdrop } : {},
...exactCameras ? { cameras: exactCameras, width: size, height: size } : { viewDirs: viewDirs.map((dir) => [...dir]), size }
}),
deadline
@@ -25481,7 +25555,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
const derivative = await renderSceneToGLB(input.root, {
derivative: true
});
- const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits);
+ const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits, input.backdrop);
if (!result.ok)
throw new Error(result.reason);
if (!result.derivativeFidelityAttested || !result.inputGlbSha256)
@@ -25531,7 +25605,12 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: err instanceof Error ? err.message : String(err) };
}
const views = resolved.views;
- const shape = { preset: resolved.preset, cols: resolved.cols, cells: views.length };
+ const shape = {
+ preset: resolved.preset,
+ cols: resolved.cols,
+ cells: views.length,
+ backdrop: resolved.backdrop
+ };
let cameras;
if (resolved.zooms.some((z) => z !== undefined)) {
try {
@@ -25543,7 +25622,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
}
}
- const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits);
+ const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits, resolved.backdrop);
if (!result.ok)
return result;
try {
@@ -27288,6 +27367,7 @@ function resolveViewRenderTimeoutMs(input) {
// src/tools/registry.ts
init_evidence_history();
+init_background();
function proceduralTextureMaterialContract(rendered, context) {
const required = [...new Set(context.requiredProceduralTextureUsages ?? [])];
if (required.length === 0)
@@ -27400,7 +27480,7 @@ async function renderDerivativeCell(input, context) {
const derivativeReasonCodes = [];
if (context.viewRenderPort) {
await Promise.resolve().then(() => init_port());
- const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits);
+ const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits, input.backdrop);
if (ported.ok && ported.derivativeFidelityAttested) {
if (ported.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`validated derivative receipt hash mismatch (${ported.inputGlbSha256} != ${inputGlbSha256})`);
@@ -27448,6 +27528,7 @@ async function renderDerivativeCell(input, context) {
const produceFlat = async () => renderGlbViewCell(derivativeGlb, input.view, {
size: input.size,
camera,
+ ...input.backdrop ? { backdrop: input.backdrop } : {},
...input.backfaceCull !== undefined ? { backfaceCull: input.backfaceCull } : {},
...input.frameBounds ? { frameBounds: input.frameBounds } : {}
});
@@ -27456,7 +27537,8 @@ async function renderDerivativeCell(input, context) {
rendererId: CPU_RASTER_RENDERER_ID,
camera,
size: input.size,
- backfaceCull: input.backfaceCull ?? true
+ backfaceCull: input.backfaceCull ?? true,
+ ...input.backdrop ? { backdrop: input.backdrop } : {}
}, produceFlat) : await produceFlat();
if (flat.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`derivative GLB fallback hash mismatch (${flat.inputGlbSha256} != ${inputGlbSha256})`);
@@ -27529,6 +27611,7 @@ var renderInput = z4.object({
var screenshotInput = z4.object({
code: z4.string().describe("Kiln source code to execute and render to a six-view image grid.")
});
+var backdropInput = z4.enum(BACKDROP_IDS).optional().describe("Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.");
var legacyCaptureInput = z4.object({
preset: z4.enum(["1x1", "1x2", "2x1", "3x1", "2x2", "3x2", "3x3"]).optional().describe("Grid shape as COLSxROWS. Default 3x2. Choose fewer views for simple shapes, up to 3x3 for more angles."),
cells: z4.array(z4.object({
@@ -27536,7 +27619,8 @@ var legacyCaptureInput = z4.object({
elevationDeg: z4.number().describe("0 = eye level, positive looks down, negative from below. Clamped to -89..89."),
zoom: z4.number().optional().describe("Padding multiplier around the asset bounds for this cell only. Omit for the default framing; below 1 crops in, above 1 pulls back."),
name: z4.string().optional().describe("Cell label. Auto-derived from the angles if omitted.")
- })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall).")
+ })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall)."),
+ backdrop: backdropInput
}).optional().describe("Optional. Choose the contact-sheet shape and cameras. Omit it entirely for the standard six-view 3x2 grid, which is the right default for most assets.");
var cameraVec3Input = z4.array(z4.number()).length(3);
var orbitCameraError = (issue) => {
@@ -27591,7 +27675,8 @@ var advancedCaptureInput = z4.strictObject({
shots: z4.array(cameraShotInput).min(1).max(9),
cols: z4.number().int().min(1).max(3).optional(),
size: z4.number().int().min(128).max(1024).optional(),
- output: z4.enum(["grid", "separate"]).optional()
+ output: z4.enum(["grid", "separate"]).optional(),
+ backdrop: backdropInput
}, { error: advancedCaptureError });
function taggedCaptureError(issue) {
const input = issue.input;
@@ -28033,6 +28118,7 @@ async function runViewInterior(input, context) {
gridWidth: grid.width,
gridHeight: grid.height,
...grid.cameraShots ? { cameraShots: grid.cameraShots } : {},
+ ...grid.capture ? { capture: grid.capture } : {},
roofsHidden: grid.roofsHidden,
wallsHidden: grid.wallsHidden,
...input.capture?.output === "separate" && grid.perFramePngs ? { framesBase64: grid.perFramePngs.map((p) => p.toString("base64")) } : { pngBase64: grid.png.toString("base64") },
diff --git a/dist/build.json b/dist/build.json
index b16dc5c2..fa67f003 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:5f0e79fc996e99fc4551b17c06d9889133b77459493b83ef12592b453ec53f76",
+ "identity": "sha256:9ffd7a8ef43c2c658249518d0d8233f439e7aa248f652b805a68a7b78b8d8d87",
"engineVersion": "0.7.1",
"toolchain": "[email protected]",
- "sourceHash": "92c41a538190c8b8cfd2a32095baace5d4f80ad28930fd925235f22ad479e42a",
+ "sourceHash": "403cfb152580c49a4001fb16143afadfe3cc52a95d7bd6e2f52aad3e42d6fbad",
"dependencyHash": "363701eaf4938fc8f46405e6e92d0b36e218439c548b2427da0468edcc78a3dc",
"dependencies": {
"@gltf-transform/core": "4.5.0",
@@ -28,13 +28,13 @@
},
"target": "node",
"file": "evaluator-worker.mjs",
- "bundleHash": "sha256:791ac0f53486e31487bf731a24be45e74048436cec203d3d25c9df8343de374f"
+ "bundleHash": "sha256:7087ab40b40fdbd19a2bff3b7e050b10a4fb564acbc90c90a1d62def5df15762"
},
"agent-run": {
- "identity": "sha256:5f0e79fc996e99fc4551b17c06d9889133b77459493b83ef12592b453ec53f76",
+ "identity": "sha256:9ffd7a8ef43c2c658249518d0d8233f439e7aa248f652b805a68a7b78b8d8d87",
"engineVersion": "0.7.1",
"toolchain": "[email protected]",
- "sourceHash": "92c41a538190c8b8cfd2a32095baace5d4f80ad28930fd925235f22ad479e42a",
+ "sourceHash": "403cfb152580c49a4001fb16143afadfe3cc52a95d7bd6e2f52aad3e42d6fbad",
"dependencyHash": "363701eaf4938fc8f46405e6e92d0b36e218439c548b2427da0468edcc78a3dc",
"dependencies": {
"@gltf-transform/core": "4.5.0",
@@ -57,13 +57,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:4bbdfa2c89ce3f25cfb829be3aba0ff6ce5bf9c33a77a33355754af421935fad"
+ "bundleHash": "sha256:977cd5abb7ae0e1615a0637fd1bd903bb48e5bbd8c4707dd5c3be7e41290948e"
},
"agent-providers": {
- "identity": "sha256:5f0e79fc996e99fc4551b17c06d9889133b77459493b83ef12592b453ec53f76",
+ "identity": "sha256:9ffd7a8ef43c2c658249518d0d8233f439e7aa248f652b805a68a7b78b8d8d87",
"engineVersion": "0.7.1",
"toolchain": "[email protected]",
- "sourceHash": "92c41a538190c8b8cfd2a32095baace5d4f80ad28930fd925235f22ad479e42a",
+ "sourceHash": "403cfb152580c49a4001fb16143afadfe3cc52a95d7bd6e2f52aad3e42d6fbad",
"dependencyHash": "363701eaf4938fc8f46405e6e92d0b36e218439c548b2427da0468edcc78a3dc",
"dependencies": {
"@gltf-transform/core": "4.5.0",
@@ -89,10 +89,10 @@
"bundleHash": "sha256:fb2295599724eaa739ef31919eccae0ff6adece4c36b6886863eb7eeacb35650"
},
"mcp": {
- "identity": "sha256:5f0e79fc996e99fc4551b17c06d9889133b77459493b83ef12592b453ec53f76",
+ "identity": "sha256:9ffd7a8ef43c2c658249518d0d8233f439e7aa248f652b805a68a7b78b8d8d87",
"engineVersion": "0.7.1",
"toolchain": "[email protected]",
- "sourceHash": "92c41a538190c8b8cfd2a32095baace5d4f80ad28930fd925235f22ad479e42a",
+ "sourceHash": "403cfb152580c49a4001fb16143afadfe3cc52a95d7bd6e2f52aad3e42d6fbad",
"dependencyHash": "363701eaf4938fc8f46405e6e92d0b36e218439c548b2427da0468edcc78a3dc",
"dependencies": {
"@gltf-transform/core": "4.5.0",
@@ -115,13 +115,13 @@
},
"target": "node",
"file": "mcp-server.mjs",
- "bundleHash": "sha256:4372d66f8a03cd5ed9e5ce436713c74e490f3de2b8f5e5fed1b9e46a848f5230"
+ "bundleHash": "sha256:4189d4f5296c4c937b8f1df92305d98ef8c0e720bd45f92050c9043816e94f0c"
},
"cli": {
- "identity": "sha256:5f0e79fc996e99fc4551b17c06d9889133b77459493b83ef12592b453ec53f76",
+ "identity": "sha256:9ffd7a8ef43c2c658249518d0d8233f439e7aa248f652b805a68a7b78b8d8d87",
"engineVersion": "0.7.1",
"toolchain": "[email protected]",
- "sourceHash": "92c41a538190c8b8cfd2a32095baace5d4f80ad28930fd925235f22ad479e42a",
+ "sourceHash": "403cfb152580c49a4001fb16143afadfe3cc52a95d7bd6e2f52aad3e42d6fbad",
"dependencyHash": "363701eaf4938fc8f46405e6e92d0b36e218439c548b2427da0468edcc78a3dc",
"dependencies": {
"@gltf-transform/core": "4.5.0",
@@ -144,7 +144,7 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:ed8fac568a104daecb8e5a9c87f9aa7676d774098176d350b64a0d869de28b06"
+ "bundleHash": "sha256:dfceee6fe6c0a45abbc5db261ed85044cadae94916997de8ac5d4d6d0832a693"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index 322bc19c..7b332864 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -21619,9 +21619,30 @@ var init_capture_limits = __esm(() => {
});
// src/views/background.ts
-var GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX = "#1a1a1a";
+function isBackdropId(value) {
+ return typeof value === "string" && BACKDROP_IDS.includes(value);
+}
+function resolveBackdrop(id) {
+ if (id === undefined)
+ return BACKDROPS[DEFAULT_BACKDROP_ID];
+ if (!isBackdropId(id))
+ throw new Error(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(id)}).`);
+ return BACKDROPS[id];
+}
+var BACKDROP_IDS, DEFAULT_BACKDROP_ID = "neutral", define = (id, rgb) => Object.freeze({
+ id,
+ rgb: Object.freeze([...rgb]),
+ hex: `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`
+}), BACKDROPS, GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX;
var init_background = __esm(() => {
- GRID_BACKGROUND_RGB = [26, 26, 26];
+ BACKDROP_IDS = ["neutral", "dark", "light"];
+ BACKDROPS = Object.freeze({
+ neutral: define("neutral", [170, 177, 188]),
+ dark: define("dark", [26, 26, 26]),
+ light: define("light", [223, 227, 232])
+ });
+ GRID_BACKGROUND_RGB = BACKDROPS[DEFAULT_BACKDROP_ID].rgb;
+ GRID_BACKGROUND_HEX = BACKDROPS[DEFAULT_BACKDROP_ID].hex;
});
// src/views/raster.ts
@@ -21754,6 +21775,7 @@ function linearToSrgb(c) {
function rasterizeView(root, dir, opts = {}) {
const size = opts.size ?? 256;
const cull = opts.backfaceCull ?? true;
+ const BG = resolveBackdrop(opts.backdrop).rgb;
const { tris, bbox } = collectTriangles(root);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++) {
@@ -21878,7 +21900,7 @@ function hideNodeInScene(root, match) {
});
return hidden;
}
-var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, BG, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
+var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
var init_raster = __esm(() => {
init_background();
SIX_VIEWS = [
@@ -21893,7 +21915,6 @@ var init_raster = __esm(() => {
...SIX_VIEWS.slice(0, 5),
{ name: "3/4 Rear", dir: [-0.7, 0.5, -0.7] }
];
- BG = GRID_BACKGROUND_RGB;
KEY_DIR = normalize3([1.5, 2, 1]);
});
@@ -22147,14 +22168,15 @@ async function withCameraVisibility(root, shot, run) {
node.visible = visible;
}
}
-function rasterizeCamera(root, input, size = 384, backfaceCull = true) {
+function rasterizeCamera(root, input, size = 384, backfaceCull = true, backdrop) {
const camera = validateResolvedAssetCamera(input);
+ const bg = resolveBackdrop(backdrop).rgb;
if (!Number.isInteger(size) || size < 1 || size > 2048)
throw new Error("camera size must be an integer in 1..2048");
const z = vec(camera.position).sub(vec(camera.target)).normalize(), x = vec(camera.up).cross(z).normalize(), y = z.clone().cross(x), position = vec(camera.position);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++)
- out.set(GRID_BACKGROUND_RGB, i * 3);
+ out.set(bg, i * 3);
const depth = new Float64Array(size * size).fill(Infinity);
const clip = (points, plane, near) => {
const result = [];
@@ -22245,6 +22267,11 @@ function validatePbrRenderRequest(input) {
throw new TypeError("PbrRenderRequest.glb must be a non-empty Uint8Array");
}
const result = { glb: source.glb };
+ if (source.backdrop !== undefined) {
+ if (!isBackdropId(source.backdrop))
+ throw new TypeError(`PbrRenderRequest.backdrop must be one of ${BACKDROP_IDS.join(", ")}`);
+ result.backdrop = source.backdrop;
+ }
if (source.viewDirs !== undefined) {
if (!Array.isArray(source.viewDirs) || source.viewDirs.length < 1 || source.viewDirs.length > 12) {
throw new TypeError("PbrRenderRequest.viewDirs must contain 1..12 directions");
@@ -22363,7 +22390,9 @@ var PBR_REQUEST_KEYS;
var init_render_port = __esm(() => {
init_camera();
init_background();
+ init_background();
PBR_REQUEST_KEYS = new Set([
+ "backdrop",
"glb",
"viewDirs",
"size",
@@ -22489,7 +22518,8 @@ function createCachedRenderPort(port, options) {
size: request.size,
width: request.width,
height: request.height,
- lighting: request.lightingPresetId
+ lighting: request.lightingPresetId,
+ backdrop: request.backdrop
})));
const cells = [];
const missing = [];
@@ -22588,92 +22618,29 @@ var init_capture_cache = __esm(() => {
init_capture_limits();
});
-// src/views/camera-capture.ts
-function validateAdvancedCapture(config) {
- for (const key of Object.keys(config))
- if (!["version", "shots", "cols", "size", "output"].includes(key))
- throw new Error(`capture.${key} is unknown or incompatible with shots`);
- if (config.version !== "kiln.capture.v1")
- throw new Error("advanced capture requires version kiln.capture.v1");
- if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
- throw new Error("capture.shots must contain 1..9 shots");
- if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
- throw new Error("capture.cols must be 1..3");
- if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
- throw new Error("capture.size must be 128..1024");
- if (config.output !== undefined && !["grid", "separate"].includes(config.output))
- throw new Error("capture.output must be grid or separate");
-}
-async function renderCaptureGrid(root, config, render, limits) {
- validateAdvancedCapture(config);
- const shots = config.shots.map((s) => resolveAssetCamera(root, s));
- const size = config.size ?? 384;
- const cols = config.cols ?? Math.min(3, shots.length);
- enforceCapturePixels(shots.length, size, cols, limits);
- const cells = [];
- const perFramePngs = [];
- const derivativeReceipts = [];
- for (const shot of shots) {
- const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
- const view = { name: shot.name, dir };
- const png = await withCameraVisibility(root, shot, async () => {
- if (render) {
- const result = await render({ root, label: shot.name, view, size, camera: shot.camera });
- derivativeReceipts.push(result.receipt);
- return result.png;
- }
- return encodePng(rasterizeCamera(root, shot.camera, size), size, size);
- });
- const decoded = decodePng(png);
- if (decoded.width !== size || decoded.height !== size)
- throw new Error("capture cell dimensions do not match request");
- annotateViewCell(decoded.rgb, size, view);
- cells.push(decoded.rgb);
- perFramePngs.push(encodePng(decoded.rgb, size, size));
- }
- const { rgb, width, height } = compositeCellGrid(cells, size, cols);
- const png = encodePng(rgb, width, height);
- enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
- return {
- png,
- width,
- height,
- views: shots.map((s) => s.name),
- capture: { preset: `${cols}x${Math.ceil(shots.length / cols)}`, cols, cells: shots.length },
- cameraShots: shots,
- perFramePngs,
- derivativeReceipts,
- ...derivativeReceipts.length ? {
- captureCache: {
- hit: derivativeReceipts.every((r) => r.captureCache?.hit),
- reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
- total: derivativeReceipts.length
- }
- } : {}
- };
-}
-var init_camera_capture = __esm(() => {
- init_capture_limits();
- init_camera();
- init_png();
- init_grid();
- init_annotate();
-});
-
// src/views/capture.ts
function captureCellLabel(azimuthDeg, elevationDeg) {
const az = Math.round((azimuthDeg % 360 + 360) % 360);
const el = Math.round(elevationDeg);
return `A${az} ${el < 0 ? "D" : "U"}${Math.abs(el)}`;
}
+function resolveCaptureBackdrop(backdrop) {
+ if (backdrop === undefined)
+ return DEFAULT_BACKDROP_ID;
+ if (!isBackdropId(backdrop))
+ throw new CaptureConfigError(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(backdrop)}).`);
+ return backdrop;
+}
function resolveCapture(config) {
+ const backdrop = resolveCaptureBackdrop(config?.backdrop);
if (!config || config.preset === undefined && config.cells === undefined) {
return {
preset: DEFAULT_CAPTURE_PRESET,
views: PRESET_VIEWS[DEFAULT_CAPTURE_PRESET],
cols: PRESET_COLS[DEFAULT_CAPTURE_PRESET],
zooms: new Array(PRESET_CAPACITY[DEFAULT_CAPTURE_PRESET]).fill(undefined),
- isDefault: true
+ isDefault: true,
+ backdrop
};
}
const cells = config.cells;
@@ -22710,7 +22677,8 @@ function resolveCapture(config) {
})),
cols: PRESET_COLS[preset],
zooms: cells.map((c) => c.zoom),
- isDefault: false
+ isDefault: false,
+ backdrop
};
}
const chosen = preset;
@@ -22719,7 +22687,8 @@ function resolveCapture(config) {
views: PRESET_VIEWS[chosen],
cols: PRESET_COLS[chosen],
zooms: new Array(PRESET_VIEWS[chosen].length).fill(undefined),
- isDefault: chosen === DEFAULT_CAPTURE_PRESET
+ isDefault: chosen === DEFAULT_CAPTURE_PRESET,
+ backdrop
};
}
function resolveGridCapture(config, envVariant) {
@@ -22732,6 +22701,7 @@ function resolveGridCapture(config, envVariant) {
var CAPTURE_PRESETS, DEFAULT_CAPTURE_PRESET = "3x2", MAX_CAPTURE_CELLS = 9, PRESET_COLS, PRESET_CAPACITY, BOTTOM, THREE_QUARTER_REAR, THREE_QUARTER_LOW, PRESET_VIEWS, CaptureConfigError;
var init_capture = __esm(() => {
init_raster();
+ init_background();
CAPTURE_PRESETS = [
"1x1",
"1x2",
@@ -22775,6 +22745,93 @@ var init_capture = __esm(() => {
};
});
+// src/views/camera-capture.ts
+function validateAdvancedCapture(config) {
+ for (const key of Object.keys(config))
+ if (!["version", "shots", "cols", "size", "output", "backdrop"].includes(key))
+ throw new Error(`capture.${key} is unknown or incompatible with shots`);
+ if (config.version !== "kiln.capture.v1")
+ throw new Error("advanced capture requires version kiln.capture.v1");
+ if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
+ throw new Error("capture.shots must contain 1..9 shots");
+ if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
+ throw new Error("capture.cols must be 1..3");
+ if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
+ throw new Error("capture.size must be 128..1024");
+ if (config.output !== undefined && !["grid", "separate"].includes(config.output))
+ throw new Error("capture.output must be grid or separate");
+ resolveCaptureBackdrop(config.backdrop);
+}
+async function renderCaptureGrid(root, config, render, limits) {
+ validateAdvancedCapture(config);
+ const shots = config.shots.map((s) => resolveAssetCamera(root, s));
+ const size = config.size ?? 384;
+ const cols = config.cols ?? Math.min(3, shots.length);
+ const backdrop = resolveCaptureBackdrop(config.backdrop);
+ enforceCapturePixels(shots.length, size, cols, limits);
+ const cells = [];
+ const perFramePngs = [];
+ const derivativeReceipts = [];
+ for (const shot of shots) {
+ const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
+ const view = { name: shot.name, dir };
+ const png = await withCameraVisibility(root, shot, async () => {
+ if (render) {
+ const result = await render({
+ root,
+ label: shot.name,
+ view,
+ size,
+ camera: shot.camera,
+ backdrop
+ });
+ derivativeReceipts.push(result.receipt);
+ return result.png;
+ }
+ return encodePng(rasterizeCamera(root, shot.camera, size, true, backdrop), size, size);
+ });
+ const decoded = decodePng(png);
+ if (decoded.width !== size || decoded.height !== size)
+ throw new Error("capture cell dimensions do not match request");
+ annotateViewCell(decoded.rgb, size, view);
+ cells.push(decoded.rgb);
+ perFramePngs.push(encodePng(decoded.rgb, size, size));
+ }
+ const { rgb, width, height } = compositeCellGrid(cells, size, cols);
+ const png = encodePng(rgb, width, height);
+ enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
+ return {
+ png,
+ width,
+ height,
+ views: shots.map((s) => s.name),
+ capture: {
+ preset: `${cols}x${Math.ceil(shots.length / cols)}`,
+ cols,
+ cells: shots.length,
+ backdrop
+ },
+ cameraShots: shots,
+ perFramePngs,
+ derivativeReceipts,
+ ...derivativeReceipts.length ? {
+ captureCache: {
+ hit: derivativeReceipts.every((r) => r.captureCache?.hit),
+ reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
+ total: derivativeReceipts.length
+ }
+ } : {}
+ };
+}
+var init_camera_capture = __esm(() => {
+ init_capture_limits();
+ init_camera();
+ init_capture();
+ init_png();
+ init_grid();
+ init_annotate();
+});
+
// src/views/architecture.ts
function nodeRoles(node) {
return readSemanticMetadataV1FromExtras(node.userData ?? {})?.roles ?? [];
@@ -23923,6 +23980,7 @@ async function renderViewGrid(root, opts = {}) {
snapSceneToPalette(root, opts.snapPalette);
const wantsZoom = resolved.zooms.some((z) => z !== undefined);
const sceneBounds = wantsZoom ? measureBounds(root) : undefined;
+ const backdrop = opts.backdrop ?? resolved.backdrop;
const cache = opts.snapPalette?.length ? undefined : opts.captureCache;
let reused = 0;
const cells = [];
@@ -23931,6 +23989,7 @@ async function renderViewGrid(root, opts = {}) {
const rasterOptions = {
size,
backfaceCull: opts.backfaceCull,
+ backdrop,
...opts.frameBounds ? { frameBounds: opts.frameBounds } : {},
...sceneBounds && zoom !== undefined ? { frameBounds: expandFrameBounds(sceneBounds, zoom) } : {}
};
@@ -23943,7 +24002,8 @@ async function renderViewGrid(root, opts = {}) {
rendererId: `${CPU_RASTER_RENDERER_ID}/legacy-fit`,
camera: camera2,
size,
- backfaceCull: opts.backfaceCull ?? true
+ backfaceCull: opts.backfaceCull ?? true,
+ backdrop
}, async () => ({
png: encodePng(rasterizeView(root, views[vi].dir, rasterOptions), size, size),
width: size,
@@ -23969,7 +24029,7 @@ async function renderViewGrid(root, opts = {}) {
width,
height,
views: views.map((v) => v.name),
- capture: { preset: resolved.preset, cols, cells: views.length },
+ capture: { preset: resolved.preset, cols, cells: views.length, backdrop },
...cache && opts.artifactGlbSha256 ? { captureCache: { hit: reused === views.length, reused, total: views.length } } : {}
};
}
@@ -23982,8 +24042,9 @@ async function renderGlbViewCell(bytes, view, options = {}) {
const exactBytes = Uint8Array.from(bytes);
const loaded = await loadGlbGeometryFlatScene(exactBytes);
const size = options.size ?? 256;
- const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull) : rasterizeView(loaded.root, view.dir, {
+ const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull, options.backdrop) : rasterizeView(loaded.root, view.dir, {
size,
+ ...options.backdrop ? { backdrop: options.backdrop } : {},
...options.backfaceCull !== undefined ? { backfaceCull: options.backfaceCull } : {},
...options.frameBounds ? { frameBounds: options.frameBounds } : {}
});
@@ -24200,6 +24261,12 @@ async function renderInteriorGrid(root, opts = {}) {
width,
height,
views: INTERIOR_VIEWS.map((v) => v.name),
+ capture: {
+ preset: "interior",
+ cols: INTERIOR_VIEWS.length,
+ cells: INTERIOR_VIEWS.length,
+ backdrop: DEFAULT_BACKDROP_ID
+ },
roofsHidden,
wallsHidden,
...derivativeReceipts.length ? { derivativeReceipts } : {}
@@ -24208,6 +24275,7 @@ async function renderInteriorGrid(root, opts = {}) {
var ANIM_CAMERAS, ANIM_CAMERA_ALIASES, ROOM_WALL_NORMALS, INTERIOR_VIEWS;
var init_views = __esm(() => {
init_capture_limits();
+ init_background();
init_capture_limits();
init_capture_cache();
init_camera();
@@ -26645,6 +26713,7 @@ function decodeAssetBundle(bytes) {
}
var ASSET_LIMIT, assetIdSchema, hash, assetManifestSchema, allowedFiles;
var init_assets = __esm(() => {
+ init_background();
ASSET_LIMIT = 64 * 1024 * 1024;
assetIdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/);
hash = z.string().regex(/^sha256:[a-f0-9]{64}$/);
@@ -26674,7 +26743,11 @@ var init_assets = __esm(() => {
dependencies: z.array(z.unknown()).optional(),
rebuild: z.enum(["engine-required", "external-dependencies-required"])
}).optional(),
- preview: z.object({ fidelity: z.unknown().optional(), error: z.string().optional() }).optional()
+ preview: z.object({
+ fidelity: z.unknown().optional(),
+ error: z.string().optional(),
+ backdrop: z.enum(BACKDROP_IDS).optional()
+ }).optional()
});
allowedFiles = new Set(["asset.glb", "source.kiln.js", "preview.png"]);
});
@@ -27181,7 +27254,7 @@ async function sha256Bytes(bytes) {
const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", input));
return `sha256:${[...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
}
-async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits) {
+async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits, backdrop) {
let timer;
try {
const exactCameras = cameras?.map(validateResolvedAssetCamera);
@@ -27195,6 +27268,7 @@ async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, came
const result = await Promise.race([
port({
glb: requestGlb,
+ ...backdrop ? { backdrop } : {},
...exactCameras ? { cameras: exactCameras, width: size, height: size } : { viewDirs: viewDirs.map((dir) => [...dir]), size }
}),
deadline
@@ -27267,7 +27341,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
const derivative = await renderSceneToGLB(input.root, {
derivative: true
});
- const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits);
+ const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits, input.backdrop);
if (!result.ok)
throw new Error(result.reason);
if (!result.derivativeFidelityAttested || !result.inputGlbSha256)
@@ -27317,7 +27391,12 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: err instanceof Error ? err.message : String(err) };
}
const views = resolved.views;
- const shape = { preset: resolved.preset, cols: resolved.cols, cells: views.length };
+ const shape = {
+ preset: resolved.preset,
+ cols: resolved.cols,
+ cells: views.length,
+ backdrop: resolved.backdrop
+ };
let cameras;
if (resolved.zooms.some((z) => z !== undefined)) {
try {
@@ -27329,7 +27408,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
}
}
- const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits);
+ const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits, resolved.backdrop);
if (!result.ok)
return result;
try {
@@ -27887,7 +27966,7 @@ async function renderDerivativeCell(input, context) {
const derivativeReasonCodes = [];
if (context.viewRenderPort) {
await Promise.resolve().then(() => init_port());
- const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits);
+ const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits, input.backdrop);
if (ported.ok && ported.derivativeFidelityAttested) {
if (ported.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`validated derivative receipt hash mismatch (${ported.inputGlbSha256} != ${inputGlbSha256})`);
@@ -27935,6 +28014,7 @@ async function renderDerivativeCell(input, context) {
const produceFlat = async () => renderGlbViewCell(derivativeGlb, input.view, {
size: input.size,
camera,
+ ...input.backdrop ? { backdrop: input.backdrop } : {},
...input.backfaceCull !== undefined ? { backfaceCull: input.backfaceCull } : {},
...input.frameBounds ? { frameBounds: input.frameBounds } : {}
});
@@ -27943,7 +28023,8 @@ async function renderDerivativeCell(input, context) {
rendererId: CPU_RASTER_RENDERER_ID,
camera,
size: input.size,
- backfaceCull: input.backfaceCull ?? true
+ backfaceCull: input.backfaceCull ?? true,
+ ...input.backdrop ? { backdrop: input.backdrop } : {}
}, produceFlat) : await produceFlat();
if (flat.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`derivative GLB fallback hash mismatch (${flat.inputGlbSha256} != ${inputGlbSha256})`);
@@ -28417,6 +28498,7 @@ async function runViewInterior(input, context) {
gridWidth: grid.width,
gridHeight: grid.height,
...grid.cameraShots ? { cameraShots: grid.cameraShots } : {},
+ ...grid.capture ? { capture: grid.capture } : {},
roofsHidden: grid.roofsHidden,
wallsHidden: grid.wallsHidden,
...input.capture?.output === "separate" && grid.perFramePngs ? { framesBase64: grid.perFramePngs.map((p) => p.toString("base64")) } : { pngBase64: grid.png.toString("base64") },
@@ -28770,7 +28852,8 @@ function createKilnAssetDefs(context) {
model: z4.string().max(200).optional(),
harness: z4.string().max(200).optional(),
author: z4.string().max(200).optional()
- }).optional()
+ }).optional(),
+ backdrop: z4.enum(BACKDROP_IDS).optional().describe("Preview backdrop: the one the reviewed sheet used.")
});
const assetsInput = z4.object({
action: z4.enum(["collections", "list", "get", "restore"]).default("list"),
@@ -28792,24 +28875,27 @@ function createKilnAssetDefs(context) {
return [
{
name: "kiln_save",
- description: "Save a completed source revision into the user-requested collection, or project when no destination was requested. Persists its exact GLB, source, preview, and build record. Discover destinations with kiln_assets action=collections. Use programRef returned by render/edit. To revise an existing asset, supply its assetId and parentRevision; previous revisions remain intact. Returns downloadable resources. Draft renders do not populate collections.",
+ description: "Save a completed source revision into the user-requested collection, or project when none was requested. Persists exact GLB, source, preview and build record. Use programRef returned by render/edit. To revise an asset, pass assetId and parentRevision; earlier revisions stay intact. Returns downloadable resources; draft renders never populate collections.",
inputSchema: saveInput,
run: async (raw) => {
- const input = saveInput.parse(raw);
+ const { backdrop, ...input } = saveInput.parse(raw);
const target = library();
const code = await context.programStore.get(input.programRef);
const rendered = await evaluateGeneratedSource(code, context);
let preview;
let previewInfo;
try {
- const result = await runRenderViews({ code }, {
- ...context,
- evaluatorPort: { render: async () => rendered }
- });
+ const result = await runRenderViews({
+ code,
+ ...backdrop ? { capture: { backdrop } } : {}
+ }, { ...context, evaluatorPort: { render: async () => rendered } });
if (!result.ok || !result.pngBase64)
throw new Error(result.error ?? "Preview unavailable");
preview = Uint8Array.from(Buffer.from(result.pngBase64, "base64"));
- previewInfo = { fidelity: result.viewFidelity };
+ previewInfo = {
+ fidelity: result.viewFidelity,
+ backdrop: result.capture?.backdrop ?? DEFAULT_BACKDROP_ID
+ };
} catch (error) {
previewInfo = {
error: error instanceof Error ? error.message : String(error)
@@ -28966,7 +29052,7 @@ function createKilnAssetDefs(context) {
}
];
}
-var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html", DEFAULT_INLOOP_VIEW_RENDER_TIMEOUT_MS = 6000, viewEvidenceHistoryByContext, VIEW_EVIDENCE_GUIDANCE = " viewEvidence.current describes ONLY this request. lastFaithful is older hash-only evidence for reference, not reused pixels and not current verification.", listPrimitivesInput, validateInput, renderInput, screenshotInput, legacyCaptureInput, cameraVec3Input, orbitCameraError = (issue) => {
+var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html", DEFAULT_INLOOP_VIEW_RENDER_TIMEOUT_MS = 6000, viewEvidenceHistoryByContext, VIEW_EVIDENCE_GUIDANCE = " viewEvidence.current describes ONLY this request. lastFaithful is older hash-only evidence for reference, not reused pixels and not current verification.", listPrimitivesInput, validateInput, renderInput, screenshotInput, backdropInput, legacyCaptureInput, cameraVec3Input, orbitCameraError = (issue) => {
if (issue.code === "unrecognized_keys" && issue.keys?.some((key) => key === "target" || key === "distance")) {
return "Orbit cameras derive target and distance from the selected subject bounds; choose subject and padding, or use an explicit camera with position and target.";
}
@@ -28993,6 +29079,7 @@ var init_registry2 = __esm(() => {
init_edit_buffer();
init_view_render_timeout();
init_evidence_history();
+ init_background();
viewEvidenceHistoryByContext = new WeakMap;
listPrimitivesInput = z4.object({
category: z4.string().optional().describe("Optional category filter: geometry, material, structure, animation, utility, instancing, csg, arrays, mesh-ops, curves, uv, textures.")
@@ -29006,6 +29093,7 @@ var init_registry2 = __esm(() => {
screenshotInput = z4.object({
code: z4.string().describe("Kiln source code to execute and render to a six-view image grid.")
});
+ backdropInput = z4.enum(BACKDROP_IDS).optional().describe("Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.");
legacyCaptureInput = z4.object({
preset: z4.enum(["1x1", "1x2", "2x1", "3x1", "2x2", "3x2", "3x3"]).optional().describe("Grid shape as COLSxROWS. Default 3x2. Choose fewer views for simple shapes, up to 3x3 for more angles."),
cells: z4.array(z4.object({
@@ -29013,7 +29101,8 @@ var init_registry2 = __esm(() => {
elevationDeg: z4.number().describe("0 = eye level, positive looks down, negative from below. Clamped to -89..89."),
zoom: z4.number().optional().describe("Padding multiplier around the asset bounds for this cell only. Omit for the default framing; below 1 crops in, above 1 pulls back."),
name: z4.string().optional().describe("Cell label. Auto-derived from the angles if omitted.")
- })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall).")
+ })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall)."),
+ backdrop: backdropInput
}).optional().describe("Optional. Choose the contact-sheet shape and cameras. Omit it entirely for the standard six-view 3x2 grid, which is the right default for most assets.");
cameraVec3Input = z4.array(z4.number()).length(3);
cameraShotInput = z4.object({
@@ -29056,7 +29145,8 @@ var init_registry2 = __esm(() => {
shots: z4.array(cameraShotInput).min(1).max(9),
cols: z4.number().int().min(1).max(3).optional(),
size: z4.number().int().min(128).max(1024).optional(),
- output: z4.enum(["grid", "separate"]).optional()
+ output: z4.enum(["grid", "separate"]).optional(),
+ backdrop: backdropInput
}, { error: advancedCaptureError });
captureInput = z4.union([
advancedCaptureInput,
@@ -29256,10 +29346,9 @@ function makeRemoteRenderPort(url, token) {
if (req.lightingPresetId)
body["lighting_preset_id"] = req.lightingPresetId;
}
- if (req.viewDirs) {
+ if (req.viewDirs)
body["views"] = req.viewDirs;
- body["background"] = GRID_BACKGROUND_HEX;
- }
+ body["backdrop"] = req.backdrop ?? DEFAULT_BACKDROP_ID;
if (req.size !== undefined)
body["size"] = req.size;
if (req.beautySize !== undefined)
@@ -29777,7 +29866,8 @@ async function assetMain(argv) {
"format",
"profile",
"port",
- "render"
+ "render",
+ "backdrop"
]);
for (let i = 1;i < argv.length; i++) {
const arg = argv[i];
@@ -29850,7 +29940,8 @@ async function assetMain(argv) {
parentRevision: flags.parent,
description: flags.description,
brief: flags.brief,
- tags
+ tags,
+ backdrop: flags.backdrop
}), null, 2));
} else if (command === "asset" || command === "export") {
const [assetId, revisionId] = positional;
@@ -29940,6 +30031,7 @@ var ASSET_USAGE = `
ASSETS & VIEWER
kiln save <source.js|programRef> --name <name> [--collection project]
[--asset <id> --parent <revision>] [--description <text>] [--tag <tag>]
+ [--backdrop neutral|dark|light] preview backdrop; the one the reviewed sheet used
kiln collections list configured collection names
kiln collections add <name> <directory> remember another collection root
kiln assets [--collection project] list saved revisions (JSON)
@@ -29991,7 +30083,9 @@ function isDirectEntry(moduleUrl) {
// src/cli.ts
init_local_runtime();
init_registry2();
+init_background();
init_cli_render_mode();
+init_render_service_host();
init_program_store_node();
init_program_store();
init_asset_cli();
@@ -30007,6 +30101,7 @@ OPTIONS
--out <path> GLB output path (default: out.glb)
--views <path> contact sheet PNG path (default: none)
--capture <file.json> camera recipe for --views (grid output; max 1 MiB)
+ --backdrop <id> neutral | dark | light (default: neutral)
--render <mode> auto | cpu | gpu (default: auto)
--render-port <url> remote GPU render service
--model <id> model id for generate (default: env KILN_MODEL)
@@ -30019,6 +30114,7 @@ EXAMPLES
kiln generate "a weathered wooden crate" --out crate.glb --views sheet.png
kiln render examples/crate.kiln.js --render cpu --views sheet.png
kiln render p_RETURNED_HANDLE --capture cameras.json --views chosen.png
+ kiln render examples/crate.kiln.js --views sheet.png --backdrop light
`;
function parseArgs(argv) {
const args = {
@@ -30027,6 +30123,7 @@ function parseArgs(argv) {
out: undefined,
views: undefined,
capture: undefined,
+ backdrop: undefined,
render: "auto",
renderPort: undefined,
model: process.env["KILN_MODEL"],
@@ -30056,6 +30153,13 @@ function parseArgs(argv) {
case "--capture":
args.capture = next();
break;
+ case "--backdrop": {
+ const id = next();
+ if (!isBackdropId(id))
+ throw new Error(`--backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${id})`);
+ args.backdrop = id;
+ break;
+ }
case "--render":
args.render = resolveRenderMode(next());
break;
@@ -30118,6 +30222,16 @@ async function readCaptureRecipe(args) {
throw new Error("--capture supports grid output only for one --views PNG. Set output to grid.");
return capture;
}
+function applyBackdrop(args) {
+ if (args.backdrop === undefined)
+ return args.captureRecipe;
+ if (!args.views)
+ throw new Error("--backdrop requires --views <output.png>.");
+ if (args.command !== "render" && args.command !== "generate")
+ throw new Error("--backdrop is supported by render and generate only.");
+ const recipe = args.captureRecipe ?? {};
+ return { ...recipe, backdrop: args.backdrop };
+}
async function emit(code, args, context) {
context.programStore ??= localProgramStore();
const programRef = await retainProgram(context.programStore, code);
@@ -30259,7 +30373,7 @@ async function withProcessAlive(run) {
}
}
function main(argv) {
- return withProcessAlive(() => runMain(argv));
+ return withProcessAlive(() => runMain(argv)).finally(stopLocalRenderService);
}
async function runMain(argv) {
if (["save", "collections", "assets", "asset", "export", "import", "view"].includes(argv[0] ?? "")) {
@@ -30284,6 +30398,7 @@ async function runMain(argv) {
try {
if (args.capture !== undefined)
args.captureRecipe = await readCaptureRecipe(args);
+ args.captureRecipe = applyBackdrop(args);
switch (args.command) {
case "source":
return await cmdSource(args);
diff --git a/dist/evaluator-worker.mjs b/dist/evaluator-worker.mjs
index a512cbe5..d8ee2567 100644
--- a/dist/evaluator-worker.mjs
+++ b/dist/evaluator-worker.mjs
@@ -20730,9 +20730,30 @@ var init_capture_limits = __esm(() => {
});
// src/views/background.ts
-var GRID_BACKGROUND_RGB;
+function isBackdropId(value) {
+ return typeof value === "string" && BACKDROP_IDS.includes(value);
+}
+function resolveBackdrop(id) {
+ if (id === undefined)
+ return BACKDROPS[DEFAULT_BACKDROP_ID];
+ if (!isBackdropId(id))
+ throw new Error(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(id)}).`);
+ return BACKDROPS[id];
+}
+var BACKDROP_IDS, DEFAULT_BACKDROP_ID = "neutral", define = (id, rgb) => Object.freeze({
+ id,
+ rgb: Object.freeze([...rgb]),
+ hex: `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`
+}), BACKDROPS, GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX;
var init_background = __esm(() => {
- GRID_BACKGROUND_RGB = [26, 26, 26];
+ BACKDROP_IDS = ["neutral", "dark", "light"];
+ BACKDROPS = Object.freeze({
+ neutral: define("neutral", [170, 177, 188]),
+ dark: define("dark", [26, 26, 26]),
+ light: define("light", [223, 227, 232])
+ });
+ GRID_BACKGROUND_RGB = BACKDROPS[DEFAULT_BACKDROP_ID].rgb;
+ GRID_BACKGROUND_HEX = BACKDROPS[DEFAULT_BACKDROP_ID].hex;
});
// src/views/raster.ts
@@ -20854,6 +20875,7 @@ function linearToSrgb(c) {
function rasterizeView(root, dir, opts = {}) {
const size = opts.size ?? 256;
const cull = opts.backfaceCull ?? true;
+ const BG = resolveBackdrop(opts.backdrop).rgb;
const { tris, bbox } = collectTriangles(root);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++) {
@@ -20959,7 +20981,7 @@ function measureBounds(root) {
const { bbox } = collectTriangles(root);
return { min: [...bbox.min], max: [...bbox.max] };
}
-var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, BG, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
+var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
var init_raster = __esm(() => {
init_background();
SIX_VIEWS = [
@@ -20974,7 +20996,6 @@ var init_raster = __esm(() => {
...SIX_VIEWS.slice(0, 5),
{ name: "3/4 Rear", dir: [-0.7, 0.5, -0.7] }
];
- BG = GRID_BACKGROUND_RGB;
KEY_DIR = normalize3([1.5, 2, 1]);
});
@@ -21228,14 +21249,15 @@ async function withCameraVisibility(root, shot, run) {
node.visible = visible;
}
}
-function rasterizeCamera(root, input, size = 384, backfaceCull = true) {
+function rasterizeCamera(root, input, size = 384, backfaceCull = true, backdrop) {
const camera = validateResolvedAssetCamera(input);
+ const bg = resolveBackdrop(backdrop).rgb;
if (!Number.isInteger(size) || size < 1 || size > 2048)
throw new Error("camera size must be an integer in 1..2048");
const z = vec(camera.position).sub(vec(camera.target)).normalize(), x = vec(camera.up).cross(z).normalize(), y = z.clone().cross(x), position = vec(camera.position);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++)
- out.set(GRID_BACKGROUND_RGB, i * 3);
+ out.set(bg, i * 3);
const depth = new Float64Array(size * size).fill(Infinity);
const clip = (points, plane, near) => {
const result = [];
@@ -21306,7 +21328,9 @@ var PBR_REQUEST_KEYS;
var init_render_port = __esm(() => {
init_camera();
init_background();
+ init_background();
PBR_REQUEST_KEYS = new Set([
+ "backdrop",
"glb",
"viewDirs",
"size",
@@ -21325,19 +21349,11 @@ var init_capture_cache = __esm(() => {
init_capture_limits();
});
-// src/views/camera-capture.ts
-var init_camera_capture = __esm(() => {
- init_capture_limits();
- init_camera();
- init_png();
- init_grid();
- init_annotate();
-});
-
// src/views/capture.ts
var BOTTOM, THREE_QUARTER_REAR, THREE_QUARTER_LOW, PRESET_VIEWS;
var init_capture = __esm(() => {
init_raster();
+ init_background();
BOTTOM = { name: "BOTTOM", dir: [0, -1, 0.0001] };
THREE_QUARTER_REAR = { name: "REAR 34", dir: [-0.7, 0.5, -0.7] };
THREE_QUARTER_LOW = { name: "LOW 34", dir: [0.7, -0.35, 0.7] };
@@ -21352,6 +21368,16 @@ var init_capture = __esm(() => {
};
});
+// src/views/camera-capture.ts
+var init_camera_capture = __esm(() => {
+ init_capture_limits();
+ init_camera();
+ init_capture();
+ init_png();
+ init_grid();
+ init_annotate();
+});
+
// src/views/architecture.ts
var ARCHITECTURE_ROOF_ROLE_PREFIXES;
var init_architecture3 = __esm(() => {
@@ -21991,6 +22017,7 @@ async function renderClipAnimation(root, clips, opts = {}) {
var ANIM_CAMERAS, ANIM_CAMERA_ALIASES;
var init_views = __esm(() => {
init_capture_limits();
+ init_background();
init_capture_limits();
init_capture_cache();
init_camera();
diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjs
index 5a82ad83..10e92598 100644
--- a/dist/mcp-server.mjs
+++ b/dist/mcp-server.mjs
@@ -26,6 +26,33 @@ var __esm = (fn, res, err) => () => {
return res;
};
+// src/views/background.ts
+function isBackdropId(value) {
+ return typeof value === "string" && BACKDROP_IDS.includes(value);
+}
+function resolveBackdrop(id) {
+ if (id === undefined)
+ return BACKDROPS[DEFAULT_BACKDROP_ID];
+ if (!isBackdropId(id))
+ throw new Error(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(id)}).`);
+ return BACKDROPS[id];
+}
+var BACKDROP_IDS, DEFAULT_BACKDROP_ID = "neutral", define = (id, rgb) => Object.freeze({
+ id,
+ rgb: Object.freeze([...rgb]),
+ hex: `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`
+}), BACKDROPS, GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX;
+var init_background = __esm(() => {
+ BACKDROP_IDS = ["neutral", "dark", "light"];
+ BACKDROPS = Object.freeze({
+ neutral: define("neutral", [170, 177, 188]),
+ dark: define("dark", [26, 26, 26]),
+ light: define("light", [223, 227, 232])
+ });
+ GRID_BACKGROUND_RGB = BACKDROPS[DEFAULT_BACKDROP_ID].rgb;
+ GRID_BACKGROUND_HEX = BACKDROPS[DEFAULT_BACKDROP_ID].hex;
+});
+
// src/assets.ts
import { z } from "zod";
import { zipSync, unzipSync } from "three/addons/libs/fflate.module.js";
@@ -83,6 +110,7 @@ function encodeAssetBundle(records) {
}
var ASSET_LIMIT, assetIdSchema, hash, assetManifestSchema, allowedFiles;
var init_assets = __esm(() => {
+ init_background();
ASSET_LIMIT = 64 * 1024 * 1024;
assetIdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/);
hash = z.string().regex(/^sha256:[a-f0-9]{64}$/);
@@ -112,7 +140,11 @@ var init_assets = __esm(() => {
dependencies: z.array(z.unknown()).optional(),
rebuild: z.enum(["engine-required", "external-dependencies-required"])
}).optional(),
- preview: z.object({ fidelity: z.unknown().optional(), error: z.string().optional() }).optional()
+ preview: z.object({
+ fidelity: z.unknown().optional(),
+ error: z.string().optional(),
+ backdrop: z.enum(BACKDROP_IDS).optional()
+ }).optional()
});
allowedFiles = new Set(["asset.glb", "source.kiln.js", "preview.png"]);
});
@@ -212,12 +244,6 @@ var init_asset_export = __esm(() => {
decoder = new TextDecoder;
});
-// src/views/background.ts
-var GRID_BACKGROUND_RGB, GRID_BACKGROUND_HEX = "#1a1a1a";
-var init_background = __esm(() => {
- GRID_BACKGROUND_RGB = [26, 26, 26];
-});
-
// src/views/raster.ts
function orbitDir(azimuthDeg, elevationDeg) {
const el = Math.min(MAX_ELEVATION_DEG, Math.max(MIN_ELEVATION_DEG, elevationDeg)) * Math.PI / 180;
@@ -348,6 +374,7 @@ function linearToSrgb(c) {
function rasterizeView(root, dir, opts = {}) {
const size = opts.size ?? 256;
const cull = opts.backfaceCull ?? true;
+ const BG = resolveBackdrop(opts.backdrop).rgb;
const { tris, bbox } = collectTriangles(root);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++) {
@@ -472,7 +499,7 @@ function hideNodeInScene(root, match) {
});
return hidden;
}
-var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, BG, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
+var SIX_VIEWS, SIX_VIEWS_REAR_QUARTER, MIN_ELEVATION_DEG = -89, MAX_ELEVATION_DEG = 89, AMBIENT = 0.25, KEY_INTENSITY = 1.1, KEY_DIR;
var init_raster = __esm(() => {
init_background();
SIX_VIEWS = [
@@ -487,7 +514,6 @@ var init_raster = __esm(() => {
...SIX_VIEWS.slice(0, 5),
{ name: "3/4 Rear", dir: [-0.7, 0.5, -0.7] }
];
- BG = GRID_BACKGROUND_RGB;
KEY_DIR = normalize([1.5, 2, 1]);
});
@@ -741,14 +767,15 @@ async function withCameraVisibility(root, shot, run) {
node.visible = visible;
}
}
-function rasterizeCamera(root, input, size = 384, backfaceCull = true) {
+function rasterizeCamera(root, input, size = 384, backfaceCull = true, backdrop) {
const camera = validateResolvedAssetCamera(input);
+ const bg = resolveBackdrop(backdrop).rgb;
if (!Number.isInteger(size) || size < 1 || size > 2048)
throw new Error("camera size must be an integer in 1..2048");
const z = vec(camera.position).sub(vec(camera.target)).normalize(), x = vec(camera.up).cross(z).normalize(), y = z.clone().cross(x), position = vec(camera.position);
const out = new Uint8Array(size * size * 3);
for (let i = 0;i < size * size; i++)
- out.set(GRID_BACKGROUND_RGB, i * 3);
+ out.set(bg, i * 3);
const depth = new Float64Array(size * size).fill(Infinity);
const clip = (points, plane, near) => {
const result = [];
@@ -839,6 +866,11 @@ function validatePbrRenderRequest(input) {
throw new TypeError("PbrRenderRequest.glb must be a non-empty Uint8Array");
}
const result = { glb: source.glb };
+ if (source.backdrop !== undefined) {
+ if (!isBackdropId(source.backdrop))
+ throw new TypeError(`PbrRenderRequest.backdrop must be one of ${BACKDROP_IDS.join(", ")}`);
+ result.backdrop = source.backdrop;
+ }
if (source.viewDirs !== undefined) {
if (!Array.isArray(source.viewDirs) || source.viewDirs.length < 1 || source.viewDirs.length > 12) {
throw new TypeError("PbrRenderRequest.viewDirs must contain 1..12 directions");
@@ -957,7 +989,9 @@ var PBR_REQUEST_KEYS;
var init_render_port = __esm(() => {
init_camera();
init_background();
+ init_background();
PBR_REQUEST_KEYS = new Set([
+ "backdrop",
"glb",
"viewDirs",
"size",
@@ -1664,7 +1698,8 @@ function createCachedRenderPort(port, options) {
size: request.size,
width: request.width,
height: request.height,
- lighting: request.lightingPresetId
+ lighting: request.lightingPresetId,
+ backdrop: request.backdrop
})));
const cells = [];
const missing = [];
@@ -22684,92 +22719,29 @@ var init_diagnostic = __esm(() => {
IDENTITY = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
});
-// src/views/camera-capture.ts
-function validateAdvancedCapture(config) {
- for (const key of Object.keys(config))
- if (!["version", "shots", "cols", "size", "output"].includes(key))
- throw new Error(`capture.${key} is unknown or incompatible with shots`);
- if (config.version !== "kiln.capture.v1")
- throw new Error("advanced capture requires version kiln.capture.v1");
- if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
- throw new Error("capture.shots must contain 1..9 shots");
- if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
- throw new Error("capture.cols must be 1..3");
- if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
- throw new Error("capture.size must be 128..1024");
- if (config.output !== undefined && !["grid", "separate"].includes(config.output))
- throw new Error("capture.output must be grid or separate");
-}
-async function renderCaptureGrid(root, config, render, limits) {
- validateAdvancedCapture(config);
- const shots = config.shots.map((s) => resolveAssetCamera(root, s));
- const size = config.size ?? 384;
- const cols = config.cols ?? Math.min(3, shots.length);
- enforceCapturePixels(shots.length, size, cols, limits);
- const cells = [];
- const perFramePngs = [];
- const derivativeReceipts = [];
- for (const shot of shots) {
- const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
- const view = { name: shot.name, dir };
- const png = await withCameraVisibility(root, shot, async () => {
- if (render) {
- const result = await render({ root, label: shot.name, view, size, camera: shot.camera });
- derivativeReceipts.push(result.receipt);
- return result.png;
- }
- return encodePng(rasterizeCamera(root, shot.camera, size), size, size);
- });
- const decoded = decodePng(png);
- if (decoded.width !== size || decoded.height !== size)
- throw new Error("capture cell dimensions do not match request");
- annotateViewCell(decoded.rgb, size, view);
- cells.push(decoded.rgb);
- perFramePngs.push(encodePng(decoded.rgb, size, size));
- }
- const { rgb, width, height } = compositeCellGrid(cells, size, cols);
- const png = encodePng(rgb, width, height);
- enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
- return {
- png,
- width,
- height,
- views: shots.map((s) => s.name),
- capture: { preset: `${cols}x${Math.ceil(shots.length / cols)}`, cols, cells: shots.length },
- cameraShots: shots,
- perFramePngs,
- derivativeReceipts,
- ...derivativeReceipts.length ? {
- captureCache: {
- hit: derivativeReceipts.every((r) => r.captureCache?.hit),
- reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
- total: derivativeReceipts.length
- }
- } : {}
- };
-}
-var init_camera_capture = __esm(() => {
- init_capture_limits();
- init_camera();
- init_png();
- init_grid();
- init_annotate();
-});
-
// src/views/capture.ts
function captureCellLabel(azimuthDeg, elevationDeg) {
const az = Math.round((azimuthDeg % 360 + 360) % 360);
const el = Math.round(elevationDeg);
return `A${az} ${el < 0 ? "D" : "U"}${Math.abs(el)}`;
}
+function resolveCaptureBackdrop(backdrop) {
+ if (backdrop === undefined)
+ return DEFAULT_BACKDROP_ID;
+ if (!isBackdropId(backdrop))
+ throw new CaptureConfigError(`capture.backdrop must be one of ${BACKDROP_IDS.join(", ")} (got ${JSON.stringify(backdrop)}).`);
+ return backdrop;
+}
function resolveCapture(config) {
+ const backdrop = resolveCaptureBackdrop(config?.backdrop);
if (!config || config.preset === undefined && config.cells === undefined) {
return {
preset: DEFAULT_CAPTURE_PRESET,
views: PRESET_VIEWS[DEFAULT_CAPTURE_PRESET],
cols: PRESET_COLS[DEFAULT_CAPTURE_PRESET],
zooms: new Array(PRESET_CAPACITY[DEFAULT_CAPTURE_PRESET]).fill(undefined),
- isDefault: true
+ isDefault: true,
+ backdrop
};
}
const cells = config.cells;
@@ -22806,7 +22778,8 @@ function resolveCapture(config) {
})),
cols: PRESET_COLS[preset],
zooms: cells.map((c) => c.zoom),
- isDefault: false
+ isDefault: false,
+ backdrop
};
}
const chosen = preset;
@@ -22815,7 +22788,8 @@ function resolveCapture(config) {
views: PRESET_VIEWS[chosen],
cols: PRESET_COLS[chosen],
zooms: new Array(PRESET_VIEWS[chosen].length).fill(undefined),
- isDefault: chosen === DEFAULT_CAPTURE_PRESET
+ isDefault: chosen === DEFAULT_CAPTURE_PRESET,
+ backdrop
};
}
function resolveGridCapture(config, envVariant) {
@@ -22828,6 +22802,7 @@ function resolveGridCapture(config, envVariant) {
var CAPTURE_PRESETS, DEFAULT_CAPTURE_PRESET = "3x2", MAX_CAPTURE_CELLS = 9, PRESET_COLS, PRESET_CAPACITY, BOTTOM, THREE_QUARTER_REAR, THREE_QUARTER_LOW, PRESET_VIEWS, CaptureConfigError;
var init_capture = __esm(() => {
init_raster();
+ init_background();
CAPTURE_PRESETS = [
"1x1",
"1x2",
@@ -22871,6 +22846,93 @@ var init_capture = __esm(() => {
};
});
+// src/views/camera-capture.ts
+function validateAdvancedCapture(config) {
+ for (const key of Object.keys(config))
+ if (!["version", "shots", "cols", "size", "output", "backdrop"].includes(key))
+ throw new Error(`capture.${key} is unknown or incompatible with shots`);
+ if (config.version !== "kiln.capture.v1")
+ throw new Error("advanced capture requires version kiln.capture.v1");
+ if (!Array.isArray(config.shots) || config.shots.length < 1 || config.shots.length > 9)
+ throw new Error("capture.shots must contain 1..9 shots");
+ if (config.cols !== undefined && (!Number.isInteger(config.cols) || config.cols < 1 || config.cols > 3))
+ throw new Error("capture.cols must be 1..3");
+ if (config.size !== undefined && (!Number.isInteger(config.size) || config.size < 128 || config.size > 1024))
+ throw new Error("capture.size must be 128..1024");
+ if (config.output !== undefined && !["grid", "separate"].includes(config.output))
+ throw new Error("capture.output must be grid or separate");
+ resolveCaptureBackdrop(config.backdrop);
+}
+async function renderCaptureGrid(root, config, render, limits) {
+ validateAdvancedCapture(config);
+ const shots = config.shots.map((s) => resolveAssetCamera(root, s));
+ const size = config.size ?? 384;
+ const cols = config.cols ?? Math.min(3, shots.length);
+ const backdrop = resolveCaptureBackdrop(config.backdrop);
+ enforceCapturePixels(shots.length, size, cols, limits);
+ const cells = [];
+ const perFramePngs = [];
+ const derivativeReceipts = [];
+ for (const shot of shots) {
+ const dir = shot.camera.position.map((n, i) => n - shot.camera.target[i]);
+ const view = { name: shot.name, dir };
+ const png = await withCameraVisibility(root, shot, async () => {
+ if (render) {
+ const result = await render({
+ root,
+ label: shot.name,
+ view,
+ size,
+ camera: shot.camera,
+ backdrop
+ });
+ derivativeReceipts.push(result.receipt);
+ return result.png;
+ }
+ return encodePng(rasterizeCamera(root, shot.camera, size, true, backdrop), size, size);
+ });
+ const decoded = decodePng(png);
+ if (decoded.width !== size || decoded.height !== size)
+ throw new Error("capture cell dimensions do not match request");
+ annotateViewCell(decoded.rgb, size, view);
+ cells.push(decoded.rgb);
+ perFramePngs.push(encodePng(decoded.rgb, size, size));
+ }
+ const { rgb, width, height } = compositeCellGrid(cells, size, cols);
+ const png = encodePng(rgb, width, height);
+ enforceCaptureBytes(config.output === "separate" ? perFramePngs : [png], limits);
+ return {
+ png,
+ width,
+ height,
+ views: shots.map((s) => s.name),
+ capture: {
+ preset: `${cols}x${Math.ceil(shots.length / cols)}`,
+ cols,
+ cells: shots.length,
+ backdrop
+ },
+ cameraShots: shots,
+ perFramePngs,
+ derivativeReceipts,
+ ...derivativeReceipts.length ? {
+ captureCache: {
+ hit: derivativeReceipts.every((r) => r.captureCache?.hit),
+ reused: derivativeReceipts.filter((r) => r.captureCache?.hit).length,
+ total: derivativeReceipts.length
+ }
+ } : {}
+ };
+}
+var init_camera_capture = __esm(() => {
+ init_capture_limits();
+ init_camera();
+ init_capture();
+ init_png();
+ init_grid();
+ init_annotate();
+});
+
// src/views/architecture.ts
function nodeRoles(node) {
return readSemanticMetadataV1FromExtras(node.userData ?? {})?.roles ?? [];
@@ -24204,6 +24266,7 @@ async function renderViewGrid(root, opts = {}) {
snapSceneToPalette(root, opts.snapPalette);
const wantsZoom = resolved.zooms.some((z) => z !== undefined);
const sceneBounds = wantsZoom ? measureBounds(root) : undefined;
+ const backdrop = opts.backdrop ?? resolved.backdrop;
const cache = opts.snapPalette?.length ? undefined : opts.captureCache;
let reused = 0;
const cells = [];
@@ -24212,6 +24275,7 @@ async function renderViewGrid(root, opts = {}) {
const rasterOptions = {
size,
backfaceCull: opts.backfaceCull,
+ backdrop,
...opts.frameBounds ? { frameBounds: opts.frameBounds } : {},
...sceneBounds && zoom !== undefined ? { frameBounds: expandFrameBounds(sceneBounds, zoom) } : {}
};
@@ -24224,7 +24288,8 @@ async function renderViewGrid(root, opts = {}) {
rendererId: `${CPU_RASTER_RENDERER_ID}/legacy-fit`,
camera: camera2,
size,
- backfaceCull: opts.backfaceCull ?? true
+ backfaceCull: opts.backfaceCull ?? true,
+ backdrop
}, async () => ({
png: encodePng(rasterizeView(root, views[vi].dir, rasterOptions), size, size),
width: size,
@@ -24250,7 +24315,7 @@ async function renderViewGrid(root, opts = {}) {
width,
height,
views: views.map((v) => v.name),
- capture: { preset: resolved.preset, cols, cells: views.length },
+ capture: { preset: resolved.preset, cols, cells: views.length, backdrop },
...cache && opts.artifactGlbSha256 ? { captureCache: { hit: reused === views.length, reused, total: views.length } } : {}
};
}
@@ -24263,8 +24328,9 @@ async function renderGlbViewCell(bytes, view, options = {}) {
const exactBytes = Uint8Array.from(bytes);
const loaded = await loadGlbGeometryFlatScene(exactBytes);
const size = options.size ?? 256;
- const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull) : rasterizeView(loaded.root, view.dir, {
+ const rgb = options.camera ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull, options.backdrop) : rasterizeView(loaded.root, view.dir, {
size,
+ ...options.backdrop ? { backdrop: options.backdrop } : {},
...options.backfaceCull !== undefined ? { backfaceCull: options.backfaceCull } : {},
...options.frameBounds ? { frameBounds: options.frameBounds } : {}
});
@@ -24481,6 +24547,12 @@ async function renderInteriorGrid(root, opts = {}) {
width,
height,
views: INTERIOR_VIEWS.map((v) => v.name),
+ capture: {
+ preset: "interior",
+ cols: INTERIOR_VIEWS.length,
+ cells: INTERIOR_VIEWS.length,
+ backdrop: DEFAULT_BACKDROP_ID
+ },
roofsHidden,
wallsHidden,
...derivativeReceipts.length ? { derivativeReceipts } : {}
@@ -24489,6 +24561,7 @@ async function renderInteriorGrid(root, opts = {}) {
var ANIM_CAMERAS, ANIM_CAMERA_ALIASES, ROOM_WALL_NORMALS, INTERIOR_VIEWS;
var init_views = __esm(() => {
init_capture_limits();
+ init_background();
init_capture_limits();
init_capture_cache();
init_camera();
@@ -25881,7 +25954,7 @@ async function sha256Bytes(bytes) {
const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", input));
return `sha256:${[...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
}
-async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits) {
+async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, cameras, limits, backdrop) {
let timer;
try {
const exactCameras = cameras?.map(validateResolvedAssetCamera);
@@ -25895,6 +25968,7 @@ async function captureViewPngsViaPort(port, glb, timeoutMs, viewDirs, size, came
const result = await Promise.race([
port({
glb: requestGlb,
+ ...backdrop ? { backdrop } : {},
...exactCameras ? { cameras: exactCameras, width: size, height: size } : { viewDirs: viewDirs.map((dir) => [...dir]), size }
}),
deadline
@@ -25967,7 +26041,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
const derivative = await renderSceneToGLB(input.root, {
derivative: true
});
- const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits);
+ const result = await captureViewPngsViaPort(port, derivative.bytes, timeoutMs, [input.view.dir], input.size, [input.camera], limits, input.backdrop);
if (!result.ok)
throw new Error(result.reason);
if (!result.derivativeFidelityAttested || !result.inputGlbSha256)
@@ -26017,7 +26091,12 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: err instanceof Error ? err.message : String(err) };
}
const views = resolved.views;
- const shape = { preset: resolved.preset, cols: resolved.cols, cells: views.length };
+ const shape = {
+ preset: resolved.preset,
+ cols: resolved.cols,
+ cells: views.length,
+ backdrop: resolved.backdrop
+ };
let cameras;
if (resolved.zooms.some((z) => z !== undefined)) {
try {
@@ -26029,7 +26108,7 @@ async function captureViewsViaPort(port, glb, timeoutMs = DEFAULT_VIEW_RENDER_TI
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
}
}
- const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits);
+ const result = await captureViewPngsViaPort(port, glb, timeoutMs, views.map((view) => view.dir), 384, cameras, limits, resolved.backdrop);
if (!result.ok)
return result;
try {
@@ -27369,6 +27448,7 @@ function resolveViewRenderTimeoutMs(input) {
// src/tools/registry.ts
init_evidence_history();
+init_background();
var KILN_ASSET_WIDGET_URI = "ui://kiln/asset-v5.html";
function proceduralTextureMaterialContract(rendered, context) {
const required = [...new Set(context.requiredProceduralTextureUsages ?? [])];
@@ -27482,7 +27562,7 @@ async function renderDerivativeCell(input, context) {
const derivativeReasonCodes = [];
if (context.viewRenderPort) {
await Promise.resolve().then(() => init_port());
- const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits);
+ const ported = await captureViewPngsViaPort(context.viewRenderPort, derivativeGlb, resolveInLoopViewRenderTimeoutMs(context, "derivative-cell"), [input.view.dir], input.size, [camera], context.captureLimits, input.backdrop);
if (ported.ok && ported.derivativeFidelityAttested) {
if (ported.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`validated derivative receipt hash mismatch (${ported.inputGlbSha256} != ${inputGlbSha256})`);
@@ -27530,6 +27610,7 @@ async function renderDerivativeCell(input, context) {
const produceFlat = async () => renderGlbViewCell(derivativeGlb, input.view, {
size: input.size,
camera,
+ ...input.backdrop ? { backdrop: input.backdrop } : {},
...input.backfaceCull !== undefined ? { backfaceCull: input.backfaceCull } : {},
...input.frameBounds ? { frameBounds: input.frameBounds } : {}
});
@@ -27538,7 +27619,8 @@ async function renderDerivativeCell(input, context) {
rendererId: CPU_RASTER_RENDERER_ID,
camera,
size: input.size,
- backfaceCull: input.backfaceCull ?? true
+ backfaceCull: input.backfaceCull ?? true,
+ ...input.backdrop ? { backdrop: input.backdrop } : {}
}, produceFlat) : await produceFlat();
if (flat.inputGlbSha256 !== inputGlbSha256) {
throw new Error(`derivative GLB fallback hash mismatch (${flat.inputGlbSha256} != ${inputGlbSha256})`);
@@ -27611,6 +27693,7 @@ var renderInput = z4.object({
var screenshotInput = z4.object({
code: z4.string().describe("Kiln source code to execute and render to a six-view image grid.")
});
+var backdropInput = z4.enum(BACKDROP_IDS).optional().describe("Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.");
var legacyCaptureInput = z4.object({
preset: z4.enum(["1x1", "1x2", "2x1", "3x1", "2x2", "3x2", "3x3"]).optional().describe("Grid shape as COLSxROWS. Default 3x2. Choose fewer views for simple shapes, up to 3x3 for more angles."),
cells: z4.array(z4.object({
@@ -27618,7 +27701,8 @@ var legacyCaptureInput = z4.object({
elevationDeg: z4.number().describe("0 = eye level, positive looks down, negative from below. Clamped to -89..89."),
zoom: z4.number().optional().describe("Padding multiplier around the asset bounds for this cell only. Omit for the default framing; below 1 crops in, above 1 pulls back."),
name: z4.string().optional().describe("Cell label. Auto-derived from the angles if omitted.")
- })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall).")
+ })).optional().describe("One camera per cell, in row-major order. Omit to use the preset default cameras. Must not exceed the preset capacity (max 9 overall)."),
+ backdrop: backdropInput
}).optional().describe("Optional. Choose the contact-sheet shape and cameras. Omit it entirely for the standard six-view 3x2 grid, which is the right default for most assets.");
var cameraVec3Input = z4.array(z4.number()).length(3);
var orbitCameraError = (issue) => {
@@ -27673,7 +27757,8 @@ var advancedCaptureInput = z4.strictObject({
shots: z4.array(cameraShotInput).min(1).max(9),
cols: z4.number().int().min(1).max(3).optional(),
size: z4.number().int().min(128).max(1024).optional(),
- output: z4.enum(["grid", "separate"]).optional()
+ output: z4.enum(["grid", "separate"]).optional(),
+ backdrop: backdropInput
}, { error: advancedCaptureError });
function taggedCaptureError(issue) {
const input = issue.input;
@@ -28115,6 +28200,7 @@ async function runViewInterior(input, context) {
gridWidth: grid.width,
gridHeight: grid.height,
...grid.cameraShots ? { cameraShots: grid.cameraShots } : {},
+ ...grid.capture ? { capture: grid.capture } : {},
roofsHidden: grid.roofsHidden,
wallsHidden: grid.wallsHidden,
...input.capture?.output === "separate" && grid.perFramePngs ? { framesBase64: grid.perFramePngs.map((p) => p.toString("base64")) } : { pngBase64: grid.png.toString("base64") },
@@ -28508,7 +28594,8 @@ function createKilnAssetDefs(context) {
model: z4.string().max(200).optional(),
harness: z4.string().max(200).optional(),
author: z4.string().max(200).optional()
- }).optional()
+ }).optional(),
+ backdrop: z4.enum(BACKDROP_IDS).optional().describe("Preview backdrop: the one the reviewed sheet used.")
});
const assetsInput = z4.object({
action: z4.enum(["collections", "list", "get", "restore"]).default("list"),
@@ -28530,24 +28617,27 @@ function createKilnAssetDefs(context) {
return [
{
name: "kiln_save",
- description: "Save a completed source revision into the user-requested collection, or project when no destination was requested. Persists its exact GLB, source, preview, and build record. Discover destinations with kiln_assets action=collections. Use programRef returned by render/edit. To revise an existing asset, supply its assetId and parentRevision; previous revisions remain intact. Returns downloadable resources. Draft renders do not populate collections.",
+ description: "Save a completed source revision into the user-requested collection, or project when none was requested. Persists exact GLB, source, preview and build record. Use programRef returned by render/edit. To revise an asset, pass assetId and parentRevision; earlier revisions stay intact. Returns downloadable resources; draft renders never populate collections.",
inputSchema: saveInput,
run: async (raw) => {
- const input = saveInput.parse(raw);
+ const { backdrop, ...input } = saveInput.parse(raw);
const target = library();
const code = await context.programStore.get(input.programRef);
const rendered = await evaluateGeneratedSource(code, context);
let preview;
let previewInfo;
try {
- const result = await runRenderViews({ code }, {
- ...context,
- evaluatorPort: { render: async () => rendered }
- });
+ const result = await runRenderViews({
+ code,
+ ...backdrop ? { capture: { backdrop } } : {}
+ }, { ...context, evaluatorPort: { render: async () => rendered } });
if (!result.ok || !result.pngBase64)
throw new Error(result.error ?? "Preview unavailable");
preview = Uint8Array.from(Buffer.from(result.pngBase64, "base64"));
- previewInfo = { fidelity: result.viewFidelity };
+ previewInfo = {
+ fidelity: result.viewFidelity,
+ backdrop: result.capture?.backdrop ?? DEFAULT_BACKDROP_ID
+ };
} catch (error) {
previewInfo = {
error: error instanceof Error ? error.message : String(error)
@@ -28843,10 +28933,9 @@ function makeRemoteRenderPort(url, token) {
if (req.lightingPresetId)
body["lighting_preset_id"] = req.lightingPresetId;
}
- if (req.viewDirs) {
+ if (req.viewDirs)
body["views"] = req.viewDirs;
- body["background"] = GRID_BACKGROUND_HEX;
- }
+ body["backdrop"] = req.backdrop ?? DEFAULT_BACKDROP_ID;
if (req.size !== undefined)
body["size"] = req.size;
if (req.beautySize !== undefined)
diff --git a/dist/viewer/app.js b/dist/viewer/app.js
index 9a1c6102..c21ca59e 100644
--- a/dist/viewer/app.js
+++ b/dist/viewer/app.js
@@ -1,8 +1,8 @@
-function ws(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 Ic(e,t="|"){return e.map((n)=>Nc(n)).join(t)}function Ts(e,t){if(typeof t==="bigint")return t.toString();return t}class ff{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 ff(e)}function df(e){return e===null||e===void 0}function No(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function pf(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 In(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Do(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function hi(e){return Do(e._zod.def)??e._zod.def.shape}function mf(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return In(this,t,i),i},enumerable:!0,configurable:!0})}function gf(e,t,n){if(t in e)In(e,t,n);else e[t]=n}function rr(e,t,n,i){let r=hi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)mf(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else gf(e,s,i?i(o.value,s):o.value)}}function Mv(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)mf(e,n,()=>t[n]);else gf(e,n,i.value)}}function un(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function _f(e){return JSON.stringify(e)}function xf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Pc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ms(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var vf=Lo(()=>{if(on.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function sr(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 Lc(e){if(sr(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 yf=new Set(["string","number","symbol"]);function Pi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $n(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Re(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Nc(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Sf(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Oo=(()=>({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]}))(),Dc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wv(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 rr(s,e,Uo(e,t)),$n(e,un(n,{shape:s,checks:[]}))}function Uo(e,t){let n=hi(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 Tv(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(Uo(e,t)),o={};return rr(o,e,Reflect.ownKeys(hi(e)).filter((a)=>!s.has(a))),$n(e,un(n,{shape:o,checks:[]}))}function Ev(e,t){if(!sr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=hi(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 $n(e,un(e._zod.def,{shape:bf(e,t)}))}function bf(e,t){let n={};return rr(n,e,Reflect.ownKeys(hi(e))),Mv(n,t),n}function Av(e,t){if(!sr(t))throw Error("Invalid input to safeExtend: expected a plain object");return $n(e,un(e._zod.def,{shape:bf(e,t)}))}function Rv(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={};rr(n,e,Reflect.ownKeys(hi(e))),rr(n,t,Reflect.ownKeys(hi(t)));let i=un(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return $n(e,i)}function Mf(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(Uo(t,n)):void 0,c={};return rr(c,t,Reflect.ownKeys(hi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),$n(t,un(t._zod.def,{shape:c,checks:[]}))}function Cv(e,t,n){let i=n?new Set(Uo(t,n)):void 0,r={};return rr(r,t,Reflect.ownKeys(hi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),$n(t,un(t._zod.def,{shape:r}))}function Zn(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 wf(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 Li(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function bs(e){return typeof e==="string"?e:e?.message}function Oc(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Xn(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:bs(e.inst?._zod.def?.error?.(e))??bs(s?.(e))??bs(t?.error?.(e))??bs(n.customError?.(e))??bs(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 Iv=/[\uD800-\uDBFF]/;function Fo(e){let t=e.length;if(!Iv.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 zo(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Tf(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function or(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Ef(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else Pv(e,n,i.value)}}function fi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ko(e,t,n){return fi(e,t,n,!1)}function Af(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return fi(this,n,i(this))},set(r){fi(this,n,r)}})}return t}function Pv(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fi(this,t,n.bind(this))},set(i){fi(this,t,i)}})}function Lv(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Cc,Ii=!1,Nv={configurable:!0,get(){Ii=!0;return}};function tt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Cc!==e._zod){Cc=void 0;return}Cc=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,Nv);let r=Ii;Ii=!1;try{let s=n(this);if(Ii)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ii=Ii||r,s}catch(s){throw delete this[t],Ii=Ii||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Dv(e,t,n,i){let r=Lv(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 Ov="~constantCatch";function Rf(e){let t=()=>e;return t[Ov]=!0,t}var Cf;var Uc={value:void 0,enumerable:!1},If="captureStackTrace"in Error?Error:null;function Uv(e){let t=If;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return If=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function j(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){Uc.value=new s(d);try{Object.defineProperty(h,"_zod",Uc)}finally{Uc.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),Ef(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?Uv(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class qn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Es extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Cf=globalThis).__zod_globalConfig??(Cf.__zod_globalConfig={});var on=globalThis.__zod_globalConfig;function hn(e){if(e)Object.assign(on,e);return on}function Fv(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ts,2)),e.message}function zv(e){this._zod.message=e}var kv={get:Fv,set:zv,enumerable:!0,configurable:!0},zc={value:void 0,enumerable:!1},Pf=new WeakSet([Object.prototype,Error.prototype]),Lf=(e,t)=>{e.name="$ZodError",zc.value=t,Object.defineProperty(e,"issues",zc),zc.value=void 0,Object.defineProperty(e,"message",kv);let n=Object.getPrototypeOf(e);if(!Pf.has(n))Pf.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})}})},Nf=j("$ZodError",Lf),M1=j("$ZodError",Lf,void 0,{Parent:Error});function Bv(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 Df(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Bv(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Of(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Bo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Go=(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 qn;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Xn(l,o,hn())));throw Pc(c,s?.callee??t),c}return a.value};return t};var Ho=(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)=>Xn(l,o,hn())));throw Pc(c,s?.callee??t),c}return a.value};return t};var Vo=(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 qn;return s.issues.length?Uf(e,s.issues,r):{success:!0,data:s.value}};function Uf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Xn(r,n,hn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Wo=(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?Uf(e,s.issues,r):{success:!0,data:s.value}};var Gv=Symbol.for("zod.compile.invalid"),Hv=Symbol.for("zod.compile.fallback"),kc=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==Gv)return!0;if(i.definite===!0&&n===void 0)return!1}return Vv(e,t,n)};function Vv(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[Hv]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new qn;return s.issues.length===0}var Bc=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},Ff=(e)=>{let t=Go(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Bo(n,o))};return n};var zf=(e)=>{let t=Go(e),n=(i,r,s,o)=>t(i,r,s,Bo(n,o));return n};var kf=(e)=>{let t=Ho(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Bo(n,o))};return n};var Bf=(e)=>{let t=Ho(e),n=async(i,r,s,o)=>await t(i,r,s,Bo(n,o));return n};var Gf=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vo(e)(t,n,r)};var Hf=(e)=>(t,n,i)=>Vo(e)(t,n,i);var Vf=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Wo(e)(t,n,r)};var Wf=(e)=>async(t,n,i)=>Wo(e)(t,n,i);var $f=/^[cC][0-9a-z]{6,}$/,Zf=/^[0-9a-z]+$/,Xf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,qf=/^[0-9a-vA-V]{20}$/,Yf=/^[A-Za-z0-9]{27}$/,jf=/^[a-zA-Z0-9_-]{21}$/;function Kf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Jf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Qf=/^([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})$/,Hc=(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 ed=/^(?:[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 Wv="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function td(){return new RegExp(Wv,"u")}var nd=/^(?:(?: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])$/,id=/^(([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 rd=/^((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])$/,sd=/^(([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])$/,od=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ad=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var cd=/^https?$/,ld=/^\+[1-9]\d{6,14}$/;var ud="(?:(?:\\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 $v(e){return new RegExp(`^${e}$`)}var hd=$v(ud);function Gc(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 fd(e){return new RegExp(`^${Gc(e)}$`)}function dd(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Gc({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Gc({precision:e.precision})}`:n;return new RegExp(`^${ud}T(?:${i})$`)}var pd=/^[\s\S]{0,}$/;var Vc=/^-?\d+$/,As=/^-?\d+(?:\.\d+)?$/,md=/^(?:true|false)$/i;var gd=/^[^A-Z]*$/,_d=/^[^a-z]*$/;var Vt=j("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Wc=(e)=>{let t=e.value;return!df(t)&&t.length!==void 0},$o={number:"number",bigint:"bigint",object:"date"},$c=j("$ZodCheckLessThan",(e,t)=>{Vt.init(e,t);let n=$o[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:$o[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})}}),Zc=j("$ZodCheckGreaterThan",(e,t)=>{Vt.init(e,t);let n=$o[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:$o[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})}}),xd=j("$ZodCheckMultipleOf",(e,t)=>{Vt.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):pf(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})}}),vd=j("$ZodCheckNumberFormat",(e,t)=>{Vt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Oo[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 yd=j("$ZodCheckMaxLength",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Fo(r):s)<=t.maximum)return;let a=zo(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sd=j("$ZodCheckMinLength",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Fo(r):s)>=t.minimum)return;let a=zo(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bd=j("$ZodCheckLengthEquals",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Fo(r):s;if(o===t.length)return;let a=zo(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})}}),Cs=j("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Vt.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=()=>{})}),Md=j("$ZodCheckRegex",(e,t)=>{Cs.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})}}),wd=j("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gd),Cs.init(e,t)}),Td=j("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_d),Cs.init(e,t)}),Ed=j("$ZodCheckIncludes",(e,t)=>{Vt.init(e,t);let n=Pi(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})}}),Ad=j("$ZodCheckStartsWith",(e,t)=>{Vt.init(e,t);let n=new RegExp(`^${Pi(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})}}),Rd=j("$ZodCheckEndsWith",(e,t)=>{Vt.init(e,t);let n=new RegExp(`.*${Pi(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 Cd=j("$ZodCheckOverwrite",(e,t)=>{Vt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Xc{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
+function ws(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 Ic(e,t="|"){return e.map((n)=>Nc(n)).join(t)}function Ts(e,t){if(typeof t==="bigint")return t.toString();return t}class pf{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 pf(e)}function mf(e){return e===null||e===void 0}function No(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gf(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 In(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Do(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function hi(e){return Do(e._zod.def)??e._zod.def.shape}function _f(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return In(this,t,i),i},enumerable:!0,configurable:!0})}function xf(e,t,n){if(t in e)In(e,t,n);else e[t]=n}function rr(e,t,n,i){let r=hi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)_f(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else xf(e,s,i?i(o.value,s):o.value)}}function Ev(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)_f(e,n,()=>t[n]);else xf(e,n,i.value)}}function un(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function vf(e){return JSON.stringify(e)}function yf(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Pc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ms(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Sf=Lo(()=>{if(on.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function sr(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 Lc(e){if(sr(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 bf=new Set(["string","number","symbol"]);function Pi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $n(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Re(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Nc(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Mf(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Oo=(()=>({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]}))(),Dc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Av(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 rr(s,e,Uo(e,t)),$n(e,un(n,{shape:s,checks:[]}))}function Uo(e,t){let n=hi(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 Rv(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(Uo(e,t)),o={};return rr(o,e,Reflect.ownKeys(hi(e)).filter((a)=>!s.has(a))),$n(e,un(n,{shape:o,checks:[]}))}function Cv(e,t){if(!sr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=hi(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 $n(e,un(e._zod.def,{shape:wf(e,t)}))}function wf(e,t){let n={};return rr(n,e,Reflect.ownKeys(hi(e))),Ev(n,t),n}function Iv(e,t){if(!sr(t))throw Error("Invalid input to safeExtend: expected a plain object");return $n(e,un(e._zod.def,{shape:wf(e,t)}))}function Pv(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={};rr(n,e,Reflect.ownKeys(hi(e))),rr(n,t,Reflect.ownKeys(hi(t)));let i=un(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return $n(e,i)}function Tf(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(Uo(t,n)):void 0,c={};return rr(c,t,Reflect.ownKeys(hi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),$n(t,un(t._zod.def,{shape:c,checks:[]}))}function Lv(e,t,n){let i=n?new Set(Uo(t,n)):void 0,r={};return rr(r,t,Reflect.ownKeys(hi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),$n(t,un(t._zod.def,{shape:r}))}function Zn(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 Ef(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 Li(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function bs(e){return typeof e==="string"?e:e?.message}function Oc(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Xn(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:bs(e.inst?._zod.def?.error?.(e))??bs(s?.(e))??bs(t?.error?.(e))??bs(n.customError?.(e))??bs(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 Nv=/[\uD800-\uDBFF]/;function Fo(e){let t=e.length;if(!Nv.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 zo(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Af(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function or(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Rf(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else Dv(e,n,i.value)}}function fi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ko(e,t,n){return fi(e,t,n,!1)}function Cf(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return fi(this,n,i(this))},set(r){fi(this,n,r)}})}return t}function Dv(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fi(this,t,n.bind(this))},set(i){fi(this,t,i)}})}function Ov(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Cc,Ii=!1,Uv={configurable:!0,get(){Ii=!0;return}};function tt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Cc!==e._zod){Cc=void 0;return}Cc=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,Uv);let r=Ii;Ii=!1;try{let s=n(this);if(Ii)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Ii=Ii||r,s}catch(s){throw delete this[t],Ii=Ii||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Fv(e,t,n,i){let r=Ov(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 zv="~constantCatch";function If(e){let t=()=>e;return t[zv]=!0,t}var Pf;var Uc={value:void 0,enumerable:!1},Lf="captureStackTrace"in Error?Error:null;function kv(e){let t=Lf;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Lf=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function j(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){Uc.value=new s(d);try{Object.defineProperty(h,"_zod",Uc)}finally{Uc.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),Rf(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?kv(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class qn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Es extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Pf=globalThis).__zod_globalConfig??(Pf.__zod_globalConfig={});var on=globalThis.__zod_globalConfig;function hn(e){if(e)Object.assign(on,e);return on}function Bv(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ts,2)),e.message}function Gv(e){this._zod.message=e}var Hv={get:Bv,set:Gv,enumerable:!0,configurable:!0},zc={value:void 0,enumerable:!1},Nf=new WeakSet([Object.prototype,Error.prototype]),Df=(e,t)=>{e.name="$ZodError",zc.value=t,Object.defineProperty(e,"issues",zc),zc.value=void 0,Object.defineProperty(e,"message",Hv);let n=Object.getPrototypeOf(e);if(!Nf.has(n))Nf.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})}})},Of=j("$ZodError",Df),E1=j("$ZodError",Df,void 0,{Parent:Error});function Vv(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 Uf(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)Vv(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Ff(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Bo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Go=(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 qn;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Xn(l,o,hn())));throw Pc(c,s?.callee??t),c}return a.value};return t};var Ho=(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)=>Xn(l,o,hn())));throw Pc(c,s?.callee??t),c}return a.value};return t};var Vo=(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 qn;return s.issues.length?zf(e,s.issues,r):{success:!0,data:s.value}};function zf(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Xn(r,n,hn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Wo=(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?zf(e,s.issues,r):{success:!0,data:s.value}};var Wv=Symbol.for("zod.compile.invalid"),$v=Symbol.for("zod.compile.fallback"),kc=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==Wv)return!0;if(i.definite===!0&&n===void 0)return!1}return Zv(e,t,n)};function Zv(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[$v]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new qn;return s.issues.length===0}var Bc=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)r=await r;return r.issues.length===0},kf=(e)=>{let t=Go(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Bo(n,o))};return n};var Bf=(e)=>{let t=Go(e),n=(i,r,s,o)=>t(i,r,s,Bo(n,o));return n};var Gf=(e)=>{let t=Ho(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Bo(n,o))};return n};var Hf=(e)=>{let t=Ho(e),n=async(i,r,s,o)=>await t(i,r,s,Bo(n,o));return n};var Vf=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Vo(e)(t,n,r)};var Wf=(e)=>(t,n,i)=>Vo(e)(t,n,i);var $f=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Wo(e)(t,n,r)};var Zf=(e)=>async(t,n,i)=>Wo(e)(t,n,i);var Xf=/^[cC][0-9a-z]{6,}$/,qf=/^[0-9a-z]+$/,Yf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jf=/^[0-9a-vA-V]{20}$/,Kf=/^[A-Za-z0-9]{27}$/,Jf=/^[a-zA-Z0-9_-]{21}$/;function Qf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ed=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var td=/^([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})$/,Hc=(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 nd=/^(?:[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 Xv="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function id(){return new RegExp(Xv,"u")}var rd=/^(?:(?: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])$/,sd=/^(([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 od=/^((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])$/,ad=/^(([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])$/,cd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ld=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ud=/^https?$/,hd=/^\+[1-9]\d{6,14}$/;var fd="(?:(?:\\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 qv(e){return new RegExp(`^${e}$`)}var dd=qv(fd);function Gc(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 pd(e){return new RegExp(`^${Gc(e)}$`)}function md(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Gc({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Gc({precision:e.precision})}`:n;return new RegExp(`^${fd}T(?:${i})$`)}var gd=/^[\s\S]{0,}$/;var Vc=/^-?\d+$/,As=/^-?\d+(?:\.\d+)?$/,_d=/^(?:true|false)$/i;var xd=/^[^A-Z]*$/,vd=/^[^a-z]*$/;var Vt=j("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Wc=(e)=>{let t=e.value;return!mf(t)&&t.length!==void 0},$o={number:"number",bigint:"bigint",object:"date"},$c=j("$ZodCheckLessThan",(e,t)=>{Vt.init(e,t);let n=$o[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:$o[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})}}),Zc=j("$ZodCheckGreaterThan",(e,t)=>{Vt.init(e,t);let n=$o[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:$o[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})}}),yd=j("$ZodCheckMultipleOf",(e,t)=>{Vt.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):gf(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})}}),Sd=j("$ZodCheckNumberFormat",(e,t)=>{Vt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Oo[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 bd=j("$ZodCheckMaxLength",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Fo(r):s)<=t.maximum)return;let a=zo(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Md=j("$ZodCheckMinLength",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Fo(r):s)>=t.minimum)return;let a=zo(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wd=j("$ZodCheckLengthEquals",(e,t)=>{var n;Vt.init(e,t),(n=e._zod.def).when??(n.when=Wc),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Fo(r):s;if(o===t.length)return;let a=zo(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})}}),Cs=j("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Vt.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=()=>{})}),Td=j("$ZodCheckRegex",(e,t)=>{Cs.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})}}),Ed=j("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xd),Cs.init(e,t)}),Ad=j("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vd),Cs.init(e,t)}),Rd=j("$ZodCheckIncludes",(e,t)=>{Vt.init(e,t);let n=Pi(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})}}),Cd=j("$ZodCheckStartsWith",(e,t)=>{Vt.init(e,t);let n=new RegExp(`^${Pi(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})}}),Id=j("$ZodCheckEndsWith",(e,t)=>{Vt.init(e,t);let n=new RegExp(`.*${Pi(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 Pd=j("$ZodCheckOverwrite",(e,t)=>{Vt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Xc{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 Pd={major:4,minor:6,patch:4};var yt=j("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pd;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=Zn(a),f;for(let h of c){if(h._zod.def.when){if(wf(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new qn;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(Oc(a.issues,d,e),!u)u=Zn(a,d)});else{if(a.issues.length===d)continue;if(Oc(a.issues,d,e),!u)u=Zn(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(Zn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new qn;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new qn;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ko(this,"~standard",Yc(this))},set "~standard"(e){fi(this,"~standard",e)}}),Hd=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Xn(n,t,hn()))}:{value:e.value};async function Zv(e,t){let n={async:!0};return Hd(await e._zod.run({value:t,issues:[]},n),n)}function Yc(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Hd(i,n)}catch(i){}return Zv(e,t)},vendor:"zod",version:1}}var Yo=j("$ZodString",(e,t)=>{yt.init(e,t),e._zod.pattern=t.pattern??pd,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}}),vt=j("$ZodStringFormat",(e,t)=>{Cs.init(e,t),Yo.init(e,t)}),Vd=j("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qf),vt.init(e,t)}),Wd=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=Hc(i))}else t.pattern??(t.pattern=Hc());vt.init(e,t)}),$d=j("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ed),vt.init(e,t)}),Zd=1,Xo=2;function Xd(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Xv(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Xd(e)||Xo;return qv(e,t)}function qv(e,t){if(!t.normalize&&t.protocol?.source===cd.source&&!/^https?:\/\//i.test(e))return Zd;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xo}return new URL(e)}catch{return Xo}}var Yv=/[\t\n\r]/g;function Ld(e){return e.replace(Yv,"")}function jv(e,t){return t.lastIndex=0,t.test(e.hostname)}function Kv(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var qd=j("$ZodURL",(e,t)=>{vt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=Xv(i,t);if(r===Zd){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xo){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Ld(i);return}if(t.hostname&&!jv(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&&!Kv(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:Ld(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Yd=j("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=td()),vt.init(e,t)}),jd=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?jf:Kf(t.length)),vt.init(e,t)}),Kd=j("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=$f),vt.init(e,t)}),Jd=j("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zf),vt.init(e,t)}),Qd=j("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xf),vt.init(e,t)}),ep=j("$ZodXID",(e,t)=>{t.pattern??(t.pattern=qf),vt.init(e,t)}),tp=j("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Yf),vt.init(e,t)}),np=j("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dd(t)),vt.init(e,t)}),ip=j("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=hd),vt.init(e,t)}),rp=j("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=fd(t)),vt.init(e,t)}),sp=j("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jf),vt.init(e,t)}),op=j("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nd),vt.init(e,t)}),Jv=/^[0-9a-fA-F:.]+$/;function ap(e){if(!Jv.test(e))return!1;return Xd(`http://[${e}]`)}var cp=j("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=id),vt.init(e,t),e._zod.check=(n)=>{if(!ap(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var lp=j("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=rd),vt.init(e,t)});function Qv(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 ap(n)}var up=j("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=sd),vt.init(e,t),e._zod.check=(n)=>{if(!Qv(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function hp(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 jc=/^[0-9a-zA-Z+/]*={0,2}$/,fp=j("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jc),vt.init(e,t),e._zod.check=(n)=>{if(hp(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jo=/^[A-Za-z0-9_-]*$/;function ey(e){if(!jo.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return hp(n)}var dp=j("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jo),vt.init(e,t),e._zod.check=(n)=>{if(ey(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),pp=j("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ld),vt.init(e,t)});function ty(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 mp=j("$ZodJWT",(e,t)=>{vt.init(e,t),e._zod.check=(n)=>{if(ty(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Kc=j("$ZodNumber",(e,t)=>{yt.init(e,t),e._zod.pattern=As,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}}),gp=j("$ZodNumberFormat",(e,t)=>{vd.init(e,t),Kc.init(e,t)}),_p=j("$ZodBoolean",(e,t)=>{yt.init(e,t),e._zod.pattern=md,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 xp=j("$ZodUnknown",(e,t)=>{yt.init(e,t),e._zod.parse=(n)=>n}),vp=j("$ZodNever",(e,t)=>{yt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Nd(e,t,n){if(e.issues.length)t.issues.push(...Li(n,e.issues));t.value[n]=e.value}var yp=j("$ZodArray",(e,t)=>{yt.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>Nd(f,i,c)));else if(Nd(u,i,c),a&&u.issues.length!==0&&Zn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function qo(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(...Li(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 ny=[];function Sp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:ny,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=Sf(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function bp(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(Zn(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>qo(p,n,g,t,f,h)));else qo(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var iy=j("$ZodObject",(e,t)=>{yt.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(()=>Sp(t));tt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))In(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ms,o=t.catchall,a,c=on.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(Zn(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,S=m._zod.run({value:f[p],issues:[]},u);if(S instanceof Promise)h.push(S.then((b)=>qo(b,l,p,f,E,R)));else qo(S,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return bp(h,f,l,u,r.value,e,g===!0)}}),Mp=j("$ZodObjectJIT",(e,t)=>{iy.init(e,t);let n=e._zod.parse,i=Lo(()=>Sp(t)),r=on.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new Xc(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,E=(b,T)=>`
+};`)(...Object.values(this.closed))}}var Nd={major:4,minor:6,patch:4};var yt=j("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nd;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=Zn(a),f;for(let h of c){if(h._zod.def.when){if(Ef(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new qn;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(Oc(a.issues,d,e),!u)u=Zn(a,d)});else{if(a.issues.length===d)continue;if(Oc(a.issues,d,e),!u)u=Zn(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(Zn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new qn;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new qn;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ko(this,"~standard",Yc(this))},set "~standard"(e){fi(this,"~standard",e)}}),Wd=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Xn(n,t,hn()))}:{value:e.value};async function Yv(e,t){let n={async:!0};return Wd(await e._zod.run({value:t,issues:[]},n),n)}function Yc(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Wd(i,n)}catch(i){}return Yv(e,t)},vendor:"zod",version:1}}var Yo=j("$ZodString",(e,t)=>{yt.init(e,t),e._zod.pattern=t.pattern??gd,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}}),vt=j("$ZodStringFormat",(e,t)=>{Cs.init(e,t),Yo.init(e,t)}),$d=j("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=td),vt.init(e,t)}),Zd=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=Hc(i))}else t.pattern??(t.pattern=Hc());vt.init(e,t)}),Xd=j("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nd),vt.init(e,t)}),qd=1,Xo=2;function Yd(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function jv(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Yd(e)||Xo;return Kv(e,t)}function Kv(e,t){if(!t.normalize&&t.protocol?.source===ud.source&&!/^https?:\/\//i.test(e))return qd;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xo}return new URL(e)}catch{return Xo}}var Jv=/[\t\n\r]/g;function Dd(e){return e.replace(Jv,"")}function Qv(e,t){return t.lastIndex=0,t.test(e.hostname)}function ey(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var jd=j("$ZodURL",(e,t)=>{vt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=jv(i,t);if(r===qd){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xo){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Dd(i);return}if(t.hostname&&!Qv(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&&!ey(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:Dd(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Kd=j("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=id()),vt.init(e,t)}),Jd=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?Jf:Qf(t.length)),vt.init(e,t)}),Qd=j("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Xf),vt.init(e,t)}),ep=j("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qf),vt.init(e,t)}),tp=j("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Yf),vt.init(e,t)}),np=j("$ZodXID",(e,t)=>{t.pattern??(t.pattern=jf),vt.init(e,t)}),ip=j("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Kf),vt.init(e,t)}),rp=j("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=md(t)),vt.init(e,t)}),sp=j("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=dd),vt.init(e,t)}),op=j("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=pd(t)),vt.init(e,t)}),ap=j("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ed),vt.init(e,t)}),cp=j("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=rd),vt.init(e,t)}),ty=/^[0-9a-fA-F:.]+$/;function lp(e){if(!ty.test(e))return!1;return Yd(`http://[${e}]`)}var up=j("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sd),vt.init(e,t),e._zod.check=(n)=>{if(!lp(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var hp=j("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=od),vt.init(e,t)});function ny(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 lp(n)}var fp=j("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ad),vt.init(e,t),e._zod.check=(n)=>{if(!ny(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function dp(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 jc=/^[0-9a-zA-Z+/]*={0,2}$/,pp=j("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jc),vt.init(e,t),e._zod.check=(n)=>{if(dp(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),jo=/^[A-Za-z0-9_-]*$/;function iy(e){if(!jo.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dp(n)}var mp=j("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jo),vt.init(e,t),e._zod.check=(n)=>{if(iy(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),gp=j("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hd),vt.init(e,t)});function ry(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 _p=j("$ZodJWT",(e,t)=>{vt.init(e,t),e._zod.check=(n)=>{if(ry(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Kc=j("$ZodNumber",(e,t)=>{yt.init(e,t),e._zod.pattern=As,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}}),xp=j("$ZodNumberFormat",(e,t)=>{Sd.init(e,t),Kc.init(e,t)}),vp=j("$ZodBoolean",(e,t)=>{yt.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 yp=j("$ZodUnknown",(e,t)=>{yt.init(e,t),e._zod.parse=(n)=>n}),Sp=j("$ZodNever",(e,t)=>{yt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Od(e,t,n){if(e.issues.length)t.issues.push(...Li(n,e.issues));t.value[n]=e.value}var bp=j("$ZodArray",(e,t)=>{yt.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>Od(f,i,c)));else if(Od(u,i,c),a&&u.issues.length!==0&&Zn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function qo(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(...Li(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 sy=[];function Mp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:sy,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=Mf(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function wp(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(Zn(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>qo(p,n,g,t,f,h)));else qo(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var oy=j("$ZodObject",(e,t)=>{yt.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(()=>Mp(t));tt(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))In(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Ms,o=t.catchall,a,c=on.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(Zn(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,S=m._zod.run({value:f[p],issues:[]},u);if(S instanceof Promise)h.push(S.then((b)=>qo(b,l,p,f,E,R)));else qo(S,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return wp(h,f,l,u,r.value,e,g===!0)}}),Tp=j("$ZodObjectJIT",(e,t)=>{oy.init(e,t);let n=e._zod.parse,i=Lo(()=>Mp(t)),r=on.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new Xc(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,E=(b,T)=>`
let ${b}_ab = false;
for (let i = 0; i < ${b}.issues.length; i++) {
const iss = ${b}.issues[i];
@@ -13,7 +13,7 @@ ${t.join(`
if (${b}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let R=Object.create(null),S=0;for(let b of g.allKeys)R[b]=`key_${S++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of g.allKeys){if(b==="__proto__")continue;let T=R[b],A=typeof b==="symbol"?`syms[${x.indexOf(b)}]`:_f(b),_=`${A} in input`,M=d[b],F=M?._zod?.optin,I=F!==void 0,O=M?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),I&&O){let K=F==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let R=Object.create(null),S=0;for(let b of g.allKeys)R[b]=`key_${S++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of g.allKeys){if(b==="__proto__")continue;let T=R[b],A=typeof b==="symbol"?`syms[${x.indexOf(b)}]`:vf(b),_=`${A} in input`,M=d[b],F=M?._zod?.optin,I=F!==void 0,O=M?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),I&&O){let K=F==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
const ${T}_present = ${_};
if (!${T}.issues.length || ${T}_present) {
if (${T}.issues.length) {${E(T,A)}
@@ -52,20 +52,20 @@ ${t.join(`
if (${T}.value !== undefined || ${_}) {
newResult[${A}] = ${T}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ms,c=!on.jitless,u=c&&vf.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return bp([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function Dd(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)=>!Zn(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)=>Xn(o,i,hn())))}),t}var wp=j("$ZodUnion",(e,t)=>{yt.init(e,t),tt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),tt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),tt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),tt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>No(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 Dd(o,i,e,r);return Promise.all(o).then((a)=>Dd(a,i,e,r))}});var Tp=j("$ZodIntersection",(e,t)=>{yt.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])=>Od(n,c,l));return Od(n,s,o)}});function qc(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(sr(e)&&sr(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=qc(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=qc(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 Od(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=qc(t.value,n.value);if(!c.valid){if(Zn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ep=j("$ZodRecord",(e,t)=>{yt.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!sr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>Xn(g,r,hn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Li(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Li(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&As.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>Xn(g,r,hn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Li(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Li(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Ap=j("$ZodEnum",(e,t)=>{yt.init(e,t);let n=ws(t.entries),i=new Set(n);e._zod.values=i,tt(e,"pattern",(r)=>{let s=ws(r.def.entries).filter((o)=>yf.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Pi(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}}),Rp=j("$ZodLiteral",(e,t)=>{yt.init(e,t);let n=new Set(t.values);e._zod.values=n,tt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Pi(s):s?Pi(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 Cp=j("$ZodTransform",(e,t)=>{yt.init(e,t),e._zod.optin="optional",on.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Es(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 qn;return n.value=r,n}});function Ud(e,t){return e.value=t.issues.length?void 0:t.value,e}var Jc=j("$ZodOptional",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${No(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)=>Ud(n,s));return Ud(n,r)}return t.innerType._zod.run(n,i)}}),Ip=j("$ZodExactOptional",(e,t)=>{Jc.init(e,t),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Pp=j("$ZodNullable",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${No(i.source)}|null)$`):void 0}),tt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Lp=j("$ZodDefault",(e,t)=>{yt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Fd(s,t));return Fd(r,t)}});function Fd(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Np=j("$ZodPrefault",(e,t)=>{yt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),Dp=j("$ZodNonOptional",(e,t)=>{yt.init(e,t),tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>zd(s,e));return zd(r,e)}});function zd(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 kd(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)=>Xn(r,i,hn()))},input:e.value}),e}var Op=j("$ZodCatch",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>kd(n,s,t,i));return kd(n,r,t,i)}});var Up=j("$ZodPipe",(e,t)=>{yt.init(e,t),tt(e,"values",(n)=>n.def.in._zod.values),tt(e,"optin",(n)=>n.def.in._zod.optin),tt(e,"optout",(n)=>n.def.out._zod.optout),tt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Zo(o,t.in,i));return Zo(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Zo(s,t.out,i));return Zo(r,t.out,i)}});function Zo(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 Fp=j("$ZodReadonly",(e,t)=>{yt.init(e,t),tt(e,"propValues",(n)=>n.def.innerType._zod.propValues),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"optin",(n)=>n.def.innerType?._zod?.optin),tt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(Bd);return Bd(r)}});function Bd(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var zp=j("$ZodCustom",(e,t)=>{Vt.init(e,t),yt.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)=>Gd(s,n,i,e));Gd(r,n,i,e);return}});function Gd(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(or(r))}}class Bp extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var el="~memo",kp=[];function Gp(e){return e!==null&&typeof e==="object"}function Qc(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Hp=new WeakMap,Is=0,Qo=1,Ps=2;function ea(e,t,n){let i=Hp.get(e);if(i!==void 0)return i?Ps:Is;if(t.has(e))return Ps;t.add(e);let r=Is,s=(u)=>{if(r!==Ps&&u?._zod){let f=ea(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=Is;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?Qo:g.value?._zod?ea(g.value,t,n):Is;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Do(c);a(u?o(u,!0):Qo),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?ea(u,t,!1):Qo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),ry(e,r)}function ry(e,t){if(t!==Qo)Hp.set(e,t===Ps);return t}function sy(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ko,Jo=[],oy={alloc(e,t,n){let i=Ko;if(!i)return n;Ko=void 0;let r={value:n,issues:null};return i.set(t.value,r),Jo.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"&&ay(s,r.value))throw new Bp;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=ea(e,new Set,!1);if(m===Is){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Ps||i)n=!0;else i=!0}let u=c.value;if(!Gp(u))return o(c,l);let f=l[el];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[el]=f;let h;if(r===l)h=s;else h=sy(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Qc(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}Ko=h;let g=Jo.length,x=o(c,l);Ko=void 0;let p=Jo.length>g?Jo.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Qc(m.issues):kp;return m});if(p)p.issues=x.issues.length?Qc(x.issues):kp;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function Vp(){return oy}function ay(e,t){let n=e[el]?.backEdges;return n!==void 0&&Gp(t)&&n.has(t)}var cy=()=>{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=Tf(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 ${Nc(s.values[0])}`;return`Invalid option: expected one of ${Ic(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":""}: ${Ic(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 tl(){return{localeError:cy()}}var Wp;class $p{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 ly(){return new $p}(Wp=globalThis).__zod_globalRegistry??(Wp.__zod_globalRegistry=ly());var ar=globalThis.__zod_globalRegistry;function Zp(e){if(e.checks)e.checks=[...e.checks];return e}function Xp(e,t){return new e(Zp({type:"string",...Re(t)}))}function qp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Re(t)})}function Yp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Re(t)})}function jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Re(t)})}function Kp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Re(t)})}function Jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Re(t)})}function Qp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Re(t)})}function em(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Re(t)})}function tm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Re(t)})}function nm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Re(t)})}function im(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Re(t)})}function rm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Re(t)})}function sm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Re(t)})}function om(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Re(t)})}function am(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Re(t)})}function cm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Re(t)})}function lm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Re(t)})}function um(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Re(t)})}function hm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Re(t)})}function fm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Re(t)})}function dm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Re(t)})}function pm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Re(t)})}function mm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Re(t)})}function gm(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Re(t)})}function _m(e,t){return new e({type:"string",format:"date",check:"string_format",...Re(t)})}function xm(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Re(t)})}function vm(e,t){return new e({type:"string",format:"duration",check:"string_format",...Re(t)})}function ym(e,t){return new e(Zp({type:"number",checks:[],...Re(t)}))}function Sm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Re(t)})}function bm(e,t){return new e({type:"boolean",...Re(t)})}function Mm(e){return new e({type:"unknown"})}function wm(e,t){return new e({type:"never",...Re(t)})}function ta(e,t){return new $c({check:"less_than",...Re(t),value:e,inclusive:!1})}function Ls(e,t){return new $c({check:"less_than",...Re(t),value:e,inclusive:!0})}function na(e,t){return new Zc({check:"greater_than",...Re(t),value:e,inclusive:!1})}function Ns(e,t){return new Zc({check:"greater_than",...Re(t),value:e,inclusive:!0})}function ia(e,t){return new xd({check:"multiple_of",...Re(t),value:e})}function ra(e,t){return new yd({check:"max_length",...Re(t),maximum:e})}function Nr(e,t){return new Sd({check:"min_length",...Re(t),minimum:e})}function sa(e,t){return new bd({check:"length_equals",...Re(t),length:e})}function nl(e,t){return new Md({check:"string_format",format:"regex",...Re(t),pattern:e})}function il(e){return new wd({check:"string_format",format:"lowercase",...Re(e)})}function rl(e){return new Td({check:"string_format",format:"uppercase",...Re(e)})}function sl(e,t){return new Ed({check:"string_format",format:"includes",...Re(t),includes:e})}function ol(e,t){return new Ad({check:"string_format",format:"starts_with",...Re(t),prefix:e})}function al(e,t){return new Rd({check:"string_format",format:"ends_with",...Re(t),suffix:e})}function Ni(e){return new Cd({check:"overwrite",tx:e})}function cl(e){return Ni((t)=>t.normalize(e))}function ll(){return Ni((e)=>e.trim())}function ul(){return Ni((e)=>e.toLowerCase())}function hl(){return Ni((e)=>e.toUpperCase())}function fl(){return Ni((e)=>xf(e))}function Tm(e,t,n){return new e({type:"array",element:t,...Re(n)})}function Em(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Re(n)})}function Am(e,t){let n=uy((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(or(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(or(s))}},e(i.value,i)),t);return n}function uy(e,t){let n=new Vt({check:"custom",...Re(t)});return n._zod.check=e,n}function Ds(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))In(e,i,n[i]);return e}function pl(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??ar,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function Rt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;Rt(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ds(o.schema,c);if(t.io==="input"&&Qt(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 Rm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ml(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${Rm(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Rm(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Ms,c=!on.jitless,u=c&&Sf.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return wp([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function Ud(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)=>!Zn(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)=>Xn(o,i,hn())))}),t}var Ep=j("$ZodUnion",(e,t)=>{yt.init(e,t),tt(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),tt(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),tt(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),tt(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>No(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 Ud(o,i,e,r);return Promise.all(o).then((a)=>Ud(a,i,e,r))}});var Ap=j("$ZodIntersection",(e,t)=>{yt.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])=>Fd(n,c,l));return Fd(n,s,o)}});function qc(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(sr(e)&&sr(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=qc(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=qc(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 Fd(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=qc(t.value,n.value);if(!c.valid){if(Zn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Rp=j("$ZodRecord",(e,t)=>{yt.init(e,t);let n=on.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!sr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>Xn(g,r,hn())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Li(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Li(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&As.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>Xn(g,r,hn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Li(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Li(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var Cp=j("$ZodEnum",(e,t)=>{yt.init(e,t);let n=ws(t.entries),i=new Set(n);e._zod.values=i,tt(e,"pattern",(r)=>{let s=ws(r.def.entries).filter((o)=>bf.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Pi(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}}),Ip=j("$ZodLiteral",(e,t)=>{yt.init(e,t);let n=new Set(t.values);e._zod.values=n,tt(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Pi(s):s?Pi(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 Pp=j("$ZodTransform",(e,t)=>{yt.init(e,t),e._zod.optin="optional",on.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Es(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 qn;return n.value=r,n}});function zd(e,t){return e.value=t.issues.length?void 0:t.value,e}var Jc=j("$ZodOptional",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${No(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)=>zd(n,s));return zd(n,r)}return t.innerType._zod.run(n,i)}}),Lp=j("$ZodExactOptional",(e,t)=>{Jc.init(e,t),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Np=j("$ZodNullable",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${No(i.source)}|null)$`):void 0}),tt(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),Dp=j("$ZodDefault",(e,t)=>{yt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>kd(s,t));return kd(r,t)}});function kd(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Op=j("$ZodPrefault",(e,t)=>{yt.init(e,t),e._zod.optin="defaulted",tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),Up=j("$ZodNonOptional",(e,t)=>{yt.init(e,t),tt(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Bd(s,e));return Bd(r,e)}});function Bd(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 Gd(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)=>Xn(r,i,hn()))},input:e.value}),e}var Fp=j("$ZodCatch",(e,t)=>{yt.init(e,t),tt(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),tt(e,"optout",(n)=>n.def.innerType._zod.optout),tt(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>Gd(n,s,t,i));return Gd(n,r,t,i)}});var zp=j("$ZodPipe",(e,t)=>{yt.init(e,t),tt(e,"values",(n)=>n.def.in._zod.values),tt(e,"optin",(n)=>n.def.in._zod.optin),tt(e,"optout",(n)=>n.def.out._zod.optout),tt(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Zo(o,t.in,i));return Zo(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Zo(s,t.out,i));return Zo(r,t.out,i)}});function Zo(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 kp=j("$ZodReadonly",(e,t)=>{yt.init(e,t),tt(e,"propValues",(n)=>n.def.innerType._zod.propValues),tt(e,"values",(n)=>n.def.innerType._zod.values),tt(e,"optin",(n)=>n.def.innerType?._zod?.optin),tt(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(Hd);return Hd(r)}});function Hd(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Bp=j("$ZodCustom",(e,t)=>{Vt.init(e,t),yt.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)=>Vd(s,n,i,e));Vd(r,n,i,e);return}});function Vd(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(or(r))}}class Hp extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var el="~memo",Gp=[];function Vp(e){return e!==null&&typeof e==="object"}function Qc(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Wp=new WeakMap,Is=0,Qo=1,Ps=2;function ea(e,t,n){let i=Wp.get(e);if(i!==void 0)return i?Ps:Is;if(t.has(e))return Ps;t.add(e);let r=Is,s=(u)=>{if(r!==Ps&&u?._zod){let f=ea(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=Is;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?Qo:g.value?._zod?ea(g.value,t,n):Is;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Do(c);a(u?o(u,!0):Qo),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?ea(u,t,!1):Qo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),ay(e,r)}function ay(e,t){if(t!==Qo)Wp.set(e,t===Ps);return t}function cy(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ko,Jo=[],ly={alloc(e,t,n){let i=Ko;if(!i)return n;Ko=void 0;let r={value:n,issues:null};return i.set(t.value,r),Jo.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"&&uy(s,r.value))throw new Hp;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=ea(e,new Set,!1);if(m===Is){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===Ps||i)n=!0;else i=!0}let u=c.value;if(!Vp(u))return o(c,l);let f=l[el];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[el]=f;let h;if(r===l)h=s;else h=cy(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...Qc(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}Ko=h;let g=Jo.length,x=o(c,l);Ko=void 0;let p=Jo.length>g?Jo.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?Qc(m.issues):Gp;return m});if(p)p.issues=x.issues.length?Qc(x.issues):Gp;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function $p(){return ly}function uy(e,t){let n=e[el]?.backEdges;return n!==void 0&&Vp(t)&&n.has(t)}var hy=()=>{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=Af(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 ${Nc(s.values[0])}`;return`Invalid option: expected one of ${Ic(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":""}: ${Ic(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 tl(){return{localeError:hy()}}var Zp;class Xp{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 fy(){return new Xp}(Zp=globalThis).__zod_globalRegistry??(Zp.__zod_globalRegistry=fy());var ar=globalThis.__zod_globalRegistry;function qp(e){if(e.checks)e.checks=[...e.checks];return e}function Yp(e,t){return new e(qp({type:"string",...Re(t)}))}function jp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Re(t)})}function Kp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Re(t)})}function Jp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Re(t)})}function Qp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Re(t)})}function em(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Re(t)})}function tm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Re(t)})}function nm(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Re(t)})}function im(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Re(t)})}function rm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Re(t)})}function sm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Re(t)})}function om(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Re(t)})}function am(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Re(t)})}function cm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Re(t)})}function lm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Re(t)})}function um(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Re(t)})}function hm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Re(t)})}function fm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Re(t)})}function dm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Re(t)})}function pm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Re(t)})}function mm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Re(t)})}function gm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Re(t)})}function _m(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Re(t)})}function xm(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Re(t)})}function vm(e,t){return new e({type:"string",format:"date",check:"string_format",...Re(t)})}function ym(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Re(t)})}function Sm(e,t){return new e({type:"string",format:"duration",check:"string_format",...Re(t)})}function bm(e,t){return new e(qp({type:"number",checks:[],...Re(t)}))}function Mm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Re(t)})}function wm(e,t){return new e({type:"boolean",...Re(t)})}function Tm(e){return new e({type:"unknown"})}function Em(e,t){return new e({type:"never",...Re(t)})}function ta(e,t){return new $c({check:"less_than",...Re(t),value:e,inclusive:!1})}function Ls(e,t){return new $c({check:"less_than",...Re(t),value:e,inclusive:!0})}function na(e,t){return new Zc({check:"greater_than",...Re(t),value:e,inclusive:!1})}function Ns(e,t){return new Zc({check:"greater_than",...Re(t),value:e,inclusive:!0})}function ia(e,t){return new yd({check:"multiple_of",...Re(t),value:e})}function ra(e,t){return new bd({check:"max_length",...Re(t),maximum:e})}function Nr(e,t){return new Md({check:"min_length",...Re(t),minimum:e})}function sa(e,t){return new wd({check:"length_equals",...Re(t),length:e})}function nl(e,t){return new Td({check:"string_format",format:"regex",...Re(t),pattern:e})}function il(e){return new Ed({check:"string_format",format:"lowercase",...Re(e)})}function rl(e){return new Ad({check:"string_format",format:"uppercase",...Re(e)})}function sl(e,t){return new Rd({check:"string_format",format:"includes",...Re(t),includes:e})}function ol(e,t){return new Cd({check:"string_format",format:"starts_with",...Re(t),prefix:e})}function al(e,t){return new Id({check:"string_format",format:"ends_with",...Re(t),suffix:e})}function Ni(e){return new Pd({check:"overwrite",tx:e})}function cl(e){return Ni((t)=>t.normalize(e))}function ll(){return Ni((e)=>e.trim())}function ul(){return Ni((e)=>e.toLowerCase())}function hl(){return Ni((e)=>e.toUpperCase())}function fl(){return Ni((e)=>yf(e))}function Am(e,t,n){return new e({type:"array",element:t,...Re(n)})}function Rm(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Re(n)})}function Cm(e,t){let n=dy((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(or(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(or(s))}},e(i.value,i)),t);return n}function dy(e,t){let n=new Vt({check:"custom",...Re(t)});return n._zod.check=e,n}function Ds(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))In(e,i,n[i]);return e}function pl(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??ar,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function di(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function Rt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;Rt(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ds(o.schema,c);if(t.io==="input"&&Qt(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 Im(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ml(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${Im(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Im(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Pm(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;Pm(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 Lm=new Set(["type","properties","required","additionalProperties"]),Cm=["oneOf","anyOf"];function Im(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 dl(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Lm.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]??Im(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:dl(a)??{allOf:a};In(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=Im(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 hy(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Lm)if(r in e)return;let n=t.filter((r)=>Cm.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=dl(t);else{let r=n[0],s=Cm.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)=>dl([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Ds(e,i)}function gl(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Ds(l,g);if(Ds(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Pm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])hy(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)}Ds(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;In(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:Os(t,"input",e.processors),output:Os(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Qt(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 Qt(i.element,n);if(i.type==="set")return Qt(i.valueType,n);if(i.type==="lazy")return Qt(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 Qt(i.innerType,n);if(i.type==="intersection")return Qt(i.left,n)||Qt(i.right,n);if(i.type==="record"||i.type==="map")return Qt(i.keyType,n)||Qt(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Qt(i.in,n)||Qt(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(Qt(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Qt(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Qt(r,n))return!0;if(i.rest&&Qt(i.rest,n))return!0;return!1}return!1}var Nm=(e,t={})=>(n)=>{let i=pl({...n,processors:t});return Rt(e,i),ml(i,e),gl(i,e)},Os=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=pl({...r??{},target:s,io:t,processors:n});return Rt(e,o),ml(o,e),gl(o,e)};var Dr=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Or=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Dm=(e,t)=>{Dr(e,"minimum",t),Or(e,"maximum",t)},zm=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},km=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Gm=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Om=(e,t)=>Dr(e,"minimum",t.minimum),Um=(e,t)=>Or(e,"maximum",t.maximum),Fm=(e)=>(t,n)=>{Gm(t,n.format);let[i,r]=e[n.format];Dr(t,"minimum",i),Or(t,"maximum",r)},fy={greater_than:(e,t)=>Dr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Or(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zm(e,t.value),number_format:Fm(Oo),bigint_format:Fm(Dc),min_length:Om,max_length:Um,length_equals:(e,t)=>Dm(e,t.length),min_size:Om,max_size:Um,size_equals:(e,t)=>Dm(e,t.size),string_format:(e,t)=>{if(Gm(e,t.format),t.pattern)km(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)=>Bm(e,t.mime)};function Mn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)fy[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Dr(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Dr(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Or(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Or(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)zm(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)Bm(t,r.mime);for(let s of r.patterns??[])km(t,s);return t}var dy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},py=new Map([[jc,od],[jo,ad]]),Hm=(e)=>py.get(e)??e,Vm=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Mn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=dy[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(Hm);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},Wm=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Mn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else di(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},$m=(e,t,n,i)=>{n.type="boolean"};var Zm=(e,t,n,i)=>{n.not={}};var Xm=(e,t,n,i)=>{};var qm=(e,t,n,i)=>{let r=e._zod.def,s=ws(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},Ym=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var jm=(e,t,n,i)=>{di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Km=(e,t,n,i)=>{di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Jm=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Mn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=Rt(s.element,t,{...i,path:[...i.path,"items"]})};function oa(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return oa(t.out);if(t.type==="catch")return oa(t.innerType);return e._zod.optin}var Qm=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)In(r.properties,l,Rt(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"?oa(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=Rt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},eg=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>Rt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},tg=(e,t,n,i)=>{let r=e._zod.def,s=Rt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=Rt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function _l(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=_l(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>_l(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?As:Vc).source;return d}var xl=new WeakMap;function my(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 xl.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=_l(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 ng=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Mn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=Rt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)In(r.patternProperties,Hm(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Rt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=xl.get(t);if(!u)u=[],xl.set(t,u),t.deferred.push(()=>my(t));u.push(e)}r.additionalProperties=Rt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&oa(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},ig=(e,t,n,i)=>{let r=e._zod.def,s=Rt(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"}]},rg=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},vl=Symbol();function sg(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),vl}var og=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=sg(r.defaultValue,e,t,n,i);if(o!==vl)n.default=o},ag=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=sg(r.defaultValue,e,t,n,i);if(o!==vl)n._prefault=o},cg=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},lg=(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;Rt(o,t,i);let a=t.seen.get(e);a.ref=o},ug=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var yl=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var hg=new WeakSet([Object.prototype,Error.prototype]);function aa(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 My=(e,t)=>{Nf.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(hg.has(n))return;hg.add(n),aa(n,"format",(i)=>(r)=>Of(i,r)),aa(n,"flatten",(i)=>(r)=>Df(i,r)),aa(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Ts,2)}),aa(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Ts,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var fn=j("ZodError",My,void 0,{Parent:Error});var fg=Go(fn),dg=Ho(fn),pg=Vo(fn),mg=Wo(fn),gg=Ff(fn),_g=zf(fn),xg=kf(fn),vg=Bf(fn),yg=Gf(fn),Sg=Hf(fn),bg=Vf(fn),Mg=Wf(fn);function Ty(){if(!on.localeError)hn(tl())}function la(){if(!on.memoizer)hn({memoizer:Vp()})}var Mt=j("ZodType",(e,t)=>(Ty(),yt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(un(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 $n(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(TS(e,t))},superRefine(e,t){return this.check(ES(e,t))},overwrite(e){return this.check(Ni(e))},optional(){return Eg(this)},exactOptional(){return fS(this)},nullable(){return Ag(this)},nullish(){return Eg(Ag(this))},nonoptional(e){return xS(this,e)},array(){return ua(this)},or(e){return sS([this,e])},and(e){return aS(this,e)},transform(e){return Rg(this,hS(e))},default(e){return mS(this,e)},prefault(e){return _S(this,e)},catch(e){return yS(this,e)},pipe(e){return Rg(this,e)},readonly(){return MS(this)},describe(e){let t=this.clone();return ar.add(t,{description:e}),t},meta(...e){if(e.length===0)return ar.get(this);let t=this.clone();return ar.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 ko(this,"~standard",{...Yc(this),jsonSchema:{input:Os(this,"input"),output:Os(this,"output")}})},set "~standard"(e){fi(this,"~standard",e)},parse:function e(t,n){return fg(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await dg(this,t,n,{callee:e})},safeParse(e,t){return pg(this,e,t)},async safeParseAsync(e,t){return mg(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){fi(this,"spa",e)},validate(e,t){return kc(this,e,t)},validateAsync(e,t){return Bc(this,e,t)},encode:function e(t,n){return gg(this,t,n,{callee:e})},decode:function e(t,n){return _g(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await xg(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await vg(this,t,n,{callee:e})},safeEncode(e,t){return yg(this,e,t)},safeDecode(e,t){return Sg(this,e,t)},async safeEncodeAsync(e,t){return bg(this,e,t)},async safeDecodeAsync(e,t){return Mg(this,e,t)},toJSONSchema(e){return Nm(this,{})(e)},get description(){return ar.get(this)?.description},get _def(){return this._zod.def}}),Cg=j("_ZodString",(e,t)=>{Yo.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Vm(e,n,i,r)},Af({format:(e)=>Mn(e).format??null,minLength:(e)=>Mn(e).minimum??null,maxLength:(e)=>Mn(e).maximum??null},{regex(...e){return this.check(nl(...e))},includes(...e){return this.check(sl(...e))},startsWith(...e){return this.check(ol(...e))},endsWith(...e){return this.check(al(...e))},min(...e){return this.check(Nr(...e))},max(...e){return this.check(ra(...e))},length(...e){return this.check(sa(...e))},nonempty(...e){return this.check(Nr(1,...e))},lowercase(e){return this.check(il(e))},uppercase(e){return this.check(rl(e))},trim(){return this.check(ll())},normalize(...e){return this.check(cl(...e))},toLowerCase(){return this.check(ul())},toUpperCase(){return this.check(hl())},slugify(){return this.check(fl())}})),Ey=j("ZodString",(e,t)=>{Yo.init(e,t),Cg.init(e,t)},{email(e){return this.check(qp(Py,e))},url(e){return this.check(em(Ny,e))},jwt(e){return this.check(mm(qy,e))},emoji(e){return this.check(tm(Dy,e))},guid(e){return this.check(Yp(Ly,e))},uuid(e){return this.check(jp(ca,e))},uuidv4(e){return this.check(Kp(ca,e))},uuidv6(e){return this.check(Jp(ca,e))},uuidv7(e){return this.check(Qp(ca,e))},nanoid(e){return this.check(nm(Oy,e))},cuid(e){return this.check(im(Uy,e))},cuid2(e){return this.check(rm(Fy,e))},ulid(e){return this.check(sm(zy,e))},base64(e){return this.check(fm($y,e))},base64url(e){return this.check(dm(Zy,e))},xid(e){return this.check(om(ky,e))},ksuid(e){return this.check(am(By,e))},ipv4(e){return this.check(cm(Gy,e))},ipv6(e){return this.check(lm(Hy,e))},cidrv4(e){return this.check(um(Vy,e))},cidrv6(e){return this.check(hm(Wy,e))},e164(e){return this.check(pm(Xy,e))},datetime(e){return this.check(gm(Ay,e))},date(e){return this.check(_m(Ry,e))},time(e){return this.check(xm(Cy,e))},duration(e){return this.check(vm(Iy,e))}});function Zt(e){return Xp(Ey,e)}var wt=j("ZodStringFormat",(e,t)=>{vt.init(e,t),Cg.init(e,t)}),Ay=j("ZodISODateTime",(e,t)=>{np.init(e,t),wt.init(e,t)}),Ry=j("ZodISODate",(e,t)=>{ip.init(e,t),wt.init(e,t)}),Cy=j("ZodISOTime",(e,t)=>{rp.init(e,t),wt.init(e,t)}),Iy=j("ZodISODuration",(e,t)=>{sp.init(e,t),wt.init(e,t)}),Py=j("ZodEmail",(e,t)=>{$d.init(e,t),wt.init(e,t)});var Ly=j("ZodGUID",(e,t)=>{Vd.init(e,t),wt.init(e,t)});var ca=j("ZodUUID",(e,t)=>{Wd.init(e,t),wt.init(e,t)});var Ny=j("ZodURL",(e,t)=>{qd.init(e,t),wt.init(e,t)});var Dy=j("ZodEmoji",(e,t)=>{Yd.init(e,t),wt.init(e,t)});var Oy=j("ZodNanoID",(e,t)=>{jd.init(e,t),wt.init(e,t)});var Uy=j("ZodCUID",(e,t)=>{Kd.init(e,t),wt.init(e,t)});var Fy=j("ZodCUID2",(e,t)=>{Jd.init(e,t),wt.init(e,t)});var zy=j("ZodULID",(e,t)=>{Qd.init(e,t),wt.init(e,t)});var ky=j("ZodXID",(e,t)=>{ep.init(e,t),wt.init(e,t)});var By=j("ZodKSUID",(e,t)=>{tp.init(e,t),wt.init(e,t)});var Gy=j("ZodIPv4",(e,t)=>{op.init(e,t),wt.init(e,t)});var Hy=j("ZodIPv6",(e,t)=>{cp.init(e,t),wt.init(e,t)});var Vy=j("ZodCIDRv4",(e,t)=>{lp.init(e,t),wt.init(e,t)});var Wy=j("ZodCIDRv6",(e,t)=>{up.init(e,t),wt.init(e,t)});var $y=j("ZodBase64",(e,t)=>{fp.init(e,t),wt.init(e,t)});var Zy=j("ZodBase64URL",(e,t)=>{dp.init(e,t),wt.init(e,t)});var Xy=j("ZodE164",(e,t)=>{pp.init(e,t),wt.init(e,t)});var qy=j("ZodJWT",(e,t)=>{mp.init(e,t),wt.init(e,t)});var Ig=j("ZodNumber",(e,t)=>{Kc.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Wm(e,n,i,r),e.isFinite=!0},Af({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Mn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Mn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Mn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Mn(e).format??null},{gt(e,t){return this.check(na(e,t))},gte(e,t){return this.check(Ns(e,t))},min(e,t){return this.check(Ns(e,t))},lt(e,t){return this.check(ta(e,t))},lte(e,t){return this.check(Ls(e,t))},max(e,t){return this.check(Ls(e,t))},int(e){return this.check(wg(e))},safe(e){return this.check(wg(e))},positive(e){return this.check(na(0,e))},nonnegative(e){return this.check(Ns(0,e))},negative(e){return this.check(ta(0,e))},nonpositive(e){return this.check(Ls(0,e))},multipleOf(e,t){return this.check(ia(e,t))},step(e,t){return this.check(ia(e,t))},finite(){return this}}));function Yy(e){return ym(Ig,e)}var jy=j("ZodNumberFormat",(e,t)=>{gp.init(e,t),Ig.init(e,t)});function wg(e){return Sm(jy,e)}var Ky=j("ZodBoolean",(e,t)=>{_p.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$m(e,n,i,r)});function Jy(e){return bm(Ky,e)}var Qy=j("ZodUnknown",(e,t)=>{xp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Xm(e,n,i,r)});function cr(){return Mm(Qy)}var eS=j("ZodNever",(e,t)=>{vp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Zm(e,n,i,r)});function tS(e){return wm(eS,e)}var nS=j("ZodArray",(e,t)=>{la(),yp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Jm(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Nr(e,t))},nonempty(e){return this.check(Nr(1,e))},max(e,t){return this.check(ra(e,t))},length(e,t){return this.check(sa(e,t))},unwrap(){return this.element}});function ua(e,t){return Tm(nS,e,t)}var iS=j("ZodObject",(e,t)=>{la(),Mp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Qm(e,n,i,r),Dv(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Lg(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(un(this._zod.def,{catchall:e}))},passthrough(){return this.clone(un(this._zod.def,{catchall:cr()}))},loose(){return this.clone(un(this._zod.def,{catchall:cr()}))},strict(){return this.clone(un(this._zod.def,{catchall:tS()}))},strip(){return this.clone(un(this._zod.def,{catchall:void 0}))},extend(e){return Ev(this,e)},safeExtend(e){return Av(this,e)},merge(e){return Rv(this,e)},pick(e){return wv(this,e)},omit(e){return Tv(this,e)},partial(...e){return Mf(Ng,this,e[0])},exactPartial(...e){return Mf(Dg,this,e[0],"exactPartial")},required(...e){return Cv(Og,this,e[0])}});function Us(e,t){let n={type:"object",shape:e??{},...Re(t)};return new iS(n)}var rS=j("ZodUnion",(e,t)=>{wp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>eg(e,n,i,r),e.options=t.options});function sS(e,t){return new rS({type:"union",options:e,...Re(t)})}var oS=j("ZodIntersection",(e,t)=>{Tp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tg(e,n,i,r)});function aS(e,t){return new oS({type:"intersection",left:e,right:t})}var Tg=j("ZodRecord",(e,t)=>{la(),Ep.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ng(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Pg(e,t,n){if(!t||!t._zod)return new Tg({type:"record",keyType:Zt(),valueType:e,...Re(t)});return new Tg({type:"record",keyType:e,valueType:t,...Re(n)})}var bl=j("ZodEnum",(e,t)=>{Ap.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>qm(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 bl({...t,checks:[],...Re(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new bl({...t,checks:[],...Re(r),entries:s})}});function Lg(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new bl({type:"enum",entries:n,...Re(t)})}var cS=j("ZodLiteral",(e,t)=>{Rp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ym(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 lS(e,t){return new cS({type:"literal",values:Array.isArray(e)?e:[e],...Re(t)})}var uS=j("ZodTransform",(e,t)=>{la(),Cp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Km(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Es(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(or(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(or(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function hS(e){return new uS({type:"transform",transform:e})}var Ng=j("ZodOptional",(e,t)=>{Jc.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yl(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Eg(e){return new Ng({type:"optional",innerType:e})}var Dg=j("ZodExactOptional",(e,t)=>{Ip.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yl(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function fS(e){return new Dg({type:"optional",innerType:e})}var dS=j("ZodNullable",(e,t)=>{Pp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ig(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Ag(e){return new dS({type:"nullable",innerType:e})}var pS=j("ZodDefault",(e,t)=>{Lp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>og(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mS(e,t){return new pS({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Lc(t)}})}var gS=j("ZodPrefault",(e,t)=>{Np.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ag(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function _S(e,t){return new gS({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Lc(t)}})}var Og=j("ZodNonOptional",(e,t)=>{Dp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function xS(e,t){return new Og({type:"nonoptional",innerType:e,...Re(t)})}var vS=j("ZodCatch",(e,t)=>{Op.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yS(e,t){return new vS({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Rf(t)})}var SS=j("ZodPipe",(e,t)=>{Up.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lg(e,n,i,r),e.in=t.in,e.out=t.out});function Rg(e,t){return new SS({type:"pipe",in:e,out:t})}var bS=j("ZodReadonly",(e,t)=>{Fp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ug(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function MS(e){return new bS({type:"readonly",innerType:e})}var wS=j("ZodCustom",(e,t)=>{zp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jm(e,n,i,r)});function TS(e,t={}){return Em(wS,e,t)}function ES(e,t){return Am(e,t)}/*!
+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 Nm(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;Nm(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 Dm=new Set(["type","properties","required","additionalProperties"]),Pm=["oneOf","anyOf"];function Lm(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 dl(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!Dm.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]??Lm(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:dl(a)??{allOf:a};In(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=Lm(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 py(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Dm)if(r in e)return;let n=t.filter((r)=>Pm.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=dl(t);else{let r=n[0],s=Pm.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)=>dl([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,Ds(e,i)}function gl(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Ds(l,g);if(Ds(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Nm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])py(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)}Ds(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;In(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:Os(t,"input",e.processors),output:Os(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Qt(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 Qt(i.element,n);if(i.type==="set")return Qt(i.valueType,n);if(i.type==="lazy")return Qt(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 Qt(i.innerType,n);if(i.type==="intersection")return Qt(i.left,n)||Qt(i.right,n);if(i.type==="record"||i.type==="map")return Qt(i.keyType,n)||Qt(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Qt(i.in,n)||Qt(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(Qt(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Qt(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Qt(r,n))return!0;if(i.rest&&Qt(i.rest,n))return!0;return!1}return!1}var Om=(e,t={})=>(n)=>{let i=pl({...n,processors:t});return Rt(e,i),ml(i,e),gl(i,e)},Os=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=pl({...r??{},target:s,io:t,processors:n});return Rt(e,o),ml(o,e),gl(o,e)};var Dr=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Or=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Um=(e,t)=>{Dr(e,"minimum",t),Or(e,"maximum",t)},Bm=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Gm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Hm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Vm=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Fm=(e,t)=>Dr(e,"minimum",t.minimum),zm=(e,t)=>Or(e,"maximum",t.maximum),km=(e)=>(t,n)=>{Vm(t,n.format);let[i,r]=e[n.format];Dr(t,"minimum",i),Or(t,"maximum",r)},my={greater_than:(e,t)=>Dr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Or(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Bm(e,t.value),number_format:km(Oo),bigint_format:km(Dc),min_length:Fm,max_length:zm,length_equals:(e,t)=>Um(e,t.length),min_size:Fm,max_size:zm,size_equals:(e,t)=>Um(e,t.size),string_format:(e,t)=>{if(Vm(e,t.format),t.pattern)Gm(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)=>Hm(e,t.mime)};function Mn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)my[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Dr(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Dr(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Or(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Or(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)Bm(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)Hm(t,r.mime);for(let s of r.patterns??[])Gm(t,s);return t}var gy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},_y=new Map([[jc,cd],[jo,ld]]),Wm=(e)=>_y.get(e)??e,$m=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Mn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=gy[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(Wm);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},Zm=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Mn(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else di(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},Xm=(e,t,n,i)=>{n.type="boolean"};var qm=(e,t,n,i)=>{n.not={}};var Ym=(e,t,n,i)=>{};var jm=(e,t,n,i)=>{let r=e._zod.def,s=ws(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},Km=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(di(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(di(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var Jm=(e,t,n,i)=>{di(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Qm=(e,t,n,i)=>{di(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var eg=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Mn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=Rt(s.element,t,{...i,path:[...i.path,"items"]})};function oa(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return oa(t.out);if(t.type==="catch")return oa(t.innerType);return e._zod.optin}var tg=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&di(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)In(r.properties,l,Rt(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"?oa(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=Rt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},ng=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>Rt(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},ig=(e,t,n,i)=>{let r=e._zod.def,s=Rt(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=Rt(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function _l(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=_l(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>_l(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?As:Vc).source;return d}var xl=new WeakMap;function xy(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 xl.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=_l(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 rg=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Mn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=Rt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)In(r.patternProperties,Wm(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Rt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=xl.get(t);if(!u)u=[],xl.set(t,u),t.deferred.push(()=>xy(t));u.push(e)}r.additionalProperties=Rt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&oa(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},sg=(e,t,n,i)=>{let r=e._zod.def,s=Rt(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"}]},og=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},vl=Symbol();function ag(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return di(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),vl}var cg=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=ag(r.defaultValue,e,t,n,i);if(o!==vl)n.default=o},lg=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=ag(r.defaultValue,e,t,n,i);if(o!==vl)n._prefault=o},ug=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{di(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},hg=(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;Rt(o,t,i);let a=t.seen.get(e);a.ref=o},fg=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var yl=(e,t,n,i)=>{let r=e._zod.def;Rt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var dg=new WeakSet([Object.prototype,Error.prototype]);function aa(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 Ey=(e,t)=>{Of.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(dg.has(n))return;dg.add(n),aa(n,"format",(i)=>(r)=>Ff(i,r)),aa(n,"flatten",(i)=>(r)=>Uf(i,r)),aa(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Ts,2)}),aa(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Ts,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var fn=j("ZodError",Ey,void 0,{Parent:Error});var pg=Go(fn),mg=Ho(fn),gg=Vo(fn),_g=Wo(fn),xg=kf(fn),vg=Bf(fn),yg=Gf(fn),Sg=Hf(fn),bg=Vf(fn),Mg=Wf(fn),wg=$f(fn),Tg=Zf(fn);function Ry(){if(!on.localeError)hn(tl())}function la(){if(!on.memoizer)hn({memoizer:$p()})}var Mt=j("ZodType",(e,t)=>(Ry(),yt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(un(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 $n(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(RS(e,t))},superRefine(e,t){return this.check(CS(e,t))},overwrite(e){return this.check(Ni(e))},optional(){return Rg(this)},exactOptional(){return mS(this)},nullable(){return Cg(this)},nullish(){return Rg(Cg(this))},nonoptional(e){return SS(this,e)},array(){return ua(this)},or(e){return cS([this,e])},and(e){return uS(this,e)},transform(e){return Ig(this,pS(e))},default(e){return xS(this,e)},prefault(e){return yS(this,e)},catch(e){return MS(this,e)},pipe(e){return Ig(this,e)},readonly(){return ES(this)},describe(e){let t=this.clone();return ar.add(t,{description:e}),t},meta(...e){if(e.length===0)return ar.get(this);let t=this.clone();return ar.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 ko(this,"~standard",{...Yc(this),jsonSchema:{input:Os(this,"input"),output:Os(this,"output")}})},set "~standard"(e){fi(this,"~standard",e)},parse:function e(t,n){return pg(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await mg(this,t,n,{callee:e})},safeParse(e,t){return gg(this,e,t)},async safeParseAsync(e,t){return _g(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){fi(this,"spa",e)},validate(e,t){return kc(this,e,t)},validateAsync(e,t){return Bc(this,e,t)},encode:function e(t,n){return xg(this,t,n,{callee:e})},decode:function e(t,n){return vg(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await yg(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Sg(this,t,n,{callee:e})},safeEncode(e,t){return bg(this,e,t)},safeDecode(e,t){return Mg(this,e,t)},async safeEncodeAsync(e,t){return wg(this,e,t)},async safeDecodeAsync(e,t){return Tg(this,e,t)},toJSONSchema(e){return Om(this,{})(e)},get description(){return ar.get(this)?.description},get _def(){return this._zod.def}}),Pg=j("_ZodString",(e,t)=>{Yo.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$m(e,n,i,r)},Cf({format:(e)=>Mn(e).format??null,minLength:(e)=>Mn(e).minimum??null,maxLength:(e)=>Mn(e).maximum??null},{regex(...e){return this.check(nl(...e))},includes(...e){return this.check(sl(...e))},startsWith(...e){return this.check(ol(...e))},endsWith(...e){return this.check(al(...e))},min(...e){return this.check(Nr(...e))},max(...e){return this.check(ra(...e))},length(...e){return this.check(sa(...e))},nonempty(...e){return this.check(Nr(1,...e))},lowercase(e){return this.check(il(e))},uppercase(e){return this.check(rl(e))},trim(){return this.check(ll())},normalize(...e){return this.check(cl(...e))},toLowerCase(){return this.check(ul())},toUpperCase(){return this.check(hl())},slugify(){return this.check(fl())}})),Cy=j("ZodString",(e,t)=>{Yo.init(e,t),Pg.init(e,t)},{email(e){return this.check(jp(Dy,e))},url(e){return this.check(nm(Uy,e))},jwt(e){return this.check(_m(Ky,e))},emoji(e){return this.check(im(Fy,e))},guid(e){return this.check(Kp(Oy,e))},uuid(e){return this.check(Jp(ca,e))},uuidv4(e){return this.check(Qp(ca,e))},uuidv6(e){return this.check(em(ca,e))},uuidv7(e){return this.check(tm(ca,e))},nanoid(e){return this.check(rm(zy,e))},cuid(e){return this.check(sm(ky,e))},cuid2(e){return this.check(om(By,e))},ulid(e){return this.check(am(Gy,e))},base64(e){return this.check(pm(qy,e))},base64url(e){return this.check(mm(Yy,e))},xid(e){return this.check(cm(Hy,e))},ksuid(e){return this.check(lm(Vy,e))},ipv4(e){return this.check(um(Wy,e))},ipv6(e){return this.check(hm($y,e))},cidrv4(e){return this.check(fm(Zy,e))},cidrv6(e){return this.check(dm(Xy,e))},e164(e){return this.check(gm(jy,e))},datetime(e){return this.check(xm(Iy,e))},date(e){return this.check(vm(Py,e))},time(e){return this.check(ym(Ly,e))},duration(e){return this.check(Sm(Ny,e))}});function Zt(e){return Yp(Cy,e)}var wt=j("ZodStringFormat",(e,t)=>{vt.init(e,t),Pg.init(e,t)}),Iy=j("ZodISODateTime",(e,t)=>{rp.init(e,t),wt.init(e,t)}),Py=j("ZodISODate",(e,t)=>{sp.init(e,t),wt.init(e,t)}),Ly=j("ZodISOTime",(e,t)=>{op.init(e,t),wt.init(e,t)}),Ny=j("ZodISODuration",(e,t)=>{ap.init(e,t),wt.init(e,t)}),Dy=j("ZodEmail",(e,t)=>{Xd.init(e,t),wt.init(e,t)});var Oy=j("ZodGUID",(e,t)=>{$d.init(e,t),wt.init(e,t)});var ca=j("ZodUUID",(e,t)=>{Zd.init(e,t),wt.init(e,t)});var Uy=j("ZodURL",(e,t)=>{jd.init(e,t),wt.init(e,t)});var Fy=j("ZodEmoji",(e,t)=>{Kd.init(e,t),wt.init(e,t)});var zy=j("ZodNanoID",(e,t)=>{Jd.init(e,t),wt.init(e,t)});var ky=j("ZodCUID",(e,t)=>{Qd.init(e,t),wt.init(e,t)});var By=j("ZodCUID2",(e,t)=>{ep.init(e,t),wt.init(e,t)});var Gy=j("ZodULID",(e,t)=>{tp.init(e,t),wt.init(e,t)});var Hy=j("ZodXID",(e,t)=>{np.init(e,t),wt.init(e,t)});var Vy=j("ZodKSUID",(e,t)=>{ip.init(e,t),wt.init(e,t)});var Wy=j("ZodIPv4",(e,t)=>{cp.init(e,t),wt.init(e,t)});var $y=j("ZodIPv6",(e,t)=>{up.init(e,t),wt.init(e,t)});var Zy=j("ZodCIDRv4",(e,t)=>{hp.init(e,t),wt.init(e,t)});var Xy=j("ZodCIDRv6",(e,t)=>{fp.init(e,t),wt.init(e,t)});var qy=j("ZodBase64",(e,t)=>{pp.init(e,t),wt.init(e,t)});var Yy=j("ZodBase64URL",(e,t)=>{mp.init(e,t),wt.init(e,t)});var jy=j("ZodE164",(e,t)=>{gp.init(e,t),wt.init(e,t)});var Ky=j("ZodJWT",(e,t)=>{_p.init(e,t),wt.init(e,t)});var Lg=j("ZodNumber",(e,t)=>{Kc.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Zm(e,n,i,r),e.isFinite=!0},Cf({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Mn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Mn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Mn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Mn(e).format??null},{gt(e,t){return this.check(na(e,t))},gte(e,t){return this.check(Ns(e,t))},min(e,t){return this.check(Ns(e,t))},lt(e,t){return this.check(ta(e,t))},lte(e,t){return this.check(Ls(e,t))},max(e,t){return this.check(Ls(e,t))},int(e){return this.check(Eg(e))},safe(e){return this.check(Eg(e))},positive(e){return this.check(na(0,e))},nonnegative(e){return this.check(Ns(0,e))},negative(e){return this.check(ta(0,e))},nonpositive(e){return this.check(Ls(0,e))},multipleOf(e,t){return this.check(ia(e,t))},step(e,t){return this.check(ia(e,t))},finite(){return this}}));function Jy(e){return bm(Lg,e)}var Qy=j("ZodNumberFormat",(e,t)=>{xp.init(e,t),Lg.init(e,t)});function Eg(e){return Mm(Qy,e)}var eS=j("ZodBoolean",(e,t)=>{vp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Xm(e,n,i,r)});function tS(e){return wm(eS,e)}var nS=j("ZodUnknown",(e,t)=>{yp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ym(e,n,i,r)});function cr(){return Tm(nS)}var iS=j("ZodNever",(e,t)=>{Sp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qm(e,n,i,r)});function rS(e){return Em(iS,e)}var sS=j("ZodArray",(e,t)=>{la(),bp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>eg(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Nr(e,t))},nonempty(e){return this.check(Nr(1,e))},max(e,t){return this.check(ra(e,t))},length(e,t){return this.check(sa(e,t))},unwrap(){return this.element}});function ua(e,t){return Am(sS,e,t)}var oS=j("ZodObject",(e,t)=>{la(),Tp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tg(e,n,i,r),Fv(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Ml(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(un(this._zod.def,{catchall:e}))},passthrough(){return this.clone(un(this._zod.def,{catchall:cr()}))},loose(){return this.clone(un(this._zod.def,{catchall:cr()}))},strict(){return this.clone(un(this._zod.def,{catchall:rS()}))},strip(){return this.clone(un(this._zod.def,{catchall:void 0}))},extend(e){return Cv(this,e)},safeExtend(e){return Iv(this,e)},merge(e){return Pv(this,e)},pick(e){return Av(this,e)},omit(e){return Rv(this,e)},partial(...e){return Tf(Dg,this,e[0])},exactPartial(...e){return Tf(Og,this,e[0],"exactPartial")},required(...e){return Lv(Ug,this,e[0])}});function Us(e,t){let n={type:"object",shape:e??{},...Re(t)};return new oS(n)}var aS=j("ZodUnion",(e,t)=>{Ep.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ng(e,n,i,r),e.options=t.options});function cS(e,t){return new aS({type:"union",options:e,...Re(t)})}var lS=j("ZodIntersection",(e,t)=>{Ap.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ig(e,n,i,r)});function uS(e,t){return new lS({type:"intersection",left:e,right:t})}var Ag=j("ZodRecord",(e,t)=>{la(),Rp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rg(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ng(e,t,n){if(!t||!t._zod)return new Ag({type:"record",keyType:Zt(),valueType:e,...Re(t)});return new Ag({type:"record",keyType:e,valueType:t,...Re(n)})}var bl=j("ZodEnum",(e,t)=>{Cp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>jm(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 bl({...t,checks:[],...Re(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let o of i)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new bl({...t,checks:[],...Re(r),entries:s})}});function Ml(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new bl({type:"enum",entries:n,...Re(t)})}var hS=j("ZodLiteral",(e,t)=>{Ip.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Km(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 fS(e,t){return new hS({type:"literal",values:Array.isArray(e)?e:[e],...Re(t)})}var dS=j("ZodTransform",(e,t)=>{la(),Pp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Qm(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Es(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(or(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(or(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function pS(e){return new dS({type:"transform",transform:e})}var Dg=j("ZodOptional",(e,t)=>{Jc.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yl(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Rg(e){return new Dg({type:"optional",innerType:e})}var Og=j("ZodExactOptional",(e,t)=>{Lp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yl(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function mS(e){return new Og({type:"optional",innerType:e})}var gS=j("ZodNullable",(e,t)=>{Np.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function Cg(e){return new gS({type:"nullable",innerType:e})}var _S=j("ZodDefault",(e,t)=>{Dp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xS(e,t){return new _S({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Lc(t)}})}var vS=j("ZodPrefault",(e,t)=>{Op.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function yS(e,t){return new vS({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Lc(t)}})}var Ug=j("ZodNonOptional",(e,t)=>{Up.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>og(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function SS(e,t){return new Ug({type:"nonoptional",innerType:e,...Re(t)})}var bS=j("ZodCatch",(e,t)=>{Fp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ug(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function MS(e,t){return new bS({type:"catch",innerType:e,catchValue:typeof t==="function"?t:If(t)})}var wS=j("ZodPipe",(e,t)=>{zp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hg(e,n,i,r),e.in=t.in,e.out=t.out});function Ig(e,t){return new wS({type:"pipe",in:e,out:t})}var TS=j("ZodReadonly",(e,t)=>{kp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fg(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ES(e){return new TS({type:"readonly",innerType:e})}var AS=j("ZodCustom",(e,t)=>{Bp.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Jm(e,n,i,r)});function RS(e,t={}){return Rm(AS,e,t)}function CS(e,t){return Cm(e,t)}var Fg=["neutral","dark","light"];var wl=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),zg=Object.freeze({neutral:wl("neutral",[170,177,188]),dark:wl("dark",[26,26,26]),light:wl("light",[223,227,232])});var jC=zg.neutral.rgb,KC=zg.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 Tt=Uint8Array,dn=Uint16Array,Nl=Int32Array,ha=new Tt([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]),fa=new Tt([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]),Al=new Tt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hg=function(e,t){var n=new dn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Nl(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}},Vg=Hg(ha,2),{b:Wg,r:Rl}=Vg;Wg[28]=258,Rl[258]=28;var $g=Hg(fa,0),{b:RS,r:Ug}=$g,Cl=new dn(32768);for(je=0;je<32768;++je)Yn=(je&43690)>>1|(je&21845)<<1,Yn=(Yn&52428)>>2|(Yn&13107)<<2,Yn=(Yn&61680)>>4|(Yn&3855)<<4,Cl[je]=((Yn&65280)>>8|(Yn&255)<<8)>>1;var Yn,je,Kn=function(e,t,n){var i=e.length,r=0,s=new dn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new dn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new dn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[Cl[f]>>c]=l}}else{a=new dn(i);for(r=0;r<i;++r)if(e[r])a[r]=Cl[o[e[r]-1]++]>>15-e[r]}return a},Di=new Tt(288);for(je=0;je<144;++je)Di[je]=8;var je;for(je=144;je<256;++je)Di[je]=9;var je;for(je=256;je<280;++je)Di[je]=7;var je;for(je=280;je<288;++je)Di[je]=8;var je,ks=new Tt(32);for(je=0;je<32;++je)ks[je]=5;var je,CS=Kn(Di,9,0),IS=Kn(Di,9,1),PS=Kn(ks,5,0),LS=Kn(ks,5,1),Ml=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Ln=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},wl=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Dl=function(e){return(e+7)/8|0},Bs=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Tt(e.subarray(t,n))};var NS=["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"],en=function(e,t,n){var i=Error(t||NS[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,en);if(!n)throw i;return i},DS=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Tt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Tt(r*3);var l=function(we){var gt=n.length;if(we>gt){var ke=new Tt(Math.max(gt*2,we));ke.set(n),n=ke}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Ln(e,f,1);var E=Ln(e,f+1,3);if(f+=3,!E){var R=Dl(f)+4,S=e[R-4]|e[R-3]<<8,b=R+S;if(b>r){if(c)en(0);break}if(a)l(h+S);n.set(e.subarray(R,b),h),t.b=h+=S,t.p=f=b*8,t.f=u;continue}else if(E==1)d=IS,g=LS,x=9,p=5;else if(E==2){var T=Ln(e,f,31)+257,A=Ln(e,f+10,15)+4,_=T+Ln(e,f+5,31)+1;f+=14;var M=new Tt(_),F=new Tt(19);for(var I=0;I<A;++I)F[Al[I]]=Ln(e,f+I*3,7);f+=A*3;var O=Ml(F),K=(1<<O)-1,C=Kn(F,O,1);for(var I=0;I<_;){var G=C[Ln(e,f,K)];f+=G&15;var R=G>>4;if(R<16)M[I++]=R;else{var X=0,z=0;if(R==16)z=3+Ln(e,f,3),f+=2,X=M[I-1];else if(R==17)z=3+Ln(e,f,7),f+=3;else if(R==18)z=11+Ln(e,f,127),f+=7;while(z--)M[I++]=X}}var te=M.subarray(0,T),H=M.subarray(T);x=Ml(te),p=Ml(H),d=Kn(te,x,1),g=Kn(H,p,1)}else en(1);if(f>m){if(c)en(0);break}}if(a)l(h+131072);var Q=(1<<x)-1,ee=(1<<p)-1,Te=f;for(;;Te=f){var X=d[wl(e,f)&Q],ve=X>>4;if(f+=X&15,f>m){if(c)en(0);break}if(!X)en(2);if(ve<256)n[h++]=ve;else if(ve==256){Te=f,d=null;break}else{var He=ve-254;if(ve>264){var I=ve-257,Me=ha[I];He=Ln(e,f,(1<<Me)-1)+Wg[I],f+=Me}var Z=g[wl(e,f)&ee],re=Z>>4;if(!Z)en(3);f+=Z&15;var H=RS[re];if(re>3){var Me=fa[re];H+=wl(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)en(0);break}if(a)l(h+131072);var se=h+He;if(h<H){var Ie=s-H,Pe=Math.min(H,se);if(Ie+h<0)en(3);for(;h<Pe;++h)n[h]=i[Ie+h]}for(;h<se;++h)n[h]=n[h-H]}}if(t.l=d,t.p=Te,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?Bs(n,0,h):n.subarray(0,h)},pi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},Fs=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},Tl=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:Xg,l:0};if(r==1){var o=new Tt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(b,T){return b.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new dn(h+1),g=Il(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var S=s[i].s;if(d[S]==t)--d[S],++x}g=t}return{t:new Tt(d),l:g}},Il=function(e,t,n){return e.s==-1?Math.max(Il(e.l,t,n+1),Il(e.r,t,n+1)):t[e.s]=n},Fg=function(e){var t=e.length;while(t&&!e[--t]);var n=new dn(++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}},zs=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Zg=function(e,t,n){var i=n.length,r=Dl(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},zg=function(e,t,n,i,r,s,o,a,c,l,u){pi(t,u++,n),++r[256];var f=Tl(r,15),{t:h,l:d}=f,g=Tl(s,15),{t:x,l:p}=g,m=Fg(h),{c:E,n:R}=m,S=Fg(x),{c:b,n:T}=S,A=new dn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<b.length;++_)++A[b[_]&31];var M=Tl(A,7),{t:F,l:I}=M,O=19;for(;O>4&&!F[Al[O-1]];--O);var K=l+5<<3,C=zs(r,Di)+zs(s,ks)+o,G=zs(r,h)+zs(s,x)+o+14+3*O+zs(A,F)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&K<=C&&K<=G)return Zg(t,u,e.subarray(c,c+l));var X,z,te,H;if(pi(t,u,1+(G<C)),u+=2,G<C){X=Kn(h,d,0),z=h,te=Kn(x,p,0),H=x;var Q=Kn(F,I,0);pi(t,u,R-257),pi(t,u+5,T-1),pi(t,u+10,O-4),u+=14;for(var _=0;_<O;++_)pi(t,u+3*_,F[Al[_]]);u+=3*O;var ee=[E,b];for(var Te=0;Te<2;++Te){var ve=ee[Te];for(var _=0;_<ve.length;++_){var He=ve[_]&31;if(pi(t,u,Q[He]),u+=F[He],He>15)pi(t,u,ve[_]>>5&127),u+=ve[_]>>12}}}else X=CS,z=Di,te=PS,H=ks;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var He=Me>>18&31;if(Fs(t,u,X[He+257]),u+=z[He+257],He>7)pi(t,u,Me>>23&31),u+=ha[He];var Z=Me&31;if(Fs(t,u,te[Z]),u+=H[Z],Z>3)Fs(t,u,Me>>5&8191),u+=fa[Z]}else Fs(t,u,X[Me]),u+=z[Me]}return Fs(t,u,X[256]),u+z[256]},OS=new Nl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xg=new Tt(0),US=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Tt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=OS[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new dn(32768),p=s.h||new dn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Xe){return(e[Xe]^e[Xe+1]<<m^e[Xe+2]<<E)&g},S=new Nl(25000),b=new dn(288),T=new dn(32),A=0,_=0,M=s.i||0,F=0,I=s.w||0,O=0;for(;M+2<o;++M){var K=R(M),C=M&32767,G=p[K];if(x[C]=G,p[K]=C,I<=M){var X=o-M;if((A>7000||F>24576)&&(X>423||!l)){u=zg(e,c,0,S,b,T,_,F,O,M-O,u),F=A=_=0,O=M;for(var z=0;z<286;++z)b[z]=0;for(var z=0;z<30;++z)T[z]=0}var te=2,H=0,Q=d,ee=C-G&32767;if(X>2&&K==R(M-ee)){var Te=Math.min(h,X)-1,ve=Math.min(32767,M),He=Math.min(258,X);while(ee<=ve&&--Q&&C!=G){if(e[M+te]==e[M+te-ee]){var Me=0;for(;Me<He&&e[M+Me]==e[M+Me-ee];++Me);if(Me>te){if(te=Me,H=ee,Me>Te)break;var Z=Math.min(ee,Me-2),re=0;for(var z=0;z<Z;++z){var se=M-ee+z&32767,Ie=x[se],Pe=se-Ie&32767;if(Pe>re)re=Pe,G=se}}}C=G,G=x[C],ee+=C-G&32767}}if(H){S[F++]=268435456|Rl[te]<<18|Ug[H];var we=Rl[te]&31,gt=Ug[H]&31;_+=ha[we]+fa[gt],++b[257+we],++T[gt],I=M+te,++A}else S[F++]=e[M],++b[e[M]]}}for(M=Math.max(M,I);M<o;++M)S[F++]=e[M],++b[e[M]];if(u=zg(e,c,l,S,b,T,_,F,O,M-O,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=M,s.w=I}else{for(var M=s.w||0;M<o+l;M+=65535){var ke=M+65535;if(ke>=o)c[u/8|0]=l,ke=o;u=Zg(c,u+1,e.subarray(M,ke))}s.i=o}return Bs(a,0,i+Dl(u)+r)},FS=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}(),zS=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=FS[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var kS=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Tt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return US(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)},qg=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 jn=function(e,t){return e[t]|e[t+1]<<8},Nn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},El=function(e,t){return Nn(e,t)+Nn(e,t+4)*4294967296},Wt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function BS(e,t){return kS(e,t||{},0,0)}function GS(e,t){return DS(e,{i:2},t&&t.out,t&&t.dictionary)}var Yg=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=qg(i,s[1]),s=s[0];if(s instanceof Tt)n[o]=[s,a];else n[o+="/"]=[new Tt(0),a],Yg(s,o,n,i)}},kg=typeof TextEncoder<"u"&&new TextEncoder,Pl=typeof TextDecoder<"u"&&new TextDecoder,HS=0;try{Pl.decode(Xg,{stream:!0}),HS=1}catch(e){}var VS=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:Bs(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 Bg(e,t){if(t){var n=new Tt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(kg)return kg.encode(e);var r=e.length,s=new Tt(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 Tt(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 Bs(s,0,o)}function WS(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(Pl)return Pl.decode(e);else{var r=VS(e),{s,r:n}=r;if(n.length)en(8);return s}}var $S=function(e,t){return t+30+jn(e,t+26)+jn(e,t+28)},ZS=function(e,t,n){var i=jn(e,t+28),r=WS(e.subarray(t+46,t+46+i),!(jn(e,t+8)&2048)),s=t+46+i,o=Nn(e,t+20),a=n&&o==4294967295?XS(e,s):[o,Nn(e,t+24),Nn(e,t+42)],c=a[0],l=a[1],u=a[2];return[jn(e,t+10),c,l,r,s+jn(e,t+30)+jn(e,t+32),u]},XS=function(e,t){for(;jn(e,t)!=1;t+=4+jn(e,t+2));return[El(e,t+12),El(e,t+4),El(e,t+20)]},Ll=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)en(9);t+=i+4}return t},Gg=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=Ll(l);if(Wt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)en(10);if(Wt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Wt(e,t,n.crc),Wt(e,t+4,s<0?-s-2:s),Wt(e,t+8,n.size);if(Wt(e,t+12,c),Wt(e,t+14,f),t+=16,o!=null)Wt(e,t,u),Wt(e,t+6,n.attrs),Wt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;Wt(e,t,+g),Wt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},qS=function(e,t,n,i,r){Wt(e,t,101010256),Wt(e,t+8,n),Wt(e,t+10,n),Wt(e,t+12,i),Wt(e,t+16,r)};function jg(e,t){if(!t)t={};var n={},i=[];Yg(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=Bg(o),h=f.length,d=l.comment,g=d&&Bg(d),x=g&&g.length,p=Ll(l.extra);if(h>65535)en(11);var m=u?BS(c,l):c,E=m.length,R=zS();R.p(c),i.push(qg(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var S=new Tt(s+22),b=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];Gg(S,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+Ll(f.extra);S.set(f.c,f.o+_),Gg(S,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return qS(S,r,i.length,T,b),S}function Kg(e,t){var n={},i=e.length-22;for(;Nn(e,i)!=101010256;--i)if(!i||e.length-i>65558)en(13);var r=jn(e,i+8);if(!r)return{};var s=Nn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Nn(e,i-12);if(o=Nn(e,a)==101075792,o)r=Nn(e,a+32),s=Nn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=ZS(e,s,o),f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=u[5],m=$S(e,p);if(s=x,!c||c({name:g,size:h,originalSize:d,compression:f}))if(!f)n[g]=Bs(e,m,m+h);else if(f==8)n[g]=GS(e.subarray(m,m+h),{out:new Tt(d)});else en(14,"unknown compression type "+f)}return n}var mi=67108864,Ol=Zt().regex(/^[a-z][a-z0-9_-]{0,79}$/),YS=Zt().regex(/^sha256:[a-f0-9]{64}$/),Jg=Us({version:lS("kiln.asset.v1"),assetId:Ol,revisionId:Ol,parentRevision:Ol.optional(),name:Zt().min(1).max(200),tags:ua(Zt().max(80)).max(30),createdAt:Zt().datetime(),description:Zt().max(4000).optional(),brief:Zt().max(8000).optional(),attribution:Us({model:Zt().max(200).optional(),harness:Zt().max(200).optional(),author:Zt().max(200).optional()}).optional(),editable:Jy(),files:Pg(Zt(),Us({sha256:YS,bytes:Yy().int().nonnegative().max(mi)})),build:Us({engine:Zt(),options:Pg(Zt(),cr()),warnings:ua(Zt()),integration:cr().optional(),qa:cr().optional(),dependencies:ua(cr()).optional(),rebuild:Lg(["engine-required","external-dependencies-required"])}).optional(),preview:Us({fidelity:cr().optional(),error:Zt().optional()}).optional()}),jS=new Set(["asset.glb","source.kiln.js","preview.png"]);function Qg(e){let t=Jg.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(!jS.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>mi||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");Ul(e.files["asset.glb"])}function Ul(e){if(e.length<20||e.length>mi)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 Fl(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){Qg(i);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}for(let i of Object.values(t))n+=i.length;if(n>mi)throw Error("Bundle exceeds 64 MiB");return jg(t,{level:0})}function e_(e){if(e.length>mi+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=Kg(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>mi||n>400||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png)$/.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=Jg.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 f of Object.keys(c.files)){if(!i[l+f])throw Error("Bundle file missing");u.files[f]=i[l+f],s.add(l+f)}Qg(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function t_(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 k_="186",Hi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Vi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},B_=0,lu=1,G_=2;var Js=1,H_=2,es=3,Wi=0,Yt=1,An=2,ni=0,Qs=1,uu=2,hu=3,fu=4,V_=5;var ts=100,W_=101,$_=102,Z_=103,X_=104,q_=200,Y_=201,j_=202,K_=203,J_=204,Q_=205,e0=206,t0=207,n0=208,i0=209,r0=210,s0=211,o0=212,a0=213,c0=214,l0=0,u0=1,h0=2,du=3,f0=4,d0=5,p0=6,m0=7,g0=0,_0=1,x0=2,kn=0,pu=1,mu=2,gu=3,eo=4,_u=5,xu=6,vu=7;var ns=301,mr=302,Ga=303,Ha=304,to=306,is=1000,rs=1001,Va=1002,Bn=1003,Wa=1004;var gr=1005;var Gt=1006,ss=1007;var ii=1008;var Gn=1009,v0=1010,y0=1011,no=1012,yu=1013,$i=1014,Mi=1015,ri=1016,Su=1017,bu=1018,os=1020,S0=35902,b0=35899,M0=1021,w0=1022,si=1023,_r=1026,xr=1027,T0=1028,Mu=1029,vr=1030,wu=1031;var Tu=1033,$a=33776,Za=33777,Xa=33778,qa=33779,Eu=35840,Au=35841,Ru=35842,Cu=35843,Iu=36196,Pu=37492,Lu=37496,Nu=37488,Du=37489,Ya=37490,Ou=37491,Uu=37808,Fu=37809,zu=37810,ku=37811,Bu=37812,Gu=37813,Hu=37814,Vu=37815,Wu=37816,$u=37817,Zu=37818,Xu=37819,qu=37820,Yu=37821,ju=36492,Ku=36494,Ju=36495,Qu=36283,eh=36284,ja=36285,th=36286;var nh=2300,Ka=2301;var ih=0,io=1,as=2;var rh=0,E0=1,yr="",Zi="srgb",gn="srgb-linear",sh="linear",ft="srgb";var A0=512,R0=513,C0=514,Ja=515,I0=516,P0=517,Qa=518,L0=519;var oh="300 es",ah=2000;function KS(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function JS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Kr(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function N0(){let e=Kr("canvas");return e.style.display="block",e}var n_={},Jr=null;function Ks(...e){let t="THREE."+e.shift();if(Jr)Jr("log",t,...e);else console.log(t,...e)}function D0(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 Ce(...e){e=D0(e);let t="THREE."+e.shift();if(Jr)Jr("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=D0(e);let t="THREE."+e.shift();if(Jr)Jr("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function dr(...e){let t=e.join(" ");if(t in n_)return;n_[t]=!0,Ce(...e)}function O0(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 U0={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Hn{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 Xt=["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"],i_=1234567,Ys=Math.PI/180,pr=180/Math.PI;function zn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xt[e&255]+Xt[e>>8&255]+Xt[e>>16&255]+Xt[e>>24&255]+"-"+Xt[t&255]+Xt[t>>8&255]+"-"+Xt[t>>16&15|64]+Xt[t>>24&255]+"-"+Xt[n&63|128]+Xt[n>>8&255]+"-"+Xt[n>>16&255]+Xt[n>>24&255]+Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]).toLowerCase()}function Ze(e,t,n){return Math.max(t,Math.min(n,e))}function ch(e,t){return(e%t+t)%t}function QS(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function eb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function js(e,t,n){return(1-n)*e+n*t}function tb(e,t,n,i){return js(e,t,1-Math.exp(-n*i))}function nb(e,t=1){return t-Math.abs(ch(e,t*2)-t)}function ib(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 rb(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 sb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ob(e,t){return e+Math.random()*(t-e)}function ab(e){return e*(0.5-Math.random())}function cb(e){if(e!==void 0)i_=e;let t=i_+=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 lb(e){return e*Ys}function ub(e){return e*pr}function hb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function fb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function db(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function pb(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Ce("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Fn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var ro={DEG2RAD:Ys,RAD2DEG:pr,generateUUID:zn,clamp:Ze,euclideanModulo:ch,mapLinear:QS,inverseLerp:eb,lerp:js,damp:tb,pingpong:nb,smoothstep:ib,smootherstep:rb,randInt:sb,randFloat:ob,randFloatSpread:ab,seededRandom:cb,degToRad:lb,radToDeg:ub,isPowerOfTwo:hb,ceilPowerOfTwo:fb,floorPowerOfTwo:db,setQuaternionFromProperEuler:pb,normalize:ot,denormalize:Fn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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(Ze(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 kt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Ce("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ze(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(r_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(r_.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=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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 zl.copy(this).projectOnVector(e),this.sub(zl)}reflect(e){return this.sub(zl.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(Ze(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 zl=new U,r_=new kt;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],S=i[2],b=i[5],T=i[8];return r[0]=s*g+o*m+a*S,r[3]=s*x+o*E+a*b,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*S,r[4]=c*x+l*E+u*b,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*S,r[5]=f*x+h*E+d*b,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return dr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(kl.makeScale(e,t)),this}rotate(e){return dr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(kl.makeRotation(-e)),this}translate(e,t){return dr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(kl.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 kl=new ze,s_=new ze().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),o_=new ze().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function mb(){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=bi(r.r),r.g=bi(r.g),r.b=bi(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=jr(r.r),r.g=jr(r.g),r.b=jr(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 dr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return dr("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:s_,fromXYZ:o_,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:s_,fromXYZ:o_,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=mb();function bi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function jr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Ur;class lh{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(Ur===void 0)Ur=Kr("canvas");Ur.width=e.width,Ur.height=e.height;let i=Ur.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Ur}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=Kr("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]=bi(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(bi(t[n]/255)*255);else t[n]=bi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ce("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var gb=0;class so{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:gb++}),this.uuid=zn(),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(Bl(i[s].image));else r.push(Bl(i[s]))}else r=Bl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Bl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return lh.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 Ce("Texture: Unable to serialize Texture."),{}}var _b=0,Gl=new U;class Et extends Hn{constructor(e=Et.DEFAULT_IMAGE,t=Et.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Et.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:_b++}),this.uuid=zn(),this.name="",this.source=new so(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Gl).x}get height(){return this.source.getSize(Gl).y}get depth(){return this.source.getSize(Gl).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){Ce(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ce(`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++}}Et.DEFAULT_IMAGE=null;Et.DEFAULT_MAPPING=300;Et.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,S=(p+1)/2,b=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>S)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=b/n,r=T/n;else if(R>S)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=b/i,r=A/i;else if(S<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(S),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this.w=Ze(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this.w=Ze(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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 uh extends Hn{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Et(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 so(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends uh{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class ec extends Et{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 hh extends Et{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Fr.setFromMatrixColumn(e,0).length(),r=1/Fr.setFromMatrixColumn(e,1).length(),s=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(xb,e,vb)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),Oi.crossVectors(n,pn),Oi.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),Oi.crossVectors(n,pn)}return Oi.normalize(),da.crossVectors(pn,Oi),i[0]=Oi.x,i[4]=da.x,i[8]=pn.x,i[1]=Oi.y,i[5]=da.y,i[9]=pn.y,i[2]=Oi.z,i[6]=da.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],S=n[15],b=i[0],T=i[4],A=i[8],_=i[12],M=i[1],F=i[5],I=i[9],O=i[13],K=i[2],C=i[6],G=i[10],X=i[14],z=i[3],te=i[7],H=i[11],Q=i[15];return r[0]=s*b+o*M+a*K+c*z,r[4]=s*T+o*F+a*C+c*te,r[8]=s*A+o*I+a*G+c*H,r[12]=s*_+o*O+a*X+c*Q,r[1]=l*b+u*M+f*K+h*z,r[5]=l*T+u*F+f*C+h*te,r[9]=l*A+u*I+f*G+h*H,r[13]=l*_+u*O+f*X+h*Q,r[2]=d*b+g*M+x*K+p*z,r[6]=d*T+g*F+x*C+p*te,r[10]=d*A+g*I+x*G+p*H,r[14]=d*_+g*O+x*X+p*Q,r[3]=m*b+E*M+R*K+S*z,r[7]=m*T+E*F+R*C+S*te,r[11]=m*A+E*I+R*G+S*H,r[15]=m*_+E*O+R*X+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,S=s*h-c*l,b=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*S+p*b)+i*(d*E-g*S+p*T)-r*(d*R-g*b+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,S=n*a-i*o,b=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,M=l*p-h*d,F=u*x-f*g,I=u*p-h*g,O=f*p-h*x,K=m*O-E*I+R*F+S*M-b*_+T*A;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/K;return e[0]=(o*O-a*I+c*F)*C,e[1]=(i*I-n*O-r*F)*C,e[2]=(g*T-x*b+p*S)*C,e[3]=(f*b-u*T-h*S)*C,e[4]=(a*M-s*O-c*_)*C,e[5]=(t*O-i*M+r*_)*C,e[6]=(x*R-d*T-p*E)*C,e[7]=(l*T-f*R+h*E)*C,e[8]=(s*I-o*M+c*A)*C,e[9]=(n*M-t*I-r*A)*C,e[10]=(d*b-g*R+p*m)*C,e[11]=(u*R-l*b-h*m)*C,e[12]=(o*_-s*F-a*A)*C,e[13]=(t*F-n*_+i*A)*C,e[14]=(g*E-d*S-x*m)*C,e[15]=(l*S-u*E+f*m)*C,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:S,y:b,z:T}=n;return i[0]=(1-(g+p))*S,i[1]=(h+R)*S,i[2]=(d-E)*S,i[3]=0,i[4]=(h-R)*b,i[5]=(1-(f+p))*b,i[6]=(x+m)*b,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Fr.set(i[0],i[1],i[2]).length(),o=Fr.set(i[4],i[5],i[6]).length(),a=Fr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Dn.copy(this);let c=1/s,l=1/o,u=1/a;return Dn.elements[0]*=c,Dn.elements[1]*=c,Dn.elements[2]*=c,Dn.elements[4]*=l,Dn.elements[5]*=l,Dn.elements[6]*=l,Dn.elements[8]*=u,Dn.elements[9]*=u,Dn.elements[10]*=u,t.setFromRotationMatrix(Dn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Fr=new U,Dn=new Ge,xb=new U(0,0,0),vb=new U(1,1,1),Oi=new U,da=new U,pn=new U,a_=new Ge,c_=new kt;class ti{constructor(e=0,t=0,n=0,i=ti.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Ze(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Ze(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(Ze(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Ze(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Ze(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(-Ze(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Ce("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return a_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(a_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return c_.setFromEuler(this),this.setFromQuaternion(c_,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}}ti.DEFAULT_ORDER="XYZ";class tc{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 yb=0,l_=new U,zr=new kt,gi=new Ge,pa=new U,Gs=new U,Sb=new U,bb=new kt,u_=new U(1,0,0),h_=new U(0,1,0),f_=new U(0,0,1),d_={type:"added"},Mb={type:"removed"},kr={type:"childadded",child:null},Hl={type:"childremoved",child:null};class ut extends Hn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:yb++}),this.uuid=zn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new U,t=new ti,n=new kt,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 Ge},normalMatrix:{value:new ze}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tc,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 zr.setFromAxisAngle(e,t),this.quaternion.multiply(zr),this}rotateOnWorldAxis(e,t){return zr.setFromAxisAngle(e,t),this.quaternion.premultiply(zr),this}rotateX(e){return this.rotateOnAxis(u_,e)}rotateY(e){return this.rotateOnAxis(h_,e)}rotateZ(e){return this.rotateOnAxis(f_,e)}translateOnAxis(e,t){return l_.copy(e).applyQuaternion(this.quaternion),this.position.add(l_.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(u_,e)}translateY(e){return this.translateOnAxis(h_,e)}translateZ(e){return this.translateOnAxis(f_,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)pa.copy(e);else pa.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Gs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)gi.lookAt(Gs,pa,this.up);else gi.lookAt(pa,Gs,this.up);if(this.quaternion.setFromRotationMatrix(gi),i)gi.extractRotation(i.matrixWorld),zr.setFromRotationMatrix(gi),this.quaternion.premultiply(zr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(d_),kr.child=e,this.dispatchEvent(kr),kr.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Mb),Hl.child=e,this.dispatchEvent(Hl),Hl.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),gi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),gi.multiply(e.parent.matrixWorld);return e.applyMatrix4(gi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(d_),kr.child=e,this.dispatchEvent(kr),kr.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(Gs,e,Sb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gs,bb,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ut.DEFAULT_UP=new U(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Qn extends ut{constructor(){super();this.isGroup=!0,this.type="Group"}}var wb={type:"move"};class oo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Qn,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 Qn,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 Qn,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 g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(wb)}}}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 Qn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var F0={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},Ui={h:0,s:0,l:0},ma={h:0,s:0,l:0};function Vl(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=ch(e,1),t=Ze(t,0,1),n=Ze(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=Vl(s,r,e+0.3333333333333333),this.g=Vl(s,r,e),this.b=Vl(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ce("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:Ce("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 Ce("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=F0[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ce("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=bi(e.r),this.g=bi(e.g),this.b=bi(e.b),this}copyLinearToSRGB(e){return this.r=jr(e.r),this.g=jr(e.g),this.b=jr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(qt.copy(this),e),Math.round(Ze(qt.r*255,0,255))*65536+Math.round(Ze(qt.g*255,0,255))*256+Math.round(Ze(qt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(qt.copy(this),t);let{r:n,g:i,b:r}=qt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(qt.copy(this),e);let{r:t,g:n,b:i}=qt;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(Ui),this.setHSL(Ui.h+e,Ui.s+t,Ui.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(Ui),e.getHSL(ma);let n=js(Ui.h,ma.h,t),i=js(Ui.s,ma.s,t),r=js(Ui.l,ma.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 qt=new Oe;Oe.NAMES=F0;class cs extends ut{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ti,this.environmentIntensity=1,this.environmentRotation=new ti,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 On=new U,_i=new U,Wl=new U,xi=new U,Br=new U,Gr=new U,p_=new U,$l=new U,Zl=new U,Xl=new U,ql=new at,Yl=new at,jl=new at;class En{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),On.subVectors(e,t),i.cross(On);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){On.subVectors(i,t),_i.subVectors(n,t),Wl.subVectors(e,t);let s=On.dot(On),o=On.dot(_i),a=On.dot(Wl),c=_i.dot(_i),l=_i.dot(Wl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,xi)===null)return!1;return xi.x>=0&&xi.y>=0&&xi.x+xi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,xi)===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,xi.x),a.addScaledVector(s,xi.y),a.addScaledVector(o,xi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return ql.setScalar(0),Yl.setScalar(0),jl.setScalar(0),ql.fromBufferAttribute(e,t),Yl.fromBufferAttribute(e,n),jl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(ql,r.x),s.addScaledVector(Yl,r.y),s.addScaledVector(jl,r.z),s}static isFrontFacing(e,t,n,i){return On.subVectors(n,t),_i.subVectors(e,t),On.cross(_i).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 On.subVectors(this.c,this.b),_i.subVectors(this.a,this.b),On.cross(_i).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return En.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return En.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return En.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return En.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return En.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;Br.subVectors(i,n),Gr.subVectors(r,n),$l.subVectors(e,n);let a=Br.dot($l),c=Gr.dot($l);if(a<=0&&c<=0)return t.copy(n);Zl.subVectors(e,i);let l=Br.dot(Zl),u=Gr.dot(Zl);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Br,s);Xl.subVectors(e,r);let h=Br.dot(Xl),d=Gr.dot(Xl);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Gr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return p_.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(p_,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Br,s).addScaledVector(Gr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class nn{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(Un.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Un.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=Un.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,Un);else Un.fromBufferAttribute(r,s);Un.applyMatrix4(e.matrixWorld),this.expandByPoint(Un)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();ga.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();ga.copy(n.boundingBox)}ga.applyMatrix4(e.matrixWorld),this.union(ga)}}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,Un),Un.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(Hs),_a.subVectors(this.max,Hs),Hr.subVectors(e.a,Hs),Vr.subVectors(e.b,Hs),Wr.subVectors(e.c,Hs),Fi.subVectors(Vr,Hr),zi.subVectors(Wr,Vr),lr.subVectors(Hr,Wr);let t=[0,-Fi.z,Fi.y,0,-zi.z,zi.y,0,-lr.z,lr.y,Fi.z,0,-Fi.x,zi.z,0,-zi.x,lr.z,0,-lr.x,-Fi.y,Fi.x,0,-zi.y,zi.x,0,-lr.y,lr.x,0];if(!Kl(t,Hr,Vr,Wr,_a))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Kl(t,Hr,Vr,Wr,_a))return!1;return xa.crossVectors(Fi,zi),t=[xa.x,xa.y,xa.z],Kl(t,Hr,Vr,Wr,_a)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Un).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Un).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 vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vi),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 vi=[new U,new U,new U,new U,new U,new U,new U,new U],Un=new U,ga=new nn,Hr=new U,Vr=new U,Wr=new U,Fi=new U,zi=new U,lr=new U,Hs=new U,_a=new U,xa=new U,ur=new U;function Kl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){ur.fromArray(e,s);let a=r.x*Math.abs(ur.x)+r.y*Math.abs(ur.y)+r.z*Math.abs(ur.z),c=t.dot(ur),l=n.dot(ur),u=i.dot(ur);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Pt=new U,va=new Ne,Tb=0;class Bt extends Hn{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:Tb++}),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++)va.fromBufferAttribute(this,t),va.applyMatrix3(e),this.setXY(t,va.x,va.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix3(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.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=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Fn(t,this.array);return t}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Fn(t,this.array);return t}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Fn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Fn(t,this.array);return t}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class nc extends Bt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ic extends Bt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class an extends Bt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Eb=new nn,Vs=new U,Jl=new U;class xn{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 Eb.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;Vs.subVectors(e,this.center);let t=Vs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Vs,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 Jl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vs.copy(e.center).add(Jl)),this.expandByPoint(Vs.copy(e.center).sub(Jl));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 Ab=0,wn=new Ge,Ql=new ut,$r=new U,mn=new nn,Ws=new nn,zt=new U;class jt extends Hn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ab++}),this.uuid=zn(),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((KS(e))?ic:nc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return wn.makeRotationFromQuaternion(e),this.applyMatrix4(wn),this}rotateX(e){return wn.makeRotationX(e),this.applyMatrix4(wn),this}rotateY(e){return wn.makeRotationY(e),this.applyMatrix4(wn),this}rotateZ(e){return wn.makeRotationZ(e),this.applyMatrix4(wn),this}translate(e,t,n){return wn.makeTranslation(e,t,n),this.applyMatrix4(wn),this}scale(e,t,n){return wn.makeScale(e,t,n),this.applyMatrix4(wn),this}lookAt(e){return Ql.lookAt(e),Ql.updateMatrix(),this.applyMatrix4(Ql.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($r).negate(),this.translate($r.x,$r.y,$r.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)Ce("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 nn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new 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))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new 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(Ws.setFromBufferAttribute(o),this.morphTargetsRelative)zt.addVectors(mn.min,Ws.min),mn.expandByPoint(zt),zt.addVectors(mn.max,Ws.max),mn.expandByPoint(zt);else mn.expandByPoint(Ws.min),mn.expandByPoint(Ws.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)$r.fromBufferAttribute(e,c),zt.add($r);i=Math.max(i,n.distanceToSquared(zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Bt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new U,a[A]=new U;let c=new U,l=new U,u=new U,f=new Ne,h=new Ne,d=new Ne,g=new U,x=new U;function p(A,_,M){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let F=1/(h.x*d.y-d.x*h.y);if(!isFinite(F))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(F),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(F),o[A].add(g),o[_].add(g),o[M].add(g),a[A].add(x),a[_].add(x),a[M].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:I}=M;for(let O=F,K=F+I;O<K;O+=3)p(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let E=new U,R=new U,S=new U,b=new U;function T(A){S.fromBufferAttribute(i,A),b.copy(S);let _=o[A];E.copy(_),E.sub(S.multiplyScalar(S.dot(_))).normalize(),R.crossVectors(b,_);let F=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,F)}for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:I}=M;for(let O=F,K=F+I;O<K;O+=3)T(e.getX(O+0)),T(e.getX(O+1)),T(e.getX(O+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 Bt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new 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 f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)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,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Bt(f,l,u)}if(this.index===null)return Ce("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new jt,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ao{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=zn()}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=zn();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=zn();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 tn=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++)tn.fromBufferAttribute(this,t),tn.applyMatrix4(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.applyNormalMatrix(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.transformDirection(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Fn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Fn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Fn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Fn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ks("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 Bt(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){Ks("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 eu=new U,Rb=new U,Cb=new ze;class Tn{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=eu.subVectors(n,t).cross(Rb.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(eu),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||Cb.getNormalMatrix(e),i=this.coplanarPoint(eu).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 Ib=0;class cn extends Hn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ib++}),this.uuid=zn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ce(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ce(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Tn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var yi=new U,tu=new U,ya=new U,Sa=new U;class Xi{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,yi)),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=yi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return yi.copy(this.origin).addScaledVector(this.direction,t),yi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){tu.copy(e).add(t).multiplyScalar(0.5),ya.copy(t).sub(e).normalize(),Sa.copy(this.origin).sub(tu);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(ya),o=Sa.dot(this.direction),a=-Sa.dot(ya),c=Sa.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(tu).addScaledVector(ya,f);return h}intersectSphere(e,t){if(e.radius<0)return null;yi.subVectors(e.center,this.origin);let n=yi.dot(this.direction),i=yi.dot(yi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,yi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),S=Math.abs(c),b=Math.abs(l),T,A,_,M,F,I,O,K,C,G,X,z;if(R>=S&&R>=b)if(_=a,I=u,C=d,z=p,a>=0)T=c,A=l,M=f,F=h,O=g,K=x,G=m,X=E;else T=l,A=c,M=h,F=f,O=x,K=g,G=E,X=m;else if(S>=b)if(_=c,I=f,C=g,z=m,c>=0)T=l,A=a,M=h,F=u,O=x,K=d,G=E,X=p;else T=a,A=l,M=u,F=h,O=d,K=x,G=p,X=E;else if(_=l,I=h,C=x,z=E,l>=0)T=a,A=c,M=u,F=f,O=d,K=g,G=p,X=m;else T=c,A=a,M=f,F=u,O=g,K=d,G=m,X=p;if(_===0)return null;let te=T/_,H=A/_,Q=1/_,ee=M-te*I,Te=F-H*I,ve=O-te*C,He=K-H*C,Me=G-te*z,Z=X-H*z,re=Me*He-Z*ve,se=ee*Z-Te*Me,Ie=ve*Te-He*ee;if(i){if(re<0||se<0||Ie<0)return null}else if((re<0||se<0||Ie<0)&&(re>0||se>0||Ie>0))return null;let Pe=re+se+Ie;if(Pe===0)return null;let we=Q*(re*I+se*C+Ie*z);if(Pe>0?we<0:we>0)return null;return this.at(we/Pe,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 oi extends cn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 m_=new Ge,hr=new Xi,ba=new xn,g_=new U,Ma=new U,wa=new U,Ta=new U,nu=new U,Ea=new U,__=new U,Aa=new U;class mt extends ut{constructor(e=new jt,t=new oi){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){Ea.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(nu.fromBufferAttribute(u,e),s)Ea.addScaledVector(nu,l);else Ea.addScaledVector(nu.sub(t),l)}t.add(Ea)}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(ba.copy(n.boundingSphere),ba.applyMatrix4(r),hr.copy(e.ray).recast(e.near),ba.containsPoint(hr.origin)===!1){if(hr.intersectSphere(ba,g_)===null)return;if(hr.origin.distanceToSquared(g_)>(e.far-e.near)**2)return}if(m_.copy(r).invert(),hr.copy(e.ray).applyMatrix4(m_),n.boundingBox!==null){if(hr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,hr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=Ra(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=Ra(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=R,T=R+1,A=R+2;if(i=Ra(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=Ra(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Pb(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;Aa.copy(a),Aa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Aa);if(l<n.near||l>n.far)return null;return{distance:l,point:Aa.clone(),object:e}}function Ra(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Ma),e.getVertexPosition(c,wa),e.getVertexPosition(l,Ta);let u=Pb(e,t,n,i,Ma,wa,Ta,__);if(u){let f=new U;if(En.getBarycoord(__,Ma,wa,Ta,f),r)u.uv=En.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=En.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=En.getInterpolatedAttribute(o,a,c,l,f,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};En.getNormal(Ma,wa,Ta,h.normal),u.face=h,u.barycoord=f}return u}var $s=new at,x_=new at,v_=new at,Lb=new at,y_=new Ge,Ca=new U,iu=new xn,S_=new Ge,ru=new Xi;class rc extends mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new nn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingBox.expandByPoint(Ca)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingSphere.expandByPoint(Ca)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(iu.copy(this.boundingSphere),iu.applyMatrix4(i),e.ray.intersectsSphere(iu)===!1)return;if(S_.copy(i).invert(),ru.copy(e.ray).applyMatrix4(S_),this.boundingBox!==null){if(ru.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,ru)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new at,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ce("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(x_.fromBufferAttribute(i.attributes.skinIndex,e),v_.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)$s.copy(t),t.set(0,0,0,0);else $s.set(...t,1),t.set(0,0,0);$s.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=v_.getComponent(r);if(s!==0){let o=x_.getComponent(r);y_.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Lb.copy($s).applyMatrix4(y_),s)}}if(t.isVector4)t.w=$s.w;return t.applyMatrix4(this.bindMatrixInverse)}}class co extends ut{constructor(){super();this.isBone=!0,this.type="Bone"}}class lo extends Et{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var b_=new Ge,Nb=new Ge;class uo{constructor(e=[],t=[]){this.uuid=zn(),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){Ce("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:Nb;b_.multiplyMatrices(o,t[r]),b_.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new uo(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 lo(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)Ce("Skeleton: No bone found with UUID:",r),s=new co;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class Gi extends Bt{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 Zr=new Ge,M_=new Ge,Ia=[],w_=new nn,Db=new Ge,Zs=new mt,Xs=new xn;class us extends mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Gi(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,Db)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new nn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zr),w_.copy(e.boundingBox).applyMatrix4(Zr),this.boundingBox.union(w_)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zr),Xs.copy(e.boundingSphere).applyMatrix4(Zr),this.boundingSphere.union(Xs)}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(Zs.geometry=this.geometry,Zs.material=this.material,Zs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Xs.copy(this.boundingSphere),Xs.applyMatrix4(n),e.ray.intersectsSphere(Xs)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Zr),M_.multiplyMatrices(n,Zr),Zs.matrixWorld=M_,Zs.raycast(e,Ia);for(let s=0,o=Ia.length;s<o;s++){let a=Ia[s];a.instanceId=r,a.object=this,t.push(a)}Ia.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Gi(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 lo(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 fr=new xn,Ob=new Ne(0.5,0.5),Pa=new U;class ho{constructor(e=new Tn,t=new Tn,n=new Tn,i=new Tn,r=new Tn,s=new Tn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],S=r[15];if(i[0].setComponents(c-s,h-l,p-d,S-m).normalize(),i[1].setComponents(c+s,h+l,p+d,S+m).normalize(),i[2].setComponents(c+o,h+u,p+g,S+E).normalize(),i[3].setComponents(c-o,h-u,p-g,S-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,S-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,S-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,S+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();fr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();fr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(fr)}intersectsSprite(e){fr.center.set(0,0,0);let t=Ob.distanceTo(e.center);return fr.radius=0.7071067811865476+t,fr.applyMatrix4(e.matrixWorld),this.intersectsSphere(fr)}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(Pa.x=i.normal.x>0?e.max.x:e.min.x,Pa.y=i.normal.y>0?e.max.y:e.min.y,Pa.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Pa)<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 fo extends cn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ka=new U,Ba=new U,T_=new Ge,qs=new Xi,La=new xn,su=new U,E_=new U;class qi extends ut{constructor(e=new jt,t=new fo){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++)ka.fromBufferAttribute(t,i-1),Ba.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ka.distanceTo(Ba);e.setAttribute("lineDistance",new an(n,1))}else Ce("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(La.copy(n.boundingSphere),La.applyMatrix4(i),La.radius+=r,e.ray.intersectsSphere(La)===!1)return;T_.copy(i).invert(),qs.copy(e.ray).applyMatrix4(T_);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=Na(this,e,qs,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=Na(this,e,qs,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=Na(this,e,qs,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=Na(this,e,qs,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Na(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ka.fromBufferAttribute(a,r),Ba.fromBufferAttribute(a,s),n.distanceSqToSegment(ka,Ba,su,E_)>i)return;su.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(su);if(l<t.near||l>t.far)return;return{distance:l,point:E_.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var A_=new U,R_=new U;class sc extends qi{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)A_.fromBufferAttribute(t,i),R_.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+A_.distanceTo(R_);e.setAttribute("lineDistance",new an(n,1))}else Ce("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class oc extends qi{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class po extends cn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var C_=new Ge,cu=new Xi,Da=new xn,Oa=new U;class hs extends ut{constructor(e=new jt,t=new po){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Da.copy(n.boundingSphere),Da.applyMatrix4(i),Da.radius+=r,e.ray.intersectsSphere(Da)===!1)return;C_.copy(i).invert(),cu.copy(e.ray).applyMatrix4(C_);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);Oa.fromBufferAttribute(u,x),I_(Oa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)Oa.fromBufferAttribute(u,d),I_(Oa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function I_(e,t,n,i,r,s,o){let a=cu.distanceSqToPoint(e);if(a<n){let c=new U;cu.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 ac extends Et{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 Sr extends Et{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new so(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class fh extends Sr{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 cc extends Et{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Yi extends jt{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new an(c,3)),this.setAttribute("normal",new an(l,3)),this.setAttribute("uv",new an(u,2));function d(g,x,p,m,E,R,S,b,T,A,_){let M=R/T,F=S/A,I=R/2,O=S/2,K=b/2,C=T+1,G=A+1,X=0,z=0,te=new U;for(let H=0;H<G;H++){let Q=H*F-O;for(let ee=0;ee<C;ee++){let Te=ee*M-I;te[g]=Te*m,te[x]=Q*E,te[p]=K,c.push(te.x,te.y,te.z),te[g]=0,te[x]=0,te[p]=b>0?1:-1,l.push(te.x,te.y,te.z),u.push(ee/T),u.push(1-H/A),X+=1}}for(let H=0;H<A;H++)for(let Q=0;Q<T;Q++){let ee=f+Q+C*H,Te=f+Q+C*(H+1),ve=f+(Q+1)+C*(H+1),He=f+(Q+1)+C*H;a.push(ee,Te,He),a.push(Te,ve,He),z+=6}o.addGroup(h,z,_),h+=z,f+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mo extends jt{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),S=m+1+c*(p+1),b=m+1+c*p;h.push(E,R,b),h.push(R,S,b)}this.setIndex(h),this.setAttribute("position",new an(d,3)),this.setAttribute("normal",new an(g,3)),this.setAttribute("uv",new an(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mo(e.width,e.height,e.widthSegments,e.heightSegments)}}function br(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(P_(r))if(r.isRenderTargetTexture)Ce("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(P_(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 Kt(e){let t={};for(let n=0;n<e.length;n++){let i=br(e[n]);for(let r in i)t[r]=i[r]}return t}function P_(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Ub(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function dh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var z0={clone:br,merge:Kt},Fb=`void main() {
+*/var Tt=Uint8Array,dn=Uint16Array,Ol=Int32Array,ha=new Tt([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]),fa=new Tt([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]),Cl=new Tt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$g=function(e,t){var n=new dn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Ol(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}},Zg=$g(ha,2),{b:Xg,r:Il}=Zg;Xg[28]=258,Il[258]=28;var qg=$g(fa,0),{b:PS,r:kg}=qg,Pl=new dn(32768);for(je=0;je<32768;++je)Yn=(je&43690)>>1|(je&21845)<<1,Yn=(Yn&52428)>>2|(Yn&13107)<<2,Yn=(Yn&61680)>>4|(Yn&3855)<<4,Pl[je]=((Yn&65280)>>8|(Yn&255)<<8)>>1;var Yn,je,Kn=function(e,t,n){var i=e.length,r=0,s=new dn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new dn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new dn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[Pl[f]>>c]=l}}else{a=new dn(i);for(r=0;r<i;++r)if(e[r])a[r]=Pl[o[e[r]-1]++]>>15-e[r]}return a},Di=new Tt(288);for(je=0;je<144;++je)Di[je]=8;var je;for(je=144;je<256;++je)Di[je]=9;var je;for(je=256;je<280;++je)Di[je]=7;var je;for(je=280;je<288;++je)Di[je]=8;var je,ks=new Tt(32);for(je=0;je<32;++je)ks[je]=5;var je,LS=Kn(Di,9,0),NS=Kn(Di,9,1),DS=Kn(ks,5,0),OS=Kn(ks,5,1),Tl=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Ln=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},El=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ul=function(e){return(e+7)/8|0},Bs=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Tt(e.subarray(t,n))};var US=["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"],en=function(e,t,n){var i=Error(t||US[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,en);if(!n)throw i;return i},FS=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Tt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Tt(r*3);var l=function(we){var gt=n.length;if(we>gt){var ke=new Tt(Math.max(gt*2,we));ke.set(n),n=ke}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Ln(e,f,1);var E=Ln(e,f+1,3);if(f+=3,!E){var R=Ul(f)+4,S=e[R-4]|e[R-3]<<8,b=R+S;if(b>r){if(c)en(0);break}if(a)l(h+S);n.set(e.subarray(R,b),h),t.b=h+=S,t.p=f=b*8,t.f=u;continue}else if(E==1)d=NS,g=OS,x=9,p=5;else if(E==2){var T=Ln(e,f,31)+257,A=Ln(e,f+10,15)+4,_=T+Ln(e,f+5,31)+1;f+=14;var M=new Tt(_),F=new Tt(19);for(var I=0;I<A;++I)F[Cl[I]]=Ln(e,f+I*3,7);f+=A*3;var O=Tl(F),K=(1<<O)-1,C=Kn(F,O,1);for(var I=0;I<_;){var G=C[Ln(e,f,K)];f+=G&15;var R=G>>4;if(R<16)M[I++]=R;else{var X=0,z=0;if(R==16)z=3+Ln(e,f,3),f+=2,X=M[I-1];else if(R==17)z=3+Ln(e,f,7),f+=3;else if(R==18)z=11+Ln(e,f,127),f+=7;while(z--)M[I++]=X}}var te=M.subarray(0,T),H=M.subarray(T);x=Tl(te),p=Tl(H),d=Kn(te,x,1),g=Kn(H,p,1)}else en(1);if(f>m){if(c)en(0);break}}if(a)l(h+131072);var Q=(1<<x)-1,ee=(1<<p)-1,Te=f;for(;;Te=f){var X=d[El(e,f)&Q],ve=X>>4;if(f+=X&15,f>m){if(c)en(0);break}if(!X)en(2);if(ve<256)n[h++]=ve;else if(ve==256){Te=f,d=null;break}else{var He=ve-254;if(ve>264){var I=ve-257,Me=ha[I];He=Ln(e,f,(1<<Me)-1)+Xg[I],f+=Me}var Z=g[El(e,f)&ee],re=Z>>4;if(!Z)en(3);f+=Z&15;var H=PS[re];if(re>3){var Me=fa[re];H+=El(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)en(0);break}if(a)l(h+131072);var se=h+He;if(h<H){var Ie=s-H,Pe=Math.min(H,se);if(Ie+h<0)en(3);for(;h<Pe;++h)n[h]=i[Ie+h]}for(;h<se;++h)n[h]=n[h-H]}}if(t.l=d,t.p=Te,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?Bs(n,0,h):n.subarray(0,h)},pi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},Fs=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},Al=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:jg,l:0};if(r==1){var o=new Tt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(b,T){return b.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new dn(h+1),g=Ll(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var S=s[i].s;if(d[S]==t)--d[S],++x}g=t}return{t:new Tt(d),l:g}},Ll=function(e,t,n){return e.s==-1?Math.max(Ll(e.l,t,n+1),Ll(e.r,t,n+1)):t[e.s]=n},Bg=function(e){var t=e.length;while(t&&!e[--t]);var n=new dn(++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}},zs=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Yg=function(e,t,n){var i=n.length,r=Ul(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},Gg=function(e,t,n,i,r,s,o,a,c,l,u){pi(t,u++,n),++r[256];var f=Al(r,15),{t:h,l:d}=f,g=Al(s,15),{t:x,l:p}=g,m=Bg(h),{c:E,n:R}=m,S=Bg(x),{c:b,n:T}=S,A=new dn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<b.length;++_)++A[b[_]&31];var M=Al(A,7),{t:F,l:I}=M,O=19;for(;O>4&&!F[Cl[O-1]];--O);var K=l+5<<3,C=zs(r,Di)+zs(s,ks)+o,G=zs(r,h)+zs(s,x)+o+14+3*O+zs(A,F)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&K<=C&&K<=G)return Yg(t,u,e.subarray(c,c+l));var X,z,te,H;if(pi(t,u,1+(G<C)),u+=2,G<C){X=Kn(h,d,0),z=h,te=Kn(x,p,0),H=x;var Q=Kn(F,I,0);pi(t,u,R-257),pi(t,u+5,T-1),pi(t,u+10,O-4),u+=14;for(var _=0;_<O;++_)pi(t,u+3*_,F[Cl[_]]);u+=3*O;var ee=[E,b];for(var Te=0;Te<2;++Te){var ve=ee[Te];for(var _=0;_<ve.length;++_){var He=ve[_]&31;if(pi(t,u,Q[He]),u+=F[He],He>15)pi(t,u,ve[_]>>5&127),u+=ve[_]>>12}}}else X=LS,z=Di,te=DS,H=ks;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var He=Me>>18&31;if(Fs(t,u,X[He+257]),u+=z[He+257],He>7)pi(t,u,Me>>23&31),u+=ha[He];var Z=Me&31;if(Fs(t,u,te[Z]),u+=H[Z],Z>3)Fs(t,u,Me>>5&8191),u+=fa[Z]}else Fs(t,u,X[Me]),u+=z[Me]}return Fs(t,u,X[256]),u+z[256]},zS=new Ol([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),jg=new Tt(0),kS=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Tt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=zS[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new dn(32768),p=s.h||new dn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Xe){return(e[Xe]^e[Xe+1]<<m^e[Xe+2]<<E)&g},S=new Ol(25000),b=new dn(288),T=new dn(32),A=0,_=0,M=s.i||0,F=0,I=s.w||0,O=0;for(;M+2<o;++M){var K=R(M),C=M&32767,G=p[K];if(x[C]=G,p[K]=C,I<=M){var X=o-M;if((A>7000||F>24576)&&(X>423||!l)){u=Gg(e,c,0,S,b,T,_,F,O,M-O,u),F=A=_=0,O=M;for(var z=0;z<286;++z)b[z]=0;for(var z=0;z<30;++z)T[z]=0}var te=2,H=0,Q=d,ee=C-G&32767;if(X>2&&K==R(M-ee)){var Te=Math.min(h,X)-1,ve=Math.min(32767,M),He=Math.min(258,X);while(ee<=ve&&--Q&&C!=G){if(e[M+te]==e[M+te-ee]){var Me=0;for(;Me<He&&e[M+Me]==e[M+Me-ee];++Me);if(Me>te){if(te=Me,H=ee,Me>Te)break;var Z=Math.min(ee,Me-2),re=0;for(var z=0;z<Z;++z){var se=M-ee+z&32767,Ie=x[se],Pe=se-Ie&32767;if(Pe>re)re=Pe,G=se}}}C=G,G=x[C],ee+=C-G&32767}}if(H){S[F++]=268435456|Il[te]<<18|kg[H];var we=Il[te]&31,gt=kg[H]&31;_+=ha[we]+fa[gt],++b[257+we],++T[gt],I=M+te,++A}else S[F++]=e[M],++b[e[M]]}}for(M=Math.max(M,I);M<o;++M)S[F++]=e[M],++b[e[M]];if(u=Gg(e,c,l,S,b,T,_,F,O,M-O,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=M,s.w=I}else{for(var M=s.w||0;M<o+l;M+=65535){var ke=M+65535;if(ke>=o)c[u/8|0]=l,ke=o;u=Yg(c,u+1,e.subarray(M,ke))}s.i=o}return Bs(a,0,i+Ul(u)+r)},BS=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}(),GS=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=BS[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var HS=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Tt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return kS(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)},Kg=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 jn=function(e,t){return e[t]|e[t+1]<<8},Nn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Rl=function(e,t){return Nn(e,t)+Nn(e,t+4)*4294967296},Wt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function VS(e,t){return HS(e,t||{},0,0)}function WS(e,t){return FS(e,{i:2},t&&t.out,t&&t.dictionary)}var Jg=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Kg(i,s[1]),s=s[0];if(s instanceof Tt)n[o]=[s,a];else n[o+="/"]=[new Tt(0),a],Jg(s,o,n,i)}},Hg=typeof TextEncoder<"u"&&new TextEncoder,Nl=typeof TextDecoder<"u"&&new TextDecoder,$S=0;try{Nl.decode(jg,{stream:!0}),$S=1}catch(e){}var ZS=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:Bs(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 Vg(e,t){if(t){var n=new Tt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(Hg)return Hg.encode(e);var r=e.length,s=new Tt(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 Tt(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 Bs(s,0,o)}function XS(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(Nl)return Nl.decode(e);else{var r=ZS(e),{s,r:n}=r;if(n.length)en(8);return s}}var qS=function(e,t){return t+30+jn(e,t+26)+jn(e,t+28)},YS=function(e,t,n){var i=jn(e,t+28),r=XS(e.subarray(t+46,t+46+i),!(jn(e,t+8)&2048)),s=t+46+i,o=Nn(e,t+20),a=n&&o==4294967295?jS(e,s):[o,Nn(e,t+24),Nn(e,t+42)],c=a[0],l=a[1],u=a[2];return[jn(e,t+10),c,l,r,s+jn(e,t+30)+jn(e,t+32),u]},jS=function(e,t){for(;jn(e,t)!=1;t+=4+jn(e,t+2));return[Rl(e,t+12),Rl(e,t+4),Rl(e,t+20)]},Dl=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)en(9);t+=i+4}return t},Wg=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=Dl(l);if(Wt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)en(10);if(Wt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Wt(e,t,n.crc),Wt(e,t+4,s<0?-s-2:s),Wt(e,t+8,n.size);if(Wt(e,t+12,c),Wt(e,t+14,f),t+=16,o!=null)Wt(e,t,u),Wt(e,t+6,n.attrs),Wt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;Wt(e,t,+g),Wt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},KS=function(e,t,n,i,r){Wt(e,t,101010256),Wt(e,t+8,n),Wt(e,t+10,n),Wt(e,t+12,i),Wt(e,t+16,r)};function Qg(e,t){if(!t)t={};var n={},i=[];Jg(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=Vg(o),h=f.length,d=l.comment,g=d&&Vg(d),x=g&&g.length,p=Dl(l.extra);if(h>65535)en(11);var m=u?VS(c,l):c,E=m.length,R=GS();R.p(c),i.push(Kg(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var S=new Tt(s+22),b=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];Wg(S,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+Dl(f.extra);S.set(f.c,f.o+_),Wg(S,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return KS(S,r,i.length,T,b),S}function e_(e,t){var n={},i=e.length-22;for(;Nn(e,i)!=101010256;--i)if(!i||e.length-i>65558)en(13);var r=jn(e,i+8);if(!r)return{};var s=Nn(e,i+16),o=s==4294967295||r==65535;if(o){var a=Nn(e,i-12);if(o=Nn(e,a)==101075792,o)r=Nn(e,a+32),s=Nn(e,a+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=YS(e,s,o),f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=u[5],m=qS(e,p);if(s=x,!c||c({name:g,size:h,originalSize:d,compression:f}))if(!f)n[g]=Bs(e,m,m+h);else if(f==8)n[g]=WS(e.subarray(m,m+h),{out:new Tt(d)});else en(14,"unknown compression type "+f)}return n}var mi=67108864,Fl=Zt().regex(/^[a-z][a-z0-9_-]{0,79}$/),JS=Zt().regex(/^sha256:[a-f0-9]{64}$/),t_=Us({version:fS("kiln.asset.v1"),assetId:Fl,revisionId:Fl,parentRevision:Fl.optional(),name:Zt().min(1).max(200),tags:ua(Zt().max(80)).max(30),createdAt:Zt().datetime(),description:Zt().max(4000).optional(),brief:Zt().max(8000).optional(),attribution:Us({model:Zt().max(200).optional(),harness:Zt().max(200).optional(),author:Zt().max(200).optional()}).optional(),editable:tS(),files:Ng(Zt(),Us({sha256:JS,bytes:Jy().int().nonnegative().max(mi)})),build:Us({engine:Zt(),options:Ng(Zt(),cr()),warnings:ua(Zt()),integration:cr().optional(),qa:cr().optional(),dependencies:ua(cr()).optional(),rebuild:Ml(["engine-required","external-dependencies-required"])}).optional(),preview:Us({fidelity:cr().optional(),error:Zt().optional(),backdrop:Ml(Fg).optional()}).optional()}),QS=new Set(["asset.glb","source.kiln.js","preview.png"]);function n_(e){let t=t_.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(!QS.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>mi||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");zl(e.files["asset.glb"])}function zl(e){if(e.length<20||e.length>mi)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 kl(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){n_(i);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}for(let i of Object.values(t))n+=i.length;if(n>mi)throw Error("Bundle exceeds 64 MiB");return Qg(t,{level:0})}function i_(e){if(e.length>mi+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=e_(e,{filter:(o)=>{if(t+=o.originalSize,n++,t>mi||n>400||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png)$/.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=t_.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 f of Object.keys(c.files)){if(!i[l+f])throw Error("Bundle file missing");u.files[f]=i[l+f],s.add(l+f)}n_(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function r_(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 H_="186",Hi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Vi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},V_=0,hu=1,W_=2;var Js=1,$_=2,es=3,Wi=0,Yt=1,An=2,ni=0,Qs=1,fu=2,du=3,pu=4,Z_=5;var ts=100,X_=101,q_=102,Y_=103,j_=104,K_=200,J_=201,Q_=202,e0=203,t0=204,n0=205,i0=206,r0=207,s0=208,o0=209,a0=210,c0=211,l0=212,u0=213,h0=214,f0=0,d0=1,p0=2,mu=3,m0=4,g0=5,_0=6,x0=7,v0=0,y0=1,S0=2,kn=0,gu=1,_u=2,xu=3,eo=4,vu=5,yu=6,Su=7;var ns=301,mr=302,Ga=303,Ha=304,to=306,is=1000,rs=1001,Va=1002,Bn=1003,Wa=1004;var gr=1005;var Gt=1006,ss=1007;var ii=1008;var Gn=1009,b0=1010,M0=1011,no=1012,bu=1013,$i=1014,Mi=1015,ri=1016,Mu=1017,wu=1018,os=1020,w0=35902,T0=35899,E0=1021,A0=1022,si=1023,_r=1026,xr=1027,R0=1028,Tu=1029,vr=1030,Eu=1031;var Au=1033,$a=33776,Za=33777,Xa=33778,qa=33779,Ru=35840,Cu=35841,Iu=35842,Pu=35843,Lu=36196,Nu=37492,Du=37496,Ou=37488,Uu=37489,Ya=37490,Fu=37491,zu=37808,ku=37809,Bu=37810,Gu=37811,Hu=37812,Vu=37813,Wu=37814,$u=37815,Zu=37816,Xu=37817,qu=37818,Yu=37819,ju=37820,Ku=37821,Ju=36492,Qu=36494,eh=36495,th=36283,nh=36284,ja=36285,ih=36286;var rh=2300,Ka=2301;var sh=0,io=1,as=2;var oh=0,C0=1,yr="",Zi="srgb",gn="srgb-linear",ah="linear",ft="srgb";var I0=512,P0=513,L0=514,Ja=515,N0=516,D0=517,Qa=518,O0=519;var ch="300 es",lh=2000;function eb(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 Kr(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function U0(){let e=Kr("canvas");return e.style.display="block",e}var s_={},Jr=null;function Ks(...e){let t="THREE."+e.shift();if(Jr)Jr("log",t,...e);else console.log(t,...e)}function F0(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 Ce(...e){e=F0(e);let t="THREE."+e.shift();if(Jr)Jr("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=F0(e);let t="THREE."+e.shift();if(Jr)Jr("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function dr(...e){let t=e.join(" ");if(t in s_)return;s_[t]=!0,Ce(...e)}function z0(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 k0={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Hn{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 Xt=["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"],o_=1234567,Ys=Math.PI/180,pr=180/Math.PI;function zn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xt[e&255]+Xt[e>>8&255]+Xt[e>>16&255]+Xt[e>>24&255]+"-"+Xt[t&255]+Xt[t>>8&255]+"-"+Xt[t>>16&15|64]+Xt[t>>24&255]+"-"+Xt[n&63|128]+Xt[n>>8&255]+"-"+Xt[n>>16&255]+Xt[n>>24&255]+Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]).toLowerCase()}function Ze(e,t,n){return Math.max(t,Math.min(n,e))}function uh(e,t){return(e%t+t)%t}function nb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function ib(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function js(e,t,n){return(1-n)*e+n*t}function rb(e,t,n,i){return js(e,t,1-Math.exp(-n*i))}function sb(e,t=1){return t-Math.abs(uh(e,t*2)-t)}function ob(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 ab(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 cb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function lb(e,t){return e+Math.random()*(t-e)}function ub(e){return e*(0.5-Math.random())}function hb(e){if(e!==void 0)o_=e;let t=o_+=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 fb(e){return e*Ys}function db(e){return e*pr}function pb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function mb(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 _b(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Ce("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Fn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ot(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var ro={DEG2RAD:Ys,RAD2DEG:pr,generateUUID:zn,clamp:Ze,euclideanModulo:uh,mapLinear:nb,inverseLerp:ib,lerp:js,damp:rb,pingpong:sb,smoothstep:ob,smootherstep:ab,randInt:cb,randFloat:lb,randFloatSpread:ub,seededRandom:hb,degToRad:fb,radToDeg:db,isPowerOfTwo:pb,ceilPowerOfTwo:mb,floorPowerOfTwo:gb,setQuaternionFromProperEuler:_b,normalize:ot,denormalize:Fn};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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(Ze(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 kt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Ce("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ze(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(a_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(a_.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=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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 Bl.copy(this).projectOnVector(e),this.sub(Bl)}reflect(e){return this.sub(Bl.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(Ze(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 Bl=new U,a_=new kt;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],S=i[2],b=i[5],T=i[8];return r[0]=s*g+o*m+a*S,r[3]=s*x+o*E+a*b,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*S,r[4]=c*x+l*E+u*b,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*S,r[5]=f*x+h*E+d*b,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return dr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Gl.makeScale(e,t)),this}rotate(e){return dr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Gl.makeRotation(-e)),this}translate(e,t){return dr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Gl.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 Gl=new ze,c_=new ze().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),l_=new ze().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function xb(){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=bi(r.r),r.g=bi(r.g),r.b=bi(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=jr(r.r),r.g=jr(r.g),r.b=jr(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 dr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return dr("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:c_,fromXYZ:l_,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:c_,fromXYZ:l_,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var $e=xb();function bi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function jr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Ur;class hh{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(Ur===void 0)Ur=Kr("canvas");Ur.width=e.width,Ur.height=e.height;let i=Ur.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Ur}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=Kr("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]=bi(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(bi(t[n]/255)*255);else t[n]=bi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ce("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var vb=0;class so{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:vb++}),this.uuid=zn(),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(Hl(i[s].image));else r.push(Hl(i[s]))}else r=Hl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Hl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return hh.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 Ce("Texture: Unable to serialize Texture."),{}}var yb=0,Vl=new U;class Et extends Hn{constructor(e=Et.DEFAULT_IMAGE,t=Et.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Et.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:yb++}),this.uuid=zn(),this.name="",this.source=new so(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Vl).x}get height(){return this.source.getSize(Vl).y}get depth(){return this.source.getSize(Vl).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){Ce(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ce(`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++}}Et.DEFAULT_IMAGE=null;Et.DEFAULT_MAPPING=300;Et.DEFAULT_ANISOTROPY=1;class at{static{at.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,S=(p+1)/2,b=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>S)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=b/n,r=T/n;else if(R>S)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=b/i,r=A/i;else if(S<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(S),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this.w=Ze(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this.w=Ze(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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 fh extends Hn{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new at(0,0,e,t),this.scissorTest=!1,this.viewport=new at(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Et(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 so(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends fh{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class ec extends Et{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 dh extends Et{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class Ge{static{Ge.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ge().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/Fr.setFromMatrixColumn(e,0).length(),r=1/Fr.setFromMatrixColumn(e,1).length(),s=1/Fr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Sb,e,bb)}lookAt(e,t,n){let i=this.elements;if(pn.subVectors(e,t),pn.lengthSq()===0)pn.z=1;if(pn.normalize(),Oi.crossVectors(n,pn),Oi.lengthSq()===0){if(Math.abs(n.z)===1)pn.x+=0.0001;else pn.z+=0.0001;pn.normalize(),Oi.crossVectors(n,pn)}return Oi.normalize(),da.crossVectors(pn,Oi),i[0]=Oi.x,i[4]=da.x,i[8]=pn.x,i[1]=Oi.y,i[5]=da.y,i[9]=pn.y,i[2]=Oi.z,i[6]=da.z,i[10]=pn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],S=n[15],b=i[0],T=i[4],A=i[8],_=i[12],M=i[1],F=i[5],I=i[9],O=i[13],K=i[2],C=i[6],G=i[10],X=i[14],z=i[3],te=i[7],H=i[11],Q=i[15];return r[0]=s*b+o*M+a*K+c*z,r[4]=s*T+o*F+a*C+c*te,r[8]=s*A+o*I+a*G+c*H,r[12]=s*_+o*O+a*X+c*Q,r[1]=l*b+u*M+f*K+h*z,r[5]=l*T+u*F+f*C+h*te,r[9]=l*A+u*I+f*G+h*H,r[13]=l*_+u*O+f*X+h*Q,r[2]=d*b+g*M+x*K+p*z,r[6]=d*T+g*F+x*C+p*te,r[10]=d*A+g*I+x*G+p*H,r[14]=d*_+g*O+x*X+p*Q,r[3]=m*b+E*M+R*K+S*z,r[7]=m*T+E*F+R*C+S*te,r[11]=m*A+E*I+R*G+S*H,r[15]=m*_+E*O+R*X+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,S=s*h-c*l,b=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*S+p*b)+i*(d*E-g*S+p*T)-r*(d*R-g*b+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,S=n*a-i*o,b=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,M=l*p-h*d,F=u*x-f*g,I=u*p-h*g,O=f*p-h*x,K=m*O-E*I+R*F+S*M-b*_+T*A;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/K;return e[0]=(o*O-a*I+c*F)*C,e[1]=(i*I-n*O-r*F)*C,e[2]=(g*T-x*b+p*S)*C,e[3]=(f*b-u*T-h*S)*C,e[4]=(a*M-s*O-c*_)*C,e[5]=(t*O-i*M+r*_)*C,e[6]=(x*R-d*T-p*E)*C,e[7]=(l*T-f*R+h*E)*C,e[8]=(s*I-o*M+c*A)*C,e[9]=(n*M-t*I-r*A)*C,e[10]=(d*b-g*R+p*m)*C,e[11]=(u*R-l*b-h*m)*C,e[12]=(o*_-s*F-a*A)*C,e[13]=(t*F-n*_+i*A)*C,e[14]=(g*E-d*S-x*m)*C,e[15]=(l*S-u*E+f*m)*C,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:S,y:b,z:T}=n;return i[0]=(1-(g+p))*S,i[1]=(h+R)*S,i[2]=(d-E)*S,i[3]=0,i[4]=(h-R)*b,i[5]=(1-(f+p))*b,i[6]=(x+m)*b,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Fr.set(i[0],i[1],i[2]).length(),o=Fr.set(i[4],i[5],i[6]).length(),a=Fr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Dn.copy(this);let c=1/s,l=1/o,u=1/a;return Dn.elements[0]*=c,Dn.elements[1]*=c,Dn.elements[2]*=c,Dn.elements[4]*=l,Dn.elements[5]*=l,Dn.elements[6]*=l,Dn.elements[8]*=u,Dn.elements[9]*=u,Dn.elements[10]*=u,t.setFromRotationMatrix(Dn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Fr=new U,Dn=new Ge,Sb=new U(0,0,0),bb=new U(1,1,1),Oi=new U,da=new U,pn=new U,u_=new Ge,h_=new kt;class ti{constructor(e=0,t=0,n=0,i=ti.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Ze(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Ze(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(Ze(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Ze(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Ze(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(-Ze(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Ce("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return u_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(u_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return h_.setFromEuler(this),this.setFromQuaternion(h_,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}}ti.DEFAULT_ORDER="XYZ";class tc{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 Mb=0,f_=new U,zr=new kt,gi=new Ge,pa=new U,Gs=new U,wb=new U,Tb=new kt,d_=new U(1,0,0),p_=new U(0,1,0),m_=new U(0,0,1),g_={type:"added"},Eb={type:"removed"},kr={type:"childadded",child:null},Wl={type:"childremoved",child:null};class ut extends Hn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Mb++}),this.uuid=zn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();let e=new U,t=new ti,n=new kt,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 Ge},normalMatrix:{value:new ze}}),this.matrix=new Ge,this.matrixWorld=new Ge,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tc,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 zr.setFromAxisAngle(e,t),this.quaternion.multiply(zr),this}rotateOnWorldAxis(e,t){return zr.setFromAxisAngle(e,t),this.quaternion.premultiply(zr),this}rotateX(e){return this.rotateOnAxis(d_,e)}rotateY(e){return this.rotateOnAxis(p_,e)}rotateZ(e){return this.rotateOnAxis(m_,e)}translateOnAxis(e,t){return f_.copy(e).applyQuaternion(this.quaternion),this.position.add(f_.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(d_,e)}translateY(e){return this.translateOnAxis(p_,e)}translateZ(e){return this.translateOnAxis(m_,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)pa.copy(e);else pa.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Gs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)gi.lookAt(Gs,pa,this.up);else gi.lookAt(pa,Gs,this.up);if(this.quaternion.setFromRotationMatrix(gi),i)gi.extractRotation(i.matrixWorld),zr.setFromRotationMatrix(gi),this.quaternion.premultiply(zr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(g_),kr.child=e,this.dispatchEvent(kr),kr.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Eb),Wl.child=e,this.dispatchEvent(Wl),Wl.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),gi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),gi.multiply(e.parent.matrixWorld);return e.applyMatrix4(gi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(g_),kr.child=e,this.dispatchEvent(kr),kr.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(Gs,e,wb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gs,Tb,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}ut.DEFAULT_UP=new U(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Qn extends ut{constructor(){super();this.isGroup=!0,this.type="Group"}}var Ab={type:"move"};class oo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new Qn,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 Qn,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 Qn,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 g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Ab)}}}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 Qn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var B0={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},Ui={h:0,s:0,l:0},ma={h:0,s:0,l:0};function $l(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$e.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=$e.workingColorSpace){return this.r=e,this.g=t,this.b=n,$e.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=$e.workingColorSpace){if(e=uh(e,1),t=Ze(t,0,1),n=Ze(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=$l(s,r,e+0.3333333333333333),this.g=$l(s,r,e),this.b=$l(s,r,e-0.3333333333333333)}return $e.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Ce("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:Ce("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 Ce("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=B0[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ce("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=bi(e.r),this.g=bi(e.g),this.b=bi(e.b),this}copyLinearToSRGB(e){return this.r=jr(e.r),this.g=jr(e.g),this.b=jr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return $e.workingToColorSpace(qt.copy(this),e),Math.round(Ze(qt.r*255,0,255))*65536+Math.round(Ze(qt.g*255,0,255))*256+Math.round(Ze(qt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=$e.workingColorSpace){$e.workingToColorSpace(qt.copy(this),t);let{r:n,g:i,b:r}=qt,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=$e.workingColorSpace){return $e.workingToColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e="srgb"){$e.workingToColorSpace(qt.copy(this),e);let{r:t,g:n,b:i}=qt;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(Ui),this.setHSL(Ui.h+e,Ui.s+t,Ui.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(Ui),e.getHSL(ma);let n=js(Ui.h,ma.h,t),i=js(Ui.s,ma.s,t),r=js(Ui.l,ma.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 qt=new Oe;Oe.NAMES=B0;class cs extends ut{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ti,this.environmentIntensity=1,this.environmentRotation=new ti,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 On=new U,_i=new U,Zl=new U,xi=new U,Br=new U,Gr=new U,__=new U,Xl=new U,ql=new U,Yl=new U,jl=new at,Kl=new at,Jl=new at;class En{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),On.subVectors(e,t),i.cross(On);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){On.subVectors(i,t),_i.subVectors(n,t),Zl.subVectors(e,t);let s=On.dot(On),o=On.dot(_i),a=On.dot(Zl),c=_i.dot(_i),l=_i.dot(Zl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,xi)===null)return!1;return xi.x>=0&&xi.y>=0&&xi.x+xi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,xi)===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,xi.x),a.addScaledVector(s,xi.y),a.addScaledVector(o,xi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return jl.setScalar(0),Kl.setScalar(0),Jl.setScalar(0),jl.fromBufferAttribute(e,t),Kl.fromBufferAttribute(e,n),Jl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(jl,r.x),s.addScaledVector(Kl,r.y),s.addScaledVector(Jl,r.z),s}static isFrontFacing(e,t,n,i){return On.subVectors(n,t),_i.subVectors(e,t),On.cross(_i).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 On.subVectors(this.c,this.b),_i.subVectors(this.a,this.b),On.cross(_i).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return En.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return En.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return En.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return En.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return En.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;Br.subVectors(i,n),Gr.subVectors(r,n),Xl.subVectors(e,n);let a=Br.dot(Xl),c=Gr.dot(Xl);if(a<=0&&c<=0)return t.copy(n);ql.subVectors(e,i);let l=Br.dot(ql),u=Gr.dot(ql);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Br,s);Yl.subVectors(e,r);let h=Br.dot(Yl),d=Gr.dot(Yl);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Gr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return __.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(__,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Br,s).addScaledVector(Gr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class nn{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(Un.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Un.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=Un.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,Un);else Un.fromBufferAttribute(r,s);Un.applyMatrix4(e.matrixWorld),this.expandByPoint(Un)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();ga.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();ga.copy(n.boundingBox)}ga.applyMatrix4(e.matrixWorld),this.union(ga)}}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,Un),Un.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(Hs),_a.subVectors(this.max,Hs),Hr.subVectors(e.a,Hs),Vr.subVectors(e.b,Hs),Wr.subVectors(e.c,Hs),Fi.subVectors(Vr,Hr),zi.subVectors(Wr,Vr),lr.subVectors(Hr,Wr);let t=[0,-Fi.z,Fi.y,0,-zi.z,zi.y,0,-lr.z,lr.y,Fi.z,0,-Fi.x,zi.z,0,-zi.x,lr.z,0,-lr.x,-Fi.y,Fi.x,0,-zi.y,zi.x,0,-lr.y,lr.x,0];if(!Ql(t,Hr,Vr,Wr,_a))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Ql(t,Hr,Vr,Wr,_a))return!1;return xa.crossVectors(Fi,zi),t=[xa.x,xa.y,xa.z],Ql(t,Hr,Vr,Wr,_a)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Un).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Un).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 vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(vi),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 vi=[new U,new U,new U,new U,new U,new U,new U,new U],Un=new U,ga=new nn,Hr=new U,Vr=new U,Wr=new U,Fi=new U,zi=new U,lr=new U,Hs=new U,_a=new U,xa=new U,ur=new U;function Ql(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){ur.fromArray(e,s);let a=r.x*Math.abs(ur.x)+r.y*Math.abs(ur.y)+r.z*Math.abs(ur.z),c=t.dot(ur),l=n.dot(ur),u=i.dot(ur);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Pt=new U,va=new Ne,Rb=0;class Bt extends Hn{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:Rb++}),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++)va.fromBufferAttribute(this,t),va.applyMatrix3(e),this.setXY(t,va.x,va.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix3(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.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=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Fn(t,this.array);return t}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Fn(t,this.array);return t}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Fn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Fn(t,this.array);return t}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class nc extends Bt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ic extends Bt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class an extends Bt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Cb=new nn,Vs=new U,eu=new U;class xn{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 Cb.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;Vs.subVectors(e,this.center);let t=Vs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Vs,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 eu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vs.copy(e.center).add(eu)),this.expandByPoint(Vs.copy(e.center).sub(eu));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 Ib=0,wn=new Ge,tu=new ut,$r=new U,mn=new nn,Ws=new nn,zt=new U;class jt extends Hn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ib++}),this.uuid=zn(),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((eb(e))?ic:nc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return wn.makeRotationFromQuaternion(e),this.applyMatrix4(wn),this}rotateX(e){return wn.makeRotationX(e),this.applyMatrix4(wn),this}rotateY(e){return wn.makeRotationY(e),this.applyMatrix4(wn),this}rotateZ(e){return wn.makeRotationZ(e),this.applyMatrix4(wn),this}translate(e,t,n){return wn.makeTranslation(e,t,n),this.applyMatrix4(wn),this}scale(e,t,n){return wn.makeScale(e,t,n),this.applyMatrix4(wn),this}lookAt(e){return tu.lookAt(e),tu.updateMatrix(),this.applyMatrix4(tu.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($r).negate(),this.translate($r.x,$r.y,$r.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)Ce("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 nn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new 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))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new xn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new 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(Ws.setFromBufferAttribute(o),this.morphTargetsRelative)zt.addVectors(mn.min,Ws.min),mn.expandByPoint(zt),zt.addVectors(mn.max,Ws.max),mn.expandByPoint(zt);else mn.expandByPoint(Ws.min),mn.expandByPoint(Ws.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)$r.fromBufferAttribute(e,c),zt.add($r);i=Math.max(i,n.distanceToSquared(zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new Bt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new U,a[A]=new U;let c=new U,l=new U,u=new U,f=new Ne,h=new Ne,d=new Ne,g=new U,x=new U;function p(A,_,M){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let F=1/(h.x*d.y-d.x*h.y);if(!isFinite(F))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(F),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(F),o[A].add(g),o[_].add(g),o[M].add(g),a[A].add(x),a[_].add(x),a[M].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:I}=M;for(let O=F,K=F+I;O<K;O+=3)p(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let E=new U,R=new U,S=new U,b=new U;function T(A){S.fromBufferAttribute(i,A),b.copy(S);let _=o[A];E.copy(_),E.sub(S.multiplyScalar(S.dot(_))).normalize(),R.crossVectors(b,_);let F=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,F)}for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:I}=M;for(let O=F,K=F+I;O<K;O+=3)T(e.getX(O+0)),T(e.getX(O+1)),T(e.getX(O+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 Bt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new 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 f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)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,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new Bt(f,l,u)}if(this.index===null)return Ce("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new jt,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ao{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=zn()}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=zn();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=zn();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 tn=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++)tn.fromBufferAttribute(this,t),tn.applyMatrix4(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.applyNormalMatrix(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)tn.fromBufferAttribute(this,t),tn.transformDirection(e),this.setXYZ(t,tn.x,tn.y,tn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Fn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ot(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ot(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Fn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Fn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Fn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Fn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),r=ot(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ks("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 Bt(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){Ks("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 nu=new U,Pb=new U,Lb=new ze;class Tn{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=nu.subVectors(n,t).cross(Pb.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(nu),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||Lb.getNormalMatrix(e),i=this.coplanarPoint(nu).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 Nb=0;class cn extends Hn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Nb++}),this.uuid=zn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Ce(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Ce(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Tn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var yi=new U,iu=new U,ya=new U,Sa=new U;class Xi{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,yi)),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=yi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return yi.copy(this.origin).addScaledVector(this.direction,t),yi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){iu.copy(e).add(t).multiplyScalar(0.5),ya.copy(t).sub(e).normalize(),Sa.copy(this.origin).sub(iu);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(ya),o=Sa.dot(this.direction),a=-Sa.dot(ya),c=Sa.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(iu).addScaledVector(ya,f);return h}intersectSphere(e,t){if(e.radius<0)return null;yi.subVectors(e.center,this.origin);let n=yi.dot(this.direction),i=yi.dot(yi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,yi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),S=Math.abs(c),b=Math.abs(l),T,A,_,M,F,I,O,K,C,G,X,z;if(R>=S&&R>=b)if(_=a,I=u,C=d,z=p,a>=0)T=c,A=l,M=f,F=h,O=g,K=x,G=m,X=E;else T=l,A=c,M=h,F=f,O=x,K=g,G=E,X=m;else if(S>=b)if(_=c,I=f,C=g,z=m,c>=0)T=l,A=a,M=h,F=u,O=x,K=d,G=E,X=p;else T=a,A=l,M=u,F=h,O=d,K=x,G=p,X=E;else if(_=l,I=h,C=x,z=E,l>=0)T=a,A=c,M=u,F=f,O=d,K=g,G=p,X=m;else T=c,A=a,M=f,F=u,O=g,K=d,G=m,X=p;if(_===0)return null;let te=T/_,H=A/_,Q=1/_,ee=M-te*I,Te=F-H*I,ve=O-te*C,He=K-H*C,Me=G-te*z,Z=X-H*z,re=Me*He-Z*ve,se=ee*Z-Te*Me,Ie=ve*Te-He*ee;if(i){if(re<0||se<0||Ie<0)return null}else if((re<0||se<0||Ie<0)&&(re>0||se>0||Ie>0))return null;let Pe=re+se+Ie;if(Pe===0)return null;let we=Q*(re*I+se*C+Ie*z);if(Pe>0?we<0:we>0)return null;return this.at(we/Pe,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 oi extends cn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 x_=new Ge,hr=new Xi,ba=new xn,v_=new U,Ma=new U,wa=new U,Ta=new U,ru=new U,Ea=new U,y_=new U,Aa=new U;class mt extends ut{constructor(e=new jt,t=new oi){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){Ea.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(ru.fromBufferAttribute(u,e),s)Ea.addScaledVector(ru,l);else Ea.addScaledVector(ru.sub(t),l)}t.add(Ea)}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(ba.copy(n.boundingSphere),ba.applyMatrix4(r),hr.copy(e.ray).recast(e.near),ba.containsPoint(hr.origin)===!1){if(hr.intersectSphere(ba,v_)===null)return;if(hr.origin.distanceToSquared(v_)>(e.far-e.near)**2)return}if(x_.copy(r).invert(),hr.copy(e.ray).applyMatrix4(x_),n.boundingBox!==null){if(hr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,hr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=Ra(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=Ra(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=R,T=R+1,A=R+2;if(i=Ra(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=Ra(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Db(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;Aa.copy(a),Aa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Aa);if(l<n.near||l>n.far)return null;return{distance:l,point:Aa.clone(),object:e}}function Ra(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Ma),e.getVertexPosition(c,wa),e.getVertexPosition(l,Ta);let u=Db(e,t,n,i,Ma,wa,Ta,y_);if(u){let f=new U;if(En.getBarycoord(y_,Ma,wa,Ta,f),r)u.uv=En.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=En.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=En.getInterpolatedAttribute(o,a,c,l,f,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};En.getNormal(Ma,wa,Ta,h.normal),u.face=h,u.barycoord=f}return u}var $s=new at,S_=new at,b_=new at,Ob=new at,M_=new Ge,Ca=new U,su=new xn,w_=new Ge,ou=new Xi;class rc extends mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ge,this.bindMatrixInverse=new Ge,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new nn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingBox.expandByPoint(Ca)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new xn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ca),this.boundingSphere.expandByPoint(Ca)}copy(e,t){if(super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}raycast(e,t){let n=this.material,i=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(su.copy(this.boundingSphere),su.applyMatrix4(i),e.ray.intersectsSphere(su)===!1)return;if(w_.copy(i).invert(),ou.copy(e.ray).applyMatrix4(w_),this.boundingBox!==null){if(ou.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,ou)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new at,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Ce("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(S_.fromBufferAttribute(i.attributes.skinIndex,e),b_.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)$s.copy(t),t.set(0,0,0,0);else $s.set(...t,1),t.set(0,0,0);$s.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=b_.getComponent(r);if(s!==0){let o=S_.getComponent(r);M_.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Ob.copy($s).applyMatrix4(M_),s)}}if(t.isVector4)t.w=$s.w;return t.applyMatrix4(this.bindMatrixInverse)}}class co extends ut{constructor(){super();this.isBone=!0,this.type="Bone"}}class lo extends Et{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var T_=new Ge,Ub=new Ge;class uo{constructor(e=[],t=[]){this.uuid=zn(),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){Ce("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ge)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ge;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:Ub;T_.multiplyMatrices(o,t[r]),T_.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new uo(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 lo(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)Ce("Skeleton: No bone found with UUID:",r),s=new co;this.bones.push(s),this.boneInverses.push(new Ge().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class Gi extends Bt{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 Zr=new Ge,E_=new Ge,Ia=[],A_=new nn,Fb=new Ge,Zs=new mt,Xs=new xn;class us extends mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Gi(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,Fb)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new nn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zr),A_.copy(e.boundingBox).applyMatrix4(Zr),this.boundingBox.union(A_)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new xn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Zr),Xs.copy(e.boundingSphere).applyMatrix4(Zr),this.boundingSphere.union(Xs)}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(Zs.geometry=this.geometry,Zs.material=this.material,Zs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Xs.copy(this.boundingSphere),Xs.applyMatrix4(n),e.ray.intersectsSphere(Xs)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Zr),E_.multiplyMatrices(n,Zr),Zs.matrixWorld=E_,Zs.raycast(e,Ia);for(let s=0,o=Ia.length;s<o;s++){let a=Ia[s];a.instanceId=r,a.object=this,t.push(a)}Ia.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Gi(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 lo(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 fr=new xn,zb=new Ne(0.5,0.5),Pa=new U;class ho{constructor(e=new Tn,t=new Tn,n=new Tn,i=new Tn,r=new Tn,s=new Tn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],S=r[15];if(i[0].setComponents(c-s,h-l,p-d,S-m).normalize(),i[1].setComponents(c+s,h+l,p+d,S+m).normalize(),i[2].setComponents(c+o,h+u,p+g,S+E).normalize(),i[3].setComponents(c-o,h-u,p-g,S-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,S-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,S-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,S+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();fr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();fr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(fr)}intersectsSprite(e){fr.center.set(0,0,0);let t=zb.distanceTo(e.center);return fr.radius=0.7071067811865476+t,fr.applyMatrix4(e.matrixWorld),this.intersectsSphere(fr)}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(Pa.x=i.normal.x>0?e.max.x:e.min.x,Pa.y=i.normal.y>0?e.max.y:e.min.y,Pa.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Pa)<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 fo extends cn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ka=new U,Ba=new U,R_=new Ge,qs=new Xi,La=new xn,au=new U,C_=new U;class qi extends ut{constructor(e=new jt,t=new fo){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++)ka.fromBufferAttribute(t,i-1),Ba.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ka.distanceTo(Ba);e.setAttribute("lineDistance",new an(n,1))}else Ce("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(La.copy(n.boundingSphere),La.applyMatrix4(i),La.radius+=r,e.ray.intersectsSphere(La)===!1)return;R_.copy(i).invert(),qs.copy(e.ray).applyMatrix4(R_);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=Na(this,e,qs,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=Na(this,e,qs,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=Na(this,e,qs,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=Na(this,e,qs,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Na(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ka.fromBufferAttribute(a,r),Ba.fromBufferAttribute(a,s),n.distanceSqToSegment(ka,Ba,au,C_)>i)return;au.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(au);if(l<t.near||l>t.far)return;return{distance:l,point:C_.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var I_=new U,P_=new U;class sc extends qi{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)I_.fromBufferAttribute(t,i),P_.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+I_.distanceTo(P_);e.setAttribute("lineDistance",new an(n,1))}else Ce("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class oc extends qi{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class po extends cn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var L_=new Ge,uu=new Xi,Da=new xn,Oa=new U;class hs extends ut{constructor(e=new jt,t=new po){super();this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Da.copy(n.boundingSphere),Da.applyMatrix4(i),Da.radius+=r,e.ray.intersectsSphere(Da)===!1)return;L_.copy(i).invert(),uu.copy(e.ray).applyMatrix4(L_);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);Oa.fromBufferAttribute(u,x),N_(Oa,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)Oa.fromBufferAttribute(u,d),N_(Oa,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function N_(e,t,n,i,r,s,o){let a=uu.distanceSqToPoint(e);if(a<n){let c=new U;uu.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 ac extends Et{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 Sr extends Et{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new so(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class ph extends Sr{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 cc extends Et{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Yi extends jt{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new an(c,3)),this.setAttribute("normal",new an(l,3)),this.setAttribute("uv",new an(u,2));function d(g,x,p,m,E,R,S,b,T,A,_){let M=R/T,F=S/A,I=R/2,O=S/2,K=b/2,C=T+1,G=A+1,X=0,z=0,te=new U;for(let H=0;H<G;H++){let Q=H*F-O;for(let ee=0;ee<C;ee++){let Te=ee*M-I;te[g]=Te*m,te[x]=Q*E,te[p]=K,c.push(te.x,te.y,te.z),te[g]=0,te[x]=0,te[p]=b>0?1:-1,l.push(te.x,te.y,te.z),u.push(ee/T),u.push(1-H/A),X+=1}}for(let H=0;H<A;H++)for(let Q=0;Q<T;Q++){let ee=f+Q+C*H,Te=f+Q+C*(H+1),ve=f+(Q+1)+C*(H+1),He=f+(Q+1)+C*H;a.push(ee,Te,He),a.push(Te,ve,He),z+=6}o.addGroup(h,z,_),h+=z,f+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class mo extends jt{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),S=m+1+c*(p+1),b=m+1+c*p;h.push(E,R,b),h.push(R,S,b)}this.setIndex(h),this.setAttribute("position",new an(d,3)),this.setAttribute("normal",new an(g,3)),this.setAttribute("uv",new an(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mo(e.width,e.height,e.widthSegments,e.heightSegments)}}function br(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(D_(r))if(r.isRenderTargetTexture)Ce("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(D_(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 Kt(e){let t={};for(let n=0;n<e.length;n++){let i=br(e[n]);for(let r in i)t[r]=i[r]}return t}function D_(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function kb(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function mh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return $e.workingColorSpace}var G0={clone:br,merge:Kt},Bb=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,zb=`void main() {
+}`,Gb=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Rn extends cn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Fb,this.fragmentShader=zb,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=br(e.uniforms),this.uniformsGroups=Ub(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new at().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class ph extends Rn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wi extends cn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 vn extends wi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ze(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class lc extends cn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 mh extends cn{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 gh extends cn{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 Bi(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 za(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function kb(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 L_(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 Bb(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 Ti{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 _h extends Ti{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let S=0;S!==o;++S)r[S]=p*s[l+S]+m*s[c+S]+E*s[a+S]+R*s[u+S];return r}}class uc extends Ti{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class xh extends Ti{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class vh extends Ti{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,S=l[R],b=l[R+1],T=Hb(n,t,m,S,i);r[d]=k0(T,g,E,b,x)}return r}}function k0(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 Gb(e,t,n,i,r){let s=1-e;return 3*s*s*(n-t)+6*s*e*(i-n)+3*e*e*(r-i)}function Hb(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=k0(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=Gb(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 yn{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=Bi(t,this.TimeBufferType),this.values=Bi(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:Bi(e.times,Array),values:Bi(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(za(e.settings))n.settings={inTangents:Bi(e.settings.inTangents,Array),outTangents:Bi(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new xh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new _h(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new vh(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 Ce("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(za(this.settings))N_(this.settings.inTangents,e),N_(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(JS(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,za(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function N_(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}yn.prototype.ValueTypeName="";yn.prototype.TimeBufferType=Float32Array;yn.prototype.ValueBufferType=Float32Array;yn.prototype.DefaultInterpolation=2301;class ji extends yn{constructor(e,t,n){super(e,t,n)}}ji.prototype.ValueTypeName="bool";ji.prototype.ValueBufferType=Array;ji.prototype.DefaultInterpolation=2300;ji.prototype.InterpolantFactoryMethodLinear=void 0;ji.prototype.InterpolantFactoryMethodSmooth=void 0;class hc extends yn{constructor(e,t,n,i){super(e,t,n,i)}}hc.prototype.ValueTypeName="color";class Ki extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Ki.prototype.ValueTypeName="number";class yh extends Ti{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)kt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Ji extends yn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new yh(this.times,this.values,this.getValueSize(),e)}}Ji.prototype.ValueTypeName="quaternion";Ji.prototype.InterpolantFactoryMethodSmooth=void 0;class Qi extends yn{constructor(e,t,n){super(e,t,n)}}Qi.prototype.ValueTypeName="string";Qi.prototype.ValueBufferType=Array;Qi.prototype.DefaultInterpolation=2300;Qi.prototype.InterpolantFactoryMethodLinear=void 0;Qi.prototype.InterpolantFactoryMethodSmooth=void 0;class Mr extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Mr.prototype.ValueTypeName="vector";class Qr{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=zn(),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(Wb(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(yn.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=kb(a);if(a=L_(a,1,l),c=L_(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new Ki(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Vb(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ki;case"vector":case"vector2":case"vector3":case"vector4":return Mr;case"color":return hc;case"quaternion":return Ji;case"bool":case"boolean":return ji;case"string":return Qi}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Wb(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Vb(e.type);if(e.times===void 0){let i=[],r=[];Bb(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(za(e.settings))n.settings={inTangents:Bi(e.settings.inTangents,Float32Array),outTangents:Bi(e.settings.outTangents,Float32Array)};return n}var ei={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(D_(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(D_(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function D_(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class go{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var B0=new go;class Ei{constructor(e){if(this.manager=e!==void 0?e:B0,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}}Ei.DEFAULT_MATERIAL_NAME="__DEFAULT";var Si={};class G0 extends Error{constructor(e,t){super(e);this.response=t}}class _o extends Ei{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=ei.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Si[e]!==void 0){Si[e].push({onLoad:t,onProgress:n,onError:i});return}Si[e]=[],Si[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)Ce("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Si[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let S=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let b=0,T=l.length;b<T;b++){let A=l[b];if(A.onProgress)A.onProgress(S)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new G0(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ei.add(`file:${e}`,c);let l=Si[e];delete Si[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Si[e];if(l===void 0)throw this.manager.itemError(e),c;delete Si[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Xr=new WeakMap;class Sh extends Ei{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=ei.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=Xr.get(s);if(u===void 0)u=[],Xr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Kr("img");function a(){if(l(),t)t(this);let u=Xr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Xr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ei.remove(`image:${e}`);let f=Xr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Xr.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 ei.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class fc extends Ei{constructor(e){super(e)}load(e,t,n,i){let r=new Et,s=new Sh(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 fs extends ut{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class dc extends fs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ou=new Ge,O_=new U,U_=new U;class xo{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ho,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;O_.setFromMatrixPosition(e.matrixWorld),t.position.copy(O_),U_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(U_),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ou.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ou,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(ou)}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 Ua=new U,Fa=new kt,Jn=new U;class pc extends ut{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Ua,Fa,Jn),Jn.x===1&&Jn.y===1&&Jn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ua,Fa,Jn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ua,Fa,Jn),Jn.x===1&&Jn.y===1&&Jn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ua,Fa,Jn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var ki=new U,F_=new Ne,z_=new Ne;class Dt extends pc{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=pr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ys*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return pr*2*Math.atan(Math.tan(Ys*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){ki.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(ki.x,ki.y).multiplyScalar(-e/ki.z),ki.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ki.x,ki.y).multiplyScalar(-e/ki.z)}getViewSize(e,t){return this.getViewBounds(e,F_,z_),t.subVectors(z_,F_)}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(Ys*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 H0 extends xo{constructor(){super(new Dt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=pr*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 fs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new H0}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 V0 extends xo{constructor(){super(new Dt(90,1,0.5,500));this.isPointLightShadow=!0}}class ds extends fs{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 V0}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 wr extends pc{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 W0 extends xo{constructor(){super(new wr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ps extends fs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new W0}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 er{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 au=new WeakMap;class gc extends Ei{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ce("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ce("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=ei.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(au.has(s)===!0){if(i)i(au.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(ei.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);au.set(a,c),ei.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ei.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var qr=-90,Yr=1;class bh extends ut{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Dt(qr,Yr,e,t);i.layers=this.layers,this.add(i);let r=new Dt(qr,Yr,e,t);r.layers=this.layers,this.add(r);let s=new Dt(qr,Yr,e,t);s.layers=this.layers,this.add(s);let o=new Dt(qr,Yr,e,t);o.layers=this.layers,this.add(o);let a=new Dt(qr,Yr,e,t);a.layers=this.layers,this.add(a);let c=new Dt(qr,Yr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Mh extends Dt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class wh{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){kt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;kt.multiplyQuaternionsFlat(e,s,e,t,e,n),kt.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 Th="\\[\\]\\.:\\/",$b=new RegExp("["+Th+"]","g"),Eh="[^"+Th+"]",Zb="[^"+Th.replace("\\.","")+"]",Xb=/((?:WC+[\/:])*)/.source.replace("WC",Eh),qb=/(WCOD+)?/.source.replace("WCOD",Zb),Yb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Eh),jb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Eh),Kb=new RegExp("^"+Xb+qb+Yb+jb+"$"),Jb=["material","materials","bones","map"];class $0{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($b,"")}static parseTrackName(e){let t=Kb.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(Jb.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ce("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=$0;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ah{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 Qb=new Float32Array(1);class _c extends Hn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new wh(et.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new uc(new Float32Array(2),new Float32Array(2),1,Qb),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"?Qr.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 Ah(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"?Qr.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 vo{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=Ze(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(Ze(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Rh{static{Rh.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 xc extends Hn{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 Ch(e,t,n,i){let r=eM(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 eM(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__)Ce("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function dx(){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 tM(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var nM=`#ifdef USE_ALPHAHASH
+}`;class Rn extends cn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Bb,this.fragmentShader=Gb,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=br(e.uniforms),this.uniformsGroups=kb(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new at().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ge().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class gh extends Rn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wi extends cn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 vn extends wi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ze(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class lc extends cn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ti,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 _h extends cn{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 xh extends cn{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 Bi(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 za(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function Hb(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 O_(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 Vb(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 Ti{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 vh extends Ti{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let S=0;S!==o;++S)r[S]=p*s[l+S]+m*s[c+S]+E*s[a+S]+R*s[u+S];return r}}class uc extends Ti{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class yh extends Ti{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Sh extends Ti{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,S=l[R],b=l[R+1],T=$b(n,t,m,S,i);r[d]=H0(T,g,E,b,x)}return r}}function H0(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 Wb(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 $b(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=H0(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=Wb(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 yn{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=Bi(t,this.TimeBufferType),this.values=Bi(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:Bi(e.times,Array),values:Bi(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(za(e.settings))n.settings={inTangents:Bi(e.settings.inTangents,Array),outTangents:Bi(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new yh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vh(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 Ce("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(za(this.settings))U_(this.settings.inTangents,e),U_(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(tb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,za(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function U_(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}yn.prototype.ValueTypeName="";yn.prototype.TimeBufferType=Float32Array;yn.prototype.ValueBufferType=Float32Array;yn.prototype.DefaultInterpolation=2301;class ji extends yn{constructor(e,t,n){super(e,t,n)}}ji.prototype.ValueTypeName="bool";ji.prototype.ValueBufferType=Array;ji.prototype.DefaultInterpolation=2300;ji.prototype.InterpolantFactoryMethodLinear=void 0;ji.prototype.InterpolantFactoryMethodSmooth=void 0;class hc extends yn{constructor(e,t,n,i){super(e,t,n,i)}}hc.prototype.ValueTypeName="color";class Ki extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Ki.prototype.ValueTypeName="number";class bh extends Ti{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)kt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Ji extends yn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new bh(this.times,this.values,this.getValueSize(),e)}}Ji.prototype.ValueTypeName="quaternion";Ji.prototype.InterpolantFactoryMethodSmooth=void 0;class Qi extends yn{constructor(e,t,n){super(e,t,n)}}Qi.prototype.ValueTypeName="string";Qi.prototype.ValueBufferType=Array;Qi.prototype.DefaultInterpolation=2300;Qi.prototype.InterpolantFactoryMethodLinear=void 0;Qi.prototype.InterpolantFactoryMethodSmooth=void 0;class Mr extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Mr.prototype.ValueTypeName="vector";class Qr{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=zn(),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(Xb(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(yn.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=Hb(a);if(a=O_(a,1,l),c=O_(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new Ki(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Zb(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ki;case"vector":case"vector2":case"vector3":case"vector4":return Mr;case"color":return hc;case"quaternion":return Ji;case"bool":case"boolean":return ji;case"string":return Qi}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Xb(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Zb(e.type);if(e.times===void 0){let i=[],r=[];Vb(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(za(e.settings))n.settings={inTangents:Bi(e.settings.inTangents,Float32Array),outTangents:Bi(e.settings.outTangents,Float32Array)};return n}var ei={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(F_(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(F_(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function F_(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class go{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var V0=new go;class Ei{constructor(e){if(this.manager=e!==void 0?e:V0,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}}Ei.DEFAULT_MATERIAL_NAME="__DEFAULT";var Si={};class W0 extends Error{constructor(e,t){super(e);this.response=t}}class _o extends Ei{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=ei.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Si[e]!==void 0){Si[e].push({onLoad:t,onProgress:n,onError:i});return}Si[e]=[],Si[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)Ce("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Si[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let S=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let b=0,T=l.length;b<T;b++){let A=l[b];if(A.onProgress)A.onProgress(S)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new W0(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{ei.add(`file:${e}`,c);let l=Si[e];delete Si[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Si[e];if(l===void 0)throw this.manager.itemError(e),c;delete Si[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Xr=new WeakMap;class Mh extends Ei{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=ei.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=Xr.get(s);if(u===void 0)u=[],Xr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Kr("img");function a(){if(l(),t)t(this);let u=Xr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}Xr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ei.remove(`image:${e}`);let f=Xr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}Xr.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 ei.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class fc extends Ei{constructor(e){super(e)}load(e,t,n,i){let r=new Et,s=new Mh(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 fs extends ut{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class dc extends fs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var cu=new Ge,z_=new U,k_=new U;class xo{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ge,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ho,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new at(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;z_.setFromMatrixPosition(e.matrixWorld),t.position.copy(z_),k_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(k_),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){cu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(cu,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(cu)}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 Ua=new U,Fa=new kt,Jn=new U;class pc extends ut{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ge,this.projectionMatrix=new Ge,this.projectionMatrixInverse=new Ge,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Ua,Fa,Jn),Jn.x===1&&Jn.y===1&&Jn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ua,Fa,Jn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Ua,Fa,Jn),Jn.x===1&&Jn.y===1&&Jn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Ua,Fa,Jn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var ki=new U,B_=new Ne,G_=new Ne;class Dt extends pc{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=pr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ys*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return pr*2*Math.atan(Math.tan(Ys*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){ki.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(ki.x,ki.y).multiplyScalar(-e/ki.z),ki.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ki.x,ki.y).multiplyScalar(-e/ki.z)}getViewSize(e,t){return this.getViewBounds(e,B_,G_),t.subVectors(G_,B_)}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(Ys*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 $0 extends xo{constructor(){super(new Dt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=pr*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 fs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new $0}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 Z0 extends xo{constructor(){super(new Dt(90,1,0.5,500));this.isPointLightShadow=!0}}class ds extends fs{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 Z0}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 wr extends pc{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 X0 extends xo{constructor(){super(new wr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ps extends fs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new X0}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 er{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 lu=new WeakMap;class gc extends Ei{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ce("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ce("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=ei.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(lu.has(s)===!0){if(i)i(lu.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(ei.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);lu.set(a,c),ei.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ei.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var qr=-90,Yr=1;class wh extends ut{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Dt(qr,Yr,e,t);i.layers=this.layers,this.add(i);let r=new Dt(qr,Yr,e,t);r.layers=this.layers,this.add(r);let s=new Dt(qr,Yr,e,t);s.layers=this.layers,this.add(s);let o=new Dt(qr,Yr,e,t);o.layers=this.layers,this.add(o);let a=new Dt(qr,Yr,e,t);a.layers=this.layers,this.add(a);let c=new Dt(qr,Yr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class Th extends Dt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Eh{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){kt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;kt.multiplyQuaternionsFlat(e,s,e,t,e,n),kt.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 Ah="\\[\\]\\.:\\/",qb=new RegExp("["+Ah+"]","g"),Rh="[^"+Ah+"]",Yb="[^"+Ah.replace("\\.","")+"]",jb=/((?:WC+[\/:])*)/.source.replace("WC",Rh),Kb=/(WCOD+)?/.source.replace("WCOD",Yb),Jb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rh),Qb=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rh),eM=new RegExp("^"+jb+Kb+Jb+Qb+"$"),tM=["material","materials","bones","map"];class q0{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(qb,"")}static parseTrackName(e){let t=eM.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(tM.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=et.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ce("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=q0;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ch{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 nM=new Float32Array(1);class _c extends Hn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new Eh(et.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new uc(new Float32Array(2),new Float32Array(2),1,nM),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"?Qr.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 Ch(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"?Qr.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 vo{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=Ze(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(Ze(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Ih{static{Ih.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 xc extends Hn{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 Ph(e,t,n,i){let r=iM(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 iM(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__)Ce("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function gx(){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 rM(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var sM=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,iM=`#ifdef USE_ALPHAHASH
+#endif`,oM=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -100,20 +100,20 @@ version 0.8.2
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,rM=`#ifdef USE_ALPHAMAP
+#endif`,aM=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,sM=`#ifdef USE_ALPHAMAP
+#endif`,cM=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,oM=`#ifdef USE_ALPHATEST
+#endif`,lM=`#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`,aM=`#ifdef USE_ALPHATEST
+#endif`,uM=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,cM=`#ifdef USE_AOMAP
+#endif`,hM=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -126,10 +126,10 @@ version 0.8.2
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,lM=`#ifdef USE_AOMAP
+#endif`,fM=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,uM=`#ifdef USE_BATCHING
+#endif`,dM=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -163,15 +163,15 @@ version 0.8.2
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,hM=`#ifdef USE_BATCHING
+#endif`,pM=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,fM=`vec3 transformed = vec3( position );
+#endif`,mM=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,dM=`vec3 objectNormal = vec3( normal );
+#endif`,gM=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,pM=`float G_BlinnPhong_Implicit( ) {
+#endif`,_M=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -185,7 +185,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
-} // validated`,mM=`#ifdef USE_IRIDESCENCE
+} // validated`,xM=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,gM=`#ifdef USE_BUMPMAP
+#endif`,vM=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -269,7 +269,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
-#endif`,_M=`#if NUM_CLIPPING_PLANES > 0
+#endif`,yM=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -315,20 +315,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,xM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,SM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,vM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,bM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,yM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,MM=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,SM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,wM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,bM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,TM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,MM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,EM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,wM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,AM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
@@ -341,7 +341,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
-#endif`,TM=`#define PI 3.141592653589793
+#endif`,RM=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -412,7 +412,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
-} // validated`,EM=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,CM=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -505,7 +505,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
-#endif`,AM=`vec3 transformedNormal = objectNormal;
+#endif`,IM=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -531,21 +531,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
-#endif`,RM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,PM=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,CM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,LM=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,IM=`#ifdef USE_EMISSIVEMAP
+#endif`,NM=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,PM=`#ifdef USE_EMISSIVEMAP
+#endif`,DM=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,LM="gl_FragColor = linearToOutputTexel( gl_FragColor );",NM=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,OM="gl_FragColor = linearToOutputTexel( gl_FragColor );",UM=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -553,7 +553,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
-}`,DM=`#ifdef USE_ENVMAP
+}`,FM=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -580,7 +580,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,OM=`#ifdef USE_ENVMAP
+#endif`,zM=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -588,7 +588,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,UM=`#ifdef USE_ENVMAP
+#endif`,kM=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -599,7 +599,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,FM=`#ifdef USE_ENVMAP
+#endif`,BM=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -610,7 +610,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,zM=`#ifdef USE_ENVMAP
+#endif`,GM=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -627,18 +627,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,kM=`#ifdef USE_FOG
+#endif`,HM=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,BM=`#ifdef USE_FOG
+#endif`,VM=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,GM=`#ifdef USE_FOG
+#endif`,WM=`#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`,HM=`#ifdef USE_FOG
+#endif`,$M=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -647,7 +647,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,VM=`#ifdef USE_GRADIENTMAP
+#endif`,ZM=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -659,12 +659,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
-}`,WM=`#ifdef USE_LIGHTMAP
+}`,XM=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,$M=`LambertMaterial material;
+#endif`,qM=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,ZM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,YM=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -678,7 +678,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,XM=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,jM=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -807,7 +807,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,qM=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,KM=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -864,8 +864,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
}
#endif
#endif
-#endif`,YM=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,jM=`varying vec3 vViewPosition;
+#endif`,JM=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,QM=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -877,11 +877,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
-#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,KM=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ew=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,JM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,tw=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -898,7 +898,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
-#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,QM=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,nw=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -991,7 +991,7 @@ material.roughness = min( material.roughness, 1.0 );
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
-#endif`,ew=`uniform sampler2D dfgLUT;
+#endif`,iw=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1358,7 +1358,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
-}`,tw=`
+}`,rw=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1506,7 +1506,7 @@ IncidentLight directLight;
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,nw=`#if defined( RE_IndirectDiffuse )
+#endif`,sw=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1536,7 +1536,7 @@ IncidentLight directLight;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,iw=`#if defined( RE_IndirectDiffuse )
+#endif`,ow=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1544,7 +1544,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,rw=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,aw=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1589,27 +1589,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,sw=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,cw=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,ow=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,lw=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,aw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,uw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,cw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,hw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,lw=`#ifdef USE_MAP
+#endif`,fw=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,uw=`#ifdef USE_MAP
+#endif`,dw=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,hw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,pw=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1621,7 +1621,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,fw=`#if defined( USE_POINTS_UV )
+#endif`,mw=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1633,19 +1633,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,dw=`float metalnessFactor = metalness;
+#endif`,gw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,pw=`#ifdef USE_METALNESSMAP
+#endif`,_w=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,mw=`#ifdef USE_INSTANCING_MORPH
+#endif`,xw=`#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`,gw=`#if defined( USE_MORPHCOLORS )
+#endif`,vw=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1654,12 +1654,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,_w=`#ifdef USE_MORPHNORMALS
+#endif`,yw=`#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`,xw=`#ifdef USE_MORPHTARGETS
+#endif`,Sw=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1673,12 +1673,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,vw=`#ifdef USE_MORPHTARGETS
+#endif`,bw=`#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`,yw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,Mw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1719,7 +1719,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,Sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,ww=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1737,19 +1737,19 @@ vec3 nonPerturbedNormal = normal;`,Sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,bw=`#ifndef FLAT_SHADED
+#endif`,Tw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,Mw=`#ifndef FLAT_SHADED
+#endif`,Ew=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,ww=`#ifndef FLAT_SHADED
+#endif`,Aw=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1758,7 +1758,7 @@ vec3 nonPerturbedNormal = normal;`,Sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,Tw=`#ifdef USE_NORMALMAP
+#endif`,Rw=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1780,13 +1780,13 @@ vec3 nonPerturbedNormal = normal;`,Sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,Ew=`#ifdef USE_CLEARCOAT
+#endif`,Cw=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,Aw=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,Iw=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,Rw=`#ifdef USE_CLEARCOATMAP
+#endif`,Pw=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1795,18 +1795,18 @@ vec3 nonPerturbedNormal = normal;`,Sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,Cw=`#ifdef USE_IRIDESCENCEMAP
+#endif`,Lw=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,Iw=`#ifdef OPAQUE
+#endif`,Nw=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Pw=`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 ) {
@@ -1885,9 +1885,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,Lw=`#ifdef PREMULTIPLIED_ALPHA
+}`,Ow=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,Nw=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,Uw=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -1895,22 +1895,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,Fw=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,Ow=`#ifdef DITHERING
+#endif`,zw=`#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`,Uw=`float roughnessFactor = roughness;
+#endif`,kw=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,Fw=`#ifdef USE_ROUGHNESSMAP
+#endif`,Bw=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,zw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,Gw=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
@@ -2161,7 +2161,7 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
}
#endif
#endif
-#endif`,kw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,Hw=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
@@ -2206,7 +2206,7 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#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 )
+#endif`,Vw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,Gw=`float getShadowMask() {
+#endif`,Ww=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2287,12 +2287,12 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,Hw=`#ifdef USE_SKINNING
+}`,$w=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,Vw=`#ifdef USE_SKINNING
+#endif`,Zw=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2307,7 +2307,7 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,Ww=`#ifdef USE_SKINNING
+#endif`,Xw=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2315,7 +2315,7 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,$w=`#ifdef USE_SKINNING
+#endif`,qw=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2326,17 +2326,17 @@ gl_Position = projectionMatrix * mvPosition;`,Dw=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,Zw=`float specularStrength;
+#endif`,Yw=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,Xw=`#ifdef USE_SPECULARMAP
+#endif`,jw=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,qw=`#if defined( TONE_MAPPING )
+#endif`,Kw=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,Yw=`#ifndef saturate
+#endif`,Jw=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2433,7 +2433,7 @@ vec3 NeutralToneMapping( vec3 color ) {
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,Qw=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2454,7 +2454,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,Kw=`#ifdef USE_TRANSMISSION
+#endif`,eT=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2580,7 +2580,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#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`,Jw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,tT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2650,7 +2650,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Qw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,nT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2744,7 +2744,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,eT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,iT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -2815,7 +2815,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var tT=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var rT=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
@@ -2824,12 +2824,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,jw=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,nT=`varying vec2 vUv;
+#endif`,sT=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,iT=`uniform sampler2D t2D;
+}`,oT=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -2841,14 +2841,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,rT=`varying vec3 vWorldDirection;
+}`,aT=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,sT=`#ifdef ENVMAP_TYPE_CUBE
+}`,cT=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -2870,14 +2870,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,oT=`varying vec3 vWorldDirection;
+}`,lT=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,aT=`uniform samplerCube tCube;
+}`,uT=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -2887,7 +2887,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,cT=`#include <common>
+}`,hT=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -2914,7 +2914,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,lT=`#if DEPTH_PACKING == 3200
+}`,fT=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -2952,7 +2952,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,uT=`#define DISTANCE
+}`,dT=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -2979,7 +2979,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,hT=`#define DISTANCE
+}`,pT=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3002,13 +3002,13 @@ void main() {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,fT=`varying vec3 vWorldDirection;
+}`,mT=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,dT=`uniform sampler2D tEquirect;
+}`,gT=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3017,7 +3017,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,pT=`uniform float scale;
+}`,_T=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3039,7 +3039,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,mT=`uniform vec3 diffuse;
+}`,xT=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3067,7 +3067,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,gT=`#include <common>
+}`,vT=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3099,7 +3099,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,_T=`uniform vec3 diffuse;
+}`,yT=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3147,7 +3147,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,xT=`#define LAMBERT
+}`,ST=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3186,7 +3186,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,vT=`#define LAMBERT
+}`,bT=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3244,7 +3244,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,yT=`#define MATCAP
+}`,MT=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3278,7 +3278,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,ST=`#define MATCAP
+}`,wT=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3324,7 +3324,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,bT=`#define NORMAL
+}`,TT=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3357,7 +3357,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,MT=`#define NORMAL
+}`,ET=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3378,7 +3378,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,wT=`#define PHONG
+}`,AT=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3417,7 +3417,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,TT=`#define PHONG
+}`,RT=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3477,7 +3477,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,ET=`#define STANDARD
+}`,CT=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3520,7 +3520,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,AT=`#define STANDARD
+}`,IT=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3648,7 +3648,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,RT=`#define TOON
+}`,PT=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3685,7 +3685,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,CT=`#define TOON
+}`,LT=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3737,7 +3737,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,IT=`uniform float size;
+}`,NT=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -3768,7 +3768,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,PT=`uniform vec3 diffuse;
+}`,DT=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -3793,7 +3793,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,LT=`#include <common>
+}`,OT=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -3816,7 +3816,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,NT=`uniform vec3 color;
+}`,UT=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
@@ -3832,7 +3832,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,DT=`uniform float rotation;
+}`,FT=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
@@ -3856,7 +3856,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,OT=`uniform vec3 diffuse;
+}`,zT=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -3881,7 +3881,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,We={alphahash_fragment:nM,alphahash_pars_fragment:iM,alphamap_fragment:rM,alphamap_pars_fragment:sM,alphatest_fragment:oM,alphatest_pars_fragment:aM,aomap_fragment:cM,aomap_pars_fragment:lM,batching_pars_vertex:uM,batching_vertex:hM,begin_vertex:fM,beginnormal_vertex:dM,bsdfs:pM,iridescence_fragment:mM,bumpmap_pars_fragment:gM,clipping_planes_fragment:_M,clipping_planes_pars_fragment:xM,clipping_planes_pars_vertex:vM,clipping_planes_vertex:yM,color_fragment:SM,color_pars_fragment:bM,color_pars_vertex:MM,color_vertex:wM,common:TM,cube_uv_reflection_fragment:EM,defaultnormal_vertex:AM,displacementmap_pars_vertex:RM,displacementmap_vertex:CM,emissivemap_fragment:IM,emissivemap_pars_fragment:PM,colorspace_fragment:LM,colorspace_pars_fragment:NM,envmap_fragment:DM,envmap_common_pars_fragment:OM,envmap_pars_fragment:UM,envmap_pars_vertex:FM,envmap_physical_pars_fragment:qM,envmap_vertex:zM,fog_vertex:kM,fog_pars_vertex:BM,fog_fragment:GM,fog_pars_fragment:HM,gradientmap_pars_fragment:VM,lightmap_pars_fragment:WM,lights_lambert_fragment:$M,lights_lambert_pars_fragment:ZM,lights_pars_begin:XM,lights_toon_fragment:YM,lights_toon_pars_fragment:jM,lights_phong_fragment:KM,lights_phong_pars_fragment:JM,lights_physical_fragment:QM,lights_physical_pars_fragment:ew,lights_fragment_begin:tw,lights_fragment_maps:nw,lights_fragment_end:iw,lightprobes_pars_fragment:rw,logdepthbuf_fragment:sw,logdepthbuf_pars_fragment:ow,logdepthbuf_pars_vertex:aw,logdepthbuf_vertex:cw,map_fragment:lw,map_pars_fragment:uw,map_particle_fragment:hw,map_particle_pars_fragment:fw,metalnessmap_fragment:dw,metalnessmap_pars_fragment:pw,morphinstance_vertex:mw,morphcolor_vertex:gw,morphnormal_vertex:_w,morphtarget_pars_vertex:xw,morphtarget_vertex:vw,normal_fragment_begin:yw,normal_fragment_maps:Sw,normal_pars_fragment:bw,normal_pars_vertex:Mw,normal_vertex:ww,normalmap_pars_fragment:Tw,clearcoat_normal_fragment_begin:Ew,clearcoat_normal_fragment_maps:Aw,clearcoat_pars_fragment:Rw,iridescence_pars_fragment:Cw,opaque_fragment:Iw,packing:Pw,premultiplied_alpha_fragment:Lw,project_vertex:Nw,dithering_fragment:Dw,dithering_pars_fragment:Ow,roughnessmap_fragment:Uw,roughnessmap_pars_fragment:Fw,shadowmap_pars_fragment:zw,shadowmap_pars_vertex:kw,shadowmap_vertex:Bw,shadowmask_pars_fragment:Gw,skinbase_vertex:Hw,skinning_pars_vertex:Vw,skinning_vertex:Ww,skinnormal_vertex:$w,specularmap_fragment:Zw,specularmap_pars_fragment:Xw,tonemapping_fragment:qw,tonemapping_pars_fragment:Yw,transmission_fragment:jw,transmission_pars_fragment:Kw,uv_pars_fragment:Jw,uv_pars_vertex:Qw,uv_vertex:eT,worldpos_vertex:tT,background_vert:nT,background_frag:iT,backgroundCube_vert:rT,backgroundCube_frag:sT,cube_vert:oT,cube_frag:aT,depth_vert:cT,depth_frag:lT,distance_vert:uT,distance_frag:hT,equirect_vert:fT,equirect_frag:dT,linedashed_vert:pT,linedashed_frag:mT,meshbasic_vert:gT,meshbasic_frag:_T,meshlambert_vert:xT,meshlambert_frag:vT,meshmatcap_vert:yT,meshmatcap_frag:ST,meshnormal_vert:bT,meshnormal_frag:MT,meshphong_vert:wT,meshphong_frag:TT,meshphysical_vert:ET,meshphysical_frag:AT,meshtoon_vert:RT,meshtoon_frag:CT,points_vert:IT,points_frag:PT,shadow_vert:LT,shadow_frag:NT,sprite_vert:DT,sprite_frag:OT},fe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},ci={basic:{uniforms:Kt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Kt([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 Oe(0)},envMapIntensity:{value:1}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Kt([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 Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Kt([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 Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Kt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Kt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Kt([fe.points,fe.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Kt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Kt([fe.common,fe.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Kt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Kt([fe.sprite,fe.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distance:{uniforms:Kt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:We.distance_vert,fragmentShader:We.distance_frag},shadow:{uniforms:Kt([fe.lights,fe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};ci.physical={uniforms:Kt([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};var vc={r:0,b:0,g:0},UT=new Ge,px=new ze;px.set(-1,0,0,0,1,0,0,0,1);function FT(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let S=E.backgroundBlurriness>0;R=t.get(R,S)}return R}function g(E){let R=!1,S=d(E);if(S===null)p(o,a);else if(S&&S.isColor)p(S,1),R=!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||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let S=d(R);if(S&&(S.isCubeTexture||S.mapping===to)){if(l===void 0)l=new mt(new Yi(1,1,1),new Rn({name:"BackgroundCubeMaterial",uniforms:br(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:Yt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(UT.makeRotationFromEuler(R.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(px);if(l.material.toneMapped=$e.getTransfer(S.colorSpace)!==ft,u!==S||f!==S.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(S&&S.isTexture){if(c===void 0)c=new mt(new mo(2,2),new Rn({name:"BackgroundMaterial",uniforms:br(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:Wi,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=S,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(S.colorSpace)!==ft,S.matrixAutoUpdate===!0)S.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(S.matrix),u!==S||f!==S.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(vc,dh(e)),n.buffers.color.setClear(vc.r,vc.g,vc.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function zT(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(I,O,K,C,G){let X=!1,z=f(I,C,K,O);if(s!==z)s=z,l(s.object);if(X=d(I,C,K,G),X)g(I,C,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,S(I,O,K,C),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(I){return e.bindVertexArray(I)}function u(I){return e.deleteVertexArray(I)}function f(I,O,K,C){let G=C.wireframe===!0,X=i[O.id];if(X===void 0)X={},i[O.id]=X;let z=I.isInstancedMesh===!0?I.id:0,te=X[z];if(te===void 0)te={},X[z]=te;let H=te[K.id];if(H===void 0)H={},te[K.id]=H;let Q=H[G];if(Q===void 0)Q=h(c()),H[G]=Q;return Q}function h(I){let O=[],K=[],C=[];for(let G=0;G<n;G++)O[G]=0,K[G]=0,C[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:K,attributeDivisors:C,object:I,attributes:{},index:null}}function d(I,O,K,C){let G=s.attributes,X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=G[H],Te=X[H];if(Te===void 0){if(H==="instanceMatrix"&&I.instanceMatrix)Te=I.instanceMatrix;if(H==="instanceColor"&&I.instanceColor)Te=I.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Te)return!0;if(Te&&ee.data!==Te.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==C)return!0;return!1}function g(I,O,K,C){let G={},X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=X[H];if(ee===void 0){if(H==="instanceMatrix"&&I.instanceMatrix)ee=I.instanceMatrix;if(H==="instanceColor"&&I.instanceColor)ee=I.instanceColor}let Te={};if(Te.attribute=ee,ee&&ee.data)Te.data=ee.data;G[H]=Te,z++}s.attributes=G,s.attributesNum=z,s.index=C}function x(){let I=s.newAttributes;for(let O=0,K=I.length;O<K;O++)I[O]=0}function p(I){m(I,0)}function m(I,O){let K=s.newAttributes,C=s.enabledAttributes,G=s.attributeDivisors;if(K[I]=1,C[I]===0)e.enableVertexAttribArray(I),C[I]=1;if(G[I]!==O)e.vertexAttribDivisor(I,O),G[I]=O}function E(){let I=s.newAttributes,O=s.enabledAttributes;for(let K=0,C=O.length;K<C;K++)if(O[K]!==I[K])e.disableVertexAttribArray(K),O[K]=0}function R(I,O,K,C,G,X,z){if(z===!0)e.vertexAttribIPointer(I,O,K,G,X);else e.vertexAttribPointer(I,O,K,C,G,X)}function S(I,O,K,C){x();let G=C.attributes,X=K.getAttributes(),z=O.defaultAttributeValues;for(let te in X){let H=X[te];if(H.location>=0){let Q=G[te];if(Q===void 0){if(te==="instanceMatrix"&&I.instanceMatrix)Q=I.instanceMatrix;if(te==="instanceColor"&&I.instanceColor)Q=I.instanceColor}if(Q!==void 0){let ee=Q.normalized,Te=Q.itemSize,ve=t.get(Q);if(ve===void 0)continue;let{buffer:He,type:Me,bytesPerElement:Z}=ve,re=Me===e.INT||Me===e.UNSIGNED_INT||Q.gpuType===yu;if(Q.isInterleavedBufferAttribute){let se=Q.data,Ie=se.stride,Pe=Q.offset;if(se.isInstancedInterleavedBuffer){for(let we=0;we<H.locationSize;we++)m(H.location+we,se.meshPerAttribute);if(I.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=se.meshPerAttribute*se.count}else for(let we=0;we<H.locationSize;we++)p(H.location+we);e.bindBuffer(e.ARRAY_BUFFER,He);for(let we=0;we<H.locationSize;we++)R(H.location+we,Te/H.locationSize,Me,ee,Ie*Z,(Pe+Te/H.locationSize*we)*Z,re)}else{if(Q.isInstancedBufferAttribute){for(let se=0;se<H.locationSize;se++)m(H.location+se,Q.meshPerAttribute);if(I.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=Q.meshPerAttribute*Q.count}else for(let se=0;se<H.locationSize;se++)p(H.location+se);e.bindBuffer(e.ARRAY_BUFFER,He);for(let se=0;se<H.locationSize;se++)R(H.location+se,Te/H.locationSize,Me,ee,Te*Z,Te/H.locationSize*se*Z,re)}}else if(z!==void 0){let ee=z[te];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(H.location,ee);break;case 3:e.vertexAttrib3fv(H.location,ee);break;case 4:e.vertexAttrib4fv(H.location,ee);break;default:e.vertexAttrib1fv(H.location,ee)}}}}E()}function b(){M();for(let I in i){let O=i[I];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[I]}}function T(I){if(i[I.id]===void 0)return;let O=i[I.id];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[I.id]}function A(I){for(let O in i){let K=i[O];for(let C in K){let G=K[C];if(G[I.id]===void 0)continue;let X=G[I.id];for(let z in X)u(X[z].object),delete X[z];delete G[I.id]}}}function _(I){for(let O in i){let K=i[O],C=I.isInstancedMesh===!0?I.id:0,G=K[C];if(G===void 0)continue;for(let X in G){let z=G[X];for(let te in z)u(z[te].object),delete z[te];delete G[X]}if(delete K[C],Object.keys(K).length===0)delete i[O]}}function M(){if(F(),o=!0,s===r)return;s=r,l(s.object)}function F(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:F,dispose:b,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function kT(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function BT(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==si&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===ri&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Gn&&A!==Mi&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ce("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ce("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:S,maxSamples:b,samples:T}}function GT(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Tn,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,S=m.clippingState||null;c.value=S,S=u(g,h,R,d);for(let b=0;b!==R;++b)S[b]=n[b];m.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,S=d;R!==x;++R,S+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,S),p[S+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var gs=4,HT=6,VT=20,WT=256,yo=new wr,Z0=new Oe,Ih=null,Ph=0,Lh=0,Nh=!1,$T=new U,Tr=new U;class wo{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=$T}=r;Ih=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Lh=this._renderer.getActiveMipmapLevel(),Nh=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=Y0(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=q0(),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(Ih,Ph,Lh),this._renderer.xr.enabled=Nh,e.scissorTest=!1,ms(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ns||e.mapping===mr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Ih=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Lh=this._renderer.getActiveMipmapLevel(),Nh=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:Gt,minFilter:Gt,generateMipmaps:!1,type:ri,format:si,colorSpace:gn,depthBuffer:!1},i=X0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=X0(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=ZT(r)),this._blurMaterial=qT(r,e,t),this._ggxMaterial=XT(r,e,t)}return i}_compileMaterial(e){let t=new mt(new jt,e);this._renderer.compile(t,yo)}_sceneToCubeUV(e,t,n,i,r){let a=new Dt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(Z0),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 Yi,new oi({name:"PMREM.Background",side:Yt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(Z0),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let S=this._cubeSize;if(ms(i,R*S,E>2?S:0,S,S),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ns||e.mapping===mr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Y0();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=q0();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;ms(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,yo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-gs?n-d+gs:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,ms(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,yo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,ms(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,yo)}_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-gs?i-this._lodMax+gs:0),f=4*(this._cubeSize-l);ms(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,yo)}}function ZT(e){let t=[],n=[],i=e,r=e-gs+1+HT;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,S=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(S,d*h*m);for(let b=0;b<h;b++){let T=u[b*2]*2-1,A=u[b*2+1]*2-1;if(m===0)Tr.set(1,A,T);else if(m===1)Tr.set(-T,1,-A);else if(m===2)Tr.set(-T,A,1);else if(m===3)Tr.set(-1,A,-T);else if(m===4)Tr.set(-T,-1,A);else Tr.set(T,A,-1);Tr.toArray(x,(m*h+b)*d)}}let p=new jt;if(p.setAttribute("position",new Bt(g,d)),p.setAttribute("outputDirection",new Bt(x,d)),n.push(new mt(p,null)),i>gs)i--}return{lodMeshes:n,sizeLods:t}}function X0(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=to,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ms(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function XT(e,t,n){return new Rn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:WT,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:Sc(),fragmentShader:`
+}`,We={alphahash_fragment:sM,alphahash_pars_fragment:oM,alphamap_fragment:aM,alphamap_pars_fragment:cM,alphatest_fragment:lM,alphatest_pars_fragment:uM,aomap_fragment:hM,aomap_pars_fragment:fM,batching_pars_vertex:dM,batching_vertex:pM,begin_vertex:mM,beginnormal_vertex:gM,bsdfs:_M,iridescence_fragment:xM,bumpmap_pars_fragment:vM,clipping_planes_fragment:yM,clipping_planes_pars_fragment:SM,clipping_planes_pars_vertex:bM,clipping_planes_vertex:MM,color_fragment:wM,color_pars_fragment:TM,color_pars_vertex:EM,color_vertex:AM,common:RM,cube_uv_reflection_fragment:CM,defaultnormal_vertex:IM,displacementmap_pars_vertex:PM,displacementmap_vertex:LM,emissivemap_fragment:NM,emissivemap_pars_fragment:DM,colorspace_fragment:OM,colorspace_pars_fragment:UM,envmap_fragment:FM,envmap_common_pars_fragment:zM,envmap_pars_fragment:kM,envmap_pars_vertex:BM,envmap_physical_pars_fragment:KM,envmap_vertex:GM,fog_vertex:HM,fog_pars_vertex:VM,fog_fragment:WM,fog_pars_fragment:$M,gradientmap_pars_fragment:ZM,lightmap_pars_fragment:XM,lights_lambert_fragment:qM,lights_lambert_pars_fragment:YM,lights_pars_begin:jM,lights_toon_fragment:JM,lights_toon_pars_fragment:QM,lights_phong_fragment:ew,lights_phong_pars_fragment:tw,lights_physical_fragment:nw,lights_physical_pars_fragment:iw,lights_fragment_begin:rw,lights_fragment_maps:sw,lights_fragment_end:ow,lightprobes_pars_fragment:aw,logdepthbuf_fragment:cw,logdepthbuf_pars_fragment:lw,logdepthbuf_pars_vertex:uw,logdepthbuf_vertex:hw,map_fragment:fw,map_pars_fragment:dw,map_particle_fragment:pw,map_particle_pars_fragment:mw,metalnessmap_fragment:gw,metalnessmap_pars_fragment:_w,morphinstance_vertex:xw,morphcolor_vertex:vw,morphnormal_vertex:yw,morphtarget_pars_vertex:Sw,morphtarget_vertex:bw,normal_fragment_begin:Mw,normal_fragment_maps:ww,normal_pars_fragment:Tw,normal_pars_vertex:Ew,normal_vertex:Aw,normalmap_pars_fragment:Rw,clearcoat_normal_fragment_begin:Cw,clearcoat_normal_fragment_maps:Iw,clearcoat_pars_fragment:Pw,iridescence_pars_fragment:Lw,opaque_fragment:Nw,packing:Dw,premultiplied_alpha_fragment:Ow,project_vertex:Uw,dithering_fragment:Fw,dithering_pars_fragment:zw,roughnessmap_fragment:kw,roughnessmap_pars_fragment:Bw,shadowmap_pars_fragment:Gw,shadowmap_pars_vertex:Hw,shadowmap_vertex:Vw,shadowmask_pars_fragment:Ww,skinbase_vertex:$w,skinning_pars_vertex:Zw,skinning_vertex:Xw,skinnormal_vertex:qw,specularmap_fragment:Yw,specularmap_pars_fragment:jw,tonemapping_fragment:Kw,tonemapping_pars_fragment:Jw,transmission_fragment:Qw,transmission_pars_fragment:eT,uv_pars_fragment:tT,uv_pars_vertex:nT,uv_vertex:iT,worldpos_vertex:rT,background_vert:sT,background_frag:oT,backgroundCube_vert:aT,backgroundCube_frag:cT,cube_vert:lT,cube_frag:uT,depth_vert:hT,depth_frag:fT,distance_vert:dT,distance_frag:pT,equirect_vert:mT,equirect_frag:gT,linedashed_vert:_T,linedashed_frag:xT,meshbasic_vert:vT,meshbasic_frag:yT,meshlambert_vert:ST,meshlambert_frag:bT,meshmatcap_vert:MT,meshmatcap_frag:wT,meshnormal_vert:TT,meshnormal_frag:ET,meshphong_vert:AT,meshphong_frag:RT,meshphysical_vert:CT,meshphysical_frag:IT,meshtoon_vert:PT,meshtoon_frag:LT,points_vert:NT,points_frag:DT,shadow_vert:OT,shadow_frag:UT,sprite_vert:FT,sprite_frag:zT},fe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},ci={basic:{uniforms:Kt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:We.meshbasic_vert,fragmentShader:We.meshbasic_frag},lambert:{uniforms:Kt([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 Oe(0)},envMapIntensity:{value:1}}]),vertexShader:We.meshlambert_vert,fragmentShader:We.meshlambert_frag},phong:{uniforms:Kt([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 Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:We.meshphong_vert,fragmentShader:We.meshphong_frag},standard:{uniforms:Kt([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 Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag},toon:{uniforms:Kt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:We.meshtoon_vert,fragmentShader:We.meshtoon_frag},matcap:{uniforms:Kt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:We.meshmatcap_vert,fragmentShader:We.meshmatcap_frag},points:{uniforms:Kt([fe.points,fe.fog]),vertexShader:We.points_vert,fragmentShader:We.points_frag},dashed:{uniforms:Kt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:We.linedashed_vert,fragmentShader:We.linedashed_frag},depth:{uniforms:Kt([fe.common,fe.displacementmap]),vertexShader:We.depth_vert,fragmentShader:We.depth_frag},normal:{uniforms:Kt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:We.meshnormal_vert,fragmentShader:We.meshnormal_frag},sprite:{uniforms:Kt([fe.sprite,fe.fog]),vertexShader:We.sprite_vert,fragmentShader:We.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:We.background_vert,fragmentShader:We.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:We.backgroundCube_vert,fragmentShader:We.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:We.cube_vert,fragmentShader:We.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:We.equirect_vert,fragmentShader:We.equirect_frag},distance:{uniforms:Kt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:We.distance_vert,fragmentShader:We.distance_frag},shadow:{uniforms:Kt([fe.lights,fe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:We.shadow_vert,fragmentShader:We.shadow_frag}};ci.physical={uniforms:Kt([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:We.meshphysical_vert,fragmentShader:We.meshphysical_frag};var vc={r:0,b:0,g:0},kT=new Ge,_x=new ze;_x.set(-1,0,0,0,1,0,0,0,1);function BT(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let S=E.backgroundBlurriness>0;R=t.get(R,S)}return R}function g(E){let R=!1,S=d(E);if(S===null)p(o,a);else if(S&&S.isColor)p(S,1),R=!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||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let S=d(R);if(S&&(S.isCubeTexture||S.mapping===to)){if(l===void 0)l=new mt(new Yi(1,1,1),new Rn({name:"BackgroundCubeMaterial",uniforms:br(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:Yt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(kT.makeRotationFromEuler(R.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(_x);if(l.material.toneMapped=$e.getTransfer(S.colorSpace)!==ft,u!==S||f!==S.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(S&&S.isTexture){if(c===void 0)c=new mt(new mo(2,2),new Rn({name:"BackgroundMaterial",uniforms:br(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:Wi,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=S,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=$e.getTransfer(S.colorSpace)!==ft,S.matrixAutoUpdate===!0)S.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(S.matrix),u!==S||f!==S.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(vc,mh(e)),n.buffers.color.setClear(vc.r,vc.g,vc.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function GT(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(I,O,K,C,G){let X=!1,z=f(I,C,K,O);if(s!==z)s=z,l(s.object);if(X=d(I,C,K,G),X)g(I,C,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,S(I,O,K,C),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(I){return e.bindVertexArray(I)}function u(I){return e.deleteVertexArray(I)}function f(I,O,K,C){let G=C.wireframe===!0,X=i[O.id];if(X===void 0)X={},i[O.id]=X;let z=I.isInstancedMesh===!0?I.id:0,te=X[z];if(te===void 0)te={},X[z]=te;let H=te[K.id];if(H===void 0)H={},te[K.id]=H;let Q=H[G];if(Q===void 0)Q=h(c()),H[G]=Q;return Q}function h(I){let O=[],K=[],C=[];for(let G=0;G<n;G++)O[G]=0,K[G]=0,C[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:K,attributeDivisors:C,object:I,attributes:{},index:null}}function d(I,O,K,C){let G=s.attributes,X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=G[H],Te=X[H];if(Te===void 0){if(H==="instanceMatrix"&&I.instanceMatrix)Te=I.instanceMatrix;if(H==="instanceColor"&&I.instanceColor)Te=I.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Te)return!0;if(Te&&ee.data!==Te.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==C)return!0;return!1}function g(I,O,K,C){let G={},X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=X[H];if(ee===void 0){if(H==="instanceMatrix"&&I.instanceMatrix)ee=I.instanceMatrix;if(H==="instanceColor"&&I.instanceColor)ee=I.instanceColor}let Te={};if(Te.attribute=ee,ee&&ee.data)Te.data=ee.data;G[H]=Te,z++}s.attributes=G,s.attributesNum=z,s.index=C}function x(){let I=s.newAttributes;for(let O=0,K=I.length;O<K;O++)I[O]=0}function p(I){m(I,0)}function m(I,O){let K=s.newAttributes,C=s.enabledAttributes,G=s.attributeDivisors;if(K[I]=1,C[I]===0)e.enableVertexAttribArray(I),C[I]=1;if(G[I]!==O)e.vertexAttribDivisor(I,O),G[I]=O}function E(){let I=s.newAttributes,O=s.enabledAttributes;for(let K=0,C=O.length;K<C;K++)if(O[K]!==I[K])e.disableVertexAttribArray(K),O[K]=0}function R(I,O,K,C,G,X,z){if(z===!0)e.vertexAttribIPointer(I,O,K,G,X);else e.vertexAttribPointer(I,O,K,C,G,X)}function S(I,O,K,C){x();let G=C.attributes,X=K.getAttributes(),z=O.defaultAttributeValues;for(let te in X){let H=X[te];if(H.location>=0){let Q=G[te];if(Q===void 0){if(te==="instanceMatrix"&&I.instanceMatrix)Q=I.instanceMatrix;if(te==="instanceColor"&&I.instanceColor)Q=I.instanceColor}if(Q!==void 0){let ee=Q.normalized,Te=Q.itemSize,ve=t.get(Q);if(ve===void 0)continue;let{buffer:He,type:Me,bytesPerElement:Z}=ve,re=Me===e.INT||Me===e.UNSIGNED_INT||Q.gpuType===bu;if(Q.isInterleavedBufferAttribute){let se=Q.data,Ie=se.stride,Pe=Q.offset;if(se.isInstancedInterleavedBuffer){for(let we=0;we<H.locationSize;we++)m(H.location+we,se.meshPerAttribute);if(I.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=se.meshPerAttribute*se.count}else for(let we=0;we<H.locationSize;we++)p(H.location+we);e.bindBuffer(e.ARRAY_BUFFER,He);for(let we=0;we<H.locationSize;we++)R(H.location+we,Te/H.locationSize,Me,ee,Ie*Z,(Pe+Te/H.locationSize*we)*Z,re)}else{if(Q.isInstancedBufferAttribute){for(let se=0;se<H.locationSize;se++)m(H.location+se,Q.meshPerAttribute);if(I.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=Q.meshPerAttribute*Q.count}else for(let se=0;se<H.locationSize;se++)p(H.location+se);e.bindBuffer(e.ARRAY_BUFFER,He);for(let se=0;se<H.locationSize;se++)R(H.location+se,Te/H.locationSize,Me,ee,Te*Z,Te/H.locationSize*se*Z,re)}}else if(z!==void 0){let ee=z[te];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(H.location,ee);break;case 3:e.vertexAttrib3fv(H.location,ee);break;case 4:e.vertexAttrib4fv(H.location,ee);break;default:e.vertexAttrib1fv(H.location,ee)}}}}E()}function b(){M();for(let I in i){let O=i[I];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[I]}}function T(I){if(i[I.id]===void 0)return;let O=i[I.id];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[I.id]}function A(I){for(let O in i){let K=i[O];for(let C in K){let G=K[C];if(G[I.id]===void 0)continue;let X=G[I.id];for(let z in X)u(X[z].object),delete X[z];delete G[I.id]}}}function _(I){for(let O in i){let K=i[O],C=I.isInstancedMesh===!0?I.id:0,G=K[C];if(G===void 0)continue;for(let X in G){let z=G[X];for(let te in z)u(z[te].object),delete z[te];delete G[X]}if(delete K[C],Object.keys(K).length===0)delete i[O]}}function M(){if(F(),o=!0,s===r)return;s=r,l(s.object)}function F(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:F,dispose:b,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function HT(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function VT(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==si&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===ri&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Gn&&A!==Mi&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Ce("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Ce("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:S,maxSamples:b,samples:T}}function WT(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Tn,a=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,S=m.clippingState||null;c.value=S,S=u(g,h,R,d);for(let b=0;b!==R;++b)S[b]=n[b];m.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,S=d;R!==x;++R,S+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,S),p[S+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var gs=4,$T=6,ZT=20,XT=256,yo=new wr,Y0=new Oe,Lh=null,Nh=0,Dh=0,Oh=!1,qT=new U,Tr=new U;class wo{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=qT}=r;Lh=this._renderer.getRenderTarget(),Nh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Oh=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=J0(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=K0(),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(Lh,Nh,Dh),this._renderer.xr.enabled=Oh,e.scissorTest=!1,ms(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===ns||e.mapping===mr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Lh=this._renderer.getRenderTarget(),Nh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Oh=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:Gt,minFilter:Gt,generateMipmaps:!1,type:ri,format:si,colorSpace:gn,depthBuffer:!1},i=j0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=j0(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=YT(r)),this._blurMaterial=KT(r,e,t),this._ggxMaterial=jT(r,e,t)}return i}_compileMaterial(e){let t=new mt(new jt,e);this._renderer.compile(t,yo)}_sceneToCubeUV(e,t,n,i,r){let a=new Dt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(Y0),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 Yi,new oi({name:"PMREM.Background",side:Yt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(Y0),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let S=this._cubeSize;if(ms(i,R*S,E>2?S:0,S,S),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===ns||e.mapping===mr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=J0();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=K0();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;ms(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,yo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-gs?n-d+gs:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,ms(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,yo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,ms(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,yo)}_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-gs?i-this._lodMax+gs:0),f=4*(this._cubeSize-l);ms(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,yo)}}function YT(e){let t=[],n=[],i=e,r=e-gs+1+$T;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,S=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(S,d*h*m);for(let b=0;b<h;b++){let T=u[b*2]*2-1,A=u[b*2+1]*2-1;if(m===0)Tr.set(1,A,T);else if(m===1)Tr.set(-T,1,-A);else if(m===2)Tr.set(-T,A,1);else if(m===3)Tr.set(-1,A,-T);else if(m===4)Tr.set(-T,-1,A);else Tr.set(T,A,-1);Tr.toArray(x,(m*h+b)*d)}}let p=new jt;if(p.setAttribute("position",new Bt(g,d)),p.setAttribute("outputDirection",new Bt(x,d)),n.push(new mt(p,null)),i>gs)i--}return{lodMeshes:n,sizeLods:t}}function j0(e,t,n){let i=new _n(e,t,n);return i.texture.mapping=to,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ms(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function jT(e,t,n){return new Rn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:XT,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:Sc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -3985,7 +3985,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:ni,depthTest:!1,depthWrite:!1})}function qT(e,t,n){return new Rn({name:"SphericalGaussianBlur",defines:{SAMPLES:VT,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:Sc(),fragmentShader:`
+ `,blending:ni,depthTest:!1,depthWrite:!1})}function KT(e,t,n){return new Rn({name:"SphericalGaussianBlur",defines:{SAMPLES:ZT,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:Sc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4045,7 +4045,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:ni,depthTest:!1,depthWrite:!1})}function q0(){return new Rn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Sc(),fragmentShader:`
+ `,blending:ni,depthTest:!1,depthWrite:!1})}function K0(){return new Rn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Sc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4064,7 +4064,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:ni,depthTest:!1,depthWrite:!1})}function Y0(){return new Rn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Sc(),fragmentShader:`
+ `,blending:ni,depthTest:!1,depthWrite:!1})}function J0(){return new Rn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Sc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4095,7 +4095,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}class zh extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new ac(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 Bh extends _n{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new ac(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -4130,7 +4130,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new Yi(5,5,5),r=new Rn({name:"CubemapFromEquirect",uniforms:br(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Yt,blending:ni});r.uniforms.tEquirect.value=t;let s=new mt(i,r),o=t.minFilter;if(t.minFilter===ii)t.minFilter=Gt;return new bh(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 YT(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===Ga||d===Ha)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new zh(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===Ga||d===Ha,x=d===ns||d===mr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new wo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new wo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===Ga)h.mapping=ns;else if(d===Ha)h.mapping=mr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function jT(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)dr("WebGLRenderer: "+i+" extension not supported.");return r}}}function KT(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,S=E.length;R<S;R+=3){let b=E[R+0],T=E[R+1],A=E[R+2];h.push(b,T,T,A,A,b)}}else{let E=g.array;x=g.version;for(let R=0,S=E.length/3-1;R<S;R+=3){let b=R+0,T=R+1,A=R+2;h.push(b,T,T,A,A,b)}}let p=new(g.count>=65535?ic:nc)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function JT(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function QT(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function eE(e,t,n){let i=new WeakMap,r=new at;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let S=a.attributes.position.count*R,b=1;if(S>t.maxTextureSize)b=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize;let T=new Float32Array(S*b*4*f),A=new ec(T,S,b,f);A.type=Mi,A.needsUpdate=!0;let _=R*4;for(let F=0;F<f;F++){let I=p[F],O=m[F],K=E[F],C=S*b*4*F;for(let G=0;G<I.count;G++){let X=G*_;if(d===!0)r.fromBufferAttribute(I,G),T[C+X+0]=r.x,T[C+X+1]=r.y,T[C+X+2]=r.z,T[C+X+3]=0;if(g===!0)r.fromBufferAttribute(O,G),T[C+X+4]=r.x,T[C+X+5]=r.y,T[C+X+6]=r.z,T[C+X+7]=0;if(x===!0)r.fromBufferAttribute(K,G),T[C+X+8]=r.x,T[C+X+9]=r.y,T[C+X+10]=r.z,T[C+X+11]=K.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(S,b)},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 d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function tE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var nE={[pu]:"LINEAR_TONE_MAPPING",[mu]:"REINHARD_TONE_MAPPING",[gu]:"CINEON_TONE_MAPPING",[eo]:"ACES_FILMIC_TONE_MAPPING",[xu]:"AGX_TONE_MAPPING",[vu]:"NEUTRAL_TONE_MAPPING",[_u]:"CUSTOM_TONE_MAPPING"};function iE(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new jt;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 ph({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new Yi(5,5,5),r=new Rn({name:"CubemapFromEquirect",uniforms:br(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Yt,blending:ni});r.uniforms.tEquirect.value=t;let s=new mt(i,r),o=t.minFilter;if(t.minFilter===ii)t.minFilter=Gt;return new wh(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 JT(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===Ga||d===Ha)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new Bh(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===Ga||d===Ha,x=d===ns||d===mr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new wo(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new wo(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===Ga)h.mapping=ns;else if(d===Ha)h.mapping=mr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function QT(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)dr("WebGLRenderer: "+i+" extension not supported.");return r}}}function eE(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,S=E.length;R<S;R+=3){let b=E[R+0],T=E[R+1],A=E[R+2];h.push(b,T,T,A,A,b)}}else{let E=g.array;x=g.version;for(let R=0,S=E.length/3-1;R<S;R+=3){let b=R+0,T=R+1,A=R+2;h.push(b,T,T,A,A,b)}}let p=new(g.count>=65535?ic:nc)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function tE(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function nE(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function iE(e,t,n){let i=new WeakMap,r=new at;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let S=a.attributes.position.count*R,b=1;if(S>t.maxTextureSize)b=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize;let T=new Float32Array(S*b*4*f),A=new ec(T,S,b,f);A.type=Mi,A.needsUpdate=!0;let _=R*4;for(let F=0;F<f;F++){let I=p[F],O=m[F],K=E[F],C=S*b*4*F;for(let G=0;G<I.count;G++){let X=G*_;if(d===!0)r.fromBufferAttribute(I,G),T[C+X+0]=r.x,T[C+X+1]=r.y,T[C+X+2]=r.z,T[C+X+3]=0;if(g===!0)r.fromBufferAttribute(O,G),T[C+X+4]=r.x,T[C+X+5]=r.y,T[C+X+6]=r.z,T[C+X+7]=0;if(x===!0)r.fromBufferAttribute(K,G),T[C+X+8]=r.x,T[C+X+9]=r.y,T[C+X+10]=r.z,T[C+X+11]=K.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(S,b)},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 d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function rE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var sE={[gu]:"LINEAR_TONE_MAPPING",[_u]:"REINHARD_TONE_MAPPING",[xu]:"CINEON_TONE_MAPPING",[eo]:"ACES_FILMIC_TONE_MAPPING",[yu]:"AGX_TONE_MAPPING",[Su]:"NEUTRAL_TONE_MAPPING",[vu]:"CUSTOM_TONE_MAPPING"};function oE(e,t,n,i,r,s){let o=new _n(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new jt;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 gh({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -4176,17 +4176,17 @@ void main() {
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),f=new mt(l,u),h=new wr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(S,b){if(o.setSize(S,b),a!==null)a.setSize(S,b);if(c!==null)c.setSize(S,b);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(S,b)}},this.setEffects=function(S){E=S,R=E.length>0&&E[0].isRenderPass===!0;let{width:b,height:T}=o;if(E.length>0&&a===null)a=new _n(b,T,{type:ri,depthBuffer:!1,stencilBuffer:!1}),c=new _n(b,T,{type:ri,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(b,T)}},this.begin=function(S,b){if(x)return!1;if(S.toneMapping===kn&&E.length===0)return!1;if(m=b,b!==null){let{width:T,height:A}=b;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)S.setRenderTarget(o);return p=S.toneMapping,S.toneMapping=kn,!0},this.hasRenderPass=function(){return R},this.end=function(S,b){S.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let M=E[_];if(M.enabled===!1)continue;if(M.render(S,A,T,b),M.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==S.outputColorSpace||g!==S.toneMapping){if(d=S.outputColorSpace,g=S.toneMapping,u.defines={},$e.getTransfer(d)===ft)u.defines.SRGB_TRANSFER="";let _=nE[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,S.setRenderTarget(m),S.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var mx=new Et,Uh=new Sr(1,1),gx=new ec,_x=new hh,xx=new ac,j0=[],K0=[],J0=new Float32Array(16),Q0=new Float32Array(9),ex=new Float32Array(4);function _s(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=j0[r];if(s===void 0)s=new Float32Array(r),j0[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 Ot(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 Ut(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function bc(e,t){let n=K0[t];if(n===void 0)n=new Int32Array(t),K0[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function rE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function sE(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(Ot(n,t))return;e.uniform2fv(this.addr,t),Ut(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(Ot(n,t))return;e.uniform3fv(this.addr,t),Ut(n,t)}}function aE(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(Ot(n,t))return;e.uniform4fv(this.addr,t),Ut(n,t)}}function cE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;ex.set(i),e.uniformMatrix2fv(this.addr,!1,ex),Ut(n,i)}}function lE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;Q0.set(i),e.uniformMatrix3fv(this.addr,!1,Q0),Ut(n,i)}}function uE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;J0.set(i),e.uniformMatrix4fv(this.addr,!1,J0),Ut(n,i)}}function hE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function fE(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(Ot(n,t))return;e.uniform2iv(this.addr,t),Ut(n,t)}}function dE(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(Ot(n,t))return;e.uniform3iv(this.addr,t),Ut(n,t)}}function pE(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(Ot(n,t))return;e.uniform4iv(this.addr,t),Ut(n,t)}}function mE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function gE(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(Ot(n,t))return;e.uniform2uiv(this.addr,t),Ut(n,t)}}function _E(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(Ot(n,t))return;e.uniform3uiv(this.addr,t),Ut(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(Ot(n,t))return;e.uniform4uiv(this.addr,t),Ut(n,t)}}function vE(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)Uh.compareFunction=n.isReversedDepthBuffer()?Qa:Ja,s=Uh;else s=mx;n.setTexture2D(t||s,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.setTexture3D(t||_x,r)}function SE(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||xx,r)}function bE(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||gx,r)}function ME(e){switch(e){case 5126:return rE;case 35664:return sE;case 35665:return oE;case 35666:return aE;case 35674:return cE;case 35675:return lE;case 35676:return uE;case 5124:case 35670:return hE;case 35667:case 35671:return fE;case 35668:case 35672:return dE;case 35669:case 35673:return pE;case 5125:return mE;case 36294:return gE;case 36295:return _E;case 36296:return xE;case 35678:case 36198:case 36298:case 36306:case 35682:return vE;case 35679:case 36299:case 36307:return yE;case 35680:case 36300:case 36308:case 36293:return SE;case 36289:case 36303:case 36311:case 36292:return bE}}function wE(e,t){e.uniform1fv(this.addr,t)}function TE(e,t){let n=_s(t,this.size,2);e.uniform2fv(this.addr,n)}function EE(e,t){let n=_s(t,this.size,3);e.uniform3fv(this.addr,n)}function AE(e,t){let n=_s(t,this.size,4);e.uniform4fv(this.addr,n)}function RE(e,t){let n=_s(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function CE(e,t){let n=_s(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function IE(e,t){let n=_s(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function PE(e,t){e.uniform1iv(this.addr,t)}function LE(e,t){e.uniform2iv(this.addr,t)}function NE(e,t){e.uniform3iv(this.addr,t)}function DE(e,t){e.uniform4iv(this.addr,t)}function OE(e,t){e.uniform1uiv(this.addr,t)}function UE(e,t){e.uniform2uiv(this.addr,t)}function FE(e,t){e.uniform3uiv(this.addr,t)}function zE(e,t){e.uniform4uiv(this.addr,t)}function kE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Uh;else o=mx;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function BE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||_x,s[o])}function GE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||xx,s[o])}function HE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||gx,s[o])}function VE(e){switch(e){case 5126:return wE;case 35664:return TE;case 35665:return EE;case 35666:return AE;case 35674:return RE;case 35675:return CE;case 35676:return IE;case 5124:case 35670:return PE;case 35667:case 35671:return LE;case 35668:case 35672:return NE;case 35669:case 35673:return DE;case 5125:return OE;case 36294:return UE;case 36295:return FE;case 36296:return zE;case 35678:case 36198:case 36298:case 36306:case 35682:return kE;case 35679:case 36299:case 36307:return BE;case 35680:case 36300:case 36308:case 36293:return GE;case 36289:case 36303:case 36311:case 36292:return HE}}class vx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=ME(t.type)}}class yx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=VE(t.type)}}class Sx{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 Dh=/(\w+)(\])?(\[|\.)?/g;function tx(e,t){e.seq.push(t),e.map[t.id]=t}function WE(e,t,n){let i=e.name,r=i.length;Dh.lastIndex=0;while(!0){let s=Dh.exec(i),o=Dh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){tx(n,l===void 0?new vx(a,e,t):new yx(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new Sx(a),tx(n,f);n=f}}}class Mo{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);WE(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 nx(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var $E=37297,ZE=0;function XE(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),f=new mt(l,u),h=new wr(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(S,b){if(o.setSize(S,b),a!==null)a.setSize(S,b);if(c!==null)c.setSize(S,b);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(S,b)}},this.setEffects=function(S){E=S,R=E.length>0&&E[0].isRenderPass===!0;let{width:b,height:T}=o;if(E.length>0&&a===null)a=new _n(b,T,{type:ri,depthBuffer:!1,stencilBuffer:!1}),c=new _n(b,T,{type:ri,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(b,T)}},this.begin=function(S,b){if(x)return!1;if(S.toneMapping===kn&&E.length===0)return!1;if(m=b,b!==null){let{width:T,height:A}=b;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)S.setRenderTarget(o);return p=S.toneMapping,S.toneMapping=kn,!0},this.hasRenderPass=function(){return R},this.end=function(S,b){S.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let M=E[_];if(M.enabled===!1)continue;if(M.render(S,A,T,b),M.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==S.outputColorSpace||g!==S.toneMapping){if(d=S.outputColorSpace,g=S.toneMapping,u.defines={},$e.getTransfer(d)===ft)u.defines.SRGB_TRANSFER="";let _=sE[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,S.setRenderTarget(m),S.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var xx=new Et,zh=new Sr(1,1),vx=new ec,yx=new dh,Sx=new ac,Q0=[],ex=[],tx=new Float32Array(16),nx=new Float32Array(9),ix=new Float32Array(4);function _s(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Q0[r];if(s===void 0)s=new Float32Array(r),Q0[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 Ot(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 Ut(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function bc(e,t){let n=ex[t];if(n===void 0)n=new Int32Array(t),ex[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function aE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function cE(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(Ot(n,t))return;e.uniform2fv(this.addr,t),Ut(n,t)}}function lE(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(Ot(n,t))return;e.uniform3fv(this.addr,t),Ut(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(Ot(n,t))return;e.uniform4fv(this.addr,t),Ut(n,t)}}function hE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;ix.set(i),e.uniformMatrix2fv(this.addr,!1,ix),Ut(n,i)}}function fE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;nx.set(i),e.uniformMatrix3fv(this.addr,!1,nx),Ut(n,i)}}function dE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ot(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ut(n,t)}else{if(Ot(n,i))return;tx.set(i),e.uniformMatrix4fv(this.addr,!1,tx),Ut(n,i)}}function pE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function mE(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(Ot(n,t))return;e.uniform2iv(this.addr,t),Ut(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(Ot(n,t))return;e.uniform3iv(this.addr,t),Ut(n,t)}}function _E(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(Ot(n,t))return;e.uniform4iv(this.addr,t),Ut(n,t)}}function xE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(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.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ot(n,t))return;e.uniform2uiv(this.addr,t),Ut(n,t)}}function yE(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(Ot(n,t))return;e.uniform3uiv(this.addr,t),Ut(n,t)}}function SE(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(Ot(n,t))return;e.uniform4uiv(this.addr,t),Ut(n,t)}}function bE(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)zh.compareFunction=n.isReversedDepthBuffer()?Qa:Ja,s=zh;else s=xx;n.setTexture2D(t||s,r)}function ME(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||yx,r)}function wE(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||Sx,r)}function TE(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||vx,r)}function EE(e){switch(e){case 5126:return aE;case 35664:return cE;case 35665:return lE;case 35666:return uE;case 35674:return hE;case 35675:return fE;case 35676:return dE;case 5124:case 35670:return pE;case 35667:case 35671:return mE;case 35668:case 35672:return gE;case 35669:case 35673:return _E;case 5125:return xE;case 36294:return vE;case 36295:return yE;case 36296:return SE;case 35678:case 36198:case 36298:case 36306:case 35682:return bE;case 35679:case 36299:case 36307:return ME;case 35680:case 36300:case 36308:case 36293:return wE;case 36289:case 36303:case 36311:case 36292:return TE}}function AE(e,t){e.uniform1fv(this.addr,t)}function RE(e,t){let n=_s(t,this.size,2);e.uniform2fv(this.addr,n)}function CE(e,t){let n=_s(t,this.size,3);e.uniform3fv(this.addr,n)}function IE(e,t){let n=_s(t,this.size,4);e.uniform4fv(this.addr,n)}function PE(e,t){let n=_s(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function LE(e,t){let n=_s(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function NE(e,t){let n=_s(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function DE(e,t){e.uniform1iv(this.addr,t)}function OE(e,t){e.uniform2iv(this.addr,t)}function UE(e,t){e.uniform3iv(this.addr,t)}function FE(e,t){e.uniform4iv(this.addr,t)}function zE(e,t){e.uniform1uiv(this.addr,t)}function kE(e,t){e.uniform2uiv(this.addr,t)}function BE(e,t){e.uniform3uiv(this.addr,t)}function GE(e,t){e.uniform4uiv(this.addr,t)}function HE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=zh;else o=xx;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function VE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||yx,s[o])}function WE(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Sx,s[o])}function $E(e,t,n){let i=this.cache,r=t.length,s=bc(n,r);if(!Ot(i,s))e.uniform1iv(this.addr,s),Ut(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||vx,s[o])}function ZE(e){switch(e){case 5126:return AE;case 35664:return RE;case 35665:return CE;case 35666:return IE;case 35674:return PE;case 35675:return LE;case 35676:return NE;case 5124:case 35670:return DE;case 35667:case 35671:return OE;case 35668:case 35672:return UE;case 35669:case 35673:return FE;case 5125:return zE;case 36294:return kE;case 36295:return BE;case 36296:return GE;case 35678:case 36198:case 36298:case 36306:case 35682:return HE;case 35679:case 36299:case 36307:return VE;case 35680:case 36300:case 36308:case 36293:return WE;case 36289:case 36303:case 36311:case 36292:return $E}}class bx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=EE(t.type)}}class Mx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=ZE(t.type)}}class wx{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 Uh=/(\w+)(\])?(\[|\.)?/g;function rx(e,t){e.seq.push(t),e.map[t.id]=t}function XE(e,t,n){let i=e.name,r=i.length;Uh.lastIndex=0;while(!0){let s=Uh.exec(i),o=Uh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){rx(n,l===void 0?new bx(a,e,t):new Mx(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new wx(a),rx(n,f);n=f}}}class Mo{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);XE(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 sx(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var qE=37297,YE=0;function jE(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 ix=new ze;function qE(e){$e._getMatrix(ix,$e.workingColorSpace,e);let t=`mat3( ${ix.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case sh:return[t,"LinearTransferOETF"];case ft:return[t,"sRGBTransferOETF"];default:return Ce("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function rx(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 ox=new ze;function KE(e){$e._getMatrix(ox,$e.workingColorSpace,e);let t=`mat3( ${ox.elements.map((n)=>n.toFixed(4))} )`;switch($e.getTransfer(e)){case ah:return[t,"LinearTransferOETF"];case ft:return[t,"sRGBTransferOETF"];default:return Ce("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function ax(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+`
-`+XE(e.getShaderSource(t),a)}else return s}function YE(e,t){let n=qE(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var jE={[pu]:"Linear",[mu]:"Reinhard",[gu]:"Cineon",[eo]:"ACESFilmic",[xu]:"AgX",[vu]:"Neutral",[_u]:"Custom"};function KE(e,t){let n=jE[t];if(n===void 0)return Ce("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var yc=new U;function JE(){$e.getLuminanceCoefficients(yc);let e=yc.x.toFixed(4),t=yc.y.toFixed(4),n=yc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function QE(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(bo).join(`
-`)}function eA(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 tA(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 bo(e){return e!==""}function sx(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 ox(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var nA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fh(e){return e.replace(nA,rA)}var iA=new Map;function rA(e,t){let n=We[t];if(n===void 0){let i=iA.get(t);if(i!==void 0)n=We[i],Ce('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Fh(n)}var sA=/#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 ax(e){return e.replace(sA,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 cx(e){let t=`precision ${e.precision} float;
+`+jE(e.getShaderSource(t),a)}else return s}function JE(e,t){let n=KE(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var QE={[gu]:"Linear",[_u]:"Reinhard",[xu]:"Cineon",[eo]:"ACESFilmic",[yu]:"AgX",[Su]:"Neutral",[vu]:"Custom"};function eA(e,t){let n=QE[t];if(n===void 0)return Ce("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var yc=new U;function tA(){$e.getLuminanceCoefficients(yc);let e=yc.x.toFixed(4),t=yc.y.toFixed(4),n=yc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function nA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(bo).join(`
+`)}function iA(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 rA(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 bo(e){return e!==""}function cx(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 lx(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var sA=/^[ \t]*#include +<([\w\d./]+)>/gm;function kh(e){return e.replace(sA,aA)}var oA=new Map;function aA(e,t){let n=We[t];if(n===void 0){let i=oA.get(t);if(i!==void 0)n=We[i],Ce('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return kh(n)}var cA=/#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 ux(e){return e.replace(cA,lA)}function lA(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 hx(e){let t=`precision ${e.precision} float;
precision ${e.precision} int;
precision ${e.precision} sampler2D;
precision ${e.precision} samplerCube;
@@ -4206,30 +4206,30 @@ void main() {
`;if(e.precision==="highp")t+=`
#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
-#define LOW_PRECISION`;return t}var aA={[Js]:"SHADOWMAP_TYPE_PCF",[es]:"SHADOWMAP_TYPE_VSM"};function cA(e){return aA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var lA={[ns]:"ENVMAP_TYPE_CUBE",[mr]:"ENVMAP_TYPE_CUBE",[to]:"ENVMAP_TYPE_CUBE_UV"};function uA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return lA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var hA={[mr]:"ENVMAP_MODE_REFRACTION"};function fA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return hA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var dA={[g0]:"ENVMAP_BLENDING_MULTIPLY",[_0]:"ENVMAP_BLENDING_MIX",[x0]:"ENVMAP_BLENDING_ADD"};function pA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return dA[e.combine]||"ENVMAP_BLENDING_NONE"}function mA(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 gA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=cA(n),l=uA(n),u=fA(n),f=pA(n),h=mA(n),d=QE(n),g=eA(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
+#define LOW_PRECISION`;return t}var uA={[Js]:"SHADOWMAP_TYPE_PCF",[es]:"SHADOWMAP_TYPE_VSM"};function hA(e){return uA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var fA={[ns]:"ENVMAP_TYPE_CUBE",[mr]:"ENVMAP_TYPE_CUBE",[to]:"ENVMAP_TYPE_CUBE_UV"};function dA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return fA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var pA={[mr]:"ENVMAP_MODE_REFRACTION"};function mA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return pA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var gA={[v0]:"ENVMAP_BLENDING_MULTIPLY",[y0]:"ENVMAP_BLENDING_MIX",[S0]:"ENVMAP_BLENDING_ADD"};function _A(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return gA[e.combine]||"ENVMAP_BLENDING_NONE"}function xA(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 vA(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=hA(n),l=dA(n),u=mA(n),f=_A(n),h=xA(n),d=nA(n),g=iA(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(bo).join(`
`),p.length>0)p+=`
`;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(bo).join(`
`),m.length>0)m+=`
-`}else p=[cx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
+`}else p=[hx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
`].filter(bo).join(`
-`),m=[cx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==kn?"#define TONE_MAPPING":"",n.toneMapping!==kn?We.tonemapping_pars_fragment:"",n.toneMapping!==kn?KE("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,YE("linearToOutputTexel",n.outputColorSpace),JE(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`),m=[hx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==kn?"#define TONE_MAPPING":"",n.toneMapping!==kn?We.tonemapping_pars_fragment:"",n.toneMapping!==kn?eA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",We.colorspace_pars_fragment,JE("linearToOutputTexel",n.outputColorSpace),tA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(bo).join(`
-`);if(o=Fh(o),o=sx(o,n),o=ox(o,n),a=Fh(a),a=sx(a,n),a=ox(a,n),o=ax(o),a=ax(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
+`);if(o=kh(o),o=cx(o,n),o=lx(o,n),a=kh(a),a=cx(a,n),a=lx(a,n),o=ux(o),a=ux(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
`,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+p,m=["#define varying in",n.glslVersion===oh?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===oh?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+p,m=["#define varying in",n.glslVersion===ch?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ch?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+m;let R=E+p+o,S=E+m+a,b=nx(r,r.VERTEX_SHADER,R),T=nx(r,r.FRAGMENT_SHADER,S);if(r.attachShader(x,b),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(I){if(e.debug.checkShaderErrors){let O=r.getProgramInfoLog(x)||"",K=r.getShaderInfoLog(b)||"",C=r.getShaderInfoLog(T)||"",G=O.trim(),X=K.trim(),z=C.trim(),te=!0,H=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(te=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,b,T);else{let Q=rx(r,b,"vertex"),ee=rx(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
+`+m;let R=E+p+o,S=E+m+a,b=sx(r,r.VERTEX_SHADER,R),T=sx(r,r.FRAGMENT_SHADER,S);if(r.attachShader(x,b),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(I){if(e.debug.checkShaderErrors){let O=r.getProgramInfoLog(x)||"",K=r.getShaderInfoLog(b)||"",C=r.getShaderInfoLog(T)||"",G=O.trim(),X=K.trim(),z=C.trim(),te=!0,H=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(te=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,b,T);else{let Q=ax(r,b,"vertex"),ee=ax(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
Material Name: `+I.name+`
Material Type: `+I.type+`
Program Info Log: `+G+`
`+Q+`
-`+ee)}else if(G!=="")Ce("WebGLProgram: Program Info Log:",G);else if(X===""||z==="")H=!1;if(H)I.diagnostics={runnable:te,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(b),r.deleteShader(T),_=new Mo(r,x),M=tA(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let F=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(F===!1)F=r.getProgramParameter(x,$E);return F},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ZE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=T,this}var _A=0;class bx{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 Mx(e),t.set(e,n);return n}}class Mx{constructor(e){this.id=_A++,this.code=e,this.usedTimes=0}}function xA(e){return e===vr||e===Ya||e===ja}function vA(e,t,n,i,r,s){let o=new tc,a=new bx,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,M,F,I,O,K){let C=I.fog,G=O.geometry,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?I.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,te=t.get(_.envMap||X,z),H=!!te&&te.mapping===to?te.image.height:null,Q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Ce("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Te=ee!==void 0?ee.length:0,ve=0;if(G.morphAttributes.position!==void 0)ve=1;if(G.morphAttributes.normal!==void 0)ve=2;if(G.morphAttributes.color!==void 0)ve=3;let He,Me,Z,re;if(Q){let dt=ci[Q];He=dt.vertexShader,Me=dt.fragmentShader}else{He=_.vertexShader,Me=_.fragmentShader;let dt=a.getVertexShaderStage(_),it=a.getFragmentShaderStage(_);a.update(_,dt,it),Z=dt.id,re=it.id}let se=e.getRenderTarget(),Ie=e.state.buffers.depth.getReversed(),Pe=O.isInstancedMesh===!0,we=O.isBatchedMesh===!0,gt=!!_.map,ke=!!_.matcap,Xe=!!te,st=!!_.aoMap,Ke=!!_.lightMap,Ht=!!_.bumpMap&&_.wireframe===!1,_t=!!_.normalMap,rn=!!_.displacementMap,Lt=!!_.emissiveMap,Nt=!!_.metalnessMap,L=!!_.roughnessMap,sn=_.anisotropy>0,nt=_.clearcoat>0,bt=_.dispersion>0,w=_.retroreflectivity>0,v=_.iridescence>0,P=_.sheen>0,V=_.transmission>0,ie=sn&&!!_.anisotropyMap,ae=nt&&!!_.clearcoatMap,ue=nt&&!!_.clearcoatNormalMap,q=nt&&!!_.clearcoatRoughnessMap,J=v&&!!_.iridescenceMap,ge=v&&!!_.iridescenceThicknessMap,Ae=P&&!!_.sheenColorMap,he=P&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Qe=V&&!!_.transmissionMap,D=V&&!!_.thicknessMap,ce=!!_.gradientMap,Y=!!_.alphaMap,le=_.alphaTest>0,_e=!!_.alphaHash,ne=!!_.extensions,de=kn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)de=e.toneMapping}let Be={shaderID:Q,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:we,batchingColor:we&&O._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&O.instanceColor!==null,instancingMorph:Pe&&O.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:gt,matcap:ke,envMap:Xe,envMapMode:Xe&&te.mapping,envMapCubeUVHeight:H,aoMap:st,lightMap:Ke,bumpMap:Ht,normalMap:_t,displacementMap:rn,emissiveMap:Lt,normalMapObjectSpace:_t&&_.normalMapType===E0,normalMapTangentSpace:_t&&_.normalMapType===rh,packedNormalMap:_t&&_.normalMapType===rh&&xA(_.normalMap.format),metalnessMap:Nt,roughnessMap:L,anisotropy:sn,anisotropyMap:ie,clearcoat:nt,clearcoatMap:ae,clearcoatNormalMap:ue,clearcoatRoughnessMap:q,dispersion:bt,retroreflection:w,iridescence:v,iridescenceMap:J,iridescenceThicknessMap:ge,sheen:P,sheenColorMap:Ae,sheenRoughnessMap:he,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Qe,thicknessMap:D,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Qs&&_.alphaToCoverage===!1,alphaMap:Y,alphaTest:le,alphaHash:_e,combine:_.combine,mapUv:gt&&g(_.map.channel),aoMapUv:st&&g(_.aoMap.channel),lightMapUv:Ke&&g(_.lightMap.channel),bumpMapUv:Ht&&g(_.bumpMap.channel),normalMapUv:_t&&g(_.normalMap.channel),displacementMapUv:rn&&g(_.displacementMap.channel),emissiveMapUv:Lt&&g(_.emissiveMap.channel),metalnessMapUv:Nt&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ue&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:q&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:he&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Qe&&g(_.transmissionMap.channel),thicknessMapUv:D&&g(_.thicknessMap.channel),alphaMapUv:Y&&g(_.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(_t||sn),vertexNormals:!!G.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!G.attributes.uv&&(gt||Y),fog:!!C,useFog:_.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||G.attributes.normal===void 0&&_t===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ie,skinning:O.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:Te,morphTextureStride:ve,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:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:de,decodeVideoTexture:gt&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===ft,decodeVideoTextureEmissive:Lt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===ft,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===An,flipSided:_.side===Yt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||we)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let F in _.defines)M.push(F),M.push(_.defines[F]);if(_.isRawShaderMaterial===!1)m(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function m(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,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(_.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);_.push(o.mask)}function R(_){let M=d[_.type],F;if(M){let I=ci[M];F=z0.clone(I.uniforms)}else F=_.uniforms;return F}function S(_,M){let F=u.get(M);if(F!==void 0)++F.usedTimes;else F=new gA(e,M,_,r),l.push(F),u.set(M,F);return F}function b(_){if(--_.usedTimes===0){let M=l.indexOf(_);l[M]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:S,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:A}}function yA(){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 SA(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 lx(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 ux(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||SA);if(i.length>1)i.sort(d||lx);if(r.length>1)r.sort(d||lx)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function bA(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new ux,e.set(i,[o]);else if(r>=s.length)o=new ux,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function MA(){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 Oe};break;case"SpotLight":n={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function wA(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var TA=0;function EA(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function AA(e){let t=new MA,n=wA(),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 Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,S=0,b=0,T=0,A=0,_=0,M=0,F=0;l.sort(EA);for(let O=0,K=l.length;O<K;O++){let C=l[O],{color:G,intensity:X,distance:z}=C,te=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===vr)te=C.shadow.map.texture;else te=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=G.r*X,f+=G.g*X,h+=G.b*X;else if(C.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(C.sh.coefficients[H],X);F++}else if(C.isSunLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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[g]=ee,i.sunShadowMap[g]=te;let Te=Q.getViewportCount();for(let ve=0;ve<Te;ve++)i.sunShadowMatrix[x+ve]=Q.getMatrix(ve),i.sunShadowCascade[x+ve]=Q._cascadeData[ve];x+=Te,g++}i.sun[d]=H,d++}else if(C.isDirectionalLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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]=te,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=H,p++}else if(C.isSpotLight){let H=t.get(C);H.position.setFromMatrixPosition(C.matrixWorld),H.color.copy(G).multiplyScalar(X),H.distance=z,H.coneCos=Math.cos(C.angle),H.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),H.decay=C.decay,i.spot[E]=H;let Q=C.shadow;if(C.map){if(i.spotLightMap[_]=C.map,_++,Q.updateMatrices(C),C.castShadow)M++}if(i.spotLightMatrix[E]=Q.matrix,C.castShadow){let ee=n.get(C);ee.shadowIntensity=Q.intensity,ee.shadowBias=Q.bias,ee.shadowNormalBias=Q.normalBias,ee.shadowRadius=Q.radius,ee.shadowMapSize=Q.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=te,A++}E++}else if(C.isRectAreaLight){let H=t.get(C);H.color.copy(G).multiplyScalar(X),H.halfWidth.set(C.width*0.5,0,0),H.halfHeight.set(0,C.height*0.5,0),i.rectArea[R]=H,R++}else if(C.isPointLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),H.distance=C.distance,H.decay=C.decay,C.castShadow){let Q=C.shadow,ee=n.get(C);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[m]=ee,i.pointShadowMap[m]=te,i.pointShadowMatrix[m]=C.shadow.matrix,T++}i.point[m]=H,m++}else if(C.isHemisphereLight){let H=t.get(C);H.skyColor.copy(C.color).multiplyScalar(X),H.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[S]=H,S++}}if(R>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]=f,i.ambient[2]=h;let I=i.hash;if(I.sunLength!==d||I.directionalLength!==p||I.pointLength!==m||I.spotLength!==E||I.rectAreaLength!==R||I.hemiLength!==S||I.numSunShadows!==g||I.numDirectionalShadows!==b||I.numPointShadows!==T||I.numSpotShadows!==A||I.numSpotMaps!==_||I.numLightProbes!==F)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=S,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=F,I.sunLength=d,I.directionalLength=p,I.pointLength=m,I.spotLength=E,I.rectAreaLength=R,I.hemiLength=S,I.numSunShadows=g,I.numDirectionalShadows=b,I.numPointShadows=T,I.numSpotShadows=A,I.numSpotMaps=_,I.numLightProbes=F,i.version=TA++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let S=l[E];if(S.isSunLight){let b=i.sun[f];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),f++}else if(S.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),h++}else if(S.isSpotLight){let b=i.spot[g];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),g++}else if(S.isRectAreaLight){let b=i.rectArea[x];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),o.identity(),s.copy(S.matrixWorld),s.premultiply(m),o.extractRotation(s),b.halfWidth.set(S.width*0.5,0,0),b.halfHeight.set(0,S.height*0.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let b=i.point[d];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),d++}else if(S.isHemisphereLight){let b=i.hemi[p];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function hx(e){let t=new AA(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function RA(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new hx(e),t.set(r,[a]);else if(s>=o.length)a=new hx(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var CA=`void main() {
+`+ee)}else if(G!=="")Ce("WebGLProgram: Program Info Log:",G);else if(X===""||z==="")H=!1;if(H)I.diagnostics={runnable:te,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(b),r.deleteShader(T),_=new Mo(r,x),M=rA(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let F=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(F===!1)F=r.getProgramParameter(x,qE);return F},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=YE++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=T,this}var yA=0;class Tx{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 Ex(e),t.set(e,n);return n}}class Ex{constructor(e){this.id=yA++,this.code=e,this.usedTimes=0}}function SA(e){return e===vr||e===Ya||e===ja}function bA(e,t,n,i,r,s){let o=new tc,a=new Tx,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,M,F,I,O,K){let C=I.fog,G=O.geometry,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?I.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,te=t.get(_.envMap||X,z),H=!!te&&te.mapping===to?te.image.height:null,Q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Ce("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Te=ee!==void 0?ee.length:0,ve=0;if(G.morphAttributes.position!==void 0)ve=1;if(G.morphAttributes.normal!==void 0)ve=2;if(G.morphAttributes.color!==void 0)ve=3;let He,Me,Z,re;if(Q){let dt=ci[Q];He=dt.vertexShader,Me=dt.fragmentShader}else{He=_.vertexShader,Me=_.fragmentShader;let dt=a.getVertexShaderStage(_),it=a.getFragmentShaderStage(_);a.update(_,dt,it),Z=dt.id,re=it.id}let se=e.getRenderTarget(),Ie=e.state.buffers.depth.getReversed(),Pe=O.isInstancedMesh===!0,we=O.isBatchedMesh===!0,gt=!!_.map,ke=!!_.matcap,Xe=!!te,st=!!_.aoMap,Ke=!!_.lightMap,Ht=!!_.bumpMap&&_.wireframe===!1,_t=!!_.normalMap,rn=!!_.displacementMap,Lt=!!_.emissiveMap,Nt=!!_.metalnessMap,L=!!_.roughnessMap,sn=_.anisotropy>0,nt=_.clearcoat>0,bt=_.dispersion>0,w=_.retroreflectivity>0,v=_.iridescence>0,P=_.sheen>0,V=_.transmission>0,ie=sn&&!!_.anisotropyMap,ae=nt&&!!_.clearcoatMap,ue=nt&&!!_.clearcoatNormalMap,q=nt&&!!_.clearcoatRoughnessMap,J=v&&!!_.iridescenceMap,ge=v&&!!_.iridescenceThicknessMap,Ae=P&&!!_.sheenColorMap,he=P&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Qe=V&&!!_.transmissionMap,D=V&&!!_.thicknessMap,ce=!!_.gradientMap,Y=!!_.alphaMap,le=_.alphaTest>0,_e=!!_.alphaHash,ne=!!_.extensions,de=kn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)de=e.toneMapping}let Be={shaderID:Q,shaderType:_.type,shaderName:_.name,vertexShader:He,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:we,batchingColor:we&&O._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&O.instanceColor!==null,instancingMorph:Pe&&O.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:$e.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:gt,matcap:ke,envMap:Xe,envMapMode:Xe&&te.mapping,envMapCubeUVHeight:H,aoMap:st,lightMap:Ke,bumpMap:Ht,normalMap:_t,displacementMap:rn,emissiveMap:Lt,normalMapObjectSpace:_t&&_.normalMapType===C0,normalMapTangentSpace:_t&&_.normalMapType===oh,packedNormalMap:_t&&_.normalMapType===oh&&SA(_.normalMap.format),metalnessMap:Nt,roughnessMap:L,anisotropy:sn,anisotropyMap:ie,clearcoat:nt,clearcoatMap:ae,clearcoatNormalMap:ue,clearcoatRoughnessMap:q,dispersion:bt,retroreflection:w,iridescence:v,iridescenceMap:J,iridescenceThicknessMap:ge,sheen:P,sheenColorMap:Ae,sheenRoughnessMap:he,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Qe,thicknessMap:D,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Qs&&_.alphaToCoverage===!1,alphaMap:Y,alphaTest:le,alphaHash:_e,combine:_.combine,mapUv:gt&&g(_.map.channel),aoMapUv:st&&g(_.aoMap.channel),lightMapUv:Ke&&g(_.lightMap.channel),bumpMapUv:Ht&&g(_.bumpMap.channel),normalMapUv:_t&&g(_.normalMap.channel),displacementMapUv:rn&&g(_.displacementMap.channel),emissiveMapUv:Lt&&g(_.emissiveMap.channel),metalnessMapUv:Nt&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ue&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:q&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:he&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Qe&&g(_.transmissionMap.channel),thicknessMapUv:D&&g(_.thicknessMap.channel),alphaMapUv:Y&&g(_.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(_t||sn),vertexNormals:!!G.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!G.attributes.uv&&(gt||Y),fog:!!C,useFog:_.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||G.attributes.normal===void 0&&_t===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ie,skinning:O.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:Te,morphTextureStride:ve,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:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:de,decodeVideoTexture:gt&&_.map.isVideoTexture===!0&&$e.getTransfer(_.map.colorSpace)===ft,decodeVideoTextureEmissive:Lt&&_.emissiveMap.isVideoTexture===!0&&$e.getTransfer(_.emissiveMap.colorSpace)===ft,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===An,flipSided:_.side===Yt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||we)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Be.vertexUv1s=c.has(1),Be.vertexUv2s=c.has(2),Be.vertexUv3s=c.has(3),c.clear(),Be}function p(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let F in _.defines)M.push(F),M.push(_.defines[F]);if(_.isRawShaderMaterial===!1)m(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function m(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,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(_.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);_.push(o.mask)}function R(_){let M=d[_.type],F;if(M){let I=ci[M];F=G0.clone(I.uniforms)}else F=_.uniforms;return F}function S(_,M){let F=u.get(M);if(F!==void 0)++F.usedTimes;else F=new vA(e,M,_,r),l.push(F),u.set(M,F);return F}function b(_){if(--_.usedTimes===0){let M=l.indexOf(_);l[M]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:S,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:A}}function MA(){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 wA(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 fx(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 dx(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||wA);if(i.length>1)i.sort(d||fx);if(r.length>1)r.sort(d||fx)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function TA(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new dx,e.set(i,[o]);else if(r>=s.length)o=new dx,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function EA(){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 Oe};break;case"SpotLight":n={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function AA(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var RA=0;function CA(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function IA(e){let t=new EA,n=AA(),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 Ge,o=new Ge;function a(l){let u=0,f=0,h=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,S=0,b=0,T=0,A=0,_=0,M=0,F=0;l.sort(CA);for(let O=0,K=l.length;O<K;O++){let C=l[O],{color:G,intensity:X,distance:z}=C,te=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===vr)te=C.shadow.map.texture;else te=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=G.r*X,f+=G.g*X,h+=G.b*X;else if(C.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(C.sh.coefficients[H],X);F++}else if(C.isSunLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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[g]=ee,i.sunShadowMap[g]=te;let Te=Q.getViewportCount();for(let ve=0;ve<Te;ve++)i.sunShadowMatrix[x+ve]=Q.getMatrix(ve),i.sunShadowCascade[x+ve]=Q._cascadeData[ve];x+=Te,g++}i.sun[d]=H,d++}else if(C.isDirectionalLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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]=te,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=H,p++}else if(C.isSpotLight){let H=t.get(C);H.position.setFromMatrixPosition(C.matrixWorld),H.color.copy(G).multiplyScalar(X),H.distance=z,H.coneCos=Math.cos(C.angle),H.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),H.decay=C.decay,i.spot[E]=H;let Q=C.shadow;if(C.map){if(i.spotLightMap[_]=C.map,_++,Q.updateMatrices(C),C.castShadow)M++}if(i.spotLightMatrix[E]=Q.matrix,C.castShadow){let ee=n.get(C);ee.shadowIntensity=Q.intensity,ee.shadowBias=Q.bias,ee.shadowNormalBias=Q.normalBias,ee.shadowRadius=Q.radius,ee.shadowMapSize=Q.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=te,A++}E++}else if(C.isRectAreaLight){let H=t.get(C);H.color.copy(G).multiplyScalar(X),H.halfWidth.set(C.width*0.5,0,0),H.halfHeight.set(0,C.height*0.5,0),i.rectArea[R]=H,R++}else if(C.isPointLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),H.distance=C.distance,H.decay=C.decay,C.castShadow){let Q=C.shadow,ee=n.get(C);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[m]=ee,i.pointShadowMap[m]=te,i.pointShadowMatrix[m]=C.shadow.matrix,T++}i.point[m]=H,m++}else if(C.isHemisphereLight){let H=t.get(C);H.skyColor.copy(C.color).multiplyScalar(X),H.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[S]=H,S++}}if(R>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]=f,i.ambient[2]=h;let I=i.hash;if(I.sunLength!==d||I.directionalLength!==p||I.pointLength!==m||I.spotLength!==E||I.rectAreaLength!==R||I.hemiLength!==S||I.numSunShadows!==g||I.numDirectionalShadows!==b||I.numPointShadows!==T||I.numSpotShadows!==A||I.numSpotMaps!==_||I.numLightProbes!==F)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=S,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=F,I.sunLength=d,I.directionalLength=p,I.pointLength=m,I.spotLength=E,I.rectAreaLength=R,I.hemiLength=S,I.numSunShadows=g,I.numDirectionalShadows=b,I.numPointShadows=T,I.numSpotShadows=A,I.numSpotMaps=_,I.numLightProbes=F,i.version=RA++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let S=l[E];if(S.isSunLight){let b=i.sun[f];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),f++}else if(S.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),h++}else if(S.isSpotLight){let b=i.spot[g];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),g++}else if(S.isRectAreaLight){let b=i.rectArea[x];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),o.identity(),s.copy(S.matrixWorld),s.premultiply(m),o.extractRotation(s),b.halfWidth.set(S.width*0.5,0,0),b.halfHeight.set(0,S.height*0.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let b=i.point[d];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),d++}else if(S.isHemisphereLight){let b=i.hemi[p];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function px(e){let t=new IA(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function PA(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new px(e),t.set(r,[a]);else if(s>=o.length)a=new px(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var LA=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,IA=`uniform sampler2D shadow_pass;
+}`,NA=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
@@ -4254,12 +4254,12 @@ void main() {
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
-}`,PA=[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)],LA=[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)],fx=new Ge,So=new U,Oh=new U;function NA(e,t,n){let i=new ho,r=new Ne,s=new Ne,o=new at,a=new mh,c=new gh,l={},u=n.maxTextureSize,f={[Wi]:Yt,[Yt]:Wi,[An]:An},h=new Rn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:CA,fragmentShader:IA}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new jt;g.setAttribute("position",new Bt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new mt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Js;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===H_)Ce("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Js;let M=e.getRenderTarget(),F=e.getActiveCubeFace(),I=e.getActiveMipmapLevel(),O=e.state;if(O.setBlending(ni),O.buffers.depth.getReversed()===!0)O.buffers.color.setClear(0,0,0,0);else O.buffers.color.setClear(1,1,1,1);O.buffers.depth.setTest(!0),O.setScissorTest(!1);let K=m!==this.type;if(K)A.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((G)=>G.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,G=T.length;C<G;C++){let X=T[C],z=X.shadow;if(z===void 0){Ce("WebGLShadowMap:",X,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let te=z.getFrameExtents();if(r.multiply(te),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/te.x),r.x=s.x*te.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/te.y),r.y=s.y*te.y,z.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=H,z.map===null||K===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===es){if(X.isPointLight){Ce("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new _n(r.x,r.y,{format:vr,type:ri,minFilter:Gt,magFilter:Gt,generateMipmaps:!1}),z.map.texture.name=X.name+".shadowMap",z.map.depthTexture=new Sr(r.x,r.y,Mi),z.map.depthTexture.name=X.name+".shadowMapDepth",z.map.depthTexture.format=_r,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Bn,z.map.depthTexture.magFilter=Bn}else{if(X.isPointLight)z.map=new zh(r.x),z.map.depthTexture=new fh(r.x,$i);else z.map=new _n(r.x,r.y),z.map.depthTexture=new Sr(r.x,r.y,$i);if(z.map.depthTexture.name=X.name+".shadowMap",z.map.depthTexture.format=_r,this.type===Js)z.map.depthTexture.compareFunction=H?Qa:Ja,z.map.depthTexture.minFilter=Gt,z.map.depthTexture.magFilter=Gt;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Bn,z.map.depthTexture.magFilter=Bn}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let Q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(X.isPointLight!==!0)z.updateMatrices(X,_);for(let ee=0;ee<Q;ee++){let Te=z.getCamera(ee);if(X.isPointLight){let{camera:ve,matrix:He}=z,Me=X.distance||ve.far;if(Me!==ve.far)ve.far=Me,ve.updateProjectionMatrix();So.setFromMatrixPosition(X.matrixWorld),ve.position.copy(So),Oh.copy(ve.position),Oh.add(PA[ee]),ve.up.copy(LA[ee]),ve.lookAt(Oh),ve.updateMatrixWorld(),He.makeTranslation(-So.x,-So.y,-So.z),fx.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),z._frustum.setFromProjectionMatrix(fx,ve.coordinateSystem,ve.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(z.map),e.clear();let ve=z.getViewport(ee);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),O.viewport(o)}i=z.getFrustum(ee),S(A,_,Te,X,this.type)}if(z.isPointLightShadow!==!0&&this.type===es)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(M,F,I)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:vr,type:ri});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,M){let F=null,I=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(I!==void 0)F=I;else if(F=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let O=F.uuid,K=A.uuid,C=l[O];if(C===void 0)C={},l[O]=C;let G=C[K];if(G===void 0)G=F.clone(),C[K]=G,A.addEventListener("dispose",b);F=G}if(F.visible=A.visible,F.wireframe=A.wireframe,M===es)F.side=A.shadowSide!==null?A.shadowSide:A.side;else F.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(F.alphaMap=A.alphaMap,F.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,F.map=A.map,F.clipShadows=A.clipShadows,F.clippingPlanes=A.clippingPlanes,F.clipIntersection=A.clipIntersection,F.displacementMap=A.displacementMap,F.displacementScale=A.displacementScale,F.displacementBias=A.displacementBias,F.wireframeLinewidth=A.wireframeLinewidth,F.linewidth=A.linewidth,_.isPointLight===!0&&F.isMeshDistanceMaterial===!0){let O=e.properties.get(F);O.light=_}return F}function S(T,A,_,M,F){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&F===es)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let K=t.update(T),C=T.material;if(Array.isArray(C)){let G=K.groups;for(let X=0,z=G.length;X<z;X++){let te=G[X],H=C[te.materialIndex];if(H&&H.visible){let Q=R(T,H,M,F);T.onBeforeShadow(e,T,A,_,K,Q,te),e.renderBufferDirect(_,null,K,Q,T,te),T.onAfterShadow(e,T,A,_,K,Q,te)}}}else if(C.visible){let G=R(T,C,M,F);T.onBeforeShadow(e,T,A,_,K,G,null),e.renderBufferDirect(_,null,K,G,T,null),T.onAfterShadow(e,T,A,_,K,G,null)}}}let O=T.children;for(let K=0,C=O.length;K<C;K++)S(O[K],A,_,M,F)}function b(T){T.target.removeEventListener("dispose",b);for(let _ in l){let M=l[_],F=T.target.uuid;if(F in M)M[F].dispose(),delete M[F]}}}function DA(e,t){function n(){let D=!1,ce=new at,Y=null,le=new at(0,0,0,0);return{setMask:function(_e){if(Y!==_e&&!D)e.colorMask(_e,_e,_e,_e),Y=_e},setLocked:function(_e){D=_e},setClear:function(_e,ne,de,Be,dt){if(dt===!0)_e*=Be,ne*=Be,de*=Be;if(ce.set(_e,ne,de,Be),le.equals(ce)===!1)e.clearColor(_e,ne,de,Be),le.copy(ce)},reset:function(){D=!1,Y=null,le.set(-1,0,0,0)}}}function i(){let D=!1,ce=!1,Y=null,le=null,_e=null;return{setReversed:function(ne){if(ce!==ne){let de=t.get("EXT_clip_control");if(ne)de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT);else de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let Be=_e;_e=null,this.setClear(Be)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Ie(e.DEPTH_TEST)},setMask:function(ne){if(Y!==ne&&!D)e.depthMask(ne),Y=ne},setFunc:function(ne){if(ce)ne=U0[ne];if(le!==ne){switch(ne){case l0:e.depthFunc(e.NEVER);break;case u0:e.depthFunc(e.ALWAYS);break;case h0:e.depthFunc(e.LESS);break;case du:e.depthFunc(e.LEQUAL);break;case f0:e.depthFunc(e.EQUAL);break;case d0:e.depthFunc(e.GEQUAL);break;case p0:e.depthFunc(e.GREATER);break;case m0:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){D=ne},setClear:function(ne){if(_e!==ne){if(_e=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){D=!1,Y=null,le=null,_e=null,ce=!1}}}function r(){let D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,Be=null,dt=null;return{setTest:function(it){if(!D)if(it)se(e.STENCIL_TEST);else Ie(e.STENCIL_TEST)},setMask:function(it){if(ce!==it&&!D)e.stencilMask(it),ce=it},setFunc:function(it,Vn,ui){if(Y!==it||le!==Vn||_e!==ui)e.stencilFunc(it,Vn,ui),Y=it,le=Vn,_e=ui},setOp:function(it,Vn,ui){if(ne!==it||de!==Vn||Be!==ui)e.stencilOp(it,Vn,ui),ne=it,de=Vn,Be=ui},setLocked:function(it){D=it},setClear:function(it){if(dt!==it)e.clearStencil(it),dt=it},reset:function(){D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,Be=null,dt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,I=null,O=null,K=null,C=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)te=parseFloat(/^WebGL (\d)/.exec(H)[1]),z=te>=1;else if(H.indexOf("OpenGL ES")!==-1)te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),z=te>=2;let Q=null,ee={},Te=e.getParameter(e.SCISSOR_BOX),ve=e.getParameter(e.VIEWPORT),He=new at().fromArray(Te),Me=new at().fromArray(ve);function Z(D,ce,Y,le){let _e=new Uint8Array(4),ne=e.createTexture();e.bindTexture(D,ne),e.texParameteri(D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(D,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let de=0;de<Y;de++)if(D===e.TEXTURE_3D||D===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,_e);else e.texImage2D(ce+de,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,_e);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(du),Ht(!1),_t(lu),se(e.CULL_FACE),st(ni);function se(D){if(u[D]!==!0)e.enable(D),u[D]=!0}function Ie(D){if(u[D]!==!1)e.disable(D),u[D]=!1}function Pe(D,ce){if(h[D]!==ce){if(e.bindFramebuffer(D,ce),h[D]=ce,D===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(D===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function we(D,ce){let Y=g,le=!1;if(D){if(Y=d.get(ce),Y===void 0)Y=[],d.set(ce,Y);let _e=D.textures;if(Y.length!==_e.length||Y[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,de=_e.length;ne<de;ne++)Y[ne]=e.COLOR_ATTACHMENT0+ne;Y.length=_e.length,le=!0}}else if(Y[0]!==e.BACK)Y[0]=e.BACK,le=!0;if(le)e.drawBuffers(Y)}function gt(D){if(x!==D)return e.useProgram(D),x=D,!0;return!1}let ke={[ts]:e.FUNC_ADD,[W_]:e.FUNC_SUBTRACT,[$_]:e.FUNC_REVERSE_SUBTRACT};ke[Z_]=e.MIN,ke[X_]=e.MAX;let Xe={[q_]:e.ZERO,[Y_]:e.ONE,[j_]:e.SRC_COLOR,[J_]:e.SRC_ALPHA,[r0]:e.SRC_ALPHA_SATURATE,[n0]:e.DST_COLOR,[e0]:e.DST_ALPHA,[K_]:e.ONE_MINUS_SRC_COLOR,[Q_]:e.ONE_MINUS_SRC_ALPHA,[i0]:e.ONE_MINUS_DST_COLOR,[t0]:e.ONE_MINUS_DST_ALPHA,[s0]:e.CONSTANT_COLOR,[o0]:e.ONE_MINUS_CONSTANT_COLOR,[a0]:e.CONSTANT_ALPHA,[c0]:e.ONE_MINUS_CONSTANT_ALPHA};function st(D,ce,Y,le,_e,ne,de,Be,dt,it){if(D===ni){if(p===!0)Ie(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(D!==V_){if(D!==m||it!==F){if(E!==ts||b!==ts)e.blendEquation(e.FUNC_ADD),E=ts,b=ts;if(it)switch(D){case Qs:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case uu:e.blendFunc(e.ONE,e.ONE);break;case hu:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case fu:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",D);break}else switch(D){case Qs:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case uu:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case hu:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fu:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",D);break}R=null,S=null,T=null,A=null,_.set(0,0,0),M=0,m=D,F=it}return}if(_e=_e||ce,ne=ne||Y,de=de||le,ce!==E||_e!==b)e.blendEquationSeparate(ke[ce],ke[_e]),E=ce,b=_e;if(Y!==R||le!==S||ne!==T||de!==A)e.blendFuncSeparate(Xe[Y],Xe[le],Xe[ne],Xe[de]),R=Y,S=le,T=ne,A=de;if(Be.equals(_)===!1||dt!==M)e.blendColor(Be.r,Be.g,Be.b,dt),_.copy(Be),M=dt;m=D,F=!1}function Ke(D,ce){D.side===An?Ie(e.CULL_FACE):se(e.CULL_FACE);let Y=D.side===Yt;if(ce)Y=!Y;Ht(Y),D.blending===Qs&&D.transparent===!1?st(ni):st(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);let le=D.stencilWrite;if(a.setTest(le),le)a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass);Lt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Ie(e.SAMPLE_ALPHA_TO_COVERAGE)}function Ht(D){if(I!==D){if(D)e.frontFace(e.CW);else e.frontFace(e.CCW);I=D}}function _t(D){if(D!==B_){if(se(e.CULL_FACE),D!==O)if(D===lu)e.cullFace(e.BACK);else if(D===G_)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Ie(e.CULL_FACE);O=D}function rn(D){if(D!==K){if(z)e.lineWidth(D);K=D}}function Lt(D,ce,Y){if(D){if(se(e.POLYGON_OFFSET_FILL),C!==ce||G!==Y){if(C=ce,G=Y,o.getReversed())ce=-ce;e.polygonOffset(ce,Y)}}else Ie(e.POLYGON_OFFSET_FILL)}function Nt(D){if(D)se(e.SCISSOR_TEST);else Ie(e.SCISSOR_TEST)}function L(D){if(D===void 0)D=e.TEXTURE0+X-1;if(Q!==D)e.activeTexture(D),Q=D}function sn(D,ce,Y){if(Y===void 0)if(Q===null)Y=e.TEXTURE0+X-1;else Y=Q;let le=ee[Y];if(le===void 0)le={type:void 0,texture:void 0},ee[Y]=le;if(le.type!==D||le.texture!==ce){if(Q!==Y)e.activeTexture(Y),Q=Y;e.bindTexture(D,ce||re[D]),le.type=D,le.texture=ce}}function nt(){let D=ee[Q];if(D!==void 0&&D.type!==void 0)e.bindTexture(D.type,null),D.type=void 0,D.texture=void 0}function bt(){try{e.compressedTexImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function v(){try{e.texSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function P(){try{e.texSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ae(){try{e.texStorage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ue(){try{e.texStorage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function q(){try{e.texImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function J(){try{e.texImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ge(D){if(f[D]!==void 0)return f[D];else return e.getParameter(D)}function Ae(D,ce){if(f[D]!==ce)e.pixelStorei(D,ce),f[D]=ce}function he(D){if(He.equals(D)===!1)e.scissor(D.x,D.y,D.z,D.w),He.copy(D)}function oe(D){if(Me.equals(D)===!1)e.viewport(D.x,D.y,D.z,D.w),Me.copy(D)}function Le(D,ce){let Y=l.get(ce);if(Y===void 0)Y=new WeakMap,l.set(ce,Y);let le=Y.get(D);if(le===void 0)le=e.getUniformBlockIndex(ce,D.name),Y.set(D,le)}function De(D,ce){let le=l.get(ce).get(D);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,D.__bindingPointIndex),c.set(ce,le)}function Qe(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Q=null,ee={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,I=null,O=null,K=null,C=null,G=null,He.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:Ie,bindFramebuffer:Pe,drawBuffers:we,useProgram:gt,setBlending:st,setMaterial:Ke,setFlipSided:Ht,setCullFace:_t,setLineWidth:rn,setPolygonOffset:Lt,setScissorTest:Nt,activeTexture:L,bindTexture:sn,unbindTexture:nt,compressedTexImage2D:bt,compressedTexImage3D:w,texImage2D:q,texImage3D:J,pixelStorei:Ae,getParameter:ge,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:ue,texSubImage2D:v,texSubImage3D:P,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:he,viewport:oe,reset:Qe}}function OA(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,v){return g?new OffscreenCanvas(w,v):Kr("canvas")}function p(w,v,P){let V=1,ie=bt(w);if(ie.width>P||ie.height>P)V=P/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),ue=Math.floor(V*ie.height);if(h===void 0)h=x(ae,ue);let q=v?x(ae,ue):h;return q.width=ae,q.height=ue,q.getContext("2d").drawImage(w,0,0,ae,ue),Ce("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+ue+")."),q}else{if("data"in w)Ce("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function S(w,v,P,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Ce("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ue;if(V){if(ue=t.get("EXT_texture_norm16"),!ue)Ce("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let q=v;if(v===e.RED){if(P===e.FLOAT)q=e.R32F;if(P===e.HALF_FLOAT)q=e.R16F;if(P===e.UNSIGNED_BYTE)q=e.R8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.R16_EXT;if(P===e.SHORT&&ue)q=ue.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.R8UI;if(P===e.UNSIGNED_SHORT)q=e.R16UI;if(P===e.UNSIGNED_INT)q=e.R32UI;if(P===e.BYTE)q=e.R8I;if(P===e.SHORT)q=e.R16I;if(P===e.INT)q=e.R32I}if(v===e.RG){if(P===e.FLOAT)q=e.RG32F;if(P===e.HALF_FLOAT)q=e.RG16F;if(P===e.UNSIGNED_BYTE)q=e.RG8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.RG16_EXT;if(P===e.SHORT&&ue)q=ue.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RG8UI;if(P===e.UNSIGNED_SHORT)q=e.RG16UI;if(P===e.UNSIGNED_INT)q=e.RG32UI;if(P===e.BYTE)q=e.RG8I;if(P===e.SHORT)q=e.RG16I;if(P===e.INT)q=e.RG32I}if(v===e.RGB_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RGB8UI;if(P===e.UNSIGNED_SHORT)q=e.RGB16UI;if(P===e.UNSIGNED_INT)q=e.RGB32UI;if(P===e.BYTE)q=e.RGB8I;if(P===e.SHORT)q=e.RGB16I;if(P===e.INT)q=e.RGB32I}if(v===e.RGBA_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RGBA8UI;if(P===e.UNSIGNED_SHORT)q=e.RGBA16UI;if(P===e.UNSIGNED_INT)q=e.RGBA32UI;if(P===e.BYTE)q=e.RGBA8I;if(P===e.SHORT)q=e.RGBA16I;if(P===e.INT)q=e.RGBA32I}if(v===e.RGB){if(P===e.UNSIGNED_SHORT&&ue)q=ue.RGB16_EXT;if(P===e.SHORT&&ue)q=ue.RGB16_SNORM_EXT;if(P===e.UNSIGNED_INT_5_9_9_9_REV)q=e.RGB9_E5;if(P===e.UNSIGNED_INT_10F_11F_11F_REV)q=e.R11F_G11F_B10F}if(v===e.RGBA){let J=ae?sh:$e.getTransfer(ie);if(P===e.FLOAT)q=e.RGBA32F;if(P===e.HALF_FLOAT)q=e.RGBA16F;if(P===e.UNSIGNED_BYTE)q=J===ft?e.SRGB8_ALPHA8:e.RGBA8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.RGBA16_EXT;if(P===e.SHORT&&ue)q=ue.RGBA16_SNORM_EXT;if(P===e.UNSIGNED_SHORT_4_4_4_4)q=e.RGBA4;if(P===e.UNSIGNED_SHORT_5_5_5_1)q=e.RGB5_A1}if(q===e.R16F||q===e.R32F||q===e.RG16F||q===e.RG32F||q===e.RGBA16F||q===e.RGBA32F)t.get("EXT_color_buffer_float");return q}function b(w,v){let P;if(w){if(v===null||v===$i||v===os)P=e.DEPTH24_STENCIL8;else if(v===Mi)P=e.DEPTH32F_STENCIL8;else if(v===no)P=e.DEPTH24_STENCIL8,Ce("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===$i||v===os)P=e.DEPTH_COMPONENT24;else if(v===Mi)P=e.DEPTH_COMPONENT32F;else if(v===no)P=e.DEPTH_COMPONENT16;return P}function T(w,v){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Bn&&w.minFilter!==Gt)return Math.log2(Math.max(v.width,v.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return v.mipmaps.length;else return 1}function A(w){let v=w.target;if(v.removeEventListener("dispose",A),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)f.delete(v)}function _(w){let v=w.target;v.removeEventListener("dispose",_),I(v)}function M(w){let v=i.get(w);if(v.__webglInit===void 0)return;let P=w.source,V=d.get(P);if(V){let ie=V[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)F(w);if(Object.keys(V).length===0)d.delete(P)}i.remove(w)}function F(w){let v=i.get(w);e.deleteTexture(v.__webglTexture);let P=w.source,V=d.get(P);delete V[v.__cacheKey],o.memory.textures--}function I(w){let v=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(v.__webglFramebuffer[V]))for(let ie=0;ie<v.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[V]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[V])}else{if(Array.isArray(v.__webglFramebuffer))for(let V=0;V<v.__webglFramebuffer.length;V++)e.deleteFramebuffer(v.__webglFramebuffer[V]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let V=0;V<v.__webglColorRenderbuffer.length;V++)if(v.__webglColorRenderbuffer[V])e.deleteRenderbuffer(v.__webglColorRenderbuffer[V])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let P=w.textures;for(let V=0,ie=P.length;V<ie;V++){let ae=i.get(P[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(P[V])}i.remove(w)}let O=0;function K(){O=0}function C(){return O}function G(w){O=w}function X(){let w=O;if(w>=r.maxTextures)Ce("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return O+=1,w}function z(w){let v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function te(w,v){let P=i.get(w);if(w.isVideoTexture)sn(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&P.__version!==w.version){let V=w.image;if(V===null)Ce("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ce("WebGLRenderer: Texture marked for update but image is incomplete");else{Ie(P,w,v);return}}else if(w.isExternalTexture)P.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,P.__webglTexture,e.TEXTURE0+v)}function H(w,v){let P=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&P.__version!==w.version){Ie(P,w,v);return}else if(w.isExternalTexture)P.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,P.__webglTexture,e.TEXTURE0+v)}function Q(w,v){let P=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&P.__version!==w.version){Ie(P,w,v);return}n.bindTexture(e.TEXTURE_3D,P.__webglTexture,e.TEXTURE0+v)}function ee(w,v){let P=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&P.__version!==w.version){Pe(P,w,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,P.__webglTexture,e.TEXTURE0+v)}let Te={[is]:e.REPEAT,[rs]:e.CLAMP_TO_EDGE,[Va]:e.MIRRORED_REPEAT},ve={[Bn]:e.NEAREST,[Wa]:e.NEAREST_MIPMAP_NEAREST,[gr]:e.NEAREST_MIPMAP_LINEAR,[Gt]:e.LINEAR,[ss]:e.LINEAR_MIPMAP_NEAREST,[ii]:e.LINEAR_MIPMAP_LINEAR},He={[A0]:e.NEVER,[L0]:e.ALWAYS,[R0]:e.LESS,[Ja]:e.LEQUAL,[C0]:e.EQUAL,[Qa]:e.GEQUAL,[I0]:e.GREATER,[P0]:e.NOTEQUAL};function Me(w,v){if(v.type===Mi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===Gt||v.magFilter===ss||v.magFilter===gr||v.magFilter===ii||v.minFilter===Gt||v.minFilter===ss||v.minFilter===gr||v.minFilter===ii))Ce("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Te[v.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Te[v.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Te[v.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ve[v.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ve[v.minFilter]),v.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,He[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Bn)return;if(v.minFilter!==gr&&v.minFilter!==ii)return;if(v.type===Mi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let P=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,P.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(w,v){let P=!1;if(w.__webglInit===void 0)w.__webglInit=!0,v.addEventListener("dispose",A);let V=v.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=z(v);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,P=!0;ie[ae].usedTimes++;let ue=ie[w.__cacheKey];if(ue!==void 0){if(ie[w.__cacheKey].usedTimes--,ue.usedTimes===0)F(v)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return P}function re(w,v,P){return Math.floor(Math.floor(w/P)/v)}function se(w,v,P,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,P,V,v.data);else{ae.sort((Ae,he)=>Ae.start-he.start);let ue=0;for(let Ae=1;Ae<ae.length;Ae++){let he=ae[ue],oe=ae[Ae],Le=he.start+he.count,De=re(oe.start,v.width,4),Qe=re(he.start,v.width,4);if(oe.start<=Le+1&&De===Qe&&re(oe.start+oe.count-1,v.width,4)===De)he.count=Math.max(he.count,oe.start+oe.count-he.start);else++ue,ae[ue]=oe}ae.length=ue+1;let q=n.getParameter(e.UNPACK_ROW_LENGTH),J=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ae=0,he=ae.length;Ae<he;Ae++){let oe=ae[Ae],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Qe=Le%v.width,D=Math.floor(Le/v.width),ce=De,Y=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Qe),n.pixelStorei(e.UNPACK_SKIP_ROWS,D),n.texSubImage2D(e.TEXTURE_2D,0,Qe,D,ce,1,P,V,v.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,q),n.pixelStorei(e.UNPACK_SKIP_PIXELS,J),n.pixelStorei(e.UNPACK_SKIP_ROWS,ge)}}function Ie(w,v,P){let V=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,v),ae=v.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+P);let ue=i.get(ae);if(ae.version!==ue.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+P),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Y=$e.getPrimaries($e.workingColorSpace),le=v.colorSpace===yr?null:$e.getPrimaries(v.colorSpace),_e=v.colorSpace===yr||Y===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,_e)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let J=p(v.image,!1,r.maxTextureSize);J=nt(v,J);let ge=s.convert(v.format,v.colorSpace),Ae=s.convert(v.type),he=S(v.internalFormat,ge,Ae,v.normalized,v.colorSpace,v.isVideoTexture);Me(V,v);let oe,Le=v.mipmaps,De=v.isVideoTexture!==!0,Qe=ue.__version===void 0||ie===!0,D=ae.dataReady,ce=T(v,J);if(v.isDepthTexture){if(he=b(v.format===xr,v.type),Qe)if(De)n.texStorage2D(e.TEXTURE_2D,1,he,J.width,J.height);else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,null)}else if(v.isDataTexture)if(Le.length>0){if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data);v.generateMipmaps=!1}else if(De){if(Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);if(D)se(v,J,ge,Ae)}else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,J.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(De&&Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,Le[0].width,Le[0].height,J.depth);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==si)if(ge!==null)if(De){if(D)if(v.layerUpdates.size>0){let _e=Ch(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let de=oe.data.subarray(ne*_e/oe.data.BYTES_PER_ELEMENT,(ne+1)*_e/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,ne,oe.width,oe.height,1,ge,de)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,oe.data,0,0);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,Ae,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,ge,Ae,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==si)if(ge!==null)if(De){if(D)n.compressedTexSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,oe.data);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data)}else if(v.isDataArrayTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,J.width,J.height,J.depth);if(D)if(v.layerUpdates.size>0){let Y=Ch(J.width,J.height,v.format,v.type);for(let le of v.layerUpdates){let _e=J.data.subarray(le*Y/J.data.BYTES_PER_ELEMENT,(le+1)*Y/J.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,J.width,J.height,1,ge,Ae,_e)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isData3DTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_3D,ce,he,J.width,J.height,J.depth);if(D)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isFramebufferTexture){if(Qe)if(De)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);else{let Y=J.width,le=J.height;for(let _e=0;_e<ce;_e++)n.texImage2D(e.TEXTURE_2D,_e,he,Y,le,0,ge,Ae,null),Y>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Y=e.canvas;if(!Y.hasAttribute("layoutsubtree"))Y.setAttribute("layoutsubtree","true");if(J.parentNode!==Y){Y.appendChild(J),f.add(v),Y.onpaint=(le)=>{let _e=le.changedElements;for(let ne of f)if(_e.includes(ne.image))ne.needsUpdate=!0},Y.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,J);else{let{RGBA:_e,RGBA:ne,UNSIGNED_BYTE:de}=e;e.texElementImage2D(e.TEXTURE_2D,0,_e,ne,de,J)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Qe){let Y=bt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,ge,Ae,oe)}else n.texImage2D(e.TEXTURE_2D,Y,he,ge,Ae,oe);v.generateMipmaps=!1}else if(De){if(Qe){let Y=bt(J);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}if(D)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ae,J)}else n.texImage2D(e.TEXTURE_2D,0,he,ge,Ae,J);if(m(v))E(V);if(ue.__version=ae.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function Pe(w,v,P){if(v.image.length!==6)return;let V=Z(w,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+P);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+P);let ue=$e.getPrimaries($e.workingColorSpace),q=v.colorSpace===yr?null:$e.getPrimaries(v.colorSpace),J=v.colorSpace===yr||ue===q?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,J);let ge=v.isCompressedTexture||v.image[0].isCompressedTexture,Ae=v.image[0]&&v.image[0].isDataTexture,he=[];for(let ne=0;ne<6;ne++){if(!ge&&!Ae)he[ne]=p(v.image[ne],!0,r.maxCubemapSize);else he[ne]=Ae?v.image[ne].image:v.image[ne];he[ne]=nt(v,he[ne])}let oe=he[0],Le=s.convert(v.format,v.colorSpace),De=s.convert(v.type),Qe=S(v.internalFormat,Le,De,v.normalized,v.colorSpace),D=v.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,Y=ie.dataReady,le=T(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let _e;if(ge){if(D&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,oe.width,oe.height);for(let ne=0;ne<6;ne++){_e=he[ne].mipmaps;for(let de=0;de<_e.length;de++){let Be=_e[de];if(v.format!==si)if(Le!==null)if(D){if(Y)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Qe,Be.width,Be.height,0,Be.data);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,Be.width,Be.height,Le,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Qe,Be.width,Be.height,0,Le,De,Be.data)}}}else{if(_e=v.mipmaps,D&&ce){if(_e.length>0)le++;let ne=bt(he[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ae){if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,he[ne].width,he[ne].height,Le,De,he[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,he[ne].width,he[ne].height,0,Le,De,he[ne].data);for(let de=0;de<_e.length;de++){let dt=_e[de].image[ne].image;if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,dt.width,dt.height,Le,De,dt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Qe,dt.width,dt.height,0,Le,De,dt.data)}}else{if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,he[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,Le,De,he[ne]);for(let de=0;de<_e.length;de++){let Be=_e[de];if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,Le,De,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Qe,Le,De,Be.image[ne])}}}if(m(v))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function we(w,v,P,V,ie,ae){let ue=s.convert(P.format,P.colorSpace),q=s.convert(P.type),J=S(P.internalFormat,ue,q,P.normalized,P.colorSpace),ge=i.get(v),Ae=i.get(P);if(Ae.__renderTarget=v,!ge.__hasExternalTextures){let he=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,J,he,oe,v.depth,0,ue,q,null);else n.texImage2D(ie,ae,J,he,oe,0,ue,q,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Ae.__webglTexture,0,Nt(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,V,ie,Ae.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function gt(w,v,P){if(e.bindRenderbuffer(e.RENDERBUFFER,w),v.depthBuffer){let V=v.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=b(v.stencilBuffer,ie),ue=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Nt(v),ae,v.width,v.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Nt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,w)}else{let V=v.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],ue=s.convert(ae.format,ae.colorSpace),q=s.convert(ae.type),J=S(ae.internalFormat,ue,q,ae.normalized,ae.colorSpace);if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Nt(v),J,v.width,v.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Nt(v),J,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,J,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ke(w,v,P){let V=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(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(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let ge=s.convert(v.depthTexture.format),Ae=s.convert(v.depthTexture.type),he;if(v.depthTexture.format===_r)he=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===xr)he=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,he,v.width,v.height,0,ge,Ae,null)}}else te(v.depthTexture,0);let ae=ie.__webglTexture,ue=Nt(v),q=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+P:e.TEXTURE_2D,J=v.depthTexture.format===xr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===_r)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else if(v.depthTexture.format===xr)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Xe(w){let v=i.get(w),P=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(V){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=V}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(P)for(let V=0;V<6;V++)ke(v.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ke(v.__webglFramebuffer[0],w,0);else ke(v.__webglFramebuffer,w,0)}else if(P){v.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[V]),v.__webglDepthbuffer[V]===void 0)v.__webglDepthbuffer[V]=e.createRenderbuffer(),gt(v.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),gt(v.__webglDepthbuffer,w,!1);else{let ie=w.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 st(w,v,P){let V=i.get(w);if(v!==void 0)we(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(P!==void 0)Xe(w)}function Ke(w){let v=w.texture,P=i.get(w),V=i.get(v);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,ue=ie.length>1;if(!ue){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=v.version,o.memory.textures++}if(ae){P.__webglFramebuffer=[];for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0){P.__webglFramebuffer[q]=[];for(let J=0;J<v.mipmaps.length;J++)P.__webglFramebuffer[q][J]=e.createFramebuffer()}else P.__webglFramebuffer[q]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){P.__webglFramebuffer=[];for(let q=0;q<v.mipmaps.length;q++)P.__webglFramebuffer[q]=e.createFramebuffer()}else P.__webglFramebuffer=e.createFramebuffer();if(ue)for(let q=0,J=ie.length;q<J;q++){let ge=i.get(ie[q]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){P.__webglMultisampledFramebuffer=e.createFramebuffer(),P.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,P.__webglMultisampledFramebuffer);for(let q=0;q<ie.length;q++){let J=ie[q];P.__webglColorRenderbuffer[q]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,P.__webglColorRenderbuffer[q]);let ge=s.convert(J.format,J.colorSpace),Ae=s.convert(J.type),he=S(J.internalFormat,ge,Ae,J.normalized,J.colorSpace,w.isXRRenderTarget===!0),oe=Nt(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,he,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+q,e.RENDERBUFFER,P.__webglColorRenderbuffer[q])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)P.__webglDepthRenderbuffer=e.createRenderbuffer(),gt(P.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(P.__webglFramebuffer[q][J],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else we(P.__webglFramebuffer[q],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);if(m(v))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ue){for(let q=0,J=ie.length;q<J;q++){let ge=ie[q],Ae=i.get(ge),he=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)he=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(he,Ae.__webglTexture),Me(he,ge),we(P.__webglFramebuffer,w,ge,e.COLOR_ATTACHMENT0+q,he,0),m(ge))E(he)}n.unbindTexture()}else{let q=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)q=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(q,V.__webglTexture),Me(q,v),v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(P.__webglFramebuffer[J],w,v,e.COLOR_ATTACHMENT0,q,J);else we(P.__webglFramebuffer,w,v,e.COLOR_ATTACHMENT0,q,0);if(m(v))E(q);n.unbindTexture()}if(w.depthBuffer)Xe(w)}function Ht(w){let v=w.textures;for(let P=0,V=v.length;P<V;P++){let ie=v[P];if(m(ie)){let ae=R(w),ue=i.get(ie).__webglTexture;n.bindTexture(ae,ue),E(ae),n.unbindTexture()}}}let _t=[],rn=[];function Lt(w){if(w.samples>0){if(L(w)===!1){let{textures:v,width:P,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ue=i.get(w),q=v.length>1;if(q)for(let ge=0;ge<v.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer);let J=w.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let ge=0;ge<v.length;ge++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(q){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ae,0)}if(e.blitFramebuffer(0,0,P,V,0,0,P,V,ie,e.NEAREST),c===!0){if(_t.length=0,rn.length=0,_t.push(e.COLOR_ATTACHMENT0+ge),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)_t.push(ae),rn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,rn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,_t)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),q)for(let ge=0;ge<v.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ae,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let v=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Nt(w){return Math.min(r.maxSamples,w.samples)}function L(w){let v=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function sn(w){let v=o.render.frame;if(u.get(w)!==v)u.set(w,v),w.update()}function nt(w,v){let{colorSpace:P,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return v;if(P!==gn&&P!==yr)if($e.getTransfer(P)===ft){if(V!==si||ie!==Gn)Ce("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",P);return v}function bt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=C,this.setTextureUnits=G,this.setTexture2D=te,this.setTexture2DArray=H,this.setTexture3D=Q,this.setTextureCube=ee,this.rebindTextures=st,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=Ht,this.updateMultisampleRenderTarget=Lt,this.setupDepthRenderbuffer=Xe,this.setupFrameBufferTexture=we,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function UA(e,t){function n(i,r=yr){let s,o=$e.getTransfer(r);if(i===Gn)return e.UNSIGNED_BYTE;if(i===Su)return e.UNSIGNED_SHORT_4_4_4_4;if(i===bu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===S0)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===b0)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===v0)return e.BYTE;if(i===y0)return e.SHORT;if(i===no)return e.UNSIGNED_SHORT;if(i===yu)return e.INT;if(i===$i)return e.UNSIGNED_INT;if(i===Mi)return e.FLOAT;if(i===ri)return e.HALF_FLOAT;if(i===M0)return e.ALPHA;if(i===w0)return e.RGB;if(i===si)return e.RGBA;if(i===_r)return e.DEPTH_COMPONENT;if(i===xr)return e.DEPTH_STENCIL;if(i===T0)return e.RED;if(i===Mu)return e.RED_INTEGER;if(i===vr)return e.RG;if(i===wu)return e.RG_INTEGER;if(i===Tu)return e.RGBA_INTEGER;if(i===$a||i===Za||i===Xa||i===qa)if(o===ft)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===$a)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Za)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===qa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===$a)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Za)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Xa)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===qa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Eu||i===Au||i===Ru||i===Cu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Eu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Au)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ru)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Cu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Iu||i===Pu||i===Lu||i===Nu||i===Du||i===Ya||i===Ou)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Iu||i===Pu)return o===ft?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Lu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Nu)return s.COMPRESSED_R11_EAC;if(i===Du)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ya)return s.COMPRESSED_RG11_EAC;if(i===Ou)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Uu||i===Fu||i===zu||i===ku||i===Bu||i===Gu||i===Hu||i===Vu||i===Wu||i===$u||i===Zu||i===Xu||i===qu||i===Yu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Uu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Fu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===zu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===ku)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Bu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Gu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Hu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Vu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Wu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$u)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Zu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Xu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===qu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Yu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ju||i===Ku||i===Ju)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===ju)return o===ft?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ku)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ju)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Qu||i===eh||i===ja||i===th)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Qu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===eh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ja)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===th)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===os)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var FA=`
+}`,DA=[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)],OA=[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)],mx=new Ge,So=new U,Fh=new U;function UA(e,t,n){let i=new ho,r=new Ne,s=new Ne,o=new at,a=new _h,c=new xh,l={},u=n.maxTextureSize,f={[Wi]:Yt,[Yt]:Wi,[An]:An},h=new Rn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:LA,fragmentShader:NA}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new jt;g.setAttribute("position",new Bt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new mt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Js;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===$_)Ce("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Js;let M=e.getRenderTarget(),F=e.getActiveCubeFace(),I=e.getActiveMipmapLevel(),O=e.state;if(O.setBlending(ni),O.buffers.depth.getReversed()===!0)O.buffers.color.setClear(0,0,0,0);else O.buffers.color.setClear(1,1,1,1);O.buffers.depth.setTest(!0),O.setScissorTest(!1);let K=m!==this.type;if(K)A.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((G)=>G.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,G=T.length;C<G;C++){let X=T[C],z=X.shadow;if(z===void 0){Ce("WebGLShadowMap:",X,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let te=z.getFrameExtents();if(r.multiply(te),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/te.x),r.x=s.x*te.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/te.y),r.y=s.y*te.y,z.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=H,z.map===null||K===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===es){if(X.isPointLight){Ce("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new _n(r.x,r.y,{format:vr,type:ri,minFilter:Gt,magFilter:Gt,generateMipmaps:!1}),z.map.texture.name=X.name+".shadowMap",z.map.depthTexture=new Sr(r.x,r.y,Mi),z.map.depthTexture.name=X.name+".shadowMapDepth",z.map.depthTexture.format=_r,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Bn,z.map.depthTexture.magFilter=Bn}else{if(X.isPointLight)z.map=new Bh(r.x),z.map.depthTexture=new ph(r.x,$i);else z.map=new _n(r.x,r.y),z.map.depthTexture=new Sr(r.x,r.y,$i);if(z.map.depthTexture.name=X.name+".shadowMap",z.map.depthTexture.format=_r,this.type===Js)z.map.depthTexture.compareFunction=H?Qa:Ja,z.map.depthTexture.minFilter=Gt,z.map.depthTexture.magFilter=Gt;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Bn,z.map.depthTexture.magFilter=Bn}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let Q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(X.isPointLight!==!0)z.updateMatrices(X,_);for(let ee=0;ee<Q;ee++){let Te=z.getCamera(ee);if(X.isPointLight){let{camera:ve,matrix:He}=z,Me=X.distance||ve.far;if(Me!==ve.far)ve.far=Me,ve.updateProjectionMatrix();So.setFromMatrixPosition(X.matrixWorld),ve.position.copy(So),Fh.copy(ve.position),Fh.add(DA[ee]),ve.up.copy(OA[ee]),ve.lookAt(Fh),ve.updateMatrixWorld(),He.makeTranslation(-So.x,-So.y,-So.z),mx.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),z._frustum.setFromProjectionMatrix(mx,ve.coordinateSystem,ve.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(z.map),e.clear();let ve=z.getViewport(ee);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),O.viewport(o)}i=z.getFrustum(ee),S(A,_,Te,X,this.type)}if(z.isPointLightShadow!==!0&&this.type===es)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(M,F,I)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new _n(r.x,r.y,{format:vr,type:ri});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,M){let F=null,I=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(I!==void 0)F=I;else if(F=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let O=F.uuid,K=A.uuid,C=l[O];if(C===void 0)C={},l[O]=C;let G=C[K];if(G===void 0)G=F.clone(),C[K]=G,A.addEventListener("dispose",b);F=G}if(F.visible=A.visible,F.wireframe=A.wireframe,M===es)F.side=A.shadowSide!==null?A.shadowSide:A.side;else F.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(F.alphaMap=A.alphaMap,F.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,F.map=A.map,F.clipShadows=A.clipShadows,F.clippingPlanes=A.clippingPlanes,F.clipIntersection=A.clipIntersection,F.displacementMap=A.displacementMap,F.displacementScale=A.displacementScale,F.displacementBias=A.displacementBias,F.wireframeLinewidth=A.wireframeLinewidth,F.linewidth=A.linewidth,_.isPointLight===!0&&F.isMeshDistanceMaterial===!0){let O=e.properties.get(F);O.light=_}return F}function S(T,A,_,M,F){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&F===es)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let K=t.update(T),C=T.material;if(Array.isArray(C)){let G=K.groups;for(let X=0,z=G.length;X<z;X++){let te=G[X],H=C[te.materialIndex];if(H&&H.visible){let Q=R(T,H,M,F);T.onBeforeShadow(e,T,A,_,K,Q,te),e.renderBufferDirect(_,null,K,Q,T,te),T.onAfterShadow(e,T,A,_,K,Q,te)}}}else if(C.visible){let G=R(T,C,M,F);T.onBeforeShadow(e,T,A,_,K,G,null),e.renderBufferDirect(_,null,K,G,T,null),T.onAfterShadow(e,T,A,_,K,G,null)}}}let O=T.children;for(let K=0,C=O.length;K<C;K++)S(O[K],A,_,M,F)}function b(T){T.target.removeEventListener("dispose",b);for(let _ in l){let M=l[_],F=T.target.uuid;if(F in M)M[F].dispose(),delete M[F]}}}function FA(e,t){function n(){let D=!1,ce=new at,Y=null,le=new at(0,0,0,0);return{setMask:function(_e){if(Y!==_e&&!D)e.colorMask(_e,_e,_e,_e),Y=_e},setLocked:function(_e){D=_e},setClear:function(_e,ne,de,Be,dt){if(dt===!0)_e*=Be,ne*=Be,de*=Be;if(ce.set(_e,ne,de,Be),le.equals(ce)===!1)e.clearColor(_e,ne,de,Be),le.copy(ce)},reset:function(){D=!1,Y=null,le.set(-1,0,0,0)}}}function i(){let D=!1,ce=!1,Y=null,le=null,_e=null;return{setReversed:function(ne){if(ce!==ne){let de=t.get("EXT_clip_control");if(ne)de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT);else de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let Be=_e;_e=null,this.setClear(Be)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Ie(e.DEPTH_TEST)},setMask:function(ne){if(Y!==ne&&!D)e.depthMask(ne),Y=ne},setFunc:function(ne){if(ce)ne=k0[ne];if(le!==ne){switch(ne){case f0:e.depthFunc(e.NEVER);break;case d0:e.depthFunc(e.ALWAYS);break;case p0:e.depthFunc(e.LESS);break;case mu:e.depthFunc(e.LEQUAL);break;case m0:e.depthFunc(e.EQUAL);break;case g0:e.depthFunc(e.GEQUAL);break;case _0:e.depthFunc(e.GREATER);break;case x0:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){D=ne},setClear:function(ne){if(_e!==ne){if(_e=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){D=!1,Y=null,le=null,_e=null,ce=!1}}}function r(){let D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,Be=null,dt=null;return{setTest:function(it){if(!D)if(it)se(e.STENCIL_TEST);else Ie(e.STENCIL_TEST)},setMask:function(it){if(ce!==it&&!D)e.stencilMask(it),ce=it},setFunc:function(it,Vn,ui){if(Y!==it||le!==Vn||_e!==ui)e.stencilFunc(it,Vn,ui),Y=it,le=Vn,_e=ui},setOp:function(it,Vn,ui){if(ne!==it||de!==Vn||Be!==ui)e.stencilOp(it,Vn,ui),ne=it,de=Vn,Be=ui},setLocked:function(it){D=it},setClear:function(it){if(dt!==it)e.clearStencil(it),dt=it},reset:function(){D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,Be=null,dt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,I=null,O=null,K=null,C=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)te=parseFloat(/^WebGL (\d)/.exec(H)[1]),z=te>=1;else if(H.indexOf("OpenGL ES")!==-1)te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),z=te>=2;let Q=null,ee={},Te=e.getParameter(e.SCISSOR_BOX),ve=e.getParameter(e.VIEWPORT),He=new at().fromArray(Te),Me=new at().fromArray(ve);function Z(D,ce,Y,le){let _e=new Uint8Array(4),ne=e.createTexture();e.bindTexture(D,ne),e.texParameteri(D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(D,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let de=0;de<Y;de++)if(D===e.TEXTURE_3D||D===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,_e);else e.texImage2D(ce+de,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,_e);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(mu),Ht(!1),_t(hu),se(e.CULL_FACE),st(ni);function se(D){if(u[D]!==!0)e.enable(D),u[D]=!0}function Ie(D){if(u[D]!==!1)e.disable(D),u[D]=!1}function Pe(D,ce){if(h[D]!==ce){if(e.bindFramebuffer(D,ce),h[D]=ce,D===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(D===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function we(D,ce){let Y=g,le=!1;if(D){if(Y=d.get(ce),Y===void 0)Y=[],d.set(ce,Y);let _e=D.textures;if(Y.length!==_e.length||Y[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,de=_e.length;ne<de;ne++)Y[ne]=e.COLOR_ATTACHMENT0+ne;Y.length=_e.length,le=!0}}else if(Y[0]!==e.BACK)Y[0]=e.BACK,le=!0;if(le)e.drawBuffers(Y)}function gt(D){if(x!==D)return e.useProgram(D),x=D,!0;return!1}let ke={[ts]:e.FUNC_ADD,[X_]:e.FUNC_SUBTRACT,[q_]:e.FUNC_REVERSE_SUBTRACT};ke[Y_]=e.MIN,ke[j_]=e.MAX;let Xe={[K_]:e.ZERO,[J_]:e.ONE,[Q_]:e.SRC_COLOR,[t0]:e.SRC_ALPHA,[a0]:e.SRC_ALPHA_SATURATE,[s0]:e.DST_COLOR,[i0]:e.DST_ALPHA,[e0]:e.ONE_MINUS_SRC_COLOR,[n0]:e.ONE_MINUS_SRC_ALPHA,[o0]:e.ONE_MINUS_DST_COLOR,[r0]:e.ONE_MINUS_DST_ALPHA,[c0]:e.CONSTANT_COLOR,[l0]:e.ONE_MINUS_CONSTANT_COLOR,[u0]:e.CONSTANT_ALPHA,[h0]:e.ONE_MINUS_CONSTANT_ALPHA};function st(D,ce,Y,le,_e,ne,de,Be,dt,it){if(D===ni){if(p===!0)Ie(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(D!==Z_){if(D!==m||it!==F){if(E!==ts||b!==ts)e.blendEquation(e.FUNC_ADD),E=ts,b=ts;if(it)switch(D){case Qs:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fu:e.blendFunc(e.ONE,e.ONE);break;case du:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case pu:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",D);break}else switch(D){case Qs:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case fu:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case du:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case pu:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",D);break}R=null,S=null,T=null,A=null,_.set(0,0,0),M=0,m=D,F=it}return}if(_e=_e||ce,ne=ne||Y,de=de||le,ce!==E||_e!==b)e.blendEquationSeparate(ke[ce],ke[_e]),E=ce,b=_e;if(Y!==R||le!==S||ne!==T||de!==A)e.blendFuncSeparate(Xe[Y],Xe[le],Xe[ne],Xe[de]),R=Y,S=le,T=ne,A=de;if(Be.equals(_)===!1||dt!==M)e.blendColor(Be.r,Be.g,Be.b,dt),_.copy(Be),M=dt;m=D,F=!1}function Ke(D,ce){D.side===An?Ie(e.CULL_FACE):se(e.CULL_FACE);let Y=D.side===Yt;if(ce)Y=!Y;Ht(Y),D.blending===Qs&&D.transparent===!1?st(ni):st(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);let le=D.stencilWrite;if(a.setTest(le),le)a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass);Lt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Ie(e.SAMPLE_ALPHA_TO_COVERAGE)}function Ht(D){if(I!==D){if(D)e.frontFace(e.CW);else e.frontFace(e.CCW);I=D}}function _t(D){if(D!==V_){if(se(e.CULL_FACE),D!==O)if(D===hu)e.cullFace(e.BACK);else if(D===W_)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Ie(e.CULL_FACE);O=D}function rn(D){if(D!==K){if(z)e.lineWidth(D);K=D}}function Lt(D,ce,Y){if(D){if(se(e.POLYGON_OFFSET_FILL),C!==ce||G!==Y){if(C=ce,G=Y,o.getReversed())ce=-ce;e.polygonOffset(ce,Y)}}else Ie(e.POLYGON_OFFSET_FILL)}function Nt(D){if(D)se(e.SCISSOR_TEST);else Ie(e.SCISSOR_TEST)}function L(D){if(D===void 0)D=e.TEXTURE0+X-1;if(Q!==D)e.activeTexture(D),Q=D}function sn(D,ce,Y){if(Y===void 0)if(Q===null)Y=e.TEXTURE0+X-1;else Y=Q;let le=ee[Y];if(le===void 0)le={type:void 0,texture:void 0},ee[Y]=le;if(le.type!==D||le.texture!==ce){if(Q!==Y)e.activeTexture(Y),Q=Y;e.bindTexture(D,ce||re[D]),le.type=D,le.texture=ce}}function nt(){let D=ee[Q];if(D!==void 0&&D.type!==void 0)e.bindTexture(D.type,null),D.type=void 0,D.texture=void 0}function bt(){try{e.compressedTexImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function v(){try{e.texSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function P(){try{e.texSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ae(){try{e.texStorage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ue(){try{e.texStorage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function q(){try{e.texImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function J(){try{e.texImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ge(D){if(f[D]!==void 0)return f[D];else return e.getParameter(D)}function Ae(D,ce){if(f[D]!==ce)e.pixelStorei(D,ce),f[D]=ce}function he(D){if(He.equals(D)===!1)e.scissor(D.x,D.y,D.z,D.w),He.copy(D)}function oe(D){if(Me.equals(D)===!1)e.viewport(D.x,D.y,D.z,D.w),Me.copy(D)}function Le(D,ce){let Y=l.get(ce);if(Y===void 0)Y=new WeakMap,l.set(ce,Y);let le=Y.get(D);if(le===void 0)le=e.getUniformBlockIndex(ce,D.name),Y.set(D,le)}function De(D,ce){let le=l.get(ce).get(D);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,D.__bindingPointIndex),c.set(ce,le)}function Qe(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Q=null,ee={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,I=null,O=null,K=null,C=null,G=null,He.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:Ie,bindFramebuffer:Pe,drawBuffers:we,useProgram:gt,setBlending:st,setMaterial:Ke,setFlipSided:Ht,setCullFace:_t,setLineWidth:rn,setPolygonOffset:Lt,setScissorTest:Nt,activeTexture:L,bindTexture:sn,unbindTexture:nt,compressedTexImage2D:bt,compressedTexImage3D:w,texImage2D:q,texImage3D:J,pixelStorei:Ae,getParameter:ge,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:ue,texSubImage2D:v,texSubImage3D:P,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:he,viewport:oe,reset:Qe}}function zA(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,v){return g?new OffscreenCanvas(w,v):Kr("canvas")}function p(w,v,P){let V=1,ie=bt(w);if(ie.width>P||ie.height>P)V=P/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),ue=Math.floor(V*ie.height);if(h===void 0)h=x(ae,ue);let q=v?x(ae,ue):h;return q.width=ae,q.height=ue,q.getContext("2d").drawImage(w,0,0,ae,ue),Ce("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+ue+")."),q}else{if("data"in w)Ce("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function S(w,v,P,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Ce("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ue;if(V){if(ue=t.get("EXT_texture_norm16"),!ue)Ce("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let q=v;if(v===e.RED){if(P===e.FLOAT)q=e.R32F;if(P===e.HALF_FLOAT)q=e.R16F;if(P===e.UNSIGNED_BYTE)q=e.R8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.R16_EXT;if(P===e.SHORT&&ue)q=ue.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.R8UI;if(P===e.UNSIGNED_SHORT)q=e.R16UI;if(P===e.UNSIGNED_INT)q=e.R32UI;if(P===e.BYTE)q=e.R8I;if(P===e.SHORT)q=e.R16I;if(P===e.INT)q=e.R32I}if(v===e.RG){if(P===e.FLOAT)q=e.RG32F;if(P===e.HALF_FLOAT)q=e.RG16F;if(P===e.UNSIGNED_BYTE)q=e.RG8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.RG16_EXT;if(P===e.SHORT&&ue)q=ue.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RG8UI;if(P===e.UNSIGNED_SHORT)q=e.RG16UI;if(P===e.UNSIGNED_INT)q=e.RG32UI;if(P===e.BYTE)q=e.RG8I;if(P===e.SHORT)q=e.RG16I;if(P===e.INT)q=e.RG32I}if(v===e.RGB_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RGB8UI;if(P===e.UNSIGNED_SHORT)q=e.RGB16UI;if(P===e.UNSIGNED_INT)q=e.RGB32UI;if(P===e.BYTE)q=e.RGB8I;if(P===e.SHORT)q=e.RGB16I;if(P===e.INT)q=e.RGB32I}if(v===e.RGBA_INTEGER){if(P===e.UNSIGNED_BYTE)q=e.RGBA8UI;if(P===e.UNSIGNED_SHORT)q=e.RGBA16UI;if(P===e.UNSIGNED_INT)q=e.RGBA32UI;if(P===e.BYTE)q=e.RGBA8I;if(P===e.SHORT)q=e.RGBA16I;if(P===e.INT)q=e.RGBA32I}if(v===e.RGB){if(P===e.UNSIGNED_SHORT&&ue)q=ue.RGB16_EXT;if(P===e.SHORT&&ue)q=ue.RGB16_SNORM_EXT;if(P===e.UNSIGNED_INT_5_9_9_9_REV)q=e.RGB9_E5;if(P===e.UNSIGNED_INT_10F_11F_11F_REV)q=e.R11F_G11F_B10F}if(v===e.RGBA){let J=ae?ah:$e.getTransfer(ie);if(P===e.FLOAT)q=e.RGBA32F;if(P===e.HALF_FLOAT)q=e.RGBA16F;if(P===e.UNSIGNED_BYTE)q=J===ft?e.SRGB8_ALPHA8:e.RGBA8;if(P===e.UNSIGNED_SHORT&&ue)q=ue.RGBA16_EXT;if(P===e.SHORT&&ue)q=ue.RGBA16_SNORM_EXT;if(P===e.UNSIGNED_SHORT_4_4_4_4)q=e.RGBA4;if(P===e.UNSIGNED_SHORT_5_5_5_1)q=e.RGB5_A1}if(q===e.R16F||q===e.R32F||q===e.RG16F||q===e.RG32F||q===e.RGBA16F||q===e.RGBA32F)t.get("EXT_color_buffer_float");return q}function b(w,v){let P;if(w){if(v===null||v===$i||v===os)P=e.DEPTH24_STENCIL8;else if(v===Mi)P=e.DEPTH32F_STENCIL8;else if(v===no)P=e.DEPTH24_STENCIL8,Ce("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===$i||v===os)P=e.DEPTH_COMPONENT24;else if(v===Mi)P=e.DEPTH_COMPONENT32F;else if(v===no)P=e.DEPTH_COMPONENT16;return P}function T(w,v){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==Bn&&w.minFilter!==Gt)return Math.log2(Math.max(v.width,v.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return v.mipmaps.length;else return 1}function A(w){let v=w.target;if(v.removeEventListener("dispose",A),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)f.delete(v)}function _(w){let v=w.target;v.removeEventListener("dispose",_),I(v)}function M(w){let v=i.get(w);if(v.__webglInit===void 0)return;let P=w.source,V=d.get(P);if(V){let ie=V[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)F(w);if(Object.keys(V).length===0)d.delete(P)}i.remove(w)}function F(w){let v=i.get(w);e.deleteTexture(v.__webglTexture);let P=w.source,V=d.get(P);delete V[v.__cacheKey],o.memory.textures--}function I(w){let v=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(v.__webglFramebuffer[V]))for(let ie=0;ie<v.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[V]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[V])}else{if(Array.isArray(v.__webglFramebuffer))for(let V=0;V<v.__webglFramebuffer.length;V++)e.deleteFramebuffer(v.__webglFramebuffer[V]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let V=0;V<v.__webglColorRenderbuffer.length;V++)if(v.__webglColorRenderbuffer[V])e.deleteRenderbuffer(v.__webglColorRenderbuffer[V])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let P=w.textures;for(let V=0,ie=P.length;V<ie;V++){let ae=i.get(P[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(P[V])}i.remove(w)}let O=0;function K(){O=0}function C(){return O}function G(w){O=w}function X(){let w=O;if(w>=r.maxTextures)Ce("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return O+=1,w}function z(w){let v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function te(w,v){let P=i.get(w);if(w.isVideoTexture)sn(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&P.__version!==w.version){let V=w.image;if(V===null)Ce("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ce("WebGLRenderer: Texture marked for update but image is incomplete");else{Ie(P,w,v);return}}else if(w.isExternalTexture)P.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,P.__webglTexture,e.TEXTURE0+v)}function H(w,v){let P=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&P.__version!==w.version){Ie(P,w,v);return}else if(w.isExternalTexture)P.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,P.__webglTexture,e.TEXTURE0+v)}function Q(w,v){let P=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&P.__version!==w.version){Ie(P,w,v);return}n.bindTexture(e.TEXTURE_3D,P.__webglTexture,e.TEXTURE0+v)}function ee(w,v){let P=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&P.__version!==w.version){Pe(P,w,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,P.__webglTexture,e.TEXTURE0+v)}let Te={[is]:e.REPEAT,[rs]:e.CLAMP_TO_EDGE,[Va]:e.MIRRORED_REPEAT},ve={[Bn]:e.NEAREST,[Wa]:e.NEAREST_MIPMAP_NEAREST,[gr]:e.NEAREST_MIPMAP_LINEAR,[Gt]:e.LINEAR,[ss]:e.LINEAR_MIPMAP_NEAREST,[ii]:e.LINEAR_MIPMAP_LINEAR},He={[I0]:e.NEVER,[O0]:e.ALWAYS,[P0]:e.LESS,[Ja]:e.LEQUAL,[L0]:e.EQUAL,[Qa]:e.GEQUAL,[N0]:e.GREATER,[D0]:e.NOTEQUAL};function Me(w,v){if(v.type===Mi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===Gt||v.magFilter===ss||v.magFilter===gr||v.magFilter===ii||v.minFilter===Gt||v.minFilter===ss||v.minFilter===gr||v.minFilter===ii))Ce("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Te[v.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Te[v.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Te[v.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ve[v.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ve[v.minFilter]),v.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,He[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Bn)return;if(v.minFilter!==gr&&v.minFilter!==ii)return;if(v.type===Mi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let P=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,P.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(w,v){let P=!1;if(w.__webglInit===void 0)w.__webglInit=!0,v.addEventListener("dispose",A);let V=v.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=z(v);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,P=!0;ie[ae].usedTimes++;let ue=ie[w.__cacheKey];if(ue!==void 0){if(ie[w.__cacheKey].usedTimes--,ue.usedTimes===0)F(v)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return P}function re(w,v,P){return Math.floor(Math.floor(w/P)/v)}function se(w,v,P,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,P,V,v.data);else{ae.sort((Ae,he)=>Ae.start-he.start);let ue=0;for(let Ae=1;Ae<ae.length;Ae++){let he=ae[ue],oe=ae[Ae],Le=he.start+he.count,De=re(oe.start,v.width,4),Qe=re(he.start,v.width,4);if(oe.start<=Le+1&&De===Qe&&re(oe.start+oe.count-1,v.width,4)===De)he.count=Math.max(he.count,oe.start+oe.count-he.start);else++ue,ae[ue]=oe}ae.length=ue+1;let q=n.getParameter(e.UNPACK_ROW_LENGTH),J=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ae=0,he=ae.length;Ae<he;Ae++){let oe=ae[Ae],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Qe=Le%v.width,D=Math.floor(Le/v.width),ce=De,Y=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Qe),n.pixelStorei(e.UNPACK_SKIP_ROWS,D),n.texSubImage2D(e.TEXTURE_2D,0,Qe,D,ce,1,P,V,v.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,q),n.pixelStorei(e.UNPACK_SKIP_PIXELS,J),n.pixelStorei(e.UNPACK_SKIP_ROWS,ge)}}function Ie(w,v,P){let V=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,v),ae=v.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+P);let ue=i.get(ae);if(ae.version!==ue.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+P),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Y=$e.getPrimaries($e.workingColorSpace),le=v.colorSpace===yr?null:$e.getPrimaries(v.colorSpace),_e=v.colorSpace===yr||Y===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,_e)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let J=p(v.image,!1,r.maxTextureSize);J=nt(v,J);let ge=s.convert(v.format,v.colorSpace),Ae=s.convert(v.type),he=S(v.internalFormat,ge,Ae,v.normalized,v.colorSpace,v.isVideoTexture);Me(V,v);let oe,Le=v.mipmaps,De=v.isVideoTexture!==!0,Qe=ue.__version===void 0||ie===!0,D=ae.dataReady,ce=T(v,J);if(v.isDepthTexture){if(he=b(v.format===xr,v.type),Qe)if(De)n.texStorage2D(e.TEXTURE_2D,1,he,J.width,J.height);else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,null)}else if(v.isDataTexture)if(Le.length>0){if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data);v.generateMipmaps=!1}else if(De){if(Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);if(D)se(v,J,ge,Ae)}else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,J.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(De&&Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,Le[0].width,Le[0].height,J.depth);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==si)if(ge!==null)if(De){if(D)if(v.layerUpdates.size>0){let _e=Ph(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let de=oe.data.subarray(ne*_e/oe.data.BYTES_PER_ELEMENT,(ne+1)*_e/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,ne,oe.width,oe.height,1,ge,de)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,oe.data,0,0);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,Ae,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,ge,Ae,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(De&&Qe)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==si)if(ge!==null)if(De){if(D)n.compressedTexSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,oe.data);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data)}else if(v.isDataArrayTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,J.width,J.height,J.depth);if(D)if(v.layerUpdates.size>0){let Y=Ph(J.width,J.height,v.format,v.type);for(let le of v.layerUpdates){let _e=J.data.subarray(le*Y/J.data.BYTES_PER_ELEMENT,(le+1)*Y/J.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,J.width,J.height,1,ge,Ae,_e)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isData3DTexture)if(De){if(Qe)n.texStorage3D(e.TEXTURE_3D,ce,he,J.width,J.height,J.depth);if(D)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isFramebufferTexture){if(Qe)if(De)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);else{let Y=J.width,le=J.height;for(let _e=0;_e<ce;_e++)n.texImage2D(e.TEXTURE_2D,_e,he,Y,le,0,ge,Ae,null),Y>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Y=e.canvas;if(!Y.hasAttribute("layoutsubtree"))Y.setAttribute("layoutsubtree","true");if(J.parentNode!==Y){Y.appendChild(J),f.add(v),Y.onpaint=(le)=>{let _e=le.changedElements;for(let ne of f)if(_e.includes(ne.image))ne.needsUpdate=!0},Y.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,J);else{let{RGBA:_e,RGBA:ne,UNSIGNED_BYTE:de}=e;e.texElementImage2D(e.TEXTURE_2D,0,_e,ne,de,J)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Qe){let Y=bt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,ge,Ae,oe)}else n.texImage2D(e.TEXTURE_2D,Y,he,ge,Ae,oe);v.generateMipmaps=!1}else if(De){if(Qe){let Y=bt(J);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}if(D)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ae,J)}else n.texImage2D(e.TEXTURE_2D,0,he,ge,Ae,J);if(m(v))E(V);if(ue.__version=ae.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function Pe(w,v,P){if(v.image.length!==6)return;let V=Z(w,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+P);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+P);let ue=$e.getPrimaries($e.workingColorSpace),q=v.colorSpace===yr?null:$e.getPrimaries(v.colorSpace),J=v.colorSpace===yr||ue===q?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,J);let ge=v.isCompressedTexture||v.image[0].isCompressedTexture,Ae=v.image[0]&&v.image[0].isDataTexture,he=[];for(let ne=0;ne<6;ne++){if(!ge&&!Ae)he[ne]=p(v.image[ne],!0,r.maxCubemapSize);else he[ne]=Ae?v.image[ne].image:v.image[ne];he[ne]=nt(v,he[ne])}let oe=he[0],Le=s.convert(v.format,v.colorSpace),De=s.convert(v.type),Qe=S(v.internalFormat,Le,De,v.normalized,v.colorSpace),D=v.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,Y=ie.dataReady,le=T(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let _e;if(ge){if(D&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,oe.width,oe.height);for(let ne=0;ne<6;ne++){_e=he[ne].mipmaps;for(let de=0;de<_e.length;de++){let Be=_e[de];if(v.format!==si)if(Le!==null)if(D){if(Y)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,Be.width,Be.height,Le,Be.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Qe,Be.width,Be.height,0,Be.data);else Ce("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,Be.width,Be.height,Le,De,Be.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Qe,Be.width,Be.height,0,Le,De,Be.data)}}}else{if(_e=v.mipmaps,D&&ce){if(_e.length>0)le++;let ne=bt(he[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Qe,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ae){if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,he[ne].width,he[ne].height,Le,De,he[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,he[ne].width,he[ne].height,0,Le,De,he[ne].data);for(let de=0;de<_e.length;de++){let dt=_e[de].image[ne].image;if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,dt.width,dt.height,Le,De,dt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Qe,dt.width,dt.height,0,Le,De,dt.data)}}else{if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,he[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Qe,Le,De,he[ne]);for(let de=0;de<_e.length;de++){let Be=_e[de];if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,Le,De,Be.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Qe,Le,De,Be.image[ne])}}}if(m(v))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function we(w,v,P,V,ie,ae){let ue=s.convert(P.format,P.colorSpace),q=s.convert(P.type),J=S(P.internalFormat,ue,q,P.normalized,P.colorSpace),ge=i.get(v),Ae=i.get(P);if(Ae.__renderTarget=v,!ge.__hasExternalTextures){let he=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,J,he,oe,v.depth,0,ue,q,null);else n.texImage2D(ie,ae,J,he,oe,0,ue,q,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Ae.__webglTexture,0,Nt(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,V,ie,Ae.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function gt(w,v,P){if(e.bindRenderbuffer(e.RENDERBUFFER,w),v.depthBuffer){let V=v.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=b(v.stencilBuffer,ie),ue=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Nt(v),ae,v.width,v.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Nt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,w)}else{let V=v.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],ue=s.convert(ae.format,ae.colorSpace),q=s.convert(ae.type),J=S(ae.internalFormat,ue,q,ae.normalized,ae.colorSpace);if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Nt(v),J,v.width,v.height);else if(P)e.renderbufferStorageMultisample(e.RENDERBUFFER,Nt(v),J,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,J,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ke(w,v,P){let V=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(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(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let ge=s.convert(v.depthTexture.format),Ae=s.convert(v.depthTexture.type),he;if(v.depthTexture.format===_r)he=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===xr)he=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,he,v.width,v.height,0,ge,Ae,null)}}else te(v.depthTexture,0);let ae=ie.__webglTexture,ue=Nt(v),q=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+P:e.TEXTURE_2D,J=v.depthTexture.format===xr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===_r)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else if(v.depthTexture.format===xr)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Xe(w){let v=i.get(w),P=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(V){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=V}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(P)for(let V=0;V<6;V++)ke(v.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ke(v.__webglFramebuffer[0],w,0);else ke(v.__webglFramebuffer,w,0)}else if(P){v.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[V]),v.__webglDepthbuffer[V]===void 0)v.__webglDepthbuffer[V]=e.createRenderbuffer(),gt(v.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),gt(v.__webglDepthbuffer,w,!1);else{let ie=w.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 st(w,v,P){let V=i.get(w);if(v!==void 0)we(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(P!==void 0)Xe(w)}function Ke(w){let v=w.texture,P=i.get(w),V=i.get(v);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,ue=ie.length>1;if(!ue){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=v.version,o.memory.textures++}if(ae){P.__webglFramebuffer=[];for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0){P.__webglFramebuffer[q]=[];for(let J=0;J<v.mipmaps.length;J++)P.__webglFramebuffer[q][J]=e.createFramebuffer()}else P.__webglFramebuffer[q]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){P.__webglFramebuffer=[];for(let q=0;q<v.mipmaps.length;q++)P.__webglFramebuffer[q]=e.createFramebuffer()}else P.__webglFramebuffer=e.createFramebuffer();if(ue)for(let q=0,J=ie.length;q<J;q++){let ge=i.get(ie[q]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){P.__webglMultisampledFramebuffer=e.createFramebuffer(),P.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,P.__webglMultisampledFramebuffer);for(let q=0;q<ie.length;q++){let J=ie[q];P.__webglColorRenderbuffer[q]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,P.__webglColorRenderbuffer[q]);let ge=s.convert(J.format,J.colorSpace),Ae=s.convert(J.type),he=S(J.internalFormat,ge,Ae,J.normalized,J.colorSpace,w.isXRRenderTarget===!0),oe=Nt(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,he,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+q,e.RENDERBUFFER,P.__webglColorRenderbuffer[q])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)P.__webglDepthRenderbuffer=e.createRenderbuffer(),gt(P.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(P.__webglFramebuffer[q][J],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else we(P.__webglFramebuffer[q],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);if(m(v))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ue){for(let q=0,J=ie.length;q<J;q++){let ge=ie[q],Ae=i.get(ge),he=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)he=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(he,Ae.__webglTexture),Me(he,ge),we(P.__webglFramebuffer,w,ge,e.COLOR_ATTACHMENT0+q,he,0),m(ge))E(he)}n.unbindTexture()}else{let q=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)q=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(q,V.__webglTexture),Me(q,v),v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(P.__webglFramebuffer[J],w,v,e.COLOR_ATTACHMENT0,q,J);else we(P.__webglFramebuffer,w,v,e.COLOR_ATTACHMENT0,q,0);if(m(v))E(q);n.unbindTexture()}if(w.depthBuffer)Xe(w)}function Ht(w){let v=w.textures;for(let P=0,V=v.length;P<V;P++){let ie=v[P];if(m(ie)){let ae=R(w),ue=i.get(ie).__webglTexture;n.bindTexture(ae,ue),E(ae),n.unbindTexture()}}}let _t=[],rn=[];function Lt(w){if(w.samples>0){if(L(w)===!1){let{textures:v,width:P,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ue=i.get(w),q=v.length>1;if(q)for(let ge=0;ge<v.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer);let J=w.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let ge=0;ge<v.length;ge++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(q){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ae,0)}if(e.blitFramebuffer(0,0,P,V,0,0,P,V,ie,e.NEAREST),c===!0){if(_t.length=0,rn.length=0,_t.push(e.COLOR_ATTACHMENT0+ge),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)_t.push(ae),rn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,rn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,_t)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),q)for(let ge=0;ge<v.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ae,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let v=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Nt(w){return Math.min(r.maxSamples,w.samples)}function L(w){let v=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function sn(w){let v=o.render.frame;if(u.get(w)!==v)u.set(w,v),w.update()}function nt(w,v){let{colorSpace:P,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return v;if(P!==gn&&P!==yr)if($e.getTransfer(P)===ft){if(V!==si||ie!==Gn)Ce("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",P);return v}function bt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=C,this.setTextureUnits=G,this.setTexture2D=te,this.setTexture2DArray=H,this.setTexture3D=Q,this.setTextureCube=ee,this.rebindTextures=st,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=Ht,this.updateMultisampleRenderTarget=Lt,this.setupDepthRenderbuffer=Xe,this.setupFrameBufferTexture=we,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function kA(e,t){function n(i,r=yr){let s,o=$e.getTransfer(r);if(i===Gn)return e.UNSIGNED_BYTE;if(i===Mu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===wu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===w0)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===T0)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===b0)return e.BYTE;if(i===M0)return e.SHORT;if(i===no)return e.UNSIGNED_SHORT;if(i===bu)return e.INT;if(i===$i)return e.UNSIGNED_INT;if(i===Mi)return e.FLOAT;if(i===ri)return e.HALF_FLOAT;if(i===E0)return e.ALPHA;if(i===A0)return e.RGB;if(i===si)return e.RGBA;if(i===_r)return e.DEPTH_COMPONENT;if(i===xr)return e.DEPTH_STENCIL;if(i===R0)return e.RED;if(i===Tu)return e.RED_INTEGER;if(i===vr)return e.RG;if(i===Eu)return e.RG_INTEGER;if(i===Au)return e.RGBA_INTEGER;if(i===$a||i===Za||i===Xa||i===qa)if(o===ft)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===$a)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Za)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Xa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===qa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===$a)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Za)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Xa)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===qa)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ru||i===Cu||i===Iu||i===Pu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ru)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Cu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Iu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Pu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Lu||i===Nu||i===Du||i===Ou||i===Uu||i===Ya||i===Fu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Lu||i===Nu)return o===ft?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Du)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ou)return s.COMPRESSED_R11_EAC;if(i===Uu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Ya)return s.COMPRESSED_RG11_EAC;if(i===Fu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===zu||i===ku||i===Bu||i===Gu||i===Hu||i===Vu||i===Wu||i===$u||i===Zu||i===Xu||i===qu||i===Yu||i===ju||i===Ku)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===zu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ku)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Bu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Gu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Hu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Vu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Wu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===$u)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Zu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Xu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===qu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Yu)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ju)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ku)return o===ft?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ju||i===Qu||i===eh)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Ju)return o===ft?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Qu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===eh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===th||i===nh||i===ja||i===ih)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===th)return s.COMPRESSED_RED_RGTC1_EXT;if(i===nh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ja)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ih)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===os)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var BA=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,zA=`
+}`,GA=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4278,4 +4278,4 @@ void main() {
}
-}`;class wx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new cc(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 Rn({vertexShader:FA,fragmentShader:zA,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new mt(new mo(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Tx extends Hn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new wx,p={},m=t.getContextAttributes(),E=null,R=null,S=[],b=[],T=new Ne,A=null,_=null,M=new Dt;M.viewport=new at;let F=new Dt;F.viewport=new at;let I=[M,F],O=new Mh,K=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getHandSpace()};function G(Z){let re=b.indexOf(Z.inputSource);if(re===-1)return;let se=S[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",z);for(let Z=0;Z<S.length;Z++){let re=b[Z];if(re===null)continue;b[Z]=null,S[Z].disconnect(re)}K=null,C=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Ce("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Ce("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",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",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:si,type:Gn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Ie=null,Pe=null;if(m.depth)Pe=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?xr:_r,Ie=m.stencil?os:$i;let we={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(we),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:si,type:Gn,depthTexture:new Sr(f.textureWidth,f.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],Ie=b.indexOf(se);if(Ie>=0)b[Ie]=null,S[Ie].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],Ie=b.indexOf(se);if(Ie===-1){for(let we=0;we<S.length;we++)if(we>=b.length){b.push(se),Ie=we;break}else if(b[we]===null){b[we]=se,Ie=we;break}if(Ie===-1)break}let Pe=S[Ie];if(Pe)Pe.connect(se)}}let te=new U,H=new U;function Q(Z,re,se){te.setFromMatrixPosition(re.matrixWorld),H.setFromMatrixPosition(se.matrixWorld);let Ie=te.distanceTo(H),Pe=re.projectionMatrix.elements,we=se.projectionMatrix.elements,gt=Pe[14]/(Pe[10]-1),ke=Pe[14]/(Pe[10]+1),Xe=(Pe[9]+1)/Pe[5],st=(Pe[9]-1)/Pe[5],Ke=(Pe[8]-1)/Pe[0],Ht=(we[8]+1)/we[0],_t=gt*Ke,rn=gt*Ht,Lt=Ie/(-Ke+Ht),Nt=Lt*-Ke;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Nt),Z.translateZ(Lt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Pe[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=gt+Lt,sn=ke+Lt,nt=_t-Nt,bt=rn+(Ie-Nt),w=Xe*ke/sn*L,v=st*ke/sn*L;Z.projectionMatrix.makePerspective(nt,bt,w,v,L,sn),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(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(O.near=F.near=M.near=re,O.far=F.far=M.far=se,K!==O.near||C!==O.far)i.updateRenderState({depthNear:O.near,depthFar:O.far}),K=O.near,C=O.far;O.layers.mask=Z.layers.mask|6,M.layers.mask=O.layers.mask&-5,F.layers.mask=O.layers.mask&-3;let Ie=Z.parent,Pe=O.cameras;ee(O,Ie);for(let we=0;we<Pe.length;we++)ee(Pe[we],Ie);if(Pe.length===2)Q(O,M,F);else O.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Te(Z,O,Ie)};function Te(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=pr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return O},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(Z){return p[Z]};let ve=null;function He(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Ie=!1;if(se.length!==O.cameras.length)O.cameras.length=0,Ie=!0;for(let ke=0;ke<se.length;ke++){let Xe=se[ke],st=null;if(h!==null)st=h.getViewport(Xe);else{let Ht=u.getViewSubImage(f,Xe);if(st=Ht.viewport,ke===0)e.setRenderTargetTextures(R,Ht.colorTexture,Ht.depthStencilTexture),e.setRenderTarget(R)}let Ke=I[ke];if(Ke===void 0)Ke=new Dt,Ke.layers.enable(ke),Ke.viewport=new at,I[ke]=Ke;if(Ke.matrix.fromArray(Xe.transform.matrix),Ke.matrix.decompose(Ke.position,Ke.quaternion,Ke.scale),Ke.projectionMatrix.fromArray(Xe.projectionMatrix),Ke.projectionMatrixInverse.copy(Ke.projectionMatrix).invert(),Ke.viewport.set(st.x,st.y,st.width,st.height),ke===0)O.matrix.copy(Ke.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale);if(Ie===!0)O.cameras.push(Ke)}let Pe=i.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ke=u.getDepthInformation(se[0]);if(ke&&ke.isValid&&ke.texture)x.init(ke,i.renderState)}if(Pe&&Pe.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ke=0;ke<se.length;ke++){let Xe=se[ke].camera;if(Xe){let st=p[Xe];if(!st)st=new cc,p[Xe]=st;let Ke=u.getCameraImage(Xe);st.sourceTexture=Ke}}}}for(let se=0;se<S.length;se++){let Ie=b[se],Pe=S[se];if(Ie!==null&&Pe!==void 0)Pe.update(Ie,re,c||s)}if(ve)ve(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new dx;Me.setAnimationLoop(He),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}}var kA=new Ge,Ex=new ze;Ex.set(-1,0,0,0,1,0,0,0,1);function BA(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,dh(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,S){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,S)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Yt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Yt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:S}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(kA.makeRotationFromEuler(S)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Ex);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Yt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function GA(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,b){let T=b.program;i.uniformBlockBinding(S,T)}function l(S,b){let T=r[S.id];if(T===void 0)p(S),T=u(S),r[S.id]=T,S.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(S,A);let _=t.render.frame;if(s[S.id]!==_)h(S),s[S.id]=_}function u(S){let b=f();S.__bindingPointIndex=b;let T=e.createBuffer(),{__size:A,usage:_}=S;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,T),T}function f(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){let b=r[S.id],{uniforms:T,__cache:A}=S;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=T.length;_<M;_++){let F=T[_];if(Array.isArray(F))for(let I=0,O=F.length;I<O;I++)d(F[I],_,I,A);else d(F,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(S,b,T,A){if(x(S,b,T,A)===!0){let{__offset:_,value:M}=S;if(Array.isArray(M)){let F=0;for(let I=0;I<M.length;I++){let O=M[I],K=m(O);if(g(O,S.__data,F),typeof O!=="number"&&typeof O!=="boolean"&&!O.isMatrix3&&!ArrayBuffer.isView(O))F+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else g(M,S.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,S.__data)}}function g(S,b,T){if(typeof S==="number"||typeof S==="boolean")b[0]=S;else if(S.isMatrix3)b[0]=S.elements[0],b[1]=S.elements[1],b[2]=S.elements[2],b[3]=0,b[4]=S.elements[3],b[5]=S.elements[4],b[6]=S.elements[5],b[7]=0,b[8]=S.elements[6],b[9]=S.elements[7],b[10]=S.elements[8],b[11]=0;else if(ArrayBuffer.isView(S))b.set(new S.constructor(S.buffer,S.byteOffset,b.length));else S.toArray(b,T)}function x(S,b,T,A){let _=S.value,M=b+"_"+T;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let F=A[M];if(typeof _==="number"||typeof _==="boolean"){if(F!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(F.equals(_)===!1)return F.copy(_),!0}return!1}function p(S){let b=S.uniforms,T=0,A=16;for(let M=0,F=b.length;M<F;M++){let I=Array.isArray(b[M])?b[M]:[b[M]];for(let O=0,K=I.length;O<K;O++){let C=I[O],G=Array.isArray(C.value)?C.value:[C.value];for(let X=0,z=G.length;X<z;X++){let te=G[X],H=m(te),Q=T%A,ee=Q%H.boundary,Te=Q+ee;if(T+=ee,Te!==0&&A-Te<H.storage)T+=A-Te;C.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=T,T+=H.storage}}}let _=T%A;if(_>0)T+=A-_;return S.__size=T,S.__cache={},this}function m(S){let b={boundary:0,storage:0};if(typeof S==="number"||typeof S==="boolean")b.boundary=4,b.storage=4;else if(S.isVector2)b.boundary=8,b.storage=8;else if(S.isVector3||S.isColor)b.boundary=16,b.storage=12;else if(S.isVector4)b.boundary=16,b.storage=16;else if(S.isMatrix3)b.boundary=48,b.storage=48;else if(S.isMatrix4)b.boundary=64,b.storage=64;else if(S.isTexture)Ce("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(S))b.boundary=16,b.storage=S.byteLength;else Ce("WebGLRenderer: Unsupported uniform value type.",S);return b}function E(S){let b=S.target;b.removeEventListener("dispose",E);let T=o.indexOf(b.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function R(){for(let S in r)e.deleteBuffer(r[S]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var HA=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]),ai=null;function VA(){if(ai===null)ai=new lo(HA,16,16,vr,ri),ai.name="DFG_LUT",ai.minFilter=Gt,ai.magFilter=Gt,ai.wrapS=rs,ai.wrapT=rs,ai.generateMipmaps=!1,ai.needsUpdate=!0;return ai}class kh{constructor(e={}){let{canvas:t=N0(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Gn}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Tu,wu,Mu]),p=new Set([Gn,$i,no,os,Su,bu]),m=new Uint32Array(4),E=new Int32Array(4),R=new U,S=null,b=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=kn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,F=!1,I=null,O=null,K=null,C=null;this._outputColorSpace=Zi;let G=0,X=0,z=null,te=-1,H=null,Q=new at,ee=new at,Te=null,ve=new Oe(0),He=0,{width:Me,height:Z}=t,re=1,se=null,Ie=null,Pe=new at(0,0,Me,Z),we=new at(0,0,Me,Z),gt=!1,ke=new ho,Xe=!1,st=!1,Ke=new Ge,Ht=new U,_t=new at,rn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Lt=!1;function Nt(){return z===null?re:1}let L=n;function sn(y,N){return t.getContext(y,N)}let nt,bt,w,v,P,V,ie,ae,ue,q,J,ge,Ae,he,oe,Le,De,Qe,D,ce,Y,le,_e;try{let y={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${k_}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",it,!1),L===null){if(L=sn("webgl2",y),L===null)if(sn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(y){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Ue("WebGLRenderer: "+y.message),y}function ne(){if(nt=new jT(L),nt.init(),Y=new UA(L,nt),bt=new BT(L,nt,e,Y),w=new DA(L,nt),bt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);O=L.createFramebuffer(),K=L.createFramebuffer(),C=L.createFramebuffer(),v=new QT(L),P=new yA,V=new OA(L,nt,w,P,bt,Y,v),ie=new YT(M),ae=new tM(L),le=new zT(L,ae),ue=new KT(L,ae,v,le),q=new tE(L,ue,ae,le,v),Qe=new eE(L,bt,V),oe=new GT(P),J=new vA(M,ie,nt,bt,le,oe),ge=new BA(M,P),Ae=new bA,he=new RA(nt),De=new FT(M,ie,w,q,d,a),Le=new NA(M,q,bt),_e=new GA(L,v,bt,w),D=new kT(L,nt,v),ce=new JT(L,nt,v),v.programs=J.programs,M.capabilities=bt,M.extensions=nt,M.properties=P,M.renderLists=Ae,M.shadowMap=Le,M.state=w,M.info=v}if(g!==Gn)_=new iE(g,t.width,t.height,o,i,r);let de=new Tx(M,L);this.xr=de,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let y=nt.get("WEBGL_lose_context");if(y)y.loseContext()},this.forceContextRestore=function(){let y=nt.get("WEBGL_lose_context");if(y)y.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(y){if(y===void 0)return;re=y,this.setSize(Me,Z,!1)},this.getSize=function(y){return y.set(Me,Z)},this.setSize=function(y,N,W=!0){if(de.isPresenting){Ce("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=y,Z=N,t.width=Math.floor(y*re),t.height=Math.floor(N*re),W===!0)t.style.width=y+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(y,N,W){Me=y,Z=N,re=W,t.width=Math.floor(y*W),t.height=Math.floor(N*W),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(g===Gn){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Ce("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(Q)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,N,W,k){if(y.isVector4)Pe.set(y.x,y.y,y.z,y.w);else Pe.set(y,N,W,k);w.viewport(Q.copy(Pe).multiplyScalar(re).round())},this.getScissor=function(y){return y.copy(we)},this.setScissor=function(y,N,W,k){if(y.isVector4)we.set(y.x,y.y,y.z,y.w);else we.set(y,N,W,k);w.scissor(ee.copy(we).multiplyScalar(re).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(y){w.setScissorTest(gt=y)},this.setOpaqueSort=function(y){se=y},this.setTransparentSort=function(y){Ie=y},this.getClearColor=function(y){return y.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,W=!0){let k=0;if(y){let B=!1;if(z!==null){let me=z.texture.format;B=x.has(me)}if(B){let me=z.texture.type,ye=p.has(me),pe=De.getClearColor(),Se=De.getClearAlpha(),{r:Ee,g:Ve,b:Ye}=pe;if(ye)m[0]=Ee,m[1]=Ve,m[2]=Ye,m[3]=Se,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ee,E[1]=Ve,E[2]=Ye,E[3]=Se,L.clearBufferiv(L.COLOR,0,E)}else k|=L.COLOR_BUFFER_BIT}if(N)k|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)k|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(k!==0)L.clear(k)},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(y){y.setRenderer(this),I=y},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),De.dispose(),Ae.dispose(),he.dispose(),P.dispose(),ie.dispose(),q.dispose(),le.dispose(),_e.dispose(),J.dispose(),de.dispose(),de.removeEventListener("sessionstart",nf),de.removeEventListener("sessionend",rf),ir.stop()};function Be(y){y.preventDefault(),Ks("WebGLRenderer: Context Lost."),F=!0}function dt(){Ks("WebGLRenderer: Context Restored."),F=!1;let y=v.autoReset,N=Le.enabled,W=Le.autoUpdate,k=Le.needsUpdate,B=Le.type;ne(),v.autoReset=y,Le.enabled=N,Le.autoUpdate=W,Le.needsUpdate=k,Le.type=B}function it(y){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Vn(y){let N=y.target;N.removeEventListener("dispose",Vn),ui(N)}function ui(y){_v(y),P.remove(y)}function _v(y){let N=P.get(y).programs;if(N!==void 0){if(N.forEach(function(W){J.releaseProgram(W)}),y.isShaderMaterial)J.releaseShaderCache(y)}}this.renderBufferDirect=function(y,N,W,k,B,me){if(N===null)N=rn;let ye=B.isMesh&&B.matrixWorld.determinantAffine()<0,pe=yv(y,N,W,k,B);w.setMaterial(k,ye);let Se=W.index,Ee=1;if(k.wireframe===!0){if(Se=ue.getWireframeAttribute(W),Se===void 0)return;Ee=2}let Ve=W.drawRange,Ye=W.attributes.position,be=Ve.start*Ee,rt=(Ve.start+Ve.count)*Ee;if(me!==null)be=Math.max(be,me.start*Ee),rt=Math.min(rt,(me.start+me.count)*Ee);if(Se!==null)be=Math.max(be,0),rt=Math.min(rt,Se.count);else if(Ye!==void 0&&Ye!==null)be=Math.max(be,0),rt=Math.min(rt,Ye.count);let It=rt-be;if(It<0||It===1/0)return;le.setup(B,k,pe,W,Se);let xt,ht=D;if(Se!==null)xt=ae.get(Se),ht=ce,ht.setIndex(xt);if(B.isMesh)if(k.wireframe===!0)w.setLineWidth(k.wireframeLinewidth*Nt()),ht.setMode(L.LINES);else ht.setMode(L.TRIANGLES);else if(B.isLine){let $t=k.linewidth;if($t===void 0)$t=1;if(w.setLineWidth($t*Nt()),B.isLineSegments)ht.setMode(L.LINES);else if(B.isLineLoop)ht.setMode(L.LINE_LOOP);else ht.setMode(L.LINE_STRIP)}else if(B.isPoints)ht.setMode(L.POINTS);else if(B.isSprite)ht.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:$t,_multiDrawCounts:xe,_multiDrawCount:Jt}=B,Je=Se?ae.get(Se).bytesPerElement:1,bn=P.get(k).currentProgram.getUniforms();for(let Wn=0;Wn<Jt;Wn++)bn.setValue(L,"_gl_DrawID",Wn),ht.render($t[Wn]/Je,xe[Wn])}else ht.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else if(B.isInstancedMesh)ht.renderInstances(be,It,B.count);else if(W.isInstancedBufferGeometry){let $t=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,$t);ht.renderInstances(be,It,xe)}else ht.render(be,It)};function tf(y,N,W,k){if(I!==null&&y.isNodeMaterial)I.setObject(k,y);if(Xe===!0)oe.setState(y,W,!1);if(y.transparent===!0&&y.side===An&&y.forceSinglePass===!1)y.side=Yt,y.needsUpdate=!0,Po(y,N,k),y.side=Wi,y.needsUpdate=!0,Po(y,N,k),y.side=An;else Po(y,N,k)}this.compile=function(y,N,W=null){if(W===null)W=y;if(I!==null)I.renderStart(y,N,W);if(b=he.get(W),b.init(N),A.push(b),W.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}}),y!==W)y.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}});if(b.setupLights(),I!==null)I.updateLights(b.state.lightsArray);if(st=this.localClippingEnabled,Xe=oe.init(this.clippingPlanes,st),Xe===!0)oe.setGlobalState(this.clippingPlanes,N);if(I!==null)Le.render(b.state.shadowsArray,W,N);let k=new Set;if(y.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let me=B.material;if(me)if(Array.isArray(me))for(let ye=0;ye<me.length;ye++){let pe=me[ye];tf(pe,W,N,B),k.add(pe)}else tf(me,W,N,B),k.add(me)}),b=A.pop(),I!==null)I.renderEnd();return k},this.compileAsync=function(y,N,W=null){let k=this.compile(y,N,W);return new Promise((B)=>{function me(){if(k.forEach(function(ye){let Se=P.get(ye).currentProgram;if(Se===void 0||Se.isReady())k.delete(ye)}),k.size===0){B(y);return}setTimeout(me,10)}if(nt.get("KHR_parallel_shader_compile")!==null)me();else setTimeout(me,10)})};let Ac=null;function xv(y){if(Ac)Ac(y)}function nf(){ir.stop()}function rf(){ir.start()}let ir=new dx;if(ir.setAnimationLoop(xv),typeof self<"u")ir.setContext(self);this.setAnimationLoop=function(y){Ac=y,de.setAnimationLoop(y),y===null?ir.stop():ir.start()},de.addEventListener("sessionstart",nf),de.addEventListener("sessionend",rf),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;if(I!==null)I.renderStart(y,N);let W=de.enabled===!0&&de.isPresenting===!0,k=_!==null&&(z===null||W)&&_.begin(M,z);if(y.matrixWorldAutoUpdate===!0)y.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(de.enabled===!0&&de.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(de.cameraAutoUpdate===!0)de.updateCamera(N);N=de.getCamera()}if(y.isScene===!0)y.onBeforeRender(M,y,N,z);if(b=he.get(y,A.length),b.init(N),b.state.textureUnits=V.getTextureUnits(),A.push(b),Ke.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ke.setFromProjectionMatrix(Ke,ah,N.reversedDepth),st=this.localClippingEnabled,Xe=oe.init(this.clippingPlanes,st),S=Ae.get(y,T.length),S.init(),T.push(S),de.enabled===!0&&de.isPresenting===!0){let ye=M.xr.getDepthSensingMesh();if(ye!==null)Rc(ye,N,-1/0,M.sortObjects)}if(Rc(y,N,0,M.sortObjects),S.finish(),I!==null)I.updateLights(b.state.lightsArray);if(M.sortObjects===!0)S.sort(se,Ie);if(Lt=de.enabled===!1||de.isPresenting===!1||de.hasDepthSensing()===!1,Lt)De.addToRenderList(S,y);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Xe===!0)oe.beginShadows();let B=b.state.shadowsArray;if(Le.render(B,y,N),Xe===!0)oe.endShadows();if((k&&_.hasRenderPass())===!1){let ye=S.opaque,pe=S.transmissive;if(b.setupLights(),N.isArrayCamera){let Se=N.cameras;if(pe.length>0)for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee];of(ye,pe,y,Ye)}if(Lt)De.render(y);for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee];sf(S,y,Ye,Ye.viewport)}}else{if(pe.length>0)of(ye,pe,y,N);if(Lt)De.render(y);sf(S,y,N)}}if(z!==null&&X===0)V.updateMultisampleRenderTarget(z),V.updateRenderTargetMipmap(z);if(k)_.end(M);if(y.isScene===!0)y.onAfterRender(M,y,N);if(le.resetDefaultState(),te=-1,H=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Xe===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(T.pop(),T.length>0)S=T[T.length-1];else S=null;if(I!==null)I.renderEnd()};function Rc(y,N,W,k){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)W=y.renderOrder;else if(y.isLOD){if(y.autoUpdate===!0)y.update(N)}else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight){if(b.pushLight(y),y.castShadow)b.pushShadow(y)}else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(ke)){if(k)_t.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ke);let ye=q.update(y),pe=y.material;if(pe.visible)S.push(y,ye,pe,W,_t.z,null,N)}}else if(y.isMesh||y.isLine||y.isPoints){if(!y.frustumCulled||y.intersectsFrustum(ke)){let ye=q.update(y),pe=y.material;if(k){if(y.boundingSphere!==void 0){if(y.boundingSphere===null)y.computeBoundingSphere();_t.copy(y.boundingSphere.center)}else{if(ye.boundingSphere===null)ye.computeBoundingSphere();_t.copy(ye.boundingSphere.center)}_t.applyMatrix4(y.matrixWorld).applyMatrix4(Ke)}if(Array.isArray(pe)){let Se=ye.groups;for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee],be=pe[Ye.materialIndex];if(be&&be.visible)S.push(y,ye,be,W,_t.z,Ye,N)}}else if(pe.visible)S.push(y,ye,pe,W,_t.z,null,N)}}}let me=y.children;for(let ye=0,pe=me.length;ye<pe;ye++)Rc(me[ye],N,W,k)}function sf(y,N,W,k){let{opaque:B,transmissive:me,transparent:ye}=y;if(b.setupLightsView(W),Xe===!0)oe.setGlobalState(M.clippingPlanes,W);if(k)w.viewport(Q.copy(k));if(B.length>0)Io(B,N,W);if(me.length>0)Io(me,N,W);if(ye.length>0)Io(ye,N,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function of(y,N,W,k){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new _n(1,1,{generateMipmaps:!0,type:be?ri:Gn,minFilter:ii,samples:Math.max(4,bt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let me=b.state.transmissionRenderTarget[k.id],ye=k.viewport||Q;me.setSize(ye.z*M.transmissionResolutionScale,ye.w*M.transmissionResolutionScale);let pe=M.getRenderTarget(),Se=M.getActiveCubeFace(),Ee=M.getActiveMipmapLevel();if(M.setRenderTarget(me),M.getClearColor(ve),He=M.getClearAlpha(),He<1)M.setClearColor(16777215,0.5);if(M.clear(),Lt)De.render(W);let Ve=M.toneMapping;M.toneMapping=kn;let Ye=k.viewport;if(k.viewport!==void 0)k.viewport=void 0;if(b.setupLightsView(k),Xe===!0)oe.setGlobalState(M.clippingPlanes,k);if(Io(y,W,k),V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me),nt.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let rt=0,It=N.length;rt<It;rt++){let xt=N[rt],{object:ht,geometry:$t,material:xe,group:Jt}=xt;if(xe.side===An&&ht.layers.test(k.layers)){let Je=xe.side;xe.side=Yt,xe.needsUpdate=!0,af(ht,W,k,$t,xe,Jt),xe.side=Je,xe.needsUpdate=!0,be=!0}}if(be===!0)V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me)}if(M.setRenderTarget(pe,Se,Ee),M.setClearColor(ve,He),Ye!==void 0)k.viewport=Ye;M.toneMapping=Ve}function Io(y,N,W){let k=N.isScene===!0?N.overrideMaterial:null;for(let B=0,me=y.length;B<me;B++){let ye=y[B],{object:pe,geometry:Se,group:Ee}=ye,Ve=ye.material;if(Ve.allowOverride===!0&&k!==null)Ve=k;if(pe.layers.test(W.layers))af(pe,N,W,Se,Ve,Ee)}}function af(y,N,W,k,B,me){if(I!==null&&B.isNodeMaterial)I.setObject(y,B);if(y.onBeforeRender(M,N,W,k,B,me),y.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),B.onBeforeRender(M,N,W,k,y,me),B.transparent===!0&&B.side===An&&B.forceSinglePass===!1)B.side=Yt,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=Wi,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=An;else M.renderBufferDirect(W,N,k,B,y,me);y.onAfterRender(M,N,W,k,B,me)}function Po(y,N,W){if(N.isScene!==!0)N=rn;let k=P.get(y),B=b.state.lights,me=b.state.shadowsArray,ye=B.state.version,pe=J.getParameters(y,B.state,me,N,W,b.state.lightProbeGridArray),Se=J.getProgramCacheKey(pe),Ee=k.programs;k.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,k.fog=N.fog;let Ve=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;if(k.envMap=ie.get(y.envMap||k.environment,Ve),k.envMapRotation=k.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Ee===void 0)y.addEventListener("dispose",Vn),Ee=new Map,k.programs=Ee;let Ye=Ee.get(Se);if(Ye!==void 0){if(k.currentProgram===Ye&&k.lightsStateVersion===ye)return lf(y,pe),Ye}else{if(pe.uniforms=J.getUniforms(y),I!==null&&y.isNodeMaterial)I.build(y,W,pe);y.onBeforeCompile(pe,M),Ye=J.acquireProgram(pe,Se),Ee.set(Se,Ye),k.uniforms=pe.uniforms}let be=k.uniforms;if(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)be.clippingPlanes=oe.uniform;if(lf(y,pe),k.needsLights=bv(y),k.lightsStateVersion=ye,k.needsLights)be.ambientLightColor.value=B.state.ambient,be.lightProbe.value=B.state.probe,be.sunLights.value=B.state.sun,be.sunLightShadows.value=B.state.sunShadow,be.directionalLights.value=B.state.directional,be.directionalLightShadows.value=B.state.directionalShadow,be.spotLights.value=B.state.spot,be.spotLightShadows.value=B.state.spotShadow,be.rectAreaLights.value=B.state.rectArea,be.ltc_1.value=B.state.rectAreaLTC1,be.ltc_2.value=B.state.rectAreaLTC2,be.pointLights.value=B.state.point,be.pointLightShadows.value=B.state.pointShadow,be.hemisphereLights.value=B.state.hemi,be.sunShadowMatrix.value=B.state.sunShadowMatrix,be.sunShadowCascade.value=B.state.sunShadowCascade,be.directionalShadowMatrix.value=B.state.directionalShadowMatrix,be.spotLightMatrix.value=B.state.spotLightMatrix,be.spotLightMap.value=B.state.spotLightMap,be.pointShadowMatrix.value=B.state.pointShadowMatrix;return k.lightProbeGrid=b.state.lightProbeGridArray.length>0,k.currentProgram=Ye,k.uniformsList=null,Ye}function cf(y){if(y.uniformsList===null){let N=y.currentProgram.getUniforms();y.uniformsList=Mo.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function lf(y,N){let W=P.get(y);W.outputColorSpace=N.outputColorSpace,W.batching=N.batching,W.batchingColor=N.batchingColor,W.instancing=N.instancing,W.instancingColor=N.instancingColor,W.instancingMorph=N.instancingMorph,W.skinning=N.skinning,W.morphTargets=N.morphTargets,W.morphNormals=N.morphNormals,W.morphColors=N.morphColors,W.morphTargetsCount=N.morphTargetsCount,W.numClippingPlanes=N.numClippingPlanes,W.numIntersection=N.numClipIntersection,W.vertexAlphas=N.vertexAlphas,W.vertexTangents=N.vertexTangents,W.toneMapping=N.toneMapping}function vv(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let W=0,k=y.length;W<k;W++){let B=y[W];if(B.texture!==null&&B.boundingBox.containsPoint(R))return B}return null}function yv(y,N,W,k,B){if(N.isScene!==!0)N=rn;V.resetTextureUnits();let me=N.fog,ye=k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial?N.environment:null,pe=z===null?M.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:$e.workingColorSpace,Se=k.isMeshStandardMaterial||k.isMeshLambertMaterial&&!k.envMap||k.isMeshPhongMaterial&&!k.envMap,Ee=ie.get(k.envMap||ye,Se),Ve=k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ye=!!W.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),be=!!W.morphAttributes.position,rt=!!W.morphAttributes.normal,It=!!W.morphAttributes.color,xt=kn;if(k.toneMapped){if(z===null||z.isXRRenderTarget===!0)xt=M.toneMapping}let ht=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,$t=ht!==void 0?ht.length:0,xe=P.get(k),Jt=b.state.lights;if(Xe===!0){if(st===!0||y!==H){let pt=y===H&&k.id===te;oe.setState(k,y,pt)}}let Je=!1;if(k.version===xe.__version){if(xe.needsLights&&xe.lightsStateVersion!==Jt.state.version)Je=!0;else if(xe.outputColorSpace!==pe)Je=!0;else if(B.isBatchedMesh&&xe.batching===!1)Je=!0;else if(!B.isBatchedMesh&&xe.batching===!0)Je=!0;else if(B.isBatchedMesh&&xe.batchingColor===!0&&B._colorsTexture===null)Je=!0;else if(B.isBatchedMesh&&xe.batchingColor===!1&&B._colorsTexture!==null)Je=!0;else if(B.isInstancedMesh&&xe.instancing===!1)Je=!0;else if(!B.isInstancedMesh&&xe.instancing===!0)Je=!0;else if(B.isSkinnedMesh&&xe.skinning===!1)Je=!0;else if(!B.isSkinnedMesh&&xe.skinning===!0)Je=!0;else if(B.isInstancedMesh&&xe.instancingColor===!0&&B.instanceColor===null)Je=!0;else if(B.isInstancedMesh&&xe.instancingColor===!1&&B.instanceColor!==null)Je=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!0&&B.morphTexture===null)Je=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!1&&B.morphTexture!==null)Je=!0;else if(xe.envMap!==Ee)Je=!0;else if(k.fog===!0&&xe.fog!==me)Je=!0;else if(xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==oe.numPlanes||xe.numIntersection!==oe.numIntersection))Je=!0;else if(xe.vertexAlphas!==Ve)Je=!0;else if(xe.vertexTangents!==Ye)Je=!0;else if(xe.morphTargets!==be)Je=!0;else if(xe.morphNormals!==rt)Je=!0;else if(xe.morphColors!==It)Je=!0;else if(xe.toneMapping!==xt)Je=!0;else if(xe.morphTargetsCount!==$t)Je=!0;else if(!!xe.lightProbeGrid!==b.state.lightProbeGridArray.length>0)Je=!0}else Je=!0,xe.__version=k.version;let bn=xe.currentProgram;if(Je===!0){if(bn=Po(k,N,B),I&&k.isNodeMaterial)I.onUpdateProgram(k,bn,xe)}let Wn=!1,Ai=!1,Pr=!1,lt=bn.getUniforms(),At=xe.uniforms;if(w.useProgram(bn.program))Wn=!0,Ai=!0,Pr=!0;if(k.id!==te)te=k.id,Ai=!0;if(xe.needsLights){let pt=vv(b.state.lightProbeGridArray,B);if(xe.lightProbeGrid!==pt)xe.lightProbeGrid=pt,Ai=!0}if(Wn||H!==y){if(w.buffers.depth.getReversed()&&y.reversedDepth!==!0)y._reversedDepth=!0,y.updateProjectionMatrix();lt.setValue(L,"projectionMatrix",y.projectionMatrix),lt.setValue(L,"viewMatrix",y.matrixWorldInverse);let Ci=lt.map.cameraPosition;if(Ci!==void 0)Ci.setValue(L,Ht.setFromMatrixPosition(y.matrixWorld));if(bt.logarithmicDepthBuffer)lt.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2));if(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)lt.setValue(L,"isOrthographic",y.isOrthographicCamera===!0);if(H!==y)H=y,Ai=!0,Pr=!0}if(xe.needsLights){if(Jt.state.sunShadowMap.length>0)lt.setValue(L,"sunShadowMap",Jt.state.sunShadowMap,V);if(Jt.state.directionalShadowMap.length>0)lt.setValue(L,"directionalShadowMap",Jt.state.directionalShadowMap,V);if(Jt.state.spotShadowMap.length>0)lt.setValue(L,"spotShadowMap",Jt.state.spotShadowMap,V);if(Jt.state.pointShadowMap.length>0)lt.setValue(L,"pointShadowMap",Jt.state.pointShadowMap,V)}if(B.isSkinnedMesh){lt.setOptional(L,B,"bindMatrix"),lt.setOptional(L,B,"bindMatrixInverse");let pt=B.skeleton;if(pt){if(pt.boneTexture===null)pt.computeBoneTexture();lt.setValue(L,"boneTexture",pt.boneTexture,V)}}if(B.isBatchedMesh){if(lt.setOptional(L,B,"batchingTexture"),lt.setValue(L,"batchingTexture",B._matricesTexture,V),lt.setOptional(L,B,"batchingIdTexture"),lt.setValue(L,"batchingIdTexture",B._indirectTexture,V),lt.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null)lt.setValue(L,"batchingColorTexture",B._colorsTexture,V)}let Ri=W.morphAttributes;if(Ri.position!==void 0||Ri.normal!==void 0||Ri.color!==void 0)Qe.update(B,W,bn);if(Ai||xe.receiveShadow!==B.receiveShadow)xe.receiveShadow=B.receiveShadow,lt.setValue(L,"receiveShadow",B.receiveShadow);if((k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&N.environment!==null)At.envMapIntensity.value=N.environmentIntensity;if(At.dfgLUT!==void 0)At.dfgLUT.value=VA();if(Ai){if(lt.setValue(L,"toneMappingExposure",M.toneMappingExposure),xe.needsLights)Sv(At,Pr);if(me&&k.fog===!0)ge.refreshFogUniforms(At,me);if(ge.refreshMaterialUniforms(At,k,re,Z,b.state.transmissionRenderTarget[y.id]),xe.needsLights&&xe.lightProbeGrid){let pt=xe.lightProbeGrid;At.probesSH.value=pt.texture,At.probesMin.value.copy(pt.boundingBox.min),At.probesMax.value.copy(pt.boundingBox.max),At.probesResolution.value.copy(pt.resolution)}Mo.upload(L,cf(xe),At,V)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0)Mo.upload(L,cf(xe),At,V),k.uniformsNeedUpdate=!1;if(k.isSpriteMaterial)lt.setValue(L,"center",B.center);if(lt.setValue(L,"modelViewMatrix",B.modelViewMatrix),lt.setValue(L,"normalMatrix",B.normalMatrix),lt.setValue(L,"modelMatrix",B.matrixWorld),k.uniformsGroups!==void 0){let pt=k.uniformsGroups;for(let Ci=0,Lr=pt.length;Ci<Lr;Ci++){let hf=pt[Ci];_e.update(hf,bn),_e.bind(hf,bn)}}return bn}function Sv(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.sunLights.needsUpdate=N,y.sunLightShadows.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function bv(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(y,N,W){let k=P.get(y);if(k.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1)k.__useRenderToTexture=!1;P.get(y.texture).__webglTexture=N,P.get(y.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:W,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){let W=P.get(y);W.__webglFramebuffer=N,W.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,W=0){z=y,G=N,X=W;let k=null,B=!1,me=!1;if(y){let pe=P.get(y);if(pe.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest,w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),te=-1;return}else if(pe.__webglFramebuffer===void 0)V.setupRenderTarget(y);else if(pe.__hasExternalTextures)V.rebindTextures(y,P.get(y.texture).__webglTexture,P.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let Ve=y.depthTexture;if(pe.__boundDepthTexture!==Ve){if(Ve!==null&&P.has(Ve)&&(y.width!==Ve.image.width||y.height!==Ve.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(y)}}let Se=y.texture;if(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)me=!0;let Ee=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget){if(Array.isArray(Ee[N]))k=Ee[N][W];else k=Ee[N];B=!0}else if(y.samples>0&&V.useMultisampledRTT(y)===!1)k=P.get(y).__webglMultisampledFramebuffer;else if(Array.isArray(Ee))k=Ee[W];else k=Ee;Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest}else Q.copy(Pe).multiplyScalar(re).floor(),ee.copy(we).multiplyScalar(re).floor(),Te=gt;if(W!==0)k=O;if(w.bindFramebuffer(L.FRAMEBUFFER,k))w.drawBuffers(y,k);if(w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),B){let pe=P.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,W)}else if(me){let pe=N;for(let Se=0;Se<y.textures.length;Se++){let Ee=P.get(y.textures[Se]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Se,Ee.__webglTexture,W,pe)}}else if(y!==null&&W!==0){let pe=P.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,W)}te=-1};function uf(y){let N=P.get(y);if(N.__readFormat!==y.format||N.__readType!==y.type)N.__readFormat=y.format,N.__readType=y.type,N.__formatReadable=bt.textureFormatReadable(y.format),N.__typeReadable=bt.textureTypeReadable(y.type);return N}if(this.readRenderTargetPixels=function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se){w.bindFramebuffer(L.FRAMEBUFFER,Se);try{let Ee=y.textures[pe],{format:Ve,type:Ye}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=uf(Ee);if(be.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B))L.readPixels(N,W,k,B,Y.convert(Ve),Y.convert(Ye),me)}finally{let Ee=z!==null?P.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se)if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B)){w.bindFramebuffer(L.FRAMEBUFFER,Se);let Ee=y.textures[pe],{format:Ve,type:Ye}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=uf(Ee);if(be.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,rt),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,W,k,B,Y.convert(Ve),Y.convert(Ye),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let It=z!==null?P.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,It);let xt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await O0(L,xt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,rt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(rt),L.deleteSync(xt),me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,W=0){let k=Math.pow(2,-W),B=Math.floor(y.image.width*k),me=Math.floor(y.image.height*k),ye=N!==null?N.x:0,pe=N!==null?N.y:0;V.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,W,0,0,ye,pe,B,me),w.unbindTexture()},this.copyTextureToTexture=function(y,N,W=null,k=null,B=0,me=0){let ye,pe,Se,Ee,Ve,Ye,be,rt,It,xt=y.isCompressedTexture?y.mipmaps[me]:y.image;if(W!==null)ye=W.max.x-W.min.x,pe=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,Ee=W.min.x,Ve=W.min.y,Ye=W.isBox3?W.min.z:0;else{let At=Math.pow(2,-B);if(ye=Math.floor(xt.width*At),pe=Math.floor(xt.height*At),y.isDataArrayTexture)Se=xt.depth;else if(y.isData3DTexture)Se=Math.floor(xt.depth*At);else Se=1;Ee=0,Ve=0,Ye=0}if(k!==null)be=k.x,rt=k.y,It=k.z;else be=0,rt=0,It=0;let ht=Y.convert(N.format),$t=Y.convert(N.type),xe;if(N.isData3DTexture)V.setTexture3D(N,0),xe=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)V.setTexture2DArray(N,0),xe=L.TEXTURE_2D_ARRAY;else V.setTexture2D(N,0),xe=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let Jt=w.getParameter(L.UNPACK_ROW_LENGTH),Je=w.getParameter(L.UNPACK_IMAGE_HEIGHT),bn=w.getParameter(L.UNPACK_SKIP_PIXELS),Wn=w.getParameter(L.UNPACK_SKIP_ROWS),Ai=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,xt.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,xt.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ee),w.pixelStorei(L.UNPACK_SKIP_ROWS,Ve),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ye);let Pr=y.isDataArrayTexture||y.isData3DTexture,lt=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){let At=P.get(y),Ri=P.get(N),pt=P.get(At.__renderTarget),Ci=P.get(Ri.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,pt.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Ci.__webglFramebuffer);for(let Lr=0;Lr<Se;Lr++){if(Pr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(y).__webglTexture,B,Ye+Lr),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(N).__webglTexture,me,It+Lr);L.blitFramebuffer(Ee,Ve,ye,pe,be,rt,ye,pe,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||y.isRenderTargetTexture||P.has(y)){let At=P.get(y),Ri=P.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,K),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,C);for(let pt=0;pt<Se;pt++){if(Pr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,At.__webglTexture,B,Ye+pt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,At.__webglTexture,B);if(lt)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ri.__webglTexture,me,It+pt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ri.__webglTexture,me);if(B!==0)L.blitFramebuffer(Ee,Ve,ye,pe,be,rt,ye,pe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(lt)L.copyTexSubImage3D(xe,me,be,rt,It+pt,Ee,Ve,ye,pe);else L.copyTexSubImage2D(xe,me,be,rt,Ee,Ve,ye,pe)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(lt)if(y.isDataTexture||y.isData3DTexture)L.texSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,$t,xt.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,xt.data);else L.texSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,$t,xt);else if(y.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,me,be,rt,ye,pe,ht,$t,xt.data);else if(y.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,me,be,rt,xt.width,xt.height,ht,xt.data);else L.texSubImage2D(L.TEXTURE_2D,me,be,rt,ye,pe,ht,$t,xt);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,Jt),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Je),w.pixelStorei(L.UNPACK_SKIP_PIXELS,bn),w.pixelStorei(L.UNPACK_SKIP_ROWS,Wn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ai),me===0&&N.generateMipmaps)L.generateMipmap(xe);w.unbindTexture()},this.initRenderTarget=function(y){if(P.get(y).__webglFramebuffer===void 0)V.setupRenderTarget(y)},this.initTexture=function(y){if(y.isCubeTexture)V.setTextureCube(y,0);else if(y.isData3DTexture)V.setTexture3D(y,0);else if(y.isDataArrayTexture||y.isCompressedArrayTexture)V.setTexture2DArray(y,0);else V.setTexture2D(y,0);w.unbindTexture()},this.resetState=function(){G=0,X=0,z=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ah}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}function Bh(e,t){if(t===ih)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===as||t===io){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===as)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 Ax(e){let t=new Map,n=new Map,i=e.clone();return Rx(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 Rx(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)Rx(e.children[i],t.children[i],n)}class Xh extends Ei{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ux(t)}),this.register(function(t){return new Fx(t)}),this.register(function(t){return new Zx(t)}),this.register(function(t){return new Xx(t)}),this.register(function(t){return new qx(t)}),this.register(function(t){return new kx(t)}),this.register(function(t){return new Bx(t)}),this.register(function(t){return new Gx(t)}),this.register(function(t){return new Hx(t)}),this.register(function(t){return new Ox(t)}),this.register(function(t){return new Vx(t)}),this.register(function(t){return new zx(t)}),this.register(function(t){return new $x(t)}),this.register(function(t){return new Wx(t)}),this.register(function(t){return new Nx(t)}),this.register(function(t){return new Wh(t,qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Wh(t,qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Yx(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=er.extractUrlBase(e);s=er.resolveURL(c,this.path)}else s=er.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 _o(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))===jx){try{s[qe.KHR_BINARY_GLTF]=new Kx(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new nv(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case qe.KHR_MATERIALS_UNLIT:s[u]=new Dx;break;case qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Jx(r,this.dracoLoader);break;case qe.KHR_TEXTURE_TRANSFORM:s[u]=new Qx;break;case qe.KHR_MESH_QUANTIZATION:s[u]=new ev;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function $A(){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 Ct(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Nx{constructor(e){this.parser=e,this.name=qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new ps(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ds(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),li(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 Dx{constructor(){this.name=qe.KHR_MATERIALS_UNLIT}getMaterialType(){return oi}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Zi))}return Promise.all(i)}}class Ox{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class Ux{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class Fx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class zx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 kx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Zi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Bx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Gx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class Hx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_IOR}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Vx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Zi));return Promise.all(i)}}class Wx{constructor(e){this.parser=e,this.name=qe.EXT_MATERIALS_BUMP}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 $x{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Zx{constructor(e){this.parser=e,this.name=qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Xx{constructor(e){this.parser=e,this.name=qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class qx{constructor(e){this.parser=e,this.name=qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Wh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Yx{constructor(e){this.name=qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Cn.TRIANGLES&&c.mode!==Cn.TRIANGLE_STRIP&&c.mode!==Cn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new U,p=new kt,m=new U(1,1,1),E=new us(d.geometry,d.material,f);for(let S=0;S<f;S++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,S);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,S);if(a.SCALE)m.fromBufferAttribute(a.SCALE,S);E.setMatrixAt(S,g.compose(x,p,m))}let R=null;for(let S in a)if(S==="_COLOR_0"){let b=a[S];E.instanceColor=new Gi(b.array,b.itemSize,b.normalized)}else if(S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"){if(R===null){let T=E.geometry;R=new jt,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let b=a[S];R.setAttribute(S,new Gi(b.array,b.itemSize,b.normalized))}ut.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var jx="glTF",To=12,Cx={JSON:1313821514,BIN:5130562};class Kx{constructor(e){this.name=qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,To),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!==jx)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-To,r=new DataView(e,To),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===Cx.JSON){let c=new Uint8Array(e,To+s,o);this.content=n.decode(c)}else if(a===Cx.BIN){let c=To+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Jx{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=$h[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=$h[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=xs[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class Qx{constructor(){this.name=qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class ev{constructor(){this.name=qe.KHR_MESH_QUANTIZATION}}class qh extends Ti{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let S=s[g+R+o],b=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*S+E*b+x*T+p*A}return r}}var ZA=new kt;class tv extends qh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return ZA.fromArray(r).normalize().toArray(r),r}}var Cn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},xs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ix={9728:Bn,9729:Gt,9984:Wa,9985:ss,9986:gr,9987:ii},Px={33071:rs,33648:Va,10497:is},Gh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$h={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"},tr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},XA={CUBICSPLINE:void 0,LINEAR:Ka,STEP:nh},Hh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function qA(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new wi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wi});return e.DefaultMaterial}function Er(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 li(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 YA(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function jA(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 KA(e){let t,n=e.extensions&&e.extensions[qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Vh(n.attributes);else t=e.indices+":"+Vh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Vh(e.targets[i]);return t}function Vh(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 Zh(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 JA(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 QA=new Ge;class nv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new $A,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 fc(this.options.manager);else this.textureLoader=new gc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _o(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 Er(r,o,i),li(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(er.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=Gh[i.type],o=xs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Bt(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=Gh[i.type],c=xs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new ao(g,h/l),t.cache.add(m,E);x=new ls(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Bt(g,a,d)}if(i.sparse!==void 0){let p=Gh.SCALAR,m=xs[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,S=new m(s[1],E,i.sparse.count*p),b=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Bt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=S.length;T<A;T++){let _=S[T];if(x.setX(_,b[T*a]),a>=2)x.setY(_,b[T*a+1]);if(a>=3)x.setZ(_,b[T*a+2]);if(a>=4)x.setW(_,b[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=Ix[f.magFilter]||Gt,l.minFilter=Ix[f.minFilter]||ii,l.wrapS=Px[f.wrapS]||is,l.wrapT=Px[f.wrapT]||is,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Bn&&l.minFilter!==Gt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new Et(g);x.needsUpdate=!0,f(x)};t.load(er.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return li(u,s),u.userData.mimeType=s.mimeType||JA(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new po,cn.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 fo,cn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return wi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[qe.KHR_MATERIALS_UNLIT]){let u=i[qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Zi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=An;let l=r.alphaMode||Hh.OPAQUE;if(l===Hh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Hh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==oi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==oi){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!==oi){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==oi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Zi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(li(u,r),t.associations.set(u,{materials:e}),r.extensions)Er(i,u,r);return u})}createUniqueName(e){let t=et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return Lx(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=KA(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[qe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=Lx(new jt,c,t);if(c.mode===Cn.TRIANGLE_STRIP)f=f.then((h)=>Bh(h,io));else if(c.mode===Cn.TRIANGLE_FAN)f=f.then((h)=>Bh(h,as));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?qA(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===Cn.TRIANGLES||x.mode===Cn.TRIANGLE_STRIP||x.mode===Cn.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new rc(g,m):new mt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===Cn.LINES)p=new sc(g,m);else if(x.mode===Cn.LINE_STRIP)p=new qi(g,m);else if(x.mode===Cn.LINE_LOOP)p=new oc(g,m);else if(x.mode===Cn.POINTS)p=new hs(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)jA(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),li(p,r),x.extensions)Er(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Er(i,u[0],r);return u[0]}let f=new Qn;if(r.extensions)Er(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Dt(ro.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new wr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return li(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new uo(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let S=f[E],b=h[E],T=d[E],A=g[E],_=x[E];if(S===void 0)continue;if(S.updateMatrix)S.updateMatrix();let M=n._createAnimationTracks(S,b,T,A,_);if(M)for(let F=0;F<M.length;F++)p.push(M[F])}let m=new Qr(r,void 0,p);return li(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,QA)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new co;else if(c.length>1)l=new Qn;else if(c.length===1)l=c[0];else l=new ut;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(li(l,r),r.extensions)Er(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new Qn;if(n.name)r.name=i.createUniqueName(n.name);if(li(r,n),n.extensions)Er(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(Ax(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof cn||f instanceof Et)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(tr[r.path]===tr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(tr[r.path]){case tr.weights:l=Ki;break;case tr.rotation:l=Ji;break;case tr.translation:case tr.scale:l=Mr;break;default:switch(n.itemSize){case 1:l=Ki;break;case 2:case 3:default:l=Mr;break}break}let u=i.interpolation!==void 0?XA[i.interpolation]:Ka,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+tr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Zh(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 Ji?tv:qh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function e1(e,t,n){let i=t.attributes,r=new nn;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=Zh(xs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=Zh(xs[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function Lx(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=$h[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return li(e,t),e1(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?YA(e,t.targets,n):e})}var iv={type:"change"},jh={type:"start"},sv={type:"end"},Mc=new Xi,rv=new Tn,t1=Math.cos(70*ro.DEG2RAD),Ft=new U,ln=2*Math.PI,ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yh=0.000001;class Kh extends xc{constructor(e,t=null){super(e,t);if(this.state=ct.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:Hi.ROTATE,MIDDLE:Hi.DOLLY,RIGHT:Hi.PAN},this.touches={ONE:Vi.ROTATE,TWO:Vi.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 kt,this._lastTargetPosition=new U,this._quat=new kt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new vo,this._sphericalDelta=new vo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new U,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=i1.bind(this),this._onPointerDown=n1.bind(this),this._onPointerUp=r1.bind(this),this._onContextMenu=h1.bind(this),this._onMouseWheel=a1.bind(this),this._onKeyDown=c1.bind(this),this._onTouchStart=l1.bind(this),this._onTouchMove=u1.bind(this),this._onMouseDown=s1.bind(this),this._onMouseMove=o1.bind(this),this._interceptControlDown=f1.bind(this),this._interceptControlUp=d1.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ct.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(iv),this.update(),this.state=ct.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Ft.copy(t).sub(this.target),Ft.applyQuaternion(this._quat),this._spherical.setFromVector3(Ft),this.autoRotate&&this.state===ct.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=ln;else if(n>Math.PI)n-=ln;if(i<-Math.PI)i+=ln;else if(i>Math.PI)i-=ln;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(Ft.setFromSpherical(this._spherical),Ft.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ft),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=Ft.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=Ft.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(Mc.origin.copy(this.object.position),Mc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mc.direction))<t1)this.object.lookAt(this.target);else rv.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mc.intersectPlane(rv,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)>Yh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yh||this._lastTargetPosition.distanceToSquared(this.target)>Yh)return this.dispatchEvent(iv),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 ln/60*this.autoRotateSpeed*e;else return ln/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){Ft.setFromMatrixColumn(t,0),Ft.multiplyScalar(-e),this._panOffset.add(Ft)}_panUp(e,t){if(this.screenSpacePanning===!0)Ft.setFromMatrixColumn(t,1);else Ft.setFromMatrixColumn(t,0),Ft.crossVectors(this.object.up,Ft);Ft.multiplyScalar(e),this._panOffset.add(Ft)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Ft.copy(i).sub(this.target);let r=Ft.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(ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(ln*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(ln*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(-ln*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(ln*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(-ln*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(ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(ln*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function n1(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 i1(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function r1(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(sv),this.state=ct.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function s1(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 Hi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ct.DOLLY;break;case Hi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}break;case Hi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(jh)}function o1(e){switch(this.state){case ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function a1(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==ct.NONE)return;e.preventDefault(),this.dispatchEvent(jh),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(sv)}function c1(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function l1(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Vi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ct.TOUCH_ROTATE;break;case Vi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ct.TOUCH_PAN;break;default:this.state=ct.NONE}break;case 2:switch(this.touches.TWO){case Vi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ct.TOUCH_DOLLY_PAN;break;case Vi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ct.TOUCH_DOLLY_ROTATE;break;default:this.state=ct.NONE}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(jh)}function u1(e){switch(this._trackPointer(e),this.state){case ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ct.NONE}}function h1(e){if(this.enabled===!1)return;e.preventDefault()}function f1(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function d1(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Jh extends cs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Yi;e.deleteAttribute("uv");let t=new wi({side:Yt}),n=new wi,i=new ds(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 us(e,n,6),o=new ut;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new 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 f=new mt(e,vs(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new mt(e,vs(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 vs(e){return new lc({color:0,emissive:16777215,emissiveIntensity:e})}function ov(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 E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let S of[E.min.y,E.max.y])for(let b of[E.min.z,E.max.z])l.push(new U(R,S,b));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),S=R.dot(a),b=R.dot(c);u=Math.min(u,S),f=Math.max(f,S),h=Math.min(h,b),d=Math.max(d,b)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),S=R.dot(o);p=Math.max(p,S+Math.abs(R.dot(a))*1.12/x,S+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function av(e){let t=new kh({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=eo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new cs,i=new Dt(40,1,0.01,1000),r=new Kh(i,t.domElement);r.enableDamping=!0;let s=new wo(t),o=new Jh,a=s.fromScene(o,0.04);n.environment=a.texture,o.dispose(),s.dispose();let c=new ps(16773591,2.4);c.position.set(4,8,5),n.add(c),n.add(new dc(14806490,5065021,1.7));let l,u,f=[],h=!0,d=performance.now(),g=0,x=0,p=!1,m=(b)=>{let T=new Set,A=new Set,_=new Set;b.traverse((M)=>{let F=M;if(!F.isMesh)return;T.add(F.geometry);for(let I of Array.isArray(F.material)?F.material:[F.material]){A.add(I);for(let O of Object.values(I))if(O instanceof Et)_.add(O)}});for(let M of[...T,...A,..._])M.dispose()},E=()=>{if(!l)return;let b=new nn().setFromObject(l,!0),T=[];l.traverse((I)=>{if(I instanceof mt||I instanceof qi||I instanceof hs){let O=new nn().setFromObject(I,!0);if(!O.isEmpty())T.push(O)}});let{center:A,radius:_,distance:M,position:F}=ov(b,i.aspect,i.fov,T);r.target.copy(A),i.position.copy(F),i.near=Math.max(_/1000,0.0001),i.far=M+_*100,r.minDistance=_*0.1,r.maxDistance=_*80,i.updateProjectionMatrix(),r.update()},R=new ResizeObserver(()=>{let{clientWidth:b,clientHeight:T}=e;if(!b||!T)return;t.setSize(b,T),i.aspect=b/T,i.updateProjectionMatrix()});R.observe(e);let S=(b)=>{if(p)return;let T=Math.min((b-d)/1000,0.1);if(d=b,h)u?.update(T);r.update(),t.render(n,i),g=requestAnimationFrame(S)};return g=requestAnimationFrame(S),{async load(b){let T=++x;Ul(b);let A=new go;A.setURLModifier((C)=>{if(!C.startsWith("blob:")&&!C.startsWith("data:"))throw Error("External model resources are not loaded");return C});let _=await new Xh(A).parseAsync(Uint8Array.from(b).buffer,"");if(p||T!==x){m(_.scene);return}if(l)u?.stopAllAction(),u?.uncacheRoot(l),n.remove(l),m(l);l=_.scene,n.add(l),f=_.animations,u=new _c(l),h=!0;let{clientWidth:M,clientHeight:F}=e;t.setSize(M,F),i.aspect=M/F,E();let I=0,O=0,K=new Set;return l.traverse((C)=>{let G=C;if(!G.isMesh)return;O++,I+=(G.geometry.index?.count??G.geometry.attributes.position?.count??0)/3*(G.isInstancedMesh?G.count:1);for(let X of Array.isArray(G.material)?G.material:[G.material])K.add(X)}),{triangles:I,meshes:O,materials:K.size,clips:f.map((C)=>C.name)}},reset:E,wire(b){l?.traverse((T)=>{let A=T;if(A.isMesh){for(let _ of Array.isArray(A.material)?A.material:[A.material])if("wireframe"in _)_.wireframe=b}})},lighting(b){t.toneMappingExposure=b==="bright"?1.65:b==="soft"?0.85:1.15,c.intensity=b==="soft"?0.8:2.4},clip(b){if(u?.stopAllAction(),f[b])u?.clipAction(f[b]).play()},pause(b){h=!b},dispose(){if(p=!0,x++,cancelAnimationFrame(g),R.disconnect(),r.dispose(),l)m(l);a.dispose(),t.dispose(),e.replaceChildren()}}}var cv=/^[a-z][a-z0-9_-]{0,79}$/u,p1=/^r_[a-z0-9_-]{1,77}$/u;function lv(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!cv.test(n)||!cv.test(i)||!p1.test(r))return;return{collection:n,assetId:i,revisionId:r}}var Fe=(e)=>document.getElementById(e),St=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},Ss=[],Cr=[],Rr=[],Tc="",ys,Sn,Eo=0,uv=0,Ao=!1,Ro=!1,nr=new Set,Qh=[],hv=[],Ar=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,fv=(e)=>{Fe("status").textContent=e},Ir=(e)=>fv(e instanceof Error?e.message:String(e)),Co=(e,t,n=Qh)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function dv(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function m1(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/${Ar(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function g1(e,t){if(e.local){if(t==="editable.zip")return Co(Fl([e.local]),"application/zip");return Co(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return Co(e.loose,"model/gltf-binary");return`/files/${Ar(e)}/${t}?download`}function pv(e,t){try{localStorage.setItem(e,t)}catch{}}function mv(e){try{return localStorage.getItem(e)}catch{return null}}function _1(){let e=Fe("collections");e.replaceChildren();for(let t of[...Ss,...Rr.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=St("button",t.label,Tc===t.id?"active":"");n.onclick=()=>void Ec(t.id).catch(Ir),e.append(n)}}async function Ec(e){let t=++uv;Tc=e,nr.clear(),_1(),fv("");let n=e==="opened-files"?Rr:(await dv(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((i)=>({collection:e,manifest:i}));if(t!==uv)return;Cr=n,pv("kiln.collection",e),Fe("collection-title").textContent=e==="opened-files"?"Opened files":Ss.find((i)=>i.id===e)?.label??e,Fe("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved revisions, editable source, and everything ready to use.",ef()}function x1(){let e=new Map;for(let t of Cr){let n=t.manifest.assetId;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===mv(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function ef(){for(let i of hv.splice(0))URL.revokeObjectURL(i);let e=Fe("cards");e.replaceChildren();let t=Fe("search").value.toLowerCase(),n=x1().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Fe("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Fe("export-selection").disabled=!nr.size,!n.length){let i=St("div",void 0,"empty");if(i.append(St("b",t?"No matching assets":"Your next idea belongs here."),St("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(St("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=St("article",void 0,"card"),o=St("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void wc(i).catch(Ir);let a=St("div",void 0,"thumb");if(r.files["preview.png"]){let d=St("img");d.loading="lazy",d.alt=r.name,d.src=i.local?Co(i.local.files["preview.png"],"image/png",hv):`/files/${Ar(i)}/preview.png`,d.onerror=()=>{d.remove(),a.textContent="◇"},a.append(d)}else a.textContent="◇";let c=St("div",void 0,"card-content");c.append(St("span",r.name,"card-title"));let l=Cr.filter((d)=>d.manifest.assetId===r.assetId),u=new Set(l.map((d)=>d.manifest.parentRevision)),f=l.filter((d)=>!u.has(d.manifest.revisionId));c.append(St("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${f.length>1?` · ${f.length} branches`:""}`,"card-meta"));let h=St("div",void 0,"tags");for(let d of r.tags)h.append(St("span",d,"tag"));if(c.append(h),o.append(a,c),s.append(o),!i.loose){let d=St("input");d.type="checkbox",d.className="selection",d.checked=nr.has(Ar(i)),d.setAttribute("aria-label",`Select ${r.name}`),d.onchange=()=>{if(d.checked)nr.add(Ar(i));else nr.delete(Ar(i));Fe("export-selection").disabled=!nr.size},s.append(d)}e.append(s)}}async function wc(e){let t=++Eo;ys=e,pv(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let a of Qh.splice(0))URL.revokeObjectURL(a);let n=Fe("detail");if(!n.open)n.showModal();Fe("asset-name").textContent=e.manifest.name;let i=Fe("revisions");i.replaceChildren();for(let a of Cr.filter((c)=>c.manifest.assetId===e.manifest.assetId)){let c=St("option",`${new Date(a.manifest.createdAt).toLocaleString()} · ${a.manifest.description||a.manifest.revisionId.slice(0,10)}`);c.value=a.manifest.revisionId,c.selected=a.manifest.revisionId===e.manifest.revisionId,i.append(c)}i.onchange=()=>{let a=Cr.find((c)=>c.manifest.assetId===e.manifest.assetId&&c.manifest.revisionId===i.value);if(a)wc(a).catch(Ir)},Fe("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 r=Fe("asset-attribution");r.replaceChildren();for(let a of t_(e.manifest)){let c=St("div");c.append(St("span",a.label),St("strong",a.value)),r.append(c)}r.hidden=!r.childElementCount,Fe("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let s=Fe("downloads");s.replaceChildren();for(let[a,c]of[["asset.glb","Download GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let l=St("a",c);l.href=g1(e,a),l.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${a==="asset.glb"?".glb":a==="source.kiln.js"?".kiln.js":".zip"}`,s.append(l)}Fe("refine").disabled=!e.manifest.editable,Fe("asset-stats").replaceChildren(),Fe("stage-status").textContent="Loading saved GLB…",Ao=!1,Ro=!1,Fe("wire").setAttribute("aria-pressed","false"),Fe("play").textContent="Pause";let o=Fe("animation");o.replaceChildren(new Option("Rest pose","")),Fe("play").disabled=!0;try{Sn??=av(Fe("stage"));let a=await m1(e,"asset.glb");if(t!==Eo)return;let c=await Sn.load(a);if(!c||t!==Eo)return;Sn.wire(!1),Sn.lighting(Fe("lighting").value);for(let[l,u]of[[c.triangles.toLocaleString(),"triangles"],[c.meshes,"meshes"],[c.materials,"materials"],[`${(a.length/1024).toFixed(0)} KB`,"GLB"]]){let f=St("div");f.append(St("strong",String(l)),St("span",String(u))),Fe("asset-stats").append(f)}for(let l=0;l<c.clips.length;l++)o.append(new Option(c.clips[l],String(l)));Fe("stage-status").textContent=""}catch(a){if(t===Eo)Sn?.dispose(),Sn=void 0,Fe("stage-status").textContent=`3D preview unavailable: ${a instanceof Error?a.message:a}. Downloads remain available.`}}async function gv(e){for(let t of e){if(t.bytes.length>mi)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of e_(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(!Rr.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Rr.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Rr.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 Ec("opened-files")}Fe("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>mi))throw Error("File exceeds 64 MiB");await gv(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ir(t)}};Fe("refresh").onclick=()=>void Ec(Tc).catch(Ir);Fe("search").oninput=ef;Fe("close-detail").onclick=()=>Fe("detail").close();Fe("detail").addEventListener("close",()=>{Eo++,Sn?.dispose(),Sn=void 0;for(let e of Qh.splice(0))URL.revokeObjectURL(e);ef()});Fe("frame").onclick=()=>Sn?.reset();Fe("wire").onclick=()=>{Ao=!Ao,Sn?.wire(Ao),Fe("wire").setAttribute("aria-pressed",String(Ao))};Fe("lighting").onchange=(e)=>Sn?.lighting(e.target.value);Fe("animation").onchange=(e)=>{let t=e.target.value;Sn?.clip(t===""?-1:Number(t)),Fe("play").disabled=t===""};Fe("play").onclick=()=>{Ro=!Ro,Sn?.pause(Ro),Fe("play").textContent=Ro?"Play":"Pause"};Fe("refine").onclick=async()=>{if(!ys)return;let e=ys.manifest,t=ys.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=${ys.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=${ys.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Fe("refine").textContent="Instructions copied"}catch{Fe("provenance").textContent=t,Fe("provenance").parentElement?.setAttribute("open","")}};Fe("export-selection").onclick=()=>{try{let e=St("a");if(Tc==="opened-files")e.href=Co(Fl(Cr.filter((t)=>nr.has(Ar(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of nr)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ir(e)}};async function v1(){Ss=(await dv("/api/collections")).collections;let e=lv(location.search),t=mv("kiln.collection");if(await Ec(Ss.find((n)=>n.id===e?.collection)?.id??Ss.find((n)=>n.id===t)?.id??Ss[0]?.id??"project"),e){let n=Cr.find((i)=>i.collection===e.collection&&i.manifest.assetId===e.assetId&&i.manifest.revisionId===e.revisionId);if(!n)throw Error("The requested saved revision is not available.");await wc(n)}if(new URLSearchParams(location.search).has("open")){let n=await fetch("/api/standalone");if(!n.ok)throw Error("File unavailable");if(await gv([{name:n.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await n.arrayBuffer())}]),Rr.length===1)await wc(Rr[0])}}v1().catch(Ir);
+}`;class Ax{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new cc(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 Rn({vertexShader:BA,fragmentShader:GA,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new mt(new mo(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Rx extends Hn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Ax,p={},m=t.getContextAttributes(),E=null,R=null,S=[],b=[],T=new Ne,A=null,_=null,M=new Dt;M.viewport=new at;let F=new Dt;F.viewport=new at;let I=[M,F],O=new Th,K=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=S[Z];if(re===void 0)re=new oo,S[Z]=re;return re.getHandSpace()};function G(Z){let re=b.indexOf(Z.inputSource);if(re===-1)return;let se=S[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",z);for(let Z=0;Z<S.length;Z++){let re=b[Z];if(re===null)continue;b[Z]=null,S[Z].disconnect(re)}K=null,C=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Ce("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Ce("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",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",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new _n(h.framebufferWidth,h.framebufferHeight,{format:si,type:Gn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Ie=null,Pe=null;if(m.depth)Pe=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?xr:_r,Ie=m.stencil?os:$i;let we={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(we),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new _n(f.textureWidth,f.textureHeight,{format:si,type:Gn,depthTexture:new Sr(f.textureWidth,f.textureHeight,Ie,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],Ie=b.indexOf(se);if(Ie>=0)b[Ie]=null,S[Ie].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],Ie=b.indexOf(se);if(Ie===-1){for(let we=0;we<S.length;we++)if(we>=b.length){b.push(se),Ie=we;break}else if(b[we]===null){b[we]=se,Ie=we;break}if(Ie===-1)break}let Pe=S[Ie];if(Pe)Pe.connect(se)}}let te=new U,H=new U;function Q(Z,re,se){te.setFromMatrixPosition(re.matrixWorld),H.setFromMatrixPosition(se.matrixWorld);let Ie=te.distanceTo(H),Pe=re.projectionMatrix.elements,we=se.projectionMatrix.elements,gt=Pe[14]/(Pe[10]-1),ke=Pe[14]/(Pe[10]+1),Xe=(Pe[9]+1)/Pe[5],st=(Pe[9]-1)/Pe[5],Ke=(Pe[8]-1)/Pe[0],Ht=(we[8]+1)/we[0],_t=gt*Ke,rn=gt*Ht,Lt=Ie/(-Ke+Ht),Nt=Lt*-Ke;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Nt),Z.translateZ(Lt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Pe[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=gt+Lt,sn=ke+Lt,nt=_t-Nt,bt=rn+(Ie-Nt),w=Xe*ke/sn*L,v=st*ke/sn*L;Z.projectionMatrix.makePerspective(nt,bt,w,v,L,sn),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(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(O.near=F.near=M.near=re,O.far=F.far=M.far=se,K!==O.near||C!==O.far)i.updateRenderState({depthNear:O.near,depthFar:O.far}),K=O.near,C=O.far;O.layers.mask=Z.layers.mask|6,M.layers.mask=O.layers.mask&-5,F.layers.mask=O.layers.mask&-3;let Ie=Z.parent,Pe=O.cameras;ee(O,Ie);for(let we=0;we<Pe.length;we++)ee(Pe[we],Ie);if(Pe.length===2)Q(O,M,F);else O.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Te(Z,O,Ie)};function Te(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=pr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return O},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(Z){return p[Z]};let ve=null;function He(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Ie=!1;if(se.length!==O.cameras.length)O.cameras.length=0,Ie=!0;for(let ke=0;ke<se.length;ke++){let Xe=se[ke],st=null;if(h!==null)st=h.getViewport(Xe);else{let Ht=u.getViewSubImage(f,Xe);if(st=Ht.viewport,ke===0)e.setRenderTargetTextures(R,Ht.colorTexture,Ht.depthStencilTexture),e.setRenderTarget(R)}let Ke=I[ke];if(Ke===void 0)Ke=new Dt,Ke.layers.enable(ke),Ke.viewport=new at,I[ke]=Ke;if(Ke.matrix.fromArray(Xe.transform.matrix),Ke.matrix.decompose(Ke.position,Ke.quaternion,Ke.scale),Ke.projectionMatrix.fromArray(Xe.projectionMatrix),Ke.projectionMatrixInverse.copy(Ke.projectionMatrix).invert(),Ke.viewport.set(st.x,st.y,st.width,st.height),ke===0)O.matrix.copy(Ke.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale);if(Ie===!0)O.cameras.push(Ke)}let Pe=i.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ke=u.getDepthInformation(se[0]);if(ke&&ke.isValid&&ke.texture)x.init(ke,i.renderState)}if(Pe&&Pe.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ke=0;ke<se.length;ke++){let Xe=se[ke].camera;if(Xe){let st=p[Xe];if(!st)st=new cc,p[Xe]=st;let Ke=u.getCameraImage(Xe);st.sourceTexture=Ke}}}}for(let se=0;se<S.length;se++){let Ie=b[se],Pe=S[se];if(Ie!==null&&Pe!==void 0)Pe.update(Ie,re,c||s)}if(ve)ve(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new gx;Me.setAnimationLoop(He),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}}var HA=new Ge,Cx=new ze;Cx.set(-1,0,0,0,1,0,0,0,1);function VA(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,mh(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,S){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,S)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Yt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Yt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:S}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(HA.makeRotationFromEuler(S)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Cx);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Yt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function WA(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,b){let T=b.program;i.uniformBlockBinding(S,T)}function l(S,b){let T=r[S.id];if(T===void 0)p(S),T=u(S),r[S.id]=T,S.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(S,A);let _=t.render.frame;if(s[S.id]!==_)h(S),s[S.id]=_}function u(S){let b=f();S.__bindingPointIndex=b;let T=e.createBuffer(),{__size:A,usage:_}=S;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,T),T}function f(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){let b=r[S.id],{uniforms:T,__cache:A}=S;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=T.length;_<M;_++){let F=T[_];if(Array.isArray(F))for(let I=0,O=F.length;I<O;I++)d(F[I],_,I,A);else d(F,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(S,b,T,A){if(x(S,b,T,A)===!0){let{__offset:_,value:M}=S;if(Array.isArray(M)){let F=0;for(let I=0;I<M.length;I++){let O=M[I],K=m(O);if(g(O,S.__data,F),typeof O!=="number"&&typeof O!=="boolean"&&!O.isMatrix3&&!ArrayBuffer.isView(O))F+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else g(M,S.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,S.__data)}}function g(S,b,T){if(typeof S==="number"||typeof S==="boolean")b[0]=S;else if(S.isMatrix3)b[0]=S.elements[0],b[1]=S.elements[1],b[2]=S.elements[2],b[3]=0,b[4]=S.elements[3],b[5]=S.elements[4],b[6]=S.elements[5],b[7]=0,b[8]=S.elements[6],b[9]=S.elements[7],b[10]=S.elements[8],b[11]=0;else if(ArrayBuffer.isView(S))b.set(new S.constructor(S.buffer,S.byteOffset,b.length));else S.toArray(b,T)}function x(S,b,T,A){let _=S.value,M=b+"_"+T;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let F=A[M];if(typeof _==="number"||typeof _==="boolean"){if(F!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(F.equals(_)===!1)return F.copy(_),!0}return!1}function p(S){let b=S.uniforms,T=0,A=16;for(let M=0,F=b.length;M<F;M++){let I=Array.isArray(b[M])?b[M]:[b[M]];for(let O=0,K=I.length;O<K;O++){let C=I[O],G=Array.isArray(C.value)?C.value:[C.value];for(let X=0,z=G.length;X<z;X++){let te=G[X],H=m(te),Q=T%A,ee=Q%H.boundary,Te=Q+ee;if(T+=ee,Te!==0&&A-Te<H.storage)T+=A-Te;C.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=T,T+=H.storage}}}let _=T%A;if(_>0)T+=A-_;return S.__size=T,S.__cache={},this}function m(S){let b={boundary:0,storage:0};if(typeof S==="number"||typeof S==="boolean")b.boundary=4,b.storage=4;else if(S.isVector2)b.boundary=8,b.storage=8;else if(S.isVector3||S.isColor)b.boundary=16,b.storage=12;else if(S.isVector4)b.boundary=16,b.storage=16;else if(S.isMatrix3)b.boundary=48,b.storage=48;else if(S.isMatrix4)b.boundary=64,b.storage=64;else if(S.isTexture)Ce("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(S))b.boundary=16,b.storage=S.byteLength;else Ce("WebGLRenderer: Unsupported uniform value type.",S);return b}function E(S){let b=S.target;b.removeEventListener("dispose",E);let T=o.indexOf(b.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function R(){for(let S in r)e.deleteBuffer(r[S]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var $A=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]),ai=null;function ZA(){if(ai===null)ai=new lo($A,16,16,vr,ri),ai.name="DFG_LUT",ai.minFilter=Gt,ai.magFilter=Gt,ai.wrapS=rs,ai.wrapT=rs,ai.generateMipmaps=!1,ai.needsUpdate=!0;return ai}class Gh{constructor(e={}){let{canvas:t=U0(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Gn}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([Au,Eu,Tu]),p=new Set([Gn,$i,no,os,Mu,wu]),m=new Uint32Array(4),E=new Int32Array(4),R=new U,S=null,b=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=kn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,F=!1,I=null,O=null,K=null,C=null;this._outputColorSpace=Zi;let G=0,X=0,z=null,te=-1,H=null,Q=new at,ee=new at,Te=null,ve=new Oe(0),He=0,{width:Me,height:Z}=t,re=1,se=null,Ie=null,Pe=new at(0,0,Me,Z),we=new at(0,0,Me,Z),gt=!1,ke=new ho,Xe=!1,st=!1,Ke=new Ge,Ht=new U,_t=new at,rn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Lt=!1;function Nt(){return z===null?re:1}let L=n;function sn(y,N){return t.getContext(y,N)}let nt,bt,w,v,P,V,ie,ae,ue,q,J,ge,Ae,he,oe,Le,De,Qe,D,ce,Y,le,_e;try{let y={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${H_}`);if(t.addEventListener("webglcontextlost",Be,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",it,!1),L===null){if(L=sn("webgl2",y),L===null)if(sn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(y){throw t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),Ue("WebGLRenderer: "+y.message),y}function ne(){if(nt=new QT(L),nt.init(),Y=new kA(L,nt),bt=new VT(L,nt,e,Y),w=new FA(L,nt),bt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);O=L.createFramebuffer(),K=L.createFramebuffer(),C=L.createFramebuffer(),v=new nE(L),P=new MA,V=new zA(L,nt,w,P,bt,Y,v),ie=new JT(M),ae=new rM(L),le=new GT(L,ae),ue=new eE(L,ae,v,le),q=new rE(L,ue,ae,le,v),Qe=new iE(L,bt,V),oe=new WT(P),J=new bA(M,ie,nt,bt,le,oe),ge=new VA(M,P),Ae=new TA,he=new PA(nt),De=new BT(M,ie,w,q,d,a),Le=new UA(M,q,bt),_e=new WA(L,v,bt,w),D=new HT(L,nt,v),ce=new tE(L,nt,v),v.programs=J.programs,M.capabilities=bt,M.extensions=nt,M.properties=P,M.renderLists=Ae,M.shadowMap=Le,M.state=w,M.info=v}if(g!==Gn)_=new oE(g,t.width,t.height,o,i,r);let de=new Rx(M,L);this.xr=de,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let y=nt.get("WEBGL_lose_context");if(y)y.loseContext()},this.forceContextRestore=function(){let y=nt.get("WEBGL_lose_context");if(y)y.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(y){if(y===void 0)return;re=y,this.setSize(Me,Z,!1)},this.getSize=function(y){return y.set(Me,Z)},this.setSize=function(y,N,W=!0){if(de.isPresenting){Ce("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=y,Z=N,t.width=Math.floor(y*re),t.height=Math.floor(N*re),W===!0)t.style.width=y+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(y,N,W){Me=y,Z=N,re=W,t.width=Math.floor(y*W),t.height=Math.floor(N*W),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(g===Gn){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Ce("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(Q)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,N,W,k){if(y.isVector4)Pe.set(y.x,y.y,y.z,y.w);else Pe.set(y,N,W,k);w.viewport(Q.copy(Pe).multiplyScalar(re).round())},this.getScissor=function(y){return y.copy(we)},this.setScissor=function(y,N,W,k){if(y.isVector4)we.set(y.x,y.y,y.z,y.w);else we.set(y,N,W,k);w.scissor(ee.copy(we).multiplyScalar(re).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(y){w.setScissorTest(gt=y)},this.setOpaqueSort=function(y){se=y},this.setTransparentSort=function(y){Ie=y},this.getClearColor=function(y){return y.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,W=!0){let k=0;if(y){let B=!1;if(z!==null){let me=z.texture.format;B=x.has(me)}if(B){let me=z.texture.type,ye=p.has(me),pe=De.getClearColor(),Se=De.getClearAlpha(),{r:Ee,g:Ve,b:Ye}=pe;if(ye)m[0]=Ee,m[1]=Ve,m[2]=Ye,m[3]=Se,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ee,E[1]=Ve,E[2]=Ye,E[3]=Se,L.clearBufferiv(L.COLOR,0,E)}else k|=L.COLOR_BUFFER_BIT}if(N)k|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)k|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(k!==0)L.clear(k)},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(y){y.setRenderer(this),I=y},this.dispose=function(){t.removeEventListener("webglcontextlost",Be,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",it,!1),De.dispose(),Ae.dispose(),he.dispose(),P.dispose(),ie.dispose(),q.dispose(),le.dispose(),_e.dispose(),J.dispose(),de.dispose(),de.removeEventListener("sessionstart",sf),de.removeEventListener("sessionend",of),ir.stop()};function Be(y){y.preventDefault(),Ks("WebGLRenderer: Context Lost."),F=!0}function dt(){Ks("WebGLRenderer: Context Restored."),F=!1;let y=v.autoReset,N=Le.enabled,W=Le.autoUpdate,k=Le.needsUpdate,B=Le.type;ne(),v.autoReset=y,Le.enabled=N,Le.autoUpdate=W,Le.needsUpdate=k,Le.type=B}function it(y){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Vn(y){let N=y.target;N.removeEventListener("dispose",Vn),ui(N)}function ui(y){yv(y),P.remove(y)}function yv(y){let N=P.get(y).programs;if(N!==void 0){if(N.forEach(function(W){J.releaseProgram(W)}),y.isShaderMaterial)J.releaseShaderCache(y)}}this.renderBufferDirect=function(y,N,W,k,B,me){if(N===null)N=rn;let ye=B.isMesh&&B.matrixWorld.determinantAffine()<0,pe=Mv(y,N,W,k,B);w.setMaterial(k,ye);let Se=W.index,Ee=1;if(k.wireframe===!0){if(Se=ue.getWireframeAttribute(W),Se===void 0)return;Ee=2}let Ve=W.drawRange,Ye=W.attributes.position,be=Ve.start*Ee,rt=(Ve.start+Ve.count)*Ee;if(me!==null)be=Math.max(be,me.start*Ee),rt=Math.min(rt,(me.start+me.count)*Ee);if(Se!==null)be=Math.max(be,0),rt=Math.min(rt,Se.count);else if(Ye!==void 0&&Ye!==null)be=Math.max(be,0),rt=Math.min(rt,Ye.count);let It=rt-be;if(It<0||It===1/0)return;le.setup(B,k,pe,W,Se);let xt,ht=D;if(Se!==null)xt=ae.get(Se),ht=ce,ht.setIndex(xt);if(B.isMesh)if(k.wireframe===!0)w.setLineWidth(k.wireframeLinewidth*Nt()),ht.setMode(L.LINES);else ht.setMode(L.TRIANGLES);else if(B.isLine){let $t=k.linewidth;if($t===void 0)$t=1;if(w.setLineWidth($t*Nt()),B.isLineSegments)ht.setMode(L.LINES);else if(B.isLineLoop)ht.setMode(L.LINE_LOOP);else ht.setMode(L.LINE_STRIP)}else if(B.isPoints)ht.setMode(L.POINTS);else if(B.isSprite)ht.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(!nt.get("WEBGL_multi_draw")){let{_multiDrawStarts:$t,_multiDrawCounts:xe,_multiDrawCount:Jt}=B,Je=Se?ae.get(Se).bytesPerElement:1,bn=P.get(k).currentProgram.getUniforms();for(let Wn=0;Wn<Jt;Wn++)bn.setValue(L,"_gl_DrawID",Wn),ht.render($t[Wn]/Je,xe[Wn])}else ht.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else if(B.isInstancedMesh)ht.renderInstances(be,It,B.count);else if(W.isInstancedBufferGeometry){let $t=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,$t);ht.renderInstances(be,It,xe)}else ht.render(be,It)};function rf(y,N,W,k){if(I!==null&&y.isNodeMaterial)I.setObject(k,y);if(Xe===!0)oe.setState(y,W,!1);if(y.transparent===!0&&y.side===An&&y.forceSinglePass===!1)y.side=Yt,y.needsUpdate=!0,Po(y,N,k),y.side=Wi,y.needsUpdate=!0,Po(y,N,k),y.side=An;else Po(y,N,k)}this.compile=function(y,N,W=null){if(W===null)W=y;if(I!==null)I.renderStart(y,N,W);if(b=he.get(W),b.init(N),A.push(b),W.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}}),y!==W)y.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}});if(b.setupLights(),I!==null)I.updateLights(b.state.lightsArray);if(st=this.localClippingEnabled,Xe=oe.init(this.clippingPlanes,st),Xe===!0)oe.setGlobalState(this.clippingPlanes,N);if(I!==null)Le.render(b.state.shadowsArray,W,N);let k=new Set;if(y.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let me=B.material;if(me)if(Array.isArray(me))for(let ye=0;ye<me.length;ye++){let pe=me[ye];rf(pe,W,N,B),k.add(pe)}else rf(me,W,N,B),k.add(me)}),b=A.pop(),I!==null)I.renderEnd();return k},this.compileAsync=function(y,N,W=null){let k=this.compile(y,N,W);return new Promise((B)=>{function me(){if(k.forEach(function(ye){let Se=P.get(ye).currentProgram;if(Se===void 0||Se.isReady())k.delete(ye)}),k.size===0){B(y);return}setTimeout(me,10)}if(nt.get("KHR_parallel_shader_compile")!==null)me();else setTimeout(me,10)})};let Ac=null;function Sv(y){if(Ac)Ac(y)}function sf(){ir.stop()}function of(){ir.start()}let ir=new gx;if(ir.setAnimationLoop(Sv),typeof self<"u")ir.setContext(self);this.setAnimationLoop=function(y){Ac=y,de.setAnimationLoop(y),y===null?ir.stop():ir.start()},de.addEventListener("sessionstart",sf),de.addEventListener("sessionend",of),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;if(I!==null)I.renderStart(y,N);let W=de.enabled===!0&&de.isPresenting===!0,k=_!==null&&(z===null||W)&&_.begin(M,z);if(y.matrixWorldAutoUpdate===!0)y.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(de.enabled===!0&&de.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(de.cameraAutoUpdate===!0)de.updateCamera(N);N=de.getCamera()}if(y.isScene===!0)y.onBeforeRender(M,y,N,z);if(b=he.get(y,A.length),b.init(N),b.state.textureUnits=V.getTextureUnits(),A.push(b),Ke.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ke.setFromProjectionMatrix(Ke,lh,N.reversedDepth),st=this.localClippingEnabled,Xe=oe.init(this.clippingPlanes,st),S=Ae.get(y,T.length),S.init(),T.push(S),de.enabled===!0&&de.isPresenting===!0){let ye=M.xr.getDepthSensingMesh();if(ye!==null)Rc(ye,N,-1/0,M.sortObjects)}if(Rc(y,N,0,M.sortObjects),S.finish(),I!==null)I.updateLights(b.state.lightsArray);if(M.sortObjects===!0)S.sort(se,Ie);if(Lt=de.enabled===!1||de.isPresenting===!1||de.hasDepthSensing()===!1,Lt)De.addToRenderList(S,y);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Xe===!0)oe.beginShadows();let B=b.state.shadowsArray;if(Le.render(B,y,N),Xe===!0)oe.endShadows();if((k&&_.hasRenderPass())===!1){let ye=S.opaque,pe=S.transmissive;if(b.setupLights(),N.isArrayCamera){let Se=N.cameras;if(pe.length>0)for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee];cf(ye,pe,y,Ye)}if(Lt)De.render(y);for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee];af(S,y,Ye,Ye.viewport)}}else{if(pe.length>0)cf(ye,pe,y,N);if(Lt)De.render(y);af(S,y,N)}}if(z!==null&&X===0)V.updateMultisampleRenderTarget(z),V.updateRenderTargetMipmap(z);if(k)_.end(M);if(y.isScene===!0)y.onAfterRender(M,y,N);if(le.resetDefaultState(),te=-1,H=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Xe===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(T.pop(),T.length>0)S=T[T.length-1];else S=null;if(I!==null)I.renderEnd()};function Rc(y,N,W,k){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)W=y.renderOrder;else if(y.isLOD){if(y.autoUpdate===!0)y.update(N)}else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight){if(b.pushLight(y),y.castShadow)b.pushShadow(y)}else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(ke)){if(k)_t.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ke);let ye=q.update(y),pe=y.material;if(pe.visible)S.push(y,ye,pe,W,_t.z,null,N)}}else if(y.isMesh||y.isLine||y.isPoints){if(!y.frustumCulled||y.intersectsFrustum(ke)){let ye=q.update(y),pe=y.material;if(k){if(y.boundingSphere!==void 0){if(y.boundingSphere===null)y.computeBoundingSphere();_t.copy(y.boundingSphere.center)}else{if(ye.boundingSphere===null)ye.computeBoundingSphere();_t.copy(ye.boundingSphere.center)}_t.applyMatrix4(y.matrixWorld).applyMatrix4(Ke)}if(Array.isArray(pe)){let Se=ye.groups;for(let Ee=0,Ve=Se.length;Ee<Ve;Ee++){let Ye=Se[Ee],be=pe[Ye.materialIndex];if(be&&be.visible)S.push(y,ye,be,W,_t.z,Ye,N)}}else if(pe.visible)S.push(y,ye,pe,W,_t.z,null,N)}}}let me=y.children;for(let ye=0,pe=me.length;ye<pe;ye++)Rc(me[ye],N,W,k)}function af(y,N,W,k){let{opaque:B,transmissive:me,transparent:ye}=y;if(b.setupLightsView(W),Xe===!0)oe.setGlobalState(M.clippingPlanes,W);if(k)w.viewport(Q.copy(k));if(B.length>0)Io(B,N,W);if(me.length>0)Io(me,N,W);if(ye.length>0)Io(ye,N,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function cf(y,N,W,k){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new _n(1,1,{generateMipmaps:!0,type:be?ri:Gn,minFilter:ii,samples:Math.max(4,bt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:$e.workingColorSpace})}let me=b.state.transmissionRenderTarget[k.id],ye=k.viewport||Q;me.setSize(ye.z*M.transmissionResolutionScale,ye.w*M.transmissionResolutionScale);let pe=M.getRenderTarget(),Se=M.getActiveCubeFace(),Ee=M.getActiveMipmapLevel();if(M.setRenderTarget(me),M.getClearColor(ve),He=M.getClearAlpha(),He<1)M.setClearColor(16777215,0.5);if(M.clear(),Lt)De.render(W);let Ve=M.toneMapping;M.toneMapping=kn;let Ye=k.viewport;if(k.viewport!==void 0)k.viewport=void 0;if(b.setupLightsView(k),Xe===!0)oe.setGlobalState(M.clippingPlanes,k);if(Io(y,W,k),V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me),nt.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let rt=0,It=N.length;rt<It;rt++){let xt=N[rt],{object:ht,geometry:$t,material:xe,group:Jt}=xt;if(xe.side===An&&ht.layers.test(k.layers)){let Je=xe.side;xe.side=Yt,xe.needsUpdate=!0,lf(ht,W,k,$t,xe,Jt),xe.side=Je,xe.needsUpdate=!0,be=!0}}if(be===!0)V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me)}if(M.setRenderTarget(pe,Se,Ee),M.setClearColor(ve,He),Ye!==void 0)k.viewport=Ye;M.toneMapping=Ve}function Io(y,N,W){let k=N.isScene===!0?N.overrideMaterial:null;for(let B=0,me=y.length;B<me;B++){let ye=y[B],{object:pe,geometry:Se,group:Ee}=ye,Ve=ye.material;if(Ve.allowOverride===!0&&k!==null)Ve=k;if(pe.layers.test(W.layers))lf(pe,N,W,Se,Ve,Ee)}}function lf(y,N,W,k,B,me){if(I!==null&&B.isNodeMaterial)I.setObject(y,B);if(y.onBeforeRender(M,N,W,k,B,me),y.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),B.onBeforeRender(M,N,W,k,y,me),B.transparent===!0&&B.side===An&&B.forceSinglePass===!1)B.side=Yt,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=Wi,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=An;else M.renderBufferDirect(W,N,k,B,y,me);y.onAfterRender(M,N,W,k,B,me)}function Po(y,N,W){if(N.isScene!==!0)N=rn;let k=P.get(y),B=b.state.lights,me=b.state.shadowsArray,ye=B.state.version,pe=J.getParameters(y,B.state,me,N,W,b.state.lightProbeGridArray),Se=J.getProgramCacheKey(pe),Ee=k.programs;k.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,k.fog=N.fog;let Ve=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;if(k.envMap=ie.get(y.envMap||k.environment,Ve),k.envMapRotation=k.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Ee===void 0)y.addEventListener("dispose",Vn),Ee=new Map,k.programs=Ee;let Ye=Ee.get(Se);if(Ye!==void 0){if(k.currentProgram===Ye&&k.lightsStateVersion===ye)return hf(y,pe),Ye}else{if(pe.uniforms=J.getUniforms(y),I!==null&&y.isNodeMaterial)I.build(y,W,pe);y.onBeforeCompile(pe,M),Ye=J.acquireProgram(pe,Se),Ee.set(Se,Ye),k.uniforms=pe.uniforms}let be=k.uniforms;if(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)be.clippingPlanes=oe.uniform;if(hf(y,pe),k.needsLights=Tv(y),k.lightsStateVersion=ye,k.needsLights)be.ambientLightColor.value=B.state.ambient,be.lightProbe.value=B.state.probe,be.sunLights.value=B.state.sun,be.sunLightShadows.value=B.state.sunShadow,be.directionalLights.value=B.state.directional,be.directionalLightShadows.value=B.state.directionalShadow,be.spotLights.value=B.state.spot,be.spotLightShadows.value=B.state.spotShadow,be.rectAreaLights.value=B.state.rectArea,be.ltc_1.value=B.state.rectAreaLTC1,be.ltc_2.value=B.state.rectAreaLTC2,be.pointLights.value=B.state.point,be.pointLightShadows.value=B.state.pointShadow,be.hemisphereLights.value=B.state.hemi,be.sunShadowMatrix.value=B.state.sunShadowMatrix,be.sunShadowCascade.value=B.state.sunShadowCascade,be.directionalShadowMatrix.value=B.state.directionalShadowMatrix,be.spotLightMatrix.value=B.state.spotLightMatrix,be.spotLightMap.value=B.state.spotLightMap,be.pointShadowMatrix.value=B.state.pointShadowMatrix;return k.lightProbeGrid=b.state.lightProbeGridArray.length>0,k.currentProgram=Ye,k.uniformsList=null,Ye}function uf(y){if(y.uniformsList===null){let N=y.currentProgram.getUniforms();y.uniformsList=Mo.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function hf(y,N){let W=P.get(y);W.outputColorSpace=N.outputColorSpace,W.batching=N.batching,W.batchingColor=N.batchingColor,W.instancing=N.instancing,W.instancingColor=N.instancingColor,W.instancingMorph=N.instancingMorph,W.skinning=N.skinning,W.morphTargets=N.morphTargets,W.morphNormals=N.morphNormals,W.morphColors=N.morphColors,W.morphTargetsCount=N.morphTargetsCount,W.numClippingPlanes=N.numClippingPlanes,W.numIntersection=N.numClipIntersection,W.vertexAlphas=N.vertexAlphas,W.vertexTangents=N.vertexTangents,W.toneMapping=N.toneMapping}function bv(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let W=0,k=y.length;W<k;W++){let B=y[W];if(B.texture!==null&&B.boundingBox.containsPoint(R))return B}return null}function Mv(y,N,W,k,B){if(N.isScene!==!0)N=rn;V.resetTextureUnits();let me=N.fog,ye=k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial?N.environment:null,pe=z===null?M.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:$e.workingColorSpace,Se=k.isMeshStandardMaterial||k.isMeshLambertMaterial&&!k.envMap||k.isMeshPhongMaterial&&!k.envMap,Ee=ie.get(k.envMap||ye,Se),Ve=k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ye=!!W.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),be=!!W.morphAttributes.position,rt=!!W.morphAttributes.normal,It=!!W.morphAttributes.color,xt=kn;if(k.toneMapped){if(z===null||z.isXRRenderTarget===!0)xt=M.toneMapping}let ht=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,$t=ht!==void 0?ht.length:0,xe=P.get(k),Jt=b.state.lights;if(Xe===!0){if(st===!0||y!==H){let pt=y===H&&k.id===te;oe.setState(k,y,pt)}}let Je=!1;if(k.version===xe.__version){if(xe.needsLights&&xe.lightsStateVersion!==Jt.state.version)Je=!0;else if(xe.outputColorSpace!==pe)Je=!0;else if(B.isBatchedMesh&&xe.batching===!1)Je=!0;else if(!B.isBatchedMesh&&xe.batching===!0)Je=!0;else if(B.isBatchedMesh&&xe.batchingColor===!0&&B._colorsTexture===null)Je=!0;else if(B.isBatchedMesh&&xe.batchingColor===!1&&B._colorsTexture!==null)Je=!0;else if(B.isInstancedMesh&&xe.instancing===!1)Je=!0;else if(!B.isInstancedMesh&&xe.instancing===!0)Je=!0;else if(B.isSkinnedMesh&&xe.skinning===!1)Je=!0;else if(!B.isSkinnedMesh&&xe.skinning===!0)Je=!0;else if(B.isInstancedMesh&&xe.instancingColor===!0&&B.instanceColor===null)Je=!0;else if(B.isInstancedMesh&&xe.instancingColor===!1&&B.instanceColor!==null)Je=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!0&&B.morphTexture===null)Je=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!1&&B.morphTexture!==null)Je=!0;else if(xe.envMap!==Ee)Je=!0;else if(k.fog===!0&&xe.fog!==me)Je=!0;else if(xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==oe.numPlanes||xe.numIntersection!==oe.numIntersection))Je=!0;else if(xe.vertexAlphas!==Ve)Je=!0;else if(xe.vertexTangents!==Ye)Je=!0;else if(xe.morphTargets!==be)Je=!0;else if(xe.morphNormals!==rt)Je=!0;else if(xe.morphColors!==It)Je=!0;else if(xe.toneMapping!==xt)Je=!0;else if(xe.morphTargetsCount!==$t)Je=!0;else if(!!xe.lightProbeGrid!==b.state.lightProbeGridArray.length>0)Je=!0}else Je=!0,xe.__version=k.version;let bn=xe.currentProgram;if(Je===!0){if(bn=Po(k,N,B),I&&k.isNodeMaterial)I.onUpdateProgram(k,bn,xe)}let Wn=!1,Ai=!1,Pr=!1,lt=bn.getUniforms(),At=xe.uniforms;if(w.useProgram(bn.program))Wn=!0,Ai=!0,Pr=!0;if(k.id!==te)te=k.id,Ai=!0;if(xe.needsLights){let pt=bv(b.state.lightProbeGridArray,B);if(xe.lightProbeGrid!==pt)xe.lightProbeGrid=pt,Ai=!0}if(Wn||H!==y){if(w.buffers.depth.getReversed()&&y.reversedDepth!==!0)y._reversedDepth=!0,y.updateProjectionMatrix();lt.setValue(L,"projectionMatrix",y.projectionMatrix),lt.setValue(L,"viewMatrix",y.matrixWorldInverse);let Ci=lt.map.cameraPosition;if(Ci!==void 0)Ci.setValue(L,Ht.setFromMatrixPosition(y.matrixWorld));if(bt.logarithmicDepthBuffer)lt.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2));if(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)lt.setValue(L,"isOrthographic",y.isOrthographicCamera===!0);if(H!==y)H=y,Ai=!0,Pr=!0}if(xe.needsLights){if(Jt.state.sunShadowMap.length>0)lt.setValue(L,"sunShadowMap",Jt.state.sunShadowMap,V);if(Jt.state.directionalShadowMap.length>0)lt.setValue(L,"directionalShadowMap",Jt.state.directionalShadowMap,V);if(Jt.state.spotShadowMap.length>0)lt.setValue(L,"spotShadowMap",Jt.state.spotShadowMap,V);if(Jt.state.pointShadowMap.length>0)lt.setValue(L,"pointShadowMap",Jt.state.pointShadowMap,V)}if(B.isSkinnedMesh){lt.setOptional(L,B,"bindMatrix"),lt.setOptional(L,B,"bindMatrixInverse");let pt=B.skeleton;if(pt){if(pt.boneTexture===null)pt.computeBoneTexture();lt.setValue(L,"boneTexture",pt.boneTexture,V)}}if(B.isBatchedMesh){if(lt.setOptional(L,B,"batchingTexture"),lt.setValue(L,"batchingTexture",B._matricesTexture,V),lt.setOptional(L,B,"batchingIdTexture"),lt.setValue(L,"batchingIdTexture",B._indirectTexture,V),lt.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null)lt.setValue(L,"batchingColorTexture",B._colorsTexture,V)}let Ri=W.morphAttributes;if(Ri.position!==void 0||Ri.normal!==void 0||Ri.color!==void 0)Qe.update(B,W,bn);if(Ai||xe.receiveShadow!==B.receiveShadow)xe.receiveShadow=B.receiveShadow,lt.setValue(L,"receiveShadow",B.receiveShadow);if((k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&N.environment!==null)At.envMapIntensity.value=N.environmentIntensity;if(At.dfgLUT!==void 0)At.dfgLUT.value=ZA();if(Ai){if(lt.setValue(L,"toneMappingExposure",M.toneMappingExposure),xe.needsLights)wv(At,Pr);if(me&&k.fog===!0)ge.refreshFogUniforms(At,me);if(ge.refreshMaterialUniforms(At,k,re,Z,b.state.transmissionRenderTarget[y.id]),xe.needsLights&&xe.lightProbeGrid){let pt=xe.lightProbeGrid;At.probesSH.value=pt.texture,At.probesMin.value.copy(pt.boundingBox.min),At.probesMax.value.copy(pt.boundingBox.max),At.probesResolution.value.copy(pt.resolution)}Mo.upload(L,uf(xe),At,V)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0)Mo.upload(L,uf(xe),At,V),k.uniformsNeedUpdate=!1;if(k.isSpriteMaterial)lt.setValue(L,"center",B.center);if(lt.setValue(L,"modelViewMatrix",B.modelViewMatrix),lt.setValue(L,"normalMatrix",B.normalMatrix),lt.setValue(L,"modelMatrix",B.matrixWorld),k.uniformsGroups!==void 0){let pt=k.uniformsGroups;for(let Ci=0,Lr=pt.length;Ci<Lr;Ci++){let df=pt[Ci];_e.update(df,bn),_e.bind(df,bn)}}return bn}function wv(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.sunLights.needsUpdate=N,y.sunLightShadows.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function Tv(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(y,N,W){let k=P.get(y);if(k.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1)k.__useRenderToTexture=!1;P.get(y.texture).__webglTexture=N,P.get(y.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:W,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){let W=P.get(y);W.__webglFramebuffer=N,W.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,W=0){z=y,G=N,X=W;let k=null,B=!1,me=!1;if(y){let pe=P.get(y);if(pe.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest,w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),te=-1;return}else if(pe.__webglFramebuffer===void 0)V.setupRenderTarget(y);else if(pe.__hasExternalTextures)V.rebindTextures(y,P.get(y.texture).__webglTexture,P.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let Ve=y.depthTexture;if(pe.__boundDepthTexture!==Ve){if(Ve!==null&&P.has(Ve)&&(y.width!==Ve.image.width||y.height!==Ve.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(y)}}let Se=y.texture;if(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)me=!0;let Ee=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget){if(Array.isArray(Ee[N]))k=Ee[N][W];else k=Ee[N];B=!0}else if(y.samples>0&&V.useMultisampledRTT(y)===!1)k=P.get(y).__webglMultisampledFramebuffer;else if(Array.isArray(Ee))k=Ee[W];else k=Ee;Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest}else Q.copy(Pe).multiplyScalar(re).floor(),ee.copy(we).multiplyScalar(re).floor(),Te=gt;if(W!==0)k=O;if(w.bindFramebuffer(L.FRAMEBUFFER,k))w.drawBuffers(y,k);if(w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),B){let pe=P.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,W)}else if(me){let pe=N;for(let Se=0;Se<y.textures.length;Se++){let Ee=P.get(y.textures[Se]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Se,Ee.__webglTexture,W,pe)}}else if(y!==null&&W!==0){let pe=P.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,W)}te=-1};function ff(y){let N=P.get(y);if(N.__readFormat!==y.format||N.__readType!==y.type)N.__readFormat=y.format,N.__readType=y.type,N.__formatReadable=bt.textureFormatReadable(y.format),N.__typeReadable=bt.textureTypeReadable(y.type);return N}if(this.readRenderTargetPixels=function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se){w.bindFramebuffer(L.FRAMEBUFFER,Se);try{let Ee=y.textures[pe],{format:Ve,type:Ye}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=ff(Ee);if(be.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B))L.readPixels(N,W,k,B,Y.convert(Ve),Y.convert(Ye),me)}finally{let Ee=z!==null?P.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=P.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se)if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B)){w.bindFramebuffer(L.FRAMEBUFFER,Se);let Ee=y.textures[pe],{format:Ve,type:Ye}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=ff(Ee);if(be.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let rt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,rt),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,W,k,B,Y.convert(Ve),Y.convert(Ye),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let It=z!==null?P.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,It);let xt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await z0(L,xt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,rt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(rt),L.deleteSync(xt),me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,W=0){let k=Math.pow(2,-W),B=Math.floor(y.image.width*k),me=Math.floor(y.image.height*k),ye=N!==null?N.x:0,pe=N!==null?N.y:0;V.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,W,0,0,ye,pe,B,me),w.unbindTexture()},this.copyTextureToTexture=function(y,N,W=null,k=null,B=0,me=0){let ye,pe,Se,Ee,Ve,Ye,be,rt,It,xt=y.isCompressedTexture?y.mipmaps[me]:y.image;if(W!==null)ye=W.max.x-W.min.x,pe=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,Ee=W.min.x,Ve=W.min.y,Ye=W.isBox3?W.min.z:0;else{let At=Math.pow(2,-B);if(ye=Math.floor(xt.width*At),pe=Math.floor(xt.height*At),y.isDataArrayTexture)Se=xt.depth;else if(y.isData3DTexture)Se=Math.floor(xt.depth*At);else Se=1;Ee=0,Ve=0,Ye=0}if(k!==null)be=k.x,rt=k.y,It=k.z;else be=0,rt=0,It=0;let ht=Y.convert(N.format),$t=Y.convert(N.type),xe;if(N.isData3DTexture)V.setTexture3D(N,0),xe=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)V.setTexture2DArray(N,0),xe=L.TEXTURE_2D_ARRAY;else V.setTexture2D(N,0),xe=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let Jt=w.getParameter(L.UNPACK_ROW_LENGTH),Je=w.getParameter(L.UNPACK_IMAGE_HEIGHT),bn=w.getParameter(L.UNPACK_SKIP_PIXELS),Wn=w.getParameter(L.UNPACK_SKIP_ROWS),Ai=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,xt.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,xt.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ee),w.pixelStorei(L.UNPACK_SKIP_ROWS,Ve),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ye);let Pr=y.isDataArrayTexture||y.isData3DTexture,lt=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){let At=P.get(y),Ri=P.get(N),pt=P.get(At.__renderTarget),Ci=P.get(Ri.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,pt.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Ci.__webglFramebuffer);for(let Lr=0;Lr<Se;Lr++){if(Pr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(y).__webglTexture,B,Ye+Lr),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,P.get(N).__webglTexture,me,It+Lr);L.blitFramebuffer(Ee,Ve,ye,pe,be,rt,ye,pe,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||y.isRenderTargetTexture||P.has(y)){let At=P.get(y),Ri=P.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,K),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,C);for(let pt=0;pt<Se;pt++){if(Pr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,At.__webglTexture,B,Ye+pt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,At.__webglTexture,B);if(lt)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ri.__webglTexture,me,It+pt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ri.__webglTexture,me);if(B!==0)L.blitFramebuffer(Ee,Ve,ye,pe,be,rt,ye,pe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(lt)L.copyTexSubImage3D(xe,me,be,rt,It+pt,Ee,Ve,ye,pe);else L.copyTexSubImage2D(xe,me,be,rt,Ee,Ve,ye,pe)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(lt)if(y.isDataTexture||y.isData3DTexture)L.texSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,$t,xt.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,xt.data);else L.texSubImage3D(xe,me,be,rt,It,ye,pe,Se,ht,$t,xt);else if(y.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,me,be,rt,ye,pe,ht,$t,xt.data);else if(y.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,me,be,rt,xt.width,xt.height,ht,xt.data);else L.texSubImage2D(L.TEXTURE_2D,me,be,rt,ye,pe,ht,$t,xt);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,Jt),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Je),w.pixelStorei(L.UNPACK_SKIP_PIXELS,bn),w.pixelStorei(L.UNPACK_SKIP_ROWS,Wn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ai),me===0&&N.generateMipmaps)L.generateMipmap(xe);w.unbindTexture()},this.initRenderTarget=function(y){if(P.get(y).__webglFramebuffer===void 0)V.setupRenderTarget(y)},this.initTexture=function(y){if(y.isCubeTexture)V.setTextureCube(y,0);else if(y.isData3DTexture)V.setTexture3D(y,0);else if(y.isDataArrayTexture||y.isCompressedArrayTexture)V.setTexture2DArray(y,0);else V.setTexture2D(y,0);w.unbindTexture()},this.resetState=function(){G=0,X=0,z=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return lh}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=$e._getDrawingBufferColorSpace(e),t.unpackColorSpace=$e._getUnpackColorSpace()}}function Hh(e,t){if(t===sh)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===as||t===io){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===as)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 Ix(e){let t=new Map,n=new Map,i=e.clone();return Px(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 Px(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)Px(e.children[i],t.children[i],n)}class Yh extends Ei{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new kx(t)}),this.register(function(t){return new Bx(t)}),this.register(function(t){return new Yx(t)}),this.register(function(t){return new jx(t)}),this.register(function(t){return new Kx(t)}),this.register(function(t){return new Hx(t)}),this.register(function(t){return new Vx(t)}),this.register(function(t){return new Wx(t)}),this.register(function(t){return new $x(t)}),this.register(function(t){return new zx(t)}),this.register(function(t){return new Zx(t)}),this.register(function(t){return new Gx(t)}),this.register(function(t){return new qx(t)}),this.register(function(t){return new Xx(t)}),this.register(function(t){return new Ux(t)}),this.register(function(t){return new Zh(t,qe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Zh(t,qe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Jx(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=er.extractUrlBase(e);s=er.resolveURL(c,this.path)}else s=er.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 _o(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))===Qx){try{s[qe.KHR_BINARY_GLTF]=new ev(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[qe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new sv(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case qe.KHR_MATERIALS_UNLIT:s[u]=new Fx;break;case qe.KHR_DRACO_MESH_COMPRESSION:s[u]=new tv(r,this.dracoLoader);break;case qe.KHR_TEXTURE_TRANSFORM:s[u]=new nv;break;case qe.KHR_MESH_QUANTIZATION:s[u]=new iv;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function qA(){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 Ct(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var qe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ux{constructor(e){this.parser=e,this.name=qe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],gn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new ps(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new ds(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),li(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 Fx{constructor(){this.name=qe.KHR_MATERIALS_UNLIT}getMaterialType(){return oi}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],gn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Zi))}return Promise.all(i)}}class zx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class kx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class Bx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Gx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Hx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],gn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Zi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Vx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Wx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],gn),Promise.all(i)}}class $x{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_IOR}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Zx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],gn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Zi));return Promise.all(i)}}class Xx{constructor(e){this.parser=e,this.name=qe.EXT_MATERIALS_BUMP}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 qx{constructor(e){this.parser=e,this.name=qe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ct(this.parser,e,this.name)!==null?vn:null}extendMaterialParams(e,t){let n=Ct(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 Yx{constructor(e){this.parser=e,this.name=qe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class jx{constructor(e){this.parser=e,this.name=qe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Kx{constructor(e){this.parser=e,this.name=qe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Zh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Jx{constructor(e){this.name=qe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Cn.TRIANGLES&&c.mode!==Cn.TRIANGLE_STRIP&&c.mode!==Cn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Ge,x=new U,p=new kt,m=new U(1,1,1),E=new us(d.geometry,d.material,f);for(let S=0;S<f;S++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,S);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,S);if(a.SCALE)m.fromBufferAttribute(a.SCALE,S);E.setMatrixAt(S,g.compose(x,p,m))}let R=null;for(let S in a)if(S==="_COLOR_0"){let b=a[S];E.instanceColor=new Gi(b.array,b.itemSize,b.normalized)}else if(S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"){if(R===null){let T=E.geometry;R=new jt,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let b=a[S];R.setAttribute(S,new Gi(b.array,b.itemSize,b.normalized))}ut.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Qx="glTF",To=12,Lx={JSON:1313821514,BIN:5130562};class ev{constructor(e){this.name=qe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,To),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!==Qx)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-To,r=new DataView(e,To),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===Lx.JSON){let c=new Uint8Array(e,To+s,o);this.content=n.decode(c)}else if(a===Lx.BIN){let c=To+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class tv{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=qe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=Xh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Xh[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=xs[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,gn,f)})})}}class nv{constructor(){this.name=qe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class iv{constructor(){this.name=qe.KHR_MESH_QUANTIZATION}}class jh extends Ti{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let S=s[g+R+o],b=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*S+E*b+x*T+p*A}return r}}var YA=new kt;class rv extends jh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return YA.fromArray(r).normalize().toArray(r),r}}var Cn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},xs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Nx={9728:Bn,9729:Gt,9984:Wa,9985:ss,9986:gr,9987:ii},Dx={33071:rs,33648:Va,10497:is},Vh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Xh={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"},tr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jA={CUBICSPLINE:void 0,LINEAR:Ka,STEP:rh},Wh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function KA(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new wi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wi});return e.DefaultMaterial}function Er(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 li(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 JA(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function QA(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 e1(e){let t,n=e.extensions&&e.extensions[qe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+$h(n.attributes);else t=e.indices+":"+$h(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+$h(e.targets[i]);return t}function $h(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 qh(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 t1(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 n1=new Ge;class sv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new qA,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 fc(this.options.manager);else this.textureLoader=new gc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _o(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 Er(r,o,i),li(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[qe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(er.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=Vh[i.type],o=xs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new Bt(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=Vh[i.type],c=xs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new ao(g,h/l),t.cache.add(m,E);x=new ls(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new Bt(g,a,d)}if(i.sparse!==void 0){let p=Vh.SCALAR,m=xs[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,S=new m(s[1],E,i.sparse.count*p),b=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new Bt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=S.length;T<A;T++){let _=S[T];if(x.setX(_,b[T*a]),a>=2)x.setY(_,b[T*a+1]);if(a>=3)x.setZ(_,b[T*a+2]);if(a>=4)x.setW(_,b[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=Nx[f.magFilter]||Gt,l.minFilter=Nx[f.minFilter]||ii,l.wrapS=Dx[f.wrapS]||is,l.wrapT=Dx[f.wrapT]||is,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Bn&&l.minFilter!==Gt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new Et(g);x.needsUpdate=!0,f(x)};t.load(er.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return li(u,s),u.userData.mimeType=s.mimeType||t1(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[qe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[qe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[qe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new po,cn.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 fo,cn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return wi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[qe.KHR_MATERIALS_UNLIT]){let u=i[qe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],gn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Zi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=An;let l=r.alphaMode||Wh.OPAQUE;if(l===Wh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Wh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==oi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==oi){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!==oi){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],gn)}if(r.emissiveTexture!==void 0&&s!==oi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Zi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(li(u,r),t.associations.set(u,{materials:e}),r.extensions)Er(i,u,r);return u})}createUniqueName(e){let t=et.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[qe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return Ox(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=e1(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[qe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=Ox(new jt,c,t);if(c.mode===Cn.TRIANGLE_STRIP)f=f.then((h)=>Hh(h,io));else if(c.mode===Cn.TRIANGLE_FAN)f=f.then((h)=>Hh(h,as));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?KA(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===Cn.TRIANGLES||x.mode===Cn.TRIANGLE_STRIP||x.mode===Cn.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new rc(g,m):new mt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===Cn.LINES)p=new sc(g,m);else if(x.mode===Cn.LINE_STRIP)p=new qi(g,m);else if(x.mode===Cn.LINE_LOOP)p=new oc(g,m);else if(x.mode===Cn.POINTS)p=new hs(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)QA(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),li(p,r),x.extensions)Er(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Er(i,u[0],r);return u[0]}let f=new Qn;if(r.extensions)Er(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Dt(ro.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new wr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return li(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Ge;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new uo(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let S=f[E],b=h[E],T=d[E],A=g[E],_=x[E];if(S===void 0)continue;if(S.updateMatrix)S.updateMatrix();let M=n._createAnimationTracks(S,b,T,A,_);if(M)for(let F=0;F<M.length;F++)p.push(M[F])}let m=new Qr(r,void 0,p);return li(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,n1)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new co;else if(c.length>1)l=new Qn;else if(c.length===1)l=c[0];else l=new ut;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(li(l,r),r.extensions)Er(n,l,r);if(r.matrix!==void 0){let u=new Ge;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new Qn;if(n.name)r.name=i.createUniqueName(n.name);if(li(r,n),n.extensions)Er(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(Ix(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof cn||f instanceof Et)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(tr[r.path]===tr.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(tr[r.path]){case tr.weights:l=Ki;break;case tr.rotation:l=Ji;break;case tr.translation:case tr.scale:l=Mr;break;default:switch(n.itemSize){case 1:l=Ki;break;case 2:case 3:default:l=Mr;break}break}let u=i.interpolation!==void 0?jA[i.interpolation]:Ka,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+tr[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=qh(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 Ji?rv:jh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function i1(e,t,n){let i=t.attributes,r=new nn;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=qh(xs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=qh(xs[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new xn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function Ox(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=Xh[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if($e.workingColorSpace!==gn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$e.workingColorSpace}" not supported.`);return li(e,t),i1(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?JA(e,t.targets,n):e})}var ov={type:"change"},Jh={type:"start"},cv={type:"end"},Mc=new Xi,av=new Tn,r1=Math.cos(70*ro.DEG2RAD),Ft=new U,ln=2*Math.PI,ct={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Kh=0.000001;class Qh extends xc{constructor(e,t=null){super(e,t);if(this.state=ct.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:Hi.ROTATE,MIDDLE:Hi.DOLLY,RIGHT:Hi.PAN},this.touches={ONE:Vi.ROTATE,TWO:Vi.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 kt,this._lastTargetPosition=new U,this._quat=new kt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new vo,this._sphericalDelta=new vo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new U,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=o1.bind(this),this._onPointerDown=s1.bind(this),this._onPointerUp=a1.bind(this),this._onContextMenu=p1.bind(this),this._onMouseWheel=u1.bind(this),this._onKeyDown=h1.bind(this),this._onTouchStart=f1.bind(this),this._onTouchMove=d1.bind(this),this._onMouseDown=c1.bind(this),this._onMouseMove=l1.bind(this),this._interceptControlDown=m1.bind(this),this._interceptControlUp=g1.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ct.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ov),this.update(),this.state=ct.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Ft.copy(t).sub(this.target),Ft.applyQuaternion(this._quat),this._spherical.setFromVector3(Ft),this.autoRotate&&this.state===ct.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=ln;else if(n>Math.PI)n-=ln;if(i<-Math.PI)i+=ln;else if(i>Math.PI)i-=ln;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(Ft.setFromSpherical(this._spherical),Ft.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ft),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=Ft.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=Ft.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(Mc.origin.copy(this.object.position),Mc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mc.direction))<r1)this.object.lookAt(this.target);else av.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mc.intersectPlane(av,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)>Kh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Kh||this._lastTargetPosition.distanceToSquared(this.target)>Kh)return this.dispatchEvent(ov),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 ln/60*this.autoRotateSpeed*e;else return ln/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){Ft.setFromMatrixColumn(t,0),Ft.multiplyScalar(-e),this._panOffset.add(Ft)}_panUp(e,t){if(this.screenSpacePanning===!0)Ft.setFromMatrixColumn(t,1);else Ft.setFromMatrixColumn(t,0),Ft.crossVectors(this.object.up,Ft);Ft.multiplyScalar(e),this._panOffset.add(Ft)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Ft.copy(i).sub(this.target);let r=Ft.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(ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(ln*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(ln*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(-ln*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(ln*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(-ln*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(ln*this._rotateDelta.x/t.clientHeight),this._rotateUp(ln*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function s1(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 o1(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function a1(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(cv),this.state=ct.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function c1(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 Hi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=ct.DOLLY;break;case Hi.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}break;case Hi.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=ct.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=ct.PAN}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Jh)}function l1(e){switch(this.state){case ct.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case ct.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case ct.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function u1(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==ct.NONE)return;e.preventDefault(),this.dispatchEvent(Jh),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(cv)}function h1(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function f1(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Vi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=ct.TOUCH_ROTATE;break;case Vi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=ct.TOUCH_PAN;break;default:this.state=ct.NONE}break;case 2:switch(this.touches.TWO){case Vi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=ct.TOUCH_DOLLY_PAN;break;case Vi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=ct.TOUCH_DOLLY_ROTATE;break;default:this.state=ct.NONE}break;default:this.state=ct.NONE}if(this.state!==ct.NONE)this.dispatchEvent(Jh)}function d1(e){switch(this._trackPointer(e),this.state){case ct.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case ct.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case ct.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case ct.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=ct.NONE}}function p1(e){if(this.enabled===!1)return;e.preventDefault()}function m1(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function g1(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class ef extends cs{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Yi;e.deleteAttribute("uv");let t=new wi({side:Yt}),n=new wi,i=new ds(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 us(e,n,6),o=new ut;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new 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 f=new mt(e,vs(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new mt(e,vs(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 vs(e){return new lc({color:0,emissive:16777215,emissiveIntensity:e})}function lv(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 E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let S of[E.min.y,E.max.y])for(let b of[E.min.z,E.max.z])l.push(new U(R,S,b));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),S=R.dot(a),b=R.dot(c);u=Math.min(u,S),f=Math.max(f,S),h=Math.min(h,b),d=Math.max(d,b)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),S=R.dot(o);p=Math.max(p,S+Math.abs(R.dot(a))*1.12/x,S+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function uv(e){let t=new Gh({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=eo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new cs,i=new Dt(40,1,0.01,1000),r=new Qh(i,t.domElement);r.enableDamping=!0;let s=new wo(t),o=new ef,a=s.fromScene(o,0.04);n.environment=a.texture,o.dispose(),s.dispose();let c=new ps(16773591,2.4);c.position.set(4,8,5),n.add(c),n.add(new dc(14806490,5065021,1.7));let l,u,f=[],h=!0,d=performance.now(),g=0,x=0,p=!1,m=(b)=>{let T=new Set,A=new Set,_=new Set;b.traverse((M)=>{let F=M;if(!F.isMesh)return;T.add(F.geometry);for(let I of Array.isArray(F.material)?F.material:[F.material]){A.add(I);for(let O of Object.values(I))if(O instanceof Et)_.add(O)}});for(let M of[...T,...A,..._])M.dispose()},E=()=>{if(!l)return;let b=new nn().setFromObject(l,!0),T=[];l.traverse((I)=>{if(I instanceof mt||I instanceof qi||I instanceof hs){let O=new nn().setFromObject(I,!0);if(!O.isEmpty())T.push(O)}});let{center:A,radius:_,distance:M,position:F}=lv(b,i.aspect,i.fov,T);r.target.copy(A),i.position.copy(F),i.near=Math.max(_/1000,0.0001),i.far=M+_*100,r.minDistance=_*0.1,r.maxDistance=_*80,i.updateProjectionMatrix(),r.update()},R=new ResizeObserver(()=>{let{clientWidth:b,clientHeight:T}=e;if(!b||!T)return;t.setSize(b,T),i.aspect=b/T,i.updateProjectionMatrix()});R.observe(e);let S=(b)=>{if(p)return;let T=Math.min((b-d)/1000,0.1);if(d=b,h)u?.update(T);r.update(),t.render(n,i),g=requestAnimationFrame(S)};return g=requestAnimationFrame(S),{async load(b){let T=++x;zl(b);let A=new go;A.setURLModifier((C)=>{if(!C.startsWith("blob:")&&!C.startsWith("data:"))throw Error("External model resources are not loaded");return C});let _=await new Yh(A).parseAsync(Uint8Array.from(b).buffer,"");if(p||T!==x){m(_.scene);return}if(l)u?.stopAllAction(),u?.uncacheRoot(l),n.remove(l),m(l);l=_.scene,n.add(l),f=_.animations,u=new _c(l),h=!0;let{clientWidth:M,clientHeight:F}=e;t.setSize(M,F),i.aspect=M/F,E();let I=0,O=0,K=new Set;return l.traverse((C)=>{let G=C;if(!G.isMesh)return;O++,I+=(G.geometry.index?.count??G.geometry.attributes.position?.count??0)/3*(G.isInstancedMesh?G.count:1);for(let X of Array.isArray(G.material)?G.material:[G.material])K.add(X)}),{triangles:I,meshes:O,materials:K.size,clips:f.map((C)=>C.name)}},reset:E,wire(b){l?.traverse((T)=>{let A=T;if(A.isMesh){for(let _ of Array.isArray(A.material)?A.material:[A.material])if("wireframe"in _)_.wireframe=b}})},lighting(b){t.toneMappingExposure=b==="bright"?1.65:b==="soft"?0.85:1.15,c.intensity=b==="soft"?0.8:2.4},clip(b){if(u?.stopAllAction(),f[b])u?.clipAction(f[b]).play()},pause(b){h=!b},dispose(){if(p=!0,x++,cancelAnimationFrame(g),R.disconnect(),r.dispose(),l)m(l);a.dispose(),t.dispose(),e.replaceChildren()}}}var hv=/^[a-z][a-z0-9_-]{0,79}$/u,_1=/^r_[a-z0-9_-]{1,77}$/u;function fv(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!hv.test(n)||!hv.test(i)||!_1.test(r))return;return{collection:n,assetId:i,revisionId:r}}var Fe=(e)=>document.getElementById(e),St=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},Ss=[],Cr=[],Rr=[],Tc="",ys,Sn,Eo=0,dv=0,Ao=!1,Ro=!1,nr=new Set,tf=[],pv=[],Ar=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,mv=(e)=>{Fe("status").textContent=e},Ir=(e)=>mv(e instanceof Error?e.message:String(e)),Co=(e,t,n=tf)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function gv(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function x1(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/${Ar(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function v1(e,t){if(e.local){if(t==="editable.zip")return Co(kl([e.local]),"application/zip");return Co(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return Co(e.loose,"model/gltf-binary");return`/files/${Ar(e)}/${t}?download`}function _v(e,t){try{localStorage.setItem(e,t)}catch{}}function xv(e){try{return localStorage.getItem(e)}catch{return null}}function y1(){let e=Fe("collections");e.replaceChildren();for(let t of[...Ss,...Rr.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=St("button",t.label,Tc===t.id?"active":"");n.onclick=()=>void Ec(t.id).catch(Ir),e.append(n)}}async function Ec(e){let t=++dv;Tc=e,nr.clear(),y1(),mv("");let n=e==="opened-files"?Rr:(await gv(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((i)=>({collection:e,manifest:i}));if(t!==dv)return;Cr=n,_v("kiln.collection",e),Fe("collection-title").textContent=e==="opened-files"?"Opened files":Ss.find((i)=>i.id===e)?.label??e,Fe("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved revisions, editable source, and everything ready to use.",nf()}function S1(){let e=new Map;for(let t of Cr){let n=t.manifest.assetId;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===xv(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function nf(){for(let i of pv.splice(0))URL.revokeObjectURL(i);let e=Fe("cards");e.replaceChildren();let t=Fe("search").value.toLowerCase(),n=S1().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Fe("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Fe("export-selection").disabled=!nr.size,!n.length){let i=St("div",void 0,"empty");if(i.append(St("b",t?"No matching assets":"Your next idea belongs here."),St("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(St("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=St("article",void 0,"card"),o=St("button",void 0,"card-open");o.setAttribute("aria-label",`View ${r.name}`),o.onclick=()=>void wc(i).catch(Ir);let a=St("div",void 0,"thumb");if(r.files["preview.png"]){let d=St("img");d.loading="lazy",d.alt=r.name,d.src=i.local?Co(i.local.files["preview.png"],"image/png",pv):`/files/${Ar(i)}/preview.png`,d.onerror=()=>{d.remove(),a.textContent="◇"},a.append(d)}else a.textContent="◇";let c=St("div",void 0,"card-content");c.append(St("span",r.name,"card-title"));let l=Cr.filter((d)=>d.manifest.assetId===r.assetId),u=new Set(l.map((d)=>d.manifest.parentRevision)),f=l.filter((d)=>!u.has(d.manifest.revisionId));c.append(St("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${f.length>1?` · ${f.length} branches`:""}`,"card-meta"));let h=St("div",void 0,"tags");for(let d of r.tags)h.append(St("span",d,"tag"));if(c.append(h),o.append(a,c),s.append(o),!i.loose){let d=St("input");d.type="checkbox",d.className="selection",d.checked=nr.has(Ar(i)),d.setAttribute("aria-label",`Select ${r.name}`),d.onchange=()=>{if(d.checked)nr.add(Ar(i));else nr.delete(Ar(i));Fe("export-selection").disabled=!nr.size},s.append(d)}e.append(s)}}async function wc(e){let t=++Eo;ys=e,_v(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let a of tf.splice(0))URL.revokeObjectURL(a);let n=Fe("detail");if(!n.open)n.showModal();Fe("asset-name").textContent=e.manifest.name;let i=Fe("revisions");i.replaceChildren();for(let a of Cr.filter((c)=>c.manifest.assetId===e.manifest.assetId)){let c=St("option",`${new Date(a.manifest.createdAt).toLocaleString()} · ${a.manifest.description||a.manifest.revisionId.slice(0,10)}`);c.value=a.manifest.revisionId,c.selected=a.manifest.revisionId===e.manifest.revisionId,i.append(c)}i.onchange=()=>{let a=Cr.find((c)=>c.manifest.assetId===e.manifest.assetId&&c.manifest.revisionId===i.value);if(a)wc(a).catch(Ir)},Fe("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 r=Fe("asset-attribution");r.replaceChildren();for(let a of r_(e.manifest)){let c=St("div");c.append(St("span",a.label),St("strong",a.value)),r.append(c)}r.hidden=!r.childElementCount,Fe("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let s=Fe("downloads");s.replaceChildren();for(let[a,c]of[["asset.glb","Download GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let l=St("a",c);l.href=v1(e,a),l.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${a==="asset.glb"?".glb":a==="source.kiln.js"?".kiln.js":".zip"}`,s.append(l)}Fe("refine").disabled=!e.manifest.editable,Fe("asset-stats").replaceChildren(),Fe("stage-status").textContent="Loading saved GLB…",Ao=!1,Ro=!1,Fe("wire").setAttribute("aria-pressed","false"),Fe("play").textContent="Pause";let o=Fe("animation");o.replaceChildren(new Option("Rest pose","")),Fe("play").disabled=!0;try{Sn??=uv(Fe("stage"));let a=await x1(e,"asset.glb");if(t!==Eo)return;let c=await Sn.load(a);if(!c||t!==Eo)return;Sn.wire(!1),Sn.lighting(Fe("lighting").value);for(let[l,u]of[[c.triangles.toLocaleString(),"triangles"],[c.meshes,"meshes"],[c.materials,"materials"],[`${(a.length/1024).toFixed(0)} KB`,"GLB"]]){let f=St("div");f.append(St("strong",String(l)),St("span",String(u))),Fe("asset-stats").append(f)}for(let l=0;l<c.clips.length;l++)o.append(new Option(c.clips[l],String(l)));Fe("stage-status").textContent=""}catch(a){if(t===Eo)Sn?.dispose(),Sn=void 0,Fe("stage-status").textContent=`3D preview unavailable: ${a instanceof Error?a.message:a}. Downloads remain available.`}}async function vv(e){for(let t of e){if(t.bytes.length>mi)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of i_(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(!Rr.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Rr.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Rr.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 Ec("opened-files")}Fe("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>mi))throw Error("File exceeds 64 MiB");await vv(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ir(t)}};Fe("refresh").onclick=()=>void Ec(Tc).catch(Ir);Fe("search").oninput=nf;Fe("close-detail").onclick=()=>Fe("detail").close();Fe("detail").addEventListener("close",()=>{Eo++,Sn?.dispose(),Sn=void 0;for(let e of tf.splice(0))URL.revokeObjectURL(e);nf()});Fe("frame").onclick=()=>Sn?.reset();Fe("wire").onclick=()=>{Ao=!Ao,Sn?.wire(Ao),Fe("wire").setAttribute("aria-pressed",String(Ao))};Fe("lighting").onchange=(e)=>Sn?.lighting(e.target.value);Fe("animation").onchange=(e)=>{let t=e.target.value;Sn?.clip(t===""?-1:Number(t)),Fe("play").disabled=t===""};Fe("play").onclick=()=>{Ro=!Ro,Sn?.pause(Ro),Fe("play").textContent=Ro?"Play":"Pause"};Fe("refine").onclick=async()=>{if(!ys)return;let e=ys.manifest,t=ys.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=${ys.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=${ys.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Fe("refine").textContent="Instructions copied"}catch{Fe("provenance").textContent=t,Fe("provenance").parentElement?.setAttribute("open","")}};Fe("export-selection").onclick=()=>{try{let e=St("a");if(Tc==="opened-files")e.href=Co(kl(Cr.filter((t)=>nr.has(Ar(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of nr)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ir(e)}};async function b1(){Ss=(await gv("/api/collections")).collections;let e=fv(location.search),t=xv("kiln.collection");if(await Ec(Ss.find((n)=>n.id===e?.collection)?.id??Ss.find((n)=>n.id===t)?.id??Ss[0]?.id??"project"),e){let n=Cr.find((i)=>i.collection===e.collection&&i.manifest.assetId===e.assetId&&i.manifest.revisionId===e.revisionId);if(!n)throw Error("The requested saved revision is not available.");await wc(n)}if(new URLSearchParams(location.search).has("open")){let n=await fetch("/api/standalone");if(!n.ok)throw Error("File unavailable");if(await vv([{name:n.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await n.arrayBuffer())}]),Rr.length===1)await wc(Rr[0])}}b1().catch(Ir);
diff --git a/dist/viewer/chat.html b/dist/viewer/chat.html
index 109571f5..e80d1a91 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 Df="186",Ui={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Fi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Of=0,Hc=1,Uf=2;var Ts=1,Ff=2,$r=3,zi=0,Xt=1,wn=2,qn=0,Es=1,Vc=2,Wc=3,$c=4,zf=5;var Zr=100,kf=101,Bf=102,Gf=103,Hf=104,Vf=200,Wf=201,$f=202,Zf=203,Xf=204,qf=205,Yf=206,jf=207,Kf=208,Jf=209,Qf=210,ed=211,td=212,nd=213,id=214,rd=0,sd=1,od=2,Zc=3,ad=4,cd=5,ld=6,ud=7,hd=0,fd=1,dd=2,Dn=0,Xc=1,qc=2,Yc=3,As=4,jc=5,Kc=6,Jc=7;var Xr=301,cr=302,Yo=303,jo=304,Rs=306,qr=1000,Yr=1001,Ko=1002,On=1003,Jo=1004;var lr=1005;var kt=1006,jr=1007;var Yn=1008;var Un=1009,pd=1010,md=1011,Cs=1012,Qc=1013,ki=1014,xi=1015,jn=1016,el=1017,tl=1018,Kr=1020,gd=35902,_d=35899,xd=1021,vd=1022,Kn=1023,ur=1026,hr=1027,yd=1028,nl=1029,fr=1030,il=1031;var rl=1033,Qo=33776,ea=33777,ta=33778,na=33779,sl=35840,ol=35841,al=35842,cl=35843,ll=36196,ul=37492,hl=37496,fl=37488,dl=37489,ia=37490,pl=37491,ml=37808,gl=37809,_l=37810,xl=37811,vl=37812,yl=37813,Sl=37814,bl=37815,Ml=37816,wl=37817,Tl=37818,El=37819,Al=37820,Rl=37821,Cl=36492,Pl=36494,Il=36495,Ll=36283,Nl=36284,ra=36285,Dl=36286;var Ol=2300,sa=2301;var Ul=0,Ps=1,Jr=2;var Fl=0,Sd=1,dr="",Bi="srgb",hn="srgb-linear",zl="linear",ht="srgb";var bd=512,Md=513,wd=514,oa=515,Td=516,Ed=517,aa=518,Ad=519;var kl="300 es",Bl=2000;function ov(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function av(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Hr(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Rd(){let e=Hr("canvas");return e.style.display="block",e}var jh={},Vr=null;function ws(...e){let t="THREE."+e.shift();if(Vr)Vr("log",t,...e);else console.log(t,...e)}function Cd(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 Re(...e){e=Cd(e);let t="THREE."+e.shift();if(Vr)Vr("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=Cd(e);let t="THREE."+e.shift();if(Vr)Vr("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function or(...e){let t=e.join(" ");if(t in jh)return;jh[t]=!0,Re(...e)}function Pd(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 Id={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Fn{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 $t=["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"],Kh=1234567,bs=Math.PI/180,ar=180/Math.PI;function Nn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($t[e&255]+$t[e>>8&255]+$t[e>>16&255]+$t[e>>24&255]+"-"+$t[t&255]+$t[t>>8&255]+"-"+$t[t>>16&15|64]+$t[t>>24&255]+"-"+$t[n&63|128]+$t[n>>8&255]+"-"+$t[n>>16&255]+$t[n>>24&255]+$t[i&255]+$t[i>>8&255]+$t[i>>16&255]+$t[i>>24&255]).toLowerCase()}function $e(e,t,n){return Math.max(t,Math.min(n,e))}function Gl(e,t){return(e%t+t)%t}function cv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function lv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Ms(e,t,n){return(1-n)*e+n*t}function uv(e,t,n,i){return Ms(e,t,1-Math.exp(-n*i))}function hv(e,t=1){return t-Math.abs(Gl(e,t*2)-t)}function fv(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 dv(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 pv(e,t){return e+Math.floor(Math.random()*(t-e+1))}function mv(e,t){return e+Math.random()*(t-e)}function gv(e){return e*(0.5-Math.random())}function _v(e){if(e!==void 0)Kh=e;let t=Kh+=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 xv(e){return e*bs}function vv(e){return e*ar}function yv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Sv(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function bv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Mv(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Re("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ln(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 st(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 Is={DEG2RAD:bs,RAD2DEG:ar,generateUUID:Nn,clamp:$e,euclideanModulo:Gl,mapLinear:cv,inverseLerp:lv,lerp:Ms,damp:uv,pingpong:hv,smoothstep:fv,smootherstep:dv,randInt:pv,randFloat:mv,randFloatSpread:gv,seededRandom:_v,degToRad:xv,radToDeg:vv,isPowerOfTwo:yv,ceilPowerOfTwo:Sv,floorPowerOfTwo:bv,setQuaternionFromProperEuler:Mv,normalize:st,denormalize:Ln};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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($e(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 Ft{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Re("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($e(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(Jh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Jh.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=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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 _c.copy(this).projectOnVector(e),this.sub(_c)}reflect(e){return this.sub(_c.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($e(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 _c=new U,Jh=new Ft;class Fe{static{Fe.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],S=i[2],b=i[5],T=i[8];return r[0]=s*g+o*m+a*S,r[3]=s*x+o*E+a*b,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*S,r[4]=c*x+l*E+u*b,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*S,r[5]=f*x+h*E+d*b,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return or("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xc.makeScale(e,t)),this}rotate(e){return or("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xc.makeRotation(-e)),this}translate(e,t){return or("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xc.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 xc=new Fe,Qh=new Fe().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),ef=new Fe().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function wv(){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=_i(r.r),r.g=_i(r.g),r.b=_i(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=Gr(r.r),r.g=Gr(r.g),r.b=Gr(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 or("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return or("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:Qh,fromXYZ:ef,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:Qh,fromXYZ:ef,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var We=wv();function _i(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Gr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Ar;class Hl{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(Ar===void 0)Ar=Hr("canvas");Ar.width=e.width,Ar.height=e.height;let i=Ar.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Ar}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=Hr("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]=_i(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(_i(t[n]/255)*255);else t[n]=_i(t[n]);return{data:t,width:e.width,height:e.height}}else return Re("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Tv=0;class Ls{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Tv++}),this.uuid=Nn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(vc(i[s].image));else r.push(vc(i[s]))}else r=vc(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function vc(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Hl.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 Re("Texture: Unable to serialize Texture."),{}}var Ev=0,yc=new U;class Mt extends Fn{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Mt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Ev++}),this.uuid=Nn(),this.name="",this.source=new Ls(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fe,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(yc).x}get height(){return this.source.getSize(yc).y}get depth(){return this.source.getSize(yc).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){Re(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Re(`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++}}Mt.DEFAULT_IMAGE=null;Mt.DEFAULT_MAPPING=300;Mt.DEFAULT_ANISOTROPY=1;class ot{static{ot.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,S=(p+1)/2,b=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>S)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=b/n,r=T/n;else if(R>S)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=b/i,r=A/i;else if(S<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(S),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this.w=$e(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this.w=$e(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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 Vl extends Fn{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 ot(0,0,e,t),this.scissorTest=!1,this.viewport=new ot(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Mt(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 Ls(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 fn extends Vl{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class ca extends Mt{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 Wl extends Mt{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 Be{static{Be.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Be().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/Rr.setFromMatrixColumn(e,0).length(),r=1/Rr.setFromMatrixColumn(e,1).length(),s=1/Rr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Av,e,Rv)}lookAt(e,t,n){let i=this.elements;if(ln.subVectors(e,t),ln.lengthSq()===0)ln.z=1;if(ln.normalize(),Ci.crossVectors(n,ln),Ci.lengthSq()===0){if(Math.abs(n.z)===1)ln.x+=0.0001;else ln.z+=0.0001;ln.normalize(),Ci.crossVectors(n,ln)}return Ci.normalize(),So.crossVectors(ln,Ci),i[0]=Ci.x,i[4]=So.x,i[8]=ln.x,i[1]=Ci.y,i[5]=So.y,i[9]=ln.y,i[2]=Ci.z,i[6]=So.z,i[10]=ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],S=n[15],b=i[0],T=i[4],A=i[8],_=i[12],M=i[1],F=i[5],P=i[9],O=i[13],K=i[2],C=i[6],G=i[10],X=i[14],z=i[3],te=i[7],H=i[11],Q=i[15];return r[0]=s*b+o*M+a*K+c*z,r[4]=s*T+o*F+a*C+c*te,r[8]=s*A+o*P+a*G+c*H,r[12]=s*_+o*O+a*X+c*Q,r[1]=l*b+u*M+f*K+h*z,r[5]=l*T+u*F+f*C+h*te,r[9]=l*A+u*P+f*G+h*H,r[13]=l*_+u*O+f*X+h*Q,r[2]=d*b+g*M+x*K+p*z,r[6]=d*T+g*F+x*C+p*te,r[10]=d*A+g*P+x*G+p*H,r[14]=d*_+g*O+x*X+p*Q,r[3]=m*b+E*M+R*K+S*z,r[7]=m*T+E*F+R*C+S*te,r[11]=m*A+E*P+R*G+S*H,r[15]=m*_+E*O+R*X+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,S=s*h-c*l,b=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*S+p*b)+i*(d*E-g*S+p*T)-r*(d*R-g*b+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,S=n*a-i*o,b=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,M=l*p-h*d,F=u*x-f*g,P=u*p-h*g,O=f*p-h*x,K=m*O-E*P+R*F+S*M-b*_+T*A;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/K;return e[0]=(o*O-a*P+c*F)*C,e[1]=(i*P-n*O-r*F)*C,e[2]=(g*T-x*b+p*S)*C,e[3]=(f*b-u*T-h*S)*C,e[4]=(a*M-s*O-c*_)*C,e[5]=(t*O-i*M+r*_)*C,e[6]=(x*R-d*T-p*E)*C,e[7]=(l*T-f*R+h*E)*C,e[8]=(s*P-o*M+c*A)*C,e[9]=(n*M-t*P-r*A)*C,e[10]=(d*b-g*R+p*m)*C,e[11]=(u*R-l*b-h*m)*C,e[12]=(o*_-s*F-a*A)*C,e[13]=(t*F-n*_+i*A)*C,e[14]=(g*E-d*S-x*m)*C,e[15]=(l*S-u*E+f*m)*C,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:S,y:b,z:T}=n;return i[0]=(1-(g+p))*S,i[1]=(h+R)*S,i[2]=(d-E)*S,i[3]=0,i[4]=(h-R)*b,i[5]=(1-(f+p))*b,i[6]=(x+m)*b,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Rr.set(i[0],i[1],i[2]).length(),o=Rr.set(i[4],i[5],i[6]).length(),a=Rr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Cn.copy(this);let c=1/s,l=1/o,u=1/a;return Cn.elements[0]*=c,Cn.elements[1]*=c,Cn.elements[2]*=c,Cn.elements[4]*=l,Cn.elements[5]*=l,Cn.elements[6]*=l,Cn.elements[8]*=u,Cn.elements[9]*=u,Cn.elements[10]*=u,t.setFromRotationMatrix(Cn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Rr=new U,Cn=new Be,Av=new U(0,0,0),Rv=new U(1,1,1),Ci=new U,So=new U,ln=new U,tf=new Be,nf=new Ft;class Xn{constructor(e=0,t=0,n=0,i=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin($e(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-$e(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($e(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-$e(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin($e(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(-$e(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Re("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return tf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return nf.setFromEuler(this),this.setFromQuaternion(nf,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}}Xn.DEFAULT_ORDER="XYZ";class la{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Cv=0,rf=new U,Cr=new Ft,hi=new Be,bo=new U,ps=new U,Pv=new U,Iv=new Ft,sf=new U(1,0,0),of=new U(0,1,0),af=new U(0,0,1),cf={type:"added"},Lv={type:"removed"},Pr={type:"childadded",child:null},Sc={type:"childremoved",child:null};class lt extends Fn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Cv++}),this.uuid=Nn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=lt.DEFAULT_UP.clone();let e=new U,t=new Xn,n=new Ft,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 Be},normalMatrix:{value:new Fe}}),this.matrix=new Be,this.matrixWorld=new Be,this.matrixAutoUpdate=lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new la,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.multiply(Cr),this}rotateOnWorldAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.premultiply(Cr),this}rotateX(e){return this.rotateOnAxis(sf,e)}rotateY(e){return this.rotateOnAxis(of,e)}rotateZ(e){return this.rotateOnAxis(af,e)}translateOnAxis(e,t){return rf.copy(e).applyQuaternion(this.quaternion),this.position.add(rf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(sf,e)}translateY(e){return this.translateOnAxis(of,e)}translateZ(e){return this.translateOnAxis(af,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)bo.copy(e);else bo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ps.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)hi.lookAt(ps,bo,this.up);else hi.lookAt(bo,ps,this.up);if(this.quaternion.setFromRotationMatrix(hi),i)hi.extractRotation(i.matrixWorld),Cr.setFromRotationMatrix(hi),this.quaternion.premultiply(Cr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(cf),Pr.child=e,this.dispatchEvent(Pr),Pr.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lv),Sc.child=e,this.dispatchEvent(Sc),Sc.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),hi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),hi.multiply(e.parent.matrixWorld);return e.applyMatrix4(hi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(cf),Pr.child=e,this.dispatchEvent(Pr),Pr.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(ps,e,Pv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ps,Iv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}lt.DEFAULT_UP=new U(0,1,0);lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class $n extends lt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Nv={type:"move"};class Ns{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new $n,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 $n,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 $n,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 g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Nv)}}}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 $n;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var Ld={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},Pi={h:0,s:0,l:0},Mo={h:0,s:0,l:0};function bc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,We.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=We.workingColorSpace){return this.r=e,this.g=t,this.b=n,We.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=We.workingColorSpace){if(e=Gl(e,1),t=$e(t,0,1),n=$e(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=bc(s,r,e+0.3333333333333333),this.g=bc(s,r,e),this.b=bc(s,r,e-0.3333333333333333)}return We.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Re("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:Re("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 Re("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=Ld[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Re("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=_i(e.r),this.g=_i(e.g),this.b=_i(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return We.workingToColorSpace(Zt.copy(this),e),Math.round($e(Zt.r*255,0,255))*65536+Math.round($e(Zt.g*255,0,255))*256+Math.round($e(Zt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=We.workingColorSpace){We.workingToColorSpace(Zt.copy(this),t);let{r:n,g:i,b:r}=Zt,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=We.workingColorSpace){return We.workingToColorSpace(Zt.copy(this),t),e.r=Zt.r,e.g=Zt.g,e.b=Zt.b,e}getStyle(e="srgb"){We.workingToColorSpace(Zt.copy(this),e);let{r:t,g:n,b:i}=Zt;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(Pi),this.setHSL(Pi.h+e,Pi.s+t,Pi.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(Pi),e.getHSL(Mo);let n=Ms(Pi.h,Mo.h,t),i=Ms(Pi.s,Mo.s,t),r=Ms(Pi.l,Mo.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 Zt=new Oe;Oe.NAMES=Ld;class Qr extends lt{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 Xn,this.environmentIntensity=1,this.environmentRotation=new Xn,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 Pn=new U,fi=new U,Mc=new U,di=new U,Ir=new U,Lr=new U,lf=new U,wc=new U,Tc=new U,Ec=new U,Ac=new ot,Rc=new ot,Cc=new ot;class Mn{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),Pn.subVectors(e,t),i.cross(Pn);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){Pn.subVectors(i,t),fi.subVectors(n,t),Mc.subVectors(e,t);let s=Pn.dot(Pn),o=Pn.dot(fi),a=Pn.dot(Mc),c=fi.dot(fi),l=fi.dot(Mc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,di)===null)return!1;return di.x>=0&&di.y>=0&&di.x+di.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,di)===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,di.x),a.addScaledVector(s,di.y),a.addScaledVector(o,di.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ac.setScalar(0),Rc.setScalar(0),Cc.setScalar(0),Ac.fromBufferAttribute(e,t),Rc.fromBufferAttribute(e,n),Cc.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ac,r.x),s.addScaledVector(Rc,r.y),s.addScaledVector(Cc,r.z),s}static isFrontFacing(e,t,n,i){return Pn.subVectors(n,t),fi.subVectors(e,t),Pn.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 Pn.subVectors(this.c,this.b),fi.subVectors(this.a,this.b),Pn.cross(fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Mn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Mn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Mn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Mn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mn.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;Ir.subVectors(i,n),Lr.subVectors(r,n),wc.subVectors(e,n);let a=Ir.dot(wc),c=Lr.dot(wc);if(a<=0&&c<=0)return t.copy(n);Tc.subVectors(e,i);let l=Ir.dot(Tc),u=Lr.dot(Tc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Ir,s);Ec.subVectors(e,r);let h=Ir.dot(Ec),d=Lr.dot(Ec);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Lr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return lf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(lf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Ir,s).addScaledVector(Lr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class en{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(In.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(In.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=In.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,In);else In.fromBufferAttribute(r,s);In.applyMatrix4(e.matrixWorld),this.expandByPoint(In)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();wo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();wo.copy(n.boundingBox)}wo.applyMatrix4(e.matrixWorld),this.union(wo)}}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,In),In.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(ms),To.subVectors(this.max,ms),Nr.subVectors(e.a,ms),Dr.subVectors(e.b,ms),Or.subVectors(e.c,ms),Ii.subVectors(Dr,Nr),Li.subVectors(Or,Dr),nr.subVectors(Nr,Or);let t=[0,-Ii.z,Ii.y,0,-Li.z,Li.y,0,-nr.z,nr.y,Ii.z,0,-Ii.x,Li.z,0,-Li.x,nr.z,0,-nr.x,-Ii.y,Ii.x,0,-Li.y,Li.x,0,-nr.y,nr.x,0];if(!Pc(t,Nr,Dr,Or,To))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Pc(t,Nr,Dr,Or,To))return!1;return Eo.crossVectors(Ii,Li),t=[Eo.x,Eo.y,Eo.z],Pc(t,Nr,Dr,Or,To)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,In).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(In).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 pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pi),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 pi=[new U,new U,new U,new U,new U,new U,new U,new U],In=new U,wo=new en,Nr=new U,Dr=new U,Or=new U,Ii=new U,Li=new U,nr=new U,ms=new U,To=new U,Eo=new U,ir=new U;function Pc(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){ir.fromArray(e,s);let a=r.x*Math.abs(ir.x)+r.y*Math.abs(ir.y)+r.z*Math.abs(ir.z),c=t.dot(ir),l=n.dot(ir),u=i.dot(ir);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Ct=new U,Ao=new Ne,Dv=0;class zt extends Fn{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:Dv++}),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++)Ao.fromBufferAttribute(this,t),Ao.applyMatrix3(e),this.setXY(t,Ao.x,Ao.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix3(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix4(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyNormalMatrix(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.transformDirection(e),this.setXYZ(t,Ct.x,Ct.y,Ct.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=Ln(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=st(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=Ln(t,this.array);return t}setX(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setY(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setZ(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setW(e,t){if(this.normalized)t=st(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=st(t,this.array),n=st(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=st(t,this.array),n=st(n,this.array),i=st(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=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(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 ua extends zt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ha extends zt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class sn extends zt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var Ov=new en,gs=new U,Ic=new U;class dn{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 Ov.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;gs.subVectors(e,this.center);let t=gs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(gs,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 Ic.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gs.copy(e.center).add(Ic)),this.expandByPoint(gs.copy(e.center).sub(Ic));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 Uv=0,Sn=new Be,Lc=new lt,Ur=new U,un=new en,_s=new en,Ut=new U;class qt extends Fn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Uv++}),this.uuid=Nn(),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((ov(e))?ha:ua)(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 Fe().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 Sn.makeRotationFromQuaternion(e),this.applyMatrix4(Sn),this}rotateX(e){return Sn.makeRotationX(e),this.applyMatrix4(Sn),this}rotateY(e){return Sn.makeRotationY(e),this.applyMatrix4(Sn),this}rotateZ(e){return Sn.makeRotationZ(e),this.applyMatrix4(Sn),this}translate(e,t,n){return Sn.makeTranslation(e,t,n),this.applyMatrix4(Sn),this}scale(e,t,n){return Sn.makeScale(e,t,n),this.applyMatrix4(Sn),this}lookAt(e){return Lc.lookAt(e),Lc.updateMatrix(),this.applyMatrix4(Lc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ur).negate(),this.translate(Ur.x,Ur.y,Ur.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 sn(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)Re("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 en;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new 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(un.setFromBufferAttribute(r),this.morphTargetsRelative)Ut.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(Ut),Ut.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(Ut);else this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new dn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(un.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(_s.setFromBufferAttribute(o),this.morphTargetsRelative)Ut.addVectors(un.min,_s.min),un.expandByPoint(Ut),Ut.addVectors(un.max,_s.max),un.expandByPoint(Ut);else un.expandByPoint(_s.min),un.expandByPoint(_s.max)}un.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Ut.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Ut));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(Ut.fromBufferAttribute(o,c),a)Ur.fromBufferAttribute(e,c),Ut.add(Ur);i=Math.max(i,n.distanceToSquared(Ut))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new zt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new U,a[A]=new U;let c=new U,l=new U,u=new U,f=new Ne,h=new Ne,d=new Ne,g=new U,x=new U;function p(A,_,M){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let F=1/(h.x*d.y-d.x*h.y);if(!isFinite(F))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(F),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(F),o[A].add(g),o[_].add(g),o[M].add(g),a[A].add(x),a[_].add(x),a[M].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:P}=M;for(let O=F,K=F+P;O<K;O+=3)p(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let E=new U,R=new U,S=new U,b=new U;function T(A){S.fromBufferAttribute(i,A),b.copy(S);let _=o[A];E.copy(_),E.sub(S.multiplyScalar(S.dot(_))).normalize(),R.crossVectors(b,_);let F=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,F)}for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:P}=M;for(let O=F,K=F+P;O<K;O+=3)T(e.getX(O+0)),T(e.getX(O+1)),T(e.getX(O+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 zt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new 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 f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ut.fromBufferAttribute(e,t),Ut.normalize(),e.setXYZ(t,Ut.x,Ut.y,Ut.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new zt(f,l,u)}if(this.index===null)return Re("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new qt,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ds{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=Nn()}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=Nn();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=Nn();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 Qt=new U;class es{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++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qt.fromBufferAttribute(this,t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qt.fromBufferAttribute(this,t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Ln(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=st(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Ln(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Ln(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Ln(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=st(t,this.array),n=st(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=st(t,this.array),n=st(n,this.array),i=st(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=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(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){ws("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 zt(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 es(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){ws("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 Nc=new U,Fv=new U,zv=new Fe;class bn{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=Nc.subVectors(n,t).cross(Fv.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(Nc),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||zv.getNormalMatrix(e),i=this.coplanarPoint(Nc).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}var kv=0;class on extends Fn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:kv++}),this.uuid=Nn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Re(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Re(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new bn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var mi=new U,Dc=new U,Ro=new U,Co=new U;class Gi{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,mi)),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=mi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return mi.copy(this.origin).addScaledVector(this.direction,t),mi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Dc.copy(e).add(t).multiplyScalar(0.5),Ro.copy(t).sub(e).normalize(),Co.copy(this.origin).sub(Dc);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ro),o=Co.dot(this.direction),a=-Co.dot(Ro),c=Co.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Dc).addScaledVector(Ro,f);return h}intersectSphere(e,t){if(e.radius<0)return null;mi.subVectors(e.center,this.origin);let n=mi.dot(this.direction),i=mi.dot(mi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,mi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),S=Math.abs(c),b=Math.abs(l),T,A,_,M,F,P,O,K,C,G,X,z;if(R>=S&&R>=b)if(_=a,P=u,C=d,z=p,a>=0)T=c,A=l,M=f,F=h,O=g,K=x,G=m,X=E;else T=l,A=c,M=h,F=f,O=x,K=g,G=E,X=m;else if(S>=b)if(_=c,P=f,C=g,z=m,c>=0)T=l,A=a,M=h,F=u,O=x,K=d,G=E,X=p;else T=a,A=l,M=u,F=h,O=d,K=x,G=p,X=E;else if(_=l,P=h,C=x,z=E,l>=0)T=a,A=c,M=u,F=f,O=d,K=g,G=p,X=m;else T=c,A=a,M=f,F=u,O=g,K=d,G=m,X=p;if(_===0)return null;let te=T/_,H=A/_,Q=1/_,ee=M-te*P,Te=F-H*P,ve=O-te*C,Ge=K-H*C,Me=G-te*z,Z=X-H*z,re=Me*Ge-Z*ve,se=ee*Z-Te*Me,Pe=ve*Te-Ge*ee;if(i){if(re<0||se<0||Pe<0)return null}else if((re<0||se<0||Pe<0)&&(re>0||se>0||Pe>0))return null;let Ie=re+se+Pe;if(Ie===0)return null;let we=Q*(re*P+se*C+Pe*z);if(Ie>0?we<0:we>0)return null;return this.at(we/Ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn extends on{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,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 uf=new Be,rr=new Gi,Po=new dn,hf=new U,Io=new U,Lo=new U,No=new U,Oc=new U,Do=new U,ff=new U,Oo=new U;class pt extends lt{constructor(e=new qt,t=new Jn){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){Do.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(Oc.fromBufferAttribute(u,e),s)Do.addScaledVector(Oc,l);else Do.addScaledVector(Oc.sub(t),l)}t.add(Do)}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(Po.copy(n.boundingSphere),Po.applyMatrix4(r),rr.copy(e.ray).recast(e.near),Po.containsPoint(rr.origin)===!1){if(rr.intersectSphere(Po,hf)===null)return;if(rr.origin.distanceToSquared(hf)>(e.far-e.near)**2)return}if(uf.copy(r).invert(),rr.copy(e.ray).applyMatrix4(uf),n.boundingBox!==null){if(rr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,rr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=Uo(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=Uo(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=R,T=R+1,A=R+2;if(i=Uo(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=Uo(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Bv(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;Oo.copy(a),Oo.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Oo);if(l<n.near||l>n.far)return null;return{distance:l,point:Oo.clone(),object:e}}function Uo(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Io),e.getVertexPosition(c,Lo),e.getVertexPosition(l,No);let u=Bv(e,t,n,i,Io,Lo,No,ff);if(u){let f=new U;if(Mn.getBarycoord(ff,Io,Lo,No,f),r)u.uv=Mn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Mn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Mn.getInterpolatedAttribute(o,a,c,l,f,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};Mn.getNormal(Io,Lo,No,h.normal),u.face=h,u.barycoord=f}return u}var xs=new ot,df=new ot,pf=new ot,Gv=new ot,mf=new Be,Fo=new U,Uc=new dn,gf=new Be,Fc=new Gi;class fa extends pt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Be,this.bindMatrixInverse=new Be,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new en;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingBox.expandByPoint(Fo)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new dn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingSphere.expandByPoint(Fo)}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(Uc.copy(this.boundingSphere),Uc.applyMatrix4(i),e.ray.intersectsSphere(Uc)===!1)return;if(gf.copy(i).invert(),Fc.copy(e.ray).applyMatrix4(gf),this.boundingBox!==null){if(Fc.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Fc)}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 ot,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 Re("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(df.fromBufferAttribute(i.attributes.skinIndex,e),pf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)xs.copy(t),t.set(0,0,0,0);else xs.set(...t,1),t.set(0,0,0);xs.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=pf.getComponent(r);if(s!==0){let o=df.getComponent(r);mf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Gv.copy(xs).applyMatrix4(mf),s)}}if(t.isVector4)t.w=xs.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Os extends lt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Us extends Mt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var _f=new Be,Hv=new Be;class Fs{constructor(e=[],t=[]){this.uuid=Nn(),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){Re("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 Be)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Be;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:Hv;_f.multiplyMatrices(o,t[r]),_f.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Fs(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 Us(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)Re("Skeleton: No bone found with UUID:",r),s=new Os;this.bones.push(s),this.boneInverses.push(new Be().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 Oi extends zt{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 Fr=new Be,xf=new Be,zo=[],vf=new en,Vv=new Be,vs=new pt,ys=new dn;class ts extends pt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Oi(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,Vv)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new en;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fr),vf.copy(e.boundingBox).applyMatrix4(Fr),this.boundingBox.union(vf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new dn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fr),ys.copy(e.boundingSphere).applyMatrix4(Fr),this.boundingSphere.union(ys)}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(vs.geometry=this.geometry,vs.material=this.material,vs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ys.copy(this.boundingSphere),ys.applyMatrix4(n),e.ray.intersectsSphere(ys)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Fr),xf.multiplyMatrices(n,Fr),vs.matrixWorld=xf,vs.raycast(e,zo);for(let s=0,o=zo.length;s<o;s++){let a=zo[s];a.instanceId=r,a.object=this,t.push(a)}zo.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Oi(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 Us(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 sr=new dn,Wv=new Ne(0.5,0.5),ko=new U;class zs{constructor(e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,s=new bn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],S=r[15];if(i[0].setComponents(c-s,h-l,p-d,S-m).normalize(),i[1].setComponents(c+s,h+l,p+d,S+m).normalize(),i[2].setComponents(c+o,h+u,p+g,S+E).normalize(),i[3].setComponents(c-o,h-u,p-g,S-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,S-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,S-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,S+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();sr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sr)}intersectsSprite(e){sr.center.set(0,0,0);let t=Wv.distanceTo(e.center);return sr.radius=0.7071067811865476+t,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}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(ko.x=i.normal.x>0?e.max.x:e.min.x,ko.y=i.normal.y>0?e.max.y:e.min.y,ko.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ko)<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 ks extends on{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Xo=new U,qo=new U,yf=new Be,Ss=new Gi,Bo=new dn,zc=new U,Sf=new U;class Hi extends lt{constructor(e=new qt,t=new ks){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++)Xo.fromBufferAttribute(t,i-1),qo.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Xo.distanceTo(qo);e.setAttribute("lineDistance",new sn(n,1))}else Re("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(Bo.copy(n.boundingSphere),Bo.applyMatrix4(i),Bo.radius+=r,e.ray.intersectsSphere(Bo)===!1)return;yf.copy(i).invert(),Ss.copy(e.ray).applyMatrix4(yf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=Go(this,e,Ss,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=Go(this,e,Ss,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=Go(this,e,Ss,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=Go(this,e,Ss,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Go(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Xo.fromBufferAttribute(a,r),qo.fromBufferAttribute(a,s),n.distanceSqToSegment(Xo,qo,zc,Sf)>i)return;zc.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(zc);if(l<t.near||l>t.far)return;return{distance:l,point:Sf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var bf=new U,Mf=new U;class da extends Hi{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)bf.fromBufferAttribute(t,i),Mf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+bf.distanceTo(Mf);e.setAttribute("lineDistance",new sn(n,1))}else Re("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class pa extends Hi{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Bs extends on{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var wf=new Be,Gc=new Gi,Ho=new dn,Vo=new U;class ns extends lt{constructor(e=new qt,t=new Bs){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(Ho.copy(n.boundingSphere),Ho.applyMatrix4(i),Ho.radius+=r,e.ray.intersectsSphere(Ho)===!1)return;wf.copy(i).invert(),Gc.copy(e.ray).applyMatrix4(wf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);Vo.fromBufferAttribute(u,x),Tf(Vo,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)Vo.fromBufferAttribute(u,d),Tf(Vo,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Tf(e,t,n,i,r,s,o){let a=Gc.distanceSqToPoint(e);if(a<n){let c=new U;Gc.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 ma extends Mt{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 pr extends Mt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ls(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class $l extends pr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class ga extends Mt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Vi extends qt{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new sn(c,3)),this.setAttribute("normal",new sn(l,3)),this.setAttribute("uv",new sn(u,2));function d(g,x,p,m,E,R,S,b,T,A,_){let M=R/T,F=S/A,P=R/2,O=S/2,K=b/2,C=T+1,G=A+1,X=0,z=0,te=new U;for(let H=0;H<G;H++){let Q=H*F-O;for(let ee=0;ee<C;ee++){let Te=ee*M-P;te[g]=Te*m,te[x]=Q*E,te[p]=K,c.push(te.x,te.y,te.z),te[g]=0,te[x]=0,te[p]=b>0?1:-1,l.push(te.x,te.y,te.z),u.push(ee/T),u.push(1-H/A),X+=1}}for(let H=0;H<A;H++)for(let Q=0;Q<T;Q++){let ee=f+Q+C*H,Te=f+Q+C*(H+1),ve=f+(Q+1)+C*(H+1),Ge=f+(Q+1)+C*H;a.push(ee,Te,Ge),a.push(Te,ve,Ge),z+=6}o.addGroup(h,z,_),h+=z,f+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Gs extends qt{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),S=m+1+c*(p+1),b=m+1+c*p;h.push(E,R,b),h.push(R,S,b)}this.setIndex(h),this.setAttribute("position",new sn(d,3)),this.setAttribute("normal",new sn(g,3)),this.setAttribute("uv",new sn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gs(e.width,e.height,e.widthSegments,e.heightSegments)}}function mr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(Ef(r))if(r.isRenderTargetTexture)Re("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(Ef(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 Yt(e){let t={};for(let n=0;n<e.length;n++){let i=mr(e[n]);for(let r in i)t[r]=i[r]}return t}function Ef(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function $v(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Zl(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return We.workingColorSpace}var Nd={clone:mr,merge:Yt},Zv=`void main() {
+ var Uf="186",Ui={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Fi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ff=0,Hc=1,zf=2;var Ts=1,kf=2,$r=3,zi=0,Xt=1,wn=2,qn=0,Es=1,Vc=2,Wc=3,$c=4,Bf=5;var Zr=100,Gf=101,Hf=102,Vf=103,Wf=104,$f=200,Zf=201,Xf=202,qf=203,Yf=204,jf=205,Kf=206,Jf=207,Qf=208,ed=209,td=210,nd=211,id=212,rd=213,sd=214,od=0,ad=1,cd=2,Zc=3,ld=4,ud=5,hd=6,fd=7,dd=0,pd=1,md=2,Dn=0,Xc=1,qc=2,Yc=3,As=4,jc=5,Kc=6,Jc=7;var Xr=301,cr=302,Yo=303,jo=304,Rs=306,qr=1000,Yr=1001,Ko=1002,On=1003,Jo=1004;var lr=1005;var kt=1006,jr=1007;var Yn=1008;var Un=1009,gd=1010,_d=1011,Cs=1012,Qc=1013,ki=1014,xi=1015,jn=1016,el=1017,tl=1018,Kr=1020,xd=35902,vd=35899,yd=1021,Sd=1022,Kn=1023,ur=1026,hr=1027,bd=1028,nl=1029,fr=1030,il=1031;var rl=1033,Qo=33776,ea=33777,ta=33778,na=33779,sl=35840,ol=35841,al=35842,cl=35843,ll=36196,ul=37492,hl=37496,fl=37488,dl=37489,ia=37490,pl=37491,ml=37808,gl=37809,_l=37810,xl=37811,vl=37812,yl=37813,Sl=37814,bl=37815,Ml=37816,wl=37817,Tl=37818,El=37819,Al=37820,Rl=37821,Cl=36492,Pl=36494,Il=36495,Ll=36283,Nl=36284,ra=36285,Dl=36286;var Ol=2300,sa=2301;var Ul=0,Ps=1,Jr=2;var Fl=0,Md=1,dr="",Bi="srgb",hn="srgb-linear",zl="linear",ht="srgb";var wd=512,Td=513,Ed=514,oa=515,Ad=516,Rd=517,aa=518,Cd=519;var kl="300 es",Bl=2000;function lv(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function uv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Hr(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Pd(){let e=Hr("canvas");return e.style.display="block",e}var Jh={},Vr=null;function ws(...e){let t="THREE."+e.shift();if(Vr)Vr("log",t,...e);else console.log(t,...e)}function Id(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 Re(...e){e=Id(e);let t="THREE."+e.shift();if(Vr)Vr("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ue(...e){e=Id(e);let t="THREE."+e.shift();if(Vr)Vr("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function or(...e){let t=e.join(" ");if(t in Jh)return;Jh[t]=!0,Re(...e)}function Ld(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 Nd={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class Fn{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 $t=["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"],Qh=1234567,bs=Math.PI/180,ar=180/Math.PI;function Nn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($t[e&255]+$t[e>>8&255]+$t[e>>16&255]+$t[e>>24&255]+"-"+$t[t&255]+$t[t>>8&255]+"-"+$t[t>>16&15|64]+$t[t>>24&255]+"-"+$t[n&63|128]+$t[n>>8&255]+"-"+$t[n>>16&255]+$t[n>>24&255]+$t[i&255]+$t[i>>8&255]+$t[i>>16&255]+$t[i>>24&255]).toLowerCase()}function $e(e,t,n){return Math.max(t,Math.min(n,e))}function Gl(e,t){return(e%t+t)%t}function hv(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function fv(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Ms(e,t,n){return(1-n)*e+n*t}function dv(e,t,n,i){return Ms(e,t,1-Math.exp(-n*i))}function pv(e,t=1){return t-Math.abs(Gl(e,t*2)-t)}function mv(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 gv(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 _v(e,t){return e+Math.floor(Math.random()*(t-e+1))}function xv(e,t){return e+Math.random()*(t-e)}function vv(e){return e*(0.5-Math.random())}function yv(e){if(e!==void 0)Qh=e;let t=Qh+=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 Sv(e){return e*bs}function bv(e){return e*ar}function Mv(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function wv(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Tv(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ev(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),f=s((t-i)/2),h=o((t-i)/2),d=s((i-t)/2),g=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*f,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*f,a*l);break;case"ZXZ":e.set(c*f,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*g,c*d,a*l);break;case"YXY":e.set(c*d,a*u,c*g,a*l);break;case"ZYZ":e.set(c*g,c*d,a*u,a*l);break;default:Re("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ln(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 st(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 Is={DEG2RAD:bs,RAD2DEG:ar,generateUUID:Nn,clamp:$e,euclideanModulo:Gl,mapLinear:hv,inverseLerp:fv,lerp:Ms,damp:dv,pingpong:pv,smoothstep:mv,smootherstep:gv,randInt:_v,randFloat:xv,randFloatSpread:vv,seededRandom:yv,degToRad:Sv,radToDeg:bv,isPowerOfTwo:Mv,ceilPowerOfTwo:wv,floorPowerOfTwo:Tv,setQuaternionFromProperEuler:Ev,normalize:st,denormalize:Ln};class Ne{static{Ne.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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($e(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 Ft{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],f=r[s+0],h=r[s+1],d=r[s+2],g=r[s+3];if(u!==g||a!==f||c!==h||l!==d){let x=a*f+c*h+l*d+u*g;if(x<0)f=-f,h=-h,d=-d,g=-g,x=-x;let p=1-o;if(x<0.9995){let m=Math.acos(x),E=Math.sin(m);p=Math.sin(p*m)/E,o=Math.sin(o*m)/E,a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o}else{a=a*p+f*o,c=c*p+h*o,l=l*p+d*o,u=u*p+g*o;let m=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=m,c*=m,l*=m,u*=m}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],f=r[s+1],h=r[s+2],d=r[s+3];return e[t]=o*d+l*u+a*h-c*f,e[t+1]=a*d+l*f+c*u-o*h,e[t+2]=c*d+l*h+o*f-a*u,e[t+3]=l*d-o*u-a*f-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),f=a(n/2),h=a(i/2),d=a(r/2);switch(s){case"XYZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"YXZ":this._x=f*l*u+c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"ZXY":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u-f*h*d;break;case"ZYX":this._x=f*l*u-c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u+f*h*d;break;case"YZX":this._x=f*l*u+c*h*d,this._y=c*h*u+f*l*d,this._z=c*l*d-f*h*u,this._w=c*l*u-f*h*d;break;case"XZY":this._x=f*l*u-c*h*d,this._y=c*h*u-f*l*d,this._z=c*l*d+f*h*u,this._w=c*l*u+f*h*d;break;default:Re("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],f=n+o+u;if(f>0){let h=0.5/Math.sqrt(f+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($e(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(ef.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ef.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=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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 _c.copy(this).projectOnVector(e),this.sub(_c)}reflect(e){return this.sub(_c.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($e(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 _c=new U,ef=new Ft;class Fe{static{Fe.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],f=n[2],h=n[5],d=n[8],g=i[0],x=i[3],p=i[6],m=i[1],E=i[4],R=i[7],S=i[2],b=i[5],T=i[8];return r[0]=s*g+o*m+a*S,r[3]=s*x+o*E+a*b,r[6]=s*p+o*R+a*T,r[1]=c*g+l*m+u*S,r[4]=c*x+l*E+u*b,r[7]=c*p+l*R+u*T,r[2]=f*g+h*m+d*S,r[5]=f*x+h*E+d*b,r[8]=f*p+h*R+d*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,f=o*a-l*r,h=c*r-s*a,d=t*u+n*f+i*h;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);let g=1/d;return e[0]=u*g,e[1]=(i*c-l*n)*g,e[2]=(o*n-i*s)*g,e[3]=f*g,e[4]=(l*t-i*a)*g,e[5]=(i*r-o*t)*g,e[6]=h*g,e[7]=(n*a-c*t)*g,e[8]=(s*t-n*r)*g,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return or("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xc.makeScale(e,t)),this}rotate(e){return or("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xc.makeRotation(-e)),this}translate(e,t){return or("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xc.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 xc=new Fe,tf=new Fe().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),nf=new Fe().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Av(){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=_i(r.r),r.g=_i(r.g),r.b=_i(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=Gr(r.r),r.g=Gr(r.g),r.b=Gr(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 or("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return or("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:nf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:tf,fromXYZ:nf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var We=Av();function _i(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Gr(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var Ar;class Hl{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(Ar===void 0)Ar=Hr("canvas");Ar.width=e.width,Ar.height=e.height;let i=Ar.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=Ar}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=Hr("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]=_i(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(_i(t[n]/255)*255);else t[n]=_i(t[n]);return{data:t,width:e.width,height:e.height}}else return Re("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var Rv=0;class Ls{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Rv++}),this.uuid=Nn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(vc(i[s].image));else r.push(vc(i[s]))}else r=vc(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function vc(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Hl.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 Re("Texture: Unable to serialize Texture."),{}}var Cv=0,yc=new U;class Mt extends Fn{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Mt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:Cv++}),this.uuid=Nn(),this.name="",this.source=new Ls(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ne(0,0),this.repeat=new Ne(1,1),this.center=new Ne(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fe,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(yc).x}get height(){return this.source.getSize(yc).y}get depth(){return this.source.getSize(yc).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){Re(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Re(`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++}}Mt.DEFAULT_IMAGE=null;Mt.DEFAULT_MAPPING=300;Mt.DEFAULT_ANISOTROPY=1;class ot{static{ot.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],f=a[1],h=a[5],d=a[9],g=a[2],x=a[6],p=a[10];if(Math.abs(l-f)<0.01&&Math.abs(u-g)<0.01&&Math.abs(d-x)<0.01){if(Math.abs(l+f)<0.1&&Math.abs(u+g)<0.1&&Math.abs(d+x)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let E=(c+1)/2,R=(h+1)/2,S=(p+1)/2,b=(l+f)/4,T=(u+g)/4,A=(d+x)/4;if(E>R&&E>S)if(E<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(E),i=b/n,r=T/n;else if(R>S)if(R<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(R),n=b/i,r=A/i;else if(S<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(S),n=T/r,i=A/r;return this.set(n,i,r,t),this}let m=Math.sqrt((x-d)*(x-d)+(u-g)*(u-g)+(f-l)*(f-l));if(Math.abs(m)<0.001)m=1;return this.x=(x-d)/m,this.y=(u-g)/m,this.z=(f-l)/m,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this.w=$e(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this.w=$e(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar($e(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 Vl extends Fn{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 ot(0,0,e,t),this.scissorTest=!1,this.viewport=new ot(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Mt(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 Ls(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 fn extends Vl{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class ca extends Mt{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 Wl extends Mt{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 Be{static{Be.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x)}set(e,t,n,i,r,s,o,a,c,l,u,f,h,d,g,x){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=f,p[3]=h,p[7]=d,p[11]=g,p[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Be().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/Rr.setFromMatrixColumn(e,0).length(),r=1/Rr.setFromMatrixColumn(e,1).length(),s=1/Rr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+d*c,t[5]=f-g*c,t[9]=-o*a,t[2]=g-f*c,t[6]=d+h*c,t[10]=s*a}else if(e.order==="YXZ"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f+g*o,t[4]=d*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-d,t[6]=g+f*o,t[10]=s*a}else if(e.order==="ZXY"){let f=a*l,h=a*u,d=c*l,g=c*u;t[0]=f-g*o,t[4]=-s*u,t[8]=d+h*o,t[1]=h+d*o,t[5]=s*l,t[9]=g-f*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let f=s*l,h=s*u,d=o*l,g=o*u;t[0]=a*l,t[4]=d*c-h,t[8]=f*c+g,t[1]=a*u,t[5]=g*c+f,t[9]=h*c-d,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=g-f*u,t[8]=d*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+d,t[10]=f-g*u}else if(e.order==="XZY"){let f=s*a,h=s*c,d=o*a,g=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=f*u+g,t[5]=s*l,t[9]=h*u-d,t[2]=d*u-h,t[6]=o*l,t[10]=g*u+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Pv,e,Iv)}lookAt(e,t,n){let i=this.elements;if(ln.subVectors(e,t),ln.lengthSq()===0)ln.z=1;if(ln.normalize(),Ci.crossVectors(n,ln),Ci.lengthSq()===0){if(Math.abs(n.z)===1)ln.x+=0.0001;else ln.z+=0.0001;ln.normalize(),Ci.crossVectors(n,ln)}return Ci.normalize(),So.crossVectors(ln,Ci),i[0]=Ci.x,i[4]=So.x,i[8]=ln.x,i[1]=Ci.y,i[5]=So.y,i[9]=ln.y,i[2]=Ci.z,i[6]=So.z,i[10]=ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],f=n[9],h=n[13],d=n[2],g=n[6],x=n[10],p=n[14],m=n[3],E=n[7],R=n[11],S=n[15],b=i[0],T=i[4],A=i[8],_=i[12],M=i[1],F=i[5],P=i[9],O=i[13],K=i[2],C=i[6],G=i[10],X=i[14],z=i[3],te=i[7],H=i[11],Q=i[15];return r[0]=s*b+o*M+a*K+c*z,r[4]=s*T+o*F+a*C+c*te,r[8]=s*A+o*P+a*G+c*H,r[12]=s*_+o*O+a*X+c*Q,r[1]=l*b+u*M+f*K+h*z,r[5]=l*T+u*F+f*C+h*te,r[9]=l*A+u*P+f*G+h*H,r[13]=l*_+u*O+f*X+h*Q,r[2]=d*b+g*M+x*K+p*z,r[6]=d*T+g*F+x*C+p*te,r[10]=d*A+g*P+x*G+p*H,r[14]=d*_+g*O+x*X+p*Q,r[3]=m*b+E*M+R*K+S*z,r[7]=m*T+E*F+R*C+S*te,r[11]=m*A+E*P+R*G+S*H,r[15]=m*_+E*O+R*X+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],f=e[10],h=e[14],d=e[3],g=e[7],x=e[11],p=e[15],m=a*h-c*f,E=o*h-c*u,R=o*f-a*u,S=s*h-c*l,b=s*f-a*l,T=s*u-o*l;return t*(g*m-x*E+p*R)-n*(d*m-x*S+p*b)+i*(d*E-g*S+p*T)-r*(d*R-g*b+x*T)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],g=e[13],x=e[14],p=e[15],m=t*o-n*s,E=t*a-i*s,R=t*c-r*s,S=n*a-i*o,b=n*c-r*o,T=i*c-r*a,A=l*g-u*d,_=l*x-f*d,M=l*p-h*d,F=u*x-f*g,P=u*p-h*g,O=f*p-h*x,K=m*O-E*P+R*F+S*M-b*_+T*A;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/K;return e[0]=(o*O-a*P+c*F)*C,e[1]=(i*P-n*O-r*F)*C,e[2]=(g*T-x*b+p*S)*C,e[3]=(f*b-u*T-h*S)*C,e[4]=(a*M-s*O-c*_)*C,e[5]=(t*O-i*M+r*_)*C,e[6]=(x*R-d*T-p*E)*C,e[7]=(l*T-f*R+h*E)*C,e[8]=(s*P-o*M+c*A)*C,e[9]=(n*M-t*P-r*A)*C,e[10]=(d*b-g*R+p*m)*C,e[11]=(u*R-l*b-h*m)*C,e[12]=(o*_-s*F-a*A)*C,e[13]=(t*F-n*_+i*A)*C,e[14]=(g*E-d*S-x*m)*C,e[15]=(l*S-u*E+f*m)*C,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,f=r*c,h=r*l,d=r*u,g=s*l,x=s*u,p=o*u,m=a*c,E=a*l,R=a*u,{x:S,y:b,z:T}=n;return i[0]=(1-(g+p))*S,i[1]=(h+R)*S,i[2]=(d-E)*S,i[3]=0,i[4]=(h-R)*b,i[5]=(1-(f+p))*b,i[6]=(x+m)*b,i[7]=0,i[8]=(d+E)*T,i[9]=(x-m)*T,i[10]=(1-(f+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=Rr.set(i[0],i[1],i[2]).length(),o=Rr.set(i[4],i[5],i[6]).length(),a=Rr.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Cn.copy(this);let c=1/s,l=1/o,u=1/a;return Cn.elements[0]*=c,Cn.elements[1]*=c,Cn.elements[2]*=c,Cn.elements[4]*=l,Cn.elements[5]*=l,Cn.elements[6]*=l,Cn.elements[8]*=u,Cn.elements[9]*=u,Cn.elements[10]*=u,t.setFromRotationMatrix(Cn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i),d,g;if(a)d=r/(s-r),g=s*r/(s-r);else if(o===2000)d=-(s+r)/(s-r),g=-2*s*r/(s-r);else if(o===2001)d=-s/(s-r),g=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),f=-(t+e)/(t-e),h=-(n+i)/(n-i),d,g;if(a)d=1/(s-r),g=s/(s-r);else if(o===2000)d=-2/(s-r),g=-(s+r)/(s-r);else if(o===2001)d=-1/(s-r),g=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=f,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var Rr=new U,Cn=new Be,Pv=new U(0,0,0),Iv=new U(1,1,1),Ci=new U,So=new U,ln=new U,rf=new Be,sf=new Ft;class Xn{constructor(e=0,t=0,n=0,i=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],f=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin($e(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(f,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-$e(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($e(f,-1,1)),Math.abs(f)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-$e(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(f,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin($e(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(-$e(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(f,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Re("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return rf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(rf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sf.setFromEuler(this),this.setFromQuaternion(sf,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}}Xn.DEFAULT_ORDER="XYZ";class la{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}var Lv=0,of=new U,Cr=new Ft,hi=new Be,bo=new U,ps=new U,Nv=new U,Dv=new Ft,af=new U(1,0,0),cf=new U(0,1,0),lf=new U(0,0,1),uf={type:"added"},Ov={type:"removed"},Pr={type:"childadded",child:null},Sc={type:"childremoved",child:null};class lt extends Fn{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lv++}),this.uuid=Nn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=lt.DEFAULT_UP.clone();let e=new U,t=new Xn,n=new Ft,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 Be},normalMatrix:{value:new Fe}}),this.matrix=new Be,this.matrixWorld=new Be,this.matrixAutoUpdate=lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new la,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.multiply(Cr),this}rotateOnWorldAxis(e,t){return Cr.setFromAxisAngle(e,t),this.quaternion.premultiply(Cr),this}rotateX(e){return this.rotateOnAxis(af,e)}rotateY(e){return this.rotateOnAxis(cf,e)}rotateZ(e){return this.rotateOnAxis(lf,e)}translateOnAxis(e,t){return of.copy(e).applyQuaternion(this.quaternion),this.position.add(of.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(af,e)}translateY(e){return this.translateOnAxis(cf,e)}translateZ(e){return this.translateOnAxis(lf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)bo.copy(e);else bo.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ps.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)hi.lookAt(ps,bo,this.up);else hi.lookAt(bo,ps,this.up);if(this.quaternion.setFromRotationMatrix(hi),i)hi.extractRotation(i.matrixWorld),Cr.setFromRotationMatrix(hi),this.quaternion.premultiply(Cr.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return Ue("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(uf),Pr.child=e,this.dispatchEvent(Pr),Pr.child=null;else Ue("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ov),Sc.child=e,this.dispatchEvent(Sc),Sc.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),hi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),hi.multiply(e.parent.matrixWorld);return e.applyMatrix4(hi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(uf),Pr.child=e,this.dispatchEvent(Pr),Pr.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(ps,e,Nv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ps,Dv,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),f=s(e.skeletons),h=s(e.animations),d=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(f.length>0)n.skeletons=f;if(h.length>0)n.animations=h;if(d.length>0)n.nodes=d}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}lt.DEFAULT_UP=new U(0,1,0);lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class $n extends lt{constructor(){super();this.isGroup=!0,this.type="Group"}}var Uv={type:"move"};class Ns{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new $n,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 $n,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 $n,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 g of e.hand.values()){let x=t.getJointPose(g,n),p=this._getHandJoint(c,g);if(x!==null)p.matrix.fromArray(x.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=x.radius;p.visible=x!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=l.position.distanceTo(u.position),h=0.02,d=0.005;if(c.inputState.pinching&&f>h+d)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&f<=h-d)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(Uv)}}}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 $n;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var Dd={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},Pi={h:0,s:0,l:0},Mo={h:0,s:0,l:0};function bc(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,We.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=We.workingColorSpace){return this.r=e,this.g=t,this.b=n,We.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=We.workingColorSpace){if(e=Gl(e,1),t=$e(t,0,1),n=$e(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=bc(s,r,e+0.3333333333333333),this.g=bc(s,r,e),this.b=bc(s,r,e-0.3333333333333333)}return We.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Re("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:Re("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 Re("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=Dd[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Re("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=_i(e.r),this.g=_i(e.g),this.b=_i(e.b),this}copyLinearToSRGB(e){return this.r=Gr(e.r),this.g=Gr(e.g),this.b=Gr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return We.workingToColorSpace(Zt.copy(this),e),Math.round($e(Zt.r*255,0,255))*65536+Math.round($e(Zt.g*255,0,255))*256+Math.round($e(Zt.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=We.workingColorSpace){We.workingToColorSpace(Zt.copy(this),t);let{r:n,g:i,b:r}=Zt,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=We.workingColorSpace){return We.workingToColorSpace(Zt.copy(this),t),e.r=Zt.r,e.g=Zt.g,e.b=Zt.b,e}getStyle(e="srgb"){We.workingToColorSpace(Zt.copy(this),e);let{r:t,g:n,b:i}=Zt;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(Pi),this.setHSL(Pi.h+e,Pi.s+t,Pi.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(Pi),e.getHSL(Mo);let n=Ms(Pi.h,Mo.h,t),i=Ms(Pi.s,Mo.s,t),r=Ms(Pi.l,Mo.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 Zt=new Oe;Oe.NAMES=Dd;class Qr extends lt{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 Xn,this.environmentIntensity=1,this.environmentRotation=new Xn,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 Pn=new U,fi=new U,Mc=new U,di=new U,Ir=new U,Lr=new U,hf=new U,wc=new U,Tc=new U,Ec=new U,Ac=new ot,Rc=new ot,Cc=new ot;class Mn{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),Pn.subVectors(e,t),i.cross(Pn);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){Pn.subVectors(i,t),fi.subVectors(n,t),Mc.subVectors(e,t);let s=Pn.dot(Pn),o=Pn.dot(fi),a=Pn.dot(Mc),c=fi.dot(fi),l=fi.dot(Mc),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let f=1/u,h=(c*a-o*l)*f,d=(s*l-o*a)*f;return r.set(1-h-d,d,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,di)===null)return!1;return di.x>=0&&di.y>=0&&di.x+di.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,di)===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,di.x),a.addScaledVector(s,di.y),a.addScaledVector(o,di.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Ac.setScalar(0),Rc.setScalar(0),Cc.setScalar(0),Ac.fromBufferAttribute(e,t),Rc.fromBufferAttribute(e,n),Cc.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Ac,r.x),s.addScaledVector(Rc,r.y),s.addScaledVector(Cc,r.z),s}static isFrontFacing(e,t,n,i){return Pn.subVectors(n,t),fi.subVectors(e,t),Pn.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 Pn.subVectors(this.c,this.b),fi.subVectors(this.a,this.b),Pn.cross(fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Mn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Mn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Mn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Mn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mn.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;Ir.subVectors(i,n),Lr.subVectors(r,n),wc.subVectors(e,n);let a=Ir.dot(wc),c=Lr.dot(wc);if(a<=0&&c<=0)return t.copy(n);Tc.subVectors(e,i);let l=Ir.dot(Tc),u=Lr.dot(Tc);if(l>=0&&u<=l)return t.copy(i);let f=a*u-l*c;if(f<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(Ir,s);Ec.subVectors(e,r);let h=Ir.dot(Ec),d=Lr.dot(Ec);if(d>=0&&h<=d)return t.copy(r);let g=h*c-a*d;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Lr,o);let x=l*d-h*u;if(x<=0&&u-l>=0&&h-d>=0)return hf.subVectors(r,i),o=(u-l)/(u-l+(h-d)),t.copy(i).addScaledVector(hf,o);let p=1/(x+g+f);return s=g*p,o=f*p,t.copy(n).addScaledVector(Ir,s).addScaledVector(Lr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class en{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(In.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(In.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=In.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,In);else In.fromBufferAttribute(r,s);In.applyMatrix4(e.matrixWorld),this.expandByPoint(In)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();wo.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();wo.copy(n.boundingBox)}wo.applyMatrix4(e.matrixWorld),this.union(wo)}}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,In),In.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(ms),To.subVectors(this.max,ms),Nr.subVectors(e.a,ms),Dr.subVectors(e.b,ms),Or.subVectors(e.c,ms),Ii.subVectors(Dr,Nr),Li.subVectors(Or,Dr),nr.subVectors(Nr,Or);let t=[0,-Ii.z,Ii.y,0,-Li.z,Li.y,0,-nr.z,nr.y,Ii.z,0,-Ii.x,Li.z,0,-Li.x,nr.z,0,-nr.x,-Ii.y,Ii.x,0,-Li.y,Li.x,0,-nr.y,nr.x,0];if(!Pc(t,Nr,Dr,Or,To))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Pc(t,Nr,Dr,Or,To))return!1;return Eo.crossVectors(Ii,Li),t=[Eo.x,Eo.y,Eo.z],Pc(t,Nr,Dr,Or,To)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,In).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(In).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 pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pi),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 pi=[new U,new U,new U,new U,new U,new U,new U,new U],In=new U,wo=new en,Nr=new U,Dr=new U,Or=new U,Ii=new U,Li=new U,nr=new U,ms=new U,To=new U,Eo=new U,ir=new U;function Pc(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){ir.fromArray(e,s);let a=r.x*Math.abs(ir.x)+r.y*Math.abs(ir.y)+r.z*Math.abs(ir.z),c=t.dot(ir),l=n.dot(ir),u=i.dot(ir);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var Ct=new U,Ao=new Ne,Fv=0;class zt extends Fn{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:Fv++}),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++)Ao.fromBufferAttribute(this,t),Ao.applyMatrix3(e),this.setXY(t,Ao.x,Ao.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix3(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyMatrix4(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.applyNormalMatrix(e),this.setXYZ(t,Ct.x,Ct.y,Ct.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ct.fromBufferAttribute(this,t),Ct.transformDirection(e),this.setXYZ(t,Ct.x,Ct.y,Ct.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=Ln(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=st(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=Ln(t,this.array);return t}setX(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setY(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setZ(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}setW(e,t){if(this.normalized)t=st(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=st(t,this.array),n=st(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=st(t,this.array),n=st(n,this.array),i=st(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=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(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 ua extends zt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class ha extends zt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class sn extends zt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var zv=new en,gs=new U,Ic=new U;class dn{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 zv.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;gs.subVectors(e,this.center);let t=gs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(gs,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 Ic.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gs.copy(e.center).add(Ic)),this.expandByPoint(gs.copy(e.center).sub(Ic));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 kv=0,Sn=new Be,Lc=new lt,Ur=new U,un=new en,_s=new en,Ut=new U;class qt extends Fn{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kv++}),this.uuid=Nn(),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((lv(e))?ha:ua)(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 Fe().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 Sn.makeRotationFromQuaternion(e),this.applyMatrix4(Sn),this}rotateX(e){return Sn.makeRotationX(e),this.applyMatrix4(Sn),this}rotateY(e){return Sn.makeRotationY(e),this.applyMatrix4(Sn),this}rotateZ(e){return Sn.makeRotationZ(e),this.applyMatrix4(Sn),this}translate(e,t,n){return Sn.makeTranslation(e,t,n),this.applyMatrix4(Sn),this}scale(e,t,n){return Sn.makeScale(e,t,n),this.applyMatrix4(Sn),this}lookAt(e){return Lc.lookAt(e),Lc.updateMatrix(),this.applyMatrix4(Lc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ur).negate(),this.translate(Ur.x,Ur.y,Ur.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 sn(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)Re("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 en;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new 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(un.setFromBufferAttribute(r),this.morphTargetsRelative)Ut.addVectors(this.boundingBox.min,un.min),this.boundingBox.expandByPoint(Ut),Ut.addVectors(this.boundingBox.max,un.max),this.boundingBox.expandByPoint(Ut);else this.boundingBox.expandByPoint(un.min),this.boundingBox.expandByPoint(un.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ue('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new dn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(un.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(_s.setFromBufferAttribute(o),this.morphTargetsRelative)Ut.addVectors(un.min,_s.min),un.expandByPoint(Ut),Ut.addVectors(un.max,_s.max),un.expandByPoint(Ut);else un.expandByPoint(_s.min),un.expandByPoint(_s.max)}un.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Ut.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Ut));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(Ut.fromBufferAttribute(o,c),a)Ur.fromBufferAttribute(e,c),Ut.add(Ur);i=Math.max(i,n.distanceToSquared(Ut))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new zt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new U,a[A]=new U;let c=new U,l=new U,u=new U,f=new Ne,h=new Ne,d=new Ne,g=new U,x=new U;function p(A,_,M){c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,_),u.fromBufferAttribute(n,M),f.fromBufferAttribute(r,A),h.fromBufferAttribute(r,_),d.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(f),d.sub(f);let F=1/(h.x*d.y-d.x*h.y);if(!isFinite(F))return;g.copy(l).multiplyScalar(d.y).addScaledVector(u,-h.y).multiplyScalar(F),x.copy(u).multiplyScalar(h.x).addScaledVector(l,-d.x).multiplyScalar(F),o[A].add(g),o[_].add(g),o[M].add(g),a[A].add(x),a[_].add(x),a[M].add(x)}let m=this.groups;if(m.length===0)m=[{start:0,count:e.count}];for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:P}=M;for(let O=F,K=F+P;O<K;O+=3)p(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let E=new U,R=new U,S=new U,b=new U;function T(A){S.fromBufferAttribute(i,A),b.copy(S);let _=o[A];E.copy(_),E.sub(S.multiplyScalar(S.dot(_))).normalize(),R.crossVectors(b,_);let F=R.dot(a[A])<0?-1:1;s.setXYZW(A,E.x,E.y,E.z,F)}for(let A=0,_=m.length;A<_;++A){let M=m[A],{start:F,count:P}=M;for(let O=F,K=F+P;O<K;O+=3)T(e.getX(O+0)),T(e.getX(O+1)),T(e.getX(O+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 zt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,h=n.count;f<h;f++)n.setXYZ(f,0,0,0);let i=new 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 f=0,h=e.count;f<h;f+=3){let d=e.getX(f+0),g=e.getX(f+1),x=e.getX(f+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,d),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),o.add(l),a.add(l),c.add(l),n.setXYZ(d,o.x,o.y,o.z),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z)}else for(let f=0,h=t.count;f<h;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(f+0,l.x,l.y,l.z),n.setXYZ(f+1,l.x,l.y,l.z),n.setXYZ(f+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ut.fromBufferAttribute(e,t),Ut.normalize(),e.setXYZ(t,Ut.x,Ut.y,Ut.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,f=new c.constructor(a.length*l),h=0,d=0;for(let g=0,x=a.length;g<x;g++){if(o.isInterleavedBufferAttribute)h=a[g]*o.data.stride+o.offset;else h=a[g]*l;for(let p=0;p<l;p++)f[d++]=c[h++]}return new zt(f,l,u)}if(this.index===null)return Re("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new qt,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let f=c[l],h=e(f,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,f=c.length;u<f;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let f=0,h=u.length;f<h;f++)l.push(u[f].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ds{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=Nn()}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=Nn();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=Nn();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 Qt=new U;class es{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++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qt.fromBufferAttribute(this,t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qt.fromBufferAttribute(this,t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Ln(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=st(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=st(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=st(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=Ln(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Ln(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Ln(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Ln(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=st(t,this.array),n=st(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=st(t,this.array),n=st(n,this.array),i=st(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=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(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){ws("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 zt(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 es(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){ws("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 Nc=new U,Bv=new U,Gv=new Fe;class bn{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=Nc.subVectors(n,t).cross(Bv.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(Nc),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||Gv.getNormalMatrix(e),i=this.coplanarPoint(Nc).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 Hv=0;class on extends Fn{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hv++}),this.uuid=Nn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Re(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Re(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new Oe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new bn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ne().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ne().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var mi=new U,Dc=new U,Ro=new U,Co=new U;class Gi{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,mi)),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=mi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return mi.copy(this.origin).addScaledVector(this.direction,t),mi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Dc.copy(e).add(t).multiplyScalar(0.5),Ro.copy(t).sub(e).normalize(),Co.copy(this.origin).sub(Dc);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ro),o=Co.dot(this.direction),a=-Co.dot(Ro),c=Co.lengthSq(),l=Math.abs(1-s*s),u,f,h,d;if(l>0)if(u=s*a-o,f=s*o-a,d=r*l,u>=0)if(f>=-d)if(f<=d){let g=1/l;u*=g,f*=g,h=u*(u+s*f+2*o)+f*(s*u+f+2*a)+c}else f=r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else f=-r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;else if(f<=-d)u=Math.max(0,-(-s*r+o)),f=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else if(f<=d)u=0,f=Math.min(Math.max(-r,-a),r),h=f*(f+2*a)+c;else u=Math.max(0,-(s*r+o)),f=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+f*(f+2*a)+c;else f=s>0?-r:r,u=Math.max(0,-(s*f+o)),h=-u*u+f*(f+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Dc).addScaledVector(Ro,f);return h}intersectSphere(e,t){if(e.radius<0)return null;mi.subVectors(e.center,this.origin);let n=mi.dot(this.direction),i=mi.dot(mi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,f=this.origin;if(c>=0)n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c;else n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c;if(l>=0)r=(e.min.y-f.y)*l,s=(e.max.y-f.y)*l;else r=(e.max.y-f.y)*l,s=(e.min.y-f.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-f.z)*u,a=(e.max.z-f.z)*u;else o=(e.max.z-f.z)*u,a=(e.min.z-f.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,mi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,f=e.y-s.y,h=e.z-s.z,d=t.x-s.x,g=t.y-s.y,x=t.z-s.z,p=n.x-s.x,m=n.y-s.y,E=n.z-s.z,R=Math.abs(a),S=Math.abs(c),b=Math.abs(l),T,A,_,M,F,P,O,K,C,G,X,z;if(R>=S&&R>=b)if(_=a,P=u,C=d,z=p,a>=0)T=c,A=l,M=f,F=h,O=g,K=x,G=m,X=E;else T=l,A=c,M=h,F=f,O=x,K=g,G=E,X=m;else if(S>=b)if(_=c,P=f,C=g,z=m,c>=0)T=l,A=a,M=h,F=u,O=x,K=d,G=E,X=p;else T=a,A=l,M=u,F=h,O=d,K=x,G=p,X=E;else if(_=l,P=h,C=x,z=E,l>=0)T=a,A=c,M=u,F=f,O=d,K=g,G=p,X=m;else T=c,A=a,M=f,F=u,O=g,K=d,G=m,X=p;if(_===0)return null;let te=T/_,H=A/_,Q=1/_,ee=M-te*P,Te=F-H*P,ve=O-te*C,Ge=K-H*C,Me=G-te*z,Z=X-H*z,re=Me*Ge-Z*ve,se=ee*Z-Te*Me,Pe=ve*Te-Ge*ee;if(i){if(re<0||se<0||Pe<0)return null}else if((re<0||se<0||Pe<0)&&(re>0||se>0||Pe>0))return null;let Ie=re+se+Pe;if(Ie===0)return null;let we=Q*(re*P+se*C+Pe*z);if(Ie>0?we<0:we>0)return null;return this.at(we/Ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn extends on{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,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 Be,rr=new Gi,Po=new dn,df=new U,Io=new U,Lo=new U,No=new U,Oc=new U,Do=new U,pf=new U,Oo=new U;class pt extends lt{constructor(e=new qt,t=new Jn){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){Do.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(Oc.fromBufferAttribute(u,e),s)Do.addScaledVector(Oc,l);else Do.addScaledVector(Oc.sub(t),l)}t.add(Do)}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(Po.copy(n.boundingSphere),Po.applyMatrix4(r),rr.copy(e.ray).recast(e.near),Po.containsPoint(rr.origin)===!1){if(rr.intersectSphere(Po,df)===null)return;if(rr.origin.distanceToSquared(df)>(e.far-e.near)**2)return}if(ff.copy(r).invert(),rr.copy(e.ray).applyMatrix4(ff),n.boundingBox!==null){if(rr.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,rr)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:f,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(o.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=o.getX(R),T=o.getX(R+1),A=o.getX(R+2);if(i=Uo(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(o.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=o.getX(x),E=o.getX(x+1),R=o.getX(x+2);if(i=Uo(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let d=0,g=f.length;d<g;d++){let x=f[d],p=s[x.materialIndex],m=Math.max(x.start,h.start),E=Math.min(a.count,Math.min(x.start+x.count,h.start+h.count));for(let R=m,S=E;R<S;R+=3){let b=R,T=R+1,A=R+2;if(i=Uo(this,p,e,n,c,l,u,b,T,A),i)i.faceIndex=Math.floor(R/3),i.face.materialIndex=x.materialIndex,t.push(i)}}else{let d=Math.max(0,h.start),g=Math.min(a.count,h.start+h.count);for(let x=d,p=g;x<p;x+=3){let m=x,E=x+1,R=x+2;if(i=Uo(this,s,e,n,c,l,u,m,E,R),i)i.faceIndex=Math.floor(x/3),t.push(i)}}}}function Vv(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;Oo.copy(a),Oo.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Oo);if(l<n.near||l>n.far)return null;return{distance:l,point:Oo.clone(),object:e}}function Uo(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Io),e.getVertexPosition(c,Lo),e.getVertexPosition(l,No);let u=Vv(e,t,n,i,Io,Lo,No,pf);if(u){let f=new U;if(Mn.getBarycoord(pf,Io,Lo,No,f),r)u.uv=Mn.getInterpolatedAttribute(r,a,c,l,f,new Ne);if(s)u.uv1=Mn.getInterpolatedAttribute(s,a,c,l,f,new Ne);if(o){if(u.normal=Mn.getInterpolatedAttribute(o,a,c,l,f,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};Mn.getNormal(Io,Lo,No,h.normal),u.face=h,u.barycoord=f}return u}var xs=new ot,mf=new ot,gf=new ot,Wv=new ot,_f=new Be,Fo=new U,Uc=new dn,xf=new Be,Fc=new Gi;class fa extends pt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Be,this.bindMatrixInverse=new Be,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new en;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingBox.expandByPoint(Fo)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new dn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingSphere.expandByPoint(Fo)}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(Uc.copy(this.boundingSphere),Uc.applyMatrix4(i),e.ray.intersectsSphere(Uc)===!1)return;if(xf.copy(i).invert(),Fc.copy(e.ray).applyMatrix4(xf),this.boundingBox!==null){if(Fc.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Fc)}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 ot,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 Re("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(mf.fromBufferAttribute(i.attributes.skinIndex,e),gf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)xs.copy(t),t.set(0,0,0,0);else xs.set(...t,1),t.set(0,0,0);xs.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=gf.getComponent(r);if(s!==0){let o=mf.getComponent(r);_f.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Wv.copy(xs).applyMatrix4(_f),s)}}if(t.isVector4)t.w=xs.w;return t.applyMatrix4(this.bindMatrixInverse)}}class Os extends lt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Us extends Mt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,f){super(null,s,o,a,c,l,i,r,u,f);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var vf=new Be,$v=new Be;class Fs{constructor(e=[],t=[]){this.uuid=Nn(),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){Re("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 Be)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Be;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:$v;vf.multiplyMatrices(o,t[r]),vf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Fs(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 Us(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)Re("Skeleton: No bone found with UUID:",r),s=new Os;this.bones.push(s),this.boneInverses.push(new Be().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 Oi extends zt{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 Fr=new Be,yf=new Be,zo=[],Sf=new en,Zv=new Be,vs=new pt,ys=new dn;class ts extends pt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new Oi(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,Zv)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new en;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fr),Sf.copy(e.boundingBox).applyMatrix4(Fr),this.boundingBox.union(Sf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new dn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fr),ys.copy(e.boundingSphere).applyMatrix4(Fr),this.boundingSphere.union(ys)}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(vs.geometry=this.geometry,vs.material=this.material,vs.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ys.copy(this.boundingSphere),ys.applyMatrix4(n),e.ray.intersectsSphere(ys)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,Fr),yf.multiplyMatrices(n,Fr),vs.matrixWorld=yf,vs.raycast(e,zo);for(let s=0,o=zo.length;s<o;s++){let a=zo[s];a.instanceId=r,a.object=this,t.push(a)}zo.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new Oi(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 Us(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 sr=new dn,Xv=new Ne(0.5,0.5),ko=new U;class zs{constructor(e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,s=new bn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],f=r[6],h=r[7],d=r[8],g=r[9],x=r[10],p=r[11],m=r[12],E=r[13],R=r[14],S=r[15];if(i[0].setComponents(c-s,h-l,p-d,S-m).normalize(),i[1].setComponents(c+s,h+l,p+d,S+m).normalize(),i[2].setComponents(c+o,h+u,p+g,S+E).normalize(),i[3].setComponents(c-o,h-u,p-g,S-E).normalize(),n)i[4].setComponents(a,f,x,R).normalize(),i[5].setComponents(c-a,h-f,p-x,S-R).normalize();else if(i[4].setComponents(c-a,h-f,p-x,S-R).normalize(),t===2000)i[5].setComponents(c+a,h+f,p+x,S+R).normalize();else if(t===2001)i[5].setComponents(a,f,x,R).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();sr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sr)}intersectsSprite(e){sr.center.set(0,0,0);let t=Xv.distanceTo(e.center);return sr.radius=0.7071067811865476+t,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}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(ko.x=i.normal.x>0?e.max.x:e.min.x,ko.y=i.normal.y>0?e.max.y:e.min.y,ko.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ko)<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 ks extends on{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Xo=new U,qo=new U,bf=new Be,Ss=new Gi,Bo=new dn,zc=new U,Mf=new U;class Hi extends lt{constructor(e=new qt,t=new ks){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++)Xo.fromBufferAttribute(t,i-1),qo.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Xo.distanceTo(qo);e.setAttribute("lineDistance",new sn(n,1))}else Re("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(Bo.copy(n.boundingSphere),Bo.applyMatrix4(i),Bo.radius+=r,e.ray.intersectsSphere(Bo)===!1)return;bf.copy(i).invert(),Ss.copy(e.ray).applyMatrix4(bf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,f=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),d=Math.min(l.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=l.getX(g),m=l.getX(g+1),E=Go(this,e,Ss,a,p,m,g);if(E)t.push(E)}if(this.isLineLoop){let g=l.getX(d-1),x=l.getX(h),p=Go(this,e,Ss,a,g,x,d-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),d=Math.min(f.count,s.start+s.count);for(let g=h,x=d-1;g<x;g+=c){let p=Go(this,e,Ss,a,g,g+1,g);if(p)t.push(p)}if(this.isLineLoop){let g=Go(this,e,Ss,a,d-1,h,d-1);if(g)t.push(g)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Go(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Xo.fromBufferAttribute(a,r),qo.fromBufferAttribute(a,s),n.distanceSqToSegment(Xo,qo,zc,Mf)>i)return;zc.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(zc);if(l<t.near||l>t.far)return;return{distance:l,point:Mf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var wf=new U,Tf=new U;class da extends Hi{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)wf.fromBufferAttribute(t,i),Tf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+wf.distanceTo(Tf);e.setAttribute("lineDistance",new sn(n,1))}else Re("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class pa extends Hi{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Bs extends on{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var Ef=new Be,Gc=new Gi,Ho=new dn,Vo=new U;class ns extends lt{constructor(e=new qt,t=new Bs){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(Ho.copy(n.boundingSphere),Ho.applyMatrix4(i),Ho.radius+=r,e.ray.intersectsSphere(Ho)===!1)return;Ef.copy(i).invert(),Gc.copy(e.ray).applyMatrix4(Ef);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let f=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let d=f,g=h;d<g;d++){let x=c.getX(d);Vo.fromBufferAttribute(u,x),Af(Vo,x,a,i,e,t,this)}}else{let f=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let d=f,g=h;d<g;d++)Vo.fromBufferAttribute(u,d),Af(Vo,d,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Af(e,t,n,i,r,s,o){let a=Gc.distanceSqToPoint(e);if(a<n){let c=new U;Gc.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 ma extends Mt{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 pr extends Mt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:u};super(f,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ls(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class $l extends pr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class ga extends Mt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Vi extends qt{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],f=0,h=0;d("z","y","x",-1,-1,n,t,e,s,r,0),d("z","y","x",1,-1,n,t,-e,s,r,1),d("x","z","y",1,1,e,n,t,i,s,2),d("x","z","y",1,-1,e,n,-t,i,s,3),d("x","y","z",1,-1,e,t,n,i,r,4),d("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new sn(c,3)),this.setAttribute("normal",new sn(l,3)),this.setAttribute("uv",new sn(u,2));function d(g,x,p,m,E,R,S,b,T,A,_){let M=R/T,F=S/A,P=R/2,O=S/2,K=b/2,C=T+1,G=A+1,X=0,z=0,te=new U;for(let H=0;H<G;H++){let Q=H*F-O;for(let ee=0;ee<C;ee++){let Te=ee*M-P;te[g]=Te*m,te[x]=Q*E,te[p]=K,c.push(te.x,te.y,te.z),te[g]=0,te[x]=0,te[p]=b>0?1:-1,l.push(te.x,te.y,te.z),u.push(ee/T),u.push(1-H/A),X+=1}}for(let H=0;H<A;H++)for(let Q=0;Q<T;Q++){let ee=f+Q+C*H,Te=f+Q+C*(H+1),ve=f+(Q+1)+C*(H+1),Ge=f+(Q+1)+C*H;a.push(ee,Te,Ge),a.push(Te,ve,Ge),z+=6}o.addGroup(h,z,_),h+=z,f+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Gs extends qt{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,f=t/a,h=[],d=[],g=[],x=[];for(let p=0;p<l;p++){let m=p*f-s;for(let E=0;E<c;E++){let R=E*u-r;d.push(R,-m,0),g.push(0,0,1),x.push(E/o),x.push(1-p/a)}}for(let p=0;p<a;p++)for(let m=0;m<o;m++){let E=m+c*p,R=m+c*(p+1),S=m+1+c*(p+1),b=m+1+c*p;h.push(E,R,b),h.push(R,S,b)}this.setIndex(h),this.setAttribute("position",new sn(d,3)),this.setAttribute("normal",new sn(g,3)),this.setAttribute("uv",new sn(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gs(e.width,e.height,e.widthSegments,e.heightSegments)}}function mr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(Rf(r))if(r.isRenderTargetTexture)Re("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(Rf(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 Yt(e){let t={};for(let n=0;n<e.length;n++){let i=mr(e[n]);for(let r in i)t[r]=i[r]}return t}function Rf(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function qv(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Zl(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return We.workingColorSpace}var Od={clone:mr,merge:Yt},Yv=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,Xv=`void main() {
+}`,jv=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Tn extends on{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zv,this.fragmentShader=Xv,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=mr(e.uniforms),this.uniformsGroups=$v(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ot().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Fe().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Be().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 Xl extends Tn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class vi extends on{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class pn extends vi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return $e(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class _a extends on{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,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 ql extends on{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 Yl extends on{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 Di(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 Zo(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function qv(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 Af(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 Yv(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 yi{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 jl extends yi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let S=0;S!==o;++S)r[S]=p*s[l+S]+m*s[c+S]+E*s[a+S]+R*s[u+S];return r}}class xa extends yi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class Kl extends yi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jl extends yi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,S=l[R],b=l[R+1],T=Kv(n,t,m,S,i);r[d]=Dd(T,g,E,b,x)}return r}}function Dd(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 jv(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 Kv(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=Dd(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=jv(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 mn{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=Di(t,this.TimeBufferType),this.values=Di(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:Di(e.times,Array),values:Di(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Zo(e.settings))n.settings={inTangents:Di(e.settings.inTangents,Array),outTangents:Di(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Kl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Jl(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 Re("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(Zo(this.settings))Rf(this.settings.inTangents,e),Rf(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(av(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Zo(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function Rf(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}mn.prototype.ValueTypeName="";mn.prototype.TimeBufferType=Float32Array;mn.prototype.ValueBufferType=Float32Array;mn.prototype.DefaultInterpolation=2301;class Wi extends mn{constructor(e,t,n){super(e,t,n)}}Wi.prototype.ValueTypeName="bool";Wi.prototype.ValueBufferType=Array;Wi.prototype.DefaultInterpolation=2300;Wi.prototype.InterpolantFactoryMethodLinear=void 0;Wi.prototype.InterpolantFactoryMethodSmooth=void 0;class va extends mn{constructor(e,t,n,i){super(e,t,n,i)}}va.prototype.ValueTypeName="color";class $i extends mn{constructor(e,t,n,i){super(e,t,n,i)}}$i.prototype.ValueTypeName="number";class Ql extends yi{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)Ft.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Zi extends mn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Ql(this.times,this.values,this.getValueSize(),e)}}Zi.prototype.ValueTypeName="quaternion";Zi.prototype.InterpolantFactoryMethodSmooth=void 0;class Xi extends mn{constructor(e,t,n){super(e,t,n)}}Xi.prototype.ValueTypeName="string";Xi.prototype.ValueBufferType=Array;Xi.prototype.DefaultInterpolation=2300;Xi.prototype.InterpolantFactoryMethodLinear=void 0;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;class gr extends mn{constructor(e,t,n,i){super(e,t,n,i)}}gr.prototype.ValueTypeName="vector";class Wr{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Nn(),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(Qv(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(mn.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=qv(a);if(a=Af(a,1,l),c=Af(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new $i(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Jv(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $i;case"vector":case"vector2":case"vector3":case"vector4":return gr;case"color":return va;case"quaternion":return Zi;case"bool":case"boolean":return Wi;case"string":return Xi}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Qv(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Jv(e.type);if(e.times===void 0){let i=[],r=[];Yv(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(Zo(e.settings))n.settings={inTangents:Di(e.settings.inTangents,Float32Array),outTangents:Di(e.settings.outTangents,Float32Array)};return n}var Zn={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(Cf(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(Cf(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function Cf(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Hs{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var Od=new Hs;class Si{constructor(e){if(this.manager=e!==void 0?e:Od,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}}Si.DEFAULT_MATERIAL_NAME="__DEFAULT";var gi={};class Ud extends Error{constructor(e,t){super(e);this.response=t}}class Vs extends Si{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=Zn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(gi[e]!==void 0){gi[e].push({onLoad:t,onProgress:n,onError:i});return}gi[e]=[],gi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Re("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=gi[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let S=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let b=0,T=l.length;b<T;b++){let A=l[b];if(A.onProgress)A.onProgress(S)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new Ud(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{Zn.add(`file:${e}`,c);let l=gi[e];delete gi[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=gi[e];if(l===void 0)throw this.manager.itemError(e),c;delete gi[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var zr=new WeakMap;class eu extends Si{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=Zn.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=zr.get(s);if(u===void 0)u=[],zr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Hr("img");function a(){if(l(),t)t(this);let u=zr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}zr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);Zn.remove(`image:${e}`);let f=zr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}zr.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 Zn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class ya extends Si{constructor(e){super(e)}load(e,t,n,i){let r=new Mt,s=new eu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class is extends lt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Sa extends is{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var kc=new Be,Pf=new U,If=new U;class Ws{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zs,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ot(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Pf.setFromMatrixPosition(e.matrixWorld),t.position.copy(Pf),If.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(If),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){kc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(kc,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(kc)}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 Wo=new U,$o=new Ft,Wn=new U;class ba extends lt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Be,this.projectionMatrix=new Be,this.projectionMatrixInverse=new Be,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(Wo,$o,Wn),Wn.x===1&&Wn.y===1&&Wn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wo,$o,Wn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wo,$o,Wn),Wn.x===1&&Wn.y===1&&Wn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wo,$o,Wn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Ni=new U,Lf=new Ne,Nf=new Ne;class Lt extends ba{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=ar*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(bs*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return ar*2*Math.atan(Math.tan(bs*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ni.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z),Ni.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z)}getViewSize(e,t){return this.getViewBounds(e,Lf,Nf),t.subVectors(Nf,Lf)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(bs*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Fd extends Ws{constructor(){super(new Lt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ar*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 Ma extends is{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(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Fd}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 zd extends Ws{constructor(){super(new Lt(90,1,0.5,500));this.isPointLightShadow=!0}}class rs extends is{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 zd}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 ba{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 kd extends Ws{constructor(){super(new _r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ss extends is{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.shadow=new kd}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 qi{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 Bc=new WeakMap;class wa extends Si{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Re("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Re("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=Zn.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Bc.has(s)===!0){if(i)i(Bc.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(Zn.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Bc.set(a,c),Zn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Zn.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var kr=-90,Br=1;class tu extends lt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Lt(kr,Br,e,t);i.layers=this.layers,this.add(i);let r=new Lt(kr,Br,e,t);r.layers=this.layers,this.add(r);let s=new Lt(kr,Br,e,t);s.layers=this.layers,this.add(s);let o=new Lt(kr,Br,e,t);o.layers=this.layers,this.add(o);let a=new Lt(kr,Br,e,t);a.layers=this.layers,this.add(a);let c=new Lt(kr,Br,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class nu extends Lt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class iu{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){Ft.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ft.multiplyQuaternionsFlat(e,s,e,t,e,n),Ft.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var ru="\\[\\]\\.:\\/",ey=new RegExp("["+ru+"]","g"),su="[^"+ru+"]",ty="[^"+ru.replace("\\.","")+"]",ny=/((?:WC+[\/:])*)/.source.replace("WC",su),iy=/(WCOD+)?/.source.replace("WCOD",ty),ry=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",su),sy=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",su),oy=new RegExp("^"+ny+iy+ry+sy+"$"),ay=["material","materials","bones","map"];class Bd{constructor(e,t,n){let i=n||Qe.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 Qe{constructor(e,t,n){this.path=t,this.parsedPath=n||Qe.parseTrackName(t),this.node=Qe.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 Qe(e,t,n);else return new Qe.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ey,"")}static parseTrackName(e){let t=oy.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(ay.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=Qe.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Re("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Qe.Composite=Bd;Qe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Qe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Qe.prototype.GetterByBindingType=[Qe.prototype._getValue_direct,Qe.prototype._getValue_array,Qe.prototype._getValue_arrayElement,Qe.prototype._getValue_toArray];Qe.prototype.SetterByBindingTypeAndVersioning=[[Qe.prototype._setValue_direct,Qe.prototype._setValue_direct_setNeedsUpdate,Qe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_array,Qe.prototype._setValue_array_setNeedsUpdate,Qe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_arrayElement,Qe.prototype._setValue_arrayElement_setNeedsUpdate,Qe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_fromArray,Qe.prototype._setValue_fromArray_setNeedsUpdate,Qe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ou{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 cy=new Float32Array(1);class Ta extends Fn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new iu(Qe.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new xa(new Float32Array(2),new Float32Array(2),1,cy),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"?Wr.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 ou(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"?Wr.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 $s{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=$e(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($e(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class au{static{au.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 Ea extends Fn{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 cu(e,t,n,i){let r=ly(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 ly(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__)Re("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function cp(){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 uy(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var hy=`#ifdef USE_ALPHAHASH
+}`;class Tn extends on{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Yv,this.fragmentShader=jv,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=mr(e.uniforms),this.uniformsGroups=qv(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ne().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ot().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Fe().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Be().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 Xl extends Tn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class vi extends on{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class pn extends vi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ne(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return $e(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class _a extends on{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ne(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xn,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 ql extends on{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 Yl extends on{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 Di(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 Zo(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function Kv(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 Cf(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 Jv(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 yi{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 jl extends yi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,h=this._weightNext,d=(n-t)/(i-t),g=d*d,x=g*d,p=-f*x+2*f*g-f*d,m=(1+f)*x+(-1.5-2*f)*g+(-0.5+f)*d+1,E=(-1-h)*x+(1.5+h)*g+0.5*d,R=h*x-h*g;for(let S=0;S!==o;++S)r[S]=p*s[l+S]+m*s[c+S]+E*s[a+S]+R*s[u+S];return r}}class xa extends yi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let f=0;f!==o;++f)r[f]=s[c+f]*u+s[a+f]*l;return r}}class Kl extends yi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jl extends yi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let d=(n-t)/(i-t),g=1-d;for(let x=0;x!==o;++x)r[x]=s[c+x]*g+s[a+x]*d;return r}let f=o*2,h=e-1;for(let d=0;d!==o;++d){let g=s[c+d],x=s[a+d],p=h*f+d*2,m=u[p],E=u[p+1],R=e*f+d*2,S=l[R],b=l[R+1],T=ey(n,t,m,S,i);r[d]=Ud(T,g,E,b,x)}return r}}function Ud(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 Qv(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 ey(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=Ud(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=Qv(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 mn{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=Di(t,this.TimeBufferType),this.values=Di(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:Di(e.times,Array),values:Di(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(Zo(e.settings))n.settings={inTangents:Di(e.settings.inTangents,Array),outTangents:Di(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Kl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Jl(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 Re("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(Zo(this.settings))Pf(this.settings.inTangents,e),Pf(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ue("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ue("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){Ue("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Ue("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(uv(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Ue("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,f=u-n,h=u+n;for(let d=0;d!==n;++d){let g=t[u+d];if(g!==t[f+d]||g!==t[h+d]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,f=s*n;for(let h=0;h!==n;++h)t[f+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,Zo(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function Pf(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}mn.prototype.ValueTypeName="";mn.prototype.TimeBufferType=Float32Array;mn.prototype.ValueBufferType=Float32Array;mn.prototype.DefaultInterpolation=2301;class Wi extends mn{constructor(e,t,n){super(e,t,n)}}Wi.prototype.ValueTypeName="bool";Wi.prototype.ValueBufferType=Array;Wi.prototype.DefaultInterpolation=2300;Wi.prototype.InterpolantFactoryMethodLinear=void 0;Wi.prototype.InterpolantFactoryMethodSmooth=void 0;class va extends mn{constructor(e,t,n,i){super(e,t,n,i)}}va.prototype.ValueTypeName="color";class $i extends mn{constructor(e,t,n,i){super(e,t,n,i)}}$i.prototype.ValueTypeName="number";class Ql extends yi{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)Ft.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Zi extends mn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Ql(this.times,this.values,this.getValueSize(),e)}}Zi.prototype.ValueTypeName="quaternion";Zi.prototype.InterpolantFactoryMethodSmooth=void 0;class Xi extends mn{constructor(e,t,n){super(e,t,n)}}Xi.prototype.ValueTypeName="string";Xi.prototype.ValueBufferType=Array;Xi.prototype.DefaultInterpolation=2300;Xi.prototype.InterpolantFactoryMethodLinear=void 0;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;class gr extends mn{constructor(e,t,n,i){super(e,t,n,i)}}gr.prototype.ValueTypeName="vector";class Wr{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Nn(),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(ny(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(mn.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=Kv(a);if(a=Cf(a,1,l),c=Cf(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new $i(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],f=i[u];if(!f)i[u]=f=[];f.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ty(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $i;case"vector":case"vector2":case"vector3":case"vector4":return gr;case"color":return va;case"quaternion":return Zi;case"bool":case"boolean":return Wi;case"string":return Xi}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function ny(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ty(e.type);if(e.times===void 0){let i=[],r=[];Jv(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(Zo(e.settings))n.settings={inTangents:Di(e.settings.inTangents,Float32Array),outTangents:Di(e.settings.outTangents,Float32Array)};return n}var Zn={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(If(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(If(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function If(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Hs{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,f=c.length;u<f;u+=2){let h=c[u],d=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return d}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var Fd=new Hs;class Si{constructor(e){if(this.manager=e!==void 0?e:Fd,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}}Si.DEFAULT_MATERIAL_NAME="__DEFAULT";var gi={};class zd extends Error{constructor(e,t){super(e);this.response=t}}class Vs extends Si{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=Zn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(gi[e]!==void 0){gi[e].push({onLoad:t,onProgress:n,onError:i});return}gi[e]=[],gi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Re("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=gi[e],u=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=f?parseInt(f):0,d=h!==0,g=0,x=new ReadableStream({start(p){m();function m(){u.read().then(({done:E,value:R})=>{if(E)p.close();else{g+=R.byteLength;let S=new ProgressEvent("progress",{lengthComputable:d,loaded:g,total:h});for(let b=0,T=l.length;b<T;b++){let A=l[b];if(A.onProgress)A.onProgress(S)}p.enqueue(R),m()}},(E)=>{p.error(E)})}}});return new Response(x)}else throw new zd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(f);return c.arrayBuffer().then((d)=>h.decode(d))}}}).then((c)=>{Zn.add(`file:${e}`,c);let l=gi[e];delete gi[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=gi[e];if(l===void 0)throw this.manager.itemError(e),c;delete gi[e];for(let u=0,f=l.length;u<f;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var zr=new WeakMap;class eu extends Si{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=Zn.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=zr.get(s);if(u===void 0)u=[],zr.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Hr("img");function a(){if(l(),t)t(this);let u=zr.get(this)||[];for(let f=0;f<u.length;f++){let h=u[f];if(h.onLoad)h.onLoad(this)}zr.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);Zn.remove(`image:${e}`);let f=zr.get(this)||[];for(let h=0;h<f.length;h++){let d=f[h];if(d.onError)d.onError(u)}zr.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 Zn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class ya extends Si{constructor(e){super(e)}load(e,t,n,i){let r=new Mt,s=new eu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class is extends lt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Sa extends is{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var kc=new Be,Lf=new U,Nf=new U;class Ws{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ne(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zs,this._frameExtents=new Ne(1,1),this._viewportCount=1,this._viewports=[new ot(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Lf.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lf),Nf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Nf),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){kc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(kc,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(kc)}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 Wo=new U,$o=new Ft,Wn=new U;class ba extends lt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Be,this.projectionMatrix=new Be,this.projectionMatrixInverse=new Be,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(Wo,$o,Wn),Wn.x===1&&Wn.y===1&&Wn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wo,$o,Wn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wo,$o,Wn),Wn.x===1&&Wn.y===1&&Wn.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Wo,$o,Wn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var Ni=new U,Df=new Ne,Of=new Ne;class Lt extends ba{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=ar*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(bs*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return ar*2*Math.atan(Math.tan(bs*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ni.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z),Ni.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ni.x,Ni.y).multiplyScalar(-e/Ni.z)}getViewSize(e,t){return this.getViewBounds(e,Df,Of),t.subVectors(Of,Df)}setViewOffset(e,t,n,i,r,s){if(this.aspect=e/t,this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(bs*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:a,fullHeight:c}=s;r+=s.offsetX*i/a,t-=s.offsetY*n/c,i*=s.width/a,n*=s.height/c}let o=this.filmOffset;if(o!==0)r+=e*o/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class kd extends Ws{constructor(){super(new Lt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ar*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 Ma extends is{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(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new kd}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 Bd extends Ws{constructor(){super(new Lt(90,1,0.5,500));this.isPointLightShadow=!0}}class rs extends is{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 Bd}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 ba{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 Gd extends Ws{constructor(){super(new _r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class ss extends is{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(lt.DEFAULT_UP),this.updateMatrix(),this.target=new lt,this.shadow=new Gd}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 qi{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 Bc=new WeakMap;class wa extends Si{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Re("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Re("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=Zn.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Bc.has(s)===!0){if(i)i(Bc.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(Zn.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Bc.set(a,c),Zn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Zn.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var kr=-90,Br=1;class tu extends lt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Lt(kr,Br,e,t);i.layers=this.layers,this.add(i);let r=new Lt(kr,Br,e,t);r.layers=this.layers,this.add(r);let s=new Lt(kr,Br,e,t);s.layers=this.layers,this.add(s);let o=new Lt(kr,Br,e,t);o.layers=this.layers,this.add(o);let a=new Lt(kr,Br,e,t);a.layers=this.layers,this.add(a);let c=new Lt(kr,Br,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),d=e.xr.enabled;e.xr.enabled=!1;let g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let x=!1;if(e.isWebGLRenderer===!0)x=e.state.buffers.depth.getReversed();else x=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),x&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),x&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,f,h),e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class nu extends Lt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class iu{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){Ft.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Ft.multiplyQuaternionsFlat(e,s,e,t,e,n),Ft.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var ru="\\[\\]\\.:\\/",iy=new RegExp("["+ru+"]","g"),su="[^"+ru+"]",ry="[^"+ru.replace("\\.","")+"]",sy=/((?:WC+[\/:])*)/.source.replace("WC",su),oy=/(WCOD+)?/.source.replace("WCOD",ry),ay=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",su),cy=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",su),ly=new RegExp("^"+sy+oy+ay+cy+"$"),uy=["material","materials","bones","map"];class Hd{constructor(e,t,n){let i=n||Qe.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 Qe{constructor(e,t,n){this.path=t,this.parsedPath=n||Qe.parseTrackName(t),this.node=Qe.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 Qe(e,t,n);else return new Qe.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(iy,"")}static parseTrackName(e){let t=ly.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(uy.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=Qe.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Re("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Ue("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Qe.Composite=Hd;Qe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Qe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Qe.prototype.GetterByBindingType=[Qe.prototype._getValue_direct,Qe.prototype._getValue_array,Qe.prototype._getValue_arrayElement,Qe.prototype._getValue_toArray];Qe.prototype.SetterByBindingTypeAndVersioning=[[Qe.prototype._setValue_direct,Qe.prototype._setValue_direct_setNeedsUpdate,Qe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_array,Qe.prototype._setValue_array_setNeedsUpdate,Qe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_arrayElement,Qe.prototype._setValue_arrayElement_setNeedsUpdate,Qe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_fromArray,Qe.prototype._setValue_fromArray_setNeedsUpdate,Qe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ou{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 hy=new Float32Array(1);class Ta extends Fn{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let f=i[u],h=f.name,d=l[h];if(d!==void 0)++d.referenceCount,s[u]=d;else{if(d=s[u],d!==void 0){if(d._cacheIndex===null)++d.referenceCount,this._addInactiveBinding(d,a,h);continue}let g=t&&t._propertyBindings[u].binding.parsedPath;d=new iu(Qe.create(n,h,g),f.ValueTypeName,f.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,a,h),s[u]=d}o[u].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,f=(e._localRoot||this._root).uuid;if(delete u[f],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new xa(new Float32Array(2),new Float32Array(2),1,hy),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"?Wr.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 ou(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"?Wr.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 $s{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=$e(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($e(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class au{static{au.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 Ea extends Fn{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 cu(e,t,n,i){let r=fy(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 fy(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__)Re("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function up(){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 dy(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,f=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)d=e.HALF_FLOAT;else d=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=e.SHORT;else if(l instanceof Uint32Array)d=e.UNSIGNED_INT;else if(l instanceof Int32Array)d=e.INT;else if(l instanceof Int8Array)d=e.BYTE;else if(l instanceof Uint8Array)d=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:f}}function i(a,c,l){let{array:u,updateRanges:f}=c;if(e.bindBuffer(l,a),f.length===0)e.bufferSubData(l,0,u);else{f.sort((d,g)=>d.start-g.start);let h=0;for(let d=1;d<f.length;d++){let g=f[h],x=f[d];if(x.start<=g.start+g.count+1)g.count=Math.max(g.count,x.start+x.count-g.start);else++h,f[h]=x}f.length=h+1;for(let d=0,g=f.length;d<g;d++){let x=f[d];e.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var py=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,fy=`#ifdef USE_ALPHAHASH
+#endif`,my=`#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`,dy=`#ifdef USE_ALPHAMAP
+#endif`,gy=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,py=`#ifdef USE_ALPHAMAP
+#endif`,_y=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,my=`#ifdef USE_ALPHATEST
+#endif`,xy=`#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`,gy=`#ifdef USE_ALPHATEST
+#endif`,vy=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,_y=`#ifdef USE_AOMAP
+#endif`,yy=`#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`,xy=`#ifdef USE_AOMAP
+#endif`,Sy=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,vy=`#ifdef USE_BATCHING
+#endif`,by=`#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`,yy=`#ifdef USE_BATCHING
+#endif`,My=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,Sy=`vec3 transformed = vec3( position );
+#endif`,wy=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,by=`vec3 objectNormal = vec3( normal );
+#endif`,Ty=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,My=`float G_BlinnPhong_Implicit( ) {
+#endif`,Ey=`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`,wy=`#ifdef USE_IRIDESCENCE
+} // validated`,Ay=`#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`,Ty=`#ifdef USE_BUMPMAP
+#endif`,Ry=`#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`,Ey=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Cy=`#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`,Ay=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Py=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,Ry=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Iy=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,Cy=`#if NUM_CLIPPING_PLANES > 0
+#endif`,Ly=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,Py=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,Ny=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,Iy=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,Dy=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,Ly=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,Oy=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,Ny=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,Uy=`#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`,Dy=`#define PI 3.141592653589793
+#endif`,Fy=`#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`,Oy=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,zy=`#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`,Uy=`vec3 transformedNormal = objectNormal;
+#endif`,ky=`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`,Fy=`#ifdef USE_DISPLACEMENTMAP
+#endif`,By=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,zy=`#ifdef USE_DISPLACEMENTMAP
+#endif`,Gy=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,ky=`#ifdef USE_EMISSIVEMAP
+#endif`,Hy=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,By=`#ifdef USE_EMISSIVEMAP
+#endif`,Vy=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,Gy="gl_FragColor = linearToOutputTexel( gl_FragColor );",Hy=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,Wy="gl_FragColor = linearToOutputTexel( gl_FragColor );",$y=`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 );
-}`,Vy=`#ifdef USE_ENVMAP
+}`,Zy=`#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`,Wy=`#ifdef USE_ENVMAP
+#endif`,Xy=`#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`,$y=`#ifdef USE_ENVMAP
+#endif`,qy=`#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`,Zy=`#ifdef USE_ENVMAP
+#endif`,Yy=`#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`,Xy=`#ifdef USE_ENVMAP
+#endif`,jy=`#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`,qy=`#ifdef USE_FOG
+#endif`,Ky=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,Yy=`#ifdef USE_FOG
+#endif`,Jy=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,jy=`#ifdef USE_FOG
+#endif`,Qy=`#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`,Ky=`#ifdef USE_FOG
+#endif`,eS=`#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`,Jy=`#ifdef USE_GRADIENTMAP
+#endif`,tS=`#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
-}`,Qy=`#ifdef USE_LIGHTMAP
+}`,nS=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,eS=`LambertMaterial material;
+#endif`,iS=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,tS=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,rS=`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`,nS=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,sS=`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>`,iS=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,oS=`#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`,rS=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,sS=`varying vec3 vViewPosition;
+#endif`,aS=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,cS=`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`,oS=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lS=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,aS=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,uS=`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`,cS=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,hS=`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`,lS=`uniform sampler2D dfgLUT;
+#endif`,fS=`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 );
-}`,uS=`
+}`,dS=`
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`,hS=`#if defined( RE_IndirectDiffuse )
+#endif`,pS=`#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`,fS=`#if defined( RE_IndirectDiffuse )
+#endif`,mS=`#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`,dS=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,gS=`#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`,pS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,_S=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,mS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,xS=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,gS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,vS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,_S=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,yS=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,xS=`#ifdef USE_MAP
+#endif`,SS=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,vS=`#ifdef USE_MAP
+#endif`,bS=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,yS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,MS=`#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`,SS=`#if defined( USE_POINTS_UV )
+#endif`,wS=`#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`,bS=`float metalnessFactor = metalness;
+#endif`,TS=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,MS=`#ifdef USE_METALNESSMAP
+#endif`,ES=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,wS=`#ifdef USE_INSTANCING_MORPH
+#endif`,AS=`#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`,TS=`#if defined( USE_MORPHCOLORS )
+#endif`,RS=`#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`,ES=`#ifdef USE_MORPHNORMALS
+#endif`,CS=`#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`,AS=`#ifdef USE_MORPHTARGETS
+#endif`,PS=`#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`,RS=`#ifdef USE_MORPHTARGETS
+#endif`,IS=`#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`,CS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,LS=`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;`,PS=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,NS=`#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;`,PS=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,IS=`#ifndef FLAT_SHADED
+#endif`,DS=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,LS=`#ifndef FLAT_SHADED
+#endif`,OS=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,NS=`#ifndef FLAT_SHADED
+#endif`,US=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,PS=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,DS=`#ifdef USE_NORMALMAP
+#endif`,FS=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1843,13 +1843,13 @@ vec3 nonPerturbedNormal = normal;`,PS=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,OS=`#ifdef USE_CLEARCOAT
+#endif`,zS=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,US=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,kS=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,FS=`#ifdef USE_CLEARCOATMAP
+#endif`,BS=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,PS=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,zS=`#ifdef USE_IRIDESCENCEMAP
+#endif`,GS=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,kS=`#ifdef OPAQUE
+#endif`,HS=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,BS=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,VS=`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
-}`,GS=`#ifdef PREMULTIPLIED_ALPHA
+}`,WS=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,HS=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,$S=`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;`,VS=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,ZS=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,WS=`#ifdef DITHERING
+#endif`,XS=`#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`,$S=`float roughnessFactor = roughness;
+#endif`,qS=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,ZS=`#ifdef USE_ROUGHNESSMAP
+#endif`,YS=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,XS=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,jS=`#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;`,VS=`#ifdef DITHERING
}
#endif
#endif
-#endif`,qS=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,KS=`#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;`,VS=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,YS=`#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`,JS=`#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;`,VS=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,jS=`float getShadowMask() {
+#endif`,QS=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,VS=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,KS=`#ifdef USE_SKINNING
+}`,eb=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,JS=`#ifdef USE_SKINNING
+#endif`,tb=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,VS=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,QS=`#ifdef USE_SKINNING
+#endif`,nb=`#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;`,VS=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,eb=`#ifdef USE_SKINNING
+#endif`,ib=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,VS=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,tb=`float specularStrength;
+#endif`,rb=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,nb=`#ifdef USE_SPECULARMAP
+#endif`,sb=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,ib=`#if defined( TONE_MAPPING )
+#endif`,ob=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,rb=`#ifndef saturate
+#endif`,ab=`#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; }`,sb=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,cb=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sb=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,ob=`#ifdef USE_TRANSMISSION
+#endif`,lb=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sb=`#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`,ab=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,ub=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sb=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,cb=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,hb=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,sb=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,lb=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,fb=`#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; }`,sb=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var ub=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var db=`#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; }`,sb=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,hb=`varying vec2 vUv;
+#endif`,pb=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,fb=`uniform sampler2D t2D;
+}`,mb=`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>
-}`,db=`varying vec3 vWorldDirection;
+}`,gb=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,pb=`#ifdef ENVMAP_TYPE_CUBE
+}`,_b=`#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>
-}`,mb=`varying vec3 vWorldDirection;
+}`,xb=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,gb=`uniform samplerCube tCube;
+}`,vb=`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>
-}`,_b=`#include <common>
+}`,yb=`#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;
-}`,xb=`#if DEPTH_PACKING == 3200
+}`,Sb=`#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
-}`,vb=`#define DISTANCE
+}`,bb=`#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;
-}`,yb=`#define DISTANCE
+}`,Mb=`#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 );
-}`,Sb=`varying vec3 vWorldDirection;
+}`,wb=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,bb=`uniform sampler2D tEquirect;
+}`,Tb=`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>
-}`,Mb=`uniform float scale;
+}`,Eb=`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>
-}`,wb=`uniform vec3 diffuse;
+}`,Ab=`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>
-}`,Tb=`#include <common>
+}`,Rb=`#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>
-}`,Eb=`uniform vec3 diffuse;
+}`,Cb=`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>
-}`,Ab=`#define LAMBERT
+}`,Pb=`#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>
-}`,Rb=`#define LAMBERT
+}`,Ib=`#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>
-}`,Cb=`#define MATCAP
+}`,Lb=`#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;
-}`,Pb=`#define MATCAP
+}`,Nb=`#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>
-}`,Ib=`#define NORMAL
+}`,Db=`#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
-}`,Lb=`#define NORMAL
+}`,Ob=`#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
-}`,Nb=`#define PHONG
+}`,Ub=`#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>
-}`,Db=`#define PHONG
+}`,Fb=`#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>
-}`,Ob=`#define STANDARD
+}`,zb=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,Ub=`#define STANDARD
+}`,kb=`#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>
-}`,Fb=`#define TOON
+}`,Bb=`#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>
-}`,zb=`#define TOON
+}`,Gb=`#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>
-}`,kb=`uniform float size;
+}`,Hb=`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>
-}`,Bb=`uniform vec3 diffuse;
+}`,Vb=`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>
-}`,Gb=`#include <common>
+}`,Wb=`#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>
-}`,Hb=`uniform vec3 color;
+}`,$b=`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>
-}`,Vb=`uniform float rotation;
+}`,Zb=`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>
-}`,Wb=`uniform vec3 diffuse;
+}`,Xb=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -3944,7 +3944,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,Ve={alphahash_fragment:hy,alphahash_pars_fragment:fy,alphamap_fragment:dy,alphamap_pars_fragment:py,alphatest_fragment:my,alphatest_pars_fragment:gy,aomap_fragment:_y,aomap_pars_fragment:xy,batching_pars_vertex:vy,batching_vertex:yy,begin_vertex:Sy,beginnormal_vertex:by,bsdfs:My,iridescence_fragment:wy,bumpmap_pars_fragment:Ty,clipping_planes_fragment:Ey,clipping_planes_pars_fragment:Ay,clipping_planes_pars_vertex:Ry,clipping_planes_vertex:Cy,color_fragment:Py,color_pars_fragment:Iy,color_pars_vertex:Ly,color_vertex:Ny,common:Dy,cube_uv_reflection_fragment:Oy,defaultnormal_vertex:Uy,displacementmap_pars_vertex:Fy,displacementmap_vertex:zy,emissivemap_fragment:ky,emissivemap_pars_fragment:By,colorspace_fragment:Gy,colorspace_pars_fragment:Hy,envmap_fragment:Vy,envmap_common_pars_fragment:Wy,envmap_pars_fragment:$y,envmap_pars_vertex:Zy,envmap_physical_pars_fragment:iS,envmap_vertex:Xy,fog_vertex:qy,fog_pars_vertex:Yy,fog_fragment:jy,fog_pars_fragment:Ky,gradientmap_pars_fragment:Jy,lightmap_pars_fragment:Qy,lights_lambert_fragment:eS,lights_lambert_pars_fragment:tS,lights_pars_begin:nS,lights_toon_fragment:rS,lights_toon_pars_fragment:sS,lights_phong_fragment:oS,lights_phong_pars_fragment:aS,lights_physical_fragment:cS,lights_physical_pars_fragment:lS,lights_fragment_begin:uS,lights_fragment_maps:hS,lights_fragment_end:fS,lightprobes_pars_fragment:dS,logdepthbuf_fragment:pS,logdepthbuf_pars_fragment:mS,logdepthbuf_pars_vertex:gS,logdepthbuf_vertex:_S,map_fragment:xS,map_pars_fragment:vS,map_particle_fragment:yS,map_particle_pars_fragment:SS,metalnessmap_fragment:bS,metalnessmap_pars_fragment:MS,morphinstance_vertex:wS,morphcolor_vertex:TS,morphnormal_vertex:ES,morphtarget_pars_vertex:AS,morphtarget_vertex:RS,normal_fragment_begin:CS,normal_fragment_maps:PS,normal_pars_fragment:IS,normal_pars_vertex:LS,normal_vertex:NS,normalmap_pars_fragment:DS,clearcoat_normal_fragment_begin:OS,clearcoat_normal_fragment_maps:US,clearcoat_pars_fragment:FS,iridescence_pars_fragment:zS,opaque_fragment:kS,packing:BS,premultiplied_alpha_fragment:GS,project_vertex:HS,dithering_fragment:VS,dithering_pars_fragment:WS,roughnessmap_fragment:$S,roughnessmap_pars_fragment:ZS,shadowmap_pars_fragment:XS,shadowmap_pars_vertex:qS,shadowmap_vertex:YS,shadowmask_pars_fragment:jS,skinbase_vertex:KS,skinning_pars_vertex:JS,skinning_vertex:QS,skinnormal_vertex:eb,specularmap_fragment:tb,specularmap_pars_fragment:nb,tonemapping_fragment:ib,tonemapping_pars_fragment:rb,transmission_fragment:sb,transmission_pars_fragment:ob,uv_pars_fragment:ab,uv_pars_vertex:cb,uv_vertex:lb,worldpos_vertex:ub,background_vert:hb,background_frag:fb,backgroundCube_vert:db,backgroundCube_frag:pb,cube_vert:mb,cube_frag:gb,depth_vert:_b,depth_frag:xb,distance_vert:vb,distance_frag:yb,equirect_vert:Sb,equirect_frag:bb,linedashed_vert:Mb,linedashed_frag:wb,meshbasic_vert:Tb,meshbasic_frag:Eb,meshlambert_vert:Ab,meshlambert_frag:Rb,meshmatcap_vert:Cb,meshmatcap_frag:Pb,meshnormal_vert:Ib,meshnormal_frag:Lb,meshphong_vert:Nb,meshphong_frag:Db,meshphysical_vert:Ob,meshphysical_frag:Ub,meshtoon_vert:Fb,meshtoon_frag:zb,points_vert:kb,points_frag:Bb,shadow_vert:Gb,shadow_frag:Hb,sprite_vert:Vb,sprite_frag:Wb},fe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fe}},envmap:{envMap:{value:null},envMapRotation:{value:new Fe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fe},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0},uvTransform:{value:new Fe}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}}},ei={basic:{uniforms:Yt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Yt([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 Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Yt([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 Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Yt([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 Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Yt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Yt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Yt([fe.points,fe.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Yt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Yt([fe.common,fe.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Yt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Yt([fe.sprite,fe.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Fe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Fe}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:Yt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:Yt([fe.lights,fe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};ei.physical={uniforms:Yt([ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fe},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fe},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fe},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fe},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fe},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fe},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fe}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Aa={r:0,b:0,g:0},$b=new Be,lp=new Fe;lp.set(-1,0,0,0,1,0,0,0,1);function Zb(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let S=E.backgroundBlurriness>0;R=t.get(R,S)}return R}function g(E){let R=!1,S=d(E);if(S===null)p(o,a);else if(S&&S.isColor)p(S,1),R=!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||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let S=d(R);if(S&&(S.isCubeTexture||S.mapping===Rs)){if(l===void 0)l=new pt(new Vi(1,1,1),new Tn({name:"BackgroundCubeMaterial",uniforms:mr(ei.backgroundCube.uniforms),vertexShader:ei.backgroundCube.vertexShader,fragmentShader:ei.backgroundCube.fragmentShader,side:Xt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4($b.makeRotationFromEuler(R.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(lp);if(l.material.toneMapped=We.getTransfer(S.colorSpace)!==ht,u!==S||f!==S.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(S&&S.isTexture){if(c===void 0)c=new pt(new Gs(2,2),new Tn({name:"BackgroundMaterial",uniforms:mr(ei.background.uniforms),vertexShader:ei.background.vertexShader,fragmentShader:ei.background.fragmentShader,side:zi,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=S,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=We.getTransfer(S.colorSpace)!==ht,S.matrixAutoUpdate===!0)S.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(S.matrix),u!==S||f!==S.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Aa,Zl(e)),n.buffers.color.setClear(Aa.r,Aa.g,Aa.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function Xb(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(P,O,K,C,G){let X=!1,z=f(P,C,K,O);if(s!==z)s=z,l(s.object);if(X=d(P,C,K,G),X)g(P,C,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,S(P,O,K,C),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(P){return e.bindVertexArray(P)}function u(P){return e.deleteVertexArray(P)}function f(P,O,K,C){let G=C.wireframe===!0,X=i[O.id];if(X===void 0)X={},i[O.id]=X;let z=P.isInstancedMesh===!0?P.id:0,te=X[z];if(te===void 0)te={},X[z]=te;let H=te[K.id];if(H===void 0)H={},te[K.id]=H;let Q=H[G];if(Q===void 0)Q=h(c()),H[G]=Q;return Q}function h(P){let O=[],K=[],C=[];for(let G=0;G<n;G++)O[G]=0,K[G]=0,C[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:K,attributeDivisors:C,object:P,attributes:{},index:null}}function d(P,O,K,C){let G=s.attributes,X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=G[H],Te=X[H];if(Te===void 0){if(H==="instanceMatrix"&&P.instanceMatrix)Te=P.instanceMatrix;if(H==="instanceColor"&&P.instanceColor)Te=P.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Te)return!0;if(Te&&ee.data!==Te.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==C)return!0;return!1}function g(P,O,K,C){let G={},X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=X[H];if(ee===void 0){if(H==="instanceMatrix"&&P.instanceMatrix)ee=P.instanceMatrix;if(H==="instanceColor"&&P.instanceColor)ee=P.instanceColor}let Te={};if(Te.attribute=ee,ee&&ee.data)Te.data=ee.data;G[H]=Te,z++}s.attributes=G,s.attributesNum=z,s.index=C}function x(){let P=s.newAttributes;for(let O=0,K=P.length;O<K;O++)P[O]=0}function p(P){m(P,0)}function m(P,O){let K=s.newAttributes,C=s.enabledAttributes,G=s.attributeDivisors;if(K[P]=1,C[P]===0)e.enableVertexAttribArray(P),C[P]=1;if(G[P]!==O)e.vertexAttribDivisor(P,O),G[P]=O}function E(){let P=s.newAttributes,O=s.enabledAttributes;for(let K=0,C=O.length;K<C;K++)if(O[K]!==P[K])e.disableVertexAttribArray(K),O[K]=0}function R(P,O,K,C,G,X,z){if(z===!0)e.vertexAttribIPointer(P,O,K,G,X);else e.vertexAttribPointer(P,O,K,C,G,X)}function S(P,O,K,C){x();let G=C.attributes,X=K.getAttributes(),z=O.defaultAttributeValues;for(let te in X){let H=X[te];if(H.location>=0){let Q=G[te];if(Q===void 0){if(te==="instanceMatrix"&&P.instanceMatrix)Q=P.instanceMatrix;if(te==="instanceColor"&&P.instanceColor)Q=P.instanceColor}if(Q!==void 0){let ee=Q.normalized,Te=Q.itemSize,ve=t.get(Q);if(ve===void 0)continue;let{buffer:Ge,type:Me,bytesPerElement:Z}=ve,re=Me===e.INT||Me===e.UNSIGNED_INT||Q.gpuType===Qc;if(Q.isInterleavedBufferAttribute){let se=Q.data,Pe=se.stride,Ie=Q.offset;if(se.isInstancedInterleavedBuffer){for(let we=0;we<H.locationSize;we++)m(H.location+we,se.meshPerAttribute);if(P.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=se.meshPerAttribute*se.count}else for(let we=0;we<H.locationSize;we++)p(H.location+we);e.bindBuffer(e.ARRAY_BUFFER,Ge);for(let we=0;we<H.locationSize;we++)R(H.location+we,Te/H.locationSize,Me,ee,Pe*Z,(Ie+Te/H.locationSize*we)*Z,re)}else{if(Q.isInstancedBufferAttribute){for(let se=0;se<H.locationSize;se++)m(H.location+se,Q.meshPerAttribute);if(P.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=Q.meshPerAttribute*Q.count}else for(let se=0;se<H.locationSize;se++)p(H.location+se);e.bindBuffer(e.ARRAY_BUFFER,Ge);for(let se=0;se<H.locationSize;se++)R(H.location+se,Te/H.locationSize,Me,ee,Te*Z,Te/H.locationSize*se*Z,re)}}else if(z!==void 0){let ee=z[te];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(H.location,ee);break;case 3:e.vertexAttrib3fv(H.location,ee);break;case 4:e.vertexAttrib4fv(H.location,ee);break;default:e.vertexAttrib1fv(H.location,ee)}}}}E()}function b(){M();for(let P in i){let O=i[P];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[P]}}function T(P){if(i[P.id]===void 0)return;let O=i[P.id];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[P.id]}function A(P){for(let O in i){let K=i[O];for(let C in K){let G=K[C];if(G[P.id]===void 0)continue;let X=G[P.id];for(let z in X)u(X[z].object),delete X[z];delete G[P.id]}}}function _(P){for(let O in i){let K=i[O],C=P.isInstancedMesh===!0?P.id:0,G=K[C];if(G===void 0)continue;for(let X in G){let z=G[X];for(let te in z)u(z[te].object),delete z[te];delete G[X]}if(delete K[C],Object.keys(K).length===0)delete i[O]}}function M(){if(F(),o=!0,s===r)return;s=r,l(s.object)}function F(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:F,dispose:b,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function qb(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function Yb(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==Kn&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===jn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Un&&A!==xi&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Re("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Re("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:S,maxSamples:b,samples:T}}function jb(e){let t=this,n=null,i=0,r=!1,s=!1,o=new bn,a=new Fe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,S=m.clippingState||null;c.value=S,S=u(g,h,R,d);for(let b=0;b!==R;++b)S[b]=n[b];m.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,S=d;R!==x;++R,S+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,S),p[S+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var as=4,Kb=6,Jb=20,Qb=256,Zs=new _r,Gd=new Oe,lu=null,uu=0,hu=0,fu=!1,eM=new U,xr=new U;class js{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=eM}=r;lu=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),hu=this._renderer.getActiveMipmapLevel(),fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Wd(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Vd(),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(lu,uu,hu),this._renderer.xr.enabled=fu,e.scissorTest=!1,os(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Xr||e.mapping===cr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);lu=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),hu=this._renderer.getActiveMipmapLevel(),fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:kt,minFilter:kt,generateMipmaps:!1,type:jn,format:Kn,colorSpace:hn,depthBuffer:!1},i=Hd(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Hd(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=tM(r)),this._blurMaterial=iM(r,e,t),this._ggxMaterial=nM(r,e,t)}return i}_compileMaterial(e){let t=new pt(new qt,e);this._renderer.compile(t,Zs)}_sceneToCubeUV(e,t,n,i,r){let a=new Lt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(Gd),u.toneMapping=Dn,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 Vi,new Jn({name:"PMREM.Background",side:Xt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(Gd),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let S=this._cubeSize;if(os(i,R*S,E>2?S:0,S,S),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Xr||e.mapping===cr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Wd();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Vd();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;os(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Zs)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-as?n-d+as:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,os(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,Zs),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,os(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,Zs)}_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-as?i-this._lodMax+as:0),f=4*(this._cubeSize-l);os(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,Zs)}}function tM(e){let t=[],n=[],i=e,r=e-as+1+Kb;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,S=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(S,d*h*m);for(let b=0;b<h;b++){let T=u[b*2]*2-1,A=u[b*2+1]*2-1;if(m===0)xr.set(1,A,T);else if(m===1)xr.set(-T,1,-A);else if(m===2)xr.set(-T,A,1);else if(m===3)xr.set(-1,A,-T);else if(m===4)xr.set(-T,-1,A);else xr.set(T,A,-1);xr.toArray(x,(m*h+b)*d)}}let p=new qt;if(p.setAttribute("position",new zt(g,d)),p.setAttribute("outputDirection",new zt(x,d)),n.push(new pt(p,null)),i>as)i--}return{lodMeshes:n,sizeLods:t}}function Hd(e,t,n){let i=new fn(e,t,n);return i.texture.mapping=Rs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function os(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function nM(e,t,n){return new Tn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Qb,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:Ca(),fragmentShader:`
+}`,Ve={alphahash_fragment:py,alphahash_pars_fragment:my,alphamap_fragment:gy,alphamap_pars_fragment:_y,alphatest_fragment:xy,alphatest_pars_fragment:vy,aomap_fragment:yy,aomap_pars_fragment:Sy,batching_pars_vertex:by,batching_vertex:My,begin_vertex:wy,beginnormal_vertex:Ty,bsdfs:Ey,iridescence_fragment:Ay,bumpmap_pars_fragment:Ry,clipping_planes_fragment:Cy,clipping_planes_pars_fragment:Py,clipping_planes_pars_vertex:Iy,clipping_planes_vertex:Ly,color_fragment:Ny,color_pars_fragment:Dy,color_pars_vertex:Oy,color_vertex:Uy,common:Fy,cube_uv_reflection_fragment:zy,defaultnormal_vertex:ky,displacementmap_pars_vertex:By,displacementmap_vertex:Gy,emissivemap_fragment:Hy,emissivemap_pars_fragment:Vy,colorspace_fragment:Wy,colorspace_pars_fragment:$y,envmap_fragment:Zy,envmap_common_pars_fragment:Xy,envmap_pars_fragment:qy,envmap_pars_vertex:Yy,envmap_physical_pars_fragment:oS,envmap_vertex:jy,fog_vertex:Ky,fog_pars_vertex:Jy,fog_fragment:Qy,fog_pars_fragment:eS,gradientmap_pars_fragment:tS,lightmap_pars_fragment:nS,lights_lambert_fragment:iS,lights_lambert_pars_fragment:rS,lights_pars_begin:sS,lights_toon_fragment:aS,lights_toon_pars_fragment:cS,lights_phong_fragment:lS,lights_phong_pars_fragment:uS,lights_physical_fragment:hS,lights_physical_pars_fragment:fS,lights_fragment_begin:dS,lights_fragment_maps:pS,lights_fragment_end:mS,lightprobes_pars_fragment:gS,logdepthbuf_fragment:_S,logdepthbuf_pars_fragment:xS,logdepthbuf_pars_vertex:vS,logdepthbuf_vertex:yS,map_fragment:SS,map_pars_fragment:bS,map_particle_fragment:MS,map_particle_pars_fragment:wS,metalnessmap_fragment:TS,metalnessmap_pars_fragment:ES,morphinstance_vertex:AS,morphcolor_vertex:RS,morphnormal_vertex:CS,morphtarget_pars_vertex:PS,morphtarget_vertex:IS,normal_fragment_begin:LS,normal_fragment_maps:NS,normal_pars_fragment:DS,normal_pars_vertex:OS,normal_vertex:US,normalmap_pars_fragment:FS,clearcoat_normal_fragment_begin:zS,clearcoat_normal_fragment_maps:kS,clearcoat_pars_fragment:BS,iridescence_pars_fragment:GS,opaque_fragment:HS,packing:VS,premultiplied_alpha_fragment:WS,project_vertex:$S,dithering_fragment:ZS,dithering_pars_fragment:XS,roughnessmap_fragment:qS,roughnessmap_pars_fragment:YS,shadowmap_pars_fragment:jS,shadowmap_pars_vertex:KS,shadowmap_vertex:JS,shadowmask_pars_fragment:QS,skinbase_vertex:eb,skinning_pars_vertex:tb,skinning_vertex:nb,skinnormal_vertex:ib,specularmap_fragment:rb,specularmap_pars_fragment:sb,tonemapping_fragment:ob,tonemapping_pars_fragment:ab,transmission_fragment:cb,transmission_pars_fragment:lb,uv_pars_fragment:ub,uv_pars_vertex:hb,uv_vertex:fb,worldpos_vertex:db,background_vert:pb,background_frag:mb,backgroundCube_vert:gb,backgroundCube_frag:_b,cube_vert:xb,cube_frag:vb,depth_vert:yb,depth_frag:Sb,distance_vert:bb,distance_frag:Mb,equirect_vert:wb,equirect_frag:Tb,linedashed_vert:Eb,linedashed_frag:Ab,meshbasic_vert:Rb,meshbasic_frag:Cb,meshlambert_vert:Pb,meshlambert_frag:Ib,meshmatcap_vert:Lb,meshmatcap_frag:Nb,meshnormal_vert:Db,meshnormal_frag:Ob,meshphong_vert:Ub,meshphong_frag:Fb,meshphysical_vert:zb,meshphysical_frag:kb,meshtoon_vert:Bb,meshtoon_frag:Gb,points_vert:Hb,points_frag:Vb,shadow_vert:Wb,shadow_frag:$b,sprite_vert:Zb,sprite_frag:Xb},fe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fe}},envmap:{envMap:{value:null},envMapRotation:{value:new Fe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fe},normalScale:{value:new Ne(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0},uvTransform:{value:new Fe}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ne(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}}},ei={basic:{uniforms:Yt([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Yt([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 Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Yt([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 Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Yt([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 Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Yt([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Yt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Yt([fe.points,fe.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Yt([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Yt([fe.common,fe.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Yt([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Yt([fe.sprite,fe.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Fe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Fe}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distance:{uniforms:Yt([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ve.distance_vert,fragmentShader:Ve.distance_frag},shadow:{uniforms:Yt([fe.lights,fe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};ei.physical={uniforms:Yt([ei.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fe},clearcoatNormalScale:{value:new Ne(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fe},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fe},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fe},transmissionSamplerSize:{value:new Ne},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fe},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fe},anisotropyVector:{value:new Ne},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fe}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};var Aa={r:0,b:0,g:0},qb=new Be,hp=new Fe;hp.set(-1,0,0,0,1,0,0,0,1);function Yb(e,t,n,i,r,s){let o=new Oe(0),a=r===!0?0:1,c,l,u=null,f=0,h=null;function d(E){let R=E.isScene===!0?E.background:null;if(R&&R.isTexture){let S=E.backgroundBlurriness>0;R=t.get(R,S)}return R}function g(E){let R=!1,S=d(E);if(S===null)p(o,a);else if(S&&S.isColor)p(S,1),R=!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||R)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function x(E,R){let S=d(R);if(S&&(S.isCubeTexture||S.mapping===Rs)){if(l===void 0)l=new pt(new Vi(1,1,1),new Tn({name:"BackgroundCubeMaterial",uniforms:mr(ei.backgroundCube.uniforms),vertexShader:ei.backgroundCube.vertexShader,fragmentShader:ei.backgroundCube.fragmentShader,side:Xt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,T,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(qb.makeRotationFromEuler(R.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(hp);if(l.material.toneMapped=We.getTransfer(S.colorSpace)!==ht,u!==S||f!==S.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;l.layers.enableAll(),E.unshift(l,l.geometry,l.material,0,0,null)}else if(S&&S.isTexture){if(c===void 0)c=new pt(new Gs(2,2),new Tn({name:"BackgroundMaterial",uniforms:mr(ei.background.uniforms),vertexShader:ei.background.vertexShader,fragmentShader:ei.background.fragmentShader,side:zi,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=S,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=We.getTransfer(S.colorSpace)!==ht,S.matrixAutoUpdate===!0)S.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(S.matrix),u!==S||f!==S.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=S,f=S.version,h=e.toneMapping;c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null)}}function p(E,R){E.getRGB(Aa,Zl(e)),n.buffers.color.setClear(Aa.r,Aa.g,Aa.b,R,s)}function m(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(E,R=1){o.set(E),a=R,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(E){a=E,p(o,a)},render:g,addToRenderList:x,dispose:m}}function jb(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(P,O,K,C,G){let X=!1,z=f(P,C,K,O);if(s!==z)s=z,l(s.object);if(X=d(P,C,K,G),X)g(P,C,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,S(P,O,K,C),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(P){return e.bindVertexArray(P)}function u(P){return e.deleteVertexArray(P)}function f(P,O,K,C){let G=C.wireframe===!0,X=i[O.id];if(X===void 0)X={},i[O.id]=X;let z=P.isInstancedMesh===!0?P.id:0,te=X[z];if(te===void 0)te={},X[z]=te;let H=te[K.id];if(H===void 0)H={},te[K.id]=H;let Q=H[G];if(Q===void 0)Q=h(c()),H[G]=Q;return Q}function h(P){let O=[],K=[],C=[];for(let G=0;G<n;G++)O[G]=0,K[G]=0,C[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:K,attributeDivisors:C,object:P,attributes:{},index:null}}function d(P,O,K,C){let G=s.attributes,X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=G[H],Te=X[H];if(Te===void 0){if(H==="instanceMatrix"&&P.instanceMatrix)Te=P.instanceMatrix;if(H==="instanceColor"&&P.instanceColor)Te=P.instanceColor}if(ee===void 0)return!0;if(ee.attribute!==Te)return!0;if(Te&&ee.data!==Te.data)return!0;z++}if(s.attributesNum!==z)return!0;if(s.index!==C)return!0;return!1}function g(P,O,K,C){let G={},X=O.attributes,z=0,te=K.getAttributes();for(let H in te)if(te[H].location>=0){let ee=X[H];if(ee===void 0){if(H==="instanceMatrix"&&P.instanceMatrix)ee=P.instanceMatrix;if(H==="instanceColor"&&P.instanceColor)ee=P.instanceColor}let Te={};if(Te.attribute=ee,ee&&ee.data)Te.data=ee.data;G[H]=Te,z++}s.attributes=G,s.attributesNum=z,s.index=C}function x(){let P=s.newAttributes;for(let O=0,K=P.length;O<K;O++)P[O]=0}function p(P){m(P,0)}function m(P,O){let K=s.newAttributes,C=s.enabledAttributes,G=s.attributeDivisors;if(K[P]=1,C[P]===0)e.enableVertexAttribArray(P),C[P]=1;if(G[P]!==O)e.vertexAttribDivisor(P,O),G[P]=O}function E(){let P=s.newAttributes,O=s.enabledAttributes;for(let K=0,C=O.length;K<C;K++)if(O[K]!==P[K])e.disableVertexAttribArray(K),O[K]=0}function R(P,O,K,C,G,X,z){if(z===!0)e.vertexAttribIPointer(P,O,K,G,X);else e.vertexAttribPointer(P,O,K,C,G,X)}function S(P,O,K,C){x();let G=C.attributes,X=K.getAttributes(),z=O.defaultAttributeValues;for(let te in X){let H=X[te];if(H.location>=0){let Q=G[te];if(Q===void 0){if(te==="instanceMatrix"&&P.instanceMatrix)Q=P.instanceMatrix;if(te==="instanceColor"&&P.instanceColor)Q=P.instanceColor}if(Q!==void 0){let ee=Q.normalized,Te=Q.itemSize,ve=t.get(Q);if(ve===void 0)continue;let{buffer:Ge,type:Me,bytesPerElement:Z}=ve,re=Me===e.INT||Me===e.UNSIGNED_INT||Q.gpuType===Qc;if(Q.isInterleavedBufferAttribute){let se=Q.data,Pe=se.stride,Ie=Q.offset;if(se.isInstancedInterleavedBuffer){for(let we=0;we<H.locationSize;we++)m(H.location+we,se.meshPerAttribute);if(P.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=se.meshPerAttribute*se.count}else for(let we=0;we<H.locationSize;we++)p(H.location+we);e.bindBuffer(e.ARRAY_BUFFER,Ge);for(let we=0;we<H.locationSize;we++)R(H.location+we,Te/H.locationSize,Me,ee,Pe*Z,(Ie+Te/H.locationSize*we)*Z,re)}else{if(Q.isInstancedBufferAttribute){for(let se=0;se<H.locationSize;se++)m(H.location+se,Q.meshPerAttribute);if(P.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=Q.meshPerAttribute*Q.count}else for(let se=0;se<H.locationSize;se++)p(H.location+se);e.bindBuffer(e.ARRAY_BUFFER,Ge);for(let se=0;se<H.locationSize;se++)R(H.location+se,Te/H.locationSize,Me,ee,Te*Z,Te/H.locationSize*se*Z,re)}}else if(z!==void 0){let ee=z[te];if(ee!==void 0)switch(ee.length){case 2:e.vertexAttrib2fv(H.location,ee);break;case 3:e.vertexAttrib3fv(H.location,ee);break;case 4:e.vertexAttrib4fv(H.location,ee);break;default:e.vertexAttrib1fv(H.location,ee)}}}}E()}function b(){M();for(let P in i){let O=i[P];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[P]}}function T(P){if(i[P.id]===void 0)return;let O=i[P.id];for(let K in O){let C=O[K];for(let G in C){let X=C[G];for(let z in X)u(X[z].object),delete X[z];delete C[G]}}delete i[P.id]}function A(P){for(let O in i){let K=i[O];for(let C in K){let G=K[C];if(G[P.id]===void 0)continue;let X=G[P.id];for(let z in X)u(X[z].object),delete X[z];delete G[P.id]}}}function _(P){for(let O in i){let K=i[O],C=P.isInstancedMesh===!0?P.id:0,G=K[C];if(G===void 0)continue;for(let X in G){let z=G[X];for(let te in z)u(z[te].object),delete z[te];delete G[X]}if(delete K[C],Object.keys(K).length===0)delete i[O]}}function M(){if(F(),o=!0,s===r)return;s=r,l(s.object)}function F(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:F,dispose:b,releaseStatesOfGeometry:T,releaseStatesOfObject:_,releaseStatesOfProgram:A,initAttributes:x,enableAttribute:p,disableUnusedAttributes:E}}function Kb(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function Jb(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(A){if(A!==Kn&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(A){let _=A===jn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(A!==Un&&A!==xi&&!_&&i.convert(A)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(A){if(A==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";A="mediump"}if(A==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Re("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let f=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Re("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),g=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),R=e.getParameter(e.MAX_VARYING_VECTORS),S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),b=e.getParameter(e.MAX_SAMPLES),T=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:E,maxVaryings:R,maxFragmentUniforms:S,maxSamples:b,samples:T}}function Qb(e){let t=this,n=null,i=0,r=!1,s=!1,o=new bn,a=new Fe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let d=f.length!==0||h||i!==0||r;return r=h,i=f.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){n=u(f,h,0)},this.setState=function(f,h,d){let{clippingPlanes:g,clipIntersection:x,clipShadows:p}=f,m=e.get(f);if(!r||g===null||g.length===0||s&&!p)if(s)u(null);else l();else{let E=s?0:i,R=E*4,S=m.clippingState||null;c.value=S,S=u(g,h,R,d);for(let b=0;b!==R;++b)S[b]=n[b];m.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=E}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(f,h,d,g){let x=f!==null?f.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let m=d+x*4,E=h.matrixWorldInverse;if(a.getNormalMatrix(E),p===null||p.length<m)p=new Float32Array(m);for(let R=0,S=d;R!==x;++R,S+=4)o.copy(f[R]).applyMatrix4(E,a),o.normal.toArray(p,S),p[S+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}var as=4,eM=6,tM=20,nM=256,Zs=new _r,Vd=new Oe,lu=null,uu=0,hu=0,fu=!1,iM=new U,xr=new U;class js{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=iM}=r;lu=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),hu=this._renderer.getActiveMipmapLevel(),fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let a=this._allocateTargets();if(a.depthBuffer=!0,this._sceneToCubeUV(e,n,i,a,o),t>0)this._blur(a,0,0,t);return this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=Zd(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=$d(),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(lu,uu,hu),this._renderer.xr.enabled=fu,e.scissorTest=!1,os(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Xr||e.mapping===cr)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);lu=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),hu=this._renderer.getActiveMipmapLevel(),fu=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:kt,minFilter:kt,generateMipmaps:!1,type:jn,format:Kn,colorSpace:hn,depthBuffer:!1},i=Wd(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Wd(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=rM(r)),this._blurMaterial=oM(r,e,t),this._ggxMaterial=sM(r,e,t)}return i}_compileMaterial(e){let t=new pt(new qt,e);this._renderer.compile(t,Zs)}_sceneToCubeUV(e,t,n,i,r){let a=new Lt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:f,toneMapping:h}=u;if(u.getClearColor(Vd),u.toneMapping=Dn,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 Vi,new Jn({name:"PMREM.Background",side:Xt,depthWrite:!1,depthTest:!1}));let g=this._backgroundBox,x=g.material,p=!1,m=e.background;if(m){if(m.isColor)x.color.copy(m),e.background=null,p=!0}else x.color.copy(Vd),p=!0;for(let E=0;E<6;E++){let R=E%3;if(R===0)a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[E],r.y,r.z);else if(R===1)a.up.set(0,0,c[E]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[E],r.z);else a.up.set(0,c[E],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[E]);let S=this._cubeSize;if(os(i,R*S,E>2?S:0,S,S),u.setRenderTarget(i),p)u.render(g,a);u.render(e,a)}u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Xr||e.mapping===cr;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Zd();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=$d();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;os(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Zs)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),f=c*1.25,h=u*f,{_lodMax:d}=this,g=this._sizeLods[n],x=3*g*(n>d-as?n-d+as:0),p=4*(this._cubeSize-g);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=d-t,os(r,x,p,3*g,2*g),i.setRenderTarget(r),i.render(o,Zs),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=d-n,os(e,x,p,3*g,2*g),i.setRenderTarget(e),i.render(o,Zs)}_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-as?i-this._lodMax+as:0),f=4*(this._cubeSize-l);os(t,u,f,3*l,2*l),s.setRenderTarget(t),s.render(a,Zs)}}function rM(e){let t=[],n=[],i=e,r=e-as+1+eM;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],f=6,h=6,d=3,g=new Float32Array(d*h*f),x=new Float32Array(d*h*f);for(let m=0;m<f;m++){let E=m%3*2/3-1,R=m>2?0:-1,S=[E,R,0,E+0.6666666666666666,R,0,E+0.6666666666666666,R+1,0,E,R,0,E+0.6666666666666666,R+1,0,E,R+1,0];g.set(S,d*h*m);for(let b=0;b<h;b++){let T=u[b*2]*2-1,A=u[b*2+1]*2-1;if(m===0)xr.set(1,A,T);else if(m===1)xr.set(-T,1,-A);else if(m===2)xr.set(-T,A,1);else if(m===3)xr.set(-1,A,-T);else if(m===4)xr.set(-T,-1,A);else xr.set(T,A,-1);xr.toArray(x,(m*h+b)*d)}}let p=new qt;if(p.setAttribute("position",new zt(g,d)),p.setAttribute("outputDirection",new zt(x,d)),n.push(new pt(p,null)),i>as)i--}return{lodMeshes:n,sizeLods:t}}function Wd(e,t,n){let i=new fn(e,t,n);return i.texture.mapping=Rs,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function os(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function sM(e,t,n){return new Tn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nM,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:Ca(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:qn,depthTest:!1,depthWrite:!1})}function iM(e,t,n){return new Tn({name:"SphericalGaussianBlur",defines:{SAMPLES:Jb,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:Ca(),fragmentShader:`
+ `,blending:qn,depthTest:!1,depthWrite:!1})}function oM(e,t,n){return new Tn({name:"SphericalGaussianBlur",defines:{SAMPLES:tM,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:Ca(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:qn,depthTest:!1,depthWrite:!1})}function Vd(){return new Tn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ca(),fragmentShader:`
+ `,blending:qn,depthTest:!1,depthWrite:!1})}function $d(){return new Tn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ca(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:qn,depthTest:!1,depthWrite:!1})}function Wd(){return new Tn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ca(),fragmentShader:`
+ `,blending:qn,depthTest:!1,depthWrite:!1})}function Zd(){return new Tn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ca(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4193,7 +4193,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new Vi(5,5,5),r=new Tn({name:"CubemapFromEquirect",uniforms:mr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Xt,blending:qn});r.uniforms.tEquirect.value=t;let s=new pt(i,r),o=t.minFilter;if(t.minFilter===Yn)t.minFilter=kt;return new tu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function rM(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===Yo||d===jo)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new _u(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===Yo||d===jo,x=d===Xr||d===cr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new js(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new js(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===Yo)h.mapping=Xr;else if(d===jo)h.mapping=cr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function sM(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)or("WebGLRenderer: "+i+" extension not supported.");return r}}}function oM(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,S=E.length;R<S;R+=3){let b=E[R+0],T=E[R+1],A=E[R+2];h.push(b,T,T,A,A,b)}}else{let E=g.array;x=g.version;for(let R=0,S=E.length/3-1;R<S;R+=3){let b=R+0,T=R+1,A=R+2;h.push(b,T,T,A,A,b)}}let p=new(g.count>=65535?ha:ua)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function aM(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function cM(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function lM(e,t,n){let i=new WeakMap,r=new ot;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let S=a.attributes.position.count*R,b=1;if(S>t.maxTextureSize)b=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize;let T=new Float32Array(S*b*4*f),A=new ca(T,S,b,f);A.type=xi,A.needsUpdate=!0;let _=R*4;for(let F=0;F<f;F++){let P=p[F],O=m[F],K=E[F],C=S*b*4*F;for(let G=0;G<P.count;G++){let X=G*_;if(d===!0)r.fromBufferAttribute(P,G),T[C+X+0]=r.x,T[C+X+1]=r.y,T[C+X+2]=r.z,T[C+X+3]=0;if(g===!0)r.fromBufferAttribute(O,G),T[C+X+4]=r.x,T[C+X+5]=r.y,T[C+X+6]=r.z,T[C+X+7]=0;if(x===!0)r.fromBufferAttribute(K,G),T[C+X+8]=r.x,T[C+X+9]=r.y,T[C+X+10]=r.z,T[C+X+11]=K.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(S,b)},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 d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function uM(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var hM={[Xc]:"LINEAR_TONE_MAPPING",[qc]:"REINHARD_TONE_MAPPING",[Yc]:"CINEON_TONE_MAPPING",[As]:"ACES_FILMIC_TONE_MAPPING",[Kc]:"AGX_TONE_MAPPING",[Jc]:"NEUTRAL_TONE_MAPPING",[jc]:"CUSTOM_TONE_MAPPING"};function fM(e,t,n,i,r,s){let o=new fn(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 qt;l.setAttribute("position",new sn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new sn([0,2,0,0,2,0],2));let u=new Xl({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new Vi(5,5,5),r=new Tn({name:"CubemapFromEquirect",uniforms:mr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Xt,blending:qn});r.uniforms.tEquirect.value=t;let s=new pt(i,r),o=t.minFilter;if(t.minFilter===Yn)t.minFilter=kt;return new tu(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}}function aM(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,d=!1){if(h===null||h===void 0)return null;if(d)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let d=h.mapping;if(d===Yo||d===jo)if(t.has(h)){let g=t.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new _u(g.height);return x.fromEquirectangularTexture(e,h),t.set(h,x),h.addEventListener("dispose",l),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let d=h.mapping,g=d===Yo||d===jo,x=d===Xr||d===cr;if(g||x){let p=n.get(h),m=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m){if(i===null)i=new js(e);return p=g?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let E=h.image;if(g&&E&&E.height>0||x&&E&&c(E)){if(i===null)i=new js(e);return p=g?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,d){if(d===Yo)h.mapping=Xr;else if(d===jo)h.mapping=cr;return h}function c(h){let d=0,g=6;for(let x=0;x<g;x++)if(h[x]!==void 0)d++;return d===g}function l(h){let d=h.target;d.removeEventListener("dispose",l);let g=t.get(d);if(g!==void 0)t.delete(d),g.dispose()}function u(h){let d=h.target;d.removeEventListener("dispose",u);let g=n.get(d);if(g!==void 0)n.delete(d),g.dispose()}function f(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:f}}function cM(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)or("WebGLRenderer: "+i+" extension not supported.");return r}}}function lM(e,t,n,i){let r={},s=new WeakMap;function o(f){let h=f.target;if(h.index!==null)t.remove(h.index);for(let g in h.attributes)t.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete r[h.id];let d=s.get(h);if(d)t.remove(d),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(f,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(f){let h=f.attributes;for(let d in h)t.update(h[d],e.ARRAY_BUFFER)}function l(f){let h=[],d=f.index,g=f.attributes.position,x=0;if(g===void 0)return;if(d!==null){let E=d.array;x=d.version;for(let R=0,S=E.length;R<S;R+=3){let b=E[R+0],T=E[R+1],A=E[R+2];h.push(b,T,T,A,A,b)}}else{let E=g.array;x=g.version;for(let R=0,S=E.length/3-1;R<S;R+=3){let b=R+0,T=R+1,A=R+2;h.push(b,T,T,A,A,b)}}let p=new(g.count>=65535?ha:ua)(h,1);p.version=x;let m=s.get(f);if(m)t.remove(m);s.set(f,p)}function u(f){let h=s.get(f);if(h){let d=f.index;if(d!==null){if(h.version<d.version)l(f)}}else l(f);return s.get(f)}return{get:a,update:c,getWireframeAttribute:u}}function uM(e,t,n){let i;function r(f){i=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,h){e.drawElements(i,h,s,f*o),n.update(h,i,1)}function l(f,h,d){if(d===0)return;e.drawElementsInstanced(i,h,s,f*o,d),n.update(h,i,d)}function u(f,h,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,f,0,d);let x=0;for(let p=0;p<d;p++)x+=h[p];n.update(x,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function hM(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:Ue("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function fM(e,t,n){let i=new WeakMap,r=new ot;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==f){let M=function(){A.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let d=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],E=a.morphAttributes.color||[],R=0;if(d===!0)R=1;if(g===!0)R=2;if(x===!0)R=3;let S=a.attributes.position.count*R,b=1;if(S>t.maxTextureSize)b=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize;let T=new Float32Array(S*b*4*f),A=new ca(T,S,b,f);A.type=xi,A.needsUpdate=!0;let _=R*4;for(let F=0;F<f;F++){let P=p[F],O=m[F],K=E[F],C=S*b*4*F;for(let G=0;G<P.count;G++){let X=G*_;if(d===!0)r.fromBufferAttribute(P,G),T[C+X+0]=r.x,T[C+X+1]=r.y,T[C+X+2]=r.z,T[C+X+3]=0;if(g===!0)r.fromBufferAttribute(O,G),T[C+X+4]=r.x,T[C+X+5]=r.y,T[C+X+6]=r.z,T[C+X+7]=0;if(x===!0)r.fromBufferAttribute(K,G),T[C+X+8]=r.x,T[C+X+9]=r.y,T[C+X+10]=r.z,T[C+X+11]=K.itemSize===4?r.w:1}}h={count:f,texture:A,size:new Ne(S,b)},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 d=0;for(let x=0;x<l.length;x++)d+=l[x];let g=a.morphTargetsRelative?1:1-d;c.getUniforms().setValue(e,"morphTargetBaseInfluence",g),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function dM(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,f=l.geometry,h=t.get(l,f);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let d=l.skeleton;if(s.get(d)!==u)d.update(),s.set(d,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var pM={[Xc]:"LINEAR_TONE_MAPPING",[qc]:"REINHARD_TONE_MAPPING",[Yc]:"CINEON_TONE_MAPPING",[As]:"ACES_FILMIC_TONE_MAPPING",[Kc]:"AGX_TONE_MAPPING",[Jc]:"NEUTRAL_TONE_MAPPING",[jc]:"CUSTOM_TONE_MAPPING"};function mM(e,t,n,i,r,s){let o=new fn(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 qt;l.setAttribute("position",new sn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new sn([0,2,0,0,2,0],2));let u=new Xl({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -4239,17 +4239,17 @@ void main() {
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),f=new pt(l,u),h=new _r(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(S,b){if(o.setSize(S,b),a!==null)a.setSize(S,b);if(c!==null)c.setSize(S,b);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(S,b)}},this.setEffects=function(S){E=S,R=E.length>0&&E[0].isRenderPass===!0;let{width:b,height:T}=o;if(E.length>0&&a===null)a=new fn(b,T,{type:jn,depthBuffer:!1,stencilBuffer:!1}),c=new fn(b,T,{type:jn,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(b,T)}},this.begin=function(S,b){if(x)return!1;if(S.toneMapping===Dn&&E.length===0)return!1;if(m=b,b!==null){let{width:T,height:A}=b;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)S.setRenderTarget(o);return p=S.toneMapping,S.toneMapping=Dn,!0},this.hasRenderPass=function(){return R},this.end=function(S,b){S.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let M=E[_];if(M.enabled===!1)continue;if(M.render(S,A,T,b),M.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==S.outputColorSpace||g!==S.toneMapping){if(d=S.outputColorSpace,g=S.toneMapping,u.defines={},We.getTransfer(d)===ht)u.defines.SRGB_TRANSFER="";let _=hM[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,S.setRenderTarget(m),S.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var up=new Mt,mu=new pr(1,1),hp=new ca,fp=new Wl,dp=new ma,$d=[],Zd=[],Xd=new Float32Array(16),qd=new Float32Array(9),Yd=new Float32Array(4);function cs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=$d[r];if(s===void 0)s=new Float32Array(r),$d[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 Nt(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 Dt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pa(e,t){let n=Zd[t];if(n===void 0)n=new Int32Array(t),Zd[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function dM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function pM(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(Nt(n,t))return;e.uniform2fv(this.addr,t),Dt(n,t)}}function mM(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(Nt(n,t))return;e.uniform3fv(this.addr,t),Dt(n,t)}}function gM(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(Nt(n,t))return;e.uniform4fv(this.addr,t),Dt(n,t)}}function _M(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;Yd.set(i),e.uniformMatrix2fv(this.addr,!1,Yd),Dt(n,i)}}function xM(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;qd.set(i),e.uniformMatrix3fv(this.addr,!1,qd),Dt(n,i)}}function vM(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;Xd.set(i),e.uniformMatrix4fv(this.addr,!1,Xd),Dt(n,i)}}function yM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function SM(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(Nt(n,t))return;e.uniform2iv(this.addr,t),Dt(n,t)}}function bM(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(Nt(n,t))return;e.uniform3iv(this.addr,t),Dt(n,t)}}function MM(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(Nt(n,t))return;e.uniform4iv(this.addr,t),Dt(n,t)}}function wM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function TM(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(Nt(n,t))return;e.uniform2uiv(this.addr,t),Dt(n,t)}}function EM(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(Nt(n,t))return;e.uniform3uiv(this.addr,t),Dt(n,t)}}function AM(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(Nt(n,t))return;e.uniform4uiv(this.addr,t),Dt(n,t)}}function RM(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)mu.compareFunction=n.isReversedDepthBuffer()?aa:oa,s=mu;else s=up;n.setTexture2D(t||s,r)}function CM(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||fp,r)}function PM(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||dp,r)}function IM(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||hp,r)}function LM(e){switch(e){case 5126:return dM;case 35664:return pM;case 35665:return mM;case 35666:return gM;case 35674:return _M;case 35675:return xM;case 35676:return vM;case 5124:case 35670:return yM;case 35667:case 35671:return SM;case 35668:case 35672:return bM;case 35669:case 35673:return MM;case 5125:return wM;case 36294:return TM;case 36295:return EM;case 36296:return AM;case 35678:case 36198:case 36298:case 36306:case 35682:return RM;case 35679:case 36299:case 36307:return CM;case 35680:case 36300:case 36308:case 36293:return PM;case 36289:case 36303:case 36311:case 36292:return IM}}function NM(e,t){e.uniform1fv(this.addr,t)}function DM(e,t){let n=cs(t,this.size,2);e.uniform2fv(this.addr,n)}function OM(e,t){let n=cs(t,this.size,3);e.uniform3fv(this.addr,n)}function UM(e,t){let n=cs(t,this.size,4);e.uniform4fv(this.addr,n)}function FM(e,t){let n=cs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function zM(e,t){let n=cs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function kM(e,t){let n=cs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function BM(e,t){e.uniform1iv(this.addr,t)}function GM(e,t){e.uniform2iv(this.addr,t)}function HM(e,t){e.uniform3iv(this.addr,t)}function VM(e,t){e.uniform4iv(this.addr,t)}function WM(e,t){e.uniform1uiv(this.addr,t)}function $M(e,t){e.uniform2uiv(this.addr,t)}function ZM(e,t){e.uniform3uiv(this.addr,t)}function XM(e,t){e.uniform4uiv(this.addr,t)}function qM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=mu;else o=up;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function YM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||fp,s[o])}function jM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||dp,s[o])}function KM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||hp,s[o])}function JM(e){switch(e){case 5126:return NM;case 35664:return DM;case 35665:return OM;case 35666:return UM;case 35674:return FM;case 35675:return zM;case 35676:return kM;case 5124:case 35670:return BM;case 35667:case 35671:return GM;case 35668:case 35672:return HM;case 35669:case 35673:return VM;case 5125:return WM;case 36294:return $M;case 36295:return ZM;case 36296:return XM;case 35678:case 36198:case 36298:case 36306:case 35682:return qM;case 35679:case 36299:case 36307:return YM;case 35680:case 36300:case 36308:case 36293:return jM;case 36289:case 36303:case 36311:case 36292:return KM}}class pp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=LM(t.type)}}class mp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=JM(t.type)}}class gp{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 du=/(\w+)(\])?(\[|\.)?/g;function jd(e,t){e.seq.push(t),e.map[t.id]=t}function QM(e,t,n){let i=e.name,r=i.length;du.lastIndex=0;while(!0){let s=du.exec(i),o=du.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){jd(n,l===void 0?new pp(a,e,t):new mp(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new gp(a),jd(n,f);n=f}}}class Ys{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);QM(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 Kd(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var ew=37297,tw=0;function nw(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),f=new pt(l,u),h=new _r(-1,1,1,-1,0,1),d=null,g=null,x=!1,p,m=null,E=[],R=!1;this.setSize=function(S,b){if(o.setSize(S,b),a!==null)a.setSize(S,b);if(c!==null)c.setSize(S,b);for(let T=0;T<E.length;T++){let A=E[T];if(A.setSize)A.setSize(S,b)}},this.setEffects=function(S){E=S,R=E.length>0&&E[0].isRenderPass===!0;let{width:b,height:T}=o;if(E.length>0&&a===null)a=new fn(b,T,{type:jn,depthBuffer:!1,stencilBuffer:!1}),c=new fn(b,T,{type:jn,depthBuffer:!1,stencilBuffer:!1});for(let A=0;A<E.length;A++){let _=E[A];if(_.setSize)_.setSize(b,T)}},this.begin=function(S,b){if(x)return!1;if(S.toneMapping===Dn&&E.length===0)return!1;if(m=b,b!==null){let{width:T,height:A}=b;if(o.width!==T||o.height!==A)this.setSize(T,A)}if(R===!1)S.setRenderTarget(o);return p=S.toneMapping,S.toneMapping=Dn,!0},this.hasRenderPass=function(){return R},this.end=function(S,b){S.toneMapping=p,x=!0;let T=o,A=a;for(let _=0;_<E.length;_++){let M=E[_];if(M.enabled===!1)continue;if(M.render(S,A,T,b),M.needsSwap!==!1)T=A,A=A===a?c:a}if(d!==S.outputColorSpace||g!==S.toneMapping){if(d=S.outputColorSpace,g=S.toneMapping,u.defines={},We.getTransfer(d)===ht)u.defines.SRGB_TRANSFER="";let _=pM[g];if(_)u.defines[_]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=T.texture,S.setRenderTarget(m),S.render(f,h),m=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var fp=new Mt,mu=new pr(1,1),dp=new ca,pp=new Wl,mp=new ma,Xd=[],qd=[],Yd=new Float32Array(16),jd=new Float32Array(9),Kd=new Float32Array(4);function cs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Xd[r];if(s===void 0)s=new Float32Array(r),Xd[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 Nt(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 Dt(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Pa(e,t){let n=qd[t];if(n===void 0)n=new Int32Array(t),qd[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function gM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function _M(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(Nt(n,t))return;e.uniform2fv(this.addr,t),Dt(n,t)}}function xM(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(Nt(n,t))return;e.uniform3fv(this.addr,t),Dt(n,t)}}function vM(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(Nt(n,t))return;e.uniform4fv(this.addr,t),Dt(n,t)}}function yM(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;Kd.set(i),e.uniformMatrix2fv(this.addr,!1,Kd),Dt(n,i)}}function SM(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;jd.set(i),e.uniformMatrix3fv(this.addr,!1,jd),Dt(n,i)}}function bM(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Nt(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Dt(n,t)}else{if(Nt(n,i))return;Yd.set(i),e.uniformMatrix4fv(this.addr,!1,Yd),Dt(n,i)}}function MM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function wM(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(Nt(n,t))return;e.uniform2iv(this.addr,t),Dt(n,t)}}function TM(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(Nt(n,t))return;e.uniform3iv(this.addr,t),Dt(n,t)}}function EM(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(Nt(n,t))return;e.uniform4iv(this.addr,t),Dt(n,t)}}function AM(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function RM(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(Nt(n,t))return;e.uniform2uiv(this.addr,t),Dt(n,t)}}function CM(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(Nt(n,t))return;e.uniform3uiv(this.addr,t),Dt(n,t)}}function PM(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(Nt(n,t))return;e.uniform4uiv(this.addr,t),Dt(n,t)}}function IM(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)mu.compareFunction=n.isReversedDepthBuffer()?aa:oa,s=mu;else s=fp;n.setTexture2D(t||s,r)}function LM(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||pp,r)}function NM(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||mp,r)}function DM(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||dp,r)}function OM(e){switch(e){case 5126:return gM;case 35664:return _M;case 35665:return xM;case 35666:return vM;case 35674:return yM;case 35675:return SM;case 35676:return bM;case 5124:case 35670:return MM;case 35667:case 35671:return wM;case 35668:case 35672:return TM;case 35669:case 35673:return EM;case 5125:return AM;case 36294:return RM;case 36295:return CM;case 36296:return PM;case 35678:case 36198:case 36298:case 36306:case 35682:return IM;case 35679:case 36299:case 36307:return LM;case 35680:case 36300:case 36308:case 36293:return NM;case 36289:case 36303:case 36311:case 36292:return DM}}function UM(e,t){e.uniform1fv(this.addr,t)}function FM(e,t){let n=cs(t,this.size,2);e.uniform2fv(this.addr,n)}function zM(e,t){let n=cs(t,this.size,3);e.uniform3fv(this.addr,n)}function kM(e,t){let n=cs(t,this.size,4);e.uniform4fv(this.addr,n)}function BM(e,t){let n=cs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function GM(e,t){let n=cs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function HM(e,t){let n=cs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function VM(e,t){e.uniform1iv(this.addr,t)}function WM(e,t){e.uniform2iv(this.addr,t)}function $M(e,t){e.uniform3iv(this.addr,t)}function ZM(e,t){e.uniform4iv(this.addr,t)}function XM(e,t){e.uniform1uiv(this.addr,t)}function qM(e,t){e.uniform2uiv(this.addr,t)}function YM(e,t){e.uniform3uiv(this.addr,t)}function jM(e,t){e.uniform4uiv(this.addr,t)}function KM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=mu;else o=fp;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function JM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||pp,s[o])}function QM(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||mp,s[o])}function ew(e,t,n){let i=this.cache,r=t.length,s=Pa(n,r);if(!Nt(i,s))e.uniform1iv(this.addr,s),Dt(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||dp,s[o])}function tw(e){switch(e){case 5126:return UM;case 35664:return FM;case 35665:return zM;case 35666:return kM;case 35674:return BM;case 35675:return GM;case 35676:return HM;case 5124:case 35670:return VM;case 35667:case 35671:return WM;case 35668:case 35672:return $M;case 35669:case 35673:return ZM;case 5125:return XM;case 36294:return qM;case 36295:return YM;case 36296:return jM;case 35678:case 36198:case 36298:case 36306:case 35682:return KM;case 35679:case 36299:case 36307:return JM;case 35680:case 36300:case 36308:case 36293:return QM;case 36289:case 36303:case 36311:case 36292:return ew}}class gp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=OM(t.type)}}class _p{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=tw(t.type)}}class xp{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 du=/(\w+)(\])?(\[|\.)?/g;function Jd(e,t){e.seq.push(t),e.map[t.id]=t}function nw(e,t,n){let i=e.name,r=i.length;du.lastIndex=0;while(!0){let s=du.exec(i),o=du.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Jd(n,l===void 0?new gp(a,e,t):new _p(a,e,t));break}else{let f=n.map[a];if(f===void 0)f=new xp(a),Jd(n,f);n=f}}}class Ys{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);nw(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 Qd(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var iw=37297,rw=0;function sw(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 Jd=new Fe;function iw(e){We._getMatrix(Jd,We.workingColorSpace,e);let t=`mat3( ${Jd.elements.map((n)=>n.toFixed(4))} )`;switch(We.getTransfer(e)){case zl:return[t,"LinearTransferOETF"];case ht:return[t,"sRGBTransferOETF"];default:return Re("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Qd(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 ep=new Fe;function ow(e){We._getMatrix(ep,We.workingColorSpace,e);let t=`mat3( ${ep.elements.map((n)=>n.toFixed(4))} )`;switch(We.getTransfer(e)){case zl:return[t,"LinearTransferOETF"];case ht:return[t,"sRGBTransferOETF"];default:return Re("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function tp(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+`
-`+nw(e.getShaderSource(t),a)}else return s}function rw(e,t){let n=iw(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var sw={[Xc]:"Linear",[qc]:"Reinhard",[Yc]:"Cineon",[As]:"ACESFilmic",[Kc]:"AgX",[Jc]:"Neutral",[jc]:"Custom"};function ow(e,t){let n=sw[t];if(n===void 0)return Re("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ra=new U;function aw(){We.getLuminanceCoefficients(Ra);let e=Ra.x.toFixed(4),t=Ra.y.toFixed(4),n=Ra.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function cw(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(qs).join(`
-`)}function lw(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 uw(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 qs(e){return e!==""}function ep(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 tp(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var hw=/^[ \t]*#include +<([\w\d./]+)>/gm;function gu(e){return e.replace(hw,dw)}var fw=new Map;function dw(e,t){let n=Ve[t];if(n===void 0){let i=fw.get(t);if(i!==void 0)n=Ve[i],Re('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return gu(n)}var pw=/#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 np(e){return e.replace(pw,mw)}function mw(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 ip(e){let t=`precision ${e.precision} float;
+`+sw(e.getShaderSource(t),a)}else return s}function aw(e,t){let n=ow(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var cw={[Xc]:"Linear",[qc]:"Reinhard",[Yc]:"Cineon",[As]:"ACESFilmic",[Kc]:"AgX",[Jc]:"Neutral",[jc]:"Custom"};function lw(e,t){let n=cw[t];if(n===void 0)return Re("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Ra=new U;function uw(){We.getLuminanceCoefficients(Ra);let e=Ra.x.toFixed(4),t=Ra.y.toFixed(4),n=Ra.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function hw(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(qs).join(`
+`)}function fw(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 dw(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 qs(e){return e!==""}function np(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_SUN_LIGHTS/g,t.numSunLights).replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,t.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function ip(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var pw=/^[ \t]*#include +<([\w\d./]+)>/gm;function gu(e){return e.replace(pw,gw)}var mw=new Map;function gw(e,t){let n=Ve[t];if(n===void 0){let i=mw.get(t);if(i!==void 0)n=Ve[i],Re('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return gu(n)}var _w=/#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 rp(e){return e.replace(_w,xw)}function xw(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 sp(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 gw={[Ts]:"SHADOWMAP_TYPE_PCF",[$r]:"SHADOWMAP_TYPE_VSM"};function _w(e){return gw[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var xw={[Xr]:"ENVMAP_TYPE_CUBE",[cr]:"ENVMAP_TYPE_CUBE",[Rs]:"ENVMAP_TYPE_CUBE_UV"};function vw(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return xw[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var yw={[cr]:"ENVMAP_MODE_REFRACTION"};function Sw(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return yw[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var bw={[hd]:"ENVMAP_BLENDING_MULTIPLY",[fd]:"ENVMAP_BLENDING_MIX",[dd]:"ENVMAP_BLENDING_ADD"};function Mw(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return bw[e.combine]||"ENVMAP_BLENDING_NONE"}function ww(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 Tw(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=_w(n),l=vw(n),u=Sw(n),f=Mw(n),h=ww(n),d=cw(n),g=lw(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
+#define LOW_PRECISION`;return t}var vw={[Ts]:"SHADOWMAP_TYPE_PCF",[$r]:"SHADOWMAP_TYPE_VSM"};function yw(e){return vw[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Sw={[Xr]:"ENVMAP_TYPE_CUBE",[cr]:"ENVMAP_TYPE_CUBE",[Rs]:"ENVMAP_TYPE_CUBE_UV"};function bw(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return Sw[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var Mw={[cr]:"ENVMAP_MODE_REFRACTION"};function ww(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return Mw[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Tw={[dd]:"ENVMAP_BLENDING_MULTIPLY",[pd]:"ENVMAP_BLENDING_MIX",[md]:"ENVMAP_BLENDING_ADD"};function Ew(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return Tw[e.combine]||"ENVMAP_BLENDING_NONE"}function Aw(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 Rw(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=yw(n),l=bw(n),u=ww(n),f=Ew(n),h=Aw(n),d=hw(n),g=fw(s),x=r.createProgram(),p,m,E=n.glslVersion?"#version "+n.glslVersion+`
`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(qs).join(`
`),p.length>0)p+=`
`;if(m=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(qs).join(`
`),m.length>0)m+=`
-`}else p=[ip(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
+`}else p=[sp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
`].filter(qs).join(`
-`),m=[ip(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Dn?"#define TONE_MAPPING":"",n.toneMapping!==Dn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Dn?ow("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,rw("linearToOutputTexel",n.outputColorSpace),aw(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`),m=[sp(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Dn?"#define TONE_MAPPING":"",n.toneMapping!==Dn?Ve.tonemapping_pars_fragment:"",n.toneMapping!==Dn?lw("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,aw("linearToOutputTexel",n.outputColorSpace),uw(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(qs).join(`
-`);if(o=gu(o),o=ep(o,n),o=tp(o,n),a=gu(a),a=ep(a,n),a=tp(a,n),o=np(o),a=np(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
+`);if(o=gu(o),o=np(o,n),o=ip(o,n),a=gu(a),a=np(a,n),a=ip(a,n),o=rp(o),a=rp(a),n.isRawShaderMaterial!==!0)E=`#version 300 es
`,p=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+p,m=["#define varying in",n.glslVersion===kl?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===kl?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+m;let R=E+p+o,S=E+m+a,b=Kd(r,r.VERTEX_SHADER,R),T=Kd(r,r.FRAGMENT_SHADER,S);if(r.attachShader(x,b),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(P){if(e.debug.checkShaderErrors){let O=r.getProgramInfoLog(x)||"",K=r.getShaderInfoLog(b)||"",C=r.getShaderInfoLog(T)||"",G=O.trim(),X=K.trim(),z=C.trim(),te=!0,H=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(te=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,b,T);else{let Q=Qd(r,b,"vertex"),ee=Qd(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
+`+m;let R=E+p+o,S=E+m+a,b=Qd(r,r.VERTEX_SHADER,R),T=Qd(r,r.FRAGMENT_SHADER,S);if(r.attachShader(x,b),r.attachShader(x,T),n.index0AttributeName!==void 0)r.bindAttribLocation(x,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(x,0,"position");r.linkProgram(x);function A(P){if(e.debug.checkShaderErrors){let O=r.getProgramInfoLog(x)||"",K=r.getShaderInfoLog(b)||"",C=r.getShaderInfoLog(T)||"",G=O.trim(),X=K.trim(),z=C.trim(),te=!0,H=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(te=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,x,b,T);else{let Q=tp(r,b,"vertex"),ee=tp(r,T,"fragment");Ue("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
Material Name: `+P.name+`
Material Type: `+P.type+`
Program Info Log: `+G+`
`+Q+`
-`+ee)}else if(G!=="")Re("WebGLProgram: Program Info Log:",G);else if(X===""||z==="")H=!1;if(H)P.diagnostics={runnable:te,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(b),r.deleteShader(T),_=new Ys(r,x),M=uw(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let F=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(F===!1)F=r.getProgramParameter(x,ew);return F},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=tw++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=T,this}var Ew=0;class _p{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 xp(e),t.set(e,n);return n}}class xp{constructor(e){this.id=Ew++,this.code=e,this.usedTimes=0}}function Aw(e){return e===fr||e===ia||e===ra}function Rw(e,t,n,i,r,s){let o=new la,a=new _p,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,M,F,P,O,K){let C=P.fog,G=O.geometry,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,te=t.get(_.envMap||X,z),H=!!te&&te.mapping===Rs?te.image.height:null,Q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Re("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Te=ee!==void 0?ee.length:0,ve=0;if(G.morphAttributes.position!==void 0)ve=1;if(G.morphAttributes.normal!==void 0)ve=2;if(G.morphAttributes.color!==void 0)ve=3;let Ge,Me,Z,re;if(Q){let ft=ei[Q];Ge=ft.vertexShader,Me=ft.fragmentShader}else{Ge=_.vertexShader,Me=_.fragmentShader;let ft=a.getVertexShaderStage(_),nt=a.getFragmentShaderStage(_);a.update(_,ft,nt),Z=ft.id,re=nt.id}let se=e.getRenderTarget(),Pe=e.state.buffers.depth.getReversed(),Ie=O.isInstancedMesh===!0,we=O.isBatchedMesh===!0,mt=!!_.map,ze=!!_.matcap,Ze=!!te,rt=!!_.aoMap,je=!!_.lightMap,Gt=!!_.bumpMap&&_.wireframe===!1,gt=!!_.normalMap,nn=!!_.displacementMap,Pt=!!_.emissiveMap,It=!!_.metalnessMap,L=!!_.roughnessMap,rn=_.anisotropy>0,tt=_.clearcoat>0,yt=_.dispersion>0,w=_.retroreflectivity>0,v=_.iridescence>0,I=_.sheen>0,V=_.transmission>0,ie=rn&&!!_.anisotropyMap,ae=tt&&!!_.clearcoatMap,ue=tt&&!!_.clearcoatNormalMap,q=tt&&!!_.clearcoatRoughnessMap,J=v&&!!_.iridescenceMap,ge=v&&!!_.iridescenceThicknessMap,Ae=I&&!!_.sheenColorMap,he=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Je=V&&!!_.transmissionMap,D=V&&!!_.thicknessMap,ce=!!_.gradientMap,Y=!!_.alphaMap,le=_.alphaTest>0,_e=!!_.alphaHash,ne=!!_.extensions,de=Dn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)de=e.toneMapping}let ke={shaderID:Q,shaderType:_.type,shaderName:_.name,vertexShader:Ge,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:we,batchingColor:we&&O._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&O.instanceColor!==null,instancingMorph:Ie&&O.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:We.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:mt,matcap:ze,envMap:Ze,envMapMode:Ze&&te.mapping,envMapCubeUVHeight:H,aoMap:rt,lightMap:je,bumpMap:Gt,normalMap:gt,displacementMap:nn,emissiveMap:Pt,normalMapObjectSpace:gt&&_.normalMapType===Sd,normalMapTangentSpace:gt&&_.normalMapType===Fl,packedNormalMap:gt&&_.normalMapType===Fl&&Aw(_.normalMap.format),metalnessMap:It,roughnessMap:L,anisotropy:rn,anisotropyMap:ie,clearcoat:tt,clearcoatMap:ae,clearcoatNormalMap:ue,clearcoatRoughnessMap:q,dispersion:yt,retroreflection:w,iridescence:v,iridescenceMap:J,iridescenceThicknessMap:ge,sheen:I,sheenColorMap:Ae,sheenRoughnessMap:he,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Je,thicknessMap:D,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Es&&_.alphaToCoverage===!1,alphaMap:Y,alphaTest:le,alphaHash:_e,combine:_.combine,mapUv:mt&&g(_.map.channel),aoMapUv:rt&&g(_.aoMap.channel),lightMapUv:je&&g(_.lightMap.channel),bumpMapUv:Gt&&g(_.bumpMap.channel),normalMapUv:gt&&g(_.normalMap.channel),displacementMapUv:nn&&g(_.displacementMap.channel),emissiveMapUv:Pt&&g(_.emissiveMap.channel),metalnessMapUv:It&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ue&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:q&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:he&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Je&&g(_.transmissionMap.channel),thicknessMapUv:D&&g(_.thicknessMap.channel),alphaMapUv:Y&&g(_.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(gt||rn),vertexNormals:!!G.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!G.attributes.uv&&(mt||Y),fog:!!C,useFog:_.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||G.attributes.normal===void 0&&gt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Pe,skinning:O.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:Te,morphTextureStride:ve,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:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:de,decodeVideoTexture:mt&&_.map.isVideoTexture===!0&&We.getTransfer(_.map.colorSpace)===ht,decodeVideoTextureEmissive:Pt&&_.emissiveMap.isVideoTexture===!0&&We.getTransfer(_.emissiveMap.colorSpace)===ht,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===wn,flipSided:_.side===Xt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||we)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return ke.vertexUv1s=c.has(1),ke.vertexUv2s=c.has(2),ke.vertexUv3s=c.has(3),c.clear(),ke}function p(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let F in _.defines)M.push(F),M.push(_.defines[F]);if(_.isRawShaderMaterial===!1)m(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function m(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,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(_.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);_.push(o.mask)}function R(_){let M=d[_.type],F;if(M){let P=ei[M];F=Nd.clone(P.uniforms)}else F=_.uniforms;return F}function S(_,M){let F=u.get(M);if(F!==void 0)++F.usedTimes;else F=new Tw(e,M,_,r),l.push(F),u.set(M,F);return F}function b(_){if(--_.usedTimes===0){let M=l.indexOf(_);l[M]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:S,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:A}}function Cw(){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 Pw(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 rp(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 sp(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||Pw);if(i.length>1)i.sort(d||rp);if(r.length>1)r.sort(d||rp)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function Iw(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new sp,e.set(i,[o]);else if(r>=s.length)o=new sp,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function Lw(){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 Oe};break;case"SpotLight":n={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function Nw(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var Dw=0;function Ow(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Uw(e){let t=new Lw,n=Nw(),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 Be,o=new Be;function a(l){let u=0,f=0,h=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,S=0,b=0,T=0,A=0,_=0,M=0,F=0;l.sort(Ow);for(let O=0,K=l.length;O<K;O++){let C=l[O],{color:G,intensity:X,distance:z}=C,te=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===fr)te=C.shadow.map.texture;else te=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=G.r*X,f+=G.g*X,h+=G.b*X;else if(C.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(C.sh.coefficients[H],X);F++}else if(C.isSunLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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[g]=ee,i.sunShadowMap[g]=te;let Te=Q.getViewportCount();for(let ve=0;ve<Te;ve++)i.sunShadowMatrix[x+ve]=Q.getMatrix(ve),i.sunShadowCascade[x+ve]=Q._cascadeData[ve];x+=Te,g++}i.sun[d]=H,d++}else if(C.isDirectionalLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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]=te,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=H,p++}else if(C.isSpotLight){let H=t.get(C);H.position.setFromMatrixPosition(C.matrixWorld),H.color.copy(G).multiplyScalar(X),H.distance=z,H.coneCos=Math.cos(C.angle),H.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),H.decay=C.decay,i.spot[E]=H;let Q=C.shadow;if(C.map){if(i.spotLightMap[_]=C.map,_++,Q.updateMatrices(C),C.castShadow)M++}if(i.spotLightMatrix[E]=Q.matrix,C.castShadow){let ee=n.get(C);ee.shadowIntensity=Q.intensity,ee.shadowBias=Q.bias,ee.shadowNormalBias=Q.normalBias,ee.shadowRadius=Q.radius,ee.shadowMapSize=Q.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=te,A++}E++}else if(C.isRectAreaLight){let H=t.get(C);H.color.copy(G).multiplyScalar(X),H.halfWidth.set(C.width*0.5,0,0),H.halfHeight.set(0,C.height*0.5,0),i.rectArea[R]=H,R++}else if(C.isPointLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),H.distance=C.distance,H.decay=C.decay,C.castShadow){let Q=C.shadow,ee=n.get(C);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[m]=ee,i.pointShadowMap[m]=te,i.pointShadowMatrix[m]=C.shadow.matrix,T++}i.point[m]=H,m++}else if(C.isHemisphereLight){let H=t.get(C);H.skyColor.copy(C.color).multiplyScalar(X),H.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[S]=H,S++}}if(R>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]=f,i.ambient[2]=h;let P=i.hash;if(P.sunLength!==d||P.directionalLength!==p||P.pointLength!==m||P.spotLength!==E||P.rectAreaLength!==R||P.hemiLength!==S||P.numSunShadows!==g||P.numDirectionalShadows!==b||P.numPointShadows!==T||P.numSpotShadows!==A||P.numSpotMaps!==_||P.numLightProbes!==F)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=S,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=F,P.sunLength=d,P.directionalLength=p,P.pointLength=m,P.spotLength=E,P.rectAreaLength=R,P.hemiLength=S,P.numSunShadows=g,P.numDirectionalShadows=b,P.numPointShadows=T,P.numSpotShadows=A,P.numSpotMaps=_,P.numLightProbes=F,i.version=Dw++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let S=l[E];if(S.isSunLight){let b=i.sun[f];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),f++}else if(S.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),h++}else if(S.isSpotLight){let b=i.spot[g];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),g++}else if(S.isRectAreaLight){let b=i.rectArea[x];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),o.identity(),s.copy(S.matrixWorld),s.premultiply(m),o.extractRotation(s),b.halfWidth.set(S.width*0.5,0,0),b.halfHeight.set(0,S.height*0.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let b=i.point[d];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),d++}else if(S.isHemisphereLight){let b=i.hemi[p];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function op(e){let t=new Uw(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function Fw(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new op(e),t.set(r,[a]);else if(s>=o.length)a=new op(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var zw=`void main() {
+`+ee)}else if(G!=="")Re("WebGLProgram: Program Info Log:",G);else if(X===""||z==="")H=!1;if(H)P.diagnostics={runnable:te,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:z,prefix:m}}}r.deleteShader(b),r.deleteShader(T),_=new Ys(r,x),M=dw(r,x)}let _;this.getUniforms=function(){if(_===void 0)A(this);return _};let M;this.getAttributes=function(){if(M===void 0)A(this);return M};let F=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(F===!1)F=r.getProgramParameter(x,iw);return F},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=rw++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=T,this}var Cw=0;class vp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let i=this._getShaderCacheForMaterial(e);if(i.has(t)===!1)i.add(t),t.usedTimes++;if(i.has(n)===!1)i.add(n),n.usedTimes++;return this}remove(e){let t=this.materialCache.get(e);for(let n of t)if(n.usedTimes--,n.usedTimes===0)this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);if(n===void 0)n=new Set,t.set(e,n);return n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);if(n===void 0)n=new yp(e),t.set(e,n);return n}}class yp{constructor(e){this.id=Cw++,this.code=e,this.usedTimes=0}}function Pw(e){return e===fr||e===ia||e===ra}function Iw(e,t,n,i,r,s){let o=new la,a=new vp,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:f,precision:h}=i,d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){if(c.add(_),_===0)return"uv";return`uv${_}`}function x(_,M,F,P,O,K){let C=P.fog,G=O.geometry,X=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,te=t.get(_.envMap||X,z),H=!!te&&te.mapping===Rs?te.image.height:null,Q=d[_.type];if(_.precision!==null){if(h=i.getMaxPrecision(_.precision),h!==_.precision)Re("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead.")}let ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Te=ee!==void 0?ee.length:0,ve=0;if(G.morphAttributes.position!==void 0)ve=1;if(G.morphAttributes.normal!==void 0)ve=2;if(G.morphAttributes.color!==void 0)ve=3;let Ge,Me,Z,re;if(Q){let ft=ei[Q];Ge=ft.vertexShader,Me=ft.fragmentShader}else{Ge=_.vertexShader,Me=_.fragmentShader;let ft=a.getVertexShaderStage(_),nt=a.getFragmentShaderStage(_);a.update(_,ft,nt),Z=ft.id,re=nt.id}let se=e.getRenderTarget(),Pe=e.state.buffers.depth.getReversed(),Ie=O.isInstancedMesh===!0,we=O.isBatchedMesh===!0,mt=!!_.map,ze=!!_.matcap,Ze=!!te,rt=!!_.aoMap,je=!!_.lightMap,Gt=!!_.bumpMap&&_.wireframe===!1,gt=!!_.normalMap,nn=!!_.displacementMap,Pt=!!_.emissiveMap,It=!!_.metalnessMap,L=!!_.roughnessMap,rn=_.anisotropy>0,tt=_.clearcoat>0,yt=_.dispersion>0,w=_.retroreflectivity>0,v=_.iridescence>0,I=_.sheen>0,V=_.transmission>0,ie=rn&&!!_.anisotropyMap,ae=tt&&!!_.clearcoatMap,ue=tt&&!!_.clearcoatNormalMap,q=tt&&!!_.clearcoatRoughnessMap,J=v&&!!_.iridescenceMap,ge=v&&!!_.iridescenceThicknessMap,Ae=I&&!!_.sheenColorMap,he=I&&!!_.sheenRoughnessMap,oe=!!_.specularMap,Le=!!_.specularColorMap,De=!!_.specularIntensityMap,Je=V&&!!_.transmissionMap,D=V&&!!_.thicknessMap,ce=!!_.gradientMap,Y=!!_.alphaMap,le=_.alphaTest>0,_e=!!_.alphaHash,ne=!!_.extensions,de=Dn;if(_.toneMapped){if(se===null||se.isXRRenderTarget===!0)de=e.toneMapping}let ke={shaderID:Q,shaderType:_.type,shaderName:_.name,vertexShader:Ge,fragmentShader:Me,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:we,batchingColor:we&&O._colorsTexture!==null,instancing:Ie,instancingColor:Ie&&O.instanceColor!==null,instancingMorph:Ie&&O.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:We.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:mt,matcap:ze,envMap:Ze,envMapMode:Ze&&te.mapping,envMapCubeUVHeight:H,aoMap:rt,lightMap:je,bumpMap:Gt,normalMap:gt,displacementMap:nn,emissiveMap:Pt,normalMapObjectSpace:gt&&_.normalMapType===Md,normalMapTangentSpace:gt&&_.normalMapType===Fl,packedNormalMap:gt&&_.normalMapType===Fl&&Pw(_.normalMap.format),metalnessMap:It,roughnessMap:L,anisotropy:rn,anisotropyMap:ie,clearcoat:tt,clearcoatMap:ae,clearcoatNormalMap:ue,clearcoatRoughnessMap:q,dispersion:yt,retroreflection:w,iridescence:v,iridescenceMap:J,iridescenceThicknessMap:ge,sheen:I,sheenColorMap:Ae,sheenRoughnessMap:he,specularMap:oe,specularColorMap:Le,specularIntensityMap:De,transmission:V,transmissionMap:Je,thicknessMap:D,gradientMap:ce,opaque:_.transparent===!1&&_.blending===Es&&_.alphaToCoverage===!1,alphaMap:Y,alphaTest:le,alphaHash:_e,combine:_.combine,mapUv:mt&&g(_.map.channel),aoMapUv:rt&&g(_.aoMap.channel),lightMapUv:je&&g(_.lightMap.channel),bumpMapUv:Gt&&g(_.bumpMap.channel),normalMapUv:gt&&g(_.normalMap.channel),displacementMapUv:nn&&g(_.displacementMap.channel),emissiveMapUv:Pt&&g(_.emissiveMap.channel),metalnessMapUv:It&&g(_.metalnessMap.channel),roughnessMapUv:L&&g(_.roughnessMap.channel),anisotropyMapUv:ie&&g(_.anisotropyMap.channel),clearcoatMapUv:ae&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ue&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:q&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:J&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:ge&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:Ae&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:he&&g(_.sheenRoughnessMap.channel),specularMapUv:oe&&g(_.specularMap.channel),specularColorMapUv:Le&&g(_.specularColorMap.channel),specularIntensityMapUv:De&&g(_.specularIntensityMap.channel),transmissionMapUv:Je&&g(_.transmissionMap.channel),thicknessMapUv:D&&g(_.thicknessMap.channel),alphaMapUv:Y&&g(_.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(gt||rn),vertexNormals:!!G.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!G.attributes.uv&&(mt||Y),fog:!!C,useFog:_.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||G.attributes.normal===void 0&&gt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Pe,skinning:O.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:Te,morphTextureStride:ve,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:_.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:de,decodeVideoTexture:mt&&_.map.isVideoTexture===!0&&We.getTransfer(_.map.colorSpace)===ht,decodeVideoTextureEmissive:Pt&&_.emissiveMap.isVideoTexture===!0&&We.getTransfer(_.emissiveMap.colorSpace)===ht,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===wn,flipSided:_.side===Xt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:ne&&_.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&_.extensions.multiDraw===!0||we)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return ke.vertexUv1s=c.has(1),ke.vertexUv2s=c.has(2),ke.vertexUv3s=c.has(3),c.clear(),ke}function p(_){let M=[];if(_.shaderID)M.push(_.shaderID);else M.push(_.customVertexShaderID),M.push(_.customFragmentShaderID);if(_.defines!==void 0)for(let F in _.defines)M.push(F),M.push(_.defines[F]);if(_.isRawShaderMaterial===!1)m(M,_),E(M,_),M.push(e.outputColorSpace);return M.push(_.customProgramCacheKey),M.join()}function m(_,M){_.push(M.precision),_.push(M.outputColorSpace),_.push(M.envMapMode),_.push(M.envMapCubeUVHeight),_.push(M.mapUv),_.push(M.alphaMapUv),_.push(M.lightMapUv),_.push(M.aoMapUv),_.push(M.bumpMapUv),_.push(M.normalMapUv),_.push(M.displacementMapUv),_.push(M.emissiveMapUv),_.push(M.metalnessMapUv),_.push(M.roughnessMapUv),_.push(M.anisotropyMapUv),_.push(M.clearcoatMapUv),_.push(M.clearcoatNormalMapUv),_.push(M.clearcoatRoughnessMapUv),_.push(M.iridescenceMapUv),_.push(M.iridescenceThicknessMapUv),_.push(M.sheenColorMapUv),_.push(M.sheenRoughnessMapUv),_.push(M.specularMapUv),_.push(M.specularColorMapUv),_.push(M.specularIntensityMapUv),_.push(M.transmissionMapUv),_.push(M.thicknessMapUv),_.push(M.combine),_.push(M.fogExp2),_.push(M.sizeAttenuation),_.push(M.morphTargetsCount),_.push(M.morphAttributeCount),_.push(M.numSunLights),_.push(M.numDirLights),_.push(M.numPointLights),_.push(M.numSpotLights),_.push(M.numSpotLightMaps),_.push(M.numHemiLights),_.push(M.numRectAreaLights),_.push(M.numSunLightShadows),_.push(M.numDirLightShadows),_.push(M.numPointLightShadows),_.push(M.numSpotLightShadows),_.push(M.numSpotLightShadowsWithMaps),_.push(M.numLightProbes),_.push(M.shadowMapType),_.push(M.toneMapping),_.push(M.numClippingPlanes),_.push(M.numClipIntersection),_.push(M.depthPacking)}function E(_,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(_.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);_.push(o.mask)}function R(_){let M=d[_.type],F;if(M){let P=ei[M];F=Od.clone(P.uniforms)}else F=_.uniforms;return F}function S(_,M){let F=u.get(M);if(F!==void 0)++F.usedTimes;else F=new Rw(e,M,_,r),l.push(F),u.set(M,F);return F}function b(_){if(--_.usedTimes===0){let M=l.indexOf(_);l[M]=l[l.length-1],l.pop(),u.delete(_.cacheKey),_.destroy()}}function T(_){a.remove(_)}function A(){a.dispose()}return{getParameters:x,getProgramCacheKey:p,getUniforms:R,acquireProgram:S,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:A}}function Lw(){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 Nw(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 op(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 ap(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let d=0;if(h.isInstancedMesh)d+=2;if(h.isSkinnedMesh)d+=1;return d}function a(h,d,g,x,p,m){let E=e[t];if(E===void 0)E={id:h.id,object:h,geometry:d,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:p,group:m},e[t]=E;else E.id=h.id,E.object=h,E.geometry=d,E.material=g,E.materialVariant=o(h),E.groupOrder=x,E.renderOrder=h.renderOrder,E.z=p,E.group=m;return t++,E}function c(h,d,g,x,p,m,E){if(E.reversedDepth===!0)p=-p;let R=a(h,d,g,x,p,m);if(g.transmission>0)i.push(R);else if(g.transparent===!0)r.push(R);else n.push(R)}function l(h,d,g,x,p,m){let E=a(h,d,g,x,p,m);if(g.transmission>0)i.unshift(E);else if(g.transparent===!0)r.unshift(E);else n.unshift(E)}function u(h,d){if(n.length>1)n.sort(h||Nw);if(i.length>1)i.sort(d||op);if(r.length>1)r.sort(d||op)}function f(){for(let h=t,d=e.length;h<d;h++){let g=e[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:f,sort:u}}function Dw(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new ap,e.set(i,[o]);else if(r>=s.length)o=new ap,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ow(){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 Oe};break;case"SpotLight":n={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":n={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function Uw(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ne,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var Fw=0;function zw(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function kw(e){let t=new Ow,n=Uw(),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 Be,o=new Be;function a(l){let u=0,f=0,h=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let d=0,g=0,x=0,p=0,m=0,E=0,R=0,S=0,b=0,T=0,A=0,_=0,M=0,F=0;l.sort(zw);for(let O=0,K=l.length;O<K;O++){let C=l[O],{color:G,intensity:X,distance:z}=C,te=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===fr)te=C.shadow.map.texture;else te=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=G.r*X,f+=G.g*X,h+=G.b*X;else if(C.isLightProbe){for(let H=0;H<9;H++)i.probe[H].addScaledVector(C.sh.coefficients[H],X);F++}else if(C.isSunLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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[g]=ee,i.sunShadowMap[g]=te;let Te=Q.getViewportCount();for(let ve=0;ve<Te;ve++)i.sunShadowMatrix[x+ve]=Q.getMatrix(ve),i.sunShadowCascade[x+ve]=Q._cascadeData[ve];x+=Te,g++}i.sun[d]=H,d++}else if(C.isDirectionalLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let Q=C.shadow,ee=n.get(C);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]=te,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=H,p++}else if(C.isSpotLight){let H=t.get(C);H.position.setFromMatrixPosition(C.matrixWorld),H.color.copy(G).multiplyScalar(X),H.distance=z,H.coneCos=Math.cos(C.angle),H.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),H.decay=C.decay,i.spot[E]=H;let Q=C.shadow;if(C.map){if(i.spotLightMap[_]=C.map,_++,Q.updateMatrices(C),C.castShadow)M++}if(i.spotLightMatrix[E]=Q.matrix,C.castShadow){let ee=n.get(C);ee.shadowIntensity=Q.intensity,ee.shadowBias=Q.bias,ee.shadowNormalBias=Q.normalBias,ee.shadowRadius=Q.radius,ee.shadowMapSize=Q.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=te,A++}E++}else if(C.isRectAreaLight){let H=t.get(C);H.color.copy(G).multiplyScalar(X),H.halfWidth.set(C.width*0.5,0,0),H.halfHeight.set(0,C.height*0.5,0),i.rectArea[R]=H,R++}else if(C.isPointLight){let H=t.get(C);if(H.color.copy(C.color).multiplyScalar(C.intensity),H.distance=C.distance,H.decay=C.decay,C.castShadow){let Q=C.shadow,ee=n.get(C);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[m]=ee,i.pointShadowMap[m]=te,i.pointShadowMatrix[m]=C.shadow.matrix,T++}i.point[m]=H,m++}else if(C.isHemisphereLight){let H=t.get(C);H.skyColor.copy(C.color).multiplyScalar(X),H.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[S]=H,S++}}if(R>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]=f,i.ambient[2]=h;let P=i.hash;if(P.sunLength!==d||P.directionalLength!==p||P.pointLength!==m||P.spotLength!==E||P.rectAreaLength!==R||P.hemiLength!==S||P.numSunShadows!==g||P.numDirectionalShadows!==b||P.numPointShadows!==T||P.numSpotShadows!==A||P.numSpotMaps!==_||P.numLightProbes!==F)i.sun.length=d,i.directional.length=p,i.spot.length=E,i.rectArea.length=R,i.point.length=m,i.hemi.length=S,i.sunShadow.length=g,i.sunShadowMap.length=g,i.sunShadowMatrix.length=x,i.sunShadowCascade.length=x,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.directionalShadowMatrix.length=b,i.pointShadow.length=T,i.pointShadowMap.length=T,i.pointShadowMatrix.length=T,i.spotShadow.length=A,i.spotShadowMap.length=A,i.spotLightMatrix.length=A+_-M,i.spotLightMap.length=_,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=F,P.sunLength=d,P.directionalLength=p,P.pointLength=m,P.spotLength=E,P.rectAreaLength=R,P.hemiLength=S,P.numSunShadows=g,P.numDirectionalShadows=b,P.numPointShadows=T,P.numSpotShadows=A,P.numSpotMaps=_,P.numLightProbes=F,i.version=Fw++}function c(l,u){let f=0,h=0,d=0,g=0,x=0,p=0,m=u.matrixWorldInverse;for(let E=0,R=l.length;E<R;E++){let S=l[E];if(S.isSunLight){let b=i.sun[f];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),f++}else if(S.isDirectionalLight){let b=i.directional[h];b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),h++}else if(S.isSpotLight){let b=i.spot[g];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),b.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(m),g++}else if(S.isRectAreaLight){let b=i.rectArea[x];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),o.identity(),s.copy(S.matrixWorld),s.premultiply(m),o.extractRotation(s),b.halfWidth.set(S.width*0.5,0,0),b.halfHeight.set(0,S.height*0.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let b=i.point[d];b.position.setFromMatrixPosition(S.matrixWorld),b.position.applyMatrix4(m),d++}else if(S.isHemisphereLight){let b=i.hemi[p];b.direction.setFromMatrixPosition(S.matrixWorld),b.direction.transformDirection(m),p++}}}return{setup:a,setupView:c,state:i}}function cp(e){let t=new kw(e),n=[],i=[],r=[];function s(h){f.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let f={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function Bw(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new cp(e),t.set(r,[a]);else if(s>=o.length)a=new cp(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var Gw=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,kw=`uniform sampler2D shadow_pass;
+}`,Hw=`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 );
-}`,Bw=[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)],Gw=[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)],ap=new Be,Xs=new U,pu=new U;function Hw(e,t,n){let i=new zs,r=new Ne,s=new Ne,o=new ot,a=new ql,c=new Yl,l={},u=n.maxTextureSize,f={[zi]:Xt,[Xt]:zi,[wn]:wn},h=new Tn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:zw,fragmentShader:kw}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new qt;g.setAttribute("position",new zt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new pt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ts;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===Ff)Re("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ts;let M=e.getRenderTarget(),F=e.getActiveCubeFace(),P=e.getActiveMipmapLevel(),O=e.state;if(O.setBlending(qn),O.buffers.depth.getReversed()===!0)O.buffers.color.setClear(0,0,0,0);else O.buffers.color.setClear(1,1,1,1);O.buffers.depth.setTest(!0),O.setScissorTest(!1);let K=m!==this.type;if(K)A.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((G)=>G.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,G=T.length;C<G;C++){let X=T[C],z=X.shadow;if(z===void 0){Re("WebGLShadowMap:",X,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let te=z.getFrameExtents();if(r.multiply(te),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/te.x),r.x=s.x*te.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/te.y),r.y=s.y*te.y,z.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=H,z.map===null||K===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===$r){if(X.isPointLight){Re("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new fn(r.x,r.y,{format:fr,type:jn,minFilter:kt,magFilter:kt,generateMipmaps:!1}),z.map.texture.name=X.name+".shadowMap",z.map.depthTexture=new pr(r.x,r.y,xi),z.map.depthTexture.name=X.name+".shadowMapDepth",z.map.depthTexture.format=ur,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=On,z.map.depthTexture.magFilter=On}else{if(X.isPointLight)z.map=new _u(r.x),z.map.depthTexture=new $l(r.x,ki);else z.map=new fn(r.x,r.y),z.map.depthTexture=new pr(r.x,r.y,ki);if(z.map.depthTexture.name=X.name+".shadowMap",z.map.depthTexture.format=ur,this.type===Ts)z.map.depthTexture.compareFunction=H?aa:oa,z.map.depthTexture.minFilter=kt,z.map.depthTexture.magFilter=kt;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=On,z.map.depthTexture.magFilter=On}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let Q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(X.isPointLight!==!0)z.updateMatrices(X,_);for(let ee=0;ee<Q;ee++){let Te=z.getCamera(ee);if(X.isPointLight){let{camera:ve,matrix:Ge}=z,Me=X.distance||ve.far;if(Me!==ve.far)ve.far=Me,ve.updateProjectionMatrix();Xs.setFromMatrixPosition(X.matrixWorld),ve.position.copy(Xs),pu.copy(ve.position),pu.add(Bw[ee]),ve.up.copy(Gw[ee]),ve.lookAt(pu),ve.updateMatrixWorld(),Ge.makeTranslation(-Xs.x,-Xs.y,-Xs.z),ap.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),z._frustum.setFromProjectionMatrix(ap,ve.coordinateSystem,ve.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(z.map),e.clear();let ve=z.getViewport(ee);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),O.viewport(o)}i=z.getFrustum(ee),S(A,_,Te,X,this.type)}if(z.isPointLightShadow!==!0&&this.type===$r)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(M,F,P)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new fn(r.x,r.y,{format:fr,type:jn});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,M){let F=null,P=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)F=P;else if(F=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let O=F.uuid,K=A.uuid,C=l[O];if(C===void 0)C={},l[O]=C;let G=C[K];if(G===void 0)G=F.clone(),C[K]=G,A.addEventListener("dispose",b);F=G}if(F.visible=A.visible,F.wireframe=A.wireframe,M===$r)F.side=A.shadowSide!==null?A.shadowSide:A.side;else F.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(F.alphaMap=A.alphaMap,F.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,F.map=A.map,F.clipShadows=A.clipShadows,F.clippingPlanes=A.clippingPlanes,F.clipIntersection=A.clipIntersection,F.displacementMap=A.displacementMap,F.displacementScale=A.displacementScale,F.displacementBias=A.displacementBias,F.wireframeLinewidth=A.wireframeLinewidth,F.linewidth=A.linewidth,_.isPointLight===!0&&F.isMeshDistanceMaterial===!0){let O=e.properties.get(F);O.light=_}return F}function S(T,A,_,M,F){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&F===$r)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let K=t.update(T),C=T.material;if(Array.isArray(C)){let G=K.groups;for(let X=0,z=G.length;X<z;X++){let te=G[X],H=C[te.materialIndex];if(H&&H.visible){let Q=R(T,H,M,F);T.onBeforeShadow(e,T,A,_,K,Q,te),e.renderBufferDirect(_,null,K,Q,T,te),T.onAfterShadow(e,T,A,_,K,Q,te)}}}else if(C.visible){let G=R(T,C,M,F);T.onBeforeShadow(e,T,A,_,K,G,null),e.renderBufferDirect(_,null,K,G,T,null),T.onAfterShadow(e,T,A,_,K,G,null)}}}let O=T.children;for(let K=0,C=O.length;K<C;K++)S(O[K],A,_,M,F)}function b(T){T.target.removeEventListener("dispose",b);for(let _ in l){let M=l[_],F=T.target.uuid;if(F in M)M[F].dispose(),delete M[F]}}}function Vw(e,t){function n(){let D=!1,ce=new ot,Y=null,le=new ot(0,0,0,0);return{setMask:function(_e){if(Y!==_e&&!D)e.colorMask(_e,_e,_e,_e),Y=_e},setLocked:function(_e){D=_e},setClear:function(_e,ne,de,ke,ft){if(ft===!0)_e*=ke,ne*=ke,de*=ke;if(ce.set(_e,ne,de,ke),le.equals(ce)===!1)e.clearColor(_e,ne,de,ke),le.copy(ce)},reset:function(){D=!1,Y=null,le.set(-1,0,0,0)}}}function i(){let D=!1,ce=!1,Y=null,le=null,_e=null;return{setReversed:function(ne){if(ce!==ne){let de=t.get("EXT_clip_control");if(ne)de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT);else de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let ke=_e;_e=null,this.setClear(ke)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Pe(e.DEPTH_TEST)},setMask:function(ne){if(Y!==ne&&!D)e.depthMask(ne),Y=ne},setFunc:function(ne){if(ce)ne=Id[ne];if(le!==ne){switch(ne){case rd:e.depthFunc(e.NEVER);break;case sd:e.depthFunc(e.ALWAYS);break;case od:e.depthFunc(e.LESS);break;case Zc:e.depthFunc(e.LEQUAL);break;case ad:e.depthFunc(e.EQUAL);break;case cd:e.depthFunc(e.GEQUAL);break;case ld:e.depthFunc(e.GREATER);break;case ud:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){D=ne},setClear:function(ne){if(_e!==ne){if(_e=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){D=!1,Y=null,le=null,_e=null,ce=!1}}}function r(){let D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,ke=null,ft=null;return{setTest:function(nt){if(!D)if(nt)se(e.STENCIL_TEST);else Pe(e.STENCIL_TEST)},setMask:function(nt){if(ce!==nt&&!D)e.stencilMask(nt),ce=nt},setFunc:function(nt,Hn,ui){if(Y!==nt||le!==Hn||_e!==ui)e.stencilFunc(nt,Hn,ui),Y=nt,le=Hn,_e=ui},setOp:function(nt,Hn,ui){if(ne!==nt||de!==Hn||ke!==ui)e.stencilOp(nt,Hn,ui),ne=nt,de=Hn,ke=ui},setLocked:function(nt){D=nt},setClear:function(nt){if(ft!==nt)e.clearStencil(nt),ft=nt},reset:function(){D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,ke=null,ft=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,P=null,O=null,K=null,C=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)te=parseFloat(/^WebGL (\d)/.exec(H)[1]),z=te>=1;else if(H.indexOf("OpenGL ES")!==-1)te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),z=te>=2;let Q=null,ee={},Te=e.getParameter(e.SCISSOR_BOX),ve=e.getParameter(e.VIEWPORT),Ge=new ot().fromArray(Te),Me=new ot().fromArray(ve);function Z(D,ce,Y,le){let _e=new Uint8Array(4),ne=e.createTexture();e.bindTexture(D,ne),e.texParameteri(D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(D,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let de=0;de<Y;de++)if(D===e.TEXTURE_3D||D===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,_e);else e.texImage2D(ce+de,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,_e);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(Zc),Gt(!1),gt(Hc),se(e.CULL_FACE),rt(qn);function se(D){if(u[D]!==!0)e.enable(D),u[D]=!0}function Pe(D){if(u[D]!==!1)e.disable(D),u[D]=!1}function Ie(D,ce){if(h[D]!==ce){if(e.bindFramebuffer(D,ce),h[D]=ce,D===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(D===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function we(D,ce){let Y=g,le=!1;if(D){if(Y=d.get(ce),Y===void 0)Y=[],d.set(ce,Y);let _e=D.textures;if(Y.length!==_e.length||Y[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,de=_e.length;ne<de;ne++)Y[ne]=e.COLOR_ATTACHMENT0+ne;Y.length=_e.length,le=!0}}else if(Y[0]!==e.BACK)Y[0]=e.BACK,le=!0;if(le)e.drawBuffers(Y)}function mt(D){if(x!==D)return e.useProgram(D),x=D,!0;return!1}let ze={[Zr]:e.FUNC_ADD,[kf]:e.FUNC_SUBTRACT,[Bf]:e.FUNC_REVERSE_SUBTRACT};ze[Gf]=e.MIN,ze[Hf]=e.MAX;let Ze={[Vf]:e.ZERO,[Wf]:e.ONE,[$f]:e.SRC_COLOR,[Xf]:e.SRC_ALPHA,[Qf]:e.SRC_ALPHA_SATURATE,[Kf]:e.DST_COLOR,[Yf]:e.DST_ALPHA,[Zf]:e.ONE_MINUS_SRC_COLOR,[qf]:e.ONE_MINUS_SRC_ALPHA,[Jf]:e.ONE_MINUS_DST_COLOR,[jf]:e.ONE_MINUS_DST_ALPHA,[ed]:e.CONSTANT_COLOR,[td]:e.ONE_MINUS_CONSTANT_COLOR,[nd]:e.CONSTANT_ALPHA,[id]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(D,ce,Y,le,_e,ne,de,ke,ft,nt){if(D===qn){if(p===!0)Pe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(D!==zf){if(D!==m||nt!==F){if(E!==Zr||b!==Zr)e.blendEquation(e.FUNC_ADD),E=Zr,b=Zr;if(nt)switch(D){case Es:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vc:e.blendFunc(e.ONE,e.ONE);break;case Wc:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case $c:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",D);break}else switch(D){case Es:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Wc:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $c:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",D);break}R=null,S=null,T=null,A=null,_.set(0,0,0),M=0,m=D,F=nt}return}if(_e=_e||ce,ne=ne||Y,de=de||le,ce!==E||_e!==b)e.blendEquationSeparate(ze[ce],ze[_e]),E=ce,b=_e;if(Y!==R||le!==S||ne!==T||de!==A)e.blendFuncSeparate(Ze[Y],Ze[le],Ze[ne],Ze[de]),R=Y,S=le,T=ne,A=de;if(ke.equals(_)===!1||ft!==M)e.blendColor(ke.r,ke.g,ke.b,ft),_.copy(ke),M=ft;m=D,F=!1}function je(D,ce){D.side===wn?Pe(e.CULL_FACE):se(e.CULL_FACE);let Y=D.side===Xt;if(ce)Y=!Y;Gt(Y),D.blending===Es&&D.transparent===!1?rt(qn):rt(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);let le=D.stencilWrite;if(a.setTest(le),le)a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass);Pt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Pe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Gt(D){if(P!==D){if(D)e.frontFace(e.CW);else e.frontFace(e.CCW);P=D}}function gt(D){if(D!==Of){if(se(e.CULL_FACE),D!==O)if(D===Hc)e.cullFace(e.BACK);else if(D===Uf)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Pe(e.CULL_FACE);O=D}function nn(D){if(D!==K){if(z)e.lineWidth(D);K=D}}function Pt(D,ce,Y){if(D){if(se(e.POLYGON_OFFSET_FILL),C!==ce||G!==Y){if(C=ce,G=Y,o.getReversed())ce=-ce;e.polygonOffset(ce,Y)}}else Pe(e.POLYGON_OFFSET_FILL)}function It(D){if(D)se(e.SCISSOR_TEST);else Pe(e.SCISSOR_TEST)}function L(D){if(D===void 0)D=e.TEXTURE0+X-1;if(Q!==D)e.activeTexture(D),Q=D}function rn(D,ce,Y){if(Y===void 0)if(Q===null)Y=e.TEXTURE0+X-1;else Y=Q;let le=ee[Y];if(le===void 0)le={type:void 0,texture:void 0},ee[Y]=le;if(le.type!==D||le.texture!==ce){if(Q!==Y)e.activeTexture(Y),Q=Y;e.bindTexture(D,ce||re[D]),le.type=D,le.texture=ce}}function tt(){let D=ee[Q];if(D!==void 0&&D.type!==void 0)e.bindTexture(D.type,null),D.type=void 0,D.texture=void 0}function yt(){try{e.compressedTexImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function v(){try{e.texSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function I(){try{e.texSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ae(){try{e.texStorage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ue(){try{e.texStorage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function q(){try{e.texImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function J(){try{e.texImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ge(D){if(f[D]!==void 0)return f[D];else return e.getParameter(D)}function Ae(D,ce){if(f[D]!==ce)e.pixelStorei(D,ce),f[D]=ce}function he(D){if(Ge.equals(D)===!1)e.scissor(D.x,D.y,D.z,D.w),Ge.copy(D)}function oe(D){if(Me.equals(D)===!1)e.viewport(D.x,D.y,D.z,D.w),Me.copy(D)}function Le(D,ce){let Y=l.get(ce);if(Y===void 0)Y=new WeakMap,l.set(ce,Y);let le=Y.get(D);if(le===void 0)le=e.getUniformBlockIndex(ce,D.name),Y.set(D,le)}function De(D,ce){let le=l.get(ce).get(D);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,D.__bindingPointIndex),c.set(ce,le)}function Je(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Q=null,ee={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,P=null,O=null,K=null,C=null,G=null,Ge.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:Pe,bindFramebuffer:Ie,drawBuffers:we,useProgram:mt,setBlending:rt,setMaterial:je,setFlipSided:Gt,setCullFace:gt,setLineWidth:nn,setPolygonOffset:Pt,setScissorTest:It,activeTexture:L,bindTexture:rn,unbindTexture:tt,compressedTexImage2D:yt,compressedTexImage3D:w,texImage2D:q,texImage3D:J,pixelStorei:Ae,getParameter:ge,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:ue,texSubImage2D:v,texSubImage3D:I,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:he,viewport:oe,reset:Je}}function Ww(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,v){return g?new OffscreenCanvas(w,v):Hr("canvas")}function p(w,v,I){let V=1,ie=yt(w);if(ie.width>I||ie.height>I)V=I/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),ue=Math.floor(V*ie.height);if(h===void 0)h=x(ae,ue);let q=v?x(ae,ue):h;return q.width=ae,q.height=ue,q.getContext("2d").drawImage(w,0,0,ae,ue),Re("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+ue+")."),q}else{if("data"in w)Re("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function S(w,v,I,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Re("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ue;if(V){if(ue=t.get("EXT_texture_norm16"),!ue)Re("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let q=v;if(v===e.RED){if(I===e.FLOAT)q=e.R32F;if(I===e.HALF_FLOAT)q=e.R16F;if(I===e.UNSIGNED_BYTE)q=e.R8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.R16_EXT;if(I===e.SHORT&&ue)q=ue.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.R8UI;if(I===e.UNSIGNED_SHORT)q=e.R16UI;if(I===e.UNSIGNED_INT)q=e.R32UI;if(I===e.BYTE)q=e.R8I;if(I===e.SHORT)q=e.R16I;if(I===e.INT)q=e.R32I}if(v===e.RG){if(I===e.FLOAT)q=e.RG32F;if(I===e.HALF_FLOAT)q=e.RG16F;if(I===e.UNSIGNED_BYTE)q=e.RG8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.RG16_EXT;if(I===e.SHORT&&ue)q=ue.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RG8UI;if(I===e.UNSIGNED_SHORT)q=e.RG16UI;if(I===e.UNSIGNED_INT)q=e.RG32UI;if(I===e.BYTE)q=e.RG8I;if(I===e.SHORT)q=e.RG16I;if(I===e.INT)q=e.RG32I}if(v===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RGB8UI;if(I===e.UNSIGNED_SHORT)q=e.RGB16UI;if(I===e.UNSIGNED_INT)q=e.RGB32UI;if(I===e.BYTE)q=e.RGB8I;if(I===e.SHORT)q=e.RGB16I;if(I===e.INT)q=e.RGB32I}if(v===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)q=e.RGBA16UI;if(I===e.UNSIGNED_INT)q=e.RGBA32UI;if(I===e.BYTE)q=e.RGBA8I;if(I===e.SHORT)q=e.RGBA16I;if(I===e.INT)q=e.RGBA32I}if(v===e.RGB){if(I===e.UNSIGNED_SHORT&&ue)q=ue.RGB16_EXT;if(I===e.SHORT&&ue)q=ue.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)q=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)q=e.R11F_G11F_B10F}if(v===e.RGBA){let J=ae?zl:We.getTransfer(ie);if(I===e.FLOAT)q=e.RGBA32F;if(I===e.HALF_FLOAT)q=e.RGBA16F;if(I===e.UNSIGNED_BYTE)q=J===ht?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.RGBA16_EXT;if(I===e.SHORT&&ue)q=ue.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)q=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)q=e.RGB5_A1}if(q===e.R16F||q===e.R32F||q===e.RG16F||q===e.RG32F||q===e.RGBA16F||q===e.RGBA32F)t.get("EXT_color_buffer_float");return q}function b(w,v){let I;if(w){if(v===null||v===ki||v===Kr)I=e.DEPTH24_STENCIL8;else if(v===xi)I=e.DEPTH32F_STENCIL8;else if(v===Cs)I=e.DEPTH24_STENCIL8,Re("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===ki||v===Kr)I=e.DEPTH_COMPONENT24;else if(v===xi)I=e.DEPTH_COMPONENT32F;else if(v===Cs)I=e.DEPTH_COMPONENT16;return I}function T(w,v){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==On&&w.minFilter!==kt)return Math.log2(Math.max(v.width,v.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return v.mipmaps.length;else return 1}function A(w){let v=w.target;if(v.removeEventListener("dispose",A),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)f.delete(v)}function _(w){let v=w.target;v.removeEventListener("dispose",_),P(v)}function M(w){let v=i.get(w);if(v.__webglInit===void 0)return;let I=w.source,V=d.get(I);if(V){let ie=V[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)F(w);if(Object.keys(V).length===0)d.delete(I)}i.remove(w)}function F(w){let v=i.get(w);e.deleteTexture(v.__webglTexture);let I=w.source,V=d.get(I);delete V[v.__cacheKey],o.memory.textures--}function P(w){let v=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(v.__webglFramebuffer[V]))for(let ie=0;ie<v.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[V]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[V])}else{if(Array.isArray(v.__webglFramebuffer))for(let V=0;V<v.__webglFramebuffer.length;V++)e.deleteFramebuffer(v.__webglFramebuffer[V]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let V=0;V<v.__webglColorRenderbuffer.length;V++)if(v.__webglColorRenderbuffer[V])e.deleteRenderbuffer(v.__webglColorRenderbuffer[V])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let I=w.textures;for(let V=0,ie=I.length;V<ie;V++){let ae=i.get(I[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(I[V])}i.remove(w)}let O=0;function K(){O=0}function C(){return O}function G(w){O=w}function X(){let w=O;if(w>=r.maxTextures)Re("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return O+=1,w}function z(w){let v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function te(w,v){let I=i.get(w);if(w.isVideoTexture)rn(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&I.__version!==w.version){let V=w.image;if(V===null)Re("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Re("WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(I,w,v);return}}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+v)}function H(w,v){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Pe(I,w,v);return}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+v)}function Q(w,v){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Pe(I,w,v);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+v)}function ee(w,v){let I=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&I.__version!==w.version){Ie(I,w,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+v)}let Te={[qr]:e.REPEAT,[Yr]:e.CLAMP_TO_EDGE,[Ko]:e.MIRRORED_REPEAT},ve={[On]:e.NEAREST,[Jo]:e.NEAREST_MIPMAP_NEAREST,[lr]:e.NEAREST_MIPMAP_LINEAR,[kt]:e.LINEAR,[jr]:e.LINEAR_MIPMAP_NEAREST,[Yn]:e.LINEAR_MIPMAP_LINEAR},Ge={[bd]:e.NEVER,[Ad]:e.ALWAYS,[Md]:e.LESS,[oa]:e.LEQUAL,[wd]:e.EQUAL,[aa]:e.GEQUAL,[Td]:e.GREATER,[Ed]:e.NOTEQUAL};function Me(w,v){if(v.type===xi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===kt||v.magFilter===jr||v.magFilter===lr||v.magFilter===Yn||v.minFilter===kt||v.minFilter===jr||v.minFilter===lr||v.minFilter===Yn))Re("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Te[v.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Te[v.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Te[v.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ve[v.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ve[v.minFilter]),v.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,Ge[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===On)return;if(v.minFilter!==lr&&v.minFilter!==Yn)return;if(v.type===xi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(w,v){let I=!1;if(w.__webglInit===void 0)w.__webglInit=!0,v.addEventListener("dispose",A);let V=v.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=z(v);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,I=!0;ie[ae].usedTimes++;let ue=ie[w.__cacheKey];if(ue!==void 0){if(ie[w.__cacheKey].usedTimes--,ue.usedTimes===0)F(v)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return I}function re(w,v,I){return Math.floor(Math.floor(w/I)/v)}function se(w,v,I,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,I,V,v.data);else{ae.sort((Ae,he)=>Ae.start-he.start);let ue=0;for(let Ae=1;Ae<ae.length;Ae++){let he=ae[ue],oe=ae[Ae],Le=he.start+he.count,De=re(oe.start,v.width,4),Je=re(he.start,v.width,4);if(oe.start<=Le+1&&De===Je&&re(oe.start+oe.count-1,v.width,4)===De)he.count=Math.max(he.count,oe.start+oe.count-he.start);else++ue,ae[ue]=oe}ae.length=ue+1;let q=n.getParameter(e.UNPACK_ROW_LENGTH),J=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ae=0,he=ae.length;Ae<he;Ae++){let oe=ae[Ae],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Je=Le%v.width,D=Math.floor(Le/v.width),ce=De,Y=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Je),n.pixelStorei(e.UNPACK_SKIP_ROWS,D),n.texSubImage2D(e.TEXTURE_2D,0,Je,D,ce,1,I,V,v.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,q),n.pixelStorei(e.UNPACK_SKIP_PIXELS,J),n.pixelStorei(e.UNPACK_SKIP_ROWS,ge)}}function Pe(w,v,I){let V=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,v),ae=v.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+I);let ue=i.get(ae);if(ae.version!==ue.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Y=We.getPrimaries(We.workingColorSpace),le=v.colorSpace===dr?null:We.getPrimaries(v.colorSpace),_e=v.colorSpace===dr||Y===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,_e)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let J=p(v.image,!1,r.maxTextureSize);J=tt(v,J);let ge=s.convert(v.format,v.colorSpace),Ae=s.convert(v.type),he=S(v.internalFormat,ge,Ae,v.normalized,v.colorSpace,v.isVideoTexture);Me(V,v);let oe,Le=v.mipmaps,De=v.isVideoTexture!==!0,Je=ue.__version===void 0||ie===!0,D=ae.dataReady,ce=T(v,J);if(v.isDepthTexture){if(he=b(v.format===hr,v.type),Je)if(De)n.texStorage2D(e.TEXTURE_2D,1,he,J.width,J.height);else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,null)}else if(v.isDataTexture)if(Le.length>0){if(De&&Je)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data);v.generateMipmaps=!1}else if(De){if(Je)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);if(D)se(v,J,ge,Ae)}else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,J.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(De&&Je)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,Le[0].width,Le[0].height,J.depth);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==Kn)if(ge!==null)if(De){if(D)if(v.layerUpdates.size>0){let _e=cu(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let de=oe.data.subarray(ne*_e/oe.data.BYTES_PER_ELEMENT,(ne+1)*_e/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,ne,oe.width,oe.height,1,ge,de)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,oe.data,0,0);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,Ae,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,ge,Ae,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(De&&Je)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==Kn)if(ge!==null)if(De){if(D)n.compressedTexSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,oe.data);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data)}else if(v.isDataArrayTexture)if(De){if(Je)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,J.width,J.height,J.depth);if(D)if(v.layerUpdates.size>0){let Y=cu(J.width,J.height,v.format,v.type);for(let le of v.layerUpdates){let _e=J.data.subarray(le*Y/J.data.BYTES_PER_ELEMENT,(le+1)*Y/J.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,J.width,J.height,1,ge,Ae,_e)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isData3DTexture)if(De){if(Je)n.texStorage3D(e.TEXTURE_3D,ce,he,J.width,J.height,J.depth);if(D)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isFramebufferTexture){if(Je)if(De)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);else{let Y=J.width,le=J.height;for(let _e=0;_e<ce;_e++)n.texImage2D(e.TEXTURE_2D,_e,he,Y,le,0,ge,Ae,null),Y>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Y=e.canvas;if(!Y.hasAttribute("layoutsubtree"))Y.setAttribute("layoutsubtree","true");if(J.parentNode!==Y){Y.appendChild(J),f.add(v),Y.onpaint=(le)=>{let _e=le.changedElements;for(let ne of f)if(_e.includes(ne.image))ne.needsUpdate=!0},Y.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,J);else{let{RGBA:_e,RGBA:ne,UNSIGNED_BYTE:de}=e;e.texElementImage2D(e.TEXTURE_2D,0,_e,ne,de,J)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Je){let Y=yt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,ge,Ae,oe)}else n.texImage2D(e.TEXTURE_2D,Y,he,ge,Ae,oe);v.generateMipmaps=!1}else if(De){if(Je){let Y=yt(J);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}if(D)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ae,J)}else n.texImage2D(e.TEXTURE_2D,0,he,ge,Ae,J);if(m(v))E(V);if(ue.__version=ae.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function Ie(w,v,I){if(v.image.length!==6)return;let V=Z(w,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+I);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+I);let ue=We.getPrimaries(We.workingColorSpace),q=v.colorSpace===dr?null:We.getPrimaries(v.colorSpace),J=v.colorSpace===dr||ue===q?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,J);let ge=v.isCompressedTexture||v.image[0].isCompressedTexture,Ae=v.image[0]&&v.image[0].isDataTexture,he=[];for(let ne=0;ne<6;ne++){if(!ge&&!Ae)he[ne]=p(v.image[ne],!0,r.maxCubemapSize);else he[ne]=Ae?v.image[ne].image:v.image[ne];he[ne]=tt(v,he[ne])}let oe=he[0],Le=s.convert(v.format,v.colorSpace),De=s.convert(v.type),Je=S(v.internalFormat,Le,De,v.normalized,v.colorSpace),D=v.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,Y=ie.dataReady,le=T(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let _e;if(ge){if(D&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Je,oe.width,oe.height);for(let ne=0;ne<6;ne++){_e=he[ne].mipmaps;for(let de=0;de<_e.length;de++){let ke=_e[de];if(v.format!==Kn)if(Le!==null)if(D){if(Y)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,ke.width,ke.height,Le,ke.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Je,ke.width,ke.height,0,ke.data);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,ke.width,ke.height,Le,De,ke.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Je,ke.width,ke.height,0,Le,De,ke.data)}}}else{if(_e=v.mipmaps,D&&ce){if(_e.length>0)le++;let ne=yt(he[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Je,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ae){if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,he[ne].width,he[ne].height,Le,De,he[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Je,he[ne].width,he[ne].height,0,Le,De,he[ne].data);for(let de=0;de<_e.length;de++){let ft=_e[de].image[ne].image;if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,ft.width,ft.height,Le,De,ft.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Je,ft.width,ft.height,0,Le,De,ft.data)}}else{if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,he[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Je,Le,De,he[ne]);for(let de=0;de<_e.length;de++){let ke=_e[de];if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,Le,De,ke.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Je,Le,De,ke.image[ne])}}}if(m(v))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function we(w,v,I,V,ie,ae){let ue=s.convert(I.format,I.colorSpace),q=s.convert(I.type),J=S(I.internalFormat,ue,q,I.normalized,I.colorSpace),ge=i.get(v),Ae=i.get(I);if(Ae.__renderTarget=v,!ge.__hasExternalTextures){let he=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,J,he,oe,v.depth,0,ue,q,null);else n.texImage2D(ie,ae,J,he,oe,0,ue,q,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Ae.__webglTexture,0,It(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,V,ie,Ae.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function mt(w,v,I){if(e.bindRenderbuffer(e.RENDERBUFFER,w),v.depthBuffer){let V=v.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=b(v.stencilBuffer,ie),ue=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(v),ae,v.width,v.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,w)}else{let V=v.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],ue=s.convert(ae.format,ae.colorSpace),q=s.convert(ae.type),J=S(ae.internalFormat,ue,q,ae.normalized,ae.colorSpace);if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(v),J,v.width,v.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(v),J,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,J,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ze(w,v,I){let V=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(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(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let ge=s.convert(v.depthTexture.format),Ae=s.convert(v.depthTexture.type),he;if(v.depthTexture.format===ur)he=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===hr)he=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,he,v.width,v.height,0,ge,Ae,null)}}else te(v.depthTexture,0);let ae=ie.__webglTexture,ue=It(v),q=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,J=v.depthTexture.format===hr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===ur)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else if(v.depthTexture.format===hr)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let v=i.get(w),I=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(V){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=V}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(I)for(let V=0;V<6;V++)ze(v.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ze(v.__webglFramebuffer[0],w,0);else ze(v.__webglFramebuffer,w,0)}else if(I){v.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[V]),v.__webglDepthbuffer[V]===void 0)v.__webglDepthbuffer[V]=e.createRenderbuffer(),mt(v.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),mt(v.__webglDepthbuffer,w,!1);else{let ie=w.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 rt(w,v,I){let V=i.get(w);if(v!==void 0)we(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(w)}function je(w){let v=w.texture,I=i.get(w),V=i.get(v);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,ue=ie.length>1;if(!ue){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=v.version,o.memory.textures++}if(ae){I.__webglFramebuffer=[];for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0){I.__webglFramebuffer[q]=[];for(let J=0;J<v.mipmaps.length;J++)I.__webglFramebuffer[q][J]=e.createFramebuffer()}else I.__webglFramebuffer[q]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){I.__webglFramebuffer=[];for(let q=0;q<v.mipmaps.length;q++)I.__webglFramebuffer[q]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(ue)for(let q=0,J=ie.length;q<J;q++){let ge=i.get(ie[q]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let q=0;q<ie.length;q++){let J=ie[q];I.__webglColorRenderbuffer[q]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[q]);let ge=s.convert(J.format,J.colorSpace),Ae=s.convert(J.type),he=S(J.internalFormat,ge,Ae,J.normalized,J.colorSpace,w.isXRRenderTarget===!0),oe=It(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,he,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+q,e.RENDERBUFFER,I.__webglColorRenderbuffer[q])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),mt(I.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(I.__webglFramebuffer[q][J],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else we(I.__webglFramebuffer[q],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);if(m(v))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ue){for(let q=0,J=ie.length;q<J;q++){let ge=ie[q],Ae=i.get(ge),he=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)he=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(he,Ae.__webglTexture),Me(he,ge),we(I.__webglFramebuffer,w,ge,e.COLOR_ATTACHMENT0+q,he,0),m(ge))E(he)}n.unbindTexture()}else{let q=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)q=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(q,V.__webglTexture),Me(q,v),v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(I.__webglFramebuffer[J],w,v,e.COLOR_ATTACHMENT0,q,J);else we(I.__webglFramebuffer,w,v,e.COLOR_ATTACHMENT0,q,0);if(m(v))E(q);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Gt(w){let v=w.textures;for(let I=0,V=v.length;I<V;I++){let ie=v[I];if(m(ie)){let ae=R(w),ue=i.get(ie).__webglTexture;n.bindTexture(ae,ue),E(ae),n.unbindTexture()}}}let gt=[],nn=[];function Pt(w){if(w.samples>0){if(L(w)===!1){let{textures:v,width:I,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ue=i.get(w),q=v.length>1;if(q)for(let ge=0;ge<v.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer);let J=w.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let ge=0;ge<v.length;ge++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(q){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ae,0)}if(e.blitFramebuffer(0,0,I,V,0,0,I,V,ie,e.NEAREST),c===!0){if(gt.length=0,nn.length=0,gt.push(e.COLOR_ATTACHMENT0+ge),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)gt.push(ae),nn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,nn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,gt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),q)for(let ge=0;ge<v.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ae,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let v=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function It(w){return Math.min(r.maxSamples,w.samples)}function L(w){let v=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function rn(w){let v=o.render.frame;if(u.get(w)!==v)u.set(w,v),w.update()}function tt(w,v){let{colorSpace:I,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return v;if(I!==hn&&I!==dr)if(We.getTransfer(I)===ht){if(V!==Kn||ie!==Un)Re("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",I);return v}function yt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=C,this.setTextureUnits=G,this.setTexture2D=te,this.setTexture2DArray=H,this.setTexture3D=Q,this.setTextureCube=ee,this.rebindTextures=rt,this.setupRenderTarget=je,this.updateRenderTargetMipmap=Gt,this.updateMultisampleRenderTarget=Pt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=we,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function $w(e,t){function n(i,r=dr){let s,o=We.getTransfer(r);if(i===Un)return e.UNSIGNED_BYTE;if(i===el)return e.UNSIGNED_SHORT_4_4_4_4;if(i===tl)return e.UNSIGNED_SHORT_5_5_5_1;if(i===gd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===_d)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===pd)return e.BYTE;if(i===md)return e.SHORT;if(i===Cs)return e.UNSIGNED_SHORT;if(i===Qc)return e.INT;if(i===ki)return e.UNSIGNED_INT;if(i===xi)return e.FLOAT;if(i===jn)return e.HALF_FLOAT;if(i===xd)return e.ALPHA;if(i===vd)return e.RGB;if(i===Kn)return e.RGBA;if(i===ur)return e.DEPTH_COMPONENT;if(i===hr)return e.DEPTH_STENCIL;if(i===yd)return e.RED;if(i===nl)return e.RED_INTEGER;if(i===fr)return e.RG;if(i===il)return e.RG_INTEGER;if(i===rl)return e.RGBA_INTEGER;if(i===Qo||i===ea||i===ta||i===na)if(o===ht)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Qo)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===na)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Qo)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===na)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===sl||i===ol||i===al||i===cl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===sl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ol)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===al)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===cl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ll||i===ul||i===hl||i===fl||i===dl||i===ia||i===pl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ll||i===ul)return o===ht?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===hl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===fl)return s.COMPRESSED_R11_EAC;if(i===dl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ia)return s.COMPRESSED_RG11_EAC;if(i===pl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===ml||i===gl||i===_l||i===xl||i===vl||i===yl||i===Sl||i===bl||i===Ml||i===wl||i===Tl||i===El||i===Al||i===Rl)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===ml)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===gl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===_l)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===xl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===vl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===yl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Sl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===bl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ml)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===wl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Tl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===El)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Al)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Rl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Cl||i===Pl||i===Il)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Cl)return o===ht?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Pl)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Il)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ll||i===Nl||i===ra||i===Dl)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ll)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Nl)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ra)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Dl)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Kr)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Zw=`
+}`,Vw=[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)],Ww=[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)],lp=new Be,Xs=new U,pu=new U;function $w(e,t,n){let i=new zs,r=new Ne,s=new Ne,o=new ot,a=new ql,c=new Yl,l={},u=n.maxTextureSize,f={[zi]:Xt,[Xt]:zi,[wn]:wn},h=new Tn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ne},radius:{value:4}},vertexShader:Gw,fragmentShader:Hw}),d=h.clone();d.defines.HORIZONTAL_PASS=1;let g=new qt;g.setAttribute("position",new zt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let x=new pt(g,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ts;let m=this.type;this.render=function(T,A,_){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(T.length===0)return;if(this.type===kf)Re("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ts;let M=e.getRenderTarget(),F=e.getActiveCubeFace(),P=e.getActiveMipmapLevel(),O=e.state;if(O.setBlending(qn),O.buffers.depth.getReversed()===!0)O.buffers.color.setClear(0,0,0,0);else O.buffers.color.setClear(1,1,1,1);O.buffers.depth.setTest(!0),O.setScissorTest(!1);let K=m!==this.type;if(K)A.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((G)=>G.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,G=T.length;C<G;C++){let X=T[C],z=X.shadow;if(z===void 0){Re("WebGLShadowMap:",X,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);let te=z.getFrameExtents();if(r.multiply(te),s.copy(z.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/te.x),r.x=s.x*te.x,z.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/te.y),r.y=s.y*te.y,z.mapSize.y=s.y}let H=e.state.buffers.depth.getReversed();if(z.camera._reversedDepth=H,z.map===null||K===!0){if(z.map!==null){if(z.map.depthTexture!==null)z.map.depthTexture.dispose(),z.map.depthTexture=null;z.map.dispose()}if(this.type===$r){if(X.isPointLight){Re("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new fn(r.x,r.y,{format:fr,type:jn,minFilter:kt,magFilter:kt,generateMipmaps:!1}),z.map.texture.name=X.name+".shadowMap",z.map.depthTexture=new pr(r.x,r.y,xi),z.map.depthTexture.name=X.name+".shadowMapDepth",z.map.depthTexture.format=ur,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=On,z.map.depthTexture.magFilter=On}else{if(X.isPointLight)z.map=new _u(r.x),z.map.depthTexture=new $l(r.x,ki);else z.map=new fn(r.x,r.y),z.map.depthTexture=new pr(r.x,r.y,ki);if(z.map.depthTexture.name=X.name+".shadowMap",z.map.depthTexture.format=ur,this.type===Ts)z.map.depthTexture.compareFunction=H?aa:oa,z.map.depthTexture.minFilter=kt,z.map.depthTexture.magFilter=kt;else z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=On,z.map.depthTexture.magFilter=On}z.camera.updateProjectionMatrix()}if(z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==r.x||z.map.height!==r.y))z.map.setSize(r.x,r.y);let Q=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();if(X.isPointLight!==!0)z.updateMatrices(X,_);for(let ee=0;ee<Q;ee++){let Te=z.getCamera(ee);if(X.isPointLight){let{camera:ve,matrix:Ge}=z,Me=X.distance||ve.far;if(Me!==ve.far)ve.far=Me,ve.updateProjectionMatrix();Xs.setFromMatrixPosition(X.matrixWorld),ve.position.copy(Xs),pu.copy(ve.position),pu.add(Vw[ee]),ve.up.copy(Ww[ee]),ve.lookAt(pu),ve.updateMatrixWorld(),Ge.makeTranslation(-Xs.x,-Xs.y,-Xs.z),lp.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),z._frustum.setFromProjectionMatrix(lp,ve.coordinateSystem,ve.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)e.setRenderTarget(z.map,ee),e.clear();else{if(ee===0)e.setRenderTarget(z.map),e.clear();let ve=z.getViewport(ee);o.set(s.x*ve.x,s.y*ve.y,s.x*ve.z,s.y*ve.w),O.viewport(o)}i=z.getFrustum(ee),S(A,_,Te,X,this.type)}if(z.isPointLightShadow!==!0&&this.type===$r)E(z,_);z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,e.setRenderTarget(M,F,P)};function E(T,A){let _=t.update(x);if(h.defines.VSM_SAMPLES!==T.blurSamples)h.defines.VSM_SAMPLES=T.blurSamples,d.defines.VSM_SAMPLES=T.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0;if(T.mapPass===null)T.mapPass=new fn(r.x,r.y,{format:fr,type:jn});else if(T.mapPass.width!==T.map.width||T.mapPass.height!==T.map.height)T.mapPass.setSize(T.map.width,T.map.height);h.uniforms.shadow_pass.value=T.map.depthTexture,h.uniforms.resolution.value.set(T.map.width,T.map.height),h.uniforms.radius.value=T.radius,e.setRenderTarget(T.mapPass),e.clear(),e.renderBufferDirect(A,null,_,h,x,null),d.uniforms.shadow_pass.value=T.mapPass.texture,d.uniforms.resolution.value.set(T.map.width,T.map.height),d.uniforms.radius.value=T.radius,e.setRenderTarget(T.map),e.clear(),e.renderBufferDirect(A,null,_,d,x,null)}function R(T,A,_,M){let F=null,P=_.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)F=P;else if(F=_.isPointLight===!0?c:a,e.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let O=F.uuid,K=A.uuid,C=l[O];if(C===void 0)C={},l[O]=C;let G=C[K];if(G===void 0)G=F.clone(),C[K]=G,A.addEventListener("dispose",b);F=G}if(F.visible=A.visible,F.wireframe=A.wireframe,M===$r)F.side=A.shadowSide!==null?A.shadowSide:A.side;else F.side=A.shadowSide!==null?A.shadowSide:f[A.side];if(F.alphaMap=A.alphaMap,F.alphaTest=A.alphaToCoverage===!0?0.5:A.alphaTest,F.map=A.map,F.clipShadows=A.clipShadows,F.clippingPlanes=A.clippingPlanes,F.clipIntersection=A.clipIntersection,F.displacementMap=A.displacementMap,F.displacementScale=A.displacementScale,F.displacementBias=A.displacementBias,F.wireframeLinewidth=A.wireframeLinewidth,F.linewidth=A.linewidth,_.isPointLight===!0&&F.isMeshDistanceMaterial===!0){let O=e.properties.get(F);O.light=_}return F}function S(T,A,_,M,F){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)){if((T.castShadow||T.receiveShadow&&F===$r)&&(!T.frustumCulled||T.intersectsFrustum(i))){T.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,T.matrixWorld);let K=t.update(T),C=T.material;if(Array.isArray(C)){let G=K.groups;for(let X=0,z=G.length;X<z;X++){let te=G[X],H=C[te.materialIndex];if(H&&H.visible){let Q=R(T,H,M,F);T.onBeforeShadow(e,T,A,_,K,Q,te),e.renderBufferDirect(_,null,K,Q,T,te),T.onAfterShadow(e,T,A,_,K,Q,te)}}}else if(C.visible){let G=R(T,C,M,F);T.onBeforeShadow(e,T,A,_,K,G,null),e.renderBufferDirect(_,null,K,G,T,null),T.onAfterShadow(e,T,A,_,K,G,null)}}}let O=T.children;for(let K=0,C=O.length;K<C;K++)S(O[K],A,_,M,F)}function b(T){T.target.removeEventListener("dispose",b);for(let _ in l){let M=l[_],F=T.target.uuid;if(F in M)M[F].dispose(),delete M[F]}}}function Zw(e,t){function n(){let D=!1,ce=new ot,Y=null,le=new ot(0,0,0,0);return{setMask:function(_e){if(Y!==_e&&!D)e.colorMask(_e,_e,_e,_e),Y=_e},setLocked:function(_e){D=_e},setClear:function(_e,ne,de,ke,ft){if(ft===!0)_e*=ke,ne*=ke,de*=ke;if(ce.set(_e,ne,de,ke),le.equals(ce)===!1)e.clearColor(_e,ne,de,ke),le.copy(ce)},reset:function(){D=!1,Y=null,le.set(-1,0,0,0)}}}function i(){let D=!1,ce=!1,Y=null,le=null,_e=null;return{setReversed:function(ne){if(ce!==ne){let de=t.get("EXT_clip_control");if(ne)de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT);else de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let ke=_e;_e=null,this.setClear(ke)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else Pe(e.DEPTH_TEST)},setMask:function(ne){if(Y!==ne&&!D)e.depthMask(ne),Y=ne},setFunc:function(ne){if(ce)ne=Nd[ne];if(le!==ne){switch(ne){case od:e.depthFunc(e.NEVER);break;case ad:e.depthFunc(e.ALWAYS);break;case cd:e.depthFunc(e.LESS);break;case Zc:e.depthFunc(e.LEQUAL);break;case ld:e.depthFunc(e.EQUAL);break;case ud:e.depthFunc(e.GEQUAL);break;case hd:e.depthFunc(e.GREATER);break;case fd:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){D=ne},setClear:function(ne){if(_e!==ne){if(_e=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){D=!1,Y=null,le=null,_e=null,ce=!1}}}function r(){let D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,ke=null,ft=null;return{setTest:function(nt){if(!D)if(nt)se(e.STENCIL_TEST);else Pe(e.STENCIL_TEST)},setMask:function(nt){if(ce!==nt&&!D)e.stencilMask(nt),ce=nt},setFunc:function(nt,Hn,ui){if(Y!==nt||le!==Hn||_e!==ui)e.stencilFunc(nt,Hn,ui),Y=nt,le=Hn,_e=ui},setOp:function(nt,Hn,ui){if(ne!==nt||de!==Hn||ke!==ui)e.stencilOp(nt,Hn,ui),ne=nt,de=Hn,ke=ui},setLocked:function(nt){D=nt},setClear:function(nt){if(ft!==nt)e.clearStencil(nt),ft=nt},reset:function(){D=!1,ce=null,Y=null,le=null,_e=null,ne=null,de=null,ke=null,ft=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},f={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,P=null,O=null,K=null,C=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,H=e.getParameter(e.VERSION);if(H.indexOf("WebGL")!==-1)te=parseFloat(/^WebGL (\d)/.exec(H)[1]),z=te>=1;else if(H.indexOf("OpenGL ES")!==-1)te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),z=te>=2;let Q=null,ee={},Te=e.getParameter(e.SCISSOR_BOX),ve=e.getParameter(e.VIEWPORT),Ge=new ot().fromArray(Te),Me=new ot().fromArray(ve);function Z(D,ce,Y,le){let _e=new Uint8Array(4),ne=e.createTexture();e.bindTexture(D,ne),e.texParameteri(D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(D,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let de=0;de<Y;de++)if(D===e.TEXTURE_3D||D===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,_e);else e.texImage2D(ce+de,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,_e);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(Zc),Gt(!1),gt(Hc),se(e.CULL_FACE),rt(qn);function se(D){if(u[D]!==!0)e.enable(D),u[D]=!0}function Pe(D){if(u[D]!==!1)e.disable(D),u[D]=!1}function Ie(D,ce){if(h[D]!==ce){if(e.bindFramebuffer(D,ce),h[D]=ce,D===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(D===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function we(D,ce){let Y=g,le=!1;if(D){if(Y=d.get(ce),Y===void 0)Y=[],d.set(ce,Y);let _e=D.textures;if(Y.length!==_e.length||Y[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,de=_e.length;ne<de;ne++)Y[ne]=e.COLOR_ATTACHMENT0+ne;Y.length=_e.length,le=!0}}else if(Y[0]!==e.BACK)Y[0]=e.BACK,le=!0;if(le)e.drawBuffers(Y)}function mt(D){if(x!==D)return e.useProgram(D),x=D,!0;return!1}let ze={[Zr]:e.FUNC_ADD,[Gf]:e.FUNC_SUBTRACT,[Hf]:e.FUNC_REVERSE_SUBTRACT};ze[Vf]=e.MIN,ze[Wf]=e.MAX;let Ze={[$f]:e.ZERO,[Zf]:e.ONE,[Xf]:e.SRC_COLOR,[Yf]:e.SRC_ALPHA,[td]:e.SRC_ALPHA_SATURATE,[Qf]:e.DST_COLOR,[Kf]:e.DST_ALPHA,[qf]:e.ONE_MINUS_SRC_COLOR,[jf]:e.ONE_MINUS_SRC_ALPHA,[ed]:e.ONE_MINUS_DST_COLOR,[Jf]:e.ONE_MINUS_DST_ALPHA,[nd]:e.CONSTANT_COLOR,[id]:e.ONE_MINUS_CONSTANT_COLOR,[rd]:e.CONSTANT_ALPHA,[sd]:e.ONE_MINUS_CONSTANT_ALPHA};function rt(D,ce,Y,le,_e,ne,de,ke,ft,nt){if(D===qn){if(p===!0)Pe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(D!==Bf){if(D!==m||nt!==F){if(E!==Zr||b!==Zr)e.blendEquation(e.FUNC_ADD),E=Zr,b=Zr;if(nt)switch(D){case Es:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vc:e.blendFunc(e.ONE,e.ONE);break;case Wc:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case $c:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ue("WebGLState: Invalid blending: ",D);break}else switch(D){case Es:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Vc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Wc:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $c:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",D);break}R=null,S=null,T=null,A=null,_.set(0,0,0),M=0,m=D,F=nt}return}if(_e=_e||ce,ne=ne||Y,de=de||le,ce!==E||_e!==b)e.blendEquationSeparate(ze[ce],ze[_e]),E=ce,b=_e;if(Y!==R||le!==S||ne!==T||de!==A)e.blendFuncSeparate(Ze[Y],Ze[le],Ze[ne],Ze[de]),R=Y,S=le,T=ne,A=de;if(ke.equals(_)===!1||ft!==M)e.blendColor(ke.r,ke.g,ke.b,ft),_.copy(ke),M=ft;m=D,F=!1}function je(D,ce){D.side===wn?Pe(e.CULL_FACE):se(e.CULL_FACE);let Y=D.side===Xt;if(ce)Y=!Y;Gt(Y),D.blending===Es&&D.transparent===!1?rt(qn):rt(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),o.setFunc(D.depthFunc),o.setTest(D.depthTest),o.setMask(D.depthWrite),s.setMask(D.colorWrite);let le=D.stencilWrite;if(a.setTest(le),le)a.setMask(D.stencilWriteMask),a.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),a.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass);Pt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):Pe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Gt(D){if(P!==D){if(D)e.frontFace(e.CW);else e.frontFace(e.CCW);P=D}}function gt(D){if(D!==Ff){if(se(e.CULL_FACE),D!==O)if(D===Hc)e.cullFace(e.BACK);else if(D===zf)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else Pe(e.CULL_FACE);O=D}function nn(D){if(D!==K){if(z)e.lineWidth(D);K=D}}function Pt(D,ce,Y){if(D){if(se(e.POLYGON_OFFSET_FILL),C!==ce||G!==Y){if(C=ce,G=Y,o.getReversed())ce=-ce;e.polygonOffset(ce,Y)}}else Pe(e.POLYGON_OFFSET_FILL)}function It(D){if(D)se(e.SCISSOR_TEST);else Pe(e.SCISSOR_TEST)}function L(D){if(D===void 0)D=e.TEXTURE0+X-1;if(Q!==D)e.activeTexture(D),Q=D}function rn(D,ce,Y){if(Y===void 0)if(Q===null)Y=e.TEXTURE0+X-1;else Y=Q;let le=ee[Y];if(le===void 0)le={type:void 0,texture:void 0},ee[Y]=le;if(le.type!==D||le.texture!==ce){if(Q!==Y)e.activeTexture(Y),Q=Y;e.bindTexture(D,ce||re[D]),le.type=D,le.texture=ce}}function tt(){let D=ee[Q];if(D!==void 0&&D.type!==void 0)e.bindTexture(D.type,null),D.type=void 0,D.texture=void 0}function yt(){try{e.compressedTexImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function w(){try{e.compressedTexImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function v(){try{e.texSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function I(){try{e.texSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function V(){try{e.compressedTexSubImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ae(){try{e.texStorage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ue(){try{e.texStorage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function q(){try{e.texImage2D(...arguments)}catch(D){Ue("WebGLState:",D)}}function J(){try{e.texImage3D(...arguments)}catch(D){Ue("WebGLState:",D)}}function ge(D){if(f[D]!==void 0)return f[D];else return e.getParameter(D)}function Ae(D,ce){if(f[D]!==ce)e.pixelStorei(D,ce),f[D]=ce}function he(D){if(Ge.equals(D)===!1)e.scissor(D.x,D.y,D.z,D.w),Ge.copy(D)}function oe(D){if(Me.equals(D)===!1)e.viewport(D.x,D.y,D.z,D.w),Me.copy(D)}function Le(D,ce){let Y=l.get(ce);if(Y===void 0)Y=new WeakMap,l.set(ce,Y);let le=Y.get(D);if(le===void 0)le=e.getUniformBlockIndex(ce,D.name),Y.set(D,le)}function De(D,ce){let le=l.get(ce).get(D);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,D.__bindingPointIndex),c.set(ce,le)}function Je(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},f={},Q=null,ee={},h={},d=new WeakMap,g=[],x=null,p=!1,m=null,E=null,R=null,S=null,b=null,T=null,A=null,_=new Oe(0,0,0),M=0,F=!1,P=null,O=null,K=null,C=null,G=null,Ge.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:Pe,bindFramebuffer:Ie,drawBuffers:we,useProgram:mt,setBlending:rt,setMaterial:je,setFlipSided:Gt,setCullFace:gt,setLineWidth:nn,setPolygonOffset:Pt,setScissorTest:It,activeTexture:L,bindTexture:rn,unbindTexture:tt,compressedTexImage2D:yt,compressedTexImage3D:w,texImage2D:q,texImage3D:J,pixelStorei:Ae,getParameter:ge,updateUBOMapping:Le,uniformBlockBinding:De,texStorage2D:ae,texStorage3D:ue,texSubImage2D:v,texSubImage3D:I,compressedTexSubImage2D:V,compressedTexSubImage3D:ie,scissor:he,viewport:oe,reset:Je}}function Xw(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ne,u=new WeakMap,f=new Set,h,d=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(w){}function x(w,v){return g?new OffscreenCanvas(w,v):Hr("canvas")}function p(w,v,I){let V=1,ie=yt(w);if(ie.width>I||ie.height>I)V=I/Math.max(ie.width,ie.height);if(V<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let ae=Math.floor(V*ie.width),ue=Math.floor(V*ie.height);if(h===void 0)h=x(ae,ue);let q=v?x(ae,ue):h;return q.width=ae,q.height=ue,q.getContext("2d").drawImage(w,0,0,ae,ue),Re("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+ue+")."),q}else{if("data"in w)Re("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return w}return w}function m(w){return w.generateMipmaps}function E(w){e.generateMipmap(w)}function R(w){if(w.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(w.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function S(w,v,I,V,ie,ae=!1){if(w!==null){if(e[w]!==void 0)return e[w];Re("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ue;if(V){if(ue=t.get("EXT_texture_norm16"),!ue)Re("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let q=v;if(v===e.RED){if(I===e.FLOAT)q=e.R32F;if(I===e.HALF_FLOAT)q=e.R16F;if(I===e.UNSIGNED_BYTE)q=e.R8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.R16_EXT;if(I===e.SHORT&&ue)q=ue.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.R8UI;if(I===e.UNSIGNED_SHORT)q=e.R16UI;if(I===e.UNSIGNED_INT)q=e.R32UI;if(I===e.BYTE)q=e.R8I;if(I===e.SHORT)q=e.R16I;if(I===e.INT)q=e.R32I}if(v===e.RG){if(I===e.FLOAT)q=e.RG32F;if(I===e.HALF_FLOAT)q=e.RG16F;if(I===e.UNSIGNED_BYTE)q=e.RG8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.RG16_EXT;if(I===e.SHORT&&ue)q=ue.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RG8UI;if(I===e.UNSIGNED_SHORT)q=e.RG16UI;if(I===e.UNSIGNED_INT)q=e.RG32UI;if(I===e.BYTE)q=e.RG8I;if(I===e.SHORT)q=e.RG16I;if(I===e.INT)q=e.RG32I}if(v===e.RGB_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RGB8UI;if(I===e.UNSIGNED_SHORT)q=e.RGB16UI;if(I===e.UNSIGNED_INT)q=e.RGB32UI;if(I===e.BYTE)q=e.RGB8I;if(I===e.SHORT)q=e.RGB16I;if(I===e.INT)q=e.RGB32I}if(v===e.RGBA_INTEGER){if(I===e.UNSIGNED_BYTE)q=e.RGBA8UI;if(I===e.UNSIGNED_SHORT)q=e.RGBA16UI;if(I===e.UNSIGNED_INT)q=e.RGBA32UI;if(I===e.BYTE)q=e.RGBA8I;if(I===e.SHORT)q=e.RGBA16I;if(I===e.INT)q=e.RGBA32I}if(v===e.RGB){if(I===e.UNSIGNED_SHORT&&ue)q=ue.RGB16_EXT;if(I===e.SHORT&&ue)q=ue.RGB16_SNORM_EXT;if(I===e.UNSIGNED_INT_5_9_9_9_REV)q=e.RGB9_E5;if(I===e.UNSIGNED_INT_10F_11F_11F_REV)q=e.R11F_G11F_B10F}if(v===e.RGBA){let J=ae?zl:We.getTransfer(ie);if(I===e.FLOAT)q=e.RGBA32F;if(I===e.HALF_FLOAT)q=e.RGBA16F;if(I===e.UNSIGNED_BYTE)q=J===ht?e.SRGB8_ALPHA8:e.RGBA8;if(I===e.UNSIGNED_SHORT&&ue)q=ue.RGBA16_EXT;if(I===e.SHORT&&ue)q=ue.RGBA16_SNORM_EXT;if(I===e.UNSIGNED_SHORT_4_4_4_4)q=e.RGBA4;if(I===e.UNSIGNED_SHORT_5_5_5_1)q=e.RGB5_A1}if(q===e.R16F||q===e.R32F||q===e.RG16F||q===e.RG32F||q===e.RGBA16F||q===e.RGBA32F)t.get("EXT_color_buffer_float");return q}function b(w,v){let I;if(w){if(v===null||v===ki||v===Kr)I=e.DEPTH24_STENCIL8;else if(v===xi)I=e.DEPTH32F_STENCIL8;else if(v===Cs)I=e.DEPTH24_STENCIL8,Re("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===ki||v===Kr)I=e.DEPTH_COMPONENT24;else if(v===xi)I=e.DEPTH_COMPONENT32F;else if(v===Cs)I=e.DEPTH_COMPONENT16;return I}function T(w,v){if(m(w)===!0||w.isFramebufferTexture&&w.minFilter!==On&&w.minFilter!==kt)return Math.log2(Math.max(v.width,v.height))+1;else if(w.mipmaps!==void 0&&w.mipmaps.length>0)return w.mipmaps.length;else if(w.isCompressedTexture&&Array.isArray(w.image))return v.mipmaps.length;else return 1}function A(w){let v=w.target;if(v.removeEventListener("dispose",A),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)f.delete(v)}function _(w){let v=w.target;v.removeEventListener("dispose",_),P(v)}function M(w){let v=i.get(w);if(v.__webglInit===void 0)return;let I=w.source,V=d.get(I);if(V){let ie=V[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)F(w);if(Object.keys(V).length===0)d.delete(I)}i.remove(w)}function F(w){let v=i.get(w);e.deleteTexture(v.__webglTexture);let I=w.source,V=d.get(I);delete V[v.__cacheKey],o.memory.textures--}function P(w){let v=i.get(w);if(w.depthTexture)w.depthTexture.dispose(),i.remove(w.depthTexture);if(w.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(v.__webglFramebuffer[V]))for(let ie=0;ie<v.__webglFramebuffer[V].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[V][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[V]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[V])}else{if(Array.isArray(v.__webglFramebuffer))for(let V=0;V<v.__webglFramebuffer.length;V++)e.deleteFramebuffer(v.__webglFramebuffer[V]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let V=0;V<v.__webglColorRenderbuffer.length;V++)if(v.__webglColorRenderbuffer[V])e.deleteRenderbuffer(v.__webglColorRenderbuffer[V])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let I=w.textures;for(let V=0,ie=I.length;V<ie;V++){let ae=i.get(I[V]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(I[V])}i.remove(w)}let O=0;function K(){O=0}function C(){return O}function G(w){O=w}function X(){let w=O;if(w>=r.maxTextures)Re("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+r.maxTextures);return O+=1,w}function z(w){let v=[];return v.push(w.wrapS),v.push(w.wrapT),v.push(w.wrapR||0),v.push(w.magFilter),v.push(w.minFilter),v.push(w.anisotropy),v.push(w.internalFormat),v.push(w.format),v.push(w.type),v.push(w.generateMipmaps),v.push(w.premultiplyAlpha),v.push(w.flipY),v.push(w.unpackAlignment),v.push(w.colorSpace),v.join()}function te(w,v){let I=i.get(w);if(w.isVideoTexture)rn(w);if(w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&I.__version!==w.version){let V=w.image;if(V===null)Re("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Re("WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(I,w,v);return}}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,I.__webglTexture,e.TEXTURE0+v)}function H(w,v){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Pe(I,w,v);return}else if(w.isExternalTexture)I.__webglTexture=w.sourceTexture?w.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,I.__webglTexture,e.TEXTURE0+v)}function Q(w,v){let I=i.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&I.__version!==w.version){Pe(I,w,v);return}n.bindTexture(e.TEXTURE_3D,I.__webglTexture,e.TEXTURE0+v)}function ee(w,v){let I=i.get(w);if(w.isCubeDepthTexture!==!0&&w.version>0&&I.__version!==w.version){Ie(I,w,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,I.__webglTexture,e.TEXTURE0+v)}let Te={[qr]:e.REPEAT,[Yr]:e.CLAMP_TO_EDGE,[Ko]:e.MIRRORED_REPEAT},ve={[On]:e.NEAREST,[Jo]:e.NEAREST_MIPMAP_NEAREST,[lr]:e.NEAREST_MIPMAP_LINEAR,[kt]:e.LINEAR,[jr]:e.LINEAR_MIPMAP_NEAREST,[Yn]:e.LINEAR_MIPMAP_LINEAR},Ge={[wd]:e.NEVER,[Cd]:e.ALWAYS,[Td]:e.LESS,[oa]:e.LEQUAL,[Ed]:e.EQUAL,[aa]:e.GEQUAL,[Ad]:e.GREATER,[Rd]:e.NOTEQUAL};function Me(w,v){if(v.type===xi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===kt||v.magFilter===jr||v.magFilter===lr||v.magFilter===Yn||v.minFilter===kt||v.minFilter===jr||v.minFilter===lr||v.minFilter===Yn))Re("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(w,e.TEXTURE_WRAP_S,Te[v.wrapS]),e.texParameteri(w,e.TEXTURE_WRAP_T,Te[v.wrapT]),w===e.TEXTURE_3D||w===e.TEXTURE_2D_ARRAY)e.texParameteri(w,e.TEXTURE_WRAP_R,Te[v.wrapR]);if(e.texParameteri(w,e.TEXTURE_MAG_FILTER,ve[v.magFilter]),e.texParameteri(w,e.TEXTURE_MIN_FILTER,ve[v.minFilter]),v.compareFunction)e.texParameteri(w,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(w,e.TEXTURE_COMPARE_FUNC,Ge[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===On)return;if(v.minFilter!==lr&&v.minFilter!==Yn)return;if(v.type===xi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let I=t.get("EXT_texture_filter_anisotropic");e.texParameterf(w,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(w,v){let I=!1;if(w.__webglInit===void 0)w.__webglInit=!0,v.addEventListener("dispose",A);let V=v.source,ie=d.get(V);if(ie===void 0)ie={},d.set(V,ie);let ae=z(v);if(ae!==w.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,I=!0;ie[ae].usedTimes++;let ue=ie[w.__cacheKey];if(ue!==void 0){if(ie[w.__cacheKey].usedTimes--,ue.usedTimes===0)F(v)}w.__cacheKey=ae,w.__webglTexture=ie[ae].texture}return I}function re(w,v,I){return Math.floor(Math.floor(w/I)/v)}function se(w,v,I,V){let ae=w.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,I,V,v.data);else{ae.sort((Ae,he)=>Ae.start-he.start);let ue=0;for(let Ae=1;Ae<ae.length;Ae++){let he=ae[ue],oe=ae[Ae],Le=he.start+he.count,De=re(oe.start,v.width,4),Je=re(he.start,v.width,4);if(oe.start<=Le+1&&De===Je&&re(oe.start+oe.count-1,v.width,4)===De)he.count=Math.max(he.count,oe.start+oe.count-he.start);else++ue,ae[ue]=oe}ae.length=ue+1;let q=n.getParameter(e.UNPACK_ROW_LENGTH),J=n.getParameter(e.UNPACK_SKIP_PIXELS),ge=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ae=0,he=ae.length;Ae<he;Ae++){let oe=ae[Ae],Le=Math.floor(oe.start/4),De=Math.ceil(oe.count/4),Je=Le%v.width,D=Math.floor(Le/v.width),ce=De,Y=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,Je),n.pixelStorei(e.UNPACK_SKIP_ROWS,D),n.texSubImage2D(e.TEXTURE_2D,0,Je,D,ce,1,I,V,v.data)}w.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,q),n.pixelStorei(e.UNPACK_SKIP_PIXELS,J),n.pixelStorei(e.UNPACK_SKIP_ROWS,ge)}}function Pe(w,v,I){let V=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)V=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)V=e.TEXTURE_3D;let ie=Z(w,v),ae=v.source;n.bindTexture(V,w.__webglTexture,e.TEXTURE0+I);let ue=i.get(ae);if(ae.version!==ue.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+I),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let Y=We.getPrimaries(We.workingColorSpace),le=v.colorSpace===dr?null:We.getPrimaries(v.colorSpace),_e=v.colorSpace===dr||Y===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,_e)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let J=p(v.image,!1,r.maxTextureSize);J=tt(v,J);let ge=s.convert(v.format,v.colorSpace),Ae=s.convert(v.type),he=S(v.internalFormat,ge,Ae,v.normalized,v.colorSpace,v.isVideoTexture);Me(V,v);let oe,Le=v.mipmaps,De=v.isVideoTexture!==!0,Je=ue.__version===void 0||ie===!0,D=ae.dataReady,ce=T(v,J);if(v.isDepthTexture){if(he=b(v.format===hr,v.type),Je)if(De)n.texStorage2D(e.TEXTURE_2D,1,he,J.width,J.height);else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,null)}else if(v.isDataTexture)if(Le.length>0){if(De&&Je)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data);v.generateMipmaps=!1}else if(De){if(Je)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);if(D)se(v,J,ge,Ae)}else n.texImage2D(e.TEXTURE_2D,0,he,J.width,J.height,0,ge,Ae,J.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(De&&Je)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,Le[0].width,Le[0].height,J.depth);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==Kn)if(ge!==null)if(De){if(D)if(v.layerUpdates.size>0){let _e=cu(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let de=oe.data.subarray(ne*_e/oe.data.BYTES_PER_ELEMENT,(ne+1)*_e/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,ne,oe.width,oe.height,1,ge,de)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,oe.data,0,0);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage3D(e.TEXTURE_2D_ARRAY,Y,0,0,0,oe.width,oe.height,J.depth,ge,Ae,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,Y,he,oe.width,oe.height,J.depth,0,ge,Ae,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(De&&Je)n.texStorage2D(e.TEXTURE_2D,ce,he,Le[0].width,Le[0].height);for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],v.format!==Kn)if(ge!==null)if(De){if(D)n.compressedTexSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,oe.data);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,oe.width,oe.height,ge,Ae,oe.data)}else n.texImage2D(e.TEXTURE_2D,Y,he,oe.width,oe.height,0,ge,Ae,oe.data)}else if(v.isDataArrayTexture)if(De){if(Je)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,he,J.width,J.height,J.depth);if(D)if(v.layerUpdates.size>0){let Y=cu(J.width,J.height,v.format,v.type);for(let le of v.layerUpdates){let _e=J.data.subarray(le*Y/J.data.BYTES_PER_ELEMENT,(le+1)*Y/J.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,J.width,J.height,1,ge,Ae,_e)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isData3DTexture)if(De){if(Je)n.texStorage3D(e.TEXTURE_3D,ce,he,J.width,J.height,J.depth);if(D)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ge,Ae,J.data)}else n.texImage3D(e.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,ge,Ae,J.data);else if(v.isFramebufferTexture){if(Je)if(De)n.texStorage2D(e.TEXTURE_2D,ce,he,J.width,J.height);else{let Y=J.width,le=J.height;for(let _e=0;_e<ce;_e++)n.texImage2D(e.TEXTURE_2D,_e,he,Y,le,0,ge,Ae,null),Y>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let Y=e.canvas;if(!Y.hasAttribute("layoutsubtree"))Y.setAttribute("layoutsubtree","true");if(J.parentNode!==Y){Y.appendChild(J),f.add(v),Y.onpaint=(le)=>{let _e=le.changedElements;for(let ne of f)if(_e.includes(ne.image))ne.needsUpdate=!0},Y.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,J);else{let{RGBA:_e,RGBA:ne,UNSIGNED_BYTE:de}=e;e.texElementImage2D(e.TEXTURE_2D,0,_e,ne,de,J)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Le.length>0){if(De&&Je){let Y=yt(Le[0]);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}for(let Y=0,le=Le.length;Y<le;Y++)if(oe=Le[Y],De){if(D)n.texSubImage2D(e.TEXTURE_2D,Y,0,0,ge,Ae,oe)}else n.texImage2D(e.TEXTURE_2D,Y,he,ge,Ae,oe);v.generateMipmaps=!1}else if(De){if(Je){let Y=yt(J);n.texStorage2D(e.TEXTURE_2D,ce,he,Y.width,Y.height)}if(D)n.texSubImage2D(e.TEXTURE_2D,0,0,0,ge,Ae,J)}else n.texImage2D(e.TEXTURE_2D,0,he,ge,Ae,J);if(m(v))E(V);if(ue.__version=ae.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function Ie(w,v,I){if(v.image.length!==6)return;let V=Z(w,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,w.__webglTexture,e.TEXTURE0+I);let ae=i.get(ie);if(ie.version!==ae.__version||V===!0){n.activeTexture(e.TEXTURE0+I);let ue=We.getPrimaries(We.workingColorSpace),q=v.colorSpace===dr?null:We.getPrimaries(v.colorSpace),J=v.colorSpace===dr||ue===q?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,J);let ge=v.isCompressedTexture||v.image[0].isCompressedTexture,Ae=v.image[0]&&v.image[0].isDataTexture,he=[];for(let ne=0;ne<6;ne++){if(!ge&&!Ae)he[ne]=p(v.image[ne],!0,r.maxCubemapSize);else he[ne]=Ae?v.image[ne].image:v.image[ne];he[ne]=tt(v,he[ne])}let oe=he[0],Le=s.convert(v.format,v.colorSpace),De=s.convert(v.type),Je=S(v.internalFormat,Le,De,v.normalized,v.colorSpace),D=v.isVideoTexture!==!0,ce=ae.__version===void 0||V===!0,Y=ie.dataReady,le=T(v,oe);Me(e.TEXTURE_CUBE_MAP,v);let _e;if(ge){if(D&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Je,oe.width,oe.height);for(let ne=0;ne<6;ne++){_e=he[ne].mipmaps;for(let de=0;de<_e.length;de++){let ke=_e[de];if(v.format!==Kn)if(Le!==null)if(D){if(Y)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,ke.width,ke.height,Le,ke.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Je,ke.width,ke.height,0,ke.data);else Re("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,0,0,ke.width,ke.height,Le,De,ke.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de,Je,ke.width,ke.height,0,Le,De,ke.data)}}}else{if(_e=v.mipmaps,D&&ce){if(_e.length>0)le++;let ne=yt(he[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,Je,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ae){if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,he[ne].width,he[ne].height,Le,De,he[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Je,he[ne].width,he[ne].height,0,Le,De,he[ne].data);for(let de=0;de<_e.length;de++){let ft=_e[de].image[ne].image;if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,ft.width,ft.height,Le,De,ft.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Je,ft.width,ft.height,0,Le,De,ft.data)}}else{if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Le,De,he[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,Je,Le,De,he[ne]);for(let de=0;de<_e.length;de++){let ke=_e[de];if(D){if(Y)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,0,0,Le,De,ke.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,de+1,Je,Le,De,ke.image[ne])}}}if(m(v))E(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}w.__version=v.version}function we(w,v,I,V,ie,ae){let ue=s.convert(I.format,I.colorSpace),q=s.convert(I.type),J=S(I.internalFormat,ue,q,I.normalized,I.colorSpace),ge=i.get(v),Ae=i.get(I);if(Ae.__renderTarget=v,!ge.__hasExternalTextures){let he=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,J,he,oe,v.depth,0,ue,q,null);else n.texImage2D(ie,ae,J,he,oe,0,ue,q,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,w),L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,V,ie,Ae.__webglTexture,0,It(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,V,ie,Ae.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function mt(w,v,I){if(e.bindRenderbuffer(e.RENDERBUFFER,w),v.depthBuffer){let V=v.depthTexture,ie=V&&V.isDepthTexture?V.type:null,ae=b(v.stencilBuffer,ie),ue=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(v),ae,v.width,v.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ue,e.RENDERBUFFER,w)}else{let V=v.textures;for(let ie=0;ie<V.length;ie++){let ae=V[ie],ue=s.convert(ae.format,ae.colorSpace),q=s.convert(ae.type),J=S(ae.internalFormat,ue,q,ae.normalized,ae.colorSpace);if(L(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,It(v),J,v.width,v.height);else if(I)e.renderbufferStorageMultisample(e.RENDERBUFFER,It(v),J,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,J,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function ze(w,v,I){let V=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,w),!(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(V){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",A);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v.depthTexture);let ge=s.convert(v.depthTexture.format),Ae=s.convert(v.depthTexture.type),he;if(v.depthTexture.format===ur)he=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===hr)he=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,he,v.width,v.height,0,ge,Ae,null)}}else te(v.depthTexture,0);let ae=ie.__webglTexture,ue=It(v),q=V?e.TEXTURE_CUBE_MAP_POSITIVE_X+I:e.TEXTURE_2D,J=v.depthTexture.format===hr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===ur)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else if(v.depthTexture.format===hr)if(L(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,J,q,ae,0,ue);else e.framebufferTexture2D(e.FRAMEBUFFER,J,q,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(w){let v=i.get(w),I=w.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==w.depthTexture){let V=w.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(V){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,V.removeEventListener("dispose",ie)};V.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=V}if(w.depthTexture&&!v.__autoAllocateDepthBuffer)if(I)for(let V=0;V<6;V++)ze(v.__webglFramebuffer[V],w,V);else{let V=w.texture.mipmaps;if(V&&V.length>0)ze(v.__webglFramebuffer[0],w,0);else ze(v.__webglFramebuffer,w,0)}else if(I){v.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[V]),v.__webglDepthbuffer[V]===void 0)v.__webglDepthbuffer[V]=e.createRenderbuffer(),mt(v.__webglDepthbuffer[V],w,!1);else{let ie=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[V];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let V=w.texture.mipmaps;if(V&&V.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),mt(v.__webglDepthbuffer,w,!1);else{let ie=w.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 rt(w,v,I){let V=i.get(w);if(v!==void 0)we(V.__webglFramebuffer,w,w.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(I!==void 0)Ze(w)}function je(w){let v=w.texture,I=i.get(w),V=i.get(v);w.addEventListener("dispose",_);let ie=w.textures,ae=w.isWebGLCubeRenderTarget===!0,ue=ie.length>1;if(!ue){if(V.__webglTexture===void 0)V.__webglTexture=e.createTexture();V.__version=v.version,o.memory.textures++}if(ae){I.__webglFramebuffer=[];for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0){I.__webglFramebuffer[q]=[];for(let J=0;J<v.mipmaps.length;J++)I.__webglFramebuffer[q][J]=e.createFramebuffer()}else I.__webglFramebuffer[q]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){I.__webglFramebuffer=[];for(let q=0;q<v.mipmaps.length;q++)I.__webglFramebuffer[q]=e.createFramebuffer()}else I.__webglFramebuffer=e.createFramebuffer();if(ue)for(let q=0,J=ie.length;q<J;q++){let ge=i.get(ie[q]);if(ge.__webglTexture===void 0)ge.__webglTexture=e.createTexture(),o.memory.textures++}if(w.samples>0&&L(w)===!1){I.__webglMultisampledFramebuffer=e.createFramebuffer(),I.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let q=0;q<ie.length;q++){let J=ie[q];I.__webglColorRenderbuffer[q]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,I.__webglColorRenderbuffer[q]);let ge=s.convert(J.format,J.colorSpace),Ae=s.convert(J.type),he=S(J.internalFormat,ge,Ae,J.normalized,J.colorSpace,w.isXRRenderTarget===!0),oe=It(w);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,he,w.width,w.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+q,e.RENDERBUFFER,I.__webglColorRenderbuffer[q])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),w.depthBuffer)I.__webglDepthRenderbuffer=e.createRenderbuffer(),mt(I.__webglDepthRenderbuffer,w,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture),Me(e.TEXTURE_CUBE_MAP,v);for(let q=0;q<6;q++)if(v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(I.__webglFramebuffer[q][J],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else we(I.__webglFramebuffer[q],w,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);if(m(v))E(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ue){for(let q=0,J=ie.length;q<J;q++){let ge=ie[q],Ae=i.get(ge),he=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)he=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(he,Ae.__webglTexture),Me(he,ge),we(I.__webglFramebuffer,w,ge,e.COLOR_ATTACHMENT0+q,he,0),m(ge))E(he)}n.unbindTexture()}else{let q=e.TEXTURE_2D;if(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)q=w.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(q,V.__webglTexture),Me(q,v),v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)we(I.__webglFramebuffer[J],w,v,e.COLOR_ATTACHMENT0,q,J);else we(I.__webglFramebuffer,w,v,e.COLOR_ATTACHMENT0,q,0);if(m(v))E(q);n.unbindTexture()}if(w.depthBuffer)Ze(w)}function Gt(w){let v=w.textures;for(let I=0,V=v.length;I<V;I++){let ie=v[I];if(m(ie)){let ae=R(w),ue=i.get(ie).__webglTexture;n.bindTexture(ae,ue),E(ae),n.unbindTexture()}}}let gt=[],nn=[];function Pt(w){if(w.samples>0){if(L(w)===!1){let{textures:v,width:I,height:V}=w,ie=e.COLOR_BUFFER_BIT,ae=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ue=i.get(w),q=v.length>1;if(q)for(let ge=0;ge<v.length;ge++)n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer);let J=w.texture.mipmaps;if(J&&J.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let ge=0;ge<v.length;ge++){if(w.resolveDepthBuffer){if(w.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(w.stencilBuffer&&w.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(q){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ae,0)}if(e.blitFramebuffer(0,0,I,V,0,0,I,V,ie,e.NEAREST),c===!0){if(gt.length=0,nn.length=0,gt.push(e.COLOR_ATTACHMENT0+ge),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1)gt.push(ae),nn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,nn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,gt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),q)for(let ge=0;ge<v.length;ge++){n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.RENDERBUFFER,ue.__webglColorRenderbuffer[ge]);let Ae=i.get(v[ge]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ue.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+ge,e.TEXTURE_2D,Ae,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let v=w.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function It(w){return Math.min(r.maxSamples,w.samples)}function L(w){let v=i.get(w);return w.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function rn(w){let v=o.render.frame;if(u.get(w)!==v)u.set(w,v),w.update()}function tt(w,v){let{colorSpace:I,format:V,type:ie}=w;if(w.isCompressedTexture===!0||w.isVideoTexture===!0)return v;if(I!==hn&&I!==dr)if(We.getTransfer(I)===ht){if(V!==Kn||ie!==Un)Re("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ue("WebGLTextures: Unsupported texture color space:",I);return v}function yt(w){if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement)l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height;else if(typeof VideoFrame<"u"&&w instanceof VideoFrame)l.width=w.displayWidth,l.height=w.displayHeight;else l.width=w.width,l.height=w.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=C,this.setTextureUnits=G,this.setTexture2D=te,this.setTexture2DArray=H,this.setTexture3D=Q,this.setTextureCube=ee,this.rebindTextures=rt,this.setupRenderTarget=je,this.updateRenderTargetMipmap=Gt,this.updateMultisampleRenderTarget=Pt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=we,this.useMultisampledRTT=L,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function qw(e,t){function n(i,r=dr){let s,o=We.getTransfer(r);if(i===Un)return e.UNSIGNED_BYTE;if(i===el)return e.UNSIGNED_SHORT_4_4_4_4;if(i===tl)return e.UNSIGNED_SHORT_5_5_5_1;if(i===xd)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===vd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===gd)return e.BYTE;if(i===_d)return e.SHORT;if(i===Cs)return e.UNSIGNED_SHORT;if(i===Qc)return e.INT;if(i===ki)return e.UNSIGNED_INT;if(i===xi)return e.FLOAT;if(i===jn)return e.HALF_FLOAT;if(i===yd)return e.ALPHA;if(i===Sd)return e.RGB;if(i===Kn)return e.RGBA;if(i===ur)return e.DEPTH_COMPONENT;if(i===hr)return e.DEPTH_STENCIL;if(i===bd)return e.RED;if(i===nl)return e.RED_INTEGER;if(i===fr)return e.RG;if(i===il)return e.RG_INTEGER;if(i===rl)return e.RGBA_INTEGER;if(i===Qo||i===ea||i===ta||i===na)if(o===ht)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Qo)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ea)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ta)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===na)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Qo)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ea)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ta)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===na)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===sl||i===ol||i===al||i===cl)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===sl)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ol)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===al)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===cl)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ll||i===ul||i===hl||i===fl||i===dl||i===ia||i===pl)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ll||i===ul)return o===ht?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===hl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===fl)return s.COMPRESSED_R11_EAC;if(i===dl)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ia)return s.COMPRESSED_RG11_EAC;if(i===pl)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===ml||i===gl||i===_l||i===xl||i===vl||i===yl||i===Sl||i===bl||i===Ml||i===wl||i===Tl||i===El||i===Al||i===Rl)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===ml)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===gl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===_l)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===xl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===vl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===yl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Sl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===bl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ml)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===wl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Tl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===El)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Al)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Rl)return o===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Cl||i===Pl||i===Il)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Cl)return o===ht?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Pl)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Il)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ll||i===Nl||i===ra||i===Dl)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ll)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Nl)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ra)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Dl)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Kr)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var Yw=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,Xw=`
+}`,jw=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4341,11 +4341,11 @@ void main() {
}
-}`;class vp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ga(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Tn({vertexShader:Zw,fragmentShader:Xw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new pt(new Gs(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class yp extends Fn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new vp,p={},m=t.getContextAttributes(),E=null,R=null,S=[],b=[],T=new Ne,A=null,_=null,M=new Lt;M.viewport=new ot;let F=new Lt;F.viewport=new ot;let P=[M,F],O=new nu,K=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getHandSpace()};function G(Z){let re=b.indexOf(Z.inputSource);if(re===-1)return;let se=S[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",z);for(let Z=0;Z<S.length;Z++){let re=b[Z];if(re===null)continue;b[Z]=null,S[Z].disconnect(re)}K=null,C=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Re("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Re("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",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",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new fn(h.framebufferWidth,h.framebufferHeight,{format:Kn,type:Un,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Pe=null,Ie=null;if(m.depth)Ie=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?hr:ur,Pe=m.stencil?Kr:ki;let we={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(we),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new fn(f.textureWidth,f.textureHeight,{format:Kn,type:Un,depthTexture:new pr(f.textureWidth,f.textureHeight,Pe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],Pe=b.indexOf(se);if(Pe>=0)b[Pe]=null,S[Pe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],Pe=b.indexOf(se);if(Pe===-1){for(let we=0;we<S.length;we++)if(we>=b.length){b.push(se),Pe=we;break}else if(b[we]===null){b[we]=se,Pe=we;break}if(Pe===-1)break}let Ie=S[Pe];if(Ie)Ie.connect(se)}}let te=new U,H=new U;function Q(Z,re,se){te.setFromMatrixPosition(re.matrixWorld),H.setFromMatrixPosition(se.matrixWorld);let Pe=te.distanceTo(H),Ie=re.projectionMatrix.elements,we=se.projectionMatrix.elements,mt=Ie[14]/(Ie[10]-1),ze=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],rt=(Ie[9]-1)/Ie[5],je=(Ie[8]-1)/Ie[0],Gt=(we[8]+1)/we[0],gt=mt*je,nn=mt*Gt,Pt=Pe/(-je+Gt),It=Pt*-je;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(It),Z.translateZ(Pt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ie[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=mt+Pt,rn=ze+Pt,tt=gt-It,yt=nn+(Pe-It),w=Ze*ze/rn*L,v=rt*ze/rn*L;Z.projectionMatrix.makePerspective(tt,yt,w,v,L,rn),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(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(O.near=F.near=M.near=re,O.far=F.far=M.far=se,K!==O.near||C!==O.far)i.updateRenderState({depthNear:O.near,depthFar:O.far}),K=O.near,C=O.far;O.layers.mask=Z.layers.mask|6,M.layers.mask=O.layers.mask&-5,F.layers.mask=O.layers.mask&-3;let Pe=Z.parent,Ie=O.cameras;ee(O,Pe);for(let we=0;we<Ie.length;we++)ee(Ie[we],Pe);if(Ie.length===2)Q(O,M,F);else O.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Te(Z,O,Pe)};function Te(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=ar*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return O},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(Z){return p[Z]};let ve=null;function Ge(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Pe=!1;if(se.length!==O.cameras.length)O.cameras.length=0,Pe=!0;for(let ze=0;ze<se.length;ze++){let Ze=se[ze],rt=null;if(h!==null)rt=h.getViewport(Ze);else{let Gt=u.getViewSubImage(f,Ze);if(rt=Gt.viewport,ze===0)e.setRenderTargetTextures(R,Gt.colorTexture,Gt.depthStencilTexture),e.setRenderTarget(R)}let je=P[ze];if(je===void 0)je=new Lt,je.layers.enable(ze),je.viewport=new ot,P[ze]=je;if(je.matrix.fromArray(Ze.transform.matrix),je.matrix.decompose(je.position,je.quaternion,je.scale),je.projectionMatrix.fromArray(Ze.projectionMatrix),je.projectionMatrixInverse.copy(je.projectionMatrix).invert(),je.viewport.set(rt.x,rt.y,rt.width,rt.height),ze===0)O.matrix.copy(je.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale);if(Pe===!0)O.cameras.push(je)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ze=u.getDepthInformation(se[0]);if(ze&&ze.isValid&&ze.texture)x.init(ze,i.renderState)}if(Ie&&Ie.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ze=0;ze<se.length;ze++){let Ze=se[ze].camera;if(Ze){let rt=p[Ze];if(!rt)rt=new ga,p[Ze]=rt;let je=u.getCameraImage(Ze);rt.sourceTexture=je}}}}for(let se=0;se<S.length;se++){let Pe=b[se],Ie=S[se];if(Pe!==null&&Ie!==void 0)Ie.update(Pe,re,c||s)}if(ve)ve(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new cp;Me.setAnimationLoop(Ge),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}}var qw=new Be,Sp=new Fe;Sp.set(-1,0,0,0,1,0,0,0,1);function Yw(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,Zl(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,S){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,S)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Xt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Xt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:S}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(qw.makeRotationFromEuler(S)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Sp);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Xt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function jw(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,b){let T=b.program;i.uniformBlockBinding(S,T)}function l(S,b){let T=r[S.id];if(T===void 0)p(S),T=u(S),r[S.id]=T,S.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(S,A);let _=t.render.frame;if(s[S.id]!==_)h(S),s[S.id]=_}function u(S){let b=f();S.__bindingPointIndex=b;let T=e.createBuffer(),{__size:A,usage:_}=S;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,T),T}function f(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){let b=r[S.id],{uniforms:T,__cache:A}=S;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=T.length;_<M;_++){let F=T[_];if(Array.isArray(F))for(let P=0,O=F.length;P<O;P++)d(F[P],_,P,A);else d(F,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(S,b,T,A){if(x(S,b,T,A)===!0){let{__offset:_,value:M}=S;if(Array.isArray(M)){let F=0;for(let P=0;P<M.length;P++){let O=M[P],K=m(O);if(g(O,S.__data,F),typeof O!=="number"&&typeof O!=="boolean"&&!O.isMatrix3&&!ArrayBuffer.isView(O))F+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else g(M,S.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,S.__data)}}function g(S,b,T){if(typeof S==="number"||typeof S==="boolean")b[0]=S;else if(S.isMatrix3)b[0]=S.elements[0],b[1]=S.elements[1],b[2]=S.elements[2],b[3]=0,b[4]=S.elements[3],b[5]=S.elements[4],b[6]=S.elements[5],b[7]=0,b[8]=S.elements[6],b[9]=S.elements[7],b[10]=S.elements[8],b[11]=0;else if(ArrayBuffer.isView(S))b.set(new S.constructor(S.buffer,S.byteOffset,b.length));else S.toArray(b,T)}function x(S,b,T,A){let _=S.value,M=b+"_"+T;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let F=A[M];if(typeof _==="number"||typeof _==="boolean"){if(F!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(F.equals(_)===!1)return F.copy(_),!0}return!1}function p(S){let b=S.uniforms,T=0,A=16;for(let M=0,F=b.length;M<F;M++){let P=Array.isArray(b[M])?b[M]:[b[M]];for(let O=0,K=P.length;O<K;O++){let C=P[O],G=Array.isArray(C.value)?C.value:[C.value];for(let X=0,z=G.length;X<z;X++){let te=G[X],H=m(te),Q=T%A,ee=Q%H.boundary,Te=Q+ee;if(T+=ee,Te!==0&&A-Te<H.storage)T+=A-Te;C.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=T,T+=H.storage}}}let _=T%A;if(_>0)T+=A-_;return S.__size=T,S.__cache={},this}function m(S){let b={boundary:0,storage:0};if(typeof S==="number"||typeof S==="boolean")b.boundary=4,b.storage=4;else if(S.isVector2)b.boundary=8,b.storage=8;else if(S.isVector3||S.isColor)b.boundary=16,b.storage=12;else if(S.isVector4)b.boundary=16,b.storage=16;else if(S.isMatrix3)b.boundary=48,b.storage=48;else if(S.isMatrix4)b.boundary=64,b.storage=64;else if(S.isTexture)Re("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(S))b.boundary=16,b.storage=S.byteLength;else Re("WebGLRenderer: Unsupported uniform value type.",S);return b}function E(S){let b=S.target;b.removeEventListener("dispose",E);let T=o.indexOf(b.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function R(){for(let S in r)e.deleteBuffer(r[S]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var Kw=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]),Qn=null;function Jw(){if(Qn===null)Qn=new Us(Kw,16,16,fr,jn),Qn.name="DFG_LUT",Qn.minFilter=kt,Qn.magFilter=kt,Qn.wrapS=Yr,Qn.wrapT=Yr,Qn.generateMipmaps=!1,Qn.needsUpdate=!0;return Qn}class xu{constructor(e={}){let{canvas:t=Rd(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Un}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([rl,il,nl]),p=new Set([Un,ki,Cs,Kr,el,tl]),m=new Uint32Array(4),E=new Int32Array(4),R=new U,S=null,b=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Dn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,F=!1,P=null,O=null,K=null,C=null;this._outputColorSpace=Bi;let G=0,X=0,z=null,te=-1,H=null,Q=new ot,ee=new ot,Te=null,ve=new Oe(0),Ge=0,{width:Me,height:Z}=t,re=1,se=null,Pe=null,Ie=new ot(0,0,Me,Z),we=new ot(0,0,Me,Z),mt=!1,ze=new zs,Ze=!1,rt=!1,je=new Be,Gt=new U,gt=new ot,nn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Pt=!1;function It(){return z===null?re:1}let L=n;function rn(y,N){return t.getContext(y,N)}let tt,yt,w,v,I,V,ie,ae,ue,q,J,ge,Ae,he,oe,Le,De,Je,D,ce,Y,le,_e;try{let y={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${Df}`);if(t.addEventListener("webglcontextlost",ke,!1),t.addEventListener("webglcontextrestored",ft,!1),t.addEventListener("webglcontextcreationerror",nt,!1),L===null){if(L=rn("webgl2",y),L===null)if(rn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(y){throw t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",ft,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Ue("WebGLRenderer: "+y.message),y}function ne(){if(tt=new sM(L),tt.init(),Y=new $w(L,tt),yt=new Yb(L,tt,e,Y),w=new Vw(L,tt),yt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);O=L.createFramebuffer(),K=L.createFramebuffer(),C=L.createFramebuffer(),v=new cM(L),I=new Cw,V=new Ww(L,tt,w,I,yt,Y,v),ie=new rM(M),ae=new uy(L),le=new Xb(L,ae),ue=new oM(L,ae,v,le),q=new uM(L,ue,ae,le,v),Je=new lM(L,yt,V),oe=new jb(I),J=new Rw(M,ie,tt,yt,le,oe),ge=new Yw(M,I),Ae=new Iw,he=new Fw(tt),De=new Zb(M,ie,w,q,d,a),Le=new Hw(M,q,yt),_e=new jw(L,v,yt,w),D=new qb(L,tt,v),ce=new aM(L,tt,v),v.programs=J.programs,M.capabilities=yt,M.extensions=tt,M.properties=I,M.renderLists=Ae,M.shadowMap=Le,M.state=w,M.info=v}if(g!==Un)_=new fM(g,t.width,t.height,o,i,r);let de=new yp(M,L);this.xr=de,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let y=tt.get("WEBGL_lose_context");if(y)y.loseContext()},this.forceContextRestore=function(){let y=tt.get("WEBGL_lose_context");if(y)y.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(y){if(y===void 0)return;re=y,this.setSize(Me,Z,!1)},this.getSize=function(y){return y.set(Me,Z)},this.setSize=function(y,N,W=!0){if(de.isPresenting){Re("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=y,Z=N,t.width=Math.floor(y*re),t.height=Math.floor(N*re),W===!0)t.style.width=y+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(y,N,W){Me=y,Z=N,re=W,t.width=Math.floor(y*W),t.height=Math.floor(N*W),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(g===Un){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Re("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(Q)},this.getViewport=function(y){return y.copy(Ie)},this.setViewport=function(y,N,W,k){if(y.isVector4)Ie.set(y.x,y.y,y.z,y.w);else Ie.set(y,N,W,k);w.viewport(Q.copy(Ie).multiplyScalar(re).round())},this.getScissor=function(y){return y.copy(we)},this.setScissor=function(y,N,W,k){if(y.isVector4)we.set(y.x,y.y,y.z,y.w);else we.set(y,N,W,k);w.scissor(ee.copy(we).multiplyScalar(re).round())},this.getScissorTest=function(){return mt},this.setScissorTest=function(y){w.setScissorTest(mt=y)},this.setOpaqueSort=function(y){se=y},this.setTransparentSort=function(y){Pe=y},this.getClearColor=function(y){return y.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,W=!0){let k=0;if(y){let B=!1;if(z!==null){let me=z.texture.format;B=x.has(me)}if(B){let me=z.texture.type,ye=p.has(me),pe=De.getClearColor(),Se=De.getClearAlpha(),{r:Ee,g:He,b:qe}=pe;if(ye)m[0]=Ee,m[1]=He,m[2]=qe,m[3]=Se,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ee,E[1]=He,E[2]=qe,E[3]=Se,L.clearBufferiv(L.COLOR,0,E)}else k|=L.COLOR_BUFFER_BIT}if(N)k|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)k|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(k!==0)L.clear(k)},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(y){y.setRenderer(this),P=y},this.dispose=function(){t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",ft,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),De.dispose(),Ae.dispose(),he.dispose(),I.dispose(),ie.dispose(),q.dispose(),le.dispose(),_e.dispose(),J.dispose(),de.dispose(),de.removeEventListener("sessionstart",Gh),de.removeEventListener("sessionend",Hh),tr.stop()};function ke(y){y.preventDefault(),ws("WebGLRenderer: Context Lost."),F=!0}function ft(){ws("WebGLRenderer: Context Restored."),F=!1;let y=v.autoReset,N=Le.enabled,W=Le.autoUpdate,k=Le.needsUpdate,B=Le.type;ne(),v.autoReset=y,Le.enabled=N,Le.autoUpdate=W,Le.needsUpdate=k,Le.type=B}function nt(y){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Hn(y){let N=y.target;N.removeEventListener("dispose",Hn),ui(N)}function ui(y){ev(y),I.remove(y)}function ev(y){let N=I.get(y).programs;if(N!==void 0){if(N.forEach(function(W){J.releaseProgram(W)}),y.isShaderMaterial)J.releaseShaderCache(y)}}this.renderBufferDirect=function(y,N,W,k,B,me){if(N===null)N=nn;let ye=B.isMesh&&B.matrixWorld.determinantAffine()<0,pe=iv(y,N,W,k,B);w.setMaterial(k,ye);let Se=W.index,Ee=1;if(k.wireframe===!0){if(Se=ue.getWireframeAttribute(W),Se===void 0)return;Ee=2}let He=W.drawRange,qe=W.attributes.position,be=He.start*Ee,it=(He.start+He.count)*Ee;if(me!==null)be=Math.max(be,me.start*Ee),it=Math.min(it,(me.start+me.count)*Ee);if(Se!==null)be=Math.max(be,0),it=Math.min(it,Se.count);else if(qe!==void 0&&qe!==null)be=Math.max(be,0),it=Math.min(it,qe.count);let Rt=it-be;if(Rt<0||Rt===1/0)return;le.setup(B,k,pe,W,Se);let _t,ut=D;if(Se!==null)_t=ae.get(Se),ut=ce,ut.setIndex(_t);if(B.isMesh)if(k.wireframe===!0)w.setLineWidth(k.wireframeLinewidth*It()),ut.setMode(L.LINES);else ut.setMode(L.TRIANGLES);else if(B.isLine){let Wt=k.linewidth;if(Wt===void 0)Wt=1;if(w.setLineWidth(Wt*It()),B.isLineSegments)ut.setMode(L.LINES);else if(B.isLineLoop)ut.setMode(L.LINE_LOOP);else ut.setMode(L.LINE_STRIP)}else if(B.isPoints)ut.setMode(L.POINTS);else if(B.isSprite)ut.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(!tt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Wt,_multiDrawCounts:xe,_multiDrawCount:Jt}=B,Ke=Se?ae.get(Se).bytesPerElement:1,yn=I.get(k).currentProgram.getUniforms();for(let Vn=0;Vn<Jt;Vn++)yn.setValue(L,"_gl_DrawID",Vn),ut.render(Wt[Vn]/Ke,xe[Vn])}else ut.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else if(B.isInstancedMesh)ut.renderInstances(be,Rt,B.count);else if(W.isInstancedBufferGeometry){let Wt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,Wt);ut.renderInstances(be,Rt,xe)}else ut.render(be,Rt)};function Bh(y,N,W,k){if(P!==null&&y.isNodeMaterial)P.setObject(k,y);if(Ze===!0)oe.setState(y,W,!1);if(y.transparent===!0&&y.side===wn&&y.forceSinglePass===!1)y.side=Xt,y.needsUpdate=!0,yo(y,N,k),y.side=zi,y.needsUpdate=!0,yo(y,N,k),y.side=wn;else yo(y,N,k)}this.compile=function(y,N,W=null){if(W===null)W=y;if(P!==null)P.renderStart(y,N,W);if(b=he.get(W),b.init(N),A.push(b),W.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}}),y!==W)y.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}});if(b.setupLights(),P!==null)P.updateLights(b.state.lightsArray);if(rt=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,rt),Ze===!0)oe.setGlobalState(this.clippingPlanes,N);if(P!==null)Le.render(b.state.shadowsArray,W,N);let k=new Set;if(y.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let me=B.material;if(me)if(Array.isArray(me))for(let ye=0;ye<me.length;ye++){let pe=me[ye];Bh(pe,W,N,B),k.add(pe)}else Bh(me,W,N,B),k.add(me)}),b=A.pop(),P!==null)P.renderEnd();return k},this.compileAsync=function(y,N,W=null){let k=this.compile(y,N,W);return new Promise((B)=>{function me(){if(k.forEach(function(ye){let Se=I.get(ye).currentProgram;if(Se===void 0||Se.isReady())k.delete(ye)}),k.size===0){B(y);return}setTimeout(me,10)}if(tt.get("KHR_parallel_shader_compile")!==null)me();else setTimeout(me,10)})};let mc=null;function tv(y){if(mc)mc(y)}function Gh(){tr.stop()}function Hh(){tr.start()}let tr=new cp;if(tr.setAnimationLoop(tv),typeof self<"u")tr.setContext(self);this.setAnimationLoop=function(y){mc=y,de.setAnimationLoop(y),y===null?tr.stop():tr.start()},de.addEventListener("sessionstart",Gh),de.addEventListener("sessionend",Hh),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;if(P!==null)P.renderStart(y,N);let W=de.enabled===!0&&de.isPresenting===!0,k=_!==null&&(z===null||W)&&_.begin(M,z);if(y.matrixWorldAutoUpdate===!0)y.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(de.enabled===!0&&de.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(de.cameraAutoUpdate===!0)de.updateCamera(N);N=de.getCamera()}if(y.isScene===!0)y.onBeforeRender(M,y,N,z);if(b=he.get(y,A.length),b.init(N),b.state.textureUnits=V.getTextureUnits(),A.push(b),je.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ze.setFromProjectionMatrix(je,Bl,N.reversedDepth),rt=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,rt),S=Ae.get(y,T.length),S.init(),T.push(S),de.enabled===!0&&de.isPresenting===!0){let ye=M.xr.getDepthSensingMesh();if(ye!==null)gc(ye,N,-1/0,M.sortObjects)}if(gc(y,N,0,M.sortObjects),S.finish(),P!==null)P.updateLights(b.state.lightsArray);if(M.sortObjects===!0)S.sort(se,Pe);if(Pt=de.enabled===!1||de.isPresenting===!1||de.hasDepthSensing()===!1,Pt)De.addToRenderList(S,y);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let B=b.state.shadowsArray;if(Le.render(B,y,N),Ze===!0)oe.endShadows();if((k&&_.hasRenderPass())===!1){let ye=S.opaque,pe=S.transmissive;if(b.setupLights(),N.isArrayCamera){let Se=N.cameras;if(pe.length>0)for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee];Wh(ye,pe,y,qe)}if(Pt)De.render(y);for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee];Vh(S,y,qe,qe.viewport)}}else{if(pe.length>0)Wh(ye,pe,y,N);if(Pt)De.render(y);Vh(S,y,N)}}if(z!==null&&X===0)V.updateMultisampleRenderTarget(z),V.updateRenderTargetMipmap(z);if(k)_.end(M);if(y.isScene===!0)y.onAfterRender(M,y,N);if(le.resetDefaultState(),te=-1,H=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Ze===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(T.pop(),T.length>0)S=T[T.length-1];else S=null;if(P!==null)P.renderEnd()};function gc(y,N,W,k){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)W=y.renderOrder;else if(y.isLOD){if(y.autoUpdate===!0)y.update(N)}else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight){if(b.pushLight(y),y.castShadow)b.pushShadow(y)}else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(ze)){if(k)gt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(je);let ye=q.update(y),pe=y.material;if(pe.visible)S.push(y,ye,pe,W,gt.z,null,N)}}else if(y.isMesh||y.isLine||y.isPoints){if(!y.frustumCulled||y.intersectsFrustum(ze)){let ye=q.update(y),pe=y.material;if(k){if(y.boundingSphere!==void 0){if(y.boundingSphere===null)y.computeBoundingSphere();gt.copy(y.boundingSphere.center)}else{if(ye.boundingSphere===null)ye.computeBoundingSphere();gt.copy(ye.boundingSphere.center)}gt.applyMatrix4(y.matrixWorld).applyMatrix4(je)}if(Array.isArray(pe)){let Se=ye.groups;for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee],be=pe[qe.materialIndex];if(be&&be.visible)S.push(y,ye,be,W,gt.z,qe,N)}}else if(pe.visible)S.push(y,ye,pe,W,gt.z,null,N)}}}let me=y.children;for(let ye=0,pe=me.length;ye<pe;ye++)gc(me[ye],N,W,k)}function Vh(y,N,W,k){let{opaque:B,transmissive:me,transparent:ye}=y;if(b.setupLightsView(W),Ze===!0)oe.setGlobalState(M.clippingPlanes,W);if(k)w.viewport(Q.copy(k));if(B.length>0)vo(B,N,W);if(me.length>0)vo(me,N,W);if(ye.length>0)vo(ye,N,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function Wh(y,N,W,k){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new fn(1,1,{generateMipmaps:!0,type:be?jn:Un,minFilter:Yn,samples:Math.max(4,yt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:We.workingColorSpace})}let me=b.state.transmissionRenderTarget[k.id],ye=k.viewport||Q;me.setSize(ye.z*M.transmissionResolutionScale,ye.w*M.transmissionResolutionScale);let pe=M.getRenderTarget(),Se=M.getActiveCubeFace(),Ee=M.getActiveMipmapLevel();if(M.setRenderTarget(me),M.getClearColor(ve),Ge=M.getClearAlpha(),Ge<1)M.setClearColor(16777215,0.5);if(M.clear(),Pt)De.render(W);let He=M.toneMapping;M.toneMapping=Dn;let qe=k.viewport;if(k.viewport!==void 0)k.viewport=void 0;if(b.setupLightsView(k),Ze===!0)oe.setGlobalState(M.clippingPlanes,k);if(vo(y,W,k),V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me),tt.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let it=0,Rt=N.length;it<Rt;it++){let _t=N[it],{object:ut,geometry:Wt,material:xe,group:Jt}=_t;if(xe.side===wn&&ut.layers.test(k.layers)){let Ke=xe.side;xe.side=Xt,xe.needsUpdate=!0,$h(ut,W,k,Wt,xe,Jt),xe.side=Ke,xe.needsUpdate=!0,be=!0}}if(be===!0)V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me)}if(M.setRenderTarget(pe,Se,Ee),M.setClearColor(ve,Ge),qe!==void 0)k.viewport=qe;M.toneMapping=He}function vo(y,N,W){let k=N.isScene===!0?N.overrideMaterial:null;for(let B=0,me=y.length;B<me;B++){let ye=y[B],{object:pe,geometry:Se,group:Ee}=ye,He=ye.material;if(He.allowOverride===!0&&k!==null)He=k;if(pe.layers.test(W.layers))$h(pe,N,W,Se,He,Ee)}}function $h(y,N,W,k,B,me){if(P!==null&&B.isNodeMaterial)P.setObject(y,B);if(y.onBeforeRender(M,N,W,k,B,me),y.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),B.onBeforeRender(M,N,W,k,y,me),B.transparent===!0&&B.side===wn&&B.forceSinglePass===!1)B.side=Xt,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=zi,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=wn;else M.renderBufferDirect(W,N,k,B,y,me);y.onAfterRender(M,N,W,k,B,me)}function yo(y,N,W){if(N.isScene!==!0)N=nn;let k=I.get(y),B=b.state.lights,me=b.state.shadowsArray,ye=B.state.version,pe=J.getParameters(y,B.state,me,N,W,b.state.lightProbeGridArray),Se=J.getProgramCacheKey(pe),Ee=k.programs;k.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,k.fog=N.fog;let He=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;if(k.envMap=ie.get(y.envMap||k.environment,He),k.envMapRotation=k.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Ee===void 0)y.addEventListener("dispose",Hn),Ee=new Map,k.programs=Ee;let qe=Ee.get(Se);if(qe!==void 0){if(k.currentProgram===qe&&k.lightsStateVersion===ye)return Xh(y,pe),qe}else{if(pe.uniforms=J.getUniforms(y),P!==null&&y.isNodeMaterial)P.build(y,W,pe);y.onBeforeCompile(pe,M),qe=J.acquireProgram(pe,Se),Ee.set(Se,qe),k.uniforms=pe.uniforms}let be=k.uniforms;if(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)be.clippingPlanes=oe.uniform;if(Xh(y,pe),k.needsLights=sv(y),k.lightsStateVersion=ye,k.needsLights)be.ambientLightColor.value=B.state.ambient,be.lightProbe.value=B.state.probe,be.sunLights.value=B.state.sun,be.sunLightShadows.value=B.state.sunShadow,be.directionalLights.value=B.state.directional,be.directionalLightShadows.value=B.state.directionalShadow,be.spotLights.value=B.state.spot,be.spotLightShadows.value=B.state.spotShadow,be.rectAreaLights.value=B.state.rectArea,be.ltc_1.value=B.state.rectAreaLTC1,be.ltc_2.value=B.state.rectAreaLTC2,be.pointLights.value=B.state.point,be.pointLightShadows.value=B.state.pointShadow,be.hemisphereLights.value=B.state.hemi,be.sunShadowMatrix.value=B.state.sunShadowMatrix,be.sunShadowCascade.value=B.state.sunShadowCascade,be.directionalShadowMatrix.value=B.state.directionalShadowMatrix,be.spotLightMatrix.value=B.state.spotLightMatrix,be.spotLightMap.value=B.state.spotLightMap,be.pointShadowMatrix.value=B.state.pointShadowMatrix;return k.lightProbeGrid=b.state.lightProbeGridArray.length>0,k.currentProgram=qe,k.uniformsList=null,qe}function Zh(y){if(y.uniformsList===null){let N=y.currentProgram.getUniforms();y.uniformsList=Ys.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function Xh(y,N){let W=I.get(y);W.outputColorSpace=N.outputColorSpace,W.batching=N.batching,W.batchingColor=N.batchingColor,W.instancing=N.instancing,W.instancingColor=N.instancingColor,W.instancingMorph=N.instancingMorph,W.skinning=N.skinning,W.morphTargets=N.morphTargets,W.morphNormals=N.morphNormals,W.morphColors=N.morphColors,W.morphTargetsCount=N.morphTargetsCount,W.numClippingPlanes=N.numClippingPlanes,W.numIntersection=N.numClipIntersection,W.vertexAlphas=N.vertexAlphas,W.vertexTangents=N.vertexTangents,W.toneMapping=N.toneMapping}function nv(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let W=0,k=y.length;W<k;W++){let B=y[W];if(B.texture!==null&&B.boundingBox.containsPoint(R))return B}return null}function iv(y,N,W,k,B){if(N.isScene!==!0)N=nn;V.resetTextureUnits();let me=N.fog,ye=k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial?N.environment:null,pe=z===null?M.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:We.workingColorSpace,Se=k.isMeshStandardMaterial||k.isMeshLambertMaterial&&!k.envMap||k.isMeshPhongMaterial&&!k.envMap,Ee=ie.get(k.envMap||ye,Se),He=k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,qe=!!W.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),be=!!W.morphAttributes.position,it=!!W.morphAttributes.normal,Rt=!!W.morphAttributes.color,_t=Dn;if(k.toneMapped){if(z===null||z.isXRRenderTarget===!0)_t=M.toneMapping}let ut=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Wt=ut!==void 0?ut.length:0,xe=I.get(k),Jt=b.state.lights;if(Ze===!0){if(rt===!0||y!==H){let dt=y===H&&k.id===te;oe.setState(k,y,dt)}}let Ke=!1;if(k.version===xe.__version){if(xe.needsLights&&xe.lightsStateVersion!==Jt.state.version)Ke=!0;else if(xe.outputColorSpace!==pe)Ke=!0;else if(B.isBatchedMesh&&xe.batching===!1)Ke=!0;else if(!B.isBatchedMesh&&xe.batching===!0)Ke=!0;else if(B.isBatchedMesh&&xe.batchingColor===!0&&B._colorsTexture===null)Ke=!0;else if(B.isBatchedMesh&&xe.batchingColor===!1&&B._colorsTexture!==null)Ke=!0;else if(B.isInstancedMesh&&xe.instancing===!1)Ke=!0;else if(!B.isInstancedMesh&&xe.instancing===!0)Ke=!0;else if(B.isSkinnedMesh&&xe.skinning===!1)Ke=!0;else if(!B.isSkinnedMesh&&xe.skinning===!0)Ke=!0;else if(B.isInstancedMesh&&xe.instancingColor===!0&&B.instanceColor===null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingColor===!1&&B.instanceColor!==null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!0&&B.morphTexture===null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!1&&B.morphTexture!==null)Ke=!0;else if(xe.envMap!==Ee)Ke=!0;else if(k.fog===!0&&xe.fog!==me)Ke=!0;else if(xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==oe.numPlanes||xe.numIntersection!==oe.numIntersection))Ke=!0;else if(xe.vertexAlphas!==He)Ke=!0;else if(xe.vertexTangents!==qe)Ke=!0;else if(xe.morphTargets!==be)Ke=!0;else if(xe.morphNormals!==it)Ke=!0;else if(xe.morphColors!==Rt)Ke=!0;else if(xe.toneMapping!==_t)Ke=!0;else if(xe.morphTargetsCount!==Wt)Ke=!0;else if(!!xe.lightProbeGrid!==b.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,xe.__version=k.version;let yn=xe.currentProgram;if(Ke===!0){if(yn=yo(k,N,B),P&&k.isNodeMaterial)P.onUpdateProgram(k,yn,xe)}let Vn=!1,Ei=!1,Tr=!1,ct=yn.getUniforms(),Tt=xe.uniforms;if(w.useProgram(yn.program))Vn=!0,Ei=!0,Tr=!0;if(k.id!==te)te=k.id,Ei=!0;if(xe.needsLights){let dt=nv(b.state.lightProbeGridArray,B);if(xe.lightProbeGrid!==dt)xe.lightProbeGrid=dt,Ei=!0}if(Vn||H!==y){if(w.buffers.depth.getReversed()&&y.reversedDepth!==!0)y._reversedDepth=!0,y.updateProjectionMatrix();ct.setValue(L,"projectionMatrix",y.projectionMatrix),ct.setValue(L,"viewMatrix",y.matrixWorldInverse);let Ri=ct.map.cameraPosition;if(Ri!==void 0)Ri.setValue(L,Gt.setFromMatrixPosition(y.matrixWorld));if(yt.logarithmicDepthBuffer)ct.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2));if(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)ct.setValue(L,"isOrthographic",y.isOrthographicCamera===!0);if(H!==y)H=y,Ei=!0,Tr=!0}if(xe.needsLights){if(Jt.state.sunShadowMap.length>0)ct.setValue(L,"sunShadowMap",Jt.state.sunShadowMap,V);if(Jt.state.directionalShadowMap.length>0)ct.setValue(L,"directionalShadowMap",Jt.state.directionalShadowMap,V);if(Jt.state.spotShadowMap.length>0)ct.setValue(L,"spotShadowMap",Jt.state.spotShadowMap,V);if(Jt.state.pointShadowMap.length>0)ct.setValue(L,"pointShadowMap",Jt.state.pointShadowMap,V)}if(B.isSkinnedMesh){ct.setOptional(L,B,"bindMatrix"),ct.setOptional(L,B,"bindMatrixInverse");let dt=B.skeleton;if(dt){if(dt.boneTexture===null)dt.computeBoneTexture();ct.setValue(L,"boneTexture",dt.boneTexture,V)}}if(B.isBatchedMesh){if(ct.setOptional(L,B,"batchingTexture"),ct.setValue(L,"batchingTexture",B._matricesTexture,V),ct.setOptional(L,B,"batchingIdTexture"),ct.setValue(L,"batchingIdTexture",B._indirectTexture,V),ct.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null)ct.setValue(L,"batchingColorTexture",B._colorsTexture,V)}let Ai=W.morphAttributes;if(Ai.position!==void 0||Ai.normal!==void 0||Ai.color!==void 0)Je.update(B,W,yn);if(Ei||xe.receiveShadow!==B.receiveShadow)xe.receiveShadow=B.receiveShadow,ct.setValue(L,"receiveShadow",B.receiveShadow);if((k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&N.environment!==null)Tt.envMapIntensity.value=N.environmentIntensity;if(Tt.dfgLUT!==void 0)Tt.dfgLUT.value=Jw();if(Ei){if(ct.setValue(L,"toneMappingExposure",M.toneMappingExposure),xe.needsLights)rv(Tt,Tr);if(me&&k.fog===!0)ge.refreshFogUniforms(Tt,me);if(ge.refreshMaterialUniforms(Tt,k,re,Z,b.state.transmissionRenderTarget[y.id]),xe.needsLights&&xe.lightProbeGrid){let dt=xe.lightProbeGrid;Tt.probesSH.value=dt.texture,Tt.probesMin.value.copy(dt.boundingBox.min),Tt.probesMax.value.copy(dt.boundingBox.max),Tt.probesResolution.value.copy(dt.resolution)}Ys.upload(L,Zh(xe),Tt,V)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0)Ys.upload(L,Zh(xe),Tt,V),k.uniformsNeedUpdate=!1;if(k.isSpriteMaterial)ct.setValue(L,"center",B.center);if(ct.setValue(L,"modelViewMatrix",B.modelViewMatrix),ct.setValue(L,"normalMatrix",B.normalMatrix),ct.setValue(L,"modelMatrix",B.matrixWorld),k.uniformsGroups!==void 0){let dt=k.uniformsGroups;for(let Ri=0,Er=dt.length;Ri<Er;Ri++){let Yh=dt[Ri];_e.update(Yh,yn),_e.bind(Yh,yn)}}return yn}function rv(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.sunLights.needsUpdate=N,y.sunLightShadows.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function sv(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(y,N,W){let k=I.get(y);if(k.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1)k.__useRenderToTexture=!1;I.get(y.texture).__webglTexture=N,I.get(y.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:W,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){let W=I.get(y);W.__webglFramebuffer=N,W.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,W=0){z=y,G=N,X=W;let k=null,B=!1,me=!1;if(y){let pe=I.get(y);if(pe.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest,w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),te=-1;return}else if(pe.__webglFramebuffer===void 0)V.setupRenderTarget(y);else if(pe.__hasExternalTextures)V.rebindTextures(y,I.get(y.texture).__webglTexture,I.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let He=y.depthTexture;if(pe.__boundDepthTexture!==He){if(He!==null&&I.has(He)&&(y.width!==He.image.width||y.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(y)}}let Se=y.texture;if(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)me=!0;let Ee=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget){if(Array.isArray(Ee[N]))k=Ee[N][W];else k=Ee[N];B=!0}else if(y.samples>0&&V.useMultisampledRTT(y)===!1)k=I.get(y).__webglMultisampledFramebuffer;else if(Array.isArray(Ee))k=Ee[W];else k=Ee;Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest}else Q.copy(Ie).multiplyScalar(re).floor(),ee.copy(we).multiplyScalar(re).floor(),Te=mt;if(W!==0)k=O;if(w.bindFramebuffer(L.FRAMEBUFFER,k))w.drawBuffers(y,k);if(w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),B){let pe=I.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,W)}else if(me){let pe=N;for(let Se=0;Se<y.textures.length;Se++){let Ee=I.get(y.textures[Se]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Se,Ee.__webglTexture,W,pe)}}else if(y!==null&&W!==0){let pe=I.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,W)}te=-1};function qh(y){let N=I.get(y);if(N.__readFormat!==y.format||N.__readType!==y.type)N.__readFormat=y.format,N.__readType=y.type,N.__formatReadable=yt.textureFormatReadable(y.format),N.__typeReadable=yt.textureTypeReadable(y.type);return N}if(this.readRenderTargetPixels=function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se){w.bindFramebuffer(L.FRAMEBUFFER,Se);try{let Ee=y.textures[pe],{format:He,type:qe}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=qh(Ee);if(be.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B))L.readPixels(N,W,k,B,Y.convert(He),Y.convert(qe),me)}finally{let Ee=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se)if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B)){w.bindFramebuffer(L.FRAMEBUFFER,Se);let Ee=y.textures[pe],{format:He,type:qe}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=qh(Ee);if(be.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let it=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,it),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,W,k,B,Y.convert(He),Y.convert(qe),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Rt=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Rt);let _t=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Pd(L,_t,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,it),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(it),L.deleteSync(_t),me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,W=0){let k=Math.pow(2,-W),B=Math.floor(y.image.width*k),me=Math.floor(y.image.height*k),ye=N!==null?N.x:0,pe=N!==null?N.y:0;V.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,W,0,0,ye,pe,B,me),w.unbindTexture()},this.copyTextureToTexture=function(y,N,W=null,k=null,B=0,me=0){let ye,pe,Se,Ee,He,qe,be,it,Rt,_t=y.isCompressedTexture?y.mipmaps[me]:y.image;if(W!==null)ye=W.max.x-W.min.x,pe=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,Ee=W.min.x,He=W.min.y,qe=W.isBox3?W.min.z:0;else{let Tt=Math.pow(2,-B);if(ye=Math.floor(_t.width*Tt),pe=Math.floor(_t.height*Tt),y.isDataArrayTexture)Se=_t.depth;else if(y.isData3DTexture)Se=Math.floor(_t.depth*Tt);else Se=1;Ee=0,He=0,qe=0}if(k!==null)be=k.x,it=k.y,Rt=k.z;else be=0,it=0,Rt=0;let ut=Y.convert(N.format),Wt=Y.convert(N.type),xe;if(N.isData3DTexture)V.setTexture3D(N,0),xe=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)V.setTexture2DArray(N,0),xe=L.TEXTURE_2D_ARRAY;else V.setTexture2D(N,0),xe=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let Jt=w.getParameter(L.UNPACK_ROW_LENGTH),Ke=w.getParameter(L.UNPACK_IMAGE_HEIGHT),yn=w.getParameter(L.UNPACK_SKIP_PIXELS),Vn=w.getParameter(L.UNPACK_SKIP_ROWS),Ei=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,_t.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,_t.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ee),w.pixelStorei(L.UNPACK_SKIP_ROWS,He),w.pixelStorei(L.UNPACK_SKIP_IMAGES,qe);let Tr=y.isDataArrayTexture||y.isData3DTexture,ct=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){let Tt=I.get(y),Ai=I.get(N),dt=I.get(Tt.__renderTarget),Ri=I.get(Ai.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,dt.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Ri.__webglFramebuffer);for(let Er=0;Er<Se;Er++){if(Tr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(y).__webglTexture,B,qe+Er),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(N).__webglTexture,me,Rt+Er);L.blitFramebuffer(Ee,He,ye,pe,be,it,ye,pe,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||y.isRenderTargetTexture||I.has(y)){let Tt=I.get(y),Ai=I.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,K),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,C);for(let dt=0;dt<Se;dt++){if(Tr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Tt.__webglTexture,B,qe+dt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Tt.__webglTexture,B);if(ct)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ai.__webglTexture,me,Rt+dt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ai.__webglTexture,me);if(B!==0)L.blitFramebuffer(Ee,He,ye,pe,be,it,ye,pe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ct)L.copyTexSubImage3D(xe,me,be,it,Rt+dt,Ee,He,ye,pe);else L.copyTexSubImage2D(xe,me,be,it,Ee,He,ye,pe)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ct)if(y.isDataTexture||y.isData3DTexture)L.texSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,Wt,_t.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,_t.data);else L.texSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,Wt,_t);else if(y.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,me,be,it,ye,pe,ut,Wt,_t.data);else if(y.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,me,be,it,_t.width,_t.height,ut,_t.data);else L.texSubImage2D(L.TEXTURE_2D,me,be,it,ye,pe,ut,Wt,_t);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,Jt),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(L.UNPACK_SKIP_PIXELS,yn),w.pixelStorei(L.UNPACK_SKIP_ROWS,Vn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ei),me===0&&N.generateMipmaps)L.generateMipmap(xe);w.unbindTexture()},this.initRenderTarget=function(y){if(I.get(y).__webglFramebuffer===void 0)V.setupRenderTarget(y)},this.initTexture=function(y){if(y.isCubeTexture)V.setTextureCube(y,0);else if(y.isData3DTexture)V.setTexture3D(y,0);else if(y.isDataArrayTexture||y.isCompressedArrayTexture)V.setTexture2DArray(y,0);else V.setTexture2D(y,0);w.unbindTexture()},this.resetState=function(){G=0,X=0,z=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=We._getDrawingBufferColorSpace(e),t.unpackColorSpace=We._getUnpackColorSpace()}}function vu(e,t){if(t===Ul)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Jr||t===Ps){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===Jr)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 bp(e){let t=new Map,n=new Map,i=e.clone();return Mp(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 Mp(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)Mp(e.children[i],t.children[i],n)}class Eu extends Si{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ip(t)}),this.register(function(t){return new Lp(t)}),this.register(function(t){return new Gp(t)}),this.register(function(t){return new Hp(t)}),this.register(function(t){return new Vp(t)}),this.register(function(t){return new Dp(t)}),this.register(function(t){return new Op(t)}),this.register(function(t){return new Up(t)}),this.register(function(t){return new Fp(t)}),this.register(function(t){return new Pp(t)}),this.register(function(t){return new zp(t)}),this.register(function(t){return new Np(t)}),this.register(function(t){return new Bp(t)}),this.register(function(t){return new kp(t)}),this.register(function(t){return new Rp(t)}),this.register(function(t){return new Mu(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mu(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Wp(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=qi.extractUrlBase(e);s=qi.resolveURL(c,this.path)}else s=qi.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 Vs(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))===$p){try{s[Xe.KHR_BINARY_GLTF]=new Zp(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Kp(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new Cp;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Xp(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new qp;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Yp;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function eT(){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 Et(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Rp{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],hn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new ss(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new rs(l),c.distance=u;break;case"spot":c=new Ma(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class Cp{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return Jn}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],hn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Bi))}return Promise.all(i)}}class Pp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class Ip{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class Lp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Np{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Dp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],hn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Bi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Op{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Up{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],hn),Promise.all(i)}}class Fp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 zp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],hn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Bi));return Promise.all(i)}}class kp{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Bp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Gp{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Hp{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Vp{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Mu{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Wp{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==En.TRIANGLES&&c.mode!==En.TRIANGLE_STRIP&&c.mode!==En.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Be,x=new U,p=new Ft,m=new U(1,1,1),E=new ts(d.geometry,d.material,f);for(let S=0;S<f;S++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,S);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,S);if(a.SCALE)m.fromBufferAttribute(a.SCALE,S);E.setMatrixAt(S,g.compose(x,p,m))}let R=null;for(let S in a)if(S==="_COLOR_0"){let b=a[S];E.instanceColor=new Oi(b.array,b.itemSize,b.normalized)}else if(S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"){if(R===null){let T=E.geometry;R=new qt,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let b=a[S];R.setAttribute(S,new Oi(b.array,b.itemSize,b.normalized))}lt.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var $p="glTF",Ks=12,wp={JSON:1313821514,BIN:5130562};class Zp{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Ks),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!==$p)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-Ks,r=new DataView(e,Ks),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===wp.JSON){let c=new Uint8Array(e,Ks+s,o);this.content=n.decode(c)}else if(a===wp.BIN){let c=Ks+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Xp{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=wu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=wu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=ls[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,hn,f)})})}}class qp{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Yp{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class Au extends yi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let S=s[g+R+o],b=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*S+E*b+x*T+p*A}return r}}var tT=new Ft;class jp extends Au{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return tT.fromArray(r).normalize().toArray(r),r}}var En={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},ls={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Tp={9728:On,9729:kt,9984:Jo,9985:jr,9986:lr,9987:Yn},Ep={33071:Yr,33648:Ko,10497:qr},yu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wu={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"},Yi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},nT={CUBICSPLINE:void 0,LINEAR:sa,STEP:Ol},Su={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function iT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new vi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:zi});return e.DefaultMaterial}function vr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function rT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function sT(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 oT(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+bu(n.attributes);else t=e.indices+":"+bu(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+bu(e.targets[i]);return t}function bu(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 Tu(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 aT(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 cT=new Be;class Kp{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new eT,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 ya(this.options.manager);else this.textureLoader=new wa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Vs(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 vr(r,o,i),ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(qi.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=yu[i.type],o=ls[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new zt(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=yu[i.type],c=ls[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new Ds(g,h/l),t.cache.add(m,E);x=new es(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new zt(g,a,d)}if(i.sparse!==void 0){let p=yu.SCALAR,m=ls[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,S=new m(s[1],E,i.sparse.count*p),b=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new zt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=S.length;T<A;T++){let _=S[T];if(x.setX(_,b[T*a]),a>=2)x.setY(_,b[T*a+1]);if(a>=3)x.setZ(_,b[T*a+2]);if(a>=4)x.setW(_,b[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=Tp[f.magFilter]||kt,l.minFilter=Tp[f.minFilter]||Yn,l.wrapS=Ep[f.wrapS]||qr,l.wrapT=Ep[f.wrapT]||qr,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==On&&l.minFilter!==kt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new Mt(g);x.needsUpdate=!0,f(x)};t.load(qi.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ti(u,s),u.userData.mimeType=s.mimeType||aT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Bs,on.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 ks,on.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 vi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],hn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Bi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=wn;let l=r.alphaMode||Su.OPAQUE;if(l===Su.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Su.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==Jn){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==Jn){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!==Jn){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],hn)}if(r.emissiveTexture!==void 0&&s!==Jn)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Bi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ti(u,r),t.associations.set(u,{materials:e}),r.extensions)vr(i,u,r);return u})}createUniqueName(e){let t=Qe.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return Ap(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=oT(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=Ap(new qt,c,t);if(c.mode===En.TRIANGLE_STRIP)f=f.then((h)=>vu(h,Ps));else if(c.mode===En.TRIANGLE_FAN)f=f.then((h)=>vu(h,Jr));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?iT(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===En.TRIANGLES||x.mode===En.TRIANGLE_STRIP||x.mode===En.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new fa(g,m):new pt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===En.LINES)p=new da(g,m);else if(x.mode===En.LINE_STRIP)p=new Hi(g,m);else if(x.mode===En.LINE_LOOP)p=new pa(g,m);else if(x.mode===En.POINTS)p=new ns(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)sT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ti(p,r),x.extensions)vr(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)vr(i,u[0],r);return u[0]}let f=new $n;if(r.extensions)vr(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Lt(Is.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 ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Be;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Fs(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let S=f[E],b=h[E],T=d[E],A=g[E],_=x[E];if(S===void 0)continue;if(S.updateMatrix)S.updateMatrix();let M=n._createAnimationTracks(S,b,T,A,_);if(M)for(let F=0;F<M.length;F++)p.push(M[F])}let m=new Wr(r,void 0,p);return ti(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,cT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Os;else if(c.length>1)l=new $n;else if(c.length===1)l=c[0];else l=new lt;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ti(l,r),r.extensions)vr(n,l,r);if(r.matrix!==void 0){let u=new Be;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 $n;if(n.name)r.name=i.createUniqueName(n.name);if(ti(r,n),n.extensions)vr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(bp(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof on||f instanceof Mt)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(Yi[r.path]===Yi.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Yi[r.path]){case Yi.weights:l=$i;break;case Yi.rotation:l=Zi;break;case Yi.translation:case Yi.scale:l=gr;break;default:switch(n.itemSize){case 1:l=$i;break;case 2:case 3:default:l=gr;break}break}let u=i.interpolation!==void 0?nT[i.interpolation]:sa,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+Yi[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Tu(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 Zi?jp:Au)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function lT(e,t,n){let i=t.attributes,r=new en;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=Tu(ls[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 f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=Tu(ls[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new dn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function Ap(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=wu[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(We.workingColorSpace!==hn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${We.workingColorSpace}" not supported.`);return ti(e,t),lT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?rT(e,t.targets,n):e})}var Jp={type:"change"},Cu={type:"start"},em={type:"end"},Ia=new Gi,Qp=new bn,uT=Math.cos(70*Is.DEG2RAD),Ot=new U,an=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ru=0.000001;class Pu extends Ea{constructor(e,t=null){super(e,t);if(this.state=at.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:Ui.ROTATE,MIDDLE:Ui.DOLLY,RIGHT:Ui.PAN},this.touches={ONE:Fi.ROTATE,TWO:Fi.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 Ft,this._lastTargetPosition=new U,this._quat=new Ft().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new $s,this._sphericalDelta=new $s,this._scale=1,this._panOffset=new U,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new U,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fT.bind(this),this._onPointerDown=hT.bind(this),this._onPointerUp=dT.bind(this),this._onContextMenu=yT.bind(this),this._onMouseWheel=gT.bind(this),this._onKeyDown=_T.bind(this),this._onTouchStart=xT.bind(this),this._onTouchMove=vT.bind(this),this._onMouseDown=pT.bind(this),this._onMouseMove=mT.bind(this),this._interceptControlDown=ST.bind(this),this._interceptControlUp=bT.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=at.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(Jp),this.update(),this.state=at.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(Ot.copy(t).sub(this.target),Ot.applyQuaternion(this._quat),this._spherical.setFromVector3(Ot),this.autoRotate&&this.state===at.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+=an;else if(n>Math.PI)n-=an;if(i<-Math.PI)i+=an;else if(i>Math.PI)i-=an;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(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),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=Ot.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=Ot.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(Ia.origin.copy(this.object.position),Ia.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ia.direction))<uT)this.object.lookAt(this.target);else Qp.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ia.intersectPlane(Qp,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)>Ru||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ru||this._lastTargetPosition.distanceToSquared(this.target)>Ru)return this.dispatchEvent(Jp),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 an/60*this.autoRotateSpeed*e;else return an/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){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){if(this.screenSpacePanning===!0)Ot.setFromMatrixColumn(t,1);else Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot);Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Ot.copy(i).sub(this.target);let r=Ot.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(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*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(an*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(-an*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(an*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(-an*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(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function hT(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 fT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function dT(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(em),this.state=at.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 pT(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 Ui.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=at.DOLLY;break;case Ui.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=at.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=at.ROTATE}break;case Ui.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=at.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=at.PAN}break;default:this.state=at.NONE}if(this.state!==at.NONE)this.dispatchEvent(Cu)}function mT(e){switch(this.state){case at.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case at.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case at.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function gT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==at.NONE)return;e.preventDefault(),this.dispatchEvent(Cu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(em)}function _T(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function xT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Fi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=at.TOUCH_ROTATE;break;case Fi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=at.TOUCH_PAN;break;default:this.state=at.NONE}break;case 2:switch(this.touches.TWO){case Fi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=at.TOUCH_DOLLY_PAN;break;case Fi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=at.TOUCH_DOLLY_ROTATE;break;default:this.state=at.NONE}break;default:this.state=at.NONE}if(this.state!==at.NONE)this.dispatchEvent(Cu)}function vT(e){switch(this._trackPointer(e),this.state){case at.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case at.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case at.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case at.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=at.NONE}}function yT(e){if(this.enabled===!1)return;e.preventDefault()}function ST(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function bT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Iu extends Qr{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Vi;e.deleteAttribute("uv");let t=new vi({side:Xt}),n=new vi,i=new rs(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 ts(e,n,6),o=new lt;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,us(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,us(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,us(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,us(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new pt(e,us(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new pt(e,us(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 us(e){return new _a({color:0,emissive:16777215,emissiveIntensity:e})}function eo(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 Nu(e,t="|"){return e.map((n)=>Uu(n)).join(t)}function to(e,t){if(typeof t==="bigint")return t.toString();return t}class tm{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 La(e){return new tm(e)}function nm(e){return e===null||e===void 0}function Na(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function im(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 zn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Da(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function bi(e){return Da(e._zod.def)??e._zod.def.shape}function rm(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return zn(this,t,i),i},enumerable:!0,configurable:!0})}function sm(e,t,n){if(t in e)zn(e,t,n);else e[t]=n}function yr(e,t,n,i){let r=bi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)rm(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else sm(e,s,i?i(o.value,s):o.value)}}function MT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)rm(e,n,()=>t[n]);else sm(e,n,i.value)}}function gn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function om(e){return JSON.stringify(e)}function am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Du="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var cm=La(()=>{if(cn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Sr(e){if(Qs(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(Qs(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Ou(e){if(Sr(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 lm=new Set(["string","number","symbol"]);function Ki(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(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 Uu(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function um(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Oa=(()=>({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]}))(),Fu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wT(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 yr(s,e,Ua(e,t)),ni(e,gn(n,{shape:s,checks:[]}))}function Ua(e,t){let n=bi(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 TT(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(Ua(e,t)),o={};return yr(o,e,Reflect.ownKeys(bi(e)).filter((a)=>!s.has(a))),ni(e,gn(n,{shape:o,checks:[]}))}function ET(e,t){if(!Sr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=bi(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 ni(e,gn(e._zod.def,{shape:hm(e,t)}))}function hm(e,t){let n={};return yr(n,e,Reflect.ownKeys(bi(e))),MT(n,t),n}function AT(e,t){if(!Sr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ni(e,gn(e._zod.def,{shape:hm(e,t)}))}function RT(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={};yr(n,e,Reflect.ownKeys(bi(e))),yr(n,t,Reflect.ownKeys(bi(t)));let i=gn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ni(e,i)}function fm(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(Ua(t,n)):void 0,c={};return yr(c,t,Reflect.ownKeys(bi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ni(t,gn(t._zod.def,{shape:c,checks:[]}))}function CT(e,t,n){let i=n?new Set(Ua(t,n)):void 0,r={};return yr(r,t,Reflect.ownKeys(bi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ni(t,gn(t._zod.def,{shape:r}))}function ii(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 dm(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 Ji(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Js(e){return typeof e==="string"?e:e?.message}function zu(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ri(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:Js(e.inst?._zod.def?.error?.(e))??Js(s?.(e))??Js(t?.error?.(e))??Js(n.customError?.(e))??Js(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 PT=/[\uD800-\uDBFF]/;function Fa(e){let t=e.length;if(!PT.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 za(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function pm(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 br(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function mm(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else IT(e,n,i.value)}}function Mi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ka(e,t,n){return Mi(e,t,n,!1)}function gm(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Mi(this,n,i(this))},set(r){Mi(this,n,r)}})}return t}function IT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Mi(this,t,n.bind(this))},set(i){Mi(this,t,i)}})}function LT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Lu,ji=!1,NT={configurable:!0,get(){ji=!0;return}};function et(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Lu!==e._zod){Lu=void 0;return}Lu=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,NT);let r=ji;ji=!1;try{let s=n(this);if(ji)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return ji=ji||r,s}catch(s){throw delete this[t],ji=ji||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function DT(e,t,n,i){let r=LT(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 OT="~constantCatch";function _m(e){let t=()=>e;return t[OT]=!0,t}var xm;var ku={value:void 0,enumerable:!1},vm="captureStackTrace"in Error?Error:null;function UT(e){let t=vm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return vm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function j(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){ku.value=new s(d);try{Object.defineProperty(h,"_zod",ku)}finally{ku.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),mm(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?UT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class si extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class no extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(xm=globalThis).__zod_globalConfig??(xm.__zod_globalConfig={});var cn=globalThis.__zod_globalConfig;function _n(e){if(e)Object.assign(cn,e);return cn}function FT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,to,2)),e.message}function zT(e){this._zod.message=e}var kT={get:FT,set:zT,enumerable:!0,configurable:!0},Gu={value:void 0,enumerable:!1},ym=new WeakSet([Object.prototype,Error.prototype]),Sm=(e,t)=>{e.name="$ZodError",Gu.value=t,Object.defineProperty(e,"issues",Gu),Gu.value=void 0,Object.defineProperty(e,"message",kT);let n=Object.getPrototypeOf(e);if(!ym.has(n))ym.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})}})},bm=j("$ZodError",Sm),EP=j("$ZodError",Sm,void 0,{Parent:Error});function BT(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 Mm(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)BT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function wm(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Ba(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ga=(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 si;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ri(l,o,_n())));throw Du(c,s?.callee??t),c}return a.value};return t};var Ha=(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)=>ri(l,o,_n())));throw Du(c,s?.callee??t),c}return a.value};return t};var Va=(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 si;return s.issues.length?Tm(e,s.issues,r):{success:!0,data:s.value}};function Tm(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ri(r,n,_n()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Wa=(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?Tm(e,s.issues,r):{success:!0,data:s.value}};var GT=Symbol.for("zod.compile.invalid"),HT=Symbol.for("zod.compile.fallback"),Hu=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==GT)return!0;if(i.definite===!0&&n===void 0)return!1}return VT(e,t,n)};function VT(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[HT]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new si;return s.issues.length===0}var Vu=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},Em=(e)=>{let t=Ga(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Ba(n,o))};return n};var Am=(e)=>{let t=Ga(e),n=(i,r,s,o)=>t(i,r,s,Ba(n,o));return n};var Rm=(e)=>{let t=Ha(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Ba(n,o))};return n};var Cm=(e)=>{let t=Ha(e),n=async(i,r,s,o)=>await t(i,r,s,Ba(n,o));return n};var Pm=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Va(e)(t,n,r)};var Im=(e)=>(t,n,i)=>Va(e)(t,n,i);var Lm=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Wa(e)(t,n,r)};var Nm=(e)=>async(t,n,i)=>Wa(e)(t,n,i);var Dm=/^[cC][0-9a-z]{6,}$/,Om=/^[0-9a-z]+$/,Um=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Fm=/^[0-9a-vA-V]{20}$/,zm=/^[A-Za-z0-9]{27}$/,km=/^[a-zA-Z0-9_-]{21}$/;function Bm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Gm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Hm=/^([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})$/,$u=(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 Vm=/^(?:[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 WT="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Wm(){return new RegExp(WT,"u")}var $m=/^(?:(?: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])$/,Zm=/^(([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 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])\/([0-9]|[1-2][0-9]|3[0-2])$/,qm=/^(([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])$/,Ym=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Km=/^https?$/,Jm=/^\+[1-9]\d{6,14}$/;var Qm="(?:(?:\\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 $T(e){return new RegExp(`^${e}$`)}var eg=$T(Qm);function Wu(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 tg(e){return new RegExp(`^${Wu(e)}$`)}function ng(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Wu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Wu({precision:e.precision})}`:n;return new RegExp(`^${Qm}T(?:${i})$`)}var ig=/^[\s\S]{0,}$/;var Zu=/^-?\d+$/,io=/^-?\d+(?:\.\d+)?$/,rg=/^(?:true|false)$/i;var sg=/^[^A-Z]*$/,og=/^[^a-z]*$/;var Ht=j("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Xu=(e)=>{let t=e.value;return!nm(t)&&t.length!==void 0},$a={number:"number",bigint:"bigint",object:"date"},qu=j("$ZodCheckLessThan",(e,t)=>{Ht.init(e,t);let n=$a[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:$a[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})}}),Yu=j("$ZodCheckGreaterThan",(e,t)=>{Ht.init(e,t);let n=$a[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:$a[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})}}),ag=j("$ZodCheckMultipleOf",(e,t)=>{Ht.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):im(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})}}),cg=j("$ZodCheckNumberFormat",(e,t)=>{Ht.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Oa[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 lg=j("$ZodCheckMaxLength",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Fa(r):s)<=t.maximum)return;let a=za(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ug=j("$ZodCheckMinLength",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Fa(r):s)>=t.minimum)return;let a=za(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hg=j("$ZodCheckLengthEquals",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Fa(r):s;if(o===t.length)return;let a=za(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})}}),so=j("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Ht.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=()=>{})}),fg=j("$ZodCheckRegex",(e,t)=>{so.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})}}),dg=j("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sg),so.init(e,t)}),pg=j("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=og),so.init(e,t)}),mg=j("$ZodCheckIncludes",(e,t)=>{Ht.init(e,t);let n=Ki(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})}}),gg=j("$ZodCheckStartsWith",(e,t)=>{Ht.init(e,t);let n=new RegExp(`^${Ki(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})}}),_g=j("$ZodCheckEndsWith",(e,t)=>{Ht.init(e,t);let n=new RegExp(`.*${Ki(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 xg=j("$ZodCheckOverwrite",(e,t)=>{Ht.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class ju{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 Sp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ga(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Tn({vertexShader:Yw,fragmentShader:jw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new pt(new Gs(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class bp extends Fn{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,f=null,h=null,d=null,g=typeof XRWebGLBinding<"u",x=new Sp,p={},m=t.getContextAttributes(),E=null,R=null,S=[],b=[],T=new Ne,A=null,_=null,M=new Lt;M.viewport=new ot;let F=new Lt;F.viewport=new ot;let P=[M,F],O=new nu,K=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=S[Z];if(re===void 0)re=new Ns,S[Z]=re;return re.getHandSpace()};function G(Z){let re=b.indexOf(Z.inputSource);if(re===-1)return;let se=S[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",z);for(let Z=0;Z<S.length;Z++){let re=b[Z];if(re===null)continue;b[Z]=null,S[Z].disconnect(re)}K=null,C=null,x.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(E),h=null,f=null,u=null,i=null,R=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),_!==null){let Z=_.camera;Z.fov=_.fov,Z.zoom=_.zoom,Z.updateProjectionMatrix(),_=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Re("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Re("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return f!==null?f:h},this.getBinding=function(){if(u===null&&g)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(E=e.getRenderTarget(),i.addEventListener("select",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",z),m.xrCompatible!==!0)await t.makeXRCompatible();if(A=e.getPixelRatio(),e.getSize(T),!(g&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),R=new fn(h.framebufferWidth,h.framebufferHeight,{format:Kn,type:Un,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,Pe=null,Ie=null;if(m.depth)Ie=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=m.stencil?hr:ur,Pe=m.stencil?Kr:ki;let we={colorFormat:t.RGBA8,depthFormat:Ie,scaleFactor:r};u=this.getBinding(),f=u.createProjectionLayer(we),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),R=new fn(f.textureWidth,f.textureHeight,{format:Kn,type:Un,depthTexture:new pr(f.textureWidth,f.textureHeight,Pe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),Me.setContext(i),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function z(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],Pe=b.indexOf(se);if(Pe>=0)b[Pe]=null,S[Pe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],Pe=b.indexOf(se);if(Pe===-1){for(let we=0;we<S.length;we++)if(we>=b.length){b.push(se),Pe=we;break}else if(b[we]===null){b[we]=se,Pe=we;break}if(Pe===-1)break}let Ie=S[Pe];if(Ie)Ie.connect(se)}}let te=new U,H=new U;function Q(Z,re,se){te.setFromMatrixPosition(re.matrixWorld),H.setFromMatrixPosition(se.matrixWorld);let Pe=te.distanceTo(H),Ie=re.projectionMatrix.elements,we=se.projectionMatrix.elements,mt=Ie[14]/(Ie[10]-1),ze=Ie[14]/(Ie[10]+1),Ze=(Ie[9]+1)/Ie[5],rt=(Ie[9]-1)/Ie[5],je=(Ie[8]-1)/Ie[0],Gt=(we[8]+1)/we[0],gt=mt*je,nn=mt*Gt,Pt=Pe/(-je+Gt),It=Pt*-je;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(It),Z.translateZ(Pt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ie[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let L=mt+Pt,rn=ze+Pt,tt=gt-It,yt=nn+(Pe-It),w=Ze*ze/rn*L,v=rt*ze/rn*L;Z.projectionMatrix.makePerspective(tt,yt,w,v,L,rn),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(x.texture!==null){if(x.depthNear>0)re=x.depthNear;if(x.depthFar>0)se=x.depthFar}if(O.near=F.near=M.near=re,O.far=F.far=M.far=se,K!==O.near||C!==O.far)i.updateRenderState({depthNear:O.near,depthFar:O.far}),K=O.near,C=O.far;O.layers.mask=Z.layers.mask|6,M.layers.mask=O.layers.mask&-5,F.layers.mask=O.layers.mask&-3;let Pe=Z.parent,Ie=O.cameras;ee(O,Pe);for(let we=0;we<Ie.length;we++)ee(Ie[we],Pe);if(Ie.length===2)Q(O,M,F);else O.projectionMatrix.copy(M.projectionMatrix);if(_===null&&Z.isPerspectiveCamera)_={camera:Z,fov:Z.fov,zoom:Z.zoom};Te(Z,O,Pe)};function Te(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=ar*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return O},this.getFoveation=function(){if(f===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,f!==null)f.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(Z){return p[Z]};let ve=null;function Ge(Z,re){if(l=re.getViewerPose(c||s),d=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(R,h.framebuffer),e.setRenderTarget(R);let Pe=!1;if(se.length!==O.cameras.length)O.cameras.length=0,Pe=!0;for(let ze=0;ze<se.length;ze++){let Ze=se[ze],rt=null;if(h!==null)rt=h.getViewport(Ze);else{let Gt=u.getViewSubImage(f,Ze);if(rt=Gt.viewport,ze===0)e.setRenderTargetTextures(R,Gt.colorTexture,Gt.depthStencilTexture),e.setRenderTarget(R)}let je=P[ze];if(je===void 0)je=new Lt,je.layers.enable(ze),je.viewport=new ot,P[ze]=je;if(je.matrix.fromArray(Ze.transform.matrix),je.matrix.decompose(je.position,je.quaternion,je.scale),je.projectionMatrix.fromArray(Ze.projectionMatrix),je.projectionMatrixInverse.copy(je.projectionMatrix).invert(),je.viewport.set(rt.x,rt.y,rt.width,rt.height),ze===0)O.matrix.copy(je.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale);if(Pe===!0)O.cameras.push(je)}let Ie=i.enabledFeatures;if(Ie&&Ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&g){u=n.getBinding();let ze=u.getDepthInformation(se[0]);if(ze&&ze.isValid&&ze.texture)x.init(ze,i.renderState)}if(Ie&&Ie.includes("camera-access")&&g){e.state.unbindTexture(),u=n.getBinding();for(let ze=0;ze<se.length;ze++){let Ze=se[ze].camera;if(Ze){let rt=p[Ze];if(!rt)rt=new ga,p[Ze]=rt;let je=u.getCameraImage(Ze);rt.sourceTexture=je}}}}for(let se=0;se<S.length;se++){let Pe=b[se],Ie=S[se];if(Pe!==null&&Ie!==void 0)Ie.update(Pe,re,c||s)}if(ve)ve(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});d=null}let Me=new up;Me.setAnimationLoop(Ge),this.setAnimationLoop=function(Z){ve=Z},this.dispose=function(){}}}var Kw=new Be,Mp=new Fe;Mp.set(-1,0,0,0,1,0,0,0,1);function Jw(e,t){function n(p,m){if(p.matrixAutoUpdate===!0)p.updateMatrix();m.value.copy(p.matrix)}function i(p,m){if(m.color.getRGB(p.fogColor.value,Zl(e)),m.isFog)p.fogNear.value=m.near,p.fogFar.value=m.far;else if(m.isFogExp2)p.fogDensity.value=m.density}function r(p,m,E,R,S){if(m.isNodeMaterial)m.uniformsNeedUpdate=!1;else if(m.isMeshBasicMaterial)s(p,m);else if(m.isMeshLambertMaterial){if(s(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshToonMaterial)s(p,m),f(p,m);else if(m.isMeshPhongMaterial){if(s(p,m),u(p,m),m.envMap)p.envMapIntensity.value=m.envMapIntensity}else if(m.isMeshStandardMaterial){if(s(p,m),h(p,m),m.isMeshPhysicalMaterial)d(p,m,S)}else if(m.isMeshMatcapMaterial)s(p,m),g(p,m);else if(m.isMeshDepthMaterial)s(p,m);else if(m.isMeshDistanceMaterial)s(p,m),x(p,m);else if(m.isMeshNormalMaterial)s(p,m);else if(m.isLineBasicMaterial){if(o(p,m),m.isLineDashedMaterial)a(p,m)}else if(m.isPointsMaterial)c(p,m,E,R);else if(m.isSpriteMaterial)l(p,m);else if(m.isShadowMaterial)p.color.value.copy(m.color),p.opacity.value=m.opacity;else if(m.isShaderMaterial)m.uniformsNeedUpdate=!1}function s(p,m){if(p.opacity.value=m.opacity,m.color)p.diffuse.value.copy(m.color);if(m.emissive)p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity);if(m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.bumpMap){if(p.bumpMap.value=m.bumpMap,n(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Xt)p.bumpScale.value*=-1}if(m.normalMap){if(p.normalMap.value=m.normalMap,n(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Xt)p.normalScale.value.negate()}if(m.displacementMap)p.displacementMap.value=m.displacementMap,n(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias;if(m.emissiveMap)p.emissiveMap.value=m.emissiveMap,n(m.emissiveMap,p.emissiveMapTransform);if(m.specularMap)p.specularMap.value=m.specularMap,n(m.specularMap,p.specularMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest;let E=t.get(m),{envMap:R,envMapRotation:S}=E;if(R){if(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(Kw.makeRotationFromEuler(S)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Mp);p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio}if(m.lightMap)p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,n(m.lightMap,p.lightMapTransform);if(m.aoMap)p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,n(m.aoMap,p.aoMapTransform)}function o(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map)p.map.value=m.map,n(m.map,p.mapTransform)}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,E,R){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*E,p.scale.value=R*0.5,m.map)p.map.value=m.map,n(m.map,p.uvTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function l(p,m){if(p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map)p.map.value=m.map,n(m.map,p.mapTransform);if(m.alphaMap)p.alphaMap.value=m.alphaMap,n(m.alphaMap,p.alphaMapTransform);if(m.alphaTest>0)p.alphaTest.value=m.alphaTest}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,0.0001)}function f(p,m){if(m.gradientMap)p.gradientMap.value=m.gradientMap}function h(p,m){if(p.metalness.value=m.metalness,m.metalnessMap)p.metalnessMap.value=m.metalnessMap,n(m.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=m.roughness,m.roughnessMap)p.roughnessMap.value=m.roughnessMap,n(m.roughnessMap,p.roughnessMapTransform);if(m.envMap)p.envMapIntensity.value=m.envMapIntensity}function d(p,m,E){if(p.ior.value=m.ior,m.sheen>0){if(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap)p.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,p.sheenColorMapTransform);if(m.sheenRoughnessMap)p.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(m.clearcoat>0){if(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap)p.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,p.clearcoatMapTransform);if(m.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(m.clearcoatNormalMap){if(p.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Xt)p.clearcoatNormalScale.value.negate()}}if(m.dispersion>0)p.dispersion.value=m.dispersion;if(m.retroreflectivity>0)p.retroreflectivity.value=m.retroreflectivity;if(m.iridescence>0){if(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap)p.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,p.iridescenceMapTransform);if(m.iridescenceThicknessMap)p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(m.transmission>0){if(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=E.texture,p.transmissionSamplerSize.value.set(E.width,E.height),m.transmissionMap)p.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=m.thickness,m.thicknessMap)p.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)}if(m.anisotropy>0){if(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap)p.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap)p.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,p.specularColorMapTransform);if(m.specularIntensityMap)p.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,p.specularIntensityMapTransform)}function g(p,m){if(m.matcap)p.matcap.value=m.matcap}function x(p,m){let E=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(E.matrixWorld),p.nearDistance.value=E.shadow.camera.near,p.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Qw(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,b){let T=b.program;i.uniformBlockBinding(S,T)}function l(S,b){let T=r[S.id];if(T===void 0)p(S),T=u(S),r[S.id]=T,S.addEventListener("dispose",E);let A=b.program;i.updateUBOMapping(S,A);let _=t.render.frame;if(s[S.id]!==_)h(S),s[S.id]=_}function u(S){let b=f();S.__bindingPointIndex=b;let T=e.createBuffer(),{__size:A,usage:_}=S;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,A,_),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,b,T),T}function f(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ue("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){let b=r[S.id],{uniforms:T,__cache:A}=S;e.bindBuffer(e.UNIFORM_BUFFER,b);for(let _=0,M=T.length;_<M;_++){let F=T[_];if(Array.isArray(F))for(let P=0,O=F.length;P<O;P++)d(F[P],_,P,A);else d(F,_,0,A)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function d(S,b,T,A){if(x(S,b,T,A)===!0){let{__offset:_,value:M}=S;if(Array.isArray(M)){let F=0;for(let P=0;P<M.length;P++){let O=M[P],K=m(O);if(g(O,S.__data,F),typeof O!=="number"&&typeof O!=="boolean"&&!O.isMatrix3&&!ArrayBuffer.isView(O))F+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else g(M,S.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,_,S.__data)}}function g(S,b,T){if(typeof S==="number"||typeof S==="boolean")b[0]=S;else if(S.isMatrix3)b[0]=S.elements[0],b[1]=S.elements[1],b[2]=S.elements[2],b[3]=0,b[4]=S.elements[3],b[5]=S.elements[4],b[6]=S.elements[5],b[7]=0,b[8]=S.elements[6],b[9]=S.elements[7],b[10]=S.elements[8],b[11]=0;else if(ArrayBuffer.isView(S))b.set(new S.constructor(S.buffer,S.byteOffset,b.length));else S.toArray(b,T)}function x(S,b,T,A){let _=S.value,M=b+"_"+T;if(A[M]===void 0){if(typeof _==="number"||typeof _==="boolean")A[M]=_;else if(ArrayBuffer.isView(_))A[M]=_.slice();else A[M]=_.clone();return!0}else{let F=A[M];if(typeof _==="number"||typeof _==="boolean"){if(F!==_)return A[M]=_,!0}else if(ArrayBuffer.isView(_))return!0;else if(F.equals(_)===!1)return F.copy(_),!0}return!1}function p(S){let b=S.uniforms,T=0,A=16;for(let M=0,F=b.length;M<F;M++){let P=Array.isArray(b[M])?b[M]:[b[M]];for(let O=0,K=P.length;O<K;O++){let C=P[O],G=Array.isArray(C.value)?C.value:[C.value];for(let X=0,z=G.length;X<z;X++){let te=G[X],H=m(te),Q=T%A,ee=Q%H.boundary,Te=Q+ee;if(T+=ee,Te!==0&&A-Te<H.storage)T+=A-Te;C.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=T,T+=H.storage}}}let _=T%A;if(_>0)T+=A-_;return S.__size=T,S.__cache={},this}function m(S){let b={boundary:0,storage:0};if(typeof S==="number"||typeof S==="boolean")b.boundary=4,b.storage=4;else if(S.isVector2)b.boundary=8,b.storage=8;else if(S.isVector3||S.isColor)b.boundary=16,b.storage=12;else if(S.isVector4)b.boundary=16,b.storage=16;else if(S.isMatrix3)b.boundary=48,b.storage=48;else if(S.isMatrix4)b.boundary=64,b.storage=64;else if(S.isTexture)Re("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(S))b.boundary=16,b.storage=S.byteLength;else Re("WebGLRenderer: Unsupported uniform value type.",S);return b}function E(S){let b=S.target;b.removeEventListener("dispose",E);let T=o.indexOf(b.__bindingPointIndex);o.splice(T,1),e.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function R(){for(let S in r)e.deleteBuffer(r[S]);o=[],r={},s={}}return{bind:c,update:l,dispose:R}}var eT=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]),Qn=null;function tT(){if(Qn===null)Qn=new Us(eT,16,16,fr,jn),Qn.name="DFG_LUT",Qn.minFilter=kt,Qn.magFilter=kt,Qn.wrapS=Yr,Qn.wrapT=Yr,Qn.generateMipmaps=!1,Qn.needsUpdate=!0;return Qn}class xu{constructor(e={}){let{canvas:t=Pd(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:f=!1,outputBufferType:h=Un}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=s;let g=h,x=new Set([rl,il,nl]),p=new Set([Un,ki,Cs,Kr,el,tl]),m=new Uint32Array(4),E=new Int32Array(4),R=new U,S=null,b=null,T=[],A=[],_=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Dn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,F=!1,P=null,O=null,K=null,C=null;this._outputColorSpace=Bi;let G=0,X=0,z=null,te=-1,H=null,Q=new ot,ee=new ot,Te=null,ve=new Oe(0),Ge=0,{width:Me,height:Z}=t,re=1,se=null,Pe=null,Ie=new ot(0,0,Me,Z),we=new ot(0,0,Me,Z),mt=!1,ze=new zs,Ze=!1,rt=!1,je=new Be,Gt=new U,gt=new ot,nn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Pt=!1;function It(){return z===null?re:1}let L=n;function rn(y,N){return t.getContext(y,N)}let tt,yt,w,v,I,V,ie,ae,ue,q,J,ge,Ae,he,oe,Le,De,Je,D,ce,Y,le,_e;try{let y={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${Uf}`);if(t.addEventListener("webglcontextlost",ke,!1),t.addEventListener("webglcontextrestored",ft,!1),t.addEventListener("webglcontextcreationerror",nt,!1),L===null){if(L=rn("webgl2",y),L===null)if(rn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(y){throw t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",ft,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),Ue("WebGLRenderer: "+y.message),y}function ne(){if(tt=new cM(L),tt.init(),Y=new qw(L,tt),yt=new Jb(L,tt,e,Y),w=new Zw(L,tt),yt.reversedDepthBuffer&&f)w.buffers.depth.setReversed(!0);O=L.createFramebuffer(),K=L.createFramebuffer(),C=L.createFramebuffer(),v=new hM(L),I=new Lw,V=new Xw(L,tt,w,I,yt,Y,v),ie=new aM(M),ae=new dy(L),le=new jb(L,ae),ue=new lM(L,ae,v,le),q=new dM(L,ue,ae,le,v),Je=new fM(L,yt,V),oe=new Qb(I),J=new Iw(M,ie,tt,yt,le,oe),ge=new Jw(M,I),Ae=new Dw,he=new Bw(tt),De=new Yb(M,ie,w,q,d,a),Le=new $w(M,q,yt),_e=new Qw(L,v,yt,w),D=new Kb(L,tt,v),ce=new uM(L,tt,v),v.programs=J.programs,M.capabilities=yt,M.extensions=tt,M.properties=I,M.renderLists=Ae,M.shadowMap=Le,M.state=w,M.info=v}if(g!==Un)_=new mM(g,t.width,t.height,o,i,r);let de=new bp(M,L);this.xr=de,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let y=tt.get("WEBGL_lose_context");if(y)y.loseContext()},this.forceContextRestore=function(){let y=tt.get("WEBGL_lose_context");if(y)y.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(y){if(y===void 0)return;re=y,this.setSize(Me,Z,!1)},this.getSize=function(y){return y.set(Me,Z)},this.setSize=function(y,N,W=!0){if(de.isPresenting){Re("WebGLRenderer: Can't change size while VR device is presenting.");return}if(Me=y,Z=N,t.width=Math.floor(y*re),t.height=Math.floor(N*re),W===!0)t.style.width=y+"px",t.style.height=N+"px";if(_!==null)_.setSize(t.width,t.height);this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Me*re,Z*re).floor()},this.setDrawingBufferSize=function(y,N,W){Me=y,Z=N,re=W,t.width=Math.floor(y*W),t.height=Math.floor(N*W),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(g===Un){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Re("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}_.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(Q)},this.getViewport=function(y){return y.copy(Ie)},this.setViewport=function(y,N,W,k){if(y.isVector4)Ie.set(y.x,y.y,y.z,y.w);else Ie.set(y,N,W,k);w.viewport(Q.copy(Ie).multiplyScalar(re).round())},this.getScissor=function(y){return y.copy(we)},this.setScissor=function(y,N,W,k){if(y.isVector4)we.set(y.x,y.y,y.z,y.w);else we.set(y,N,W,k);w.scissor(ee.copy(we).multiplyScalar(re).round())},this.getScissorTest=function(){return mt},this.setScissorTest=function(y){w.setScissorTest(mt=y)},this.setOpaqueSort=function(y){se=y},this.setTransparentSort=function(y){Pe=y},this.getClearColor=function(y){return y.copy(De.getClearColor())},this.setClearColor=function(){De.setClearColor(...arguments)},this.getClearAlpha=function(){return De.getClearAlpha()},this.setClearAlpha=function(){De.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,W=!0){let k=0;if(y){let B=!1;if(z!==null){let me=z.texture.format;B=x.has(me)}if(B){let me=z.texture.type,ye=p.has(me),pe=De.getClearColor(),Se=De.getClearAlpha(),{r:Ee,g:He,b:qe}=pe;if(ye)m[0]=Ee,m[1]=He,m[2]=qe,m[3]=Se,L.clearBufferuiv(L.COLOR,0,m);else E[0]=Ee,E[1]=He,E[2]=qe,E[3]=Se,L.clearBufferiv(L.COLOR,0,E)}else k|=L.COLOR_BUFFER_BIT}if(N)k|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)k|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(k!==0)L.clear(k)},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(y){y.setRenderer(this),P=y},this.dispose=function(){t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",ft,!1),t.removeEventListener("webglcontextcreationerror",nt,!1),De.dispose(),Ae.dispose(),he.dispose(),I.dispose(),ie.dispose(),q.dispose(),le.dispose(),_e.dispose(),J.dispose(),de.dispose(),de.removeEventListener("sessionstart",Vh),de.removeEventListener("sessionend",Wh),tr.stop()};function ke(y){y.preventDefault(),ws("WebGLRenderer: Context Lost."),F=!0}function ft(){ws("WebGLRenderer: Context Restored."),F=!1;let y=v.autoReset,N=Le.enabled,W=Le.autoUpdate,k=Le.needsUpdate,B=Le.type;ne(),v.autoReset=y,Le.enabled=N,Le.autoUpdate=W,Le.needsUpdate=k,Le.type=B}function nt(y){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Hn(y){let N=y.target;N.removeEventListener("dispose",Hn),ui(N)}function ui(y){iv(y),I.remove(y)}function iv(y){let N=I.get(y).programs;if(N!==void 0){if(N.forEach(function(W){J.releaseProgram(W)}),y.isShaderMaterial)J.releaseShaderCache(y)}}this.renderBufferDirect=function(y,N,W,k,B,me){if(N===null)N=nn;let ye=B.isMesh&&B.matrixWorld.determinantAffine()<0,pe=ov(y,N,W,k,B);w.setMaterial(k,ye);let Se=W.index,Ee=1;if(k.wireframe===!0){if(Se=ue.getWireframeAttribute(W),Se===void 0)return;Ee=2}let He=W.drawRange,qe=W.attributes.position,be=He.start*Ee,it=(He.start+He.count)*Ee;if(me!==null)be=Math.max(be,me.start*Ee),it=Math.min(it,(me.start+me.count)*Ee);if(Se!==null)be=Math.max(be,0),it=Math.min(it,Se.count);else if(qe!==void 0&&qe!==null)be=Math.max(be,0),it=Math.min(it,qe.count);let Rt=it-be;if(Rt<0||Rt===1/0)return;le.setup(B,k,pe,W,Se);let _t,ut=D;if(Se!==null)_t=ae.get(Se),ut=ce,ut.setIndex(_t);if(B.isMesh)if(k.wireframe===!0)w.setLineWidth(k.wireframeLinewidth*It()),ut.setMode(L.LINES);else ut.setMode(L.TRIANGLES);else if(B.isLine){let Wt=k.linewidth;if(Wt===void 0)Wt=1;if(w.setLineWidth(Wt*It()),B.isLineSegments)ut.setMode(L.LINES);else if(B.isLineLoop)ut.setMode(L.LINE_LOOP);else ut.setMode(L.LINE_STRIP)}else if(B.isPoints)ut.setMode(L.POINTS);else if(B.isSprite)ut.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(!tt.get("WEBGL_multi_draw")){let{_multiDrawStarts:Wt,_multiDrawCounts:xe,_multiDrawCount:Jt}=B,Ke=Se?ae.get(Se).bytesPerElement:1,yn=I.get(k).currentProgram.getUniforms();for(let Vn=0;Vn<Jt;Vn++)yn.setValue(L,"_gl_DrawID",Vn),ut.render(Wt[Vn]/Ke,xe[Vn])}else ut.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else if(B.isInstancedMesh)ut.renderInstances(be,Rt,B.count);else if(W.isInstancedBufferGeometry){let Wt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,Wt);ut.renderInstances(be,Rt,xe)}else ut.render(be,Rt)};function Hh(y,N,W,k){if(P!==null&&y.isNodeMaterial)P.setObject(k,y);if(Ze===!0)oe.setState(y,W,!1);if(y.transparent===!0&&y.side===wn&&y.forceSinglePass===!1)y.side=Xt,y.needsUpdate=!0,yo(y,N,k),y.side=zi,y.needsUpdate=!0,yo(y,N,k),y.side=wn;else yo(y,N,k)}this.compile=function(y,N,W=null){if(W===null)W=y;if(P!==null)P.renderStart(y,N,W);if(b=he.get(W),b.init(N),A.push(b),W.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}}),y!==W)y.traverseVisible(function(B){if(B.isLight&&B.layers.test(N.layers)){if(b.pushLight(B),B.castShadow)b.pushShadow(B)}});if(b.setupLights(),P!==null)P.updateLights(b.state.lightsArray);if(rt=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,rt),Ze===!0)oe.setGlobalState(this.clippingPlanes,N);if(P!==null)Le.render(b.state.shadowsArray,W,N);let k=new Set;if(y.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let me=B.material;if(me)if(Array.isArray(me))for(let ye=0;ye<me.length;ye++){let pe=me[ye];Hh(pe,W,N,B),k.add(pe)}else Hh(me,W,N,B),k.add(me)}),b=A.pop(),P!==null)P.renderEnd();return k},this.compileAsync=function(y,N,W=null){let k=this.compile(y,N,W);return new Promise((B)=>{function me(){if(k.forEach(function(ye){let Se=I.get(ye).currentProgram;if(Se===void 0||Se.isReady())k.delete(ye)}),k.size===0){B(y);return}setTimeout(me,10)}if(tt.get("KHR_parallel_shader_compile")!==null)me();else setTimeout(me,10)})};let mc=null;function rv(y){if(mc)mc(y)}function Vh(){tr.stop()}function Wh(){tr.start()}let tr=new up;if(tr.setAnimationLoop(rv),typeof self<"u")tr.setContext(self);this.setAnimationLoop=function(y){mc=y,de.setAnimationLoop(y),y===null?tr.stop():tr.start()},de.addEventListener("sessionstart",Vh),de.addEventListener("sessionend",Wh),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;if(P!==null)P.renderStart(y,N);let W=de.enabled===!0&&de.isPresenting===!0,k=_!==null&&(z===null||W)&&_.begin(M,z);if(y.matrixWorldAutoUpdate===!0)y.updateMatrixWorld();if(N.parent===null&&N.matrixWorldAutoUpdate===!0)N.updateMatrixWorld();if(de.enabled===!0&&de.isPresenting===!0&&(_===null||_.isCompositing()===!1)){if(de.cameraAutoUpdate===!0)de.updateCamera(N);N=de.getCamera()}if(y.isScene===!0)y.onBeforeRender(M,y,N,z);if(b=he.get(y,A.length),b.init(N),b.state.textureUnits=V.getTextureUnits(),A.push(b),je.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ze.setFromProjectionMatrix(je,Bl,N.reversedDepth),rt=this.localClippingEnabled,Ze=oe.init(this.clippingPlanes,rt),S=Ae.get(y,T.length),S.init(),T.push(S),de.enabled===!0&&de.isPresenting===!0){let ye=M.xr.getDepthSensingMesh();if(ye!==null)gc(ye,N,-1/0,M.sortObjects)}if(gc(y,N,0,M.sortObjects),S.finish(),P!==null)P.updateLights(b.state.lightsArray);if(M.sortObjects===!0)S.sort(se,Pe);if(Pt=de.enabled===!1||de.isPresenting===!1||de.hasDepthSensing()===!1,Pt)De.addToRenderList(S,y);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ze===!0)oe.beginShadows();let B=b.state.shadowsArray;if(Le.render(B,y,N),Ze===!0)oe.endShadows();if((k&&_.hasRenderPass())===!1){let ye=S.opaque,pe=S.transmissive;if(b.setupLights(),N.isArrayCamera){let Se=N.cameras;if(pe.length>0)for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee];Zh(ye,pe,y,qe)}if(Pt)De.render(y);for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee];$h(S,y,qe,qe.viewport)}}else{if(pe.length>0)Zh(ye,pe,y,N);if(Pt)De.render(y);$h(S,y,N)}}if(z!==null&&X===0)V.updateMultisampleRenderTarget(z),V.updateRenderTargetMipmap(z);if(k)_.end(M);if(y.isScene===!0)y.onAfterRender(M,y,N);if(le.resetDefaultState(),te=-1,H=null,A.pop(),A.length>0){if(b=A[A.length-1],V.setTextureUnits(b.state.textureUnits),Ze===!0)oe.setGlobalState(M.clippingPlanes,b.state.camera)}else b=null;if(T.pop(),T.length>0)S=T[T.length-1];else S=null;if(P!==null)P.renderEnd()};function gc(y,N,W,k){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)W=y.renderOrder;else if(y.isLOD){if(y.autoUpdate===!0)y.update(N)}else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight){if(b.pushLight(y),y.castShadow)b.pushShadow(y)}else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(ze)){if(k)gt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(je);let ye=q.update(y),pe=y.material;if(pe.visible)S.push(y,ye,pe,W,gt.z,null,N)}}else if(y.isMesh||y.isLine||y.isPoints){if(!y.frustumCulled||y.intersectsFrustum(ze)){let ye=q.update(y),pe=y.material;if(k){if(y.boundingSphere!==void 0){if(y.boundingSphere===null)y.computeBoundingSphere();gt.copy(y.boundingSphere.center)}else{if(ye.boundingSphere===null)ye.computeBoundingSphere();gt.copy(ye.boundingSphere.center)}gt.applyMatrix4(y.matrixWorld).applyMatrix4(je)}if(Array.isArray(pe)){let Se=ye.groups;for(let Ee=0,He=Se.length;Ee<He;Ee++){let qe=Se[Ee],be=pe[qe.materialIndex];if(be&&be.visible)S.push(y,ye,be,W,gt.z,qe,N)}}else if(pe.visible)S.push(y,ye,pe,W,gt.z,null,N)}}}let me=y.children;for(let ye=0,pe=me.length;ye<pe;ye++)gc(me[ye],N,W,k)}function $h(y,N,W,k){let{opaque:B,transmissive:me,transparent:ye}=y;if(b.setupLightsView(W),Ze===!0)oe.setGlobalState(M.clippingPlanes,W);if(k)w.viewport(Q.copy(k));if(B.length>0)vo(B,N,W);if(me.length>0)vo(me,N,W);if(ye.length>0)vo(ye,N,W);w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function Zh(y,N,W,k){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new fn(1,1,{generateMipmaps:!0,type:be?jn:Un,minFilter:Yn,samples:Math.max(4,yt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:We.workingColorSpace})}let me=b.state.transmissionRenderTarget[k.id],ye=k.viewport||Q;me.setSize(ye.z*M.transmissionResolutionScale,ye.w*M.transmissionResolutionScale);let pe=M.getRenderTarget(),Se=M.getActiveCubeFace(),Ee=M.getActiveMipmapLevel();if(M.setRenderTarget(me),M.getClearColor(ve),Ge=M.getClearAlpha(),Ge<1)M.setClearColor(16777215,0.5);if(M.clear(),Pt)De.render(W);let He=M.toneMapping;M.toneMapping=Dn;let qe=k.viewport;if(k.viewport!==void 0)k.viewport=void 0;if(b.setupLightsView(k),Ze===!0)oe.setGlobalState(M.clippingPlanes,k);if(vo(y,W,k),V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me),tt.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let it=0,Rt=N.length;it<Rt;it++){let _t=N[it],{object:ut,geometry:Wt,material:xe,group:Jt}=_t;if(xe.side===wn&&ut.layers.test(k.layers)){let Ke=xe.side;xe.side=Xt,xe.needsUpdate=!0,Xh(ut,W,k,Wt,xe,Jt),xe.side=Ke,xe.needsUpdate=!0,be=!0}}if(be===!0)V.updateMultisampleRenderTarget(me),V.updateRenderTargetMipmap(me)}if(M.setRenderTarget(pe,Se,Ee),M.setClearColor(ve,Ge),qe!==void 0)k.viewport=qe;M.toneMapping=He}function vo(y,N,W){let k=N.isScene===!0?N.overrideMaterial:null;for(let B=0,me=y.length;B<me;B++){let ye=y[B],{object:pe,geometry:Se,group:Ee}=ye,He=ye.material;if(He.allowOverride===!0&&k!==null)He=k;if(pe.layers.test(W.layers))Xh(pe,N,W,Se,He,Ee)}}function Xh(y,N,W,k,B,me){if(P!==null&&B.isNodeMaterial)P.setObject(y,B);if(y.onBeforeRender(M,N,W,k,B,me),y.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),B.onBeforeRender(M,N,W,k,y,me),B.transparent===!0&&B.side===wn&&B.forceSinglePass===!1)B.side=Xt,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=zi,B.needsUpdate=!0,M.renderBufferDirect(W,N,k,B,y,me),B.side=wn;else M.renderBufferDirect(W,N,k,B,y,me);y.onAfterRender(M,N,W,k,B,me)}function yo(y,N,W){if(N.isScene!==!0)N=nn;let k=I.get(y),B=b.state.lights,me=b.state.shadowsArray,ye=B.state.version,pe=J.getParameters(y,B.state,me,N,W,b.state.lightProbeGridArray),Se=J.getProgramCacheKey(pe),Ee=k.programs;k.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,k.fog=N.fog;let He=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;if(k.envMap=ie.get(y.envMap||k.environment,He),k.envMapRotation=k.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Ee===void 0)y.addEventListener("dispose",Hn),Ee=new Map,k.programs=Ee;let qe=Ee.get(Se);if(qe!==void 0){if(k.currentProgram===qe&&k.lightsStateVersion===ye)return Yh(y,pe),qe}else{if(pe.uniforms=J.getUniforms(y),P!==null&&y.isNodeMaterial)P.build(y,W,pe);y.onBeforeCompile(pe,M),qe=J.acquireProgram(pe,Se),Ee.set(Se,qe),k.uniforms=pe.uniforms}let be=k.uniforms;if(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)be.clippingPlanes=oe.uniform;if(Yh(y,pe),k.needsLights=cv(y),k.lightsStateVersion=ye,k.needsLights)be.ambientLightColor.value=B.state.ambient,be.lightProbe.value=B.state.probe,be.sunLights.value=B.state.sun,be.sunLightShadows.value=B.state.sunShadow,be.directionalLights.value=B.state.directional,be.directionalLightShadows.value=B.state.directionalShadow,be.spotLights.value=B.state.spot,be.spotLightShadows.value=B.state.spotShadow,be.rectAreaLights.value=B.state.rectArea,be.ltc_1.value=B.state.rectAreaLTC1,be.ltc_2.value=B.state.rectAreaLTC2,be.pointLights.value=B.state.point,be.pointLightShadows.value=B.state.pointShadow,be.hemisphereLights.value=B.state.hemi,be.sunShadowMatrix.value=B.state.sunShadowMatrix,be.sunShadowCascade.value=B.state.sunShadowCascade,be.directionalShadowMatrix.value=B.state.directionalShadowMatrix,be.spotLightMatrix.value=B.state.spotLightMatrix,be.spotLightMap.value=B.state.spotLightMap,be.pointShadowMatrix.value=B.state.pointShadowMatrix;return k.lightProbeGrid=b.state.lightProbeGridArray.length>0,k.currentProgram=qe,k.uniformsList=null,qe}function qh(y){if(y.uniformsList===null){let N=y.currentProgram.getUniforms();y.uniformsList=Ys.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function Yh(y,N){let W=I.get(y);W.outputColorSpace=N.outputColorSpace,W.batching=N.batching,W.batchingColor=N.batchingColor,W.instancing=N.instancing,W.instancingColor=N.instancingColor,W.instancingMorph=N.instancingMorph,W.skinning=N.skinning,W.morphTargets=N.morphTargets,W.morphNormals=N.morphNormals,W.morphColors=N.morphColors,W.morphTargetsCount=N.morphTargetsCount,W.numClippingPlanes=N.numClippingPlanes,W.numIntersection=N.numClipIntersection,W.vertexAlphas=N.vertexAlphas,W.vertexTangents=N.vertexTangents,W.toneMapping=N.toneMapping}function sv(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;R.setFromMatrixPosition(N.matrixWorld);for(let W=0,k=y.length;W<k;W++){let B=y[W];if(B.texture!==null&&B.boundingBox.containsPoint(R))return B}return null}function ov(y,N,W,k,B){if(N.isScene!==!0)N=nn;V.resetTextureUnits();let me=N.fog,ye=k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial?N.environment:null,pe=z===null?M.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:We.workingColorSpace,Se=k.isMeshStandardMaterial||k.isMeshLambertMaterial&&!k.envMap||k.isMeshPhongMaterial&&!k.envMap,Ee=ie.get(k.envMap||ye,Se),He=k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,qe=!!W.attributes.tangent&&(!!k.normalMap||k.anisotropy>0),be=!!W.morphAttributes.position,it=!!W.morphAttributes.normal,Rt=!!W.morphAttributes.color,_t=Dn;if(k.toneMapped){if(z===null||z.isXRRenderTarget===!0)_t=M.toneMapping}let ut=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Wt=ut!==void 0?ut.length:0,xe=I.get(k),Jt=b.state.lights;if(Ze===!0){if(rt===!0||y!==H){let dt=y===H&&k.id===te;oe.setState(k,y,dt)}}let Ke=!1;if(k.version===xe.__version){if(xe.needsLights&&xe.lightsStateVersion!==Jt.state.version)Ke=!0;else if(xe.outputColorSpace!==pe)Ke=!0;else if(B.isBatchedMesh&&xe.batching===!1)Ke=!0;else if(!B.isBatchedMesh&&xe.batching===!0)Ke=!0;else if(B.isBatchedMesh&&xe.batchingColor===!0&&B._colorsTexture===null)Ke=!0;else if(B.isBatchedMesh&&xe.batchingColor===!1&&B._colorsTexture!==null)Ke=!0;else if(B.isInstancedMesh&&xe.instancing===!1)Ke=!0;else if(!B.isInstancedMesh&&xe.instancing===!0)Ke=!0;else if(B.isSkinnedMesh&&xe.skinning===!1)Ke=!0;else if(!B.isSkinnedMesh&&xe.skinning===!0)Ke=!0;else if(B.isInstancedMesh&&xe.instancingColor===!0&&B.instanceColor===null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingColor===!1&&B.instanceColor!==null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!0&&B.morphTexture===null)Ke=!0;else if(B.isInstancedMesh&&xe.instancingMorph===!1&&B.morphTexture!==null)Ke=!0;else if(xe.envMap!==Ee)Ke=!0;else if(k.fog===!0&&xe.fog!==me)Ke=!0;else if(xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==oe.numPlanes||xe.numIntersection!==oe.numIntersection))Ke=!0;else if(xe.vertexAlphas!==He)Ke=!0;else if(xe.vertexTangents!==qe)Ke=!0;else if(xe.morphTargets!==be)Ke=!0;else if(xe.morphNormals!==it)Ke=!0;else if(xe.morphColors!==Rt)Ke=!0;else if(xe.toneMapping!==_t)Ke=!0;else if(xe.morphTargetsCount!==Wt)Ke=!0;else if(!!xe.lightProbeGrid!==b.state.lightProbeGridArray.length>0)Ke=!0}else Ke=!0,xe.__version=k.version;let yn=xe.currentProgram;if(Ke===!0){if(yn=yo(k,N,B),P&&k.isNodeMaterial)P.onUpdateProgram(k,yn,xe)}let Vn=!1,Ei=!1,Tr=!1,ct=yn.getUniforms(),Tt=xe.uniforms;if(w.useProgram(yn.program))Vn=!0,Ei=!0,Tr=!0;if(k.id!==te)te=k.id,Ei=!0;if(xe.needsLights){let dt=sv(b.state.lightProbeGridArray,B);if(xe.lightProbeGrid!==dt)xe.lightProbeGrid=dt,Ei=!0}if(Vn||H!==y){if(w.buffers.depth.getReversed()&&y.reversedDepth!==!0)y._reversedDepth=!0,y.updateProjectionMatrix();ct.setValue(L,"projectionMatrix",y.projectionMatrix),ct.setValue(L,"viewMatrix",y.matrixWorldInverse);let Ri=ct.map.cameraPosition;if(Ri!==void 0)Ri.setValue(L,Gt.setFromMatrixPosition(y.matrixWorld));if(yt.logarithmicDepthBuffer)ct.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2));if(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)ct.setValue(L,"isOrthographic",y.isOrthographicCamera===!0);if(H!==y)H=y,Ei=!0,Tr=!0}if(xe.needsLights){if(Jt.state.sunShadowMap.length>0)ct.setValue(L,"sunShadowMap",Jt.state.sunShadowMap,V);if(Jt.state.directionalShadowMap.length>0)ct.setValue(L,"directionalShadowMap",Jt.state.directionalShadowMap,V);if(Jt.state.spotShadowMap.length>0)ct.setValue(L,"spotShadowMap",Jt.state.spotShadowMap,V);if(Jt.state.pointShadowMap.length>0)ct.setValue(L,"pointShadowMap",Jt.state.pointShadowMap,V)}if(B.isSkinnedMesh){ct.setOptional(L,B,"bindMatrix"),ct.setOptional(L,B,"bindMatrixInverse");let dt=B.skeleton;if(dt){if(dt.boneTexture===null)dt.computeBoneTexture();ct.setValue(L,"boneTexture",dt.boneTexture,V)}}if(B.isBatchedMesh){if(ct.setOptional(L,B,"batchingTexture"),ct.setValue(L,"batchingTexture",B._matricesTexture,V),ct.setOptional(L,B,"batchingIdTexture"),ct.setValue(L,"batchingIdTexture",B._indirectTexture,V),ct.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null)ct.setValue(L,"batchingColorTexture",B._colorsTexture,V)}let Ai=W.morphAttributes;if(Ai.position!==void 0||Ai.normal!==void 0||Ai.color!==void 0)Je.update(B,W,yn);if(Ei||xe.receiveShadow!==B.receiveShadow)xe.receiveShadow=B.receiveShadow,ct.setValue(L,"receiveShadow",B.receiveShadow);if((k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&N.environment!==null)Tt.envMapIntensity.value=N.environmentIntensity;if(Tt.dfgLUT!==void 0)Tt.dfgLUT.value=tT();if(Ei){if(ct.setValue(L,"toneMappingExposure",M.toneMappingExposure),xe.needsLights)av(Tt,Tr);if(me&&k.fog===!0)ge.refreshFogUniforms(Tt,me);if(ge.refreshMaterialUniforms(Tt,k,re,Z,b.state.transmissionRenderTarget[y.id]),xe.needsLights&&xe.lightProbeGrid){let dt=xe.lightProbeGrid;Tt.probesSH.value=dt.texture,Tt.probesMin.value.copy(dt.boundingBox.min),Tt.probesMax.value.copy(dt.boundingBox.max),Tt.probesResolution.value.copy(dt.resolution)}Ys.upload(L,qh(xe),Tt,V)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0)Ys.upload(L,qh(xe),Tt,V),k.uniformsNeedUpdate=!1;if(k.isSpriteMaterial)ct.setValue(L,"center",B.center);if(ct.setValue(L,"modelViewMatrix",B.modelViewMatrix),ct.setValue(L,"normalMatrix",B.normalMatrix),ct.setValue(L,"modelMatrix",B.matrixWorld),k.uniformsGroups!==void 0){let dt=k.uniformsGroups;for(let Ri=0,Er=dt.length;Ri<Er;Ri++){let Kh=dt[Ri];_e.update(Kh,yn),_e.bind(Kh,yn)}}return yn}function av(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.sunLights.needsUpdate=N,y.sunLightShadows.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function cv(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(y,N,W){let k=I.get(y);if(k.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,k.__autoAllocateDepthBuffer===!1)k.__useRenderToTexture=!1;I.get(y.texture).__webglTexture=N,I.get(y.depthTexture).__webglTexture=k.__autoAllocateDepthBuffer?void 0:W,k.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){let W=I.get(y);W.__webglFramebuffer=N,W.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,W=0){z=y,G=N,X=W;let k=null,B=!1,me=!1;if(y){let pe=I.get(y);if(pe.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(L.FRAMEBUFFER,pe.__webglFramebuffer),Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest,w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),te=-1;return}else if(pe.__webglFramebuffer===void 0)V.setupRenderTarget(y);else if(pe.__hasExternalTextures)V.rebindTextures(y,I.get(y.texture).__webglTexture,I.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let He=y.depthTexture;if(pe.__boundDepthTexture!==He){if(He!==null&&I.has(He)&&(y.width!==He.image.width||y.height!==He.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");V.setupDepthRenderbuffer(y)}}let Se=y.texture;if(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)me=!0;let Ee=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget){if(Array.isArray(Ee[N]))k=Ee[N][W];else k=Ee[N];B=!0}else if(y.samples>0&&V.useMultisampledRTT(y)===!1)k=I.get(y).__webglMultisampledFramebuffer;else if(Array.isArray(Ee))k=Ee[W];else k=Ee;Q.copy(y.viewport),ee.copy(y.scissor),Te=y.scissorTest}else Q.copy(Ie).multiplyScalar(re).floor(),ee.copy(we).multiplyScalar(re).floor(),Te=mt;if(W!==0)k=O;if(w.bindFramebuffer(L.FRAMEBUFFER,k))w.drawBuffers(y,k);if(w.viewport(Q),w.scissor(ee),w.setScissorTest(Te),B){let pe=I.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pe.__webglTexture,W)}else if(me){let pe=N;for(let Se=0;Se<y.textures.length;Se++){let Ee=I.get(y.textures[Se]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Se,Ee.__webglTexture,W,pe)}}else if(y!==null&&W!==0){let pe=I.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pe.__webglTexture,W)}te=-1};function jh(y){let N=I.get(y);if(N.__readFormat!==y.format||N.__readType!==y.type)N.__readFormat=y.format,N.__readType=y.type,N.__formatReadable=yt.textureFormatReadable(y.format),N.__typeReadable=yt.textureTypeReadable(y.type);return N}if(this.readRenderTargetPixels=function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se){w.bindFramebuffer(L.FRAMEBUFFER,Se);try{let Ee=y.textures[pe],{format:He,type:qe}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=jh(Ee);if(be.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B))L.readPixels(N,W,k,B,Y.convert(He),Y.convert(qe),me)}finally{let Ee=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(y,N,W,k,B,me,ye,pe=0){if(!(y&&y.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=I.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ye!==void 0)Se=Se[ye];if(Se)if(N>=0&&N<=y.width-k&&(W>=0&&W<=y.height-B)){w.bindFramebuffer(L.FRAMEBUFFER,Se);let Ee=y.textures[pe],{format:He,type:qe}=Ee;if(y.textures.length>1)L.readBuffer(L.COLOR_ATTACHMENT0+pe);let be=jh(Ee);if(be.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let it=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,it),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(N,W,k,B,Y.convert(He),Y.convert(qe),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let Rt=z!==null?I.get(z).__webglFramebuffer:null;w.bindFramebuffer(L.FRAMEBUFFER,Rt);let _t=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Ld(L,_t,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,it),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer(it),L.deleteSync(_t),me}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,W=0){let k=Math.pow(2,-W),B=Math.floor(y.image.width*k),me=Math.floor(y.image.height*k),ye=N!==null?N.x:0,pe=N!==null?N.y:0;V.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,W,0,0,ye,pe,B,me),w.unbindTexture()},this.copyTextureToTexture=function(y,N,W=null,k=null,B=0,me=0){let ye,pe,Se,Ee,He,qe,be,it,Rt,_t=y.isCompressedTexture?y.mipmaps[me]:y.image;if(W!==null)ye=W.max.x-W.min.x,pe=W.max.y-W.min.y,Se=W.isBox3?W.max.z-W.min.z:1,Ee=W.min.x,He=W.min.y,qe=W.isBox3?W.min.z:0;else{let Tt=Math.pow(2,-B);if(ye=Math.floor(_t.width*Tt),pe=Math.floor(_t.height*Tt),y.isDataArrayTexture)Se=_t.depth;else if(y.isData3DTexture)Se=Math.floor(_t.depth*Tt);else Se=1;Ee=0,He=0,qe=0}if(k!==null)be=k.x,it=k.y,Rt=k.z;else be=0,it=0,Rt=0;let ut=Y.convert(N.format),Wt=Y.convert(N.type),xe;if(N.isData3DTexture)V.setTexture3D(N,0),xe=L.TEXTURE_3D;else if(N.isDataArrayTexture||N.isCompressedArrayTexture)V.setTexture2DArray(N,0),xe=L.TEXTURE_2D_ARRAY;else V.setTexture2D(N,0),xe=L.TEXTURE_2D;w.activeTexture(L.TEXTURE0),w.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),w.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),w.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);let Jt=w.getParameter(L.UNPACK_ROW_LENGTH),Ke=w.getParameter(L.UNPACK_IMAGE_HEIGHT),yn=w.getParameter(L.UNPACK_SKIP_PIXELS),Vn=w.getParameter(L.UNPACK_SKIP_ROWS),Ei=w.getParameter(L.UNPACK_SKIP_IMAGES);w.pixelStorei(L.UNPACK_ROW_LENGTH,_t.width),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,_t.height),w.pixelStorei(L.UNPACK_SKIP_PIXELS,Ee),w.pixelStorei(L.UNPACK_SKIP_ROWS,He),w.pixelStorei(L.UNPACK_SKIP_IMAGES,qe);let Tr=y.isDataArrayTexture||y.isData3DTexture,ct=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){let Tt=I.get(y),Ai=I.get(N),dt=I.get(Tt.__renderTarget),Ri=I.get(Ai.__renderTarget);w.bindFramebuffer(L.READ_FRAMEBUFFER,dt.__webglFramebuffer),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,Ri.__webglFramebuffer);for(let Er=0;Er<Se;Er++){if(Tr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(y).__webglTexture,B,qe+Er),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,I.get(N).__webglTexture,me,Rt+Er);L.blitFramebuffer(Ee,He,ye,pe,be,it,ye,pe,L.DEPTH_BUFFER_BIT,L.NEAREST)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||y.isRenderTargetTexture||I.has(y)){let Tt=I.get(y),Ai=I.get(N);w.bindFramebuffer(L.READ_FRAMEBUFFER,K),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,C);for(let dt=0;dt<Se;dt++){if(Tr)L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Tt.__webglTexture,B,qe+dt);else L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Tt.__webglTexture,B);if(ct)L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Ai.__webglTexture,me,Rt+dt);else L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Ai.__webglTexture,me);if(B!==0)L.blitFramebuffer(Ee,He,ye,pe,be,it,ye,pe,L.COLOR_BUFFER_BIT,L.NEAREST);else if(ct)L.copyTexSubImage3D(xe,me,be,it,Rt+dt,Ee,He,ye,pe);else L.copyTexSubImage2D(xe,me,be,it,Ee,He,ye,pe)}w.bindFramebuffer(L.READ_FRAMEBUFFER,null),w.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(ct)if(y.isDataTexture||y.isData3DTexture)L.texSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,Wt,_t.data);else if(N.isCompressedArrayTexture)L.compressedTexSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,_t.data);else L.texSubImage3D(xe,me,be,it,Rt,ye,pe,Se,ut,Wt,_t);else if(y.isDataTexture)L.texSubImage2D(L.TEXTURE_2D,me,be,it,ye,pe,ut,Wt,_t.data);else if(y.isCompressedTexture)L.compressedTexSubImage2D(L.TEXTURE_2D,me,be,it,_t.width,_t.height,ut,_t.data);else L.texSubImage2D(L.TEXTURE_2D,me,be,it,ye,pe,ut,Wt,_t);if(w.pixelStorei(L.UNPACK_ROW_LENGTH,Jt),w.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke),w.pixelStorei(L.UNPACK_SKIP_PIXELS,yn),w.pixelStorei(L.UNPACK_SKIP_ROWS,Vn),w.pixelStorei(L.UNPACK_SKIP_IMAGES,Ei),me===0&&N.generateMipmaps)L.generateMipmap(xe);w.unbindTexture()},this.initRenderTarget=function(y){if(I.get(y).__webglFramebuffer===void 0)V.setupRenderTarget(y)},this.initTexture=function(y){if(y.isCubeTexture)V.setTextureCube(y,0);else if(y.isData3DTexture)V.setTexture3D(y,0);else if(y.isDataArrayTexture||y.isCompressedArrayTexture)V.setTexture2DArray(y,0);else V.setTexture2D(y,0);w.unbindTexture()},this.resetState=function(){G=0,X=0,z=null,w.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=We._getDrawingBufferColorSpace(e),t.unpackColorSpace=We._getUnpackColorSpace()}}function vu(e,t){if(t===Ul)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Jr||t===Ps){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===Jr)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 wp(e){let t=new Map,n=new Map,i=e.clone();return Tp(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 Tp(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)Tp(e.children[i],t.children[i],n)}class Eu extends Si{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Np(t)}),this.register(function(t){return new Dp(t)}),this.register(function(t){return new Vp(t)}),this.register(function(t){return new Wp(t)}),this.register(function(t){return new $p(t)}),this.register(function(t){return new Up(t)}),this.register(function(t){return new Fp(t)}),this.register(function(t){return new zp(t)}),this.register(function(t){return new kp(t)}),this.register(function(t){return new Lp(t)}),this.register(function(t){return new Bp(t)}),this.register(function(t){return new Op(t)}),this.register(function(t){return new Hp(t)}),this.register(function(t){return new Gp(t)}),this.register(function(t){return new Pp(t)}),this.register(function(t){return new Mu(t,Xe.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Mu(t,Xe.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Zp(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=qi.extractUrlBase(e);s=qi.resolveURL(c,this.path)}else s=qi.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 Vs(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))===Xp){try{s[Xe.KHR_BINARY_GLTF]=new qp(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Xe.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Qp(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],f=r.extensionsRequired||[];switch(u){case Xe.KHR_MATERIALS_UNLIT:s[u]=new Ip;break;case Xe.KHR_DRACO_MESH_COMPRESSION:s[u]=new Yp(r,this.dracoLoader);break;case Xe.KHR_TEXTURE_TRANSFORM:s[u]=new jp;break;case Xe.KHR_MESH_QUANTIZATION:s[u]=new Kp;break;default:if(f.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function iT(){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 Et(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Xe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Pp{constructor(e){this.parser=e,this.name=Xe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new Oe(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],hn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new ss(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new rs(l),c.distance=u;break;case"spot":c=new Ma(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),ti(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class Ip{constructor(){this.name=Xe.KHR_MATERIALS_UNLIT}getMaterialType(){return Jn}extendParams(e,t,n){let i=[];e.color=new Oe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],hn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,Bi))}return Promise.all(i)}}class Lp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class Np{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ne(r,r)}}return Promise.all(i)}}class Dp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Op{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Up{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SHEEN}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new Oe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],hn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Bi));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class Fp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 zp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_VOLUME}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Oe().setRGB(r[0],r[1],r[2],hn),Promise.all(i)}}class kp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_IOR}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Bp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new Oe().setRGB(r[0],r[1],r[2],hn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Bi));return Promise.all(i)}}class Gp{constructor(e){this.parser=e,this.name=Xe.EXT_MATERIALS_BUMP}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Hp{constructor(e){this.parser=e,this.name=Xe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Et(this.parser,e,this.name)!==null?pn:null}extendMaterialParams(e,t){let n=Et(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 Vp{constructor(e){this.parser=e,this.name=Xe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Wp{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class $p{constructor(e){this.parser=e,this.name=Xe.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Mu{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,f=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,f,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,f,i.mode,i.filter),h})})}else return null}}class Zp{constructor(e){this.name=Xe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==En.TRIANGLES&&c.mode!==En.TRIANGLE_STRIP&&c.mode!==En.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,h=[];for(let d of u){let g=new Be,x=new U,p=new Ft,m=new U(1,1,1),E=new ts(d.geometry,d.material,f);for(let S=0;S<f;S++){if(a.TRANSLATION)x.fromBufferAttribute(a.TRANSLATION,S);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,S);if(a.SCALE)m.fromBufferAttribute(a.SCALE,S);E.setMatrixAt(S,g.compose(x,p,m))}let R=null;for(let S in a)if(S==="_COLOR_0"){let b=a[S];E.instanceColor=new Oi(b.array,b.itemSize,b.normalized)}else if(S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"){if(R===null){let T=E.geometry;R=new qt,R.name=T.name;for(let A in T.attributes)R.setAttribute(A,T.attributes[A]);for(let A in T.morphAttributes)R.morphAttributes[A]=T.morphAttributes[A];if(T.index!==null)R.setIndex(T.index);R.morphTargetsRelative=T.morphTargetsRelative;for(let A of T.groups)R.addGroup(A.start,A.count,A.materialIndex);if(T.boundingBox!==null)R.boundingBox=T.boundingBox.clone();if(T.boundingSphere!==null)R.boundingSphere=T.boundingSphere.clone();R.drawRange.start=T.drawRange.start,R.drawRange.count=T.drawRange.count,R.userData=Object.assign({},T.userData),E.geometry=R}let b=a[S];R.setAttribute(S,new Oi(b.array,b.itemSize,b.normalized))}lt.prototype.copy.call(E,d),this.parser.assignFinalMaterial(E),h.push(E)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Xp="glTF",Ks=12,Ep={JSON:1313821514,BIN:5130562};class qp{constructor(e){this.name=Xe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Ks),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!==Xp)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-Ks,r=new DataView(e,Ks),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===Ep.JSON){let c=new Uint8Array(e,Ks+s,o);this.content=n.decode(c)}else if(a===Ep.BIN){let c=Ks+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Yp{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Xe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=wu[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=wu[l]||l.toLowerCase();if(s[l]!==void 0){let f=n.accessors[e.attributes[l]],h=ls[f.componentType];c[u]=h.name,a[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,f){i.decodeDracoFile(l,function(h){for(let d in h.attributes){let g=h.attributes[d],x=a[d];if(x!==void 0)g.normalized=x}u(h)},o,c,hn,f)})})}}class jp{constructor(){this.name=Xe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Kp{constructor(){this.name=Xe.KHR_MESH_QUANTIZATION}}class Au extends yi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,f=u*u,h=f*u,d=e*c,g=d-c,x=-2*h+3*f,p=h-f,m=1-x,E=p-f+u;for(let R=0;R!==o;R++){let S=s[g+R+o],b=s[g+R+a]*l,T=s[d+R+o],A=s[d+R]*l;r[R]=m*S+E*b+x*T+p*A}return r}}var rT=new Ft;class Jp extends Au{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return rT.fromArray(r).normalize().toArray(r),r}}var En={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},ls={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ap={9728:On,9729:kt,9984:Jo,9985:jr,9986:lr,9987:Yn},Rp={33071:Yr,33648:Ko,10497:qr},yu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wu={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"},Yi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},sT={CUBICSPLINE:void 0,LINEAR:sa,STEP:Ol},Su={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function oT(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new vi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:zi});return e.DefaultMaterial}function vr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function ti(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function aT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let f=t[l];if(f.POSITION!==void 0)i=!0;if(f.NORMAL!==void 0)r=!0;if(f.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let f=t[l];if(i){let h=f.POSITION!==void 0?n.getDependency("accessor",f.POSITION):e.attributes.position;o.push(h)}if(r){let h=f.NORMAL!==void 0?n.getDependency("accessor",f.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=f.COLOR_0!==void 0?n.getDependency("accessor",f.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],f=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=f;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function cT(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let i=0,r=n.length;i<r;i++)e.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function lT(e){let t,n=e.extensions&&e.extensions[Xe.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+bu(n.attributes);else t=e.indices+":"+bu(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+bu(e.targets[i]);return t}function bu(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 Tu(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 uT(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 hT=new Be;class Qp{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new iT,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 ya(this.options.manager);else this.textureLoader=new wa(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Vs(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 vr(r,o,i),ti(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Xe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(qi.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=yu[i.type],o=ls[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new zt(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=yu[i.type],c=ls[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,f=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0,g,x;if(h&&h!==u){let p=Math.floor(f/h),m="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,E=t.cache.get(m);if(!E)g=new c(o,p*h,i.count*h/l),E=new Ds(g,h/l),t.cache.add(m,E);x=new es(E,a,f%h/l,d)}else{if(o===null)g=new c(i.count*a);else g=new c(o,f,i.count*a);x=new zt(g,a,d)}if(i.sparse!==void 0){let p=yu.SCALAR,m=ls[i.sparse.indices.componentType],E=i.sparse.indices.byteOffset||0,R=i.sparse.values.byteOffset||0,S=new m(s[1],E,i.sparse.count*p),b=new c(s[2],R,i.sparse.count*a);if(o!==null)x=new zt(x.array.slice(),x.itemSize,x.normalized);x.normalized=!1;for(let T=0,A=S.length;T<A;T++){let _=S[T];if(x.setX(_,b[T*a]),a>=2)x.setY(_,b[T*a+1]);if(a>=3)x.setZ(_,b[T*a+2]);if(a>=4)x.setW(_,b[T*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=d}return x})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let f=(r.samplers||{})[s.sampler]||{};return l.magFilter=Ap[f.magFilter]||kt,l.minFilter=Ap[f.minFilter]||Yn,l.wrapS=Rp[f.wrapS]||qr,l.wrapT=Rp[f.wrapT]||qr,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==On&&l.minFilter!==kt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(f),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(f,h){let d=f;if(t.isImageBitmapLoader===!0)d=function(g){let x=new Mt(g);x.needsUpdate=!0,f(x)};t.load(qi.resolveURL(u,r.path),d,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return ti(u,s),u.userData.mimeType=s.mimeType||uT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Xe.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Xe.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Xe.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Bs,on.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 ks,on.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 vi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Xe.KHR_MATERIALS_UNLIT]){let u=i[Xe.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new Oe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],hn),o.opacity=f[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,Bi));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=wn;let l=r.alphaMode||Su.OPAQUE;if(l===Su.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Su.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==Jn){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ne(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==Jn){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!==Jn){let u=r.emissiveFactor;o.emissive=new Oe().setRGB(u[0],u[1],u[2],hn)}if(r.emissiveTexture!==void 0&&s!==Jn)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Bi));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(ti(u,r),t.associations.set(u,{materials:e}),r.extensions)vr(i,u,r);return u})}createUniqueName(e){let t=Qe.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Xe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return Cp(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=lT(c),u=i[l];if(u)s.push(u.promise);else{let f;if(c.extensions&&c.extensions[Xe.KHR_DRACO_MESH_COMPRESSION])f=r(c);else f=Cp(new qt,c,t);if(c.mode===En.TRIANGLE_STRIP)f=f.then((h)=>vu(h,Ps));else if(c.mode===En.TRIANGLE_FAN)f=f.then((h)=>vu(h,Jr));i[l]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?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 h=0,d=l.length;h<d;h++){let g=l[h],x=s[h],p,m=c[h];if(x.mode===En.TRIANGLES||x.mode===En.TRIANGLE_STRIP||x.mode===En.TRIANGLE_FAN||x.mode===void 0){let E=r.isSkinnedMesh===!0,R=g.hasAttribute("skinIndex")&&g.hasAttribute("skinWeight");if(E&&R===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=E&&R?new fa(g,m):new pt(g,m),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(x.mode===En.LINES)p=new da(g,m);else if(x.mode===En.LINE_STRIP)p=new Hi(g,m);else if(x.mode===En.LINE_LOOP)p=new pa(g,m);else if(x.mode===En.POINTS)p=new ns(g,m);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);if(Object.keys(p.geometry.morphAttributes).length>0)cT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),ti(p,r),x.extensions)vr(i,p,x);t.assignFinalMaterial(p),u.push(p)}for(let h=0,d=u.length;h<d;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)vr(i,u[0],r);return u[0]}let f=new $n;if(r.extensions)vr(i,f,r);t.associations.set(f,{meshes:e});for(let h=0,d=u.length;h<d;h++)f.add(u[h]);return f})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Lt(Is.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 ti(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let f=new Be;if(r!==null)f.fromArray(r.array,c*16);a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Fs(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,f=i.channels.length;u<f;u++){let h=i.channels[u],d=i.samplers[h.sampler],g=h.target,x=g.node,p=i.parameters!==void 0?i.parameters[d.input]:d.input,m=i.parameters!==void 0?i.parameters[d.output]:d.output;if(g.node===void 0)continue;s.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",m)),c.push(d),l.push(g)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],h=u[1],d=u[2],g=u[3],x=u[4],p=[];for(let E=0,R=f.length;E<R;E++){let S=f[E],b=h[E],T=d[E],A=g[E],_=x[E];if(S===void 0)continue;if(S.updateMatrix)S.updateMatrix();let M=n._createAnimationTracks(S,b,T,A,_);if(M)for(let F=0;F<M.length;F++)p.push(M[F])}let m=new Wr(r,void 0,p);return ti(m,i),m})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],f=c[2];if(f!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(f,hT)});for(let h=0,d=u.length;h<d;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,d=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],d.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new Os;else if(c.length>1)l=new $n;else if(c.length===1)l=c[0];else l=new lt;if(l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(ti(l,r),r.extensions)vr(n,l,r);if(r.matrix!==void 0){let u=new Be;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 $n;if(n.name)r.name=i.createUniqueName(n.name);if(ti(r,n),n.extensions)vr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let f=a[l];if(f.parent!==null)r.add(wp(f));else r.add(f)}let c=(l)=>{let u=new Map;for(let[f,h]of i.associations)if(f instanceof on||f instanceof Mt)u.set(f,h);return l.traverse((f)=>{let h=i.associations.get(f);if(h!=null)u.set(f,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(Yi[r.path]===Yi.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Yi[r.path]){case Yi.weights:l=$i;break;case Yi.rotation:l=Zi;break;case Yi.translation:case Yi.scale:l=gr;break;default:switch(n.itemSize){case 1:l=$i;break;case 2:case 3:default:l=gr;break}break}let u=i.interpolation!==void 0?sT[i.interpolation]:sa,f=this._getArrayFromAccessor(n);for(let h=0,d=a.length;h<d;h++){let g=new l(a[h]+"."+Yi[r.path],t.array,f,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(g);s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Tu(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 Zi?Jp:Au)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function fT(e,t,n){let i=t.attributes,r=new en;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=Tu(ls[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 f=s[l];if(f.POSITION!==void 0){let h=n.json.accessors[f.POSITION],{min:d,max:g}=h;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),h.normalized){let x=Tu(ls[h.componentType]);c.multiplyScalar(x)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new dn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function Cp(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=wu[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(We.workingColorSpace!==hn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${We.workingColorSpace}" not supported.`);return ti(e,t),fT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?aT(e,t.targets,n):e})}var em={type:"change"},Cu={type:"start"},nm={type:"end"},Ia=new Gi,tm=new bn,dT=Math.cos(70*Is.DEG2RAD),Ot=new U,an=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ru=0.000001;class Pu extends Ea{constructor(e,t=null){super(e,t);if(this.state=at.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:Ui.ROTATE,MIDDLE:Ui.DOLLY,RIGHT:Ui.PAN},this.touches={ONE:Fi.ROTATE,TWO:Fi.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 Ft,this._lastTargetPosition=new U,this._quat=new Ft().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new $s,this._sphericalDelta=new $s,this._scale=1,this._panOffset=new U,this._rotateStart=new Ne,this._rotateEnd=new Ne,this._rotateDelta=new Ne,this._panStart=new Ne,this._panEnd=new Ne,this._panDelta=new Ne,this._dollyStart=new Ne,this._dollyEnd=new Ne,this._dollyDelta=new Ne,this._dollyDirection=new U,this._mouse=new Ne,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mT.bind(this),this._onPointerDown=pT.bind(this),this._onPointerUp=gT.bind(this),this._onContextMenu=MT.bind(this),this._onMouseWheel=vT.bind(this),this._onKeyDown=yT.bind(this),this._onTouchStart=ST.bind(this),this._onTouchMove=bT.bind(this),this._onMouseDown=_T.bind(this),this._onMouseMove=xT.bind(this),this._interceptControlDown=wT.bind(this),this._interceptControlUp=TT.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=at.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(em),this.update(),this.state=at.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(Ot.copy(t).sub(this.target),Ot.applyQuaternion(this._quat),this._spherical.setFromVector3(Ot),this.autoRotate&&this.state===at.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+=an;else if(n>Math.PI)n-=an;if(i<-Math.PI)i+=an;else if(i>Math.PI)i-=an;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(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),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=Ot.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=Ot.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(Ia.origin.copy(this.object.position),Ia.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ia.direction))<dT)this.object.lookAt(this.target);else tm.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ia.intersectPlane(tm,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)>Ru||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ru||this._lastTargetPosition.distanceToSquared(this.target)>Ru)return this.dispatchEvent(em),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 an/60*this.autoRotateSpeed*e;else return an/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){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){if(this.screenSpacePanning===!0)Ot.setFromMatrixColumn(t,1);else Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot);Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Ot.copy(i).sub(this.target);let r=Ot.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(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*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(an*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(-an*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(an*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(-an*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(an*this._rotateDelta.x/t.clientHeight),this._rotateUp(an*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ne,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function pT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function mT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function gT(e){switch(this._removePointer(e),this._pointers.length){case 0:if(this.domElement.releasePointerCapture(e.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(nm),this.state=at.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function _T(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Ui.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=at.DOLLY;break;case Ui.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=at.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=at.ROTATE}break;case Ui.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=at.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=at.PAN}break;default:this.state=at.NONE}if(this.state!==at.NONE)this.dispatchEvent(Cu)}function xT(e){switch(this.state){case at.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case at.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case at.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function vT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==at.NONE)return;e.preventDefault(),this.dispatchEvent(Cu),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(nm)}function yT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function ST(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case Fi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=at.TOUCH_ROTATE;break;case Fi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=at.TOUCH_PAN;break;default:this.state=at.NONE}break;case 2:switch(this.touches.TWO){case Fi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=at.TOUCH_DOLLY_PAN;break;case Fi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=at.TOUCH_DOLLY_ROTATE;break;default:this.state=at.NONE}break;default:this.state=at.NONE}if(this.state!==at.NONE)this.dispatchEvent(Cu)}function bT(e){switch(this._trackPointer(e),this.state){case at.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case at.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case at.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case at.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=at.NONE}}function MT(e){if(this.enabled===!1)return;e.preventDefault()}function wT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function TT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Iu extends Qr{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Vi;e.deleteAttribute("uv");let t=new vi({side:Xt}),n=new vi,i=new rs(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 ts(e,n,6),o=new lt;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,us(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,us(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,us(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,us(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let f=new pt(e,us(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,0.1),this.add(f);let h=new pt(e,us(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 us(e){return new _a({color:0,emissive:16777215,emissiveIntensity:e})}function eo(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 Nu(e,t="|"){return e.map((n)=>Uu(n)).join(t)}function to(e,t){if(typeof t==="bigint")return t.toString();return t}class im{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 La(e){return new im(e)}function rm(e){return e===null||e===void 0}function Na(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function sm(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 zn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Da(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function bi(e){return Da(e._zod.def)??e._zod.def.shape}function om(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return zn(this,t,i),i},enumerable:!0,configurable:!0})}function am(e,t,n){if(t in e)zn(e,t,n);else e[t]=n}function yr(e,t,n,i){let r=bi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)om(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else am(e,s,i?i(o.value,s):o.value)}}function ET(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)om(e,n,()=>t[n]);else am(e,n,i.value)}}function gn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function cm(e){return JSON.stringify(e)}function lm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Du="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var um=La(()=>{if(cn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Sr(e){if(Qs(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(Qs(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Ou(e){if(Sr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var hm=new Set(["string","number","symbol"]);function Ki(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(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 Uu(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function fm(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Oa=(()=>({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]}))(),Fu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function AT(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 yr(s,e,Ua(e,t)),ni(e,gn(n,{shape:s,checks:[]}))}function Ua(e,t){let n=bi(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 RT(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(Ua(e,t)),o={};return yr(o,e,Reflect.ownKeys(bi(e)).filter((a)=>!s.has(a))),ni(e,gn(n,{shape:o,checks:[]}))}function CT(e,t){if(!Sr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=bi(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 ni(e,gn(e._zod.def,{shape:dm(e,t)}))}function dm(e,t){let n={};return yr(n,e,Reflect.ownKeys(bi(e))),ET(n,t),n}function PT(e,t){if(!Sr(t))throw Error("Invalid input to safeExtend: expected a plain object");return ni(e,gn(e._zod.def,{shape:dm(e,t)}))}function IT(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={};yr(n,e,Reflect.ownKeys(bi(e))),yr(n,t,Reflect.ownKeys(bi(t)));let i=gn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ni(e,i)}function pm(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(Ua(t,n)):void 0,c={};return yr(c,t,Reflect.ownKeys(bi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),ni(t,gn(t._zod.def,{shape:c,checks:[]}))}function LT(e,t,n){let i=n?new Set(Ua(t,n)):void 0,r={};return yr(r,t,Reflect.ownKeys(bi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),ni(t,gn(t._zod.def,{shape:r}))}function ii(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 mm(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 Ji(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Js(e){return typeof e==="string"?e:e?.message}function zu(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function ri(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:Js(e.inst?._zod.def?.error?.(e))??Js(s?.(e))??Js(t?.error?.(e))??Js(n.customError?.(e))??Js(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 NT=/[\uD800-\uDBFF]/;function Fa(e){let t=e.length;if(!NT.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 za(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function gm(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 br(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function _m(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else DT(e,n,i.value)}}function Mi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function ka(e,t,n){return Mi(e,t,n,!1)}function xm(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Mi(this,n,i(this))},set(r){Mi(this,n,r)}})}return t}function DT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Mi(this,t,n.bind(this))},set(i){Mi(this,t,i)}})}function OT(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Lu,ji=!1,UT={configurable:!0,get(){ji=!0;return}};function et(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Lu!==e._zod){Lu=void 0;return}Lu=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,UT);let r=ji;ji=!1;try{let s=n(this);if(ji)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return ji=ji||r,s}catch(s){throw delete this[t],ji=ji||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function FT(e,t,n,i){let r=OT(e,t);if(!r)return;Object.defineProperty(r,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:s})}})}var zT="~constantCatch";function vm(e){let t=()=>e;return t[zT]=!0,t}var ym;var ku={value:void 0,enumerable:!1},Sm="captureStackTrace"in Error?Error:null;function kT(e){let t=Sm;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Sm=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function j(e,t,n,i){let r={};function s(h){this.def=h,this.constr=f,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,d){if(!h._zod){ku.value=new s(d);try{Object.defineProperty(h,"_zod",ku)}finally{ku.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,d),a){let x=Object.getPrototypeOf(h),p=h._zod.constr.prototype,m=x;while(m&&m!==p)m=Object.getPrototypeOf(m);let E=m??x;if(!a.has(E))a.add(E),_m(E,o)}let g=f.prototype;for(let x in g){if(!Object.prototype.hasOwnProperty.call(g,x))continue;if(!(x in h))h[x]=g[x].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(h){let d=i?.Parent?kT(u):this;c(d,h);let g=d._zod.deferred;if(g){for(let p of g)p();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class si extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class no extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(ym=globalThis).__zod_globalConfig??(ym.__zod_globalConfig={});var cn=globalThis.__zod_globalConfig;function _n(e){if(e)Object.assign(cn,e);return cn}function BT(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,to,2)),e.message}function GT(e){this._zod.message=e}var HT={get:BT,set:GT,enumerable:!0,configurable:!0},Gu={value:void 0,enumerable:!1},bm=new WeakSet([Object.prototype,Error.prototype]),Mm=(e,t)=>{e.name="$ZodError",Gu.value=t,Object.defineProperty(e,"issues",Gu),Gu.value=void 0,Object.defineProperty(e,"message",HT);let n=Object.getPrototypeOf(e);if(!bm.has(n))bm.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})}})},wm=j("$ZodError",Mm),CP=j("$ZodError",Mm,void 0,{Parent:Error});function VT(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 Tm(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)VT(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function Em(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],f=l===a.length-1;if(u==="_errors"){if(f)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(f)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Ba(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ga=(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 si;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>ri(l,o,_n())));throw Du(c,s?.callee??t),c}return a.value};return t};var Ha=(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)=>ri(l,o,_n())));throw Du(c,s?.callee??t),c}return a.value};return t};var Va=(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 si;return s.issues.length?Am(e,s.issues,r):{success:!0,data:s.value}};function Am(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>ri(r,n,_n()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Wa=(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?Am(e,s.issues,r):{success:!0,data:s.value}};var WT=Symbol.for("zod.compile.invalid"),$T=Symbol.for("zod.compile.fallback"),Hu=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==WT)return!0;if(i.definite===!0&&n===void 0)return!1}return ZT(e,t,n)};function ZT(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[$T]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new si;return s.issues.length===0}var Vu=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},Rm=(e)=>{let t=Ga(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Ba(n,o))};return n};var Cm=(e)=>{let t=Ga(e),n=(i,r,s,o)=>t(i,r,s,Ba(n,o));return n};var Pm=(e)=>{let t=Ha(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Ba(n,o))};return n};var Im=(e)=>{let t=Ha(e),n=async(i,r,s,o)=>await t(i,r,s,Ba(n,o));return n};var Lm=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Va(e)(t,n,r)};var Nm=(e)=>(t,n,i)=>Va(e)(t,n,i);var Dm=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Wa(e)(t,n,r)};var Om=(e)=>async(t,n,i)=>Wa(e)(t,n,i);var Um=/^[cC][0-9a-z]{6,}$/,Fm=/^[0-9a-z]+$/,zm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,km=/^[0-9a-vA-V]{20}$/,Bm=/^[A-Za-z0-9]{27}$/,Gm=/^[a-zA-Z0-9_-]{21}$/;function Hm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Vm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Wm=/^([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})$/,$u=(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 $m=/^(?:[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 XT="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Zm(){return new RegExp(XT,"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])$/,qm=/^(([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])$/,jm=/^(([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])$/,Km=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Qm=/^https?$/,eg=/^\+[1-9]\d{6,14}$/;var tg="(?:(?:\\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 qT(e){return new RegExp(`^${e}$`)}var ng=qT(tg);function Wu(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 ig(e){return new RegExp(`^${Wu(e)}$`)}function rg(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Wu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Wu({precision:e.precision})}`:n;return new RegExp(`^${tg}T(?:${i})$`)}var sg=/^[\s\S]{0,}$/;var Zu=/^-?\d+$/,io=/^-?\d+(?:\.\d+)?$/,og=/^(?:true|false)$/i;var ag=/^[^A-Z]*$/,cg=/^[^a-z]*$/;var Ht=j("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Xu=(e)=>{let t=e.value;return!rm(t)&&t.length!==void 0},$a={number:"number",bigint:"bigint",object:"date"},qu=j("$ZodCheckLessThan",(e,t)=>{Ht.init(e,t);let n=$a[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:$a[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})}}),Yu=j("$ZodCheckGreaterThan",(e,t)=>{Ht.init(e,t);let n=$a[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:$a[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})}}),lg=j("$ZodCheckMultipleOf",(e,t)=>{Ht.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):sm(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})}}),ug=j("$ZodCheckNumberFormat",(e,t)=>{Ht.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Oa[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<r)o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var hg=j("$ZodCheckMaxLength",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Fa(r):s)<=t.maximum)return;let a=za(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fg=j("$ZodCheckMinLength",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Fa(r):s)>=t.minimum)return;let a=za(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dg=j("$ZodCheckLengthEquals",(e,t)=>{var n;Ht.init(e,t),(n=e._zod.def).when??(n.when=Xu),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Fa(r):s;if(o===t.length)return;let a=za(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})}}),so=j("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Ht.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=()=>{})}),pg=j("$ZodCheckRegex",(e,t)=>{so.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})}}),mg=j("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ag),so.init(e,t)}),gg=j("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cg),so.init(e,t)}),_g=j("$ZodCheckIncludes",(e,t)=>{Ht.init(e,t);let n=Ki(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})}}),xg=j("$ZodCheckStartsWith",(e,t)=>{Ht.init(e,t);let n=new RegExp(`^${Ki(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})}}),vg=j("$ZodCheckEndsWith",(e,t)=>{Ht.init(e,t);let n=new RegExp(`.*${Ki(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 yg=j("$ZodCheckOverwrite",(e,t)=>{Ht.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class ju{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 yg={major:4,minor:6,patch:4};var vt=j("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yg;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=ii(a),f;for(let h of c){if(h._zod.def.when){if(dm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new si;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(zu(a.issues,d,e),!u)u=ii(a,d)});else{if(a.issues.length===d)continue;if(zu(a.issues,d,e),!u)u=ii(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(ii(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new si;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new si;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ka(this,"~standard",Ju(this))},set "~standard"(e){Mi(this,"~standard",e)}}),Ig=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ri(n,t,_n()))}:{value:e.value};async function ZT(e,t){let n={async:!0};return Ig(await e._zod.run({value:t,issues:[]},n),n)}function Ju(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Ig(i,n)}catch(i){}return ZT(e,t)},vendor:"zod",version:1}}var Ya=j("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??ig,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}}),xt=j("$ZodStringFormat",(e,t)=>{so.init(e,t),Ya.init(e,t)}),Lg=j("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Hm),xt.init(e,t)}),Ng=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=$u(i))}else t.pattern??(t.pattern=$u());xt.init(e,t)}),Dg=j("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Vm),xt.init(e,t)}),Og=1,Xa=2;function Ug(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function XT(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Ug(e)||Xa;return qT(e,t)}function qT(e,t){if(!t.normalize&&t.protocol?.source===Km.source&&!/^https?:\/\//i.test(e))return Og;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xa}return new URL(e)}catch{return Xa}}var YT=/[\t\n\r]/g;function Sg(e){return e.replace(YT,"")}function jT(e,t){return t.lastIndex=0,t.test(e.hostname)}function KT(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Fg=j("$ZodURL",(e,t)=>{xt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=XT(i,t);if(r===Og){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xa){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Sg(i);return}if(t.hostname&&!jT(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&&!KT(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:Sg(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),zg=j("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wm()),xt.init(e,t)}),kg=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?km:Bm(t.length)),xt.init(e,t)}),Bg=j("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Dm),xt.init(e,t)}),Gg=j("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Om),xt.init(e,t)}),Hg=j("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Um),xt.init(e,t)}),Vg=j("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fm),xt.init(e,t)}),Wg=j("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=zm),xt.init(e,t)}),$g=j("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ng(t)),xt.init(e,t)}),Zg=j("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=eg),xt.init(e,t)}),Xg=j("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=tg(t)),xt.init(e,t)}),qg=j("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Gm),xt.init(e,t)}),Yg=j("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$m),xt.init(e,t)}),JT=/^[0-9a-fA-F:.]+$/;function jg(e){if(!JT.test(e))return!1;return Ug(`http://[${e}]`)}var Kg=j("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Zm),xt.init(e,t),e._zod.check=(n)=>{if(!jg(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Jg=j("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xm),xt.init(e,t)});function QT(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 jg(n)}var Qg=j("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qm),xt.init(e,t),e._zod.check=(n)=>{if(!QT(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function e_(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 Qu=/^[0-9a-zA-Z+/]*={0,2}$/,t_=j("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qu),xt.init(e,t),e._zod.check=(n)=>{if(e_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),ja=/^[A-Za-z0-9_-]*$/;function eE(e){if(!ja.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return e_(n)}var n_=j("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ja),xt.init(e,t),e._zod.check=(n)=>{if(eE(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),i_=j("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jm),xt.init(e,t)});function tE(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 r_=j("$ZodJWT",(e,t)=>{xt.init(e,t),e._zod.check=(n)=>{if(tE(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var eh=j("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=io,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}}),s_=j("$ZodNumberFormat",(e,t)=>{cg.init(e,t),eh.init(e,t)}),o_=j("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=rg,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 a_=j("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),c_=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 bg(e,t,n){if(e.issues.length)t.issues.push(...Ji(n,e.issues));t.value[n]=e.value}var l_=j("$ZodArray",(e,t)=>{vt.init(e,t);let n=cn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>bg(f,i,c)));else if(bg(u,i,c),a&&u.issues.length!==0&&ii(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function qa(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(...Ji(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 nE=[];function u_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:nE,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=um(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function h_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(ii(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>qa(p,n,g,t,f,h)));else qa(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var iE=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=La(()=>u_(t));et(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))zn(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Qs,o=t.catchall,a,c=cn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(ii(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,S=m._zod.run({value:f[p],issues:[]},u);if(S instanceof Promise)h.push(S.then((b)=>qa(b,l,p,f,E,R)));else qa(S,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return h_(h,f,l,u,r.value,e,g===!0)}}),f_=j("$ZodObjectJIT",(e,t)=>{iE.init(e,t);let n=e._zod.parse,i=La(()=>u_(t)),r=cn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new ju(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,E=(b,T)=>`
+};`)(...Object.values(this.closed))}}var bg={major:4,minor:6,patch:4};var vt=j("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bg;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=ii(a),f;for(let h of c){if(h._zod.def.when){if(mm(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let d=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&l?.async===!1)throw new si;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===d)return;if(zu(a.issues,d,e),!u)u=ii(a,d)});else{if(a.issues.length===d)continue;if(zu(a.issues,d,e),!u)u=ii(a,d)}}if(f)return f.then(()=>a);return a},o=(a,c,l)=>{if(ii(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new si;return u.then((f)=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((f)=>o(f,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new si;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return ka(this,"~standard",Ju(this))},set "~standard"(e){Mi(this,"~standard",e)}}),Ng=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ri(n,t,_n()))}:{value:e.value};async function YT(e,t){let n={async:!0};return Ng(await e._zod.run({value:t,issues:[]},n),n)}function Ju(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return Ng(i,n)}catch(i){}return YT(e,t)},vendor:"zod",version:1}}var Ya=j("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??sg,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}}),xt=j("$ZodStringFormat",(e,t)=>{so.init(e,t),Ya.init(e,t)}),Dg=j("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Wm),xt.init(e,t)}),Og=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=$u(i))}else t.pattern??(t.pattern=$u());xt.init(e,t)}),Ug=j("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=$m),xt.init(e,t)}),Fg=1,Xa=2;function zg(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function jT(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return zg(e)||Xa;return KT(e,t)}function KT(e,t){if(!t.normalize&&t.protocol?.source===Qm.source&&!/^https?:\/\//i.test(e))return Fg;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xa}return new URL(e)}catch{return Xa}}var JT=/[\t\n\r]/g;function Mg(e){return e.replace(JT,"")}function QT(e,t){return t.lastIndex=0,t.test(e.hostname)}function eE(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var kg=j("$ZodURL",(e,t)=>{xt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=jT(i,t);if(r===Fg){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xa){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Mg(i);return}if(t.hostname&&!QT(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&&!eE(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:Mg(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Bg=j("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Zm()),xt.init(e,t)}),Gg=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?Gm:Hm(t.length)),xt.init(e,t)}),Hg=j("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Um),xt.init(e,t)}),Vg=j("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fm),xt.init(e,t)}),Wg=j("$ZodULID",(e,t)=>{t.pattern??(t.pattern=zm),xt.init(e,t)}),$g=j("$ZodXID",(e,t)=>{t.pattern??(t.pattern=km),xt.init(e,t)}),Zg=j("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Bm),xt.init(e,t)}),Xg=j("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rg(t)),xt.init(e,t)}),qg=j("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ng),xt.init(e,t)}),Yg=j("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ig(t)),xt.init(e,t)}),jg=j("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Vm),xt.init(e,t)}),Kg=j("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xm),xt.init(e,t)}),tE=/^[0-9a-fA-F:.]+$/;function Jg(e){if(!tE.test(e))return!1;return zg(`http://[${e}]`)}var Qg=j("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=qm),xt.init(e,t),e._zod.check=(n)=>{if(!Jg(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var e_=j("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ym),xt.init(e,t)});function nE(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 Jg(n)}var t_=j("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jm),xt.init(e,t),e._zod.check=(n)=>{if(!nE(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function n_(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Qu=/^[0-9a-zA-Z+/]*={0,2}$/,i_=j("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qu),xt.init(e,t),e._zod.check=(n)=>{if(n_(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),ja=/^[A-Za-z0-9_-]*$/;function iE(e){if(!ja.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return n_(n)}var r_=j("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ja),xt.init(e,t),e._zod.check=(n)=>{if(iE(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),s_=j("$ZodE164",(e,t)=>{t.pattern??(t.pattern=eg),xt.init(e,t)});function rE(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 o_=j("$ZodJWT",(e,t)=>{xt.init(e,t),e._zod.check=(n)=>{if(rE(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var eh=j("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=io,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}}),a_=j("$ZodNumberFormat",(e,t)=>{ug.init(e,t),eh.init(e,t)}),c_=j("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=og,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 l_=j("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),u_=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 wg(e,t,n){if(e.issues.length)t.issues.push(...Ji(n,e.issues));t.value[n]=e.value}var h_=j("$ZodArray",(e,t)=>{vt.init(e,t);let n=cn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((f)=>wg(f,i,c)));else if(wg(u,i,c),a&&u.issues.length!==0&&ii(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function qa(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(...Ji(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 sE=[];function f_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:sE,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=fm(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function d_(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:f,optout:h}=l,d=0;for(let g in t){if(o&&n.issues.length!==d){if(ii(n,d))break;d=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(u==="never")a.push(g);continue}if(u==="never"){a.push(g);continue}let x=l.run({value:t[g],issues:[]},i);if(x instanceof Promise)e.push(x.then((p)=>qa(p,n,g,t,f,h)));else qa(x,n,g,t,f,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var oE=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=La(()=>f_(t));et(e,"propValues",(l)=>{let u=l.def.shape,f={};for(let h in u){let d=u[h]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(f,h))zn(f,h,new Set);for(let g of d.values)f[h].add(g);if(d.optin!==void 0)f[h].add(void 0)}}return f});let s=Qs,o=t.catchall,a,c=cn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let f=l.value;if(!s(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],d=a.shape,g=u?.abortEarly,x=l.issues.length;for(let p of a.allKeys){if(g&&l.issues.length!==x){if(ii(l,x))break;x=l.issues.length}if(p==="__proto__")continue;let m=d[p],E=m._zod.optin,R=m._zod.optout,S=m._zod.run({value:f[p],issues:[]},u);if(S instanceof Promise)h.push(S.then((b)=>qa(b,l,p,f,E,R)));else qa(S,l,p,f,E,R)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return d_(h,f,l,u,r.value,e,g===!0)}}),p_=j("$ZodObjectJIT",(e,t)=>{oE.init(e,t);let n=e._zod.parse,i=La(()=>f_(t)),r=cn.memoizer,s=(d)=>{let g=i.value,x=g.symbolKeys,p=new ju(["payload","ctx"],{shape:d,inst:e,memo:r,syms:x}),m=(b)=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,E=(b,T)=>`
let ${b}_ab = false;
for (let i = 0; i < ${b}.issues.length; i++) {
const iss = ${b}.issues[i];
@@ -4356,7 +4356,7 @@ ${t.join(`
if (${b}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let R=Object.create(null),S=0;for(let b of g.allKeys)R[b]=`key_${S++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of g.allKeys){if(b==="__proto__")continue;let T=R[b],A=typeof b==="symbol"?`syms[${x.indexOf(b)}]`:om(b),_=`${A} in input`,M=d[b],F=M?._zod?.optin,P=F!==void 0,O=M?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),P&&O){let K=F==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let R=Object.create(null),S=0;for(let b of g.allKeys)R[b]=`key_${S++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of g.allKeys){if(b==="__proto__")continue;let T=R[b],A=typeof b==="symbol"?`syms[${x.indexOf(b)}]`:cm(b),_=`${A} in input`,M=d[b],F=M?._zod?.optin,P=F!==void 0,O=M?._zod?.optout==="optional";if(p.write(`const ${T} = ${m(A)};`),P&&O){let K=F==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;p.write(`
const ${T}_present = ${_};
if (!${T}.issues.length || ${T}_present) {
if (${T}.issues.length) {${E(T,A)}
@@ -4395,14 +4395,14 @@ ${t.join(`
if (${T}.value !== undefined || ${_}) {
newResult[${A}] = ${T}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Qs,c=!cn.jitless,u=c&&cm.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return h_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function Mg(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)=>!ii(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)=>ri(o,i,_n())))}),t}var d_=j("$ZodUnion",(e,t)=>{vt.init(e,t),et(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),et(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),et(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}),et(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)=>Na(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 Mg(o,i,e,r);return Promise.all(o).then((a)=>Mg(a,i,e,r))}});var p_=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])=>wg(n,c,l));return wg(n,s,o)}});function Ku(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(Sr(e)&&Sr(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=Ku(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=Ku(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 wg(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Ku(t.value,n.value);if(!c.valid){if(ii(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var m_=j("$ZodRecord",(e,t)=>{vt.init(e,t);let n=cn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Sr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>ri(g,r,_n())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Ji(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Ji(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&io.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>ri(g,r,_n())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Ji(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Ji(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var g_=j("$ZodEnum",(e,t)=>{vt.init(e,t);let n=eo(t.entries),i=new Set(n);e._zod.values=i,et(e,"pattern",(r)=>{let s=eo(r.def.entries).filter((o)=>lm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Ki(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}}),__=j("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,et(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Ki(s):s?Ki(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 x_=j("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",cn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new no(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 si;return n.value=r,n}});function Tg(e,t){return e.value=t.issues.length?void 0:t.value,e}var th=j("$ZodOptional",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",et(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Na(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)=>Tg(n,s));return Tg(n,r)}return t.innerType._zod.run(n,i)}}),v_=j("$ZodExactOptional",(e,t)=>{th.init(e,t),et(e,"values",(n)=>n.def.innerType._zod.values),et(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),y_=j("$ZodNullable",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin),et(e,"optout",(n)=>n.def.innerType._zod.optout),et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Na(i.source)}|null)$`):void 0}),et(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)}}),S_=j("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",et(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)=>Eg(s,t));return Eg(r,t)}});function Eg(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var b_=j("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",et(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)}}),M_=j("$ZodNonOptional",(e,t)=>{vt.init(e,t),et(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)=>Ag(s,e));return Ag(r,e)}});function Ag(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 Rg(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)=>ri(r,i,_n()))},input:e.value}),e}var w_=j("$ZodCatch",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),et(e,"optout",(n)=>n.def.innerType._zod.optout),et(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)=>Rg(n,s,t,i));return Rg(n,r,t,i)}});var T_=j("$ZodPipe",(e,t)=>{vt.init(e,t),et(e,"values",(n)=>n.def.in._zod.values),et(e,"optin",(n)=>n.def.in._zod.optin),et(e,"optout",(n)=>n.def.out._zod.optout),et(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)=>Za(o,t.in,i));return Za(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Za(s,t.out,i));return Za(r,t.out,i)}});function Za(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 E_=j("$ZodReadonly",(e,t)=>{vt.init(e,t),et(e,"propValues",(n)=>n.def.innerType._zod.propValues),et(e,"values",(n)=>n.def.innerType._zod.values),et(e,"optin",(n)=>n.def.innerType?._zod?.optin),et(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(Cg);return Cg(r)}});function Cg(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var A_=j("$ZodCustom",(e,t)=>{Ht.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)=>Pg(s,n,i,e));Pg(r,n,i,e);return}});function Pg(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(br(r))}}class C_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ih="~memo",R_=[];function P_(e){return e!==null&&typeof e==="object"}function nh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var I_=new WeakMap,oo=0,Qa=1,ao=2;function ec(e,t,n){let i=I_.get(e);if(i!==void 0)return i?ao:oo;if(t.has(e))return ao;t.add(e);let r=oo,s=(u)=>{if(r!==ao&&u?._zod){let f=ec(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=oo;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?Qa:g.value?._zod?ec(g.value,t,n):oo;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Da(c);a(u?o(u,!0):Qa),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):Qa);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),rE(e,r)}function rE(e,t){if(t!==Qa)I_.set(e,t===ao);return t}function sE(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ka,Ja=[],oE={alloc(e,t,n){let i=Ka;if(!i)return n;Ka=void 0;let r={value:n,issues:null};return i.set(t.value,r),Ja.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"&&aE(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 m=ec(e,new Set,!1);if(m===oo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===ao||i)n=!0;else i=!0}let u=c.value;if(!P_(u))return o(c,l);let f=l[ih];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[ih]=f;let h;if(r===l)h=s;else h=sE(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...nh(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}Ka=h;let g=Ja.length,x=o(c,l);Ka=void 0;let p=Ja.length>g?Ja.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?nh(m.issues):R_;return m});if(p)p.issues=x.issues.length?nh(x.issues):R_;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function L_(){return oE}function aE(e,t){let n=e[ih]?.backEdges;return n!==void 0&&P_(t)&&n.has(t)}var cE=()=>{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=pm(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 ${Uu(s.values[0])}`;return`Invalid option: expected one of ${Nu(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":""}: ${Nu(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 rh(){return{localeError:cE()}}var N_;class D_{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 lE(){return new D_}(N_=globalThis).__zod_globalRegistry??(N_.__zod_globalRegistry=lE());var Mr=globalThis.__zod_globalRegistry;function O_(e){if(e.checks)e.checks=[...e.checks];return e}function U_(e,t){return new e(O_({type:"string",...Ce(t)}))}function F_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function z_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function k_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function B_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function G_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function H_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function V_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function W_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function $_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Z_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function X_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function q_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Y_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function j_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function K_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function J_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Q_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function e0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function t0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function n0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function i0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function r0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function s0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function o0(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function a0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function c0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function l0(e,t){return new e(O_({type:"number",checks:[],...Ce(t)}))}function u0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function h0(e,t){return new e({type:"boolean",...Ce(t)})}function f0(e){return new e({type:"unknown"})}function d0(e,t){return new e({type:"never",...Ce(t)})}function tc(e,t){return new qu({check:"less_than",...Ce(t),value:e,inclusive:!1})}function co(e,t){return new qu({check:"less_than",...Ce(t),value:e,inclusive:!0})}function nc(e,t){return new Yu({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function lo(e,t){return new Yu({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function ic(e,t){return new ag({check:"multiple_of",...Ce(t),value:e})}function rc(e,t){return new lg({check:"max_length",...Ce(t),maximum:e})}function hs(e,t){return new ug({check:"min_length",...Ce(t),minimum:e})}function sc(e,t){return new hg({check:"length_equals",...Ce(t),length:e})}function sh(e,t){return new fg({check:"string_format",format:"regex",...Ce(t),pattern:e})}function oh(e){return new dg({check:"string_format",format:"lowercase",...Ce(e)})}function ah(e){return new pg({check:"string_format",format:"uppercase",...Ce(e)})}function ch(e,t){return new mg({check:"string_format",format:"includes",...Ce(t),includes:e})}function lh(e,t){return new gg({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function uh(e,t){return new _g({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function Qi(e){return new xg({check:"overwrite",tx:e})}function hh(e){return Qi((t)=>t.normalize(e))}function fh(){return Qi((e)=>e.trim())}function dh(){return Qi((e)=>e.toLowerCase())}function ph(){return Qi((e)=>e.toUpperCase())}function mh(){return Qi((e)=>am(e))}function p0(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function m0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function g0(e,t){let n=uE((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(br(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(br(s))}},e(i.value,i)),t);return n}function uE(e,t){let n=new Ht({check:"custom",...Ce(t)});return n._zod.check=e,n}function uo(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))zn(e,i,n[i]);return e}function _h(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??Mr,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 wi(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 At(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;At(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)uo(o.schema,c);if(t.io==="input"&&tn(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 _0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function xh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${_0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+_0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=Qs,c=!cn.jitless,u=c&&um.value,f=t.catchall,h;e._zod.parse=(d,g)=>{h??(h=i.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!o)o=s(t.shape);if(d=o(d,g),!f)return d;return d_([],x,d,g,h,e,g?.abortEarly===!0)}return n(d,g)}});function Tg(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)=>!ii(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)=>ri(o,i,_n())))}),t}var m_=j("$ZodUnion",(e,t)=>{vt.init(e,t),et(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),et(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),et(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}),et(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)=>Na(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 Tg(o,i,e,r);return Promise.all(o).then((a)=>Tg(a,i,e,r))}});var g_=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])=>Eg(n,c,l));return Eg(n,s,o)}});function Ku(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(Sr(e)&&Sr(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=Ku(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=Ku(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 Eg(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);f=[h]}else return!1;for(let h of f){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Ku(t.value,n.value);if(!c.valid){if(ii(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var __=j("$ZodRecord",(e,t)=>{vt.init(e,t);let n=cn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Sr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>ri(g,r,_n())),input:u,path:[u],inst:e});continue}let h=f.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[u],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Ji(u,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Ji(u,d.issues));i.value[h]=d.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&io.test(l)&&u.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)u=g}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((g)=>ri(g,r,_n())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let d=t.valueType._zod.run({value:s[l],issues:[]},r);if(d instanceof Promise)o.push(d.then((g)=>{if(g.issues.length)i.issues.push(...Ji(l,g.issues));i.value[h]=g.value}));else{if(d.issues.length)i.issues.push(...Ji(l,d.issues));i.value[h]=d.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var x_=j("$ZodEnum",(e,t)=>{vt.init(e,t);let n=eo(t.entries),i=new Set(n);e._zod.values=i,et(e,"pattern",(r)=>{let s=eo(r.def.entries).filter((o)=>hm.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>Ki(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}}),v_=j("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,et(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?Ki(s):s?Ki(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 y_=j("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",cn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new no(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 si;return n.value=r,n}});function Ag(e,t){return e.value=t.issues.length?void 0:t.value,e}var th=j("$ZodOptional",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",et(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Na(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)=>Ag(n,s));return Ag(n,r)}return t.innerType._zod.run(n,i)}}),S_=j("$ZodExactOptional",(e,t)=>{th.init(e,t),et(e,"values",(n)=>n.def.innerType._zod.values),et(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),b_=j("$ZodNullable",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin),et(e,"optout",(n)=>n.def.innerType._zod.optout),et(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Na(i.source)}|null)$`):void 0}),et(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)}}),M_=j("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",et(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)=>Rg(s,t));return Rg(r,t)}});function Rg(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var w_=j("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",et(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_=j("$ZodNonOptional",(e,t)=>{vt.init(e,t),et(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)=>Cg(s,e));return Cg(r,e)}});function Cg(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 Pg(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)=>ri(r,i,_n()))},input:e.value}),e}var E_=j("$ZodCatch",(e,t)=>{vt.init(e,t),et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),et(e,"optout",(n)=>n.def.innerType._zod.optout),et(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)=>Pg(n,s,t,i));return Pg(n,r,t,i)}});var A_=j("$ZodPipe",(e,t)=>{vt.init(e,t),et(e,"values",(n)=>n.def.in._zod.values),et(e,"optin",(n)=>n.def.in._zod.optin),et(e,"optout",(n)=>n.def.out._zod.optout),et(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)=>Za(o,t.in,i));return Za(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Za(s,t.out,i));return Za(r,t.out,i)}});function Za(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_=j("$ZodReadonly",(e,t)=>{vt.init(e,t),et(e,"propValues",(n)=>n.def.innerType._zod.propValues),et(e,"values",(n)=>n.def.innerType._zod.values),et(e,"optin",(n)=>n.def.innerType?._zod?.optin),et(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(Ig);return Ig(r)}});function Ig(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var C_=j("$ZodCustom",(e,t)=>{Ht.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)=>Lg(s,n,i,e));Lg(r,n,i,e);return}});function Lg(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(br(r))}}class I_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var ih="~memo",P_=[];function L_(e){return e!==null&&typeof e==="object"}function nh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var N_=new WeakMap,oo=0,Qa=1,ao=2;function ec(e,t,n){let i=N_.get(e);if(i!==void 0)return i?ao:oo;if(t.has(e))return ao;t.add(e);let r=oo,s=(u)=>{if(r!==ao&&u?._zod){let f=ec(u,t,n);if(f>r)r=f}},o=(u,f)=>{let h=oo;for(let d of Reflect.ownKeys(u)){let g=Object.getOwnPropertyDescriptor(u,d);if(f&&!g.enumerable)continue;let x=g.get?Qa:g.value?._zod?ec(g.value,t,n):oo;if(x>h)h=x}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Da(c);a(u?o(u,!0):Qa),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):Qa);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let h=f.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let d of h)s(d)}}return t.delete(e),aE(e,r)}function aE(e,t){if(t!==Qa)N_.set(e,t===ao);return t}function cE(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Ka,Ja=[],lE={alloc(e,t,n){let i=Ka;if(!i)return n;Ka=void 0;let r={value:n,issues:null};return i.set(t.value,r),Ja.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"&&uE(s,r.value))throw new I_;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let m=ec(e,new Set,!1);if(m===oo){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(m===ao||i)n=!0;else i=!0}let u=c.value;if(!L_(u))return o(c,l);let f=l[ih];if(!f)f={buckets:new WeakMap,backEdges:void 0},l[ih]=f;let h;if(r===l)h=s;else h=cE(f,e),r=l,s=h;let d=h.get(u);if(d){if(c.value=d.value,d.issues){if(d.issues.length)c.issues.push(...nh(d.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(d.value);return c}Ka=h;let g=Ja.length,x=o(c,l);Ka=void 0;let p=Ja.length>g?Ja.pop():void 0;if(x instanceof Promise)return x.then((m)=>{if(p)p.issues=m.issues.length?nh(m.issues):P_;return m});if(p)p.issues=x.issues.length?nh(x.issues):P_;return x};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function D_(){return lE}function uE(e,t){let n=e[ih]?.backEdges;return n!==void 0&&L_(t)&&n.has(t)}var hE=()=>{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=gm(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 ${Uu(s.values[0])}`;return`Invalid option: expected one of ${Nu(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":""}: ${Nu(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 rh(){return{localeError:hE()}}var O_;class U_{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 fE(){return new U_}(O_=globalThis).__zod_globalRegistry??(O_.__zod_globalRegistry=fE());var Mr=globalThis.__zod_globalRegistry;function F_(e){if(e.checks)e.checks=[...e.checks];return e}function z_(e,t){return new e(F_({type:"string",...Ce(t)}))}function k_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function B_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function G_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function H_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function V_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function W_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function $_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Z_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function X_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function q_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Y_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function j_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function K_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function J_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Q_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function e0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function t0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function n0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function i0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function r0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function s0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function o0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function a0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function c0(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function l0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function u0(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function h0(e,t){return new e(F_({type:"number",checks:[],...Ce(t)}))}function f0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function d0(e,t){return new e({type:"boolean",...Ce(t)})}function p0(e){return new e({type:"unknown"})}function m0(e,t){return new e({type:"never",...Ce(t)})}function tc(e,t){return new qu({check:"less_than",...Ce(t),value:e,inclusive:!1})}function co(e,t){return new qu({check:"less_than",...Ce(t),value:e,inclusive:!0})}function nc(e,t){return new Yu({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function lo(e,t){return new Yu({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function ic(e,t){return new lg({check:"multiple_of",...Ce(t),value:e})}function rc(e,t){return new hg({check:"max_length",...Ce(t),maximum:e})}function hs(e,t){return new fg({check:"min_length",...Ce(t),minimum:e})}function sc(e,t){return new dg({check:"length_equals",...Ce(t),length:e})}function sh(e,t){return new pg({check:"string_format",format:"regex",...Ce(t),pattern:e})}function oh(e){return new mg({check:"string_format",format:"lowercase",...Ce(e)})}function ah(e){return new gg({check:"string_format",format:"uppercase",...Ce(e)})}function ch(e,t){return new _g({check:"string_format",format:"includes",...Ce(t),includes:e})}function lh(e,t){return new xg({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function uh(e,t){return new vg({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function Qi(e){return new yg({check:"overwrite",tx:e})}function hh(e){return Qi((t)=>t.normalize(e))}function fh(){return Qi((e)=>e.trim())}function dh(){return Qi((e)=>e.toLowerCase())}function ph(){return Qi((e)=>e.toUpperCase())}function mh(){return Qi((e)=>lm(e))}function g0(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function _0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function x0(e,t){let n=dE((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(br(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(br(s))}},e(i.value,i)),t);return n}function dE(e,t){let n=new Ht({check:"custom",...Ce(t)});return n._zod.check=e,n}function uo(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))zn(e,i,n[i]);return e}function _h(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??Mr,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 wi(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 At(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,d=t.processors[r.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);d(e,t,h,u)}let f=e._zod.parent;if(f){if(!o.ref)o.ref=f;At(f,t,u),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)uo(o.schema,c);if(t.io==="input"&&tn(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 v0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function xh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(o[0])?.id,h=e.external.uri??((g)=>g);if(f)return{ref:h(f)};let d=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=d,{defId:d,ref:`${h("__shared")}#/${a}/${v0(d)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+v0(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function y0(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;y0(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 S0=new Set(["type","properties","required","additionalProperties"]),x0=["oneOf","anyOf"];function v0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function gh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!S0.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]??v0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:gh(a)??{allOf:a};zn(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=v0(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 hE(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of S0)if(r in e)return;let n=t.filter((r)=>x0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=gh(t);else{let r=n[0],s=x0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>gh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,uo(e,i)}function vh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else uo(l,g);if(uo(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())y0(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])hE(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)}uo(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;zn(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 tn(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 tn(i.element,n);if(i.type==="set")return tn(i.valueType,n);if(i.type==="lazy")return tn(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 tn(i.innerType,n);if(i.type==="intersection")return tn(i.left,n)||tn(i.right,n);if(i.type==="record"||i.type==="map")return tn(i.keyType,n)||tn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return tn(i.in,n)||tn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(tn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(tn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(tn(r,n))return!0;if(i.rest&&tn(i.rest,n))return!0;return!1}return!1}var b0=(e,t={})=>(n)=>{let i=_h({...n,processors:t});return At(e,i),xh(i,e),vh(i,e)},ho=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=_h({...r??{},target:s,io:t,processors:n});return At(e,o),xh(o,e),vh(o,e)};var fs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ds=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},M0=(e,t)=>{fs(e,"minimum",t),ds(e,"maximum",t)},A0=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},R0=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},C0=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},P0=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},w0=(e,t)=>fs(e,"minimum",t.minimum),T0=(e,t)=>ds(e,"maximum",t.maximum),E0=(e)=>(t,n)=>{P0(t,n.format);let[i,r]=e[n.format];fs(t,"minimum",i),ds(t,"maximum",r)},fE={greater_than:(e,t)=>fs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ds(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>A0(e,t.value),number_format:E0(Oa),bigint_format:E0(Fu),min_length:w0,max_length:T0,length_equals:(e,t)=>M0(e,t.length),min_size:w0,max_size:T0,size_equals:(e,t)=>M0(e,t.size),string_format:(e,t)=>{if(P0(e,t.format),t.pattern)R0(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)=>C0(e,t.mime)};function An(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)fE[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)fs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)fs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)ds(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)ds(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)A0(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)C0(t,r.mime);for(let s of r.patterns??[])R0(t,s);return t}var dE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pE=new Map([[Qu,Ym],[ja,jm]]),I0=(e)=>pE.get(e)??e,L0=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=An(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=dE[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(I0);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},N0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=An(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else wi(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},D0=(e,t,n,i)=>{n.type="boolean"};var O0=(e,t,n,i)=>{n.not={}};var U0=(e,t,n,i)=>{};var F0=(e,t,n,i)=>{let r=e._zod.def,s=eo(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},z0=(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(wi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(wi(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 k0=(e,t,n,i)=>{wi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var B0=(e,t,n,i)=>{wi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var G0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=An(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=At(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 H0=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&wi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)zn(r.properties,l,At(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"?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=At(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},V0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>At(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},W0=(e,t,n,i)=>{let r=e._zod.def,s=At(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=At(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function yh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=yh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>yh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?io:Zu).source;return d}var Sh=new WeakMap;function mE(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 Sh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=yh(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 $0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=An(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=At(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)zn(r.patternProperties,I0(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=At(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Sh.get(t);if(!u)u=[],Sh.set(t,u),t.deferred.push(()=>mE(t));u.push(e)}r.additionalProperties=At(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&oc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},Z0=(e,t,n,i)=>{let r=e._zod.def,s=At(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"}]},X0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},bh=Symbol();function q0(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 wi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),bh}var Y0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=q0(r.defaultValue,e,t,n,i);if(o!==bh)n.default=o},j0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=q0(r.defaultValue,e,t,n,i);if(o!==bh)n._prefault=o},K0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{wi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},J0=(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;At(o,t,i);let a=t.seen.get(e);a.ref=o},Q0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Mh=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var ex=new WeakSet([Object.prototype,Error.prototype]);function ac(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 ME=(e,t)=>{bm.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(ex.has(n))return;ex.add(n),ac(n,"format",(i)=>(r)=>wm(i,r)),ac(n,"flatten",(i)=>(r)=>Mm(i,r)),ac(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,to,2)}),ac(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,to,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var xn=j("ZodError",ME,void 0,{Parent:Error});var tx=Ga(xn),nx=Ha(xn),ix=Va(xn),rx=Wa(xn),sx=Em(xn),ox=Am(xn),ax=Rm(xn),cx=Cm(xn),lx=Pm(xn),ux=Im(xn),hx=Lm(xn),fx=Nm(xn);function TE(){if(!cn.localeError)_n(rh())}function lc(){if(!cn.memoizer)_n({memoizer:L_()})}var St=j("ZodType",(e,t)=>(TE(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(gn(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 ni(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(TA(e,t))},superRefine(e,t){return this.check(EA(e,t))},overwrite(e){return this.check(Qi(e))},optional(){return mx(this)},exactOptional(){return fA(this)},nullable(){return gx(this)},nullish(){return mx(gx(this))},nonoptional(e){return xA(this,e)},array(){return uc(this)},or(e){return sA([this,e])},and(e){return aA(this,e)},transform(e){return _x(this,hA(e))},default(e){return mA(this,e)},prefault(e){return _A(this,e)},catch(e){return yA(this,e)},pipe(e){return _x(this,e)},readonly(){return MA(this)},describe(e){let t=this.clone();return Mr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mr.get(this);let t=this.clone();return Mr.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 ka(this,"~standard",{...Ju(this),jsonSchema:{input:ho(this,"input"),output:ho(this,"output")}})},set "~standard"(e){Mi(this,"~standard",e)},parse:function e(t,n){return tx(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await nx(this,t,n,{callee:e})},safeParse(e,t){return ix(this,e,t)},async safeParseAsync(e,t){return rx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Mi(this,"spa",e)},validate(e,t){return Hu(this,e,t)},validateAsync(e,t){return Vu(this,e,t)},encode:function e(t,n){return sx(this,t,n,{callee:e})},decode:function e(t,n){return ox(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await ax(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await cx(this,t,n,{callee:e})},safeEncode(e,t){return lx(this,e,t)},safeDecode(e,t){return ux(this,e,t)},async safeEncodeAsync(e,t){return hx(this,e,t)},async safeDecodeAsync(e,t){return fx(this,e,t)},toJSONSchema(e){return b0(this,{})(e)},get description(){return Mr.get(this)?.description},get _def(){return this._zod.def}}),xx=j("_ZodString",(e,t)=>{Ya.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>L0(e,n,i,r)},gm({format:(e)=>An(e).format??null,minLength:(e)=>An(e).minimum??null,maxLength:(e)=>An(e).maximum??null},{regex(...e){return this.check(sh(...e))},includes(...e){return this.check(ch(...e))},startsWith(...e){return this.check(lh(...e))},endsWith(...e){return this.check(uh(...e))},min(...e){return this.check(hs(...e))},max(...e){return this.check(rc(...e))},length(...e){return this.check(sc(...e))},nonempty(...e){return this.check(hs(1,...e))},lowercase(e){return this.check(oh(e))},uppercase(e){return this.check(ah(e))},trim(){return this.check(fh())},normalize(...e){return this.check(hh(...e))},toLowerCase(){return this.check(dh())},toUpperCase(){return this.check(ph())},slugify(){return this.check(mh())}})),EE=j("ZodString",(e,t)=>{Ya.init(e,t),xx.init(e,t)},{email(e){return this.check(F_(IE,e))},url(e){return this.check(V_(NE,e))},jwt(e){return this.check(r0(qE,e))},emoji(e){return this.check(W_(DE,e))},guid(e){return this.check(z_(LE,e))},uuid(e){return this.check(k_(cc,e))},uuidv4(e){return this.check(B_(cc,e))},uuidv6(e){return this.check(G_(cc,e))},uuidv7(e){return this.check(H_(cc,e))},nanoid(e){return this.check($_(OE,e))},cuid(e){return this.check(Z_(UE,e))},cuid2(e){return this.check(X_(FE,e))},ulid(e){return this.check(q_(zE,e))},base64(e){return this.check(t0($E,e))},base64url(e){return this.check(n0(ZE,e))},xid(e){return this.check(Y_(kE,e))},ksuid(e){return this.check(j_(BE,e))},ipv4(e){return this.check(K_(GE,e))},ipv6(e){return this.check(J_(HE,e))},cidrv4(e){return this.check(Q_(VE,e))},cidrv6(e){return this.check(e0(WE,e))},e164(e){return this.check(i0(XE,e))},datetime(e){return this.check(s0(AE,e))},date(e){return this.check(o0(RE,e))},time(e){return this.check(a0(CE,e))},duration(e){return this.check(c0(PE,e))}});function jt(e){return U_(EE,e)}var bt=j("ZodStringFormat",(e,t)=>{xt.init(e,t),xx.init(e,t)}),AE=j("ZodISODateTime",(e,t)=>{$g.init(e,t),bt.init(e,t)}),RE=j("ZodISODate",(e,t)=>{Zg.init(e,t),bt.init(e,t)}),CE=j("ZodISOTime",(e,t)=>{Xg.init(e,t),bt.init(e,t)}),PE=j("ZodISODuration",(e,t)=>{qg.init(e,t),bt.init(e,t)}),IE=j("ZodEmail",(e,t)=>{Dg.init(e,t),bt.init(e,t)});var LE=j("ZodGUID",(e,t)=>{Lg.init(e,t),bt.init(e,t)});var cc=j("ZodUUID",(e,t)=>{Ng.init(e,t),bt.init(e,t)});var NE=j("ZodURL",(e,t)=>{Fg.init(e,t),bt.init(e,t)});var DE=j("ZodEmoji",(e,t)=>{zg.init(e,t),bt.init(e,t)});var OE=j("ZodNanoID",(e,t)=>{kg.init(e,t),bt.init(e,t)});var UE=j("ZodCUID",(e,t)=>{Bg.init(e,t),bt.init(e,t)});var FE=j("ZodCUID2",(e,t)=>{Gg.init(e,t),bt.init(e,t)});var zE=j("ZodULID",(e,t)=>{Hg.init(e,t),bt.init(e,t)});var kE=j("ZodXID",(e,t)=>{Vg.init(e,t),bt.init(e,t)});var BE=j("ZodKSUID",(e,t)=>{Wg.init(e,t),bt.init(e,t)});var GE=j("ZodIPv4",(e,t)=>{Yg.init(e,t),bt.init(e,t)});var HE=j("ZodIPv6",(e,t)=>{Kg.init(e,t),bt.init(e,t)});var VE=j("ZodCIDRv4",(e,t)=>{Jg.init(e,t),bt.init(e,t)});var WE=j("ZodCIDRv6",(e,t)=>{Qg.init(e,t),bt.init(e,t)});var $E=j("ZodBase64",(e,t)=>{t_.init(e,t),bt.init(e,t)});var ZE=j("ZodBase64URL",(e,t)=>{n_.init(e,t),bt.init(e,t)});var XE=j("ZodE164",(e,t)=>{i_.init(e,t),bt.init(e,t)});var qE=j("ZodJWT",(e,t)=>{r_.init(e,t),bt.init(e,t)});var vx=j("ZodNumber",(e,t)=>{eh.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>N0(e,n,i,r),e.isFinite=!0},gm({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=An(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=An(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=An(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>An(e).format??null},{gt(e,t){return this.check(nc(e,t))},gte(e,t){return this.check(lo(e,t))},min(e,t){return this.check(lo(e,t))},lt(e,t){return this.check(tc(e,t))},lte(e,t){return this.check(co(e,t))},max(e,t){return this.check(co(e,t))},int(e){return this.check(dx(e))},safe(e){return this.check(dx(e))},positive(e){return this.check(nc(0,e))},nonnegative(e){return this.check(lo(0,e))},negative(e){return this.check(tc(0,e))},nonpositive(e){return this.check(co(0,e))},multipleOf(e,t){return this.check(ic(e,t))},step(e,t){return this.check(ic(e,t))},finite(){return this}}));function YE(e){return l0(vx,e)}var jE=j("ZodNumberFormat",(e,t)=>{s_.init(e,t),vx.init(e,t)});function dx(e){return u0(jE,e)}var KE=j("ZodBoolean",(e,t)=>{o_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>D0(e,n,i,r)});function JE(e){return h0(KE,e)}var QE=j("ZodUnknown",(e,t)=>{a_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>U0(e,n,i,r)});function wr(){return f0(QE)}var eA=j("ZodNever",(e,t)=>{c_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>O0(e,n,i,r)});function tA(e){return d0(eA,e)}var nA=j("ZodArray",(e,t)=>{lc(),l_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>G0(e,n,i,r),e.element=t.element},{min(e,t){return this.check(hs(e,t))},nonempty(e){return this.check(hs(1,e))},max(e,t){return this.check(rc(e,t))},length(e,t){return this.check(sc(e,t))},unwrap(){return this.element}});function uc(e,t){return p0(nA,e,t)}var iA=j("ZodObject",(e,t)=>{lc(),f_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>H0(e,n,i,r),DT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Sx(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(gn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(gn(this._zod.def,{catchall:wr()}))},loose(){return this.clone(gn(this._zod.def,{catchall:wr()}))},strict(){return this.clone(gn(this._zod.def,{catchall:tA()}))},strip(){return this.clone(gn(this._zod.def,{catchall:void 0}))},extend(e){return ET(this,e)},safeExtend(e){return AT(this,e)},merge(e){return RT(this,e)},pick(e){return wT(this,e)},omit(e){return TT(this,e)},partial(...e){return fm(bx,this,e[0])},exactPartial(...e){return fm(Mx,this,e[0],"exactPartial")},required(...e){return CT(wx,this,e[0])}});function fo(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new iA(n)}var rA=j("ZodUnion",(e,t)=>{d_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>V0(e,n,i,r),e.options=t.options});function sA(e,t){return new rA({type:"union",options:e,...Ce(t)})}var oA=j("ZodIntersection",(e,t)=>{p_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>W0(e,n,i,r)});function aA(e,t){return new oA({type:"intersection",left:e,right:t})}var px=j("ZodRecord",(e,t)=>{lc(),m_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function yx(e,t,n){if(!t||!t._zod)return new px({type:"record",keyType:jt(),valueType:e,...Ce(t)});return new px({type:"record",keyType:e,valueType:t,...Ce(n)})}var Th=j("ZodEnum",(e,t)=>{g_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(i,r,s)=>F0(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 Th({...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 Th({...t,checks:[],...Ce(r),entries:s})}});function Sx(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Th({type:"enum",entries:n,...Ce(t)})}var cA=j("ZodLiteral",(e,t)=>{__.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>z0(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 lA(e,t){return new cA({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var uA=j("ZodTransform",(e,t)=>{lc(),x_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>B0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new no(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(br(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(br(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 hA(e){return new uA({type:"transform",transform:e})}var bx=j("ZodOptional",(e,t)=>{th.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function mx(e){return new bx({type:"optional",innerType:e})}var Mx=j("ZodExactOptional",(e,t)=>{v_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function fA(e){return new Mx({type:"optional",innerType:e})}var dA=j("ZodNullable",(e,t)=>{y_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Z0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function gx(e){return new dA({type:"nullable",innerType:e})}var pA=j("ZodDefault",(e,t)=>{S_.init(e,t),St.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 mA(e,t){return new pA({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Ou(t)}})}var gA=j("ZodPrefault",(e,t)=>{b_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>j0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function _A(e,t){return new gA({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Ou(t)}})}var wx=j("ZodNonOptional",(e,t)=>{M_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>X0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function xA(e,t){return new wx({type:"nonoptional",innerType:e,...Ce(t)})}var vA=j("ZodCatch",(e,t)=>{w_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>K0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yA(e,t){return new vA({type:"catch",innerType:e,catchValue:typeof t==="function"?t:_m(t)})}var SA=j("ZodPipe",(e,t)=>{T_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>J0(e,n,i,r),e.in=t.in,e.out=t.out});function _x(e,t){return new SA({type:"pipe",in:e,out:t})}var bA=j("ZodReadonly",(e,t)=>{E_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Q0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function MA(e){return new bA({type:"readonly",innerType:e})}var wA=j("ZodCustom",(e,t)=>{A_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>k0(e,n,i,r)});function TA(e,t={}){return m0(wA,e,t)}function EA(e,t){return g0(e,t)}/*!
+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 b0(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;b0(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 M0=new Set(["type","properties","required","additionalProperties"]),y0=["oneOf","anyOf"];function S0(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function gh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!M0.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]??S0(l);if(u===null||u===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:gh(a)??{allOf:a};zn(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=S0(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 pE(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of M0)if(r in e)return;let n=t.filter((r)=>y0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=gh(t);else{let r=n[0],s=y0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let o=t.filter((c)=>c!==r),a=r[s].map((c)=>gh([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,uo(e,i)}function vh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let d=e.seen.get(f),g=d.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else uo(l,g);if(uo(l,u),a._zod.parent===f)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(g.$ref&&d.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in d.def&&JSON.stringify(l[p])===JSON.stringify(d.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==f){i(h);let d=e.seen.get(h);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(l[g])===JSON.stringify(d.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())b0(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=a.get(u);if(f)f.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])pE(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)}uo(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;zn(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 tn(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 tn(i.element,n);if(i.type==="set")return tn(i.valueType,n);if(i.type==="lazy")return tn(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 tn(i.innerType,n);if(i.type==="intersection")return tn(i.left,n)||tn(i.right,n);if(i.type==="record"||i.type==="map")return tn(i.keyType,n)||tn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return tn(i.in,n)||tn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(tn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(tn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(tn(r,n))return!0;if(i.rest&&tn(i.rest,n))return!0;return!1}return!1}var w0=(e,t={})=>(n)=>{let i=_h({...n,processors:t});return At(e,i),xh(i,e),vh(i,e)},ho=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=_h({...r??{},target:s,io:t,processors:n});return At(e,o),xh(o,e),vh(o,e)};var fs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ds=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},T0=(e,t)=>{fs(e,"minimum",t),ds(e,"maximum",t)},C0=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},P0=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},I0=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},L0=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},E0=(e,t)=>fs(e,"minimum",t.minimum),A0=(e,t)=>ds(e,"maximum",t.maximum),R0=(e)=>(t,n)=>{L0(t,n.format);let[i,r]=e[n.format];fs(t,"minimum",i),ds(t,"maximum",r)},mE={greater_than:(e,t)=>fs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ds(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>C0(e,t.value),number_format:R0(Oa),bigint_format:R0(Fu),min_length:E0,max_length:A0,length_equals:(e,t)=>T0(e,t.length),min_size:E0,max_size:A0,size_equals:(e,t)=>T0(e,t.size),string_format:(e,t)=>{if(L0(e,t.format),t.pattern)P0(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)=>I0(e,t.mime)};function An(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)mE[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)fs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)fs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)ds(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)ds(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)C0(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)I0(t,r.mime);for(let s of r.patterns??[])P0(t,s);return t}var gE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},_E=new Map([[Qu,Km],[ja,Jm]]),N0=(e)=>_E.get(e)??e,D0=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=An(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=gE[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let f=[...c].map(N0);if(f.length===1)r.pattern=f[0].source;else if(f.length>1)r.allOf=[...f.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},O0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=An(e);r.type=u?"integer":"number";let f=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(d)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(d)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let g=new Set;for(let m of a)if(Number.isFinite(m)&&m!==0)g.add(Math.abs(m));else wi(e,t,r,i,`A multipleOf divisor of ${m} cannot be represented in JSON Schema`);let[x,...p]=g;if(x!==void 0)r.multipleOf=x;if(p.length)r.allOf=[...r.allOf??[],...p.map((m)=>({multipleOf:m}))]}},U0=(e,t,n,i)=>{n.type="boolean"};var F0=(e,t,n,i)=>{n.not={}};var z0=(e,t,n,i)=>{};var k0=(e,t,n,i)=>{let r=e._zod.def,s=eo(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},B0=(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(wi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(wi(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 G0=(e,t,n,i)=>{wi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var H0=(e,t,n,i)=>{wi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var V0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=An(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=At(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 W0=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&wi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)zn(r.properties,l,At(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"?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=At(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},$0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>At(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Z0=(e,t,n,i)=>{let r=e._zod.def,s=At(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=At(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function yh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let x=yh(e,g,n);return x===g?t:x}for(let g of["anyOf","oneOf"]){let x=t[g];if(!Array.isArray(x))continue;let p=x.map((m)=>yh(e,m,n));if(p.some((m,E)=>m!==x[E]))t={...t,[g]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((g)=>g==="number"||g==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((g)=>typeof g==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:h,...d}=t;if(d.enum)d.enum=d.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof d.const==="number")d.const=String(d.const);if(!r)return d;if(d.type="string",!s)d.pattern=(i.includes("number")?io:Zu).source;return d}var Sh=new WeakMap;function xE(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 Sh.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=yh(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 X0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=An(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=At(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of a)zn(r.patternProperties,N0(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=At(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Sh.get(t);if(!u)u=[],Sh.set(t,u),t.deferred.push(()=>xE(t));u.push(e)}r.additionalProperties=At(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&oc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(u.length>0)r.required=u.map(String)}},q0=(e,t,n,i)=>{let r=e._zod.def,s=At(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"}]},Y0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},bh=Symbol();function j0(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 wi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),bh}var K0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=j0(r.defaultValue,e,t,n,i);if(o!==bh)n.default=o},J0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=j0(r.defaultValue,e,t,n,i);if(o!==bh)n._prefault=o},Q0=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{wi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},ex=(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;At(o,t,i);let a=t.seen.get(e);a.ref=o},tx=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Mh=(e,t,n,i)=>{let r=e._zod.def;At(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var nx=new WeakSet([Object.prototype,Error.prototype]);function ac(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 EE=(e,t)=>{wm.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(nx.has(n))return;nx.add(n),ac(n,"format",(i)=>(r)=>Em(i,r)),ac(n,"flatten",(i)=>(r)=>Tm(i,r)),ac(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,to,2)}),ac(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,to,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var xn=j("ZodError",EE,void 0,{Parent:Error});var ix=Ga(xn),rx=Ha(xn),sx=Va(xn),ox=Wa(xn),ax=Rm(xn),cx=Cm(xn),lx=Pm(xn),ux=Im(xn),hx=Lm(xn),fx=Nm(xn),dx=Dm(xn),px=Om(xn);function RE(){if(!cn.localeError)_n(rh())}function lc(){if(!cn.memoizer)_n({memoizer:D_()})}var St=j("ZodType",(e,t)=>(RE(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(gn(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 ni(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(RA(e,t))},superRefine(e,t){return this.check(CA(e,t))},overwrite(e){return this.check(Qi(e))},optional(){return _x(this)},exactOptional(){return mA(this)},nullable(){return xx(this)},nullish(){return _x(xx(this))},nonoptional(e){return SA(this,e)},array(){return uc(this)},or(e){return cA([this,e])},and(e){return uA(this,e)},transform(e){return vx(this,pA(e))},default(e){return xA(this,e)},prefault(e){return yA(this,e)},catch(e){return MA(this,e)},pipe(e){return vx(this,e)},readonly(){return EA(this)},describe(e){let t=this.clone();return Mr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mr.get(this);let t=this.clone();return Mr.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 ka(this,"~standard",{...Ju(this),jsonSchema:{input:ho(this,"input"),output:ho(this,"output")}})},set "~standard"(e){Mi(this,"~standard",e)},parse:function e(t,n){return ix(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await rx(this,t,n,{callee:e})},safeParse(e,t){return sx(this,e,t)},async safeParseAsync(e,t){return ox(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Mi(this,"spa",e)},validate(e,t){return Hu(this,e,t)},validateAsync(e,t){return Vu(this,e,t)},encode:function e(t,n){return ax(this,t,n,{callee:e})},decode:function e(t,n){return cx(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await lx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ux(this,t,n,{callee:e})},safeEncode(e,t){return hx(this,e,t)},safeDecode(e,t){return fx(this,e,t)},async safeEncodeAsync(e,t){return dx(this,e,t)},async safeDecodeAsync(e,t){return px(this,e,t)},toJSONSchema(e){return w0(this,{})(e)},get description(){return Mr.get(this)?.description},get _def(){return this._zod.def}}),yx=j("_ZodString",(e,t)=>{Ya.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>D0(e,n,i,r)},xm({format:(e)=>An(e).format??null,minLength:(e)=>An(e).minimum??null,maxLength:(e)=>An(e).maximum??null},{regex(...e){return this.check(sh(...e))},includes(...e){return this.check(ch(...e))},startsWith(...e){return this.check(lh(...e))},endsWith(...e){return this.check(uh(...e))},min(...e){return this.check(hs(...e))},max(...e){return this.check(rc(...e))},length(...e){return this.check(sc(...e))},nonempty(...e){return this.check(hs(1,...e))},lowercase(e){return this.check(oh(e))},uppercase(e){return this.check(ah(e))},trim(){return this.check(fh())},normalize(...e){return this.check(hh(...e))},toLowerCase(){return this.check(dh())},toUpperCase(){return this.check(ph())},slugify(){return this.check(mh())}})),CE=j("ZodString",(e,t)=>{Ya.init(e,t),yx.init(e,t)},{email(e){return this.check(k_(DE,e))},url(e){return this.check($_(UE,e))},jwt(e){return this.check(o0(KE,e))},emoji(e){return this.check(Z_(FE,e))},guid(e){return this.check(B_(OE,e))},uuid(e){return this.check(G_(cc,e))},uuidv4(e){return this.check(H_(cc,e))},uuidv6(e){return this.check(V_(cc,e))},uuidv7(e){return this.check(W_(cc,e))},nanoid(e){return this.check(X_(zE,e))},cuid(e){return this.check(q_(kE,e))},cuid2(e){return this.check(Y_(BE,e))},ulid(e){return this.check(j_(GE,e))},base64(e){return this.check(i0(qE,e))},base64url(e){return this.check(r0(YE,e))},xid(e){return this.check(K_(HE,e))},ksuid(e){return this.check(J_(VE,e))},ipv4(e){return this.check(Q_(WE,e))},ipv6(e){return this.check(e0($E,e))},cidrv4(e){return this.check(t0(ZE,e))},cidrv6(e){return this.check(n0(XE,e))},e164(e){return this.check(s0(jE,e))},datetime(e){return this.check(a0(PE,e))},date(e){return this.check(c0(IE,e))},time(e){return this.check(l0(LE,e))},duration(e){return this.check(u0(NE,e))}});function jt(e){return z_(CE,e)}var bt=j("ZodStringFormat",(e,t)=>{xt.init(e,t),yx.init(e,t)}),PE=j("ZodISODateTime",(e,t)=>{Xg.init(e,t),bt.init(e,t)}),IE=j("ZodISODate",(e,t)=>{qg.init(e,t),bt.init(e,t)}),LE=j("ZodISOTime",(e,t)=>{Yg.init(e,t),bt.init(e,t)}),NE=j("ZodISODuration",(e,t)=>{jg.init(e,t),bt.init(e,t)}),DE=j("ZodEmail",(e,t)=>{Ug.init(e,t),bt.init(e,t)});var OE=j("ZodGUID",(e,t)=>{Dg.init(e,t),bt.init(e,t)});var cc=j("ZodUUID",(e,t)=>{Og.init(e,t),bt.init(e,t)});var UE=j("ZodURL",(e,t)=>{kg.init(e,t),bt.init(e,t)});var FE=j("ZodEmoji",(e,t)=>{Bg.init(e,t),bt.init(e,t)});var zE=j("ZodNanoID",(e,t)=>{Gg.init(e,t),bt.init(e,t)});var kE=j("ZodCUID",(e,t)=>{Hg.init(e,t),bt.init(e,t)});var BE=j("ZodCUID2",(e,t)=>{Vg.init(e,t),bt.init(e,t)});var GE=j("ZodULID",(e,t)=>{Wg.init(e,t),bt.init(e,t)});var HE=j("ZodXID",(e,t)=>{$g.init(e,t),bt.init(e,t)});var VE=j("ZodKSUID",(e,t)=>{Zg.init(e,t),bt.init(e,t)});var WE=j("ZodIPv4",(e,t)=>{Kg.init(e,t),bt.init(e,t)});var $E=j("ZodIPv6",(e,t)=>{Qg.init(e,t),bt.init(e,t)});var ZE=j("ZodCIDRv4",(e,t)=>{e_.init(e,t),bt.init(e,t)});var XE=j("ZodCIDRv6",(e,t)=>{t_.init(e,t),bt.init(e,t)});var qE=j("ZodBase64",(e,t)=>{i_.init(e,t),bt.init(e,t)});var YE=j("ZodBase64URL",(e,t)=>{r_.init(e,t),bt.init(e,t)});var jE=j("ZodE164",(e,t)=>{s_.init(e,t),bt.init(e,t)});var KE=j("ZodJWT",(e,t)=>{o_.init(e,t),bt.init(e,t)});var Sx=j("ZodNumber",(e,t)=>{eh.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>O0(e,n,i,r),e.isFinite=!0},xm({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=An(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=An(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=An(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>An(e).format??null},{gt(e,t){return this.check(nc(e,t))},gte(e,t){return this.check(lo(e,t))},min(e,t){return this.check(lo(e,t))},lt(e,t){return this.check(tc(e,t))},lte(e,t){return this.check(co(e,t))},max(e,t){return this.check(co(e,t))},int(e){return this.check(mx(e))},safe(e){return this.check(mx(e))},positive(e){return this.check(nc(0,e))},nonnegative(e){return this.check(lo(0,e))},negative(e){return this.check(tc(0,e))},nonpositive(e){return this.check(co(0,e))},multipleOf(e,t){return this.check(ic(e,t))},step(e,t){return this.check(ic(e,t))},finite(){return this}}));function JE(e){return h0(Sx,e)}var QE=j("ZodNumberFormat",(e,t)=>{a_.init(e,t),Sx.init(e,t)});function mx(e){return f0(QE,e)}var eA=j("ZodBoolean",(e,t)=>{c_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>U0(e,n,i,r)});function tA(e){return d0(eA,e)}var nA=j("ZodUnknown",(e,t)=>{l_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>z0(e,n,i,r)});function wr(){return p0(nA)}var iA=j("ZodNever",(e,t)=>{u_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>F0(e,n,i,r)});function rA(e){return m0(iA,e)}var sA=j("ZodArray",(e,t)=>{lc(),h_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>V0(e,n,i,r),e.element=t.element},{min(e,t){return this.check(hs(e,t))},nonempty(e){return this.check(hs(1,e))},max(e,t){return this.check(rc(e,t))},length(e,t){return this.check(sc(e,t))},unwrap(){return this.element}});function uc(e,t){return g0(sA,e,t)}var oA=j("ZodObject",(e,t)=>{lc(),p_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>W0(e,n,i,r),FT(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Eh(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(gn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(gn(this._zod.def,{catchall:wr()}))},loose(){return this.clone(gn(this._zod.def,{catchall:wr()}))},strict(){return this.clone(gn(this._zod.def,{catchall:rA()}))},strip(){return this.clone(gn(this._zod.def,{catchall:void 0}))},extend(e){return CT(this,e)},safeExtend(e){return PT(this,e)},merge(e){return IT(this,e)},pick(e){return AT(this,e)},omit(e){return RT(this,e)},partial(...e){return pm(Mx,this,e[0])},exactPartial(...e){return pm(wx,this,e[0],"exactPartial")},required(...e){return LT(Tx,this,e[0])}});function fo(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new oA(n)}var aA=j("ZodUnion",(e,t)=>{m_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$0(e,n,i,r),e.options=t.options});function cA(e,t){return new aA({type:"union",options:e,...Ce(t)})}var lA=j("ZodIntersection",(e,t)=>{g_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Z0(e,n,i,r)});function uA(e,t){return new lA({type:"intersection",left:e,right:t})}var gx=j("ZodRecord",(e,t)=>{lc(),__.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>X0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function bx(e,t,n){if(!t||!t._zod)return new gx({type:"record",keyType:jt(),valueType:e,...Ce(t)});return new gx({type:"record",keyType:e,valueType:t,...Ce(n)})}var Th=j("ZodEnum",(e,t)=>{x_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(i,r,s)=>k0(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 Th({...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 Th({...t,checks:[],...Ce(r),entries:s})}});function Eh(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Th({type:"enum",entries:n,...Ce(t)})}var hA=j("ZodLiteral",(e,t)=>{v_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>B0(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 fA(e,t){return new hA({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var dA=j("ZodTransform",(e,t)=>{lc(),y_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>H0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new no(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(br(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(br(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 pA(e){return new dA({type:"transform",transform:e})}var Mx=j("ZodOptional",(e,t)=>{th.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function _x(e){return new Mx({type:"optional",innerType:e})}var wx=j("ZodExactOptional",(e,t)=>{S_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mh(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function mA(e){return new wx({type:"optional",innerType:e})}var gA=j("ZodNullable",(e,t)=>{b_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>q0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function xx(e){return new gA({type:"nullable",innerType:e})}var _A=j("ZodDefault",(e,t)=>{M_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>K0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xA(e,t){return new _A({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Ou(t)}})}var vA=j("ZodPrefault",(e,t)=>{w_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>J0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function yA(e,t){return new vA({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Ou(t)}})}var Tx=j("ZodNonOptional",(e,t)=>{T_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Y0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function SA(e,t){return new Tx({type:"nonoptional",innerType:e,...Ce(t)})}var bA=j("ZodCatch",(e,t)=>{E_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Q0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function MA(e,t){return new bA({type:"catch",innerType:e,catchValue:typeof t==="function"?t:vm(t)})}var wA=j("ZodPipe",(e,t)=>{A_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ex(e,n,i,r),e.in=t.in,e.out=t.out});function vx(e,t){return new wA({type:"pipe",in:e,out:t})}var TA=j("ZodReadonly",(e,t)=>{R_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tx(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function EA(e){return new TA({type:"readonly",innerType:e})}var AA=j("ZodCustom",(e,t)=>{C_.init(e,t),St.init(e,t),e._zod.processJSONSchema=(n,i,r)=>G0(e,n,i,r)});function RA(e,t={}){return _0(AA,e,t)}function CA(e,t){return x0(e,t)}var Ex=["neutral","dark","light"];var Ah=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),Ax=Object.freeze({neutral:Ah("neutral",[170,177,188]),dark:Ah("dark",[26,26,26]),light:Ah("light",[223,227,232])});var QL=Ax.neutral.rgb,eN=Ax.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 wt=Uint8Array,vn=Uint16Array,Dh=Int32Array,hc=new wt([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]),fc=new wt([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]),Ch=new wt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ix=function(e,t){var n=new vn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Dh(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}},Lx=Ix(hc,2),{b:Nx,r:Ph}=Lx;Nx[28]=258,Ph[258]=28;var Dx=Ix(fc,0),{b:RA,r:Tx}=Dx,Ih=new vn(32768);for(Ye=0;Ye<32768;++Ye)oi=(Ye&43690)>>1|(Ye&21845)<<1,oi=(oi&52428)>>2|(oi&13107)<<2,oi=(oi&61680)>>4|(oi&3855)<<4,Ih[Ye]=((oi&65280)>>8|(oi&255)<<8)>>1;var oi,Ye,ai=function(e,t,n){var i=e.length,r=0,s=new vn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new vn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new vn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[Ih[f]>>c]=l}}else{a=new vn(i);for(r=0;r<i;++r)if(e[r])a[r]=Ih[o[e[r]-1]++]>>15-e[r]}return a},er=new wt(288);for(Ye=0;Ye<144;++Ye)er[Ye]=8;var Ye;for(Ye=144;Ye<256;++Ye)er[Ye]=9;var Ye;for(Ye=256;Ye<280;++Ye)er[Ye]=7;var Ye;for(Ye=280;Ye<288;++Ye)er[Ye]=8;var Ye,go=new wt(32);for(Ye=0;Ye<32;++Ye)go[Ye]=5;var Ye,CA=ai(er,9,0),PA=ai(er,9,1),IA=ai(go,5,0),LA=ai(go,5,1),Eh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Bn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Ah=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Oh=function(e){return(e+7)/8|0},Uh=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new wt(e.subarray(t,n))};var NA=["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"],Rn=function(e,t,n){var i=Error(t||NA[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Rn);if(!n)throw i;return i},DA=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new wt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new wt(r*3);var l=function(we){var mt=n.length;if(we>mt){var ze=new wt(Math.max(mt*2,we));ze.set(n),n=ze}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Bn(e,f,1);var E=Bn(e,f+1,3);if(f+=3,!E){var R=Oh(f)+4,S=e[R-4]|e[R-3]<<8,b=R+S;if(b>r){if(c)Rn(0);break}if(a)l(h+S);n.set(e.subarray(R,b),h),t.b=h+=S,t.p=f=b*8,t.f=u;continue}else if(E==1)d=PA,g=LA,x=9,p=5;else if(E==2){var T=Bn(e,f,31)+257,A=Bn(e,f+10,15)+4,_=T+Bn(e,f+5,31)+1;f+=14;var M=new wt(_),F=new wt(19);for(var P=0;P<A;++P)F[Ch[P]]=Bn(e,f+P*3,7);f+=A*3;var O=Eh(F),K=(1<<O)-1,C=ai(F,O,1);for(var P=0;P<_;){var G=C[Bn(e,f,K)];f+=G&15;var R=G>>4;if(R<16)M[P++]=R;else{var X=0,z=0;if(R==16)z=3+Bn(e,f,3),f+=2,X=M[P-1];else if(R==17)z=3+Bn(e,f,7),f+=3;else if(R==18)z=11+Bn(e,f,127),f+=7;while(z--)M[P++]=X}}var te=M.subarray(0,T),H=M.subarray(T);x=Eh(te),p=Eh(H),d=ai(te,x,1),g=ai(H,p,1)}else Rn(1);if(f>m){if(c)Rn(0);break}}if(a)l(h+131072);var Q=(1<<x)-1,ee=(1<<p)-1,Te=f;for(;;Te=f){var X=d[Ah(e,f)&Q],ve=X>>4;if(f+=X&15,f>m){if(c)Rn(0);break}if(!X)Rn(2);if(ve<256)n[h++]=ve;else if(ve==256){Te=f,d=null;break}else{var Ge=ve-254;if(ve>264){var P=ve-257,Me=hc[P];Ge=Bn(e,f,(1<<Me)-1)+Nx[P],f+=Me}var Z=g[Ah(e,f)&ee],re=Z>>4;if(!Z)Rn(3);f+=Z&15;var H=RA[re];if(re>3){var Me=fc[re];H+=Ah(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)Rn(0);break}if(a)l(h+131072);var se=h+Ge;if(h<H){var Pe=s-H,Ie=Math.min(H,se);if(Pe+h<0)Rn(3);for(;h<Ie;++h)n[h]=i[Pe+h]}for(;h<se;++h)n[h]=n[h-H]}}if(t.l=d,t.p=Te,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?Uh(n,0,h):n.subarray(0,h)},Ti=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},po=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},Rh=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:Ux,l:0};if(r==1){var o=new wt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(b,T){return b.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new vn(h+1),g=Lh(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var S=s[i].s;if(d[S]==t)--d[S],++x}g=t}return{t:new wt(d),l:g}},Lh=function(e,t,n){return e.s==-1?Math.max(Lh(e.l,t,n+1),Lh(e.r,t,n+1)):t[e.s]=n},Ex=function(e){var t=e.length;while(t&&!e[--t]);var n=new vn(++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}},mo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Ox=function(e,t,n){var i=n.length,r=Oh(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},Ax=function(e,t,n,i,r,s,o,a,c,l,u){Ti(t,u++,n),++r[256];var f=Rh(r,15),{t:h,l:d}=f,g=Rh(s,15),{t:x,l:p}=g,m=Ex(h),{c:E,n:R}=m,S=Ex(x),{c:b,n:T}=S,A=new vn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<b.length;++_)++A[b[_]&31];var M=Rh(A,7),{t:F,l:P}=M,O=19;for(;O>4&&!F[Ch[O-1]];--O);var K=l+5<<3,C=mo(r,er)+mo(s,go)+o,G=mo(r,h)+mo(s,x)+o+14+3*O+mo(A,F)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&K<=C&&K<=G)return Ox(t,u,e.subarray(c,c+l));var X,z,te,H;if(Ti(t,u,1+(G<C)),u+=2,G<C){X=ai(h,d,0),z=h,te=ai(x,p,0),H=x;var Q=ai(F,P,0);Ti(t,u,R-257),Ti(t,u+5,T-1),Ti(t,u+10,O-4),u+=14;for(var _=0;_<O;++_)Ti(t,u+3*_,F[Ch[_]]);u+=3*O;var ee=[E,b];for(var Te=0;Te<2;++Te){var ve=ee[Te];for(var _=0;_<ve.length;++_){var Ge=ve[_]&31;if(Ti(t,u,Q[Ge]),u+=F[Ge],Ge>15)Ti(t,u,ve[_]>>5&127),u+=ve[_]>>12}}}else X=CA,z=er,te=IA,H=go;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var Ge=Me>>18&31;if(po(t,u,X[Ge+257]),u+=z[Ge+257],Ge>7)Ti(t,u,Me>>23&31),u+=hc[Ge];var Z=Me&31;if(po(t,u,te[Z]),u+=H[Z],Z>3)po(t,u,Me>>5&8191),u+=fc[Z]}else po(t,u,X[Me]),u+=z[Me]}return po(t,u,X[256]),u+z[256]},OA=new Dh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ux=new wt(0),UA=function(e,t,n,i,r,s){var o=s.z||e.length,a=new wt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=OA[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new vn(32768),p=s.h||new vn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},S=new Dh(25000),b=new vn(288),T=new vn(32),A=0,_=0,M=s.i||0,F=0,P=s.w||0,O=0;for(;M+2<o;++M){var K=R(M),C=M&32767,G=p[K];if(x[C]=G,p[K]=C,P<=M){var X=o-M;if((A>7000||F>24576)&&(X>423||!l)){u=Ax(e,c,0,S,b,T,_,F,O,M-O,u),F=A=_=0,O=M;for(var z=0;z<286;++z)b[z]=0;for(var z=0;z<30;++z)T[z]=0}var te=2,H=0,Q=d,ee=C-G&32767;if(X>2&&K==R(M-ee)){var Te=Math.min(h,X)-1,ve=Math.min(32767,M),Ge=Math.min(258,X);while(ee<=ve&&--Q&&C!=G){if(e[M+te]==e[M+te-ee]){var Me=0;for(;Me<Ge&&e[M+Me]==e[M+Me-ee];++Me);if(Me>te){if(te=Me,H=ee,Me>Te)break;var Z=Math.min(ee,Me-2),re=0;for(var z=0;z<Z;++z){var se=M-ee+z&32767,Pe=x[se],Ie=se-Pe&32767;if(Ie>re)re=Ie,G=se}}}C=G,G=x[C],ee+=C-G&32767}}if(H){S[F++]=268435456|Ph[te]<<18|Tx[H];var we=Ph[te]&31,mt=Tx[H]&31;_+=hc[we]+fc[mt],++b[257+we],++T[mt],P=M+te,++A}else S[F++]=e[M],++b[e[M]]}}for(M=Math.max(M,P);M<o;++M)S[F++]=e[M],++b[e[M]];if(u=Ax(e,c,l,S,b,T,_,F,O,M-O,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=M,s.w=P}else{for(var M=s.w||0;M<o+l;M+=65535){var ze=M+65535;if(ze>=o)c[u/8|0]=l,ze=o;u=Ox(c,u+1,e.subarray(M,ze))}s.i=o}return Uh(a,0,i+Oh(u)+r)},FA=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}(),zA=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=FA[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var kA=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new wt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return UA(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)},Fx=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 Vt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function zx(e,t){return kA(e,t||{},0,0)}function kx(e,t){return DA(e,{i:2},t&&t.out,t&&t.dictionary)}var Bx=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Fx(i,s[1]),s=s[0];if(s instanceof wt)n[o]=[s,a];else n[o+="/"]=[new wt(0),a],Bx(s,o,n,i)}},Rx=typeof TextEncoder<"u"&&new TextEncoder,BA=typeof TextDecoder<"u"&&new TextDecoder,GA=0;try{BA.decode(Ux,{stream:!0}),GA=1}catch(e){}function Cx(e,t){if(t){var n=new wt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(Rx)return Rx.encode(e);var r=e.length,s=new wt(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 wt(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 Uh(s,0,o)}var Nh=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Rn(9);t+=i+4}return t},Px=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=Nh(l);if(Vt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)Rn(10);if(Vt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Vt(e,t,n.crc),Vt(e,t+4,s<0?-s-2:s),Vt(e,t+8,n.size);if(Vt(e,t+12,c),Vt(e,t+14,f),t+=16,o!=null)Vt(e,t,u),Vt(e,t+6,n.attrs),Vt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;Vt(e,t,+g),Vt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},HA=function(e,t,n,i,r){Vt(e,t,101010256),Vt(e,t+8,n),Vt(e,t+10,n),Vt(e,t+12,i),Vt(e,t+16,r)};function Gx(e,t){if(!t)t={};var n={},i=[];Bx(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=Cx(o),h=f.length,d=l.comment,g=d&&Cx(d),x=g&&g.length,p=Nh(l.extra);if(h>65535)Rn(11);var m=u?zx(c,l):c,E=m.length,R=zA();R.p(c),i.push(Fx(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var S=new wt(s+22),b=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];Px(S,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+Nh(f.extra);S.set(f.c,f.o+_),Px(S,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return HA(S,r,i.length,T,b),S}var dc=67108864,Fh=jt().regex(/^[a-z][a-z0-9_-]{0,79}$/),VA=jt().regex(/^sha256:[a-f0-9]{64}$/),zh=fo({version:lA("kiln.asset.v1"),assetId:Fh,revisionId:Fh,parentRevision:Fh.optional(),name:jt().min(1).max(200),tags:uc(jt().max(80)).max(30),createdAt:jt().datetime(),description:jt().max(4000).optional(),brief:jt().max(8000).optional(),attribution:fo({model:jt().max(200).optional(),harness:jt().max(200).optional(),author:jt().max(200).optional()}).optional(),editable:JE(),files:yx(jt(),fo({sha256:VA,bytes:YE().int().nonnegative().max(dc)})),build:fo({engine:jt(),options:yx(jt(),wr()),warnings:uc(jt()),integration:wr().optional(),qa:wr().optional(),dependencies:uc(wr()).optional(),rebuild:Sx(["engine-required","external-dependencies-required"])}).optional(),preview:fo({fidelity:wr().optional(),error:jt().optional()}).optional()}),WA=new Set(["asset.glb","source.kiln.js","preview.png"]);function $A(e){let t=zh.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(!WA.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>dc||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");kh(e.files["asset.glb"])}function kh(e){if(e.length<20||e.length>dc)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 Hx(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){$A(i);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}for(let i of Object.values(t))n+=i.length;if(n>dc)throw Error("Bundle exceeds 64 MiB");return Gx(t,{level:0})}function Vx(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 E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let S of[E.min.y,E.max.y])for(let b of[E.min.z,E.max.z])l.push(new U(R,S,b));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),S=R.dot(a),b=R.dot(c);u=Math.min(u,S),f=Math.max(f,S),h=Math.min(h,b),d=Math.max(d,b)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),S=R.dot(o);p=Math.max(p,S+Math.abs(R.dot(a))*1.12/x,S+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function Wx(e){let t=new xu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=As,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Qr,i=new Lt(40,1,0.01,1000),r=new Pu(i,t.domElement);r.enableDamping=!0;let s=new js(t),o=new Iu,a=s.fromScene(o,0.04);n.environment=a.texture,o.dispose(),s.dispose();let c=new ss(16773591,2.4);c.position.set(4,8,5),n.add(c),n.add(new Sa(14806490,5065021,1.7));let l,u,f=[],h=!0,d=performance.now(),g=0,x=0,p=!1,m=(b)=>{let T=new Set,A=new Set,_=new Set;b.traverse((M)=>{let F=M;if(!F.isMesh)return;T.add(F.geometry);for(let P of Array.isArray(F.material)?F.material:[F.material]){A.add(P);for(let O of Object.values(P))if(O instanceof Mt)_.add(O)}});for(let M of[...T,...A,..._])M.dispose()},E=()=>{if(!l)return;let b=new en().setFromObject(l,!0),T=[];l.traverse((P)=>{if(P instanceof pt||P instanceof Hi||P instanceof ns){let O=new en().setFromObject(P,!0);if(!O.isEmpty())T.push(O)}});let{center:A,radius:_,distance:M,position:F}=Vx(b,i.aspect,i.fov,T);r.target.copy(A),i.position.copy(F),i.near=Math.max(_/1000,0.0001),i.far=M+_*100,r.minDistance=_*0.1,r.maxDistance=_*80,i.updateProjectionMatrix(),r.update()},R=new ResizeObserver(()=>{let{clientWidth:b,clientHeight:T}=e;if(!b||!T)return;t.setSize(b,T),i.aspect=b/T,i.updateProjectionMatrix()});R.observe(e);let S=(b)=>{if(p)return;let T=Math.min((b-d)/1000,0.1);if(d=b,h)u?.update(T);r.update(),t.render(n,i),g=requestAnimationFrame(S)};return g=requestAnimationFrame(S),{async load(b){let T=++x;kh(b);let A=new Hs;A.setURLModifier((C)=>{if(!C.startsWith("blob:")&&!C.startsWith("data:"))throw Error("External model resources are not loaded");return C});let _=await new Eu(A).parseAsync(Uint8Array.from(b).buffer,"");if(p||T!==x){m(_.scene);return}if(l)u?.stopAllAction(),u?.uncacheRoot(l),n.remove(l),m(l);l=_.scene,n.add(l),f=_.animations,u=new Ta(l),h=!0;let{clientWidth:M,clientHeight:F}=e;t.setSize(M,F),i.aspect=M/F,E();let P=0,O=0,K=new Set;return l.traverse((C)=>{let G=C;if(!G.isMesh)return;O++,P+=(G.geometry.index?.count??G.geometry.attributes.position?.count??0)/3*(G.isInstancedMesh?G.count:1);for(let X of Array.isArray(G.material)?G.material:[G.material])K.add(X)}),{triangles:P,meshes:O,materials:K.size,clips:f.map((C)=>C.name)}},reset:E,wire(b){l?.traverse((T)=>{let A=T;if(A.isMesh){for(let _ of Array.isArray(A.material)?A.material:[A.material])if("wireframe"in _)_.wireframe=b}})},lighting(b){t.toneMappingExposure=b==="bright"?1.65:b==="soft"?0.85:1.15,c.intensity=b==="soft"?0.8:2.4},clip(b){if(u?.stopAllAction(),f[b])u?.clipAction(f[b]).play()},pause(b){h=!b},dispose(){if(p=!0,x++,cancelAnimationFrame(g),R.disconnect(),r.dispose(),l)m(l);a.dispose(),t.dispose(),e.replaceChildren()}}}async function $x(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var Xx=16777216,qx=Math.ceil(Xx/3)*4,Bt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function ZA(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function Zx(e){if(typeof e!=="string"||e.length>qx)return Bt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Bt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Bt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(ZA(n)!==e)Bt("contains noncanonical base64 data");return n}function _o(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function Yx(e){if(!_o(e))return Bt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=zh.safeParse(e.manifest);if(!t.success||!_o(e.files))return Bt("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 Bt("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 Bt("file metadata is missing");if(r+=n.files[c].bytes,r>Xx)return Bt("exceeds the decoded size limit");let u=typeof l==="string"?l:_o(l)?l.data:void 0;if(typeof u!=="string")return Bt("file encoding is malformed");if(s+=u.length,s>qx)return Bt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=Zx(l);else{if(!_o(l)||l.encoding!=="kiln.deflate-base64.v1")return Bt("encoding is unsupported");let g=Zx(l.data);try{f=kx(g,{out:new Uint8Array(u.bytes+1)})}catch{return Bt("compressed data is damaged")}}if(f.length!==u.bytes)return Bt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Bt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Bt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!_o(e.downloadUrls))return Bt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Bt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function jx(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 Gn=(e)=>document.getElementById(e),ci=Gn("status"),Kt,Jx={},xo,XA=0,li=0,pc=new Map;function Qx(e,t){let n=++XA;return new Promise((i,r)=>{let s=setTimeout(()=>{pc.delete(n),r(Error("Chat host did not respond."))},20000);pc.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 Kx(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function qA(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 YA(e){let t=++li;Kt=void 0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await jA(e,t)}catch(n){if(t!==li)return;ci.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function jA(e,t){if(e.isError){ci.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await Yx(e._meta?.kilnAsset)}catch(i){if(t!==li)return;ci.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==li)return;Kt=n.record,Gn("name").textContent=Kt.manifest.name,Jx=n.downloadUrls,Gn("revision").textContent=`${Kt.manifest.editable?"Editable source included":"GLB asset"} · ${Kt.manifest.revisionId.slice(0,10)}`,Gn("attribution").textContent=jx(Kt.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{xo??=Wx(Gn("stage"));let i=await xo.load(Kt.files["asset.glb"]);if(t!==li)return;if(i){Gn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(Kt.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Gn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}ci.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==li)return;let r=Kt.files["preview.png"];if(r){let s=new Image;s.alt=Kt.manifest.name,s.src=`data:image/png;base64,${qA(r)}`,Gn("stage").replaceChildren(s)}ci.textContent=`3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Gn("source").hidden=!Kt.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=pc.get(t.id);if(pc.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")YA(t.params);if(t.method==="ui/resource-teardown")xo?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Gn("reset").onclick=()=>xo?.reset();Gn("clips").onchange=(e)=>xo?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!Kt)return;let t=li,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?Hx([Kt]):Kt.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=Kt.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,ci.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await $x(r,`${o}-${i}`,s,Qx,a,Jx[i]);if(t!==li)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})},ci.replaceChildren("Download ready. ",l)}else ci.textContent="Download requested."}catch(a){if(t===li)ci.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!Kt||t!==li}};Qx("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Kx("ui/notifications/initialized"),Kx("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{ci.textContent=e.message});
+*/var wt=Uint8Array,vn=Uint16Array,Uh=Int32Array,hc=new wt([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]),fc=new wt([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]),Ih=new wt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dx=function(e,t){var n=new vn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Uh(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}},Ox=Dx(hc,2),{b:Ux,r:Lh}=Ox;Ux[28]=258,Lh[258]=28;var Fx=Dx(fc,0),{b:IA,r:Rx}=Fx,Nh=new vn(32768);for(Ye=0;Ye<32768;++Ye)oi=(Ye&43690)>>1|(Ye&21845)<<1,oi=(oi&52428)>>2|(oi&13107)<<2,oi=(oi&61680)>>4|(oi&3855)<<4,Nh[Ye]=((oi&65280)>>8|(oi&255)<<8)>>1;var oi,Ye,ai=function(e,t,n){var i=e.length,r=0,s=new vn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new vn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new vn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],f=o[e[r]-1]++<<u;for(var h=f|(1<<u)-1;f<=h;++f)a[Nh[f]>>c]=l}}else{a=new vn(i);for(r=0;r<i;++r)if(e[r])a[r]=Nh[o[e[r]-1]++]>>15-e[r]}return a},er=new wt(288);for(Ye=0;Ye<144;++Ye)er[Ye]=8;var Ye;for(Ye=144;Ye<256;++Ye)er[Ye]=9;var Ye;for(Ye=256;Ye<280;++Ye)er[Ye]=7;var Ye;for(Ye=280;Ye<288;++Ye)er[Ye]=8;var Ye,go=new wt(32);for(Ye=0;Ye<32;++Ye)go[Ye]=5;var Ye,LA=ai(er,9,0),NA=ai(er,9,1),DA=ai(go,5,0),OA=ai(go,5,1),Rh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Bn=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Ch=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Fh=function(e){return(e+7)/8|0},zh=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new wt(e.subarray(t,n))};var UA=["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"],Rn=function(e,t,n){var i=Error(t||UA[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Rn);if(!n)throw i;return i},FA=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new wt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new wt(r*3);var l=function(we){var mt=n.length;if(we>mt){var ze=new wt(Math.max(mt*2,we));ze.set(n),n=ze}},u=t.f||0,f=t.p||0,h=t.b||0,{l:d,d:g,m:x,n:p}=t,m=r*8;do{if(!d){u=Bn(e,f,1);var E=Bn(e,f+1,3);if(f+=3,!E){var R=Fh(f)+4,S=e[R-4]|e[R-3]<<8,b=R+S;if(b>r){if(c)Rn(0);break}if(a)l(h+S);n.set(e.subarray(R,b),h),t.b=h+=S,t.p=f=b*8,t.f=u;continue}else if(E==1)d=NA,g=OA,x=9,p=5;else if(E==2){var T=Bn(e,f,31)+257,A=Bn(e,f+10,15)+4,_=T+Bn(e,f+5,31)+1;f+=14;var M=new wt(_),F=new wt(19);for(var P=0;P<A;++P)F[Ih[P]]=Bn(e,f+P*3,7);f+=A*3;var O=Rh(F),K=(1<<O)-1,C=ai(F,O,1);for(var P=0;P<_;){var G=C[Bn(e,f,K)];f+=G&15;var R=G>>4;if(R<16)M[P++]=R;else{var X=0,z=0;if(R==16)z=3+Bn(e,f,3),f+=2,X=M[P-1];else if(R==17)z=3+Bn(e,f,7),f+=3;else if(R==18)z=11+Bn(e,f,127),f+=7;while(z--)M[P++]=X}}var te=M.subarray(0,T),H=M.subarray(T);x=Rh(te),p=Rh(H),d=ai(te,x,1),g=ai(H,p,1)}else Rn(1);if(f>m){if(c)Rn(0);break}}if(a)l(h+131072);var Q=(1<<x)-1,ee=(1<<p)-1,Te=f;for(;;Te=f){var X=d[Ch(e,f)&Q],ve=X>>4;if(f+=X&15,f>m){if(c)Rn(0);break}if(!X)Rn(2);if(ve<256)n[h++]=ve;else if(ve==256){Te=f,d=null;break}else{var Ge=ve-254;if(ve>264){var P=ve-257,Me=hc[P];Ge=Bn(e,f,(1<<Me)-1)+Ux[P],f+=Me}var Z=g[Ch(e,f)&ee],re=Z>>4;if(!Z)Rn(3);f+=Z&15;var H=IA[re];if(re>3){var Me=fc[re];H+=Ch(e,f)&(1<<Me)-1,f+=Me}if(f>m){if(c)Rn(0);break}if(a)l(h+131072);var se=h+Ge;if(h<H){var Pe=s-H,Ie=Math.min(H,se);if(Pe+h<0)Rn(3);for(;h<Ie;++h)n[h]=i[Pe+h]}for(;h<se;++h)n[h]=n[h-H]}}if(t.l=d,t.p=Te,t.b=h,t.f=u,d)u=1,t.m=x,t.d=g,t.n=p}while(!u);return h!=n.length&&o?zh(n,0,h):n.subarray(0,h)},Ti=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},po=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},Ph=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:kx,l:0};if(r==1){var o=new wt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(b,T){return b.f-T.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,f=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var d=new vn(h+1),g=Dh(n[u-1],d,0);if(g>t){var i=0,x=0,p=g-t,m=1<<p;s.sort(function(T,A){return d[A.s]-d[T.s]||T.f-A.f});for(;i<r;++i){var E=s[i].s;if(d[E]>t)x+=m-(1<<g-d[E]),d[E]=t;else break}x>>=p;while(x>0){var R=s[i].s;if(d[R]<t)x-=1<<t-d[R]++-1;else++i}for(;i>=0&&x;--i){var S=s[i].s;if(d[S]==t)--d[S],++x}g=t}return{t:new wt(d),l:g}},Dh=function(e,t,n){return e.s==-1?Math.max(Dh(e.l,t,n+1),Dh(e.r,t,n+1)):t[e.s]=n},Cx=function(e){var t=e.length;while(t&&!e[--t]);var n=new vn(++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}},mo=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},zx=function(e,t,n){var i=n.length,r=Fh(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},Px=function(e,t,n,i,r,s,o,a,c,l,u){Ti(t,u++,n),++r[256];var f=Ph(r,15),{t:h,l:d}=f,g=Ph(s,15),{t:x,l:p}=g,m=Cx(h),{c:E,n:R}=m,S=Cx(x),{c:b,n:T}=S,A=new vn(19);for(var _=0;_<E.length;++_)++A[E[_]&31];for(var _=0;_<b.length;++_)++A[b[_]&31];var M=Ph(A,7),{t:F,l:P}=M,O=19;for(;O>4&&!F[Ih[O-1]];--O);var K=l+5<<3,C=mo(r,er)+mo(s,go)+o,G=mo(r,h)+mo(s,x)+o+14+3*O+mo(A,F)+2*A[16]+3*A[17]+7*A[18];if(c>=0&&K<=C&&K<=G)return zx(t,u,e.subarray(c,c+l));var X,z,te,H;if(Ti(t,u,1+(G<C)),u+=2,G<C){X=ai(h,d,0),z=h,te=ai(x,p,0),H=x;var Q=ai(F,P,0);Ti(t,u,R-257),Ti(t,u+5,T-1),Ti(t,u+10,O-4),u+=14;for(var _=0;_<O;++_)Ti(t,u+3*_,F[Ih[_]]);u+=3*O;var ee=[E,b];for(var Te=0;Te<2;++Te){var ve=ee[Te];for(var _=0;_<ve.length;++_){var Ge=ve[_]&31;if(Ti(t,u,Q[Ge]),u+=F[Ge],Ge>15)Ti(t,u,ve[_]>>5&127),u+=ve[_]>>12}}}else X=LA,z=er,te=DA,H=go;for(var _=0;_<a;++_){var Me=i[_];if(Me>255){var Ge=Me>>18&31;if(po(t,u,X[Ge+257]),u+=z[Ge+257],Ge>7)Ti(t,u,Me>>23&31),u+=hc[Ge];var Z=Me&31;if(po(t,u,te[Z]),u+=H[Z],Z>3)po(t,u,Me>>5&8191),u+=fc[Z]}else po(t,u,X[Me]),u+=z[Me]}return po(t,u,X[256]),u+z[256]},zA=new Uh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kx=new wt(0),kA=function(e,t,n,i,r,s){var o=s.z||e.length,a=new wt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var f=zA[t-1],h=f>>13,d=f&8191,g=(1<<n)-1,x=s.p||new vn(32768),p=s.h||new vn(g+1),m=Math.ceil(n/3),E=2*m,R=function(Ze){return(e[Ze]^e[Ze+1]<<m^e[Ze+2]<<E)&g},S=new Uh(25000),b=new vn(288),T=new vn(32),A=0,_=0,M=s.i||0,F=0,P=s.w||0,O=0;for(;M+2<o;++M){var K=R(M),C=M&32767,G=p[K];if(x[C]=G,p[K]=C,P<=M){var X=o-M;if((A>7000||F>24576)&&(X>423||!l)){u=Px(e,c,0,S,b,T,_,F,O,M-O,u),F=A=_=0,O=M;for(var z=0;z<286;++z)b[z]=0;for(var z=0;z<30;++z)T[z]=0}var te=2,H=0,Q=d,ee=C-G&32767;if(X>2&&K==R(M-ee)){var Te=Math.min(h,X)-1,ve=Math.min(32767,M),Ge=Math.min(258,X);while(ee<=ve&&--Q&&C!=G){if(e[M+te]==e[M+te-ee]){var Me=0;for(;Me<Ge&&e[M+Me]==e[M+Me-ee];++Me);if(Me>te){if(te=Me,H=ee,Me>Te)break;var Z=Math.min(ee,Me-2),re=0;for(var z=0;z<Z;++z){var se=M-ee+z&32767,Pe=x[se],Ie=se-Pe&32767;if(Ie>re)re=Ie,G=se}}}C=G,G=x[C],ee+=C-G&32767}}if(H){S[F++]=268435456|Lh[te]<<18|Rx[H];var we=Lh[te]&31,mt=Rx[H]&31;_+=hc[we]+fc[mt],++b[257+we],++T[mt],P=M+te,++A}else S[F++]=e[M],++b[e[M]]}}for(M=Math.max(M,P);M<o;++M)S[F++]=e[M],++b[e[M]];if(u=Px(e,c,l,S,b,T,_,F,O,M-O,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=x,s.i=M,s.w=P}else{for(var M=s.w||0;M<o+l;M+=65535){var ze=M+65535;if(ze>=o)c[u/8|0]=l,ze=o;u=zx(c,u+1,e.subarray(M,ze))}s.i=o}return zh(a,0,i+Fh(u)+r)},BA=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}(),GA=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=BA[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var HA=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new wt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return kA(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)},Bx=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 Vt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Gx(e,t){return HA(e,t||{},0,0)}function Hx(e,t){return FA(e,{i:2},t&&t.out,t&&t.dictionary)}var Vx=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Bx(i,s[1]),s=s[0];if(s instanceof wt)n[o]=[s,a];else n[o+="/"]=[new wt(0),a],Vx(s,o,n,i)}},Ix=typeof TextEncoder<"u"&&new TextEncoder,VA=typeof TextDecoder<"u"&&new TextDecoder,WA=0;try{VA.decode(kx,{stream:!0}),WA=1}catch(e){}function Lx(e,t){if(t){var n=new wt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(Ix)return Ix.encode(e);var r=e.length,s=new wt(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 wt(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 zh(s,0,o)}var Oh=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Rn(9);t+=i+4}return t},Nx=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,f=Oh(l);if(Vt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),d=h.getFullYear()-1980;if(d<0||d>119)Rn(10);if(Vt(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Vt(e,t,n.crc),Vt(e,t+4,s<0?-s-2:s),Vt(e,t+8,n.size);if(Vt(e,t+12,c),Vt(e,t+14,f),t+=16,o!=null)Vt(e,t,u),Vt(e,t+6,n.attrs),Vt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,f)for(var g in l){var x=l[g],p=x.length;Vt(e,t,+g),Vt(e,t+2,p),e.set(x,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},$A=function(e,t,n,i,r){Vt(e,t,101010256),Vt(e,t+8,n),Vt(e,t+10,n),Vt(e,t+12,i),Vt(e,t+16,r)};function Wx(e,t){if(!t)t={};var n={},i=[];Vx(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,f=Lx(o),h=f.length,d=l.comment,g=d&&Lx(d),x=g&&g.length,p=Oh(l.extra);if(h>65535)Rn(11);var m=u?Gx(c,l):c,E=m.length,R=GA();R.p(c),i.push(Bx(l,{size:c.length,crc:R.d(),c:m,f,m:g,u:h!=o.length||g&&d.length!=x,o:r,compression:u})),r+=30+h+p+E,s+=76+2*(h+p)+(x||0)+E}var S=new wt(s+22),b=r,T=s-r;for(var A=0;A<i.length;++A){var f=i[A];Nx(S,f.o,f,f.f,f.u,f.c.length);var _=30+f.f.length+Oh(f.extra);S.set(f.c,f.o+_),Nx(S,r,f,f.f,f.u,f.c.length,f.o,f.m),r+=16+_+(f.m?f.m.length:0)}return $A(S,r,i.length,T,b),S}var dc=67108864,kh=jt().regex(/^[a-z][a-z0-9_-]{0,79}$/),ZA=jt().regex(/^sha256:[a-f0-9]{64}$/),Bh=fo({version:fA("kiln.asset.v1"),assetId:kh,revisionId:kh,parentRevision:kh.optional(),name:jt().min(1).max(200),tags:uc(jt().max(80)).max(30),createdAt:jt().datetime(),description:jt().max(4000).optional(),brief:jt().max(8000).optional(),attribution:fo({model:jt().max(200).optional(),harness:jt().max(200).optional(),author:jt().max(200).optional()}).optional(),editable:tA(),files:bx(jt(),fo({sha256:ZA,bytes:JE().int().nonnegative().max(dc)})),build:fo({engine:jt(),options:bx(jt(),wr()),warnings:uc(jt()),integration:wr().optional(),qa:wr().optional(),dependencies:uc(wr()).optional(),rebuild:Eh(["engine-required","external-dependencies-required"])}).optional(),preview:fo({fidelity:wr().optional(),error:jt().optional(),backdrop:Eh(Ex).optional()}).optional()}),XA=new Set(["asset.glb","source.kiln.js","preview.png"]);function qA(e){let t=Bh.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(!XA.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>dc||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");Gh(e.files["asset.glb"])}function Gh(e){if(e.length<20||e.length>dc)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 $x(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){qA(i);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}for(let i of Object.values(t))n+=i.length;if(n>dc)throw Error("Bundle exceeds 64 MiB");return Wx(t,{level:0})}function Zx(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 E of i.length?i:[e])for(let R of[E.min.x,E.max.x])for(let S of[E.min.y,E.max.y])for(let b of[E.min.z,E.max.z])l.push(new U(R,S,b));let u=1/0,f=-1/0,h=1/0,d=-1/0;for(let E of l){let R=E.clone().sub(r),S=R.dot(a),b=R.dot(c);u=Math.min(u,S),f=Math.max(f,S),h=Math.min(h,b),d=Math.max(d,b)}r.addScaledVector(a,(u+f)/2),r.addScaledVector(c,(h+d)/2);let g=Math.tan(n*Math.PI/360),x=g*t,p=s;for(let E of l){let R=E.clone().sub(r),S=R.dot(o);p=Math.max(p,S+Math.abs(R.dot(a))*1.12/x,S+Math.abs(R.dot(c))*1.12/g)}let m=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:m}}function Xx(e){let t=new xu({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=As,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Qr,i=new Lt(40,1,0.01,1000),r=new Pu(i,t.domElement);r.enableDamping=!0;let s=new js(t),o=new Iu,a=s.fromScene(o,0.04);n.environment=a.texture,o.dispose(),s.dispose();let c=new ss(16773591,2.4);c.position.set(4,8,5),n.add(c),n.add(new Sa(14806490,5065021,1.7));let l,u,f=[],h=!0,d=performance.now(),g=0,x=0,p=!1,m=(b)=>{let T=new Set,A=new Set,_=new Set;b.traverse((M)=>{let F=M;if(!F.isMesh)return;T.add(F.geometry);for(let P of Array.isArray(F.material)?F.material:[F.material]){A.add(P);for(let O of Object.values(P))if(O instanceof Mt)_.add(O)}});for(let M of[...T,...A,..._])M.dispose()},E=()=>{if(!l)return;let b=new en().setFromObject(l,!0),T=[];l.traverse((P)=>{if(P instanceof pt||P instanceof Hi||P instanceof ns){let O=new en().setFromObject(P,!0);if(!O.isEmpty())T.push(O)}});let{center:A,radius:_,distance:M,position:F}=Zx(b,i.aspect,i.fov,T);r.target.copy(A),i.position.copy(F),i.near=Math.max(_/1000,0.0001),i.far=M+_*100,r.minDistance=_*0.1,r.maxDistance=_*80,i.updateProjectionMatrix(),r.update()},R=new ResizeObserver(()=>{let{clientWidth:b,clientHeight:T}=e;if(!b||!T)return;t.setSize(b,T),i.aspect=b/T,i.updateProjectionMatrix()});R.observe(e);let S=(b)=>{if(p)return;let T=Math.min((b-d)/1000,0.1);if(d=b,h)u?.update(T);r.update(),t.render(n,i),g=requestAnimationFrame(S)};return g=requestAnimationFrame(S),{async load(b){let T=++x;Gh(b);let A=new Hs;A.setURLModifier((C)=>{if(!C.startsWith("blob:")&&!C.startsWith("data:"))throw Error("External model resources are not loaded");return C});let _=await new Eu(A).parseAsync(Uint8Array.from(b).buffer,"");if(p||T!==x){m(_.scene);return}if(l)u?.stopAllAction(),u?.uncacheRoot(l),n.remove(l),m(l);l=_.scene,n.add(l),f=_.animations,u=new Ta(l),h=!0;let{clientWidth:M,clientHeight:F}=e;t.setSize(M,F),i.aspect=M/F,E();let P=0,O=0,K=new Set;return l.traverse((C)=>{let G=C;if(!G.isMesh)return;O++,P+=(G.geometry.index?.count??G.geometry.attributes.position?.count??0)/3*(G.isInstancedMesh?G.count:1);for(let X of Array.isArray(G.material)?G.material:[G.material])K.add(X)}),{triangles:P,meshes:O,materials:K.size,clips:f.map((C)=>C.name)}},reset:E,wire(b){l?.traverse((T)=>{let A=T;if(A.isMesh){for(let _ of Array.isArray(A.material)?A.material:[A.material])if("wireframe"in _)_.wireframe=b}})},lighting(b){t.toneMappingExposure=b==="bright"?1.65:b==="soft"?0.85:1.15,c.intensity=b==="soft"?0.8:2.4},clip(b){if(u?.stopAllAction(),f[b])u?.clipAction(f[b]).play()},pause(b){h=!b},dispose(){if(p=!0,x++,cancelAnimationFrame(g),R.disconnect(),r.dispose(),l)m(l);a.dispose(),t.dispose(),e.replaceChildren()}}}async function qx(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let f=new URL(s);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(f.hostname)))throw Error("Invalid host download URL");return{downloadUrl:f.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var jx=16777216,Kx=Math.ceil(jx/3)*4,Bt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function YA(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function Yx(e){if(typeof e!=="string"||e.length>Kx)return Bt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Bt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Bt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(YA(n)!==e)Bt("contains noncanonical base64 data");return n}function _o(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function Jx(e){if(!_o(e))return Bt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=Bh.safeParse(e.manifest);if(!t.success||!_o(e.files))return Bt("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 Bt("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 Bt("file metadata is missing");if(r+=n.files[c].bytes,r>jx)return Bt("exceeds the decoded size limit");let u=typeof l==="string"?l:_o(l)?l.data:void 0;if(typeof u!=="string")return Bt("file encoding is malformed");if(s+=u.length,s>Kx)return Bt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],f;if(typeof l==="string")f=Yx(l);else{if(!_o(l)||l.encoding!=="kiln.deflate-base64.v1")return Bt("encoding is unsupported");let g=Yx(l.data);try{f=Hx(g,{out:new Uint8Array(u.bytes+1)})}catch{return Bt("compressed data is damaged")}}if(f.length!==u.bytes)return Bt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(f));if(`sha256:${Array.from(new Uint8Array(h),(g)=>g.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Bt("integrity check failed");o[c]=f}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Bt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!_o(e.downloadUrls))return Bt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Bt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Qx(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 Gn=(e)=>document.getElementById(e),ci=Gn("status"),Kt,tv={},xo,jA=0,li=0,pc=new Map;function nv(e,t){let n=++jA;return new Promise((i,r)=>{let s=setTimeout(()=>{pc.delete(n),r(Error("Chat host did not respond."))},20000);pc.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 ev(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function KA(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 JA(e){let t=++li;Kt=void 0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await QA(e,t)}catch(n){if(t!==li)return;ci.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function QA(e,t){if(e.isError){ci.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await Jx(e._meta?.kilnAsset)}catch(i){if(t!==li)return;ci.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==li)return;Kt=n.record,Gn("name").textContent=Kt.manifest.name,tv=n.downloadUrls,Gn("revision").textContent=`${Kt.manifest.editable?"Editable source included":"GLB asset"} · ${Kt.manifest.revisionId.slice(0,10)}`,Gn("attribution").textContent=Qx(Kt.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{xo??=Xx(Gn("stage"));let i=await xo.load(Kt.files["asset.glb"]);if(t!==li)return;if(i){Gn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(Kt.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Gn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}ci.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==li)return;let r=Kt.files["preview.png"];if(r){let s=new Image;s.alt=Kt.manifest.name,s.src=`data:image/png;base64,${KA(r)}`,Gn("stage").replaceChildren(s)}ci.textContent=`3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Gn("source").hidden=!Kt.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=pc.get(t.id);if(pc.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")JA(t.params);if(t.method==="ui/resource-teardown")xo?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Gn("reset").onclick=()=>xo?.reset();Gn("clips").onchange=(e)=>xo?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!Kt)return;let t=li,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?$x([Kt]):Kt.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=Kt.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,ci.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await qx(r,`${o}-${i}`,s,nv,a,tv[i]);if(t!==li)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})},ci.replaceChildren("Download ready. ",l)}else ci.textContent="Download requested."}catch(a){if(t===li)ci.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!Kt||t!==li}};nv("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{ev("ui/notifications/initialized"),ev("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{ci.textContent=e.message});
</script>
</body>
diff --git a/docs/cameras.md b/docs/cameras.md
index abc45fb7..a8eb3bad 100644
--- a/docs/cameras.md
+++ b/docs/cameras.md
@@ -19,6 +19,8 @@ Available layouts are `1x1`, `1x2`, `2x1`, `3x1`, `2x2`, `3x2`, and `3x3`. For c
Kiln uses +X forward, +Y up and +Z right. Azimuth 0 looks from the front (+X), 90 from the right (+Z). Positive elevation looks down. Legacy `zoom` is a padding multiplier: larger values show more surrounding space.
+`backdrop` names the colour behind every cell: `neutral` grey by default, `dark` when a part that merges with the grey is lighter than it, `light` when it is darker. Choose it from a sheet you have seen, not from the brief. It is one of three fixed entries, never a free colour, so two sheets of one asset differ only where the asset does, and every result echoes the one used as `capture.backdrop`. It applies to both capture shapes, on `kiln_render`, `kiln_edit` and `kiln_view_interior`, and `--backdrop` sets it for a CLI `--views` sheet. `kiln_save` and `kiln save --backdrop` take the same id for the preview they store, and the manifest records it as `preview.backdrop`, so a stored preview matches the sheet that was reviewed.
+
## Frame a part or place the camera
The versioned capture format supports up to nine `shots`. Use the exact `parts[].path` or a unique `parts[].name` from a render result. These identify evaluated scene nodes, whose names can include generated prefixes. Duplicate names require a path.
diff --git a/docs/tools.md b/docs/tools.md
index 0f6dc5a1..f7166c5c 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -329,6 +329,15 @@ Build a program and return geometry metrics, exact part paths and images. Omit c
"grid",
"separate"
]
+ },
+ "backdrop": {
+ "description": "Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"required": [
@@ -382,6 +391,15 @@ Build a program and return geometry metrics, exact part paths and images. Omit c
],
"additionalProperties": false
}
+ },
+ "backdrop": {
+ "description": "Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"additionalProperties": false
@@ -864,6 +882,15 @@ Render roof-off floor-plan, dollhouse, and eye-level cutaway views. Optional ver
"grid",
"separate"
]
+ },
+ "backdrop": {
+ "description": "Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"required": [
@@ -1451,6 +1478,15 @@ Apply exact-string replacements to a program revision and render the result (ren
"grid",
"separate"
]
+ },
+ "backdrop": {
+ "description": "Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"required": [
@@ -1504,6 +1540,15 @@ Apply exact-string replacements to a program revision and render the result (ren
],
"additionalProperties": false
}
+ },
+ "backdrop": {
+ "description": "Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"additionalProperties": false
@@ -1581,7 +1626,7 @@ Read a saved program revision without changing it. Returns exact source text in
## kiln_save
-Save a completed source revision into the user-requested collection, or project when no destination was requested. Persists its exact GLB, source, preview, and build record. Discover destinations with kiln_assets action=collections. Use programRef returned by render/edit. To revise an existing asset, supply its assetId and parentRevision; previous revisions remain intact. Returns downloadable resources. Draft renders do not populate collections.
+Save a completed source revision into the user-requested collection, or project when none was requested. Persists exact GLB, source, preview and build record. Use programRef returned by render/edit. To revise an asset, pass assetId and parentRevision; earlier revisions stay intact. Returns downloadable resources; draft renders never populate collections.
<details>
<summary>Input JSON Schema</summary>
@@ -1647,6 +1692,15 @@ Save a completed source revision into the user-requested collection, or project
}
},
"additionalProperties": false
+ },
+ "backdrop": {
+ "description": "Preview backdrop: the one the reviewed sheet used.",
+ "type": "string",
+ "enum": [
+ "neutral",
+ "dark",
+ "light"
+ ]
}
},
"required": [
diff --git a/render-service/README.md b/render-service/README.md
index 6c192c04..f33991d6 100644
--- a/render-service/README.md
+++ b/render-service/README.md
@@ -49,8 +49,8 @@ will not start, never one that quietly renders on CPU while reporting success.
| Route | Body | Returns |
|---|---|---|
| `GET /health` | -- | `{ok, rendererId, backend, adapter, capabilities, presentationProfile, lightingPresetIds}` |
-| `POST /render` (legacy) | `{glb_base64, size?=384, views?, beauty_size?, background?}` | `{ok, rendererId, presentationProfile, timings, views[base64 png], beauty?}` |
-| `POST /render` (camera) | `{glb_base64, cameras, width, height, lighting_preset_id?}` | the above plus `{backend, cameras, width, height, lightingPresetId, viewSha256, outputSetSha256, cameraReceipts}` |
+| `POST /render` (legacy) | `{glb_base64, size?=384, views?, beauty_size?, backdrop?}` | `{ok, rendererId, presentationProfile, timings, views[base64 png], beauty?}` |
+| `POST /render` (camera) | `{glb_base64, cameras, width, height, lighting_preset_id?, backdrop?}` | the above plus `{backend, cameras, width, height, lightingPresetId, viewSha256, outputSetSha256, cameraReceipts}` |
| `POST /bake` | -- | 501 |
Auth, when `RENDER_SERVICE_TOKEN` is set, is the `x-render-token` header -- **not** `Authorization`,
@@ -71,6 +71,14 @@ Camera mode is additive and exact: 1-12 perspective cameras with `position`, `ta
exclusive with `views`, `size`, and `beauty_size`. The only lighting identity is `neutral-studio-v1`;
`/health.lightingPresetIds` advertises the registry.
+`backdrop` names one of `neutral`, `dark` or `light` from `src/backdrops.mjs`, the same table the
+engine's CPU rasterizer paints from, and is accepted in both modes; omitted means `neutral`. The
+backdrop is cleared into the HDR framebuffer and tone-mapped with the asset, so the service sets it
+as the linear colour that comes out of the output pass as exactly the table's bytes
+(`src/display-transform.mjs`), and a GPU sheet and a CPU sheet agree pixel for pixel on it. The old
+free-hex `background` field is rejected in both modes: a colour the engine would not also paint
+breaks the agreement the named table exists for.
+
## Docker
```bash
diff --git a/render-service/package.json b/render-service/package.json
index c0bc43be..538be878 100644
--- a/render-service/package.json
+++ b/render-service/package.json
@@ -6,7 +6,7 @@
"description": "GLB in, PBR PNG views out. Dawn/WebGPU + three.js, headless. No Kiln engine coupling.",
"scripts": {
"start": "node --import ./src/register-hooks.mjs src/server.mjs",
- "test": "node --test test/bind-policy.test.mjs test/beauty-camera.test.mjs test/display-output.test.mjs test/readback.test.mjs test/cache-identity.test.mjs test/asset-camera.test.mjs test/contract.test.mjs test/framing.test.mjs test/material-fixture.test.mjs test/presentation-presets.test.mjs test/gallery-presentation.test.mjs",
+ "test": "node --test test/bind-policy.test.mjs test/beauty-camera.test.mjs test/display-output.test.mjs test/readback.test.mjs test/cache-identity.test.mjs test/asset-camera.test.mjs test/contract.test.mjs test/framing.test.mjs test/material-fixture.test.mjs test/presentation-presets.test.mjs test/gallery-presentation.test.mjs test/display-transform.test.mjs",
"smoke": "node --import ./src/register-hooks.mjs test/smoke.mjs",
"conformance:display": "node --import ./src/register-hooks.mjs test/display-output-conformance.mjs",
"conformance:material": "node --import ./src/register-hooks.mjs test/material-conformance.mjs"
diff --git a/render-service/src/backdrops.mjs b/render-service/src/backdrops.mjs
new file mode 100644
index 00000000..2eef570c
--- /dev/null
+++ b/render-service/src/backdrops.mjs
@@ -0,0 +1,26 @@
+/**
+ * The named backdrops a render request may ask for, mirrored from the engine's
+ * `src/views/background.ts`. The engine's `backdrop.test.ts` asserts the two
+ * tables agree, so a change here without the matching engine change fails the
+ * engine suite rather than shipping two producers that disagree.
+ *
+ * A request that names no backdrop gets `neutral`. The renderer clears to the
+ * linear colour that its display transform turns into exactly these bytes
+ * (`display-transform.mjs`), so a sheet rendered here and a CPU fallback sheet
+ * share the backdrop pixel for pixel.
+ */
+export const BACKDROP_IDS = Object.freeze(['neutral', 'dark', 'light']);
+export const DEFAULT_BACKDROP_ID = 'neutral';
+export const BACKDROP_HEX = Object.freeze({
+ neutral: '#aab1bc',
+ dark: '#1a1a1a',
+ light: '#dfe3e8',
+});
+
+export function isBackdropId(value) {
+ return typeof value === 'string' && BACKDROP_IDS.includes(value);
+}
+
+export function backdropMessage(field) {
+ return `${field} must be one of: ${BACKDROP_IDS.join(', ')}`;
+}
diff --git a/render-service/src/contract.mjs b/render-service/src/contract.mjs
index cb974ced..5636711a 100644
--- a/render-service/src/contract.mjs
+++ b/render-service/src/contract.mjs
@@ -4,6 +4,7 @@ import {
PRESENTATION_PRESET_IDS,
isPresentationPresetId,
} from './presentation-presets.mjs';
+import { DEFAULT_BACKDROP_ID, backdropMessage, isBackdropId } from './backdrops.mjs';
// Singular export retained for existing Engine/Studio callers. The plural list
// is the registry-backed source of truth for strict ID validation and discovery.
@@ -326,13 +327,16 @@ export function validateRenderMode(body) {
if (!body || typeof body !== 'object' || Array.isArray(body)) {
throw badRequest('render body must be an object');
}
+ // The legacy free-hex `background` is gone from both modes: a colour the
+ // engine's CPU rasterizer would not also paint breaks the agreement the named
+ // backdrop table exists for. Both modes take `backdrop`; omitted is neutral.
+ if (body.background !== undefined) {
+ throw badRequest('background is not accepted; name a backdrop instead: neutral, dark, light');
+ }
if (body.cameras !== undefined) {
if (body.views !== undefined || body.size !== undefined || body.beauty_size !== undefined) {
throw badRequest('camera mode is mutually exclusive with views, size, and beauty_size');
}
- if (body.background !== undefined) {
- throw badRequest('camera mode cannot override the neutral-studio-v1 background');
- }
const allowed = new Set([
'glb_base64',
'input_glb_sha256',
@@ -340,6 +344,7 @@ export function validateRenderMode(body) {
'width',
'height',
'lighting_preset_id',
+ 'backdrop',
]);
for (const key of Object.keys(body)) {
if (body[key] !== undefined && !allowed.has(key)) {
@@ -352,7 +357,7 @@ export function validateRenderMode(body) {
height: body.height,
lightingPresetId: body.lighting_preset_id,
});
- return { mode: 'camera', ...camera };
+ return { mode: 'camera', ...camera, backdrop: validateBackdrop(body.backdrop) };
}
if (
body.width !== undefined ||
@@ -366,10 +371,21 @@ export function validateRenderMode(body) {
viewDirs: validateViewDirs(body.views),
size: body.size,
beautySize: body.beauty_size,
- background: body.background,
+ backdrop: validateBackdrop(body.backdrop),
};
}
+/**
+ * A named backdrop from the shared table, accepted in both modes. It cannot name
+ * a colour the engine's CPU rasterizer would not also paint, so it is safe in
+ * exact camera mode too. Omitted means the neutral entry.
+ */
+function validateBackdrop(value) {
+ if (value === undefined) return DEFAULT_BACKDROP_ID;
+ if (!isBackdropId(value)) throw badRequest(backdropMessage('backdrop'));
+ return value;
+}
+
export function sha256(bytes) {
return `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
}
diff --git a/render-service/src/display-transform.mjs b/render-service/src/display-transform.mjs
new file mode 100644
index 00000000..483f58df
--- /dev/null
+++ b/render-service/src/display-transform.mjs
@@ -0,0 +1,138 @@
+/**
+ * The display transform the renderer applies to every HDR pixel, and its inverse.
+ *
+ * `renderDisplayTarget` draws into three's HalfFloat framebuffer and then runs
+ * the output pass: ACES filmic tone mapping at the preset's exposure, then the
+ * sRGB transfer function. The scene background is cleared into that framebuffer
+ * like any other pixel, so a backdrop set as a plain colour came out of the pass
+ * shifted -- the neutral `#aab1bc` read back as (203, 207, 213) -- while the
+ * engine's CPU rasterizer paints the table value exactly. Compositing the
+ * backdrop after the pass instead would leave a one-pixel fringe on every
+ * silhouette, because multisampled edges resolve to premultiplied colour before
+ * tone mapping. So the backdrop stays inside the pass, and this module answers
+ * "which linear clear colour comes out as exactly that byte triple".
+ *
+ * The forward transform is a port of three r185's `acesFilmicToneMapping` and
+ * `sRGBTransferOETF`, with the matrices read row-major; it reproduces pixels
+ * measured on a dawn-d3d12 device to within rounding. The inverse is analytic:
+ * both matrices invert, and the RRT/ODT fit is a rational function whose inverse
+ * is one quadratic per channel. Every answer is checked through the forward
+ * transform before it is returned, so drift in either direction is an error
+ * here rather than a quietly wrong backdrop.
+ */
+
+// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
+const ACES_INPUT = Object.freeze([
+ 0.59719, 0.35458, 0.04823, 0.076, 0.90834, 0.01566, 0.0284, 0.13383, 0.83777,
+]);
+// ODT_SAT => XYZ => D60_2_D65 => sRGB
+const ACES_OUTPUT = Object.freeze([
+ 1.60475, -0.53108, -0.07367, -0.10208, 1.10813, -0.00605, -0.00327, -0.07276, 1.07602,
+]);
+const FIT = Object.freeze({ a: 0.0245786, b: 0.000090537, c: 0.983729, d: 0.432951, e: 0.238081 });
+
+function multiply(m, v) {
+ return [0, 1, 2].map((row) => m[row * 3] * v[0] + m[row * 3 + 1] * v[1] + m[row * 3 + 2] * v[2]);
+}
+
+function invert(m) {
+ const [a, b, c, d, e, f, g, h, i] = m;
+ const A = e * i - f * h;
+ const B = -(d * i - f * g);
+ const C = d * h - e * g;
+ const det = a * A + b * B + c * C;
+ if (!det) throw new Error('display transform matrix is singular');
+ return [
+ A / det,
+ -(b * i - c * h) / det,
+ (b * f - c * e) / det,
+ B / det,
+ (a * i - c * g) / det,
+ -(a * f - c * d) / det,
+ C / det,
+ -(a * h - b * g) / det,
+ (a * e - b * d) / det,
+ ];
+}
+
+const ACES_INPUT_INVERSE = Object.freeze(invert(ACES_INPUT));
+const ACES_OUTPUT_INVERSE = Object.freeze(invert(ACES_OUTPUT));
+
+const rrtOdtFit = (x) => (x * (x + FIT.a) - FIT.b) / (x * (x + FIT.d) * FIT.c + FIT.e);
+
+/** The non-negative root of `rrtOdtFit(x) = t`; the fit is monotonic there. */
+function rrtOdtFitInverse(t) {
+ // (1 - c t) x^2 + (a - c d t) x - (b + e t) = 0
+ const qa = 1 - FIT.c * t;
+ const qb = FIT.a - FIT.c * FIT.d * t;
+ const qc = -(FIT.b + FIT.e * t);
+ if (qa <= 0) return Number.POSITIVE_INFINITY;
+ return (-qb + Math.sqrt(qb * qb - 4 * qa * qc)) / (2 * qa);
+}
+
+/** three's `sRGBTransferOETF`, including its 0.41666 exponent. */
+export function srgbEncode(c) {
+ return c <= 0.0031308 ? c * 12.92 : 1.055 * c ** 0.41666 - 0.055;
+}
+
+export function srgbDecode(e) {
+ return e <= 0.04045 ? e / 12.92 : ((e + 0.055) / 1.055) ** (1 / 0.41666);
+}
+
+/** ACES filmic tone mapping of a linear working-space colour, clamped to [0, 1]. */
+export function toneMap(linear, exposure) {
+ const scaled = linear.map((c) => (c * exposure) / 0.6);
+ const fitted = multiply(ACES_INPUT, scaled).map(rrtOdtFit);
+ return multiply(ACES_OUTPUT, fitted).map((c) => Math.min(1, Math.max(0, c)));
+}
+
+/** The byte triple a linear colour reads back as after the output pass. */
+export function displayBytes(linear, exposure) {
+ return toneMap(linear, exposure).map((c) => Math.round(srgbEncode(c) * 255));
+}
+
+function assertExposure(exposure) {
+ if (!Number.isFinite(exposure) || exposure <= 0)
+ throw new Error(`exposure must be a positive number (got ${exposure})`);
+}
+
+/**
+ * The linear colour that reads back as exactly `bytes` at `exposure`, or an
+ * error when the tone mapping cannot reach it (saturated colours leave the
+ * gamut on the way back through the matrices).
+ */
+export function linearForDisplayBytes(bytes, exposure) {
+ assertExposure(exposure);
+ if (
+ !Array.isArray(bytes) ||
+ bytes.length !== 3 ||
+ !bytes.every((b) => Number.isInteger(b) && b >= 0 && b <= 255)
+ )
+ throw new Error(
+ `display bytes must be three integers in 0..255 (got ${JSON.stringify(bytes)})`,
+ );
+ const display = bytes.map((b) => srgbDecode(b / 255));
+ const fitted = multiply(ACES_OUTPUT_INVERSE, display).map(rrtOdtFitInverse);
+ const linear = multiply(ACES_INPUT_INVERSE, fitted).map((c) => (c * 0.6) / exposure);
+ const reached = displayBytes(linear, exposure);
+ if (
+ linear.some((c) => !Number.isFinite(c) || c < 0) ||
+ reached.some((c, index) => c !== bytes[index])
+ ) {
+ throw new Error(
+ `display colour ${JSON.stringify(bytes)} is not reachable through the tone mapping at exposure ${exposure}`,
+ );
+ }
+ return linear;
+}
+
+export function hexToBytes(hex) {
+ if (typeof hex !== 'string' || !/^#[0-9a-f]{6}$/.test(hex))
+ throw new Error(`expected a lowercase #rrggbb hex colour (got ${JSON.stringify(hex)})`);
+ return [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
+}
+
+/** The linear clear colour that makes a backdrop read back as its own hex. */
+export function backdropClearColor(hex, exposure) {
+ return linearForDisplayBytes(hexToBytes(hex), exposure);
+}
diff --git a/render-service/src/presentation-presets.mjs b/render-service/src/presentation-presets.mjs
index fec67bec..8a414f46 100644
--- a/render-service/src/presentation-presets.mjs
+++ b/render-service/src/presentation-presets.mjs
@@ -4,7 +4,6 @@
const PRESET_KEYS = Object.freeze([
'id',
'environment',
- 'background',
'exposure',
'ambient',
'sun',
@@ -89,9 +88,6 @@ function validatePreset(preset) {
if (preset.environment.type !== 'room')
throw new TypeError(`${preset.id}.environment.type must be room`);
finite(preset.environment.sigma, `${preset.id}.environment.sigma`, { minimum: 0 });
- if (!/^#[0-9a-f]{6}$/.test(preset.background)) {
- throw new TypeError(`${preset.id}.background must be lowercase #rrggbb`);
- }
finite(preset.exposure, `${preset.id}.exposure`, { minimum: 0 });
exactKeys(preset.ambient, ['type', 'sky', 'ground', 'intensity'], `${preset.id}.ambient`);
if (preset.ambient.type !== 'hemisphere')
@@ -130,7 +126,6 @@ const definitions = [
validatePreset({
id: 'neutral-studio-v1',
environment: { type: 'room', sigma: 0.04 },
- background: '#aab1bc',
exposure: 1.38,
ambient: { type: 'hemisphere', sky: 0xffffff, ground: 0x6f7888, intensity: 2 },
// The v1 studio rig has no separate sun. Retaining this explicit disabled
@@ -170,7 +165,6 @@ definitions.push(
...definitions[0],
id: 'gallery-studio-v1',
exposure: 0.9,
- background: '#747474',
}),
);
diff --git a/render-service/src/renderer.mjs b/render-service/src/renderer.mjs
index 8d2b71ad..088386d1 100644
--- a/render-service/src/renderer.mjs
+++ b/render-service/src/renderer.mjs
@@ -18,6 +18,8 @@ import {
SHADOW_FILTERS,
getPresentationPreset,
} from './presentation-presets.mjs';
+import { BACKDROP_HEX } from './backdrops.mjs';
+import { backdropClearColor } from './display-transform.mjs';
export { MAX_VIEW_DIRS, validateViewDirs } from './contract.mjs';
import { beautyCameraSpec, orthoDepth, orthoHalfExtent } from './framing.mjs';
@@ -48,7 +50,6 @@ export const PRESENTATION_PROFILE_ID = DEFAULT_PRESENTATION_PRESET_ID;
const defaultPresentation = getPresentationPreset(PRESENTATION_PROFILE_ID);
// Compatibility exports retain their exact shapes/values while the renderer
// itself now consumes the registry definition below.
-export const PRESENTATION_BACKGROUND = defaultPresentation.background;
export const PRESENTATION_EXPOSURE = defaultPresentation.exposure;
export const PRESENTATION_LIGHTS = Object.freeze({
hemisphere: Object.freeze({
@@ -221,11 +222,18 @@ for (const name of SHADOW_FILTERS) {
}
}
-function applyPresentationPreset(renderer, scene, root, preset, environment) {
+function applyPresentationPreset(renderer, scene, root, preset, environment, backdrop) {
renderer.toneMappingExposure = preset.exposure;
renderer.shadowMap.enabled = preset.shadows.enabled;
if (preset.shadows.enabled) renderer.shadowMap.type = SHADOW_MAP_TYPES[preset.shadows.type];
- scene.background = new THREE.Color(preset.background);
+ // The backdrop is cleared into the HDR framebuffer and tone-mapped with the
+ // asset, so it is set as the linear colour that comes out of that pass as
+ // exactly the table's bytes -- the value the CPU rasterizer paints. Reflections
+ // come from `environment`, never from the backdrop.
+ scene.background = new THREE.Color().setRGB(
+ ...backdropClearColor(BACKDROP_HEX[backdrop], preset.exposure),
+ THREE.LinearSRGBColorSpace,
+ );
scene.environment = environment;
const ambient = preset.ambient;
@@ -303,7 +311,7 @@ async function readPng(renderer, rt, w, h) {
/**
* Render a GLB into PNG views.
* @param {Buffer} glbBytes
- * @param {{size?: number, viewDirs?: number[][], beautySize?: number, background?: string,
+ * @param {{size?: number, viewDirs?: number[][], beautySize?: number, backdrop?: string,
* cameras?: object[], width?: number, height?: number, lightingPresetId?: string}} opts
* @returns {Promise<{views: Buffer[], beauty: Buffer|null, timings: object,
* cameras?: object[], width?: number, height?: number, lightingPresetId?: string}>}
@@ -318,7 +326,7 @@ export async function renderGlb(glbBytes, opts = {}) {
views: opts.viewDirs,
size: opts.size,
beauty_size: opts.beautySize,
- background: opts.background,
+ backdrop: opts.backdrop,
});
// Snapped, not clamped: pooled render targets are keyed by size and never
// evicted, so an unbounded key space is a caller-controlled VRAM leak. The
@@ -350,12 +358,8 @@ export async function renderGlb(glbBytes, opts = {}) {
gltf.scene,
presentation,
environments.get(presentationPresetId),
+ renderMode.backdrop,
);
- // Legacy callers retain their historical escape hatch. Exact camera mode is
- // preset-ID-only and validateRenderMode rejects a background field.
- if (renderMode.mode === 'legacy' && opts.background !== undefined) {
- scene.background = new THREE.Color(opts.background);
- }
scene.add(gltf.scene);
if (renderMode.mode === 'camera') {
diff --git a/render-service/src/server.mjs b/render-service/src/server.mjs
index 3d7d2f70..8481e572 100644
--- a/render-service/src/server.mjs
+++ b/render-service/src/server.mjs
@@ -2,9 +2,9 @@
// GET /health, /ping -> 200 {ok, rendererId, adapter, capabilities, authRequired}
// (never 503: a software or absent adapter aborts boot below,
// so a listening server always implies a hardware adapter)
-// POST /render legacy: {glb_base64, input_glb_sha256?, size?, views?, beauty_size?, background?}
+// POST /render legacy: {glb_base64, input_glb_sha256?, size?, views?, beauty_size?, backdrop?}
// POST /render camera: {glb_base64, input_glb_sha256?, cameras, width, height,
-// lighting_preset_id?}
+// lighting_preset_id?, backdrop?}
// -> 200 legacy response unchanged, or exact camera
// receipt metadata + ordered output identities
// (`input_glb_sha256` opts into an additive,
@@ -236,13 +236,13 @@ const server = createServer(async (req, res) => {
width: renderMode.width,
height: renderMode.height,
lightingPresetId: renderMode.lightingPresetId,
- background: renderMode.background,
+ backdrop: renderMode.backdrop,
}
: {
size: renderMode.size,
viewDirs: renderMode.viewDirs,
beautySize: renderMode.beautySize,
- background: renderMode.background,
+ backdrop: renderMode.backdrop,
},
),
};
diff --git a/render-service/test/contract.test.mjs b/render-service/test/contract.test.mjs
index e36d2997..4c78c0f2 100644
--- a/render-service/test/contract.test.mjs
+++ b/render-service/test/contract.test.mjs
@@ -74,6 +74,7 @@ describe('provider-free render contract', () => {
height: 720,
lightingPresetId: SUPPORTED_LIGHTING_PRESET_ID,
totalPixels: 1280 * 720,
+ backdrop: 'neutral',
});
assert.notEqual(parsed.cameras, body.cameras);
assert.notEqual(parsed.cameras[0].position, body.cameras[0].position);
@@ -95,9 +96,21 @@ describe('provider-free render contract', () => {
throws400(() => validateRenderMode({ ...exactBody(), ...legacy }), /mutually exclusive/);
}
throws400(() => validateRenderMode({ ...exactBody(), mystery_option: true }), /unknown/);
+ // A free colour is refused in both modes; a named backdrop is accepted in
+ // both, and omitting it means the neutral entry.
+ throws400(() => validateRenderMode({ ...exactBody(), background: '#000000' }), /backdrop/);
+ throws400(() => validateRenderMode({ views: [[1, 0, 0]], background: '#000000' }), /backdrop/);
+ assert.equal(validateRenderMode({ ...exactBody(), backdrop: 'dark' }).backdrop, 'dark');
+ assert.equal(validateRenderMode(exactBody()).backdrop, 'neutral');
+ assert.equal(validateRenderMode({ views: [[1, 0, 0]] }).backdrop, 'neutral');
throws400(
- () => validateRenderMode({ ...exactBody(), background: '#000000' }),
- /cannot override/,
+ () => validateRenderMode({ ...exactBody(), backdrop: '#1a1a1a' }),
+ /neutral, dark, light/,
+ );
+ assert.equal(validateRenderMode({ views: [[1, 0, 0]], backdrop: 'light' }).backdrop, 'light');
+ throws400(
+ () => validateRenderMode({ views: [[1, 0, 0]], backdrop: 'pink' }),
+ /neutral, dark, light/,
);
for (const cameraOnly of [
{ width: 1 },
diff --git a/render-service/test/display-transform.test.mjs b/render-service/test/display-transform.test.mjs
new file mode 100644
index 00000000..cb988b9f
--- /dev/null
+++ b/render-service/test/display-transform.test.mjs
@@ -0,0 +1,58 @@
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { BACKDROP_HEX, BACKDROP_IDS } from '../src/backdrops.mjs';
+import {
+ backdropClearColor,
+ displayBytes,
+ hexToBytes,
+ linearForDisplayBytes,
+ srgbDecode,
+} from '../src/display-transform.mjs';
+import { PRESENTATION_PRESET_IDS, getPresentationPreset } from '../src/presentation-presets.mjs';
+
+test('the forward transform reproduces pixels measured on the GPU', () => {
+ // Read back from a dawn-d3d12 device at the studio exposure of 1.38, when the
+ // backdrop was still cleared as a plain colour. This is the calibration that
+ // says the port is the transform the output pass really applies.
+ for (const [hex, measured] of [
+ ['#aab1bc', [203, 207, 213]],
+ ['#1a1a1a', [14, 14, 14]],
+ ['#dfe3e8', [227, 228, 230]],
+ ]) {
+ const linear = hexToBytes(hex).map((byte) => srgbDecode(byte / 255));
+ assert.deepEqual(displayBytes(linear, 1.38), measured, hex);
+ }
+});
+
+test('every backdrop reads back as its own table bytes at every preset exposure', () => {
+ for (const id of PRESENTATION_PRESET_IDS) {
+ const { exposure } = getPresentationPreset(id);
+ for (const backdrop of BACKDROP_IDS) {
+ const hex = BACKDROP_HEX[backdrop];
+ const clear = backdropClearColor(hex, exposure);
+ // A clear above 1.0 is fine: the framebuffer is HalfFloat, and a lower
+ // exposure needs a brighter scene value to reach the same byte.
+ assert.ok(
+ clear.every((c) => c >= 0),
+ `${backdrop} at ${id}: ${clear}`,
+ );
+ assert.deepEqual(displayBytes(clear, exposure), hexToBytes(hex), `${backdrop} at ${id}`);
+ }
+ }
+});
+
+test('the inverse is exact for every grey at any exposure', () => {
+ for (const exposure of [0.9, 1.38, 2.5]) {
+ for (let grey = 0; grey <= 255; grey++) {
+ const bytes = [grey, grey, grey];
+ assert.deepEqual(displayBytes(linearForDisplayBytes(bytes, exposure), exposure), bytes);
+ }
+ }
+});
+
+test('refuses what the tone mapping cannot reach and what it cannot parse', () => {
+ assert.throws(() => linearForDisplayBytes([255, 0, 0], 1.38), /not reachable/);
+ assert.throws(() => linearForDisplayBytes([170, 177], 1.38), /three integers/);
+ assert.throws(() => backdropClearColor('#aab1bc', 0), /exposure/);
+ assert.throws(() => backdropClearColor('aab1bc', 1.38), /hex/);
+});
diff --git a/render-service/test/gallery-presentation.test.mjs b/render-service/test/gallery-presentation.test.mjs
index 2301b6f3..28b58c59 100644
--- a/render-service/test/gallery-presentation.test.mjs
+++ b/render-service/test/gallery-presentation.test.mjs
@@ -4,7 +4,7 @@ import {
getPresentationPreset,
DEFAULT_PRESENTATION_PRESET_ID,
} from '../src/presentation-presets.mjs';
-test('gallery profile changes gallery exposure and backdrop and leaves default studio unchanged', () => {
+test('gallery profile changes only the exposure and leaves default studio unchanged', () => {
const original = getPresentationPreset('neutral-studio-v1');
const gallery = getPresentationPreset('gallery-studio-v1');
assert.ok(gallery, 'gallery profile must be selectable');
@@ -14,7 +14,6 @@ test('gallery profile changes gallery exposure and backdrop and leaves default s
...original,
id: 'gallery-studio-v1',
exposure: 0.9,
- background: '#747474',
});
assert.ok(Object.isFrozen(gallery));
});
diff --git a/render-service/test/presentation-presets.test.mjs b/render-service/test/presentation-presets.test.mjs
index 13ad6701..766f1925 100644
--- a/render-service/test/presentation-presets.test.mjs
+++ b/render-service/test/presentation-presets.test.mjs
@@ -43,7 +43,6 @@ describe('versioned presentation preset registry', () => {
assert.deepEqual(getPresentationPreset('neutral-studio-v1'), {
id: 'neutral-studio-v1',
environment: { type: 'room', sigma: 0.04 },
- background: '#aab1bc',
exposure: 1.38,
ambient: { type: 'hemisphere', sky: 0xffffff, ground: 0x6f7888, intensity: 2 },
sun: { enabled: false },
diff --git a/skills/kiln-author-asset/SKILL.md b/skills/kiln-author-asset/SKILL.md
index f4fff021..d8ad216c 100644
--- a/skills/kiln-author-asset/SKILL.md
+++ b/skills/kiln-author-asset/SKILL.md
@@ -22,7 +22,7 @@ Submit `code` once to `kiln_render` or `kiln_validate`, then retain its `program
Choose views that answer a question. A broad sheet can establish shape; a part-local view can reveal a seam, underside, or hidden attachment. Use the [camera recipes](references/camera-recipes.md) for image count, exact part framing, explicit cameras, and separate images. Read returned part paths instead of constructing them.
-Inspect the actual images. Check silhouette, proportion, orientation, attachment, and ground contact. If the request calls for a finished asset, repair concrete gaps visible at its intended viewing distance rather than stopping at a blockout. Do not repeat the same render without a new question or change.
+Inspect the actual images. Render on the default neutral grey backdrop first. Only when a sheet you have seen shows a part merging with it, add `backdrop` to `capture`: `light` when the merging part is darker than the grey (near-black iron, dark wood), `dark` when it is lighter (near-white, pale grey, emissive). Read the echoed `capture.backdrop`. Check silhouette, proportion, orientation, attachment, and ground contact. If the request calls for a finished asset, repair concrete gaps visible at its intended viewing distance rather than stopping at a blockout. Do not repeat the same render without a new question or change.
`viewFidelity.materialFaithful: false` means geometry evidence, not verified PBR appearance. Check camera/fallback receipts too. A GPU connection alone is not evidence that the requested view was used. Animation needs intermediate-pose review; interiors may need cutaway views.
@@ -32,7 +32,7 @@ Read the [export profile guide](references/export-profiles.md) when choosing del
Read a bounded source region with `kiln_source({ programRef, query: "dimensionOrPart" })`. Copy an exact anchor into `kiln_edit`, batch related replacements, and continue with its new `programRef`. Rendering is on by default; `capture` can keep the relevant framing. An applied edit can still fail to build, so inspect `render.ok` separately.
-When the collection tools are available, use them for delivery. A finished asset is not delivered until its accepted final reference is saved. The user chooses the destination when they name one. Call `kiln_assets({ action: "collections" })` to resolve available IDs when more than one collection is configured or the request mentions a destination. Use `project` only as the fallback when the user gave no destination; use `library` for an explicitly requested cross-workspace library. Then call `kiln_save({ programRef, name, collection, brief, description, attribution: { model, harness } })`. Record the actual model and harness when known, and omit unknown attribution rather than guessing. Saving creates the durable asset record and returns the asset ID, revision ID, and download resources for its exact GLB, source, preview, and ZIP bundle. Return those links to the user using the host's resource/download interface; do not transcribe binary data.
+When the collection tools are available, use them for delivery. A finished asset is not delivered until its accepted final reference is saved. The user chooses the destination when they name one. Call `kiln_assets({ action: "collections" })` to resolve available IDs when more than one collection is configured or the request mentions a destination. Use `project` only as the fallback when the user gave no destination; use `library` for an explicitly requested cross-workspace library. Then call `kiln_save({ programRef, name, collection, brief, description, attribution: { model, harness } })`. If the sheet you accepted used a `backdrop` other than the default, pass the same `backdrop` so the saved preview matches what you reviewed. Record the actual model and harness when known, and omit unknown attribution rather than guessing. Saving creates the durable asset record and returns the asset ID, revision ID, and download resources for its exact GLB, source, preview, and ZIP bundle. Return those links to the user using the host's resource/download interface; do not transcribe binary data.
After saving, call `kiln_present` when available with the exact collection, asset ID, and revision ID. If the host confirms it rendered the interactive result, the handoff is complete. If the user wants to see the asset, the host only returns portable links, and you have a terminal, launch `node kiln.mjs view --collection COLLECTION --asset ASSET_ID --revision REVISION_ID` yourself in a persistent or background terminal from the asset workspace. Substitute the exact values returned by `kiln_save`, give the user the printed loopback URL, and use the harness's browser-opening capability when one exists. Do not ask the user to start the viewer unless the host gives you neither presentation nor process-launch capability. The deep link opens that exact revision in the same local viewer with orbit, zoom, revision history, animation, and downloads. Use returned download URLs when provided; never invent HTTPS URLs or claim that a host supports native attachments without evidence. A `kiln://` resource may require the host's resource reader or local viewer.
@@ -45,6 +45,6 @@ node kiln.mjs render RETURNED_REF --out asset-v1.glb --views asset-v1.png
Replace `RETURNED_REF` with the final reference returned by Kiln. Keep `.kiln/programs`, including its mappings, while using saved references.
-To save a chosen camera view, write the `capture` object itself to `cameras.json` and run `node kiln.mjs render RETURNED_REF --capture cameras.json --views hero.png`. This uses the same camera schema and render pipeline as MCP. CLI image export supports grid output; use one shot for a single hero PNG. Do not copy image base64 into shell commands. The [camera recipes](references/camera-recipes.md) include a complete file example.
+To save a chosen camera view, write the `capture` object itself to `cameras.json` and run `node kiln.mjs render RETURNED_REF --capture cameras.json --views hero.png`. This uses the same camera schema and render pipeline as MCP. CLI image export supports grid output; use one shot for a single hero PNG. Add `--backdrop light` or `--backdrop dark` to any `--views` command when the neutral grey hides the silhouette. Do not copy image base64 into shell commands. The [camera recipes](references/camera-recipes.md) include a complete file example.
Source export refuses to overwrite a file. Report the source and GLB, important design choices, what you reviewed, and any unresolved limitation. Validation does not establish visual quality or destination-runtime performance. There is no default triangle target; measure geometry, draw calls, textures, and loading against the user's actual constraints.
diff --git a/skills/kiln-author-asset/references/camera-recipes.md b/skills/kiln-author-asset/references/camera-recipes.md
index 441cfcc1..3d55b4cd 100644
--- a/skills/kiln-author-asset/references/camera-recipes.md
+++ b/skills/kiln-author-asset/references/camera-recipes.md
@@ -33,6 +33,8 @@ kiln_render({ programRef: REF, capture: {
Versioned capture accepts 1–9 shots, 1–3 columns, and a square per-shot `size` from 128–1024. It does not accept `width`/`height`; those are returned dimensions. Set `output: 'separate'` when individual images better fit the harness. `visibility: 'isolate'` hides everything outside the selected subtree; context remains visible by default. Orbit `relativeTo` is `world`, `asset`, or `part`. Orbit cameras derive their target and distance from the selected subject bounds, so they accept `subject` and `padding`, not `target` or `distance`. Use an explicit camera when you need `position` and `target`.
+`backdrop` selects the colour behind every cell: `neutral` grey by default, `dark` when a part that merges with the grey is lighter than it (near-white, pale grey, emissive), `light` when it is darker (near-black, dark wood). Choose it from a sheet you have seen, not from the brief: render on the default first and switch only when a silhouette merges with it. It is a fixed choice, not a free colour, and the result echoes it as `capture.backdrop`. Legacy `preset`/`cells` sheets accept it too.
+
The same capture object can accompany `kiln_edit` so the edited result answers the same visual question. It is a render request, not a source change.
## Explicit framing
@@ -91,4 +93,5 @@ It writes PNG bytes directly; there is no need to copy image base64. `--capture`
requires `--views`, accepts JSON up to 1 MiB, and supports grid output only. A single
shot is one image; multiple shots share the grid. For separate files, export one
single-shot recipe per requested file. MCP still supports `output: "separate"` for
-image blocks delivered to the agent.
+image blocks delivered to the agent. `--backdrop neutral|dark|light` sets the backdrop of
+any `--views` sheet, with or without `--capture`, and wins over the recipe's own `backdrop`.
diff --git a/skills/kiln-qa-asset/SKILL.md b/skills/kiln-qa-asset/SKILL.md
index e1c72111..4743a9a1 100644
--- a/skills/kiln-qa-asset/SKILL.md
+++ b/skills/kiln-qa-asset/SKILL.md
@@ -16,7 +16,7 @@ Read validation/build findings and export warnings. `kiln_validate` only checks
Distinguish expected open sheets from invalid solid topology. `geometryDiagnostics` reports boundary edges, non-manifold edges, orientation conflicts and degenerates; it does not prove absence of self-intersection. A capped loft, shell-like surface, or sampled field is not automatically a manufacturing-grade solid.
-Check material and camera fidelity independently. A fallback image may still answer a geometry question, but it cannot establish faithful PBR appearance. Keep unresolved export or material findings visible in the delivery report.
+Read `capture.backdrop` in image results: views are on a neutral grey unless a capture asked for `dark` or `light`, and a silhouette judged on the wrong assumption about the backdrop is not evidence. Check material and camera fidelity independently. A fallback image may still answer a geometry question, but it cannot establish faithful PBR appearance. Keep unresolved export or material findings visible in the delivery report.
## In the destination
diff --git a/skills/kiln-refine-asset/SKILL.md b/skills/kiln-refine-asset/SKILL.md
index c3ce2f80..f8ea07f6 100644
--- a/skills/kiln-refine-asset/SKILL.md
+++ b/skills/kiln-refine-asset/SKILL.md
@@ -10,7 +10,7 @@ Work from the saved program. A GLB alone does not contain editable Kiln JavaScri
For a collection asset, first call `kiln_assets` with `action: "restore"`, `collection`, `assetId`, and `revisionId`. This imports its exact source into the current program store and returns a fresh `programRef`. A downloaded ZIP can be imported with `node kiln.mjs import bundle.zip`. A binary-only GLB has no source to restore.
-After reviewing the change, use `kiln_save` to create an immutable child revision with the new `programRef`, the original `assetId`, and `parentRevision` set to the exact revision you started from. Preserve the collection, name, relevant tags, and known model/harness attribution; describe the change. Never replace or delete the base: its prior revision remains intact, and concurrent children remain visible as branches. Return the new revision's download resources; copying to a different collection does not make a live link.
+After reviewing the change, use `kiln_save` to create an immutable child revision with the new `programRef`, the original `assetId`, and `parentRevision` set to the exact revision you started from. Preserve the collection, name, relevant tags, and known model/harness attribution; describe the change. Pass the `backdrop` the accepted sheet used when it was not the default, so the preview matches what you reviewed. Never replace or delete the base: its prior revision remains intact, and concurrent children remain visible as branches. Return the new revision's download resources; copying to a different collection does not make a live link.
## Read, change, compare
@@ -22,7 +22,7 @@ After saving the reviewed child revision, call `kiln_present` when available wit
4. Apply related `{ oldString, newString }` replacements through `kiln_edit`. Keep the returned new reference. Shared constants and shared geometry can affect more than the selected part.
5. Review the diff and returned images against the same question. Check `render.ok` independently of edit success. Repair a failed draft by its new reference rather than recreating the whole source.
-An edit renders by default and accepts the same `capture` object as `kiln_render`. Use `render: false` when no image is needed. A missing or ambiguous anchor changes nothing; expand the anchor or use `replaceAll: true` only when every match should change. Long diffs may set `diffTruncated`; read more source instead of requesting a full-program echo by habit.
+An edit renders by default and accepts the same `capture` object as `kiln_render`, including `backdrop` once a sheet on the default neutral grey has shown a part merging with it: `light` when that part is darker than the grey, `dark` when it is lighter. Use `render: false` when no image is needed. A missing or ambiguous anchor changes nothing; expand the anchor or use `replaceAll: true` only when every match should change. Long diffs may set `diffTruncated`; read more source instead of requesting a full-program echo by habit.
## Preserve intended structure
diff --git a/src/__tests__/cli-backdrop.test.ts b/src/__tests__/cli-backdrop.test.ts
new file mode 100644
index 00000000..45370416
--- /dev/null
+++ b/src/__tests__/cli-backdrop.test.ts
@@ -0,0 +1,100 @@
+import { expect, it } from 'bun:test';
+import { mkdtemp, mkdir, writeFile, readFile, readdir, rm } from 'node:fs/promises';
+import { join, resolve } from 'node:path';
+import { BACKDROPS } from '../views/background';
+import { decodePng } from '../views/png';
+import { PAD } from '../views/grid';
+
+it('paints the CLI contact sheet on the named backdrop, with or without a capture file', async () => {
+ const base = resolve(import.meta.dir, '../../tmp');
+ await mkdir(base, { recursive: true });
+ const directory = await mkdtemp(join(base, 'cli-backdrop-'));
+ try {
+ const built = await Bun.build({
+ entrypoints: [resolve(import.meta.dir, '../cli.ts')],
+ target: 'node',
+ packages: 'external',
+ outdir: directory,
+ naming: 'cli.mjs',
+ });
+ expect(built.success).toBe(true);
+ const env = {
+ ...process.env,
+ KILN_EVALUATOR_MODE: 'in-process',
+ KILN_BUILD_CACHE: 'off',
+ KILN_PROGRAM_STORE: join(directory, 'programs'),
+ KILN_RENDER: 'cpu',
+ };
+ const run = (args: string[]) =>
+ Bun.spawnSync(['node', join(directory, 'cli.mjs'), ...args], {
+ cwd: directory,
+ env,
+ stdout: 'pipe',
+ stderr: 'pipe',
+ });
+ // The sheet's outer pixels are gutter, so read just inside the last cell's
+ // top-right corner: away from the centred cube and from each cell's label.
+ const corner = async (name: string): Promise<number[]> => {
+ const png = decodePng(await readFile(join(directory, name)));
+ const at = ((PAD + 1) * png.width + (png.width - PAD - 2)) * 3;
+ return [...png.rgb.subarray(at, at + 3)];
+ };
+ await writeFile(
+ join(directory, 'source.js'),
+ "const meta={name:'BackdropFixture',category:'prop'};function build(){const root=createRoot('Root');createPart('Body',boxGeo(1,1,1),gameMaterial(0x101010),{parent:root});return root;}",
+ );
+ // No --capture: the flag alone chooses the backdrop of the default six-view sheet.
+ const light = run(['render', 'source.js', '--views', 'light.png', '--backdrop', 'light']);
+ expect(light.stderr.toString()).toBe('');
+ expect(light.exitCode).toBe(0);
+ expect(await corner('light.png')).toEqual([...BACKDROPS.light.rgb]);
+ const plain = run(['render', 'source.js', '--views', 'plain.png']);
+ expect(plain.exitCode).toBe(0);
+ expect(await corner('plain.png')).toEqual([...BACKDROPS.neutral.rgb]);
+ // With --capture: the flag overrides the recipe's own backdrop, so a shared
+ // recipe file can be re-run on another backdrop without editing it.
+ await writeFile(
+ join(directory, 'capture.json'),
+ JSON.stringify({ preset: '1x1', backdrop: 'light' }),
+ );
+ const dark = run([
+ 'render',
+ 'source.js',
+ '--views',
+ 'dark.png',
+ '--capture',
+ 'capture.json',
+ '--backdrop',
+ 'dark',
+ ]);
+ expect(dark.stderr.toString()).toBe('');
+ expect(dark.exitCode).toBe(0);
+ expect(await corner('dark.png')).toEqual([...BACKDROPS.dark.rgb]);
+ const fromFile = run([
+ 'render',
+ 'source.js',
+ '--views',
+ 'file.png',
+ '--capture',
+ 'capture.json',
+ ]);
+ expect(fromFile.exitCode).toBe(0);
+ expect(await corner('file.png')).toEqual([...BACKDROPS.light.rgb]);
+ // Parsing is exercised through the spawned CLI, not in-process: importing
+ // cli.ts here would instrument the whole file for coverage it cannot earn.
+ const bad = run(['render', 'source.js', '--views', 'bad.png', '--backdrop', '#1a1a1a']);
+ expect(bad.exitCode).not.toBe(0);
+ expect(bad.stderr.toString()).toContain('neutral, dark, light');
+ expect(await readdir(directory)).not.toContain('bad.png');
+ const missing = run(['render', 'source.js', '--views', 'missing.png', '--backdrop']);
+ expect(missing.exitCode).not.toBe(0);
+ expect(missing.stderr.toString()).toContain('requires a value');
+ // Without --views there is nothing for a backdrop to paint.
+ const noViews = run(['render', 'source.js', '--backdrop', 'dark', '--out', 'x.glb']);
+ expect(noViews.exitCode).not.toBe(0);
+ expect(noViews.stderr.toString()).toContain('--backdrop requires --views');
+ expect(await readdir(directory)).not.toContain('x.glb');
+ } finally {
+ await rm(directory, { recursive: true, force: true });
+ }
+});
diff --git a/src/__tests__/cli-render-mode.test.ts b/src/__tests__/cli-render-mode.test.ts
index be1097c7..9aeef739 100644
--- a/src/__tests__/cli-render-mode.test.ts
+++ b/src/__tests__/cli-render-mode.test.ts
@@ -72,7 +72,7 @@ describe('probeRenderService', () => {
});
});
-it('sends the shared grid background to the GPU service for ordinary asset sheets', async () => {
+it('names the shared grid backdrop to the GPU service for ordinary asset sheets', async () => {
let body: Record<string, unknown> | undefined;
const server = createServer(async (req, res) => {
const chunks: Buffer[] = [];
@@ -100,7 +100,9 @@ it('sends the shared grid background to the GPU service for ordinary asset sheet
size: 384,
});
- expect(body?.background).toBe('#1a1a1a');
+ // The engine names the backdrop; the service owns the colour table.
+ expect(body?.background).toBeUndefined();
+ expect(body?.backdrop).toBe('neutral');
});
it('authenticates an auto-started local renderer with its inherited service token', async () => {
diff --git a/src/__tests__/cli-service-lifecycle.test.ts b/src/__tests__/cli-service-lifecycle.test.ts
new file mode 100644
index 00000000..b732b752
--- /dev/null
+++ b/src/__tests__/cli-service-lifecycle.test.ts
@@ -0,0 +1,163 @@
+/**
+ * A one-shot CLI command that had to start the GPU render service itself must
+ * also stop it when the command settles.
+ *
+ * The host module kills a service it started from an `exit` hook, which is the
+ * right shape for the long-lived MCP server. For the CLI it was a deadlock by
+ * construction: the child's piped stderr kept the event loop alive, so the
+ * process never reached `exit`, so the hook that would have killed the child
+ * never ran. `kiln render --render gpu` finished its work and then hung, with a
+ * GPU process orphaned behind it, whenever no service was already listening.
+ */
+import { expect, it } from 'bun:test';
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
+import { join, resolve } from 'node:path';
+
+/** A port nothing is listening on right now. */
+async function freePort(): Promise<number> {
+ const server = createServer();
+ await new Promise<void>((done) => server.listen(0, '127.0.0.1', done));
+ const { port } = server.address() as AddressInfo;
+ await new Promise<void>((done) => server.close(() => done()));
+ return port;
+}
+
+async function listening(port: number): Promise<boolean> {
+ try {
+ const res = await fetch(`http://127.0.0.1:${port}/health`, {
+ signal: AbortSignal.timeout(1_000),
+ });
+ return res.ok;
+ } catch {
+ return false;
+ }
+}
+
+/**
+ * A stand-in for render-service/: what `localRenderServiceState` needs to call
+ * it ready, plus a server that answers `/health` and `/render` with one flat PNG
+ * per requested view. `gpu` mode requires the GPU render to succeed, so the
+ * answer has to pass the port's PNG validation; the pixels do not matter, the
+ * process does.
+ */
+const FAKE_SERVER = `
+import { createServer } from 'node:http';
+import { crc32, deflateSync } from 'node:zlib';
+const chunk = (type, data) => {
+ const length = Buffer.alloc(4);
+ length.writeUInt32BE(data.length);
+ const body = Buffer.concat([Buffer.from(type), data]);
+ const crc = Buffer.alloc(4);
+ crc.writeUInt32BE(crc32(body));
+ return Buffer.concat([length, body, crc]);
+};
+const png = (size) => {
+ const ihdr = Buffer.alloc(13);
+ ihdr.writeUInt32BE(size, 0);
+ ihdr.writeUInt32BE(size, 4);
+ ihdr[8] = 8;
+ ihdr[9] = 2;
+ const raw = Buffer.alloc(size * (1 + size * 3), 0x80);
+ for (let y = 0; y < size; y++) raw[y * (1 + size * 3)] = 0;
+ return Buffer.concat([
+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
+ chunk('IHDR', ihdr),
+ chunk('IDAT', deflateSync(raw)),
+ chunk('IEND', Buffer.alloc(0)),
+ ]);
+};
+createServer((req, res) => {
+ let body = '';
+ req.on('data', (piece) => {
+ body += piece;
+ });
+ req.on('end', () => {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ if (req.url === '/health') {
+ res.end(JSON.stringify({ ok: true, rendererId: 'fake-renderer' }));
+ return;
+ }
+ const request = body ? JSON.parse(body) : {};
+ const count = (request.views ?? request.cameras ?? []).length;
+ const size = request.size ?? request.width ?? 384;
+ const views = Array.from({ length: count }, () => png(size).toString('base64'));
+ res.end(JSON.stringify({ ok: true, rendererId: 'fake-renderer', views }));
+ });
+}).listen(Number(process.env.PORT), process.env.HOST ?? '127.0.0.1');
+`;
+
+it('stops a render service the CLI started once the command settles, instead of hanging on it', async () => {
+ const base = resolve(import.meta.dir, '../../tmp');
+ await mkdir(base, { recursive: true });
+ const directory = await mkdtemp(join(base, 'cli-service-'));
+ try {
+ const built = await Bun.build({
+ entrypoints: [resolve(import.meta.dir, '../cli.ts')],
+ target: 'node',
+ packages: 'external',
+ outdir: directory,
+ naming: 'cli.mjs',
+ });
+ expect(built.success).toBe(true);
+
+ const service = join(directory, 'render-service');
+ await mkdir(join(service, 'src'), { recursive: true });
+ await mkdir(join(service, 'node_modules/webgpu'), { recursive: true });
+ await mkdir(join(service, 'node_modules/three'), { recursive: true });
+ await writeFile(join(service, 'package.json'), '{"name":"fake-render-service"}');
+ await writeFile(join(service, 'src/register-hooks.mjs'), 'export {};');
+ await writeFile(join(service, 'src/server.mjs'), FAKE_SERVER);
+ const port = await freePort();
+ expect(await listening(port)).toBe(false);
+
+ // Metalness above zero is what routes a scene to the render port.
+ await writeFile(
+ join(directory, 'source.js'),
+ "const meta={name:'LifecycleFixture',category:'prop'};function build(){const root=createRoot('Root');createPart('Body',boxGeo(1,1,1),gameMaterial(0xc0c0c0,{metalness:0.9,roughness:0.3}),{parent:root});return root;}",
+ );
+ const env: Record<string, string | undefined> = {
+ ...process.env,
+ KILN_EVALUATOR_MODE: 'in-process',
+ KILN_BUILD_CACHE: 'off',
+ KILN_PROGRAM_STORE: join(directory, 'programs'),
+ KILN_RENDER_SERVICE_DIR: service,
+ KILN_RENDER_SERVICE_PORT: String(port),
+ };
+ delete env['KILN_RENDER'];
+ delete env['KILN_RENDER_PORT_URL'];
+ const started = Date.now();
+ const run = Bun.spawnSync(
+ [
+ 'node',
+ join(directory, 'cli.mjs'),
+ 'render',
+ 'source.js',
+ '--render',
+ 'gpu',
+ '--views',
+ 'sheet.png',
+ ],
+ { cwd: directory, env, stdout: 'pipe', stderr: 'pipe', timeout: 45_000 },
+ );
+ const elapsed = Date.now() - started;
+ // The command's own work takes seconds. Hitting the timeout is the hang.
+ expect({ exitCode: run.exitCode, elapsed, stderr: run.stderr.toString() }).toMatchObject({
+ exitCode: 0,
+ });
+ expect(elapsed).toBeLessThan(40_000);
+ expect(run.stdout.toString()).toContain('fake-renderer');
+ expect(await readdir(directory)).toContain('sheet.png');
+ // The service the command started is gone with it. Killing is synchronous,
+ // but the port can take a moment to close on Windows.
+ let gone = false;
+ for (let attempt = 0; attempt < 20 && !gone; attempt++) {
+ gone = !(await listening(port));
+ if (!gone) await new Promise((done) => setTimeout(done, 250));
+ }
+ expect(gone).toBe(true);
+ } finally {
+ await rm(directory, { recursive: true, force: true });
+ }
+}, 90_000);
diff --git a/src/__tests__/render-service-host.test.ts b/src/__tests__/render-service-host.test.ts
index 00b0f941..f2a0b723 100644
--- a/src/__tests__/render-service-host.test.ts
+++ b/src/__tests__/render-service-host.test.ts
@@ -99,13 +99,22 @@ it('passes the Node import hook as a file URL on every platform', () => {
describe('buildRenderPort with autoSpawn', () => {
it('attaches nothing when the renderer is not installed, so a CPU-only machine reads as ordinary', async () => {
- const context = await buildRenderPort('auto', undefined, {
- autoSpawn: true,
- serviceDir: join(await scratch(), 'nothing-here'),
- });
- // Not merely "renders on the CPU" -- `viewRenderPort` must be ABSENT, because
- // that absence is what `describeDrawnBy` reads to call a CPU view ordinary.
- expect(context.viewRenderPort).toBeUndefined();
+ // Pin a dead port: the host joins a listening service before it looks at the
+ // install, so this test would attach one that happens to be running on 8000.
+ const previous = process.env['KILN_RENDER_SERVICE_PORT'];
+ process.env['KILN_RENDER_SERVICE_PORT'] = '1';
+ try {
+ const context = await buildRenderPort('auto', undefined, {
+ autoSpawn: true,
+ serviceDir: join(await scratch(), 'nothing-here'),
+ });
+ // Not merely "renders on the CPU" -- `viewRenderPort` must be ABSENT, because
+ // that absence is what `describeDrawnBy` reads to call a CPU view ordinary.
+ expect(context.viewRenderPort).toBeUndefined();
+ } finally {
+ if (previous === undefined) delete process.env['KILN_RENDER_SERVICE_PORT'];
+ else process.env['KILN_RENDER_SERVICE_PORT'] = previous;
+ }
});
it('leaves an explicit URL alone rather than starting anything', async () => {
diff --git a/src/agent/generate.test.ts b/src/agent/generate.test.ts
index eed92f93..9f856f74 100644
--- a/src/agent/generate.test.ts
+++ b/src/agent/generate.test.ts
@@ -570,8 +570,13 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
capture: { preset: '3x2' },
});
expect(Buffer.compare(explicit.views!, base.views!)).toBe(0);
- expect(base.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6 });
- expect(explicit.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6 });
+ expect(base.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6, backdrop: 'neutral' });
+ expect(explicit.viewsCapture).toEqual({
+ preset: '3x2',
+ cols: 3,
+ cells: 6,
+ backdrop: 'neutral',
+ });
});
test('T3.3: the port is asked for the requested cell count and composited at its columns', async () => {
@@ -591,7 +596,7 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
// be a hard six).
expect(requests[0]!.viewDirs).toHaveLength(9);
expect(r.renderDegraded).toBe(false);
- expect(r.viewsCapture).toEqual({ preset: '3x3', cols: 3, cells: 9 });
+ expect(r.viewsCapture).toEqual({ preset: '3x3', cols: 3, cells: 9, backdrop: 'neutral' });
const { compositeViewPngGrid, resolveCapture } = await import('../views');
const cells = resolveCapture({ preset: '3x3' }).views;
expect(Buffer.compare(r.views!, compositeViewPngGrid(viewsPng, 3, cells).png)).toBe(0);
@@ -606,7 +611,7 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
capture: { preset: '2x2' },
viewRenderPort: async () => ({ ok: true, rendererId: 'gpu:test', viewsPng }),
});
- expect(r.viewsCapture).toEqual({ preset: '2x2', cols: 2, cells: 4 });
+ expect(r.viewsCapture).toEqual({ preset: '2x2', cols: 2, cells: 4, backdrop: 'neutral' });
const { compositeViewPngGrid, resolveCapture } = await import('../views');
const cells = resolveCapture({ preset: '2x2' }).views;
// Same cells at 3 cols would be a different image; pin that it is not that.
@@ -626,7 +631,12 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
},
});
expect(degraded.renderDegraded).toBe(true);
- expect(degraded.viewsCapture).toEqual({ preset: '3x1', cols: 3, cells: 3 });
+ expect(degraded.viewsCapture).toEqual({
+ preset: '3x1',
+ cols: 3,
+ cells: 3,
+ backdrop: 'neutral',
+ });
// The whole point: a GPU outage must not reshape the artifact. The degraded
// sheet is exactly what the CPU path produces for the same request.
@@ -670,7 +680,7 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
capture: { preset: '4x4' as never },
});
expect(r.views).toBeInstanceOf(Buffer);
- expect(r.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6 });
+ expect(r.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6, backdrop: 'neutral' });
expect(r.warnings.some((w) => w.includes('capture config ignored'))).toBe(true);
const base = await generateKilnAsset({ prompt: 'a crate', captureViews: true });
@@ -693,7 +703,7 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
// the rejected config and not skipped entirely.
expect(portCalls).toBe(1);
expect(r.renderDegraded).toBe(false);
- expect(r.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6 });
+ expect(r.viewsCapture).toEqual({ preset: '3x2', cols: 3, cells: 6, backdrop: 'neutral' });
expect(r.warnings.some((w) => w.includes('capture config ignored'))).toBe(true);
});
@@ -747,7 +757,8 @@ describe('generateKilnAsset viewRenderPort (B3b/B4)', () => {
);
expect(seen).toEqual([2]);
expect(out.ok).toBe(true);
- if (out.ok) expect(out.capture).toEqual({ preset: '2x1', cols: 2, cells: 2 });
+ if (out.ok)
+ expect(out.capture).toEqual({ preset: '2x1', cols: 2, cells: 2, backdrop: 'neutral' });
// Count mismatch now reports the REQUESTED count, not a hardcoded six.
const short = await captureViewsViaPort(
diff --git a/src/agent/tools-unified.test.ts b/src/agent/tools-unified.test.ts
index 6053101d..25ad505e 100644
--- a/src/agent/tools-unified.test.ts
+++ b/src/agent/tools-unified.test.ts
@@ -251,9 +251,9 @@ describe('makeKilnUnifiedTools', () => {
const render = findTool(tools, 'kiln_render');
const out = (await render.invoke({ capture: { preset: '1x1' } })) as unknown[];
const json = (out[1] as JsonBlock).json as {
- capture?: { preset?: string; cols?: number; cells?: number };
+ capture?: { preset?: string; cols?: number; cells?: number; backdrop?: string };
};
- expect(json.capture).toEqual({ preset: '1x1', cols: 1, cells: 1 });
+ expect(json.capture).toEqual({ preset: '1x1', cols: 1, cells: 1, backdrop: 'neutral' });
expect(sink.rendered).toBe(true);
expect(sink.capture).toEqual({ preset: '1x1' });
@@ -468,6 +468,23 @@ describe('makeKilnUnifiedTools', () => {
expect('pngBase64' in json).toBe(false); // image stripped by the media extractor
});
+ test('kiln_view_interior echoes the backdrop it painted, like every other image result', async () => {
+ const sink: UnifiedSink = { edits: [] };
+ const tools = makeKilnUnifiedTools({ seedCode: BUILDING_CODE, sink });
+ const plain = (await findTool(tools, 'kiln_view_interior').invoke({})) as unknown[];
+ const plainJson = (plain[1] as JsonBlock).json as { capture?: { backdrop?: string } };
+ expect(plainJson.capture?.backdrop).toBe('neutral');
+ const dark = (await findTool(tools, 'kiln_view_interior').invoke({
+ capture: { version: 'kiln.capture.v1', backdrop: 'dark', shots: [{ name: 'Inside' }] },
+ })) as unknown[];
+ const darkJson = (dark[1] as JsonBlock).json as {
+ ok?: boolean;
+ capture?: { backdrop?: string };
+ };
+ expect(darkJson.ok).toBe(true);
+ expect(darkJson.capture?.backdrop).toBe('dark');
+ });
+
test('kiln_view_interior on a broken buffer is image-free (plain JSON error)', async () => {
const sink: UnifiedSink = { edits: [] };
const tools = makeKilnUnifiedTools({ seedCode: 'not a kiln program (', sink });
diff --git a/src/asset-cli.test.ts b/src/asset-cli.test.ts
index f872f2af..34fa308f 100644
--- a/src/asset-cli.test.ts
+++ b/src/asset-cli.test.ts
@@ -4,6 +4,9 @@ import { mkdtemp, readFile, rm, readdir } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { tmpdir } from 'node:os';
import { decodeAssetBundle } from './assets';
+import { BACKDROPS } from './views/background';
+import { PAD } from './views/grid';
+import { decodePng } from './views/png';
test('CLI saves, exports, imports, and restores a revision across independent stores', async () => {
const root = await mkdtemp(join(tmpdir(), 'kiln-asset-cli-'));
@@ -116,3 +119,57 @@ test('CLI saves, exports, imports, and restores a revision across independent st
await rm(root, { recursive: true, force: true });
}
}, 30000);
+
+test('CLI save paints its preview on the named backdrop and records it, like kiln_save', async () => {
+ const root = await mkdtemp(join(tmpdir(), 'kiln-asset-cli-backdrop-'));
+ const cli = resolve('src/cli.ts');
+ const run = (args: string[]) =>
+ spawnSync(process.execPath, [cli, ...args], {
+ cwd: root,
+ env: {
+ ...process.env,
+ KILN_RENDER: 'cpu',
+ KILN_EVALUATOR_MODE: 'in-process',
+ KILN_PROGRAM_STORE: join(root, '.kiln', 'programs'),
+ KILN_COLLECTIONS: JSON.stringify({ project: join(root, 'collection') }),
+ },
+ encoding: 'utf8',
+ windowsHide: true,
+ });
+ try {
+ const saved = run([
+ 'save',
+ resolve('examples/crate.kiln.js'),
+ '--name',
+ 'Crate',
+ '--render',
+ 'cpu',
+ '--backdrop',
+ 'dark',
+ ]);
+ expect(saved.status).toBe(0);
+ expect(saved.stdout.length).toBeGreaterThan(0);
+ const asset = JSON.parse(saved.stdout).asset;
+ const file = join(root, 'crate.zip');
+ expect(run(['export', asset.assetId, asset.revisionId, '--out', file]).status).toBe(0);
+ const [entry] = decodeAssetBundle(new Uint8Array(await readFile(file)));
+ expect(entry!.manifest.preview?.backdrop).toBe('dark');
+ const png = decodePng(entry!.files['preview.png']!);
+ // A corner inside the sheet's padding is backdrop, whatever the asset is.
+ const at = ((PAD + 1) * png.width + (png.width - PAD - 2)) * 3;
+ expect([...png.rgb.subarray(at, at + 3)]).toEqual([...BACKDROPS.dark.rgb]);
+
+ // A free colour is refused by the same validation the tool applies.
+ const free = run([
+ 'save',
+ resolve('examples/crate.kiln.js'),
+ '--name',
+ 'Crate',
+ '--backdrop',
+ '#000000',
+ ]);
+ expect(free.status).not.toBe(0);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+}, 30000);
diff --git a/src/asset-cli.ts b/src/asset-cli.ts
index 07c476a6..e3025bb4 100644
--- a/src/asset-cli.ts
+++ b/src/asset-cli.ts
@@ -17,6 +17,7 @@ export const ASSET_USAGE = `
ASSETS & VIEWER
kiln save <source.js|programRef> --name <name> [--collection project]
[--asset <id> --parent <revision>] [--description <text>] [--tag <tag>]
+ [--backdrop neutral|dark|light] preview backdrop; the one the reviewed sheet used
kiln collections list configured collection names
kiln collections add <name> <directory> remember another collection root
kiln assets [--collection project] list saved revisions (JSON)
@@ -51,6 +52,7 @@ export async function assetMain(argv: readonly string[]): Promise<number> {
'profile',
'port',
'render',
+ 'backdrop',
]);
for (let i = 1; i < argv.length; i++) {
const arg = argv[i]!;
@@ -128,6 +130,7 @@ export async function assetMain(argv: readonly string[]): Promise<number> {
description: flags.description,
brief: flags.brief,
tags,
+ backdrop: flags.backdrop,
}),
null,
2,
diff --git a/src/assets-tools.test.ts b/src/assets-tools.test.ts
index af9c0841..6dc3e9d1 100644
--- a/src/assets-tools.test.ts
+++ b/src/assets-tools.test.ts
@@ -10,6 +10,9 @@ import { MemoryProgramStore, retainProgram } from './program-store';
import { createKilnProgramToolRegistry } from './tools/registry';
import { decodeWidgetAsset } from './widget-transfer';
import { readAssetResource } from './assets-resources';
+import { BACKDROPS } from './views/background';
+import { PAD } from './views/grid';
+import { decodePng } from './views/png';
test('MCP saves an editable revision, exposes exact downloadable bytes, and restores source in a new session', async () => {
const root = await mkdtemp(join(tmpdir(), 'kiln-asset-tools-'));
@@ -278,3 +281,51 @@ test('the default MCP transport keeps artifact URIs readable without resource-li
await rm(root, { recursive: true, force: true });
}
});
+
+/**
+ * A saved preview is a render like any other, so it takes the same named backdrop
+ * and the manifest records which one it was painted on. Without that, the model
+ * could review a grey asset on `dark` and then ship a preview where it vanishes
+ * into the neutral grey, and nothing downstream could tell.
+ */
+test('kiln_save paints its preview on the named backdrop and records it in the manifest', async () => {
+ const root = await mkdtemp(join(tmpdir(), 'kiln-save-backdrop-'));
+ const assetLibrary = new FileAssetLibrary({ project: root });
+ const programStore = new MemoryProgramStore();
+ const programRef = await retainProgram(
+ programStore,
+ "const meta = { name: 'Box', category: 'prop' }; function build() { const root = createRoot('Box'); createPart('Body', boxGeo(1,1,1), gameMaterial(0x88aa66), {parent: root, position: [0,0.5,0]}); return root; }",
+ );
+ const server = createKilnMcpServer({ programStore, assetLibrary });
+ const client = new Client({ name: 'save-backdrop-test', version: '1' });
+ const [ct, st] = InMemoryTransport.createLinkedPair();
+ await Promise.all([client.connect(ct), server.connect(st)]);
+ const corner = (png: Uint8Array) => {
+ const decoded = decodePng(png);
+ const at = ((PAD + 1) * decoded.width + (decoded.width - PAD - 2)) * 3;
+ return [...decoded.rgb.subarray(at, at + 3)];
+ };
+ try {
+ for (const [args, expected] of [
+ [{ programRef, name: 'Box' }, 'neutral'],
+ [{ programRef, name: 'Box on dark', backdrop: 'dark' }, 'dark'],
+ ] as const) {
+ const saved = await client.callTool({ name: 'kiln_save', arguments: { ...args } });
+ const blocks = saved.content as { type: string; text?: string }[];
+ const data = JSON.parse(blocks.find((block) => block.type === 'text')!.text!);
+ expect(data.ok).toBe(true);
+ const record = await assetLibrary.read('project', data.asset.assetId, data.asset.revisionId);
+ expect(record.manifest.preview?.backdrop).toBe(expected);
+ expect(corner(record.files['preview.png']!)).toEqual([...BACKDROPS[expected].rgb]);
+ }
+ const bad = await client.callTool({
+ name: 'kiln_save',
+ arguments: { programRef, name: 'Box', backdrop: '#000000' },
+ });
+ expect(bad.isError).toBe(true);
+ } finally {
+ await client.close();
+ await server.close();
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/src/assets.ts b/src/assets.ts
index ef0fde24..bee7e380 100644
--- a/src/assets.ts
+++ b/src/assets.ts
@@ -1,5 +1,6 @@
/** Portable asset records. No filesystem, renderer, or server dependencies. */
import { z } from 'zod';
+import { BACKDROP_IDS, type BackdropId } from './views/background';
import { zipSync, unzipSync } from 'three/addons/libs/fflate.module.js';
export const ASSET_LIMIT = 64 * 1024 * 1024;
@@ -38,7 +39,14 @@ export const assetManifestSchema = z.object({
rebuild: z.enum(['engine-required', 'external-dependencies-required']),
})
.optional(),
- preview: z.object({ fidelity: z.unknown().optional(), error: z.string().optional() }).optional(),
+ preview: z
+ .object({
+ fidelity: z.unknown().optional(),
+ error: z.string().optional(),
+ /** The named backdrop the preview was painted on; a reader must never guess it. */
+ backdrop: z.enum(BACKDROP_IDS as [BackdropId, ...BackdropId[]]).optional(),
+ })
+ .optional(),
});
export type AssetManifest = z.infer<typeof assetManifestSchema>;
export interface AssetRecord {
diff --git a/src/cli-render-mode.ts b/src/cli-render-mode.ts
index 6e37947f..79f1ec7d 100644
--- a/src/cli-render-mode.ts
+++ b/src/cli-render-mode.ts
@@ -30,7 +30,7 @@ import {
startLocalRenderService,
} from './render-service-host';
import type { KilnToolContext } from './tools/registry';
-import { GRID_BACKGROUND_HEX } from './views/background';
+import { DEFAULT_BACKDROP_ID } from './views/background';
export type RenderMode = 'auto' | 'cpu' | 'gpu';
@@ -71,10 +71,11 @@ export function makeRemoteRenderPort(url: string, token?: string): PbrRenderPort
body['height'] = req.height;
if (req.lightingPresetId) body['lighting_preset_id'] = req.lightingPresetId;
}
- if (req.viewDirs) {
- body['views'] = req.viewDirs;
- body['background'] = GRID_BACKGROUND_HEX;
- }
+ if (req.viewDirs) body['views'] = req.viewDirs;
+ // The service owns the colour table; the engine names the backdrop so both
+ // producers resolve one id to one colour. Always sent, so a sheet's backdrop
+ // never depends on which side's default happened to apply.
+ body['backdrop'] = req.backdrop ?? DEFAULT_BACKDROP_ID;
if (req.size !== undefined) body['size'] = req.size;
if (req.beautySize !== undefined) body['beauty_size'] = req.beautySize;
diff --git a/src/cli.ts b/src/cli.ts
index e66fd3a4..ffeb1a10 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -11,7 +11,9 @@ import { prepareDestination, writeDestinationAtomic } from './cli-output';
import { isDirectEntry } from './direct-entry';
import { createPackagedLocalToolContext } from './local-runtime';
import { createKilnProgramToolRegistry, type KilnToolContext } from './tools/registry';
+import { BACKDROP_IDS, isBackdropId, type BackdropId } from './views/background';
import { resolveRenderMode, buildRenderPort, describeDrawnBy } from './cli-render-mode';
+import { stopLocalRenderService } from './render-service-host';
import type { RenderMode } from './cli-render-mode';
import { localProgramStore } from './program-store-node';
import { retainProgram, programRefPattern } from './program-store';
@@ -29,6 +31,7 @@ OPTIONS
--out <path> GLB output path (default: out.glb)
--views <path> contact sheet PNG path (default: none)
--capture <file.json> camera recipe for --views (grid output; max 1 MiB)
+ --backdrop <id> neutral | dark | light (default: neutral)
--render <mode> auto | cpu | gpu (default: auto)
--render-port <url> remote GPU render service
--model <id> model id for generate (default: env KILN_MODEL)
@@ -41,6 +44,7 @@ EXAMPLES
kiln generate "a weathered wooden crate" --out crate.glb --views sheet.png
kiln render examples/crate.kiln.js --render cpu --views sheet.png
kiln render p_RETURNED_HANDLE --capture cameras.json --views chosen.png
+ kiln render examples/crate.kiln.js --views sheet.png --backdrop light
`;
interface Args {
@@ -50,6 +54,7 @@ interface Args {
views: string | undefined;
capture: string | undefined;
captureRecipe?: unknown;
+ backdrop: BackdropId | undefined;
render: RenderMode;
renderPort: string | undefined;
model: string | undefined;
@@ -65,6 +70,7 @@ export function parseArgs(argv: readonly string[]): Args {
out: undefined,
views: undefined,
capture: undefined,
+ backdrop: undefined,
render: 'auto',
renderPort: undefined,
model: process.env['KILN_MODEL'],
@@ -93,6 +99,13 @@ export function parseArgs(argv: readonly string[]): Args {
case '--capture':
args.capture = next();
break;
+ case '--backdrop': {
+ const id = next();
+ if (!isBackdropId(id))
+ throw new Error(`--backdrop must be one of ${BACKDROP_IDS.join(', ')} (got ${id})`);
+ args.backdrop = id;
+ break;
+ }
case '--render':
args.render = resolveRenderMode(next());
break;
@@ -156,6 +169,22 @@ async function readCaptureRecipe(args: Args): Promise<unknown> {
return capture;
}
+/**
+ * `--backdrop` is the one capture field worth a flag of its own: it is the
+ * question "same sheet, other backdrop", which should not require writing a
+ * recipe file. It rides in the same `capture` object every surface takes, so
+ * the CLI, MCP and API resolve it through one path, and it overrides a recipe's
+ * own `backdrop` so a shared recipe can be re-run on another backdrop unedited.
+ */
+function applyBackdrop(args: Args): unknown {
+ if (args.backdrop === undefined) return args.captureRecipe;
+ if (!args.views) throw new Error('--backdrop requires --views <output.png>.');
+ if (args.command !== 'render' && args.command !== 'generate')
+ throw new Error('--backdrop is supported by render and generate only.');
+ const recipe = (args.captureRecipe ?? {}) as Record<string, unknown>;
+ return { ...recipe, backdrop: args.backdrop };
+}
+
/**
* Render one program to GLB bytes plus, optionally, the contact sheet.
* Shared by both commands so `generate` and `render` cannot diverge in output.
@@ -343,8 +372,18 @@ export async function withProcessAlive<T>(run: () => Promise<T>): Promise<T> {
}
}
+/**
+ * A one-shot command that had to start the GPU render service must also stop it
+ * when the command settles. The host module kills a service it started from an
+ * `exit` hook, which suits the long-lived MCP server; here it was a deadlock by
+ * construction, because the child's piped stderr kept the loop alive, so the
+ * process never reached `exit`, so the hook never ran, and `--render gpu` hung
+ * after finishing its work with a GPU process orphaned behind it. A service the
+ * command merely found is left alone: `stopLocalRenderService` only kills what
+ * this process spawned.
+ */
export function main(argv: readonly string[]): Promise<number> {
- return withProcessAlive(() => runMain(argv));
+ return withProcessAlive(() => runMain(argv)).finally(stopLocalRenderService);
}
async function runMain(argv: readonly string[]): Promise<number> {
@@ -371,6 +410,7 @@ async function runMain(argv: readonly string[]): Promise<number> {
}
try {
if (args.capture !== undefined) args.captureRecipe = await readCaptureRecipe(args);
+ args.captureRecipe = applyBackdrop(args);
switch (args.command) {
case 'source':
return await cmdSource(args);
diff --git a/src/composer/render-port.ts b/src/composer/render-port.ts
index 0ea50df2..c697e470 100644
--- a/src/composer/render-port.ts
+++ b/src/composer/render-port.ts
@@ -1,4 +1,5 @@
import { validateResolvedAssetCamera, type ResolvedAssetCameraV1 } from '../views/camera';
+import { isBackdropId, BACKDROP_IDS, type BackdropId } from '../views/background';
/**
* SceneRenderPort — the host-supplied seam that lets the composer SEE the scene
* without the engine importing THREE. The engine defines this interface and the
@@ -279,9 +280,16 @@ export interface PbrRenderRequest {
height?: number;
/** Host-owned lighting preset identity applied to the perspective render. */
lightingPresetId?: string;
+ /**
+ * Named backdrop behind every view, from the engine's fixed table. Omitted
+ * means the default. A host paints the matching colour so a GPU sheet and a
+ * CPU fallback sheet of the same request share one backdrop.
+ */
+ backdrop?: BackdropId;
}
const PBR_REQUEST_KEYS = new Set([
+ 'backdrop',
'glb',
'viewDirs',
'size',
@@ -322,6 +330,11 @@ export function validatePbrRenderRequest(input: unknown): PbrRenderRequest {
throw new TypeError('PbrRenderRequest.glb must be a non-empty Uint8Array');
}
const result: PbrRenderRequest = { glb: source.glb };
+ if (source.backdrop !== undefined) {
+ if (!isBackdropId(source.backdrop))
+ throw new TypeError(`PbrRenderRequest.backdrop must be one of ${BACKDROP_IDS.join(', ')}`);
+ result.backdrop = source.backdrop;
+ }
if (source.viewDirs !== undefined) {
if (
!Array.isArray(source.viewDirs) ||
@@ -456,7 +469,15 @@ export function validatePbrRenderRequest(input: unknown): PbrRenderRequest {
* the rasterizer's own leaf constant) because the host implementing this port
* has no reason to import the rasterizer.
*/
-export { GRID_BACKGROUND_HEX, GRID_BACKGROUND_RGB } from '../views/background';
+export {
+ BACKDROPS,
+ BACKDROP_IDS,
+ DEFAULT_BACKDROP_ID,
+ GRID_BACKGROUND_HEX,
+ GRID_BACKGROUND_RGB,
+ resolveBackdrop,
+} from '../views/background';
+export type { Backdrop, BackdropId } from '../views/background';
export interface PbrRenderResult {
captureCache?: { hit: boolean; reused: number; total: number };
diff --git a/src/qa/reference-comparison.test.ts b/src/qa/reference-comparison.test.ts
index 83628c3d..b75c20b9 100644
--- a/src/qa/reference-comparison.test.ts
+++ b/src/qa/reference-comparison.test.ts
@@ -23,6 +23,7 @@ import {
} from './reference-comparison';
import type { QaContext } from './types';
import { createAssetIntentV1 } from '../contracts';
+import { GRID_BACKGROUND_RGB } from '../views/background';
const SIZE = 128;
@@ -68,9 +69,9 @@ function studioReference(withShadow = true): RgbRasterV1 {
return raster;
}
-/** A Kiln view: near-black background, the same box, no shadow. */
+/** A Kiln view: the neutral grey view backdrop, the same box, no shadow. */
function renderedView(rgb: [number, number, number] = [150, 40, 40]): RgbRasterV1 {
- const raster = blank(SIZE, SIZE, [26, 26, 26]);
+ const raster = blank(SIZE, SIZE, [...GRID_BACKGROUND_RGB]);
fillRect(raster, 44, 36, 84, 84, rgb);
return raster;
}
@@ -115,11 +116,16 @@ describe('segmentation', () => {
const grey = segmentSubject(
resampleRgb(studioReference(false), REFERENCE_COMPARISON_WORK_SIZE),
);
- const dark = segmentSubject(resampleRgb(renderedView(), REFERENCE_COMPARISON_WORK_SIZE));
+ const view = segmentSubject(resampleRgb(renderedView(), REFERENCE_COMPARISON_WORK_SIZE));
+ const dark = segmentSubject(
+ resampleRgb(blank(SIZE, SIZE, [26, 26, 26]), REFERENCE_COMPARISON_WORK_SIZE),
+ );
expect(grey.side.backdrop[0]).toBe(128);
- // The same code has to work on a photographic mid-grey and on Kiln's own
- // near-black view background; a constant would only ever fit one of them.
+ // The same code has to work on a photographic mid-grey, on Kiln's own
+ // neutral grey view backdrop and on the older near-black one; a constant
+ // would only ever fit one of them.
+ expect(view.side.backdrop[0]).toBe(GRID_BACKGROUND_RGB[0]);
expect(dark.side.backdrop[0]).toBe(26);
});
@@ -225,7 +231,7 @@ describe('cropGridCell', () => {
// Six copies of the subject plus five gutters is a different shape from one
// subject, so the sheet scores badly against its own reference.
const cell = renderedView();
- const sheet = blank(SIZE * 3, SIZE * 2, [26, 26, 26]);
+ const sheet = blank(SIZE * 3, SIZE * 2, [...GRID_BACKGROUND_RGB]);
for (let r = 0; r < 2; r++) {
for (let c = 0; c < 3; c++) {
for (let y = 0; y < SIZE; y++) {
diff --git a/src/qa/reference-comparison.ts b/src/qa/reference-comparison.ts
index 89efb16b..4ecc9743 100644
--- a/src/qa/reference-comparison.ts
+++ b/src/qa/reference-comparison.ts
@@ -34,7 +34,8 @@
* A soft shadow is near-neutral and mildly darker, so it lands in the band. A
* genuinely dark object is either much darker or carries chroma, so it does
* not. The fraction is relative rather than absolute so the same rule works on
- * a mid-grey photographic backdrop and on Kiln's near-black view background.
+ * a mid-grey photographic backdrop and on Kiln's neutral grey view backdrop
+ * (re-measured when the backdrop moved from near-black to `#aab1bc`).
*
* ## Determinism
*
diff --git a/src/tools/registry.ts b/src/tools/registry.ts
index 52a5bcd6..ab7a0978 100644
--- a/src/tools/registry.ts
+++ b/src/tools/registry.ts
@@ -46,6 +46,7 @@ import {
type ViewRenderTimeoutResolver,
} from '../agent/view-render-timeout';
import { ViewEvidenceHistoryStore } from '../views/evidence-history';
+import { BACKDROP_IDS, DEFAULT_BACKDROP_ID, type BackdropId } from '../views/background';
import type { TextureUsage } from '../textures';
// =============================================================================
@@ -457,6 +458,7 @@ async function renderDerivativeCell(
input.size,
[camera],
context.captureLimits,
+ input.backdrop,
);
if (ported.ok && ported.derivativeFidelityAttested) {
if (ported.inputGlbSha256 !== inputGlbSha256) {
@@ -510,6 +512,7 @@ async function renderDerivativeCell(
renderGlbViewCell(derivativeGlb, input.view, {
size: input.size,
camera,
+ ...(input.backdrop ? { backdrop: input.backdrop } : {}),
...(input.backfaceCull !== undefined ? { backfaceCull: input.backfaceCull } : {}),
...(input.frameBounds ? { frameBounds: input.frameBounds } : {}),
});
@@ -524,6 +527,7 @@ async function renderDerivativeCell(
camera,
size: input.size,
backfaceCull: input.backfaceCull ?? true,
+ ...(input.backdrop ? { backdrop: input.backdrop } : {}),
},
produceFlat,
)
@@ -627,6 +631,18 @@ const screenshotInput = z.object({
* metrics-only `kiln_render` produces no image, so a grid shape would be a
* meaningless argument there and would change that schema for no reason.
*/
+/**
+ * A named backdrop, never a free colour: sheets must stay comparable across
+ * runs, and a backdrop tuned to the asset colour hides the seams the model is
+ * meant to find. Neutral is the measured default; see `views/background.ts`.
+ */
+const backdropInput = z
+ .enum(BACKDROP_IDS as [BackdropId, ...BackdropId[]])
+ .optional()
+ .describe(
+ 'Neutral grey unless a sheet shows merging: light if the part is darker, dark if lighter.',
+ );
+
const legacyCaptureInput = z
.object({
preset: z
@@ -662,6 +678,7 @@ const legacyCaptureInput = z
'One camera per cell, in row-major order. Omit to use the preset default cameras. ' +
'Must not exceed the preset capacity (max 9 overall).',
),
+ backdrop: backdropInput,
})
.optional()
.describe(
@@ -774,6 +791,7 @@ const advancedCaptureInput = z.strictObject(
cols: z.number().int().min(1).max(3).optional(),
size: z.number().int().min(128).max(1024).optional(),
output: z.enum(['grid', 'separate']).optional(),
+ backdrop: backdropInput,
},
{ error: advancedCaptureError },
);
@@ -1082,8 +1100,8 @@ export interface KilnScreenshotResult {
ok: boolean;
/** View names in grid order (row-major). Defaults to Front, Right, Back, Left, Top, 3/4. */
views?: string[];
- /** Grid shape actually rendered — echoes the capture config back, or `3x2` by default. */
- capture?: { preset: string; cols: number; cells: number };
+ /** Grid shape and backdrop actually rendered — echoes the capture config back, or `3x2` on neutral by default. */
+ capture?: { preset: string; cols: number; cells: number; backdrop?: BackdropId };
width?: number;
height?: number;
/** The 3x2 grid PNG, base64-encoded (transports with image support strip this and attach the bytes). */
@@ -1174,8 +1192,8 @@ export interface KilnRenderViewsResult {
materialContract?: ProceduralTextureMaterialContract;
/** View names in grid order (row-major). Defaults to Front, Right, Back, Left, Top, 3/4. */
views?: string[];
- /** Grid shape actually rendered — echoes the capture config back, or `3x2` by default. */
- capture?: { preset: string; cols: number; cells: number };
+ /** Grid shape and backdrop actually rendered — echoes the capture config back, or `3x2` on neutral by default. */
+ capture?: { preset: string; cols: number; cells: number; backdrop?: BackdropId };
gridWidth?: number;
gridHeight?: number;
/** The 3x2 grid PNG, base64-encoded (transports with image support strip this and attach the bytes). */
@@ -1622,6 +1640,8 @@ export const kilnScreenshotAnimationDef: KilnToolDef = createKilnScreenshotAnima
// =============================================================================
export interface KilnViewInteriorResult {
+ /** Grid shape and backdrop actually rendered, echoed like every other image result. */
+ capture?: { preset: string; cols: number; cells: number; backdrop?: BackdropId };
cameraShots?: import('../views').ResolvedCameraShotV1[];
framesBase64?: string[];
ok: boolean;
@@ -1690,6 +1710,7 @@ async function runViewInterior(
gridWidth: grid.width,
gridHeight: grid.height,
...(grid.cameraShots ? { cameraShots: grid.cameraShots } : {}),
+ ...(grid.capture ? { capture: grid.capture } : {}),
roofsHidden: grid.roofsHidden,
wallsHidden: grid.wallsHidden,
...(input.capture?.output === 'separate' && grid.perFramePngs
@@ -2456,6 +2477,10 @@ export function createKilnAssetDefs(context: KilnToolContext): KilnToolDef[] {
author: z.string().max(200).optional(),
})
.optional(),
+ backdrop: z
+ .enum(BACKDROP_IDS as [BackdropId, ...BackdropId[]])
+ .optional()
+ .describe('Preview backdrop: the one the reviewed sheet used.'),
});
const assetsInput = z.object({
action: z.enum(['collections', 'list', 'get', 'restore']).default('list'),
@@ -2483,24 +2508,33 @@ export function createKilnAssetDefs(context: KilnToolContext): KilnToolDef[] {
{
name: 'kiln_save',
description:
- 'Save a completed source revision into the user-requested collection, or project when no destination was requested. Persists its exact GLB, source, preview, and build record. Discover destinations with kiln_assets action=collections. Use programRef returned by render/edit. To revise an existing asset, supply its assetId and parentRevision; previous revisions remain intact. Returns downloadable resources. Draft renders do not populate collections.',
+ 'Save a completed source revision into the user-requested collection, or project when none was requested. Persists exact GLB, source, preview and build record. Use programRef returned by render/edit. To revise an asset, pass assetId and parentRevision; earlier revisions stay intact. Returns downloadable resources; draft renders never populate collections.',
inputSchema: saveInput,
run: async (raw) => {
- const input = saveInput.parse(raw);
+ const { backdrop, ...input } = saveInput.parse(raw);
const target = library();
const code = await context.programStore!.get(input.programRef);
const rendered = await evaluateGeneratedSource(code, context);
let preview: Uint8Array | undefined;
let previewInfo: import('../assets').AssetManifest['preview'];
try {
- const result = await runRenderViews({ code } as z.infer<typeof renderViewsInput>, {
- ...context,
- evaluatorPort: { render: async () => rendered },
- });
+ // The preview is the default six-view sheet on the named backdrop, and
+ // the manifest records the one actually painted, so a preview reviewed
+ // on `dark` ships on `dark` and a reader never has to guess.
+ const result = await runRenderViews(
+ {
+ code,
+ ...(backdrop ? { capture: { backdrop } } : {}),
+ } as z.infer<typeof renderViewsInput>,
+ { ...context, evaluatorPort: { render: async () => rendered } },
+ );
if (!result.ok || !result.pngBase64)
throw new Error(result.error ?? 'Preview unavailable');
preview = Uint8Array.from(Buffer.from(result.pngBase64, 'base64'));
- previewInfo = { fidelity: result.viewFidelity };
+ previewInfo = {
+ fidelity: result.viewFidelity,
+ backdrop: result.capture?.backdrop ?? DEFAULT_BACKDROP_ID,
+ };
} catch (error) {
previewInfo = {
error: error instanceof Error ? error.message : String(error),
diff --git a/src/views/__tests__/backdrop.test.ts b/src/views/__tests__/backdrop.test.ts
new file mode 100644
index 00000000..a77041cd
--- /dev/null
+++ b/src/views/__tests__/backdrop.test.ts
@@ -0,0 +1,127 @@
+import { describe, expect, it } from 'bun:test';
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import {
+ BACKDROPS,
+ BACKDROP_IDS,
+ DEFAULT_BACKDROP_ID,
+ GRID_BACKGROUND_HEX,
+ GRID_BACKGROUND_RGB,
+ resolveBackdrop,
+} from '../background';
+import { coverage, rasterizeView } from '../raster';
+import { rasterizeCamera, cameraFromBounds } from '../camera';
+import { resolveCapture } from '../capture';
+import { BoxGeometry, Mesh, MeshStandardMaterial, Scene } from 'three';
+
+function darkCube(): Scene {
+ const scene = new Scene();
+ scene.add(new Mesh(new BoxGeometry(1, 1, 1), new MeshStandardMaterial({ color: 0x0a0a0a })));
+ return scene;
+}
+
+describe('backdrop table', () => {
+ it('defaults to the neutral studio grey measured against the example set', () => {
+ expect(DEFAULT_BACKDROP_ID).toBe('neutral');
+ expect(BACKDROPS.neutral.hex).toBe('#aab1bc');
+ expect(GRID_BACKGROUND_HEX).toBe(BACKDROPS.neutral.hex);
+ expect(GRID_BACKGROUND_RGB).toEqual(BACKDROPS.neutral.rgb);
+ });
+
+ it('keeps hex and rgb forms of every backdrop in agreement', () => {
+ for (const id of BACKDROP_IDS) {
+ const { rgb, hex } = BACKDROPS[id];
+ expect(hex).toBe(`#${rgb.map((c) => c.toString(16).padStart(2, '0')).join('')}`);
+ }
+ });
+
+ it('resolves an omitted id to the default and rejects an unknown one', () => {
+ expect(resolveBackdrop(undefined)).toBe(BACKDROPS.neutral);
+ expect(resolveBackdrop('dark').hex).toBe('#1a1a1a');
+ expect(() => resolveBackdrop('#ff00ff' as never)).toThrow(/backdrop/);
+ });
+
+ it('matches the render service table byte for byte', async () => {
+ const servicePath = join(
+ import.meta.dir,
+ '..',
+ '..',
+ '..',
+ 'render-service',
+ 'src',
+ 'backdrops.mjs',
+ );
+ const service = (await import(servicePath)) as {
+ BACKDROP_IDS: readonly string[];
+ BACKDROP_HEX: Record<string, string>;
+ DEFAULT_BACKDROP_ID: string;
+ };
+ expect([...service.BACKDROP_IDS]).toEqual([...BACKDROP_IDS]);
+ expect(service.DEFAULT_BACKDROP_ID).toBe(DEFAULT_BACKDROP_ID);
+ for (const id of BACKDROP_IDS) expect(service.BACKDROP_HEX[id]).toBe(BACKDROPS[id].hex);
+ // The GPU renderer paints from this table through its display transform, and
+ // the presentation presets carry no colour of their own, so there is no second
+ // source a GPU sheet could disagree with a CPU sheet about.
+ const serviceSrc = join(import.meta.dir, '..', '..', '..', 'render-service', 'src');
+ expect(readFileSync(join(serviceSrc, 'renderer.mjs'), 'utf8')).toContain(
+ 'backdropClearColor(BACKDROP_HEX[backdrop], preset.exposure)',
+ );
+ expect(readFileSync(join(serviceSrc, 'presentation-presets.mjs'), 'utf8')).not.toContain(
+ 'background',
+ );
+ });
+});
+
+describe('backdrop in the rasterizer', () => {
+ it('clears to the requested backdrop and coverage follows it', () => {
+ const size = 16;
+ const empty = new Scene();
+ const dark = rasterizeView(empty, [1, 0, 0], { size, backdrop: 'dark' });
+ expect([dark[0], dark[1], dark[2]]).toEqual([...BACKDROPS.dark.rgb]);
+ expect(coverage(dark, size, 'dark')).toBe(0);
+ // Measured against the wrong backdrop, every pixel looks filled.
+ expect(coverage(dark, size, 'neutral')).toBe(1);
+ const neutral = rasterizeView(empty, [1, 0, 0], { size });
+ expect([neutral[0], neutral[1], neutral[2]]).toEqual([...BACKDROPS.neutral.rgb]);
+ });
+
+ it('a near-black asset has a visible edge on the default backdrop', () => {
+ const size = 64;
+ const rgb = rasterizeView(darkCube(), [0.7, 0.5, 0.7], { size });
+ const bg = BACKDROPS.neutral.rgb;
+ let edge = 0;
+ let weak = 0;
+ for (let y = 1; y < size - 1; y++)
+ for (let x = 1; x < size - 1; x++) {
+ const i = y * size + x;
+ const isBg = (p: number) =>
+ rgb[p * 3] === bg[0] && rgb[p * 3 + 1] === bg[1] && rgb[p * 3 + 2] === bg[2];
+ if (isBg(i) || !(isBg(i - 1) || isBg(i + 1) || isBg(i - size) || isBg(i + size))) continue;
+ edge++;
+ const luma = 0.2126 * rgb[i * 3]! + 0.7152 * rgb[i * 3 + 1]! + 0.0722 * rgb[i * 3 + 2]!;
+ const bgLuma = 0.2126 * bg[0] + 0.7152 * bg[1] + 0.0722 * bg[2];
+ if (Math.abs(luma - bgLuma) < 40) weak++;
+ }
+ expect(edge).toBeGreaterThan(20);
+ expect(weak / edge).toBeLessThan(0.05);
+ });
+
+ it('the camera rasterizer honours the backdrop too', () => {
+ const scene = new Scene();
+ const camera = cameraFromBounds({ min: [-1, -1, -1], max: [1, 1, 1] }, [1, 0, 0]);
+ const rgb = rasterizeCamera(scene, camera, 8, true, 'light');
+ expect([rgb[0], rgb[1], rgb[2]]).toEqual([...BACKDROPS.light.rgb]);
+ });
+});
+
+describe('backdrop in the capture config', () => {
+ it('resolves to neutral by default and echoes an explicit choice', () => {
+ expect(resolveCapture(undefined).backdrop).toBe('neutral');
+ expect(resolveCapture({ preset: '1x1', backdrop: 'dark' }).backdrop).toBe('dark');
+ expect(resolveCapture({ backdrop: 'light' }).backdrop).toBe('light');
+ });
+
+ it('rejects an unknown backdrop with a message naming the choices', () => {
+ expect(() => resolveCapture({ backdrop: 'pink' as never })).toThrow(/neutral, dark, light/);
+ });
+});
diff --git a/src/views/__tests__/capture.test.ts b/src/views/__tests__/capture.test.ts
index e9051c4d..c66179ce 100644
--- a/src/views/__tests__/capture.test.ts
+++ b/src/views/__tests__/capture.test.ts
@@ -184,9 +184,9 @@ describe('resolveGridCapture', () => {
describe('grid background', () => {
it('the hex and rgb forms are the same color', () => {
- // The GPU render port sends the hex; the rasterizer clears to the rgb. They
- // drifted once (#202225 vs #1a1a1a) and the sheet's backdrop depended on
- // whether a serverless worker was warm.
+ // The GPU render port and the rasterizer resolve one named backdrop to one
+ // colour. They drifted once (#202225 vs #1a1a1a) and the sheet's backdrop
+ // depended on whether a serverless worker was warm.
const [r, g, b] = GRID_BACKGROUND_RGB;
expect(GRID_BACKGROUND_HEX).toBe(
`#${[r, g, b].map((c) => c.toString(16).padStart(2, '0')).join('')}`,
@@ -229,7 +229,7 @@ describe('renderViewGrid capture', () => {
expect(Buffer.from(explicitDefault.png).equals(Buffer.from(base.png))).toBe(true);
expect(Buffer.from(explicit3x2.png).equals(Buffer.from(base.png))).toBe(true);
expect(base.views).toEqual(['Front', 'Right', 'Back', 'Left', 'Top', '3/4']);
- expect(base.capture).toEqual({ preset: '3x2', cols: 3, cells: 6 });
+ expect(base.capture).toEqual({ preset: '3x2', cols: 3, cells: 6, backdrop: 'neutral' });
});
it('each preset composites to the right pixel dimensions', async () => {
diff --git a/src/views/__tests__/inspect.test.ts b/src/views/__tests__/inspect.test.ts
index 7ebb6ce1..fd40053a 100644
--- a/src/views/__tests__/inspect.test.ts
+++ b/src/views/__tests__/inspect.test.ts
@@ -13,6 +13,8 @@ import * as THREE from 'three';
import { renderInspectView, listPartNames, INSPECT_SIZE } from '../inspect';
import { executeKilnCode } from '../../render';
+import { GRID_BACKGROUND_RGB } from '../background';
+const BG = GRID_BACKGROUND_RGB;
// A small red core fully enclosed by a larger blue shell. From EVERY camera the
// shell covers the core, so this is the "buried part" the model cannot inspect
@@ -39,7 +41,7 @@ async function hueCounts(png: Buffer): Promise<{ red: number; blue: number; back
const r = data[i * info.channels]!;
const g = data[i * info.channels + 1]!;
const b = data[i * info.channels + 2]!;
- if (r === 26 && g === 26 && b === 26) background++;
+ if (r === BG[0] && g === BG[1] && b === BG[2]) background++;
else if (r > b) red++;
else if (b > r) blue++;
}
diff --git a/src/views/__tests__/views.test.ts b/src/views/__tests__/views.test.ts
index ca27a2a0..6ddcf100 100644
--- a/src/views/__tests__/views.test.ts
+++ b/src/views/__tests__/views.test.ts
@@ -12,6 +12,8 @@ import {
snapSceneToPalette,
} from '../index';
import { encodePng } from '../png';
+import { GRID_BACKGROUND_RGB } from '../background';
+const BG = GRID_BACKGROUND_RGB;
import { executeKilnCode } from '../../render';
import { GENERAL_RENDER_PALETTE, paletteToSnapSlots } from '../../palette';
import { hexToLinearRgb } from '../../palette-snap';
@@ -80,7 +82,7 @@ describe('rasterizeView', () => {
const reds = new Set<number>();
for (let i = 0; i < 128 * 128; i++) {
const r = rgb[i * 3]!;
- if (r !== 26) reds.add(r); // skip background
+ if (r !== GRID_BACKGROUND_RGB[0]) reds.add(r); // skip background
}
expect(reds.size).toBeGreaterThanOrEqual(2);
});
@@ -99,7 +101,7 @@ describe('rasterizeView', () => {
for (let y = 0; y < size; y++) {
for (let x = 0; x < size; x++) {
const i = (y * size + x) * 3;
- if (rgb[i] !== 26 || rgb[i + 1] !== 26 || rgb[i + 2] !== 26) {
+ if (rgb[i] !== BG[0] || rgb[i + 1] !== BG[1] || rgb[i + 2] !== BG[2]) {
if (x < minX) minX = x;
if (x > maxX) maxX = x;
if (y < minY) minY = y;
@@ -172,7 +174,7 @@ describe('rasterizeView', () => {
const r = rgb[i * 3]!;
const g = rgb[i * 3 + 1]!;
const b = rgb[i * 3 + 2]!;
- if (r === 26 && g === 26 && b === 26) continue; // background
+ if (r === BG[0] && g === BG[1] && b === BG[2]) continue; // background
if (r > 100 && b < 60) redPixels++;
if (b > 100 && r < 60) bluePixels++;
}
@@ -206,7 +208,7 @@ describe('rasterizeView', () => {
for (let i = 0; i < 32 * 32; i++) {
const r = rgb[i * 3]!;
const b = rgb[i * 3 + 2]!;
- if (r === 26 && rgb[i * 3 + 1] === 26 && b === 26) continue;
+ if (r === BG[0] && rgb[i * 3 + 1] === BG[1] && b === BG[2]) continue;
if (r > 100 && b < 60) redPixels++;
if (b > 100 && r < 60) bluePixels++;
}
diff --git a/src/views/background.ts b/src/views/background.ts
index be80d13c..84cb336e 100644
--- a/src/views/background.ts
+++ b/src/views/background.ts
@@ -1,20 +1,87 @@
/**
- * The one backdrop every view producer paints behind an asset.
+ * The backdrops every view producer paints behind an asset.
*
* Two producers make the same contact sheet — the CPU rasterizer here and the
* host GPU render port — and for a while they disagreed: the render service
* defaulted to `#202225` while the rasterizer painted `#1a1a1a`, so which
* backdrop a run's sheet came back on depended on nothing but whether a
- * serverless worker happened to be warm. Studio patched it by mirroring the
- * literal in its port, with a note to fold it into a shared constant here.
+ * serverless worker happened to be warm. The first fix pinned both to the
+ * near-black `#1a1a1a`, which kept them in agreement but read badly for dark
+ * assets: a black-lacquer mech on a near-black sheet loses its silhouette, tail
+ * and ground contact, which are the things the render tool asks the model to
+ * review.
*
- * This is that constant. A dependency-free leaf so both the rasterizer and the
- * port contract (`composer/render-port`) can import it without either subpath
- * pulling in the other.
+ * The default is now the neutral studio grey. It was chosen by measurement over
+ * the 86 checked-in examples plus a near-black test asset, scoring the WCAG
+ * contrast ratio of every silhouette-edge pixel on the CPU rasterizer against
+ * seven candidate colours. Near-black left 39.7% of edge pixels below 1.5:1 and
+ * 76 of 87 assets with a tenth-percentile edge contrast under 1.5:1; `#aab1bc`
+ * left 12.8% and 48. A lighter `#c8ccd2` was marginally better on average but
+ * lost the near-white assets outright, and `#aab1bc` is already the value the
+ * GPU studio preset was lit against, so choosing it also means a CPU fallback
+ * sheet and a GPU sheet share one backdrop.
+ *
+ * The model may name one of three fixed backdrops per capture. Free-form colour
+ * is deliberately not offered: cross-run comparability (arena, capture cache,
+ * reference comparison) assumes two sheets of the same GLB differ only because
+ * the asset does, and a backdrop close to the asset colour hides seams and gaps
+ * from exactly the reviewer being judged on them.
+ *
+ * A dependency-free leaf so both the rasterizer and the port contract
+ * (`composer/render-port`) can import it without either subpath pulling in the
+ * other. `render-service/src/backdrops.mjs` carries the same table for the GPU
+ * service; `src/views/__tests__/backdrop.test.ts` asserts the two agree.
*/
-/** Row-major RGB the rasterizer clears each cell to. */
-export const GRID_BACKGROUND_RGB: readonly [number, number, number] = [26, 26, 26];
+/** The bounded set of backdrops a capture may ask for. */
+export type BackdropId = 'neutral' | 'dark' | 'light';
+
+export const BACKDROP_IDS: readonly BackdropId[] = ['neutral', 'dark', 'light'] as const;
+
+/** The backdrop every producer paints when a capture names none. */
+export const DEFAULT_BACKDROP_ID: BackdropId = 'neutral';
+
+export interface Backdrop {
+ id: BackdropId;
+ /** Row-major RGB the rasterizer clears each cell to. */
+ rgb: readonly [number, number, number];
+ /** The same colour as lowercase CSS hex, for hosts whose render request takes a string. */
+ hex: string;
+}
+
+const define = (id: BackdropId, rgb: readonly [number, number, number]): Backdrop =>
+ Object.freeze({
+ id,
+ rgb: Object.freeze([...rgb]) as readonly [number, number, number],
+ hex: `#${rgb.map((c) => c.toString(16).padStart(2, '0')).join('')}`,
+ });
+
+export const BACKDROPS: Readonly<Record<BackdropId, Backdrop>> = Object.freeze({
+ /** Studio grey: the measured best worst-case across dark and light assets. */
+ neutral: define('neutral', [170, 177, 188]),
+ /** The former default. For near-white or emissive assets that wash out on grey. */
+ dark: define('dark', [26, 26, 26]),
+ /** For near-black assets whose silhouette still merges with the neutral grey. */
+ light: define('light', [223, 227, 232]),
+});
+
+export function isBackdropId(value: unknown): value is BackdropId {
+ return typeof value === 'string' && (BACKDROP_IDS as readonly string[]).includes(value);
+}
+
+/** Resolve an optional backdrop id to its colours; omitted means the default. */
+export function resolveBackdrop(id: BackdropId | undefined): Backdrop {
+ if (id === undefined) return BACKDROPS[DEFAULT_BACKDROP_ID];
+ if (!isBackdropId(id))
+ throw new Error(
+ `capture.backdrop must be one of ${BACKDROP_IDS.join(', ')} (got ${JSON.stringify(id)}).`,
+ );
+ return BACKDROPS[id];
+}
+
+/** The default backdrop's RGB. Kept for callers that predate the named table. */
+export const GRID_BACKGROUND_RGB: readonly [number, number, number] =
+ BACKDROPS[DEFAULT_BACKDROP_ID].rgb;
-/** The same color as CSS hex, for hosts whose render request takes a string. */
-export const GRID_BACKGROUND_HEX = '#1a1a1a';
+/** The default backdrop's hex. Kept for callers that predate the named table. */
+export const GRID_BACKGROUND_HEX = BACKDROPS[DEFAULT_BACKDROP_ID].hex;
diff --git a/src/views/camera-capture.ts b/src/views/camera-capture.ts
index 932ce9a3..dcacbfec 100644
--- a/src/views/camera-capture.ts
+++ b/src/views/camera-capture.ts
@@ -5,7 +5,7 @@ import {
withCameraVisibility,
type ResolvedCameraShotV1,
} from './camera';
-import type { CaptureConfig } from './capture';
+import { resolveCaptureBackdrop, type CaptureConfig } from './capture';
import type { DerivativeCellRenderer, ViewGridResult } from './index';
import { encodePng, decodePng } from './png';
import { compositeCellGrid } from './grid';
@@ -18,7 +18,7 @@ export interface CameraCaptureGridResult extends ViewGridResult {
}
export function validateAdvancedCapture(config: CaptureConfig): void {
for (const key of Object.keys(config))
- if (!['version', 'shots', 'cols', 'size', 'output'].includes(key))
+ if (!['version', 'shots', 'cols', 'size', 'output', 'backdrop'].includes(key))
throw new Error(`capture.${key} is unknown or incompatible with shots`);
if (config.version !== 'kiln.capture.v1')
throw new Error('advanced capture requires version kiln.capture.v1');
@@ -36,6 +36,7 @@ export function validateAdvancedCapture(config: CaptureConfig): void {
throw new Error('capture.size must be 128..1024');
if (config.output !== undefined && !['grid', 'separate'].includes(config.output))
throw new Error('capture.output must be grid or separate');
+ resolveCaptureBackdrop(config.backdrop);
}
export async function renderCaptureGrid(
root: unknown,
@@ -47,6 +48,7 @@ export async function renderCaptureGrid(
const shots = config.shots!.map((s) => resolveAssetCamera(root, s));
const size = config.size ?? 384;
const cols = config.cols ?? Math.min(3, shots.length);
+ const backdrop = resolveCaptureBackdrop(config.backdrop);
enforceCapturePixels(shots.length, size, cols, limits);
const cells: Uint8Array[] = [];
const perFramePngs: Buffer[] = [];
@@ -60,11 +62,18 @@ export async function renderCaptureGrid(
const view = { name: shot.name, dir };
const png = await withCameraVisibility(root, shot, async () => {
if (render) {
- const result = await render({ root, label: shot.name, view, size, camera: shot.camera });
+ const result = await render({
+ root,
+ label: shot.name,
+ view,
+ size,
+ camera: shot.camera,
+ backdrop,
+ });
derivativeReceipts.push(result.receipt);
return result.png;
}
- return encodePng(rasterizeCamera(root, shot.camera, size), size, size);
+ return encodePng(rasterizeCamera(root, shot.camera, size, true, backdrop), size, size);
});
const decoded = decodePng(png);
if (decoded.width !== size || decoded.height !== size)
@@ -81,7 +90,12 @@ export async function renderCaptureGrid(
width,
height,
views: shots.map((s) => s.name),
- capture: { preset: `${cols}x${Math.ceil(shots.length / cols)}`, cols, cells: shots.length },
+ capture: {
+ preset: `${cols}x${Math.ceil(shots.length / cols)}`,
+ cols,
+ cells: shots.length,
+ backdrop,
+ },
cameraShots: shots,
perFramePngs,
derivativeReceipts,
diff --git a/src/views/camera.ts b/src/views/camera.ts
index 77af55b1..dc5b7f2e 100644
--- a/src/views/camera.ts
+++ b/src/views/camera.ts
@@ -1,6 +1,6 @@
import { Vector3, Matrix4, Euler, type Object3D } from 'three';
import { collectTriangles, measureBounds, orbitDir } from './raster';
-import { GRID_BACKGROUND_RGB } from './background';
+import { resolveBackdrop, type BackdropId } from './background';
export type CameraVec3 = [number, number, number];
export type CameraBounds = { min: CameraVec3; max: CameraVec3 };
@@ -371,8 +371,10 @@ export function rasterizeCamera(
input: ResolvedAssetCameraV1,
size = 384,
backfaceCull = true,
+ backdrop?: BackdropId,
): Uint8Array {
const camera = validateResolvedAssetCamera(input);
+ const bg = resolveBackdrop(backdrop).rgb;
if (!Number.isInteger(size) || size < 1 || size > 2048)
throw new Error('camera size must be an integer in 1..2048');
const z = vec(camera.position).sub(vec(camera.target)).normalize(),
@@ -380,7 +382,7 @@ export function rasterizeCamera(
y = z.clone().cross(x),
position = vec(camera.position);
const out = new Uint8Array(size * size * 3);
- for (let i = 0; i < size * size; i++) out.set(GRID_BACKGROUND_RGB, i * 3);
+ for (let i = 0; i < size * size; i++) out.set(bg, i * 3);
const depth = new Float64Array(size * size).fill(Infinity);
const clip = (points: Vector3[], plane: number, near: boolean) => {
const result: Vector3[] = [];
diff --git a/src/views/capture-cache.ts b/src/views/capture-cache.ts
index 5be22a78..07a921f6 100644
--- a/src/views/capture-cache.ts
+++ b/src/views/capture-cache.ts
@@ -149,6 +149,7 @@ export function createCachedRenderPort(
width: request.width,
height: request.height,
lighting: request.lightingPresetId,
+ backdrop: request.backdrop,
}),
),
);
@@ -230,6 +231,8 @@ export interface CpuCaptureIdentity {
camera: ResolvedAssetCameraV1;
size: number;
backfaceCull?: boolean;
+ /** Painted backdrop; part of the key because the pixels differ per backdrop. */
+ backdrop?: import('./background').BackdropId;
}
/** CPU entries are explicitly geometry-flat and live in a different key namespace from GPU cells. */
export async function captureCpuCell(
diff --git a/src/views/capture.ts b/src/views/capture.ts
index 0daffee4..764990ff 100644
--- a/src/views/capture.ts
+++ b/src/views/capture.ts
@@ -24,6 +24,7 @@
*/
import { SIX_VIEWS, type ViewSpec, orbitAnglesOf, orbitDir, resolveGridViews } from './raster';
+import { BACKDROP_IDS, DEFAULT_BACKDROP_ID, isBackdropId, type BackdropId } from './background';
/** Grid shapes the model may ask for. `COLS x ROWS`. */
export type CapturePreset = '1x1' | '1x2' | '2x1' | '3x1' | '2x2' | '3x2' | '3x3';
@@ -62,6 +63,12 @@ export interface CaptureConfig {
output?: 'grid' | 'separate';
preset?: CapturePreset;
cells?: CaptureCell[];
+ /**
+ * Named backdrop behind every cell. Omit for the default. One of three fixed
+ * colours rather than a free hex, so sheets stay comparable across runs and a
+ * backdrop can never be tuned to hide a seam. See `views/background.ts`.
+ */
+ backdrop?: BackdropId;
}
/** Columns for each preset. Rows follow from the cell count. */
@@ -130,6 +137,8 @@ export interface ResolvedCapture {
zooms: Array<number | undefined>;
/** True when the result is the untouched shipped default. */
isDefault: boolean;
+ /** The backdrop every cell is painted on. */
+ backdrop: BackdropId;
}
/**
@@ -142,10 +151,22 @@ export interface CaptureShape {
preset: string;
cols: number;
cells: number;
+ /** Echoed so the model never has to guess what colour it is looking at. */
+ backdrop?: BackdropId;
}
export class CaptureConfigError extends Error {}
+/** Validate an optional backdrop id, naming the choices on a miss. */
+export function resolveCaptureBackdrop(backdrop: unknown): BackdropId {
+ if (backdrop === undefined) return DEFAULT_BACKDROP_ID;
+ if (!isBackdropId(backdrop))
+ throw new CaptureConfigError(
+ `capture.backdrop must be one of ${BACKDROP_IDS.join(', ')} (got ${JSON.stringify(backdrop)}).`,
+ );
+ return backdrop;
+}
+
/**
* Resolve a capture config into the view list, column count and per-cell zooms
* the grid renderer needs.
@@ -155,6 +176,7 @@ export class CaptureConfigError extends Error {}
* the model's only feedback channel.
*/
export function resolveCapture(config?: CaptureConfig): ResolvedCapture {
+ const backdrop = resolveCaptureBackdrop(config?.backdrop);
if (!config || (config.preset === undefined && config.cells === undefined)) {
return {
preset: DEFAULT_CAPTURE_PRESET,
@@ -162,6 +184,7 @@ export function resolveCapture(config?: CaptureConfig): ResolvedCapture {
cols: PRESET_COLS[DEFAULT_CAPTURE_PRESET],
zooms: new Array(PRESET_CAPACITY[DEFAULT_CAPTURE_PRESET]).fill(undefined),
isDefault: true,
+ backdrop,
};
}
@@ -217,6 +240,7 @@ export function resolveCapture(config?: CaptureConfig): ResolvedCapture {
cols: PRESET_COLS[preset],
zooms: cells.map((c) => c.zoom),
isDefault: false,
+ backdrop,
};
}
@@ -228,6 +252,7 @@ export function resolveCapture(config?: CaptureConfig): ResolvedCapture {
cols: PRESET_COLS[chosen],
zooms: new Array(PRESET_VIEWS[chosen].length).fill(undefined),
isDefault: chosen === DEFAULT_CAPTURE_PRESET,
+ backdrop,
};
}
diff --git a/src/views/index.ts b/src/views/index.ts
index b852c3d0..81d27cdd 100644
--- a/src/views/index.ts
+++ b/src/views/index.ts
@@ -1,4 +1,5 @@
import { enforceCapturePixels, enforceCaptureBytes, type CaptureLimits } from './capture-limits';
+import { DEFAULT_BACKDROP_ID } from './background';
export { DEFAULT_CAPTURE_LIMITS, resolveCaptureLimits } from './capture-limits';
export type { CaptureLimits } from './capture-limits';
import { captureCpuCell, type CaptureCache } from './capture-cache';
@@ -82,7 +83,16 @@ export {
} from './raster';
export type { RasterOptions, ViewSpec, ViewGridVariant } from './raster';
export { annotateViewCell, stampAxisGnomon } from './annotate';
-export { GRID_BACKGROUND_HEX, GRID_BACKGROUND_RGB } from './background';
+export {
+ BACKDROPS,
+ BACKDROP_IDS,
+ DEFAULT_BACKDROP_ID,
+ GRID_BACKGROUND_HEX,
+ GRID_BACKGROUND_RGB,
+ isBackdropId,
+ resolveBackdrop,
+} from './background';
+export type { Backdrop, BackdropId } from './background';
export { encodePng, decodePng } from './png';
export type { DecodedPng } from './png';
export {
@@ -361,6 +371,9 @@ export async function renderViewGrid(
// the byte-identity guarantee for the default grid.
const wantsZoom = resolved.zooms.some((z) => z !== undefined);
const sceneBounds = wantsZoom ? measureBounds(root) : undefined;
+ // An explicit raster option wins over the capture's backdrop, matching how
+ // `views`/`cols` already treat internal callers; both default to neutral.
+ const backdrop = opts.backdrop ?? resolved.backdrop;
const cache = opts.snapPalette?.length ? undefined : opts.captureCache;
let reused = 0;
@@ -370,6 +383,7 @@ export async function renderViewGrid(
const rasterOptions = {
size,
backfaceCull: opts.backfaceCull,
+ backdrop,
...(opts.frameBounds ? { frameBounds: opts.frameBounds } : {}),
...(sceneBounds && zoom !== undefined
? { frameBounds: expandFrameBounds(sceneBounds, zoom) }
@@ -390,6 +404,7 @@ export async function renderViewGrid(
camera,
size,
backfaceCull: opts.backfaceCull ?? true,
+ backdrop,
},
async () => ({
png: encodePng(rasterizeView(root, views[vi]!.dir, rasterOptions), size, size),
@@ -417,7 +432,7 @@ export async function renderViewGrid(
width,
height,
views: views.map((v) => v.name),
- capture: { preset: resolved.preset, cols, cells: views.length },
+ capture: { preset: resolved.preset, cols, cells: views.length, backdrop },
...(cache && opts.artifactGlbSha256
? { captureCache: { hit: reused === views.length, reused, total: views.length } }
: {}),
@@ -459,9 +474,10 @@ export async function renderGlbViewCell(
const loaded = await loadGlbGeometryFlatScene(exactBytes);
const size = options.size ?? 256;
const rgb = options.camera
- ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull)
+ ? rasterizeCamera(loaded.root, options.camera, size, options.backfaceCull, options.backdrop)
: rasterizeView(loaded.root, view.dir, {
size,
+ ...(options.backdrop ? { backdrop: options.backdrop } : {}),
...(options.backfaceCull !== undefined ? { backfaceCull: options.backfaceCull } : {}),
...(options.frameBounds ? { frameBounds: options.frameBounds } : {}),
});
@@ -591,6 +607,8 @@ export interface DerivativeCellRenderInput {
size: number;
backfaceCull?: boolean;
frameBounds?: { min: [number, number, number]; max: [number, number, number] };
+ /** Backdrop the cell must be painted on, by either producer. */
+ backdrop?: import('./background').BackdropId;
/** Stable reason to decline GPU when its auto-framing cannot honor this view. */
gpuUnsupportedReasonCode?: 'DERIVATIVE_GPU_FRAMING_UNSUPPORTED';
}
@@ -930,6 +948,14 @@ export async function renderInteriorGrid(
width,
height,
views: INTERIOR_VIEWS.map((v) => v.name),
+ // The fixed interior row paints the default backdrop; echo it the way every
+ // other grid does, so a reader never has to guess what a silhouette sat on.
+ capture: {
+ preset: 'interior',
+ cols: INTERIOR_VIEWS.length,
+ cells: INTERIOR_VIEWS.length,
+ backdrop: DEFAULT_BACKDROP_ID,
+ },
roofsHidden,
wallsHidden,
...(derivativeReceipts.length ? { derivativeReceipts } : {}),
diff --git a/src/views/port.ts b/src/views/port.ts
index e700a45e..5c34c131 100644
--- a/src/views/port.ts
+++ b/src/views/port.ts
@@ -66,6 +66,7 @@ export async function captureViewPngsViaPort(
size: number,
cameras?: readonly ResolvedAssetCameraV1[],
limits?: CaptureLimits,
+ backdrop?: import('./background').BackdropId,
): Promise<PortViewPngsOutcome> {
let timer: ReturnType<typeof setTimeout> | undefined;
try {
@@ -83,6 +84,7 @@ export async function captureViewPngsViaPort(
const result = await Promise.race([
port({
glb: requestGlb,
+ ...(backdrop ? { backdrop } : {}),
...(exactCameras
? { cameras: exactCameras, width: size, height: size }
: { viewDirs: viewDirs.map((dir) => [...dir] as [number, number, number]), size }),
@@ -201,6 +203,7 @@ export async function captureViewsViaPort(
input.size,
[input.camera!],
limits,
+ input.backdrop,
);
if (!result.ok) throw new Error(result.reason);
if (!result.derivativeFidelityAttested || !result.inputGlbSha256)
@@ -252,7 +255,12 @@ export async function captureViewsViaPort(
return { ok: false, reason: err instanceof Error ? err.message : String(err) };
}
const views = resolved.views;
- const shape: CaptureShape = { preset: resolved.preset, cols: resolved.cols, cells: views.length };
+ const shape: CaptureShape = {
+ preset: resolved.preset,
+ cols: resolved.cols,
+ cells: views.length,
+ backdrop: resolved.backdrop,
+ };
let cameras: ResolvedAssetCameraV1[] | undefined;
if (resolved.zooms.some((z) => z !== undefined)) {
@@ -274,6 +282,7 @@ export async function captureViewsViaPort(
384,
cameras,
limits,
+ resolved.backdrop,
);
if (!result.ok) return result;
try {
diff --git a/src/views/raster.ts b/src/views/raster.ts
index bb5c357c..2f5d91e6 100644
--- a/src/views/raster.ts
+++ b/src/views/raster.ts
@@ -20,7 +20,7 @@
* the offline audit grid) so inverted winding shows up as missing faces.
*/
-import { GRID_BACKGROUND_RGB } from './background';
+import { resolveBackdrop, type BackdropId } from './background';
export interface ViewSpec {
name: string;
@@ -119,10 +119,9 @@ export interface RasterOptions {
* geometry is still drawn; only the camera center/zoom come from this box.
*/
frameBounds?: { min: [number, number, number]; max: [number, number, number] };
+ /** Named backdrop to clear to. Omit for the default; see `views/background.ts`. */
+ backdrop?: BackdropId;
}
-
-// Shared with the GPU render port so both producers paint the same backdrop.
-const BG = GRID_BACKGROUND_RGB;
const AMBIENT = 0.25;
const KEY_INTENSITY = 1.1;
const KEY_DIR = normalize([1.5, 2, 1]);
@@ -312,6 +311,7 @@ export function rasterizeView(
): Uint8Array {
const size = opts.size ?? 256;
const cull = opts.backfaceCull ?? true;
+ const BG = resolveBackdrop(opts.backdrop).rgb;
const { tris, bbox } = collectTriangles(root as DuckObject3D);
const out = new Uint8Array(size * size * 3);
@@ -451,8 +451,13 @@ export function measureBounds(root: unknown): {
return { min: [...bbox.min], max: [...bbox.max] };
}
-/** Fraction of non-background pixels — used by tests and occupancy checks. */
-export function coverage(rgb: Uint8Array, size: number): number {
+/**
+ * Fraction of non-background pixels — used by tests and occupancy checks. The
+ * raster must be measured against the backdrop it was painted with, so pass the
+ * same `backdrop` the render used (omitted on both sides means the default).
+ */
+export function coverage(rgb: Uint8Array, size: number, backdrop?: BackdropId): number {
+ const BG = resolveBackdrop(backdrop).rgb;
let filled = 0;
for (let i = 0; i < size * size; i++) {
if (rgb[i * 3] !== BG[0] || rgb[i * 3 + 1] !== BG[1] || rgb[i * 3 + 2] !== BG[2]) filled++;