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.

Let a project declare where its modules stand, and measure them composed (#277) (#327)

Matthew Kissingerf8b1d810d377
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05244f54..d22469dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,20 @@ does not publish a package.
## Unreleased
+- Project inventory items can state where they stand, and a project can be measured as it is composed
+ (#277). `placement` on an inventory item holds optional `translation`, `rotation` (Euler XYZ degrees)
+ and `scale`; `{}` means the shared origin, and a missing placement means the item is not composed,
+ never identity. `kiln project check <id> [--revision <r>]` and `kiln_project` action `check` load the
+ exact pinned GLBs of the placed items, compose them on the host, and run the existing part-volume and
+ open-surface passes over cross-module pairs only, naming the module and part on each side with volume
+ or depth. `kiln_save` records the same report as `composition` and in `build.composition` when the
+ call's bound project pins this collection and asset at a placement, measuring the revision being saved
+ rather than the older pin. A pin that cannot be read is reported unmeasured with coverage `partial`,
+ never clear; a positive is a measurement rather than a verdict and never stops a save. Standalone
+ assets get no report and no warning. A draft is not measured until it is saved. The key is omitted when
+ absent, so existing project revisions keep their ids; a record that states one is refused by an engine
+ older than this one, whose project schema is strict. The `kiln_project` schema gains the action.
+
- Procedural materials have a periodic cellular (Worley/Voronoi) layer (#312). `op: 'cellular'` is a
V2 layer, so it also reaches V3 through `legacy-v2`: integer `cellsX`/`cellsY` per tile, a seed,
per-axis `jitterX`/`jitterY` and `metricX`/`metricY`, and optional additive `weight`. Its `feature`
diff --git a/biome.json b/biome.json
index 1e8b1bf0..ed5bead4 100644
--- a/biome.json
+++ b/biome.json
@@ -154,19 +154,6 @@
}
}
},
- {
- "includes": ["src/project-cli.ts"],
- "linter": {
- "rules": {
- "complexity": {
- "noExcessiveCognitiveComplexity": {
- "level": "error",
- "options": { "maxAllowedComplexity": 113 }
- }
- }
- }
- }
- },
{
"includes": ["src/geometry-export.ts"],
"linter": {
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index 8d18c95f..cee1c719 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -6054,6 +6054,7 @@ var init_assets = __esm(() => {
warnings: z6.array(z6.string()),
integration: z6.unknown().optional(),
qa: z6.unknown().optional(),
+ composition: z6.unknown().optional(),
dependencies: z6.array(z6.unknown()).optional(),
rebuild: z6.enum(["engine-required", "external-dependencies-required"])
}).optional(),
@@ -10287,7 +10288,7 @@ function checkContent(data, ctx) {
message: "Material role requires a locked resource"
});
}
-var MAX_PROJECT_BYTES, projectIdSchema, projectRevisionIdSchema, hash4, text6, resourceId2, assetReference, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectNotFoundError;
+var MAX_PROJECT_BYTES, projectIdSchema, projectRevisionIdSchema, hash4, text6, resourceId2, assetReference, placementNumber, placementVector, placementScale, inventoryPlacementSchema, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectNotFoundError;
var init_projects = __esm(() => {
MAX_PROJECT_BYTES = 1024 * 1024;
projectIdSchema = z10.string().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((value) => !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(value), "Reserved filesystem name");
@@ -10300,6 +10301,16 @@ var init_projects = __esm(() => {
assetId: projectIdSchema,
revisionId: projectIdSchema
}).strict();
+ placementNumber = z10.number().min(-1e6).max(1e6);
+ placementVector = z10.tuple([placementNumber, placementNumber, placementNumber]);
+ placementScale = placementNumber.min(-1000).max(1000).refine((value) => value !== 0, {
+ message: "A zero scale collapses the module."
+ });
+ inventoryPlacementSchema = z10.object({
+ translation: placementVector.optional(),
+ rotation: placementVector.optional(),
+ scale: z10.tuple([placementScale, placementScale, placementScale]).optional()
+ }).strict();
projectDesignSchema = z10.object({
style: text6.default(""),
scale: z10.string().max(1000).default(""),
@@ -10332,7 +10343,8 @@ var init_projects = __esm(() => {
kind: z10.enum(["asset", "environment"]).default("asset"),
brief: text6.default(""),
references: z10.array(projectIdSchema).max(64).default([]),
- asset: assetReference.optional()
+ asset: assetReference.optional(),
+ placement: inventoryPlacementSchema.optional()
}).strict()).max(1000).default([]),
deliveryProfiles: z10.array(z10.object({
id: projectIdSchema,
@@ -18126,7 +18138,7 @@ function inside(root, point, budget) {
}
return null;
}
-function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE) {
+function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE, options = {}) {
const evidence = {
schemaVersion: 1,
source: "engine-scene-analysis",
@@ -18149,11 +18161,15 @@ function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CON
const closed = parts.filter((part) => part.closed);
evidence.openParts = open.length;
evidence.closedParts = closed.length;
+ if (options.comparable)
+ evidence.openPartNames = open.map((part) => part.name);
const candidates = [];
let considered = 0;
broadPhase:
for (const surface of open) {
for (const solid of closed) {
+ if (options.comparable && !options.comparable(surface.mesh, solid.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
evidence.broadPhaseTruncated = true;
break broadPhase;
@@ -18692,7 +18708,7 @@ function meshToArrays(part) {
[tris[i + 1], tris[i + 2]] = [tris[i + 2], tris[i + 1]];
return { vertProperties: verts, triVerts: tris };
}
-async function analyzePartPenetration(root) {
+async function analyzePartPenetration(root, options = {}) {
const skipped = [];
const parts = collectParts4(root, skipped);
const base = {
@@ -18715,12 +18731,14 @@ async function analyzePartPenetration(root) {
broadPhase:
for (let i = 0;i < parts.length; i++) {
for (let j = i + 1;j < parts.length; j++) {
+ const a = parts[i];
+ const b = parts[j];
+ if (options.comparable && !options.comparable(a.mesh, b.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS2) {
base.broadPhaseTruncated = true;
break broadPhase;
}
- const a = parts[i];
- const b = parts[j];
if (!a.box.intersectsBox(b.box))
continue;
if (a.lod && b.lod && a.lod.parent === b.lod.parent && a.lod.stem === b.lod.stem && a.lod.level !== b.lod.level) {
@@ -40755,6 +40773,258 @@ var init_protocol = __esm(() => {
};
});
+// src/project-composition.ts
+import * as THREE60 from "three";
+function placementMatrix(placement) {
+ const [rx, ry, rz] = placement.rotation ?? [0, 0, 0];
+ return new THREE60.Matrix4().compose(new THREE60.Vector3(...placement.translation ?? [0, 0, 0]), new THREE60.Quaternion().setFromEuler(new THREE60.Euler(THREE60.MathUtils.degToRad(rx), THREE60.MathUtils.degToRad(ry), THREE60.MathUtils.degToRad(rz), "XYZ")), new THREE60.Vector3(...placement.scale ?? [1, 1, 1]));
+}
+function nameParts(name) {
+ const at = name.indexOf("/");
+ return { inventoryId: name.slice(0, at), part: name.slice(at + 1).slice(0, 200) };
+}
+function readFailure(item, error) {
+ const code = error?.code;
+ const message = error instanceof Error ? error.message : String(error);
+ const { collectionId, assetId, revisionId } = item.asset;
+ const pin = `${collectionId}/${assetId} at ${revisionId}`;
+ if (code === "ENOENT" || /Unknown collection/.test(message))
+ return {
+ inventoryId: item.id,
+ reason: "unavailable",
+ detail: `The pinned revision ${pin} is not in the configured collections.`
+ };
+ return {
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The pinned revision ${pin} could not be read (${code ?? message}).`
+ };
+}
+async function composeModule(moduleOf, index, item, glb) {
+ const loaded = (await loadGlbReviewScene(glb)).root;
+ const group = new THREE60.Group;
+ group.matrix.copy(placementMatrix(item.placement));
+ group.matrixAutoUpdate = false;
+ group.add(loaded);
+ let parts = 0;
+ let lodExcluded = 0;
+ loaded.traverse((node) => {
+ const mesh = node;
+ if (!mesh.isMesh)
+ return;
+ if ((lodLevel(mesh) ?? 0) > 0) {
+ mesh.visible = false;
+ lodExcluded++;
+ }
+ moduleOf.set(mesh, index);
+ mesh.name = moduleName(item.id, mesh.name || "(unnamed mesh)");
+ parts++;
+ });
+ return { parts, lodExcluded, group };
+}
+function failedCompositionReport(project, error) {
+ return {
+ ...emptyReport(project),
+ coverage: "failed",
+ error: error instanceof Error ? error.message : String(error)
+ };
+}
+function emptyReport(project) {
+ return {
+ schemaVersion: 1,
+ source: "host-composed-scene",
+ projectId: project.projectId,
+ projectRevision: project.revisionId,
+ coverage: "nothing-to-compare",
+ modules: [],
+ notComposed: { count: 0, ids: [] },
+ unmeasured: [],
+ overlaps: [],
+ overlapsOmitted: 0,
+ openSurfaces: [],
+ openSurfacesOmitted: 0,
+ unmeasuredParts: [],
+ unmeasuredPartsOmitted: 0,
+ lodAlternatesExcluded: 0,
+ solids: { candidatePairs: 0, pairsTested: 0, pairsUnmeasurable: 0, pairsNotReached: 0 },
+ surfaces: { candidatePairs: 0, pairsTested: 0, pairsNotReached: 0, verticesUnresolved: 0 },
+ truncated: false,
+ note: COMPOSITION_NOTE
+ };
+}
+async function composeProjectModules(project, library, options = {}) {
+ const limits = { ...PROJECT_COMPOSITION_LIMITS, ...options.limits };
+ const report = emptyReport(project);
+ const { subject } = options;
+ const holdsSubject = (item) => subject !== undefined && item.asset?.collectionId === subject.collectionId && item.asset.assetId === subject.assetId;
+ const placed = project.inventory.filter((item) => item.placement);
+ const outside = project.inventory.filter((item) => !item.placement);
+ report.notComposed = {
+ count: outside.length,
+ ids: outside.slice(0, limits.maxListed).map((item) => item.id)
+ };
+ const held = placed.filter(holdsSubject);
+ if (subject)
+ report.subject = held.map((item) => item.id);
+ const scene = new THREE60.Group;
+ const moduleOf = new Map;
+ const subjectModules = new Set;
+ let bytes = 0;
+ let parts = 0;
+ let exhausted = false;
+ const overBudget = (item, detail) => {
+ exhausted = true;
+ report.unmeasured.push({ inventoryId: item.id, reason: "budget", detail });
+ };
+ for (const item of [...held, ...placed.filter((item) => !holdsSubject(item))]) {
+ if (!item.asset) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unpinned",
+ detail: "This item states a placement but links no saved revision."
+ });
+ continue;
+ }
+ if (exhausted || report.modules.length >= limits.maxModules) {
+ overBudget(item, `Not loaded: the check composes at most ${limits.maxModules} modules, ${limits.maxBytes} bytes and ${limits.maxParts} parts.`);
+ continue;
+ }
+ const saved = holdsSubject(item);
+ let glb;
+ if (saved)
+ glb = subject.glb;
+ else {
+ try {
+ const { collectionId, assetId, revisionId } = item.asset;
+ glb = (await library.read(collectionId, assetId, revisionId)).files["asset.glb"];
+ } catch (error) {
+ report.unmeasured.push(readFailure(item, error));
+ continue;
+ }
+ if (!glb) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: "The pinned revision has no asset.glb."
+ });
+ continue;
+ }
+ }
+ if (bytes + glb.length > limits.maxBytes) {
+ overBudget(item, `Not loaded: the check loads at most ${limits.maxBytes} GLB bytes.`);
+ continue;
+ }
+ bytes += glb.length;
+ let module;
+ try {
+ module = await composeModule(moduleOf, report.modules.length, item, glb);
+ } catch (error) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The GLB could not be loaded (${error instanceof Error ? error.message : String(error)}).`
+ });
+ continue;
+ }
+ if (parts + module.parts > limits.maxParts) {
+ overBudget(item, `Not composed: the check composes at most ${limits.maxParts} parts.`);
+ continue;
+ }
+ parts += module.parts;
+ report.lodAlternatesExcluded += module.lodExcluded;
+ scene.add(module.group);
+ if (saved)
+ subjectModules.add(report.modules.length);
+ report.modules.push({
+ inventoryId: item.id,
+ collectionId: item.asset.collectionId,
+ assetId: item.asset.assetId,
+ ...saved ? { saved: true } : { revisionId: item.asset.revisionId },
+ parts: module.parts
+ });
+ }
+ let failed = false;
+ if (report.modules.length >= 2) {
+ const comparable = (a, b) => {
+ const left = moduleOf.get(a);
+ const right = moduleOf.get(b);
+ if (left === right)
+ return false;
+ return !subject || subjectModules.has(left) || subjectModules.has(right);
+ };
+ const unmeasured = [];
+ let open = new Set;
+ try {
+ const surfaces = analyzeOpenSurfacePenetration(scene, undefined, { comparable });
+ open = new Set(surfaces.openPartNames);
+ report.surfaces = {
+ candidatePairs: surfaces.candidatePairs,
+ pairsTested: surfaces.pairsTested,
+ pairsNotReached: surfaces.pairsNotReached,
+ verticesUnresolved: surfaces.verticesUnresolved
+ };
+ report.truncated ||= surfaces.truncated;
+ report.openSurfaces = surfaces.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ open: nameParts(pair.open),
+ solid: nameParts(pair.solid),
+ depth: pair.depth,
+ vertices: pair.vertices,
+ tested: pair.tested
+ }));
+ report.openSurfacesOmitted = surfaces.penetrations.length - report.openSurfaces.length;
+ for (const { part, reason } of surfaces.skipped)
+ unmeasured.push({ ...nameParts(part), pass: "surfaces", reason });
+ } catch {
+ report.surfaces.failed = true;
+ failed = true;
+ }
+ try {
+ const solids = await analyzePartPenetration(scene, { comparable });
+ report.solids = {
+ candidatePairs: solids.candidatePairs,
+ pairsTested: solids.pairsTested,
+ pairsUnmeasurable: solids.pairsUnmeasurable,
+ pairsNotReached: solids.pairsNotReached
+ };
+ report.truncated ||= solids.truncated;
+ report.overlaps = solids.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ a: nameParts(pair.a),
+ b: nameParts(pair.b),
+ volume: pair.volume,
+ fraction: pair.fraction
+ }));
+ report.overlapsOmitted = solids.penetrations.length - report.overlaps.length;
+ for (const { part, reason } of [...solids.skipped, ...solids.acknowledged ?? []])
+ if (!open.has(part))
+ unmeasured.push({ ...nameParts(part), pass: "solids", reason });
+ } catch {
+ report.solids.failed = true;
+ failed = true;
+ }
+ report.unmeasuredParts = unmeasured.slice(0, limits.maxListed);
+ report.unmeasuredPartsOmitted = unmeasured.length - report.unmeasuredParts.length;
+ report.truncated ||= report.overlapsOmitted > 0 || report.openSurfacesOmitted > 0;
+ failed ||= unmeasured.length > 0;
+ }
+ report.truncated ||= exhausted;
+ report.coverage = failed || report.truncated || report.unmeasured.length > 0 ? "partial" : report.modules.length < 2 ? "nothing-to-compare" : "complete";
+ return report;
+}
+var PROJECT_COMPOSITION_LIMITS, COMPOSITION_NOTE = "A positive is a measurement, not a verdict: a fitting socketed into a neighbour is reported as a bolt in a hole is. Measured at rest over visible static parts; open surfaces are not measured against each other, and a solid thinner than a surface’s facet spacing can pass between its vertices. A clean result is not a fit audit.", moduleName = (inventoryId, part) => `${inventoryId}/${part}`;
+var init_project_composition = __esm(() => {
+ init_lod2();
+ init_open_surface_penetration();
+ init_self_intersection();
+ init_glb();
+ PROJECT_COMPOSITION_LIMITS = Object.freeze({
+ maxModules: 64,
+ maxBytes: 256 * 1024 * 1024,
+ maxParts: 4096,
+ maxReportedPairs: 100,
+ maxListed: 32
+ });
+});
+
// src/texture-sharing.ts
var init_texture_sharing = __esm(() => {
init_runtime_textures();
@@ -41266,12 +41536,12 @@ var exports_part_placement = {};
__export(exports_part_placement, {
createPartPlacementReader: () => createPartPlacementReader
});
-import * as THREE60 from "three";
+import * as THREE61 from "three";
function createPartPlacementReader(root) {
const bounds = createPartBoundsReader(root);
- const position = new THREE60.Vector3;
- const quaternion = new THREE60.Quaternion;
- const scale = new THREE60.Vector3;
+ const position = new THREE61.Vector3;
+ const quaternion = new THREE61.Quaternion;
+ const scale = new THREE61.Vector3;
return (node) => {
node.matrixWorld.decompose(position, quaternion, scale);
const box = bounds(node);
@@ -41422,7 +41692,7 @@ var init_inspect = __esm(() => {
});
// src/views/measurement.ts
-import { Box3 as Box328, Vector3 as Vector347 } from "three";
+import { Box3 as Box328, Vector3 as Vector348 } from "three";
function describeSubjectFrame(root, subject) {
const selected = selectCameraSubject(root, subject);
selected.node.updateWorldMatrix(true, true);
@@ -41439,10 +41709,10 @@ function describeSubjectFrame(root, subject) {
if (!attr)
return;
for (let i = 0;i < attr.count; i++)
- local.expandByPoint(new Vector347().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
+ local.expandByPoint(new Vector348().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
});
const box = (b) => b.isEmpty() ? null : { min: b.min.toArray(), max: b.max.toArray() };
- const axis = (i) => new Vector347().setFromMatrixColumn(matrix, i).normalize().toArray();
+ const axis = (i) => new Vector348().setFromMatrixColumn(matrix, i).normalize().toArray();
return {
path: selected.path,
name: selected.name,
@@ -41452,7 +41722,7 @@ function describeSubjectFrame(root, subject) {
invertible,
worldMatrix: matrix.toArray(),
axes: { frame: "world", x: axis(0), y: axis(1), z: axis(2) },
- origin: new Vector347().setFromMatrixPosition(matrix).toArray()
+ origin: new Vector348().setFromMatrixPosition(matrix).toArray()
};
}
function measureAttachment(root, input) {
@@ -41465,7 +41735,7 @@ function measureAttachment(root, input) {
return {
path: selected.path,
local: [...local],
- world: new Vector347(...local).applyMatrix4(selected.node.matrixWorld).toArray()
+ world: new Vector348(...local).applyMatrix4(selected.node.matrixWorld).toArray()
};
};
const from = endpoint(input.from), to = endpoint(input.to);
@@ -41475,7 +41745,7 @@ function measureAttachment(root, input) {
method: "straight-line anchor distance",
from,
to,
- distance: new Vector347(...from.world).distanceTo(new Vector347(...to.world))
+ distance: new Vector348(...from.world).distanceTo(new Vector348(...to.world))
};
}
var init_measurement = __esm(() => {
@@ -41487,7 +41757,7 @@ import {
PropertyType as PropertyType6
} from "@gltf-transform/core";
import { ALL_EXTENSIONS as ALL_EXTENSIONS2 } from "@gltf-transform/extensions";
-import { Box3 as Box329, Matrix4 as Matrix419, Quaternion as Quaternion23, Vector3 as Vector348 } from "three";
+import { Box3 as Box329, Matrix4 as Matrix420, Quaternion as Quaternion24, Vector3 as Vector349 } from "three";
async function accessorFingerprint(accessor) {
const array = accessor?.getArray();
if (!accessor || !array)
@@ -41506,7 +41776,7 @@ function bounds(box) {
return box.isEmpty() ? null : {
min: box.min.toArray(),
max: box.max.toArray(),
- size: box.getSize(new Vector348).toArray()
+ size: box.getSize(new Vector349).toArray()
};
}
async function digest3(bytes) {
@@ -41514,7 +41784,7 @@ async function digest3(bytes) {
return `sha256:${[...hash].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
}
function placements(node) {
- const world = new Matrix419().fromArray(node.getWorldMatrix());
+ const world = new Matrix420().fromArray(node.getWorldMatrix());
const instances = node.getExtension("EXT_mesh_gpu_instancing");
if (!instances)
return [world];
@@ -41522,7 +41792,7 @@ function placements(node) {
const rotation = instances.getAttribute("ROTATION");
const scale = instances.getAttribute("SCALE");
const count = translation?.getCount() ?? rotation?.getCount() ?? scale?.getCount() ?? 1;
- return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix419().compose(new Vector348().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion23().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector348().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
+ return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix420().compose(new Vector349().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion24().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector349().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
}
function triangleCorners(mode, count) {
const corners = [];
@@ -41589,7 +41859,7 @@ async function drawnGeometryDigests(doc) {
}
const data = new Float32Array(triangles * RECORD);
const others = [];
- const point = new Vector348;
+ const point = new Vector349;
const element = [0, 0, 0];
const texcoord = [0, 0];
const corner = new Float32Array(15);
@@ -41672,7 +41942,7 @@ async function revisionTotals(doc) {
const { vertices, geometry, uv } = await drawnGeometryDigests(doc);
const scene = doc.getRoot().getDefaultScene() ?? doc.getRoot().listScenes()[0];
const drawnBounds = scene ? drawnSceneBounds(scene) : null;
- const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector348(...drawnBounds.min), new Vector348(...drawnBounds.max)) : new Box329;
+ const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector349(...drawnBounds.min), new Vector349(...drawnBounds.max)) : new Box329;
return {
triangles: metrics.triangles,
vertices,
@@ -41765,7 +42035,7 @@ async function snapshot3(bytes) {
throw new Error("Revision comparison does not support node/mesh extensions (including instancing).");
const primitives = mesh?.listPrimitives() ?? [];
const own = new Box329;
- const matrix = parentWorld.clone().multiply(new Matrix419().fromArray(node.getMatrix()));
+ const matrix = parentWorld.clone().multiply(new Matrix420().fromArray(node.getMatrix()));
if (matrix.elements.some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite transforms.");
for (const primitive of primitives) {
@@ -41785,7 +42055,7 @@ async function snapshot3(bytes) {
if (!Number.isInteger(vertex) || vertex < 0 || vertex >= position.getCount())
throw new Error("Revision comparison found an invalid vertex index.");
position.getElement(vertex, element);
- const point = new Vector348(...element).applyMatrix4(matrix);
+ const point = new Vector349(...element).applyMatrix4(matrix);
if (point.toArray().some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite positions.");
own.expandByPoint(point);
@@ -41804,7 +42074,7 @@ async function snapshot3(bytes) {
if (scenes[0].listExtensions().length)
throw new Error("Revision comparison does not support scene extensions.");
const scenePath = `/${encodeURIComponent(scenes[0].getName() || "Scene")}[0]`;
- const box = visit(scenes[0].listChildren(), "", 0, new Matrix419);
+ const box = visit(scenes[0].listChildren(), "", 0, new Matrix420);
const nodePaths = new Map([...parts].map(([path, part]) => [part.node, path]));
const animation = new Map;
const clipNames = new Set;
@@ -41986,10 +42256,10 @@ var init_revision_comparison = __esm(() => {
// src/views/surface-distance.ts
import {
Box3 as Box330,
- Matrix4 as Matrix420,
+ Matrix4 as Matrix421,
Ray as Ray3,
Triangle as Triangle3,
- Vector3 as Vector349
+ Vector3 as Vector350
} from "three";
function hierarchy(triangles) {
const box = new Box330;
@@ -41998,7 +42268,7 @@ function hierarchy(triangles) {
const count = triangles.length;
if (count <= 4)
return { box, count, triangles };
- const size = box.getSize(new Vector349);
+ const size = box.getSize(new Vector350);
const axis = size.x >= size.y && size.x >= size.z ? "x" : size.y >= size.z ? "y" : "z";
const center = (triangle) => triangle.box.min[axis] / 2 + triangle.box.max[axis] / 2;
triangles.sort((a, b) => center(a) - center(b));
@@ -42041,7 +42311,7 @@ function collect(node, paths) {
for (let instance = 0;instance < instances; instance++) {
const matrix = mesh.matrixWorld.clone();
if (instanced.isInstancedMesh) {
- const local = new Matrix420;
+ const local = new Matrix421;
instanced.getMatrixAt(instance, local);
matrix.multiply(local);
}
@@ -42050,7 +42320,7 @@ function collect(node, paths) {
const id = index ? index.getX(i + offset) : i + offset;
if (!Number.isSafeInteger(id) || id < 0 || id >= position.count)
throw new Error("Surface distance encountered an invalid triangle index.");
- const point = new Vector349().fromBufferAttribute(position, id).applyMatrix4(matrix);
+ const point = new Vector350().fromBufferAttribute(position, id).applyMatrix4(matrix);
if (![point.x, point.y, point.z].every(Number.isFinite))
throw new Error("Surface distance encountered a non-finite world position.");
return point;
@@ -42109,10 +42379,10 @@ function trianglePair(a, b) {
const av = [a.a, a.b, a.c], bv = [b.a, b.b, b.c];
if (b.getArea() > 0)
for (const p of av)
- record(p, b.closestPointToPoint(p, new Vector349));
+ record(p, b.closestPointToPoint(p, new Vector350));
if (a.getArea() > 0)
for (const q of bv)
- record(a.closestPointToPoint(q, new Vector349), q);
+ record(a.closestPointToPoint(q, new Vector350), q);
for (let i = 0;i < 3; i++) {
const p = av[i], q = av[(i + 1) % 3];
for (let j = 0;j < 3; j++)
@@ -42125,9 +42395,9 @@ function trianglePair(a, b) {
const length = delta.length();
if (length === 0)
continue;
- const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector349);
+ const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector350);
if (hit && origin.distanceTo(hit) <= length) {
- const onFace = target.closestPointToPoint(hit, new Vector349);
+ const onFace = target.closestPointToPoint(hit, new Vector350);
if (vertices === av)
record(hit, onFace);
else
@@ -42293,7 +42563,7 @@ __export(exports_draw_diagnostics, {
});
import { Primitive as Primitive3 } from "@gltf-transform/core";
import { cloneDocument as cloneDocument2 } from "@gltf-transform/functions";
-import * as THREE61 from "three";
+import * as THREE62 from "three";
function withinLimits(doc) {
const root = doc.getRoot();
if (root.listNodes().length > MAX_NODES2 || root.listAccessors().length > 4096 || root.listMaterials().length > 2048 || root.listTextures().length > 256 || root.listScenes().length > 32 || doc.getGraph().listEdges().length > 32768)
@@ -42346,7 +42616,7 @@ function collect2(doc, keep) {
function overlaps(a, b) {
if (Math.abs(a.normal.dot(b.normal)) < 1 - 0.00000001 || !a.bounds.intersectsBox(b.bounds))
return false;
- const tolerance = Math.max(a.bounds.getSize(new THREE61.Vector3).length(), b.bounds.getSize(new THREE61.Vector3).length(), 0.000000000001) * 0.000001;
+ const tolerance = Math.max(a.bounds.getSize(new THREE62.Vector3).length(), b.bounds.getSize(new THREE62.Vector3).length(), 0.000000000001) * 0.000001;
if (b.points.some((p) => Math.abs(a.normal.dot(p.clone().sub(a.points[0]))) > tolerance))
return false;
const normal = a.normal.toArray().map(Math.abs);
@@ -42388,7 +42658,7 @@ function observe(uses) {
unexaminedPrimitiveUses++;
continue;
}
- const matrix = new THREE61.Matrix4().fromArray(node.getWorldMatrix());
+ const matrix = new THREE62.Matrix4().fromArray(node.getWorldMatrix());
if (primitive.getAttribute("TANGENT") && matrix.determinant() < 0)
mirrored.set(part.id, part);
const position = primitive.getAttribute("POSITION");
@@ -42402,14 +42672,14 @@ function observe(uses) {
const amount = Math.min(count, 8, MAX_SAMPLES - samples.length);
for (let i = 0;i < amount; i++) {
const start = Math.floor(i * count / amount) * 3;
- const points = [0, 1, 2].map((j) => new THREE61.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
+ const points = [0, 1, 2].map((j) => new THREE62.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
const normal = points[1].clone().sub(points[0]).cross(points[2].clone().sub(points[0]));
if (!Number.isFinite(normal.lengthSq()) || normal.lengthSq() === 0)
continue;
samples.push({
points,
normal: normal.normalize(),
- bounds: new THREE61.Box3().setFromPoints(points),
+ bounds: new THREE62.Box3().setFromPoints(points),
part
});
}
@@ -48255,7 +48525,7 @@ function flattenIssuePaths(issues, prefix = []) {
}
// src/tools/projects.ts
-var PROJECT_ACTIONS = ["list", "get", "create", "update", "export"];
+var PROJECT_ACTIONS = ["list", "get", "create", "update", "export", "check"];
var REQUIREMENTS = {
list: { required: [] },
get: { required: ["projectId"] },
@@ -48264,25 +48534,26 @@ var REQUIREMENTS = {
required: ["projectId", "expectedRevision", "patch"],
shapes: { patch: "shape:project-patch" }
},
- export: { required: ["projectId"] }
+ export: { required: ["projectId"] },
+ check: { required: ["projectId"] }
};
var record10 = (description) => z16.record(z16.string(), z16.unknown()).optional().describe(description);
function projectToolInput(actions = PROJECT_ACTIONS) {
return z16.strictObject({
action: z16.enum(actions),
- projectId: projectIdSchema.optional().describe("get, update, export."),
- revisionId: projectRevisionIdSchema.optional().describe("get, export: an exact revision; omit for the current one."),
+ projectId: projectIdSchema.optional().describe("get, update, export, check."),
+ revisionId: projectRevisionIdSchema.optional().describe("get, export, check: an exact revision; omit for the current one."),
expectedRevision: projectRevisionIdSchema.optional().describe("update: the revision being replaced; a stale value is a conflict."),
draft: record10(nestedRecordDescription("create: name, brief, design, inventory, deliveryProfiles, materialDependencies, references, reviews; optional projectId.", "shape:project-draft")),
patch: record10(nestedRecordDescription("update: the same top-level fields as draft; each supplied field replaces its previous value whole.", "shape:project-patch")),
profile: z16.enum(["editable", "runtime"]).optional().describe("export: editable (default) keeps source and resources; runtime is GLB plus metadata.")
});
}
-function createKilnProjectDef(store, bundleReader) {
- const schema = projectToolInput(bundleReader ? PROJECT_ACTIONS : PROJECT_ACTIONS.filter((action) => action !== "export"));
+function createKilnProjectDef(store, bundleReader, assetLibrary) {
+ const schema = projectToolInput(PROJECT_ACTIONS.filter((action) => (action !== "export" || bundleReader) && (action !== "check" || assetLibrary)));
return {
name: "kiln_project",
- description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : ""),
+ description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : "") + (assetLibrary ? " check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict." : ""),
inputSchema: schema,
annotations: {
readOnlyHint: false,
@@ -48315,6 +48586,13 @@ function createKilnProjectDef(store, bundleReader) {
ok: true,
project: await store.update(input.projectId, input.expectedRevision, projectPatchSchema.parse(input.patch))
};
+ case "check": {
+ await Promise.resolve().then(() => init_project_composition());
+ return {
+ ok: true,
+ composition: await composeProjectModules(await store.read(input.projectId, input.revisionId), assetLibrary)
+ };
+ }
case "export": {
const profile = input.profile ?? "editable";
const project = await store.read(input.projectId, input.revisionId);
@@ -49550,7 +49828,7 @@ function createCachedEvaluatorPort(evaluator, options) {
// src/tools/registry.ts
init_validation();
-import * as THREE62 from "three";
+import * as THREE63 from "three";
// src/evaluator/source-check.ts
init_validation();
@@ -50195,8 +50473,8 @@ function collectSceneMetrics(root) {
let meshes = 0;
const materialSet = new Set;
let lowestPart;
- const box = new THREE62.Box3;
- const point = new THREE62.Vector3;
+ const box = new THREE63.Box3;
+ const point = new THREE63.Vector3;
root.updateWorldMatrix(true, true);
root.traverseVisible((node) => {
const n = node;
@@ -50212,7 +50490,7 @@ function collectSceneMetrics(root) {
const mesh = node;
const position = mesh.geometry.getAttribute("position");
const index = mesh.geometry.index;
- const mb = new THREE62.Box3;
+ const mb = new THREE63.Box3;
if (position) {
for (let i = 0;i < (index?.count ?? position.count); i++) {
point.fromBufferAttribute(position, index ? index.getX(i) : i);
@@ -50227,7 +50505,7 @@ function collectSceneMetrics(root) {
});
let bbox;
if (!box.isEmpty()) {
- const size = new THREE62.Vector3;
+ const size = new THREE63.Vector3;
box.getSize(size);
bbox = {
min: [box.min.x, box.min.y, box.min.z],
@@ -51114,7 +51392,9 @@ function createProgramDefs(suppliedContext, presentation) {
createKilnEditDef(context)
].map((def) => withProgramReferences(def, store, context.readSourceFile)),
createKilnSourceDef(store),
- ...context.projectStore ? [createKilnProjectDef(context.projectStore, context.projectBundleReader)] : [],
+ ...context.projectStore ? [
+ createKilnProjectDef(context.projectStore, context.projectBundleReader, context.assetLibrary)
+ ] : [],
...context.materialLibrary ? [createKilnMaterialDef(context.materialLibrary, presentation)] : [],
...context.reviewStore && context.assetLibrary ? [
createKilnReviewDef({
@@ -51279,6 +51559,19 @@ async function parentRevisionComparison(parent, child) {
};
}
}
+async function savedComposition(context, library, { collection, assetId }, glb) {
+ const project = context.workspace?.current()?.project;
+ if (!project || !assetId || !project.inventory.some(({ asset, placement }) => placement && asset?.collectionId === collection && asset.assetId === assetId))
+ return;
+ await Promise.resolve().then(() => init_project_composition());
+ try {
+ return await composeProjectModules(project, library, {
+ subject: { collectionId: collection, assetId, glb }
+ });
+ } catch (error) {
+ return failedCompositionReport(project, error);
+ }
+}
async function buildProgramGlb(programRef, context) {
if (!context.programStore)
throw new Error("Building a programRef requires a program store.");
@@ -51443,9 +51736,15 @@ function createKilnAssetDefs(context, presentation = "grouped") {
}
const code = await context.programStore.get(input.programRef);
const draft = await buildProgramAssetDraft(code, callContext, backdrop);
- const asset = await target.save(input.collection, { ...input, ...draft });
+ const composition = await savedComposition(context, target, input, draft.glb);
+ const asset = await target.save(input.collection, {
+ ...input,
+ ...draft,
+ ...composition ? { build: { ...draft.build, composition } } : {}
+ });
return {
...await links(input.collection, asset),
+ ...composition ? { composition } : {},
...parent ? { comparison: await parentRevisionComparison(parent.files["asset.glb"], draft.glb) } : {}
};
}
diff --git a/dist/build.json b/dist/build.json
index 821779b7..d7d4d3fc 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -37,13 +37,13 @@
},
"target": "node",
"file": "evaluator-worker.mjs",
- "bundleHash": "sha256:b077c0896cc118dccea90f1d844b84bb4408d0ed2ad3060f8d4d7c43a22dfb47"
+ "bundleHash": "sha256:4490920e6f6d45845c108527d3da1f4b6fb7f77c01ae5679ce80c6b3134ccb35"
},
"agent-run": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -75,13 +75,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:c931aae6946317bf3f5dc998f1de0a45c4370461aa698428c16b7523b0d01769"
+ "bundleHash": "sha256:292085972dde02bd49c7df4cc749355289accef7538a6d1627c121594ee81cf1"
},
"agent-providers": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -116,10 +116,10 @@
"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"
},
"mcp": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -151,13 +151,13 @@
},
"target": "node",
"file": "mcp-server.mjs",
- "bundleHash": "sha256:ec8ccc0d1f25184650191131ad5dcd25e1434408f92bdf8d2ef150e1bf5f266b"
+ "bundleHash": "sha256:bf78db4536a6c7fa5d19988f9cd112b5ce58aaf5896c4ddf20fa30a669b0fe20"
},
"cli": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -189,13 +189,13 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:aedab71cd93bf352ade99c3a28acdbfc9379cc806f54a401f1515a3449ec2c1b"
+ "bundleHash": "sha256:4791c0ed5b71735b1aa8219cf21519eade12728e7580321c4266cf2016902ca7"
},
"engine": {
- "identity": "sha256:b7939aae93d3c8c730f22b6cf2dcc76f88baac9e9e2a43b7dba24ec8013bc831",
+ "identity": "sha256:1a7ed24895433b8eee978d4e2443325e606da70e4080779823fcf9399e2a2be4",
"engineVersion": "1.6.0",
"toolchain": "[email protected]",
- "sourceHash": "25ed77f2cde078e7b99148eafe328af5f9480c083e82fa713b0aa5e5d0e2bd7c",
+ "sourceHash": "c16969c811c2d6645f0df61364030a1f6a44d567e0b67964a95dbfbf3a216250",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "73cddf0cd8364a4555ebc2a6a2b508120c4553dc8aa71469532e9c1b3dad35c5",
"dependencies": {
@@ -227,7 +227,7 @@
},
"target": "node",
"file": "mcp-engine.mjs",
- "bundleHash": "sha256:07a40ac289bcd7eec991fca1241a4f02e93f12aeca03039f391b9bd7394776fd"
+ "bundleHash": "sha256:946d35edbd43a44c62add289e2da9021d963441c4a55c99ada27c74275fb7bb7"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index 1ffbe6f0..bb88188e 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -14044,7 +14044,7 @@ function inside(root, point, budget) {
}
return null;
}
-function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE) {
+function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE, options = {}) {
const evidence = {
schemaVersion: 1,
source: "engine-scene-analysis",
@@ -14067,11 +14067,15 @@ function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CON
const closed = parts.filter((part) => part.closed);
evidence.openParts = open.length;
evidence.closedParts = closed.length;
+ if (options.comparable)
+ evidence.openPartNames = open.map((part) => part.name);
const candidates = [];
let considered = 0;
broadPhase:
for (const surface of open) {
for (const solid of closed) {
+ if (options.comparable && !options.comparable(surface.mesh, solid.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
evidence.broadPhaseTruncated = true;
break broadPhase;
@@ -14610,7 +14614,7 @@ function meshToArrays(part) {
[tris[i + 1], tris[i + 2]] = [tris[i + 2], tris[i + 1]];
return { vertProperties: verts, triVerts: tris };
}
-async function analyzePartPenetration(root) {
+async function analyzePartPenetration(root, options = {}) {
const skipped = [];
const parts = collectParts4(root, skipped);
const base = {
@@ -14633,12 +14637,14 @@ async function analyzePartPenetration(root) {
broadPhase:
for (let i = 0;i < parts.length; i++) {
for (let j = i + 1;j < parts.length; j++) {
+ const a = parts[i];
+ const b = parts[j];
+ if (options.comparable && !options.comparable(a.mesh, b.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS2) {
base.broadPhaseTruncated = true;
break broadPhase;
}
- const a = parts[i];
- const b = parts[j];
if (!a.box.intersectsBox(b.box))
continue;
if (a.lod && b.lod && a.lod.parent === b.lod.parent && a.lod.stem === b.lod.stem && a.lod.level !== b.lod.level) {
@@ -43624,7 +43630,7 @@ function checkContent(data, ctx) {
message: "Material role requires a locked resource"
});
}
-var MAX_PROJECT_BYTES, MAX_PROJECT_REVISIONS = 1e4, projectIdSchema, projectRevisionIdSchema, hash3, text6, resourceId2, assetReference, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectConflictError, ProjectNotFoundError, ProjectExistsError;
+var MAX_PROJECT_BYTES, MAX_PROJECT_REVISIONS = 1e4, projectIdSchema, projectRevisionIdSchema, hash3, text6, resourceId2, assetReference, placementNumber, placementVector, placementScale, inventoryPlacementSchema, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectConflictError, ProjectNotFoundError, ProjectExistsError;
var init_projects = __esm(() => {
MAX_PROJECT_BYTES = 1024 * 1024;
projectIdSchema = z7.string().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((value) => !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(value), "Reserved filesystem name");
@@ -43637,6 +43643,16 @@ var init_projects = __esm(() => {
assetId: projectIdSchema,
revisionId: projectIdSchema
}).strict();
+ placementNumber = z7.number().min(-1e6).max(1e6);
+ placementVector = z7.tuple([placementNumber, placementNumber, placementNumber]);
+ placementScale = placementNumber.min(-1000).max(1000).refine((value) => value !== 0, {
+ message: "A zero scale collapses the module."
+ });
+ inventoryPlacementSchema = z7.object({
+ translation: placementVector.optional(),
+ rotation: placementVector.optional(),
+ scale: z7.tuple([placementScale, placementScale, placementScale]).optional()
+ }).strict();
projectDesignSchema = z7.object({
style: text6.default(""),
scale: z7.string().max(1000).default(""),
@@ -43669,7 +43685,8 @@ var init_projects = __esm(() => {
kind: z7.enum(["asset", "environment"]).default("asset"),
brief: text6.default(""),
references: z7.array(projectIdSchema).max(64).default([]),
- asset: assetReference.optional()
+ asset: assetReference.optional(),
+ placement: inventoryPlacementSchema.optional()
}).strict()).max(1000).default([]),
deliveryProfiles: z7.array(z7.object({
id: projectIdSchema,
@@ -44272,6 +44289,7 @@ var init_assets = __esm(() => {
warnings: z9.array(z9.string()),
integration: z9.unknown().optional(),
qa: z9.unknown().optional(),
+ composition: z9.unknown().optional(),
dependencies: z9.array(z9.unknown()).optional(),
rebuild: z9.enum(["engine-required", "external-dependencies-required"])
}).optional(),
@@ -52237,24 +52255,276 @@ function flattenIssuePaths(issues, prefix = []) {
}
var list = (fields) => fields.length <= 1 ? fields.join("") : `${fields.slice(0, -1).join(", ")} and ${fields.at(-1)}`, nestedRecordDescription = (purpose, shape) => `${purpose} Shape: kiln_discover({ ids: ['${shape}'] }).`, BARE_REFINE_MESSAGE = "Invalid input";
+// src/project-composition.ts
+import * as THREE60 from "three";
+function placementMatrix(placement) {
+ const [rx, ry, rz] = placement.rotation ?? [0, 0, 0];
+ return new THREE60.Matrix4().compose(new THREE60.Vector3(...placement.translation ?? [0, 0, 0]), new THREE60.Quaternion().setFromEuler(new THREE60.Euler(THREE60.MathUtils.degToRad(rx), THREE60.MathUtils.degToRad(ry), THREE60.MathUtils.degToRad(rz), "XYZ")), new THREE60.Vector3(...placement.scale ?? [1, 1, 1]));
+}
+function nameParts(name) {
+ const at = name.indexOf("/");
+ return { inventoryId: name.slice(0, at), part: name.slice(at + 1).slice(0, 200) };
+}
+function readFailure(item, error) {
+ const code = error?.code;
+ const message = error instanceof Error ? error.message : String(error);
+ const { collectionId, assetId, revisionId } = item.asset;
+ const pin = `${collectionId}/${assetId} at ${revisionId}`;
+ if (code === "ENOENT" || /Unknown collection/.test(message))
+ return {
+ inventoryId: item.id,
+ reason: "unavailable",
+ detail: `The pinned revision ${pin} is not in the configured collections.`
+ };
+ return {
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The pinned revision ${pin} could not be read (${code ?? message}).`
+ };
+}
+async function composeModule(moduleOf, index, item, glb) {
+ const loaded = (await loadGlbReviewScene(glb)).root;
+ const group = new THREE60.Group;
+ group.matrix.copy(placementMatrix(item.placement));
+ group.matrixAutoUpdate = false;
+ group.add(loaded);
+ let parts = 0;
+ let lodExcluded = 0;
+ loaded.traverse((node) => {
+ const mesh = node;
+ if (!mesh.isMesh)
+ return;
+ if ((lodLevel(mesh) ?? 0) > 0) {
+ mesh.visible = false;
+ lodExcluded++;
+ }
+ moduleOf.set(mesh, index);
+ mesh.name = moduleName(item.id, mesh.name || "(unnamed mesh)");
+ parts++;
+ });
+ return { parts, lodExcluded, group };
+}
+function failedCompositionReport(project, error) {
+ return {
+ ...emptyReport(project),
+ coverage: "failed",
+ error: error instanceof Error ? error.message : String(error)
+ };
+}
+function emptyReport(project) {
+ return {
+ schemaVersion: 1,
+ source: "host-composed-scene",
+ projectId: project.projectId,
+ projectRevision: project.revisionId,
+ coverage: "nothing-to-compare",
+ modules: [],
+ notComposed: { count: 0, ids: [] },
+ unmeasured: [],
+ overlaps: [],
+ overlapsOmitted: 0,
+ openSurfaces: [],
+ openSurfacesOmitted: 0,
+ unmeasuredParts: [],
+ unmeasuredPartsOmitted: 0,
+ lodAlternatesExcluded: 0,
+ solids: { candidatePairs: 0, pairsTested: 0, pairsUnmeasurable: 0, pairsNotReached: 0 },
+ surfaces: { candidatePairs: 0, pairsTested: 0, pairsNotReached: 0, verticesUnresolved: 0 },
+ truncated: false,
+ note: COMPOSITION_NOTE
+ };
+}
+async function composeProjectModules(project, library, options = {}) {
+ const limits = { ...PROJECT_COMPOSITION_LIMITS, ...options.limits };
+ const report = emptyReport(project);
+ const { subject } = options;
+ const holdsSubject = (item) => subject !== undefined && item.asset?.collectionId === subject.collectionId && item.asset.assetId === subject.assetId;
+ const placed = project.inventory.filter((item) => item.placement);
+ const outside = project.inventory.filter((item) => !item.placement);
+ report.notComposed = {
+ count: outside.length,
+ ids: outside.slice(0, limits.maxListed).map((item) => item.id)
+ };
+ const held = placed.filter(holdsSubject);
+ if (subject)
+ report.subject = held.map((item) => item.id);
+ const scene = new THREE60.Group;
+ const moduleOf = new Map;
+ const subjectModules = new Set;
+ let bytes = 0;
+ let parts = 0;
+ let exhausted = false;
+ const overBudget = (item, detail) => {
+ exhausted = true;
+ report.unmeasured.push({ inventoryId: item.id, reason: "budget", detail });
+ };
+ for (const item of [...held, ...placed.filter((item) => !holdsSubject(item))]) {
+ if (!item.asset) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unpinned",
+ detail: "This item states a placement but links no saved revision."
+ });
+ continue;
+ }
+ if (exhausted || report.modules.length >= limits.maxModules) {
+ overBudget(item, `Not loaded: the check composes at most ${limits.maxModules} modules, ${limits.maxBytes} bytes and ${limits.maxParts} parts.`);
+ continue;
+ }
+ const saved = holdsSubject(item);
+ let glb;
+ if (saved)
+ glb = subject.glb;
+ else {
+ try {
+ const { collectionId, assetId, revisionId } = item.asset;
+ glb = (await library.read(collectionId, assetId, revisionId)).files["asset.glb"];
+ } catch (error) {
+ report.unmeasured.push(readFailure(item, error));
+ continue;
+ }
+ if (!glb) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: "The pinned revision has no asset.glb."
+ });
+ continue;
+ }
+ }
+ if (bytes + glb.length > limits.maxBytes) {
+ overBudget(item, `Not loaded: the check loads at most ${limits.maxBytes} GLB bytes.`);
+ continue;
+ }
+ bytes += glb.length;
+ let module;
+ try {
+ module = await composeModule(moduleOf, report.modules.length, item, glb);
+ } catch (error) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The GLB could not be loaded (${error instanceof Error ? error.message : String(error)}).`
+ });
+ continue;
+ }
+ if (parts + module.parts > limits.maxParts) {
+ overBudget(item, `Not composed: the check composes at most ${limits.maxParts} parts.`);
+ continue;
+ }
+ parts += module.parts;
+ report.lodAlternatesExcluded += module.lodExcluded;
+ scene.add(module.group);
+ if (saved)
+ subjectModules.add(report.modules.length);
+ report.modules.push({
+ inventoryId: item.id,
+ collectionId: item.asset.collectionId,
+ assetId: item.asset.assetId,
+ ...saved ? { saved: true } : { revisionId: item.asset.revisionId },
+ parts: module.parts
+ });
+ }
+ let failed = false;
+ if (report.modules.length >= 2) {
+ const comparable = (a, b) => {
+ const left = moduleOf.get(a);
+ const right = moduleOf.get(b);
+ if (left === right)
+ return false;
+ return !subject || subjectModules.has(left) || subjectModules.has(right);
+ };
+ const unmeasured = [];
+ let open = new Set;
+ try {
+ const surfaces = analyzeOpenSurfacePenetration(scene, undefined, { comparable });
+ open = new Set(surfaces.openPartNames);
+ report.surfaces = {
+ candidatePairs: surfaces.candidatePairs,
+ pairsTested: surfaces.pairsTested,
+ pairsNotReached: surfaces.pairsNotReached,
+ verticesUnresolved: surfaces.verticesUnresolved
+ };
+ report.truncated ||= surfaces.truncated;
+ report.openSurfaces = surfaces.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ open: nameParts(pair.open),
+ solid: nameParts(pair.solid),
+ depth: pair.depth,
+ vertices: pair.vertices,
+ tested: pair.tested
+ }));
+ report.openSurfacesOmitted = surfaces.penetrations.length - report.openSurfaces.length;
+ for (const { part, reason } of surfaces.skipped)
+ unmeasured.push({ ...nameParts(part), pass: "surfaces", reason });
+ } catch {
+ report.surfaces.failed = true;
+ failed = true;
+ }
+ try {
+ const solids = await analyzePartPenetration(scene, { comparable });
+ report.solids = {
+ candidatePairs: solids.candidatePairs,
+ pairsTested: solids.pairsTested,
+ pairsUnmeasurable: solids.pairsUnmeasurable,
+ pairsNotReached: solids.pairsNotReached
+ };
+ report.truncated ||= solids.truncated;
+ report.overlaps = solids.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ a: nameParts(pair.a),
+ b: nameParts(pair.b),
+ volume: pair.volume,
+ fraction: pair.fraction
+ }));
+ report.overlapsOmitted = solids.penetrations.length - report.overlaps.length;
+ for (const { part, reason } of [...solids.skipped, ...solids.acknowledged ?? []])
+ if (!open.has(part))
+ unmeasured.push({ ...nameParts(part), pass: "solids", reason });
+ } catch {
+ report.solids.failed = true;
+ failed = true;
+ }
+ report.unmeasuredParts = unmeasured.slice(0, limits.maxListed);
+ report.unmeasuredPartsOmitted = unmeasured.length - report.unmeasuredParts.length;
+ report.truncated ||= report.overlapsOmitted > 0 || report.openSurfacesOmitted > 0;
+ failed ||= unmeasured.length > 0;
+ }
+ report.truncated ||= exhausted;
+ report.coverage = failed || report.truncated || report.unmeasured.length > 0 ? "partial" : report.modules.length < 2 ? "nothing-to-compare" : "complete";
+ return report;
+}
+var PROJECT_COMPOSITION_LIMITS, COMPOSITION_NOTE = "A positive is a measurement, not a verdict: a fitting socketed into a neighbour is reported as a bolt in a hole is. Measured at rest over visible static parts; open surfaces are not measured against each other, and a solid thinner than a surface’s facet spacing can pass between its vertices. A clean result is not a fit audit.", moduleName = (inventoryId, part) => `${inventoryId}/${part}`;
+var init_project_composition = __esm(() => {
+ init_lod2();
+ init_open_surface_penetration();
+ init_self_intersection();
+ init_glb();
+ PROJECT_COMPOSITION_LIMITS = Object.freeze({
+ maxModules: 64,
+ maxBytes: 256 * 1024 * 1024,
+ maxParts: 4096,
+ maxReportedPairs: 100,
+ maxListed: 32
+ });
+});
+
// src/tools/projects.ts
import { z as z18 } from "zod";
function projectToolInput(actions = PROJECT_ACTIONS) {
return z18.strictObject({
action: z18.enum(actions),
- projectId: projectIdSchema.optional().describe("get, update, export."),
- revisionId: projectRevisionIdSchema.optional().describe("get, export: an exact revision; omit for the current one."),
+ projectId: projectIdSchema.optional().describe("get, update, export, check."),
+ revisionId: projectRevisionIdSchema.optional().describe("get, export, check: an exact revision; omit for the current one."),
expectedRevision: projectRevisionIdSchema.optional().describe("update: the revision being replaced; a stale value is a conflict."),
draft: record10(nestedRecordDescription("create: name, brief, design, inventory, deliveryProfiles, materialDependencies, references, reviews; optional projectId.", "shape:project-draft")),
patch: record10(nestedRecordDescription("update: the same top-level fields as draft; each supplied field replaces its previous value whole.", "shape:project-patch")),
profile: z18.enum(["editable", "runtime"]).optional().describe("export: editable (default) keeps source and resources; runtime is GLB plus metadata.")
});
}
-function createKilnProjectDef(store, bundleReader) {
- const schema = projectToolInput(bundleReader ? PROJECT_ACTIONS : PROJECT_ACTIONS.filter((action) => action !== "export"));
+function createKilnProjectDef(store, bundleReader, assetLibrary) {
+ const schema = projectToolInput(PROJECT_ACTIONS.filter((action) => (action !== "export" || bundleReader) && (action !== "check" || assetLibrary)));
return {
name: "kiln_project",
- description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : ""),
+ description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : "") + (assetLibrary ? " check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict." : ""),
inputSchema: schema,
annotations: {
readOnlyHint: false,
@@ -52287,6 +52557,13 @@ function createKilnProjectDef(store, bundleReader) {
ok: true,
project: await store.update(input.projectId, input.expectedRevision, projectPatchSchema.parse(input.patch))
};
+ case "check": {
+ await Promise.resolve().then(() => init_project_composition());
+ return {
+ ok: true,
+ composition: await composeProjectModules(await store.read(input.projectId, input.revisionId), assetLibrary)
+ };
+ }
case "export": {
const profile = input.profile ?? "editable";
const project = await store.read(input.projectId, input.revisionId);
@@ -52311,7 +52588,7 @@ function createKilnProjectDef(store, bundleReader) {
var PROJECT_ACTIONS, REQUIREMENTS, record10 = (description) => z18.record(z18.string(), z18.unknown()).optional().describe(description);
var init_projects2 = __esm(() => {
init_projects();
- PROJECT_ACTIONS = ["list", "get", "create", "update", "export"];
+ PROJECT_ACTIONS = ["list", "get", "create", "update", "export", "check"];
REQUIREMENTS = {
list: { required: [] },
get: { required: ["projectId"] },
@@ -52320,7 +52597,8 @@ var init_projects2 = __esm(() => {
required: ["projectId", "expectedRevision", "patch"],
shapes: { patch: "shape:project-patch" }
},
- export: { required: ["projectId"] }
+ export: { required: ["projectId"] },
+ check: { required: ["projectId"] }
};
});
@@ -53602,12 +53880,12 @@ var exports_part_placement = {};
__export(exports_part_placement, {
createPartPlacementReader: () => createPartPlacementReader
});
-import * as THREE60 from "three";
+import * as THREE61 from "three";
function createPartPlacementReader(root) {
const bounds = createPartBoundsReader(root);
- const position = new THREE60.Vector3;
- const quaternion = new THREE60.Quaternion;
- const scale = new THREE60.Vector3;
+ const position = new THREE61.Vector3;
+ const quaternion = new THREE61.Quaternion;
+ const scale = new THREE61.Vector3;
return (node) => {
node.matrixWorld.decompose(position, quaternion, scale);
const box = bounds(node);
@@ -53758,7 +54036,7 @@ var init_inspect = __esm(() => {
});
// src/views/measurement.ts
-import { Box3 as Box328, Vector3 as Vector347 } from "three";
+import { Box3 as Box328, Vector3 as Vector348 } from "three";
function describeSubjectFrame(root, subject) {
const selected = selectCameraSubject(root, subject);
selected.node.updateWorldMatrix(true, true);
@@ -53775,10 +54053,10 @@ function describeSubjectFrame(root, subject) {
if (!attr)
return;
for (let i = 0;i < attr.count; i++)
- local.expandByPoint(new Vector347().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
+ local.expandByPoint(new Vector348().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
});
const box = (b) => b.isEmpty() ? null : { min: b.min.toArray(), max: b.max.toArray() };
- const axis = (i) => new Vector347().setFromMatrixColumn(matrix, i).normalize().toArray();
+ const axis = (i) => new Vector348().setFromMatrixColumn(matrix, i).normalize().toArray();
return {
path: selected.path,
name: selected.name,
@@ -53788,7 +54066,7 @@ function describeSubjectFrame(root, subject) {
invertible,
worldMatrix: matrix.toArray(),
axes: { frame: "world", x: axis(0), y: axis(1), z: axis(2) },
- origin: new Vector347().setFromMatrixPosition(matrix).toArray()
+ origin: new Vector348().setFromMatrixPosition(matrix).toArray()
};
}
function measureAttachment(root, input) {
@@ -53801,7 +54079,7 @@ function measureAttachment(root, input) {
return {
path: selected.path,
local: [...local],
- world: new Vector347(...local).applyMatrix4(selected.node.matrixWorld).toArray()
+ world: new Vector348(...local).applyMatrix4(selected.node.matrixWorld).toArray()
};
};
const from = endpoint(input.from), to = endpoint(input.to);
@@ -53811,7 +54089,7 @@ function measureAttachment(root, input) {
method: "straight-line anchor distance",
from,
to,
- distance: new Vector347(...from.world).distanceTo(new Vector347(...to.world))
+ distance: new Vector348(...from.world).distanceTo(new Vector348(...to.world))
};
}
var init_measurement = __esm(() => {
@@ -53823,7 +54101,7 @@ import {
PropertyType as PropertyType6
} from "@gltf-transform/core";
import { ALL_EXTENSIONS as ALL_EXTENSIONS2 } from "@gltf-transform/extensions";
-import { Box3 as Box329, Matrix4 as Matrix419, Quaternion as Quaternion23, Vector3 as Vector348 } from "three";
+import { Box3 as Box329, Matrix4 as Matrix420, Quaternion as Quaternion24, Vector3 as Vector349 } from "three";
async function accessorFingerprint(accessor) {
const array = accessor?.getArray();
if (!accessor || !array)
@@ -53842,7 +54120,7 @@ function bounds(box) {
return box.isEmpty() ? null : {
min: box.min.toArray(),
max: box.max.toArray(),
- size: box.getSize(new Vector348).toArray()
+ size: box.getSize(new Vector349).toArray()
};
}
async function digest8(bytes) {
@@ -53850,7 +54128,7 @@ async function digest8(bytes) {
return `sha256:${[...hash].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
}
function placements(node) {
- const world = new Matrix419().fromArray(node.getWorldMatrix());
+ const world = new Matrix420().fromArray(node.getWorldMatrix());
const instances = node.getExtension("EXT_mesh_gpu_instancing");
if (!instances)
return [world];
@@ -53858,7 +54136,7 @@ function placements(node) {
const rotation = instances.getAttribute("ROTATION");
const scale = instances.getAttribute("SCALE");
const count = translation?.getCount() ?? rotation?.getCount() ?? scale?.getCount() ?? 1;
- return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix419().compose(new Vector348().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion23().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector348().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
+ return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix420().compose(new Vector349().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion24().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector349().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
}
function triangleCorners(mode, count) {
const corners = [];
@@ -53925,7 +54203,7 @@ async function drawnGeometryDigests(doc) {
}
const data = new Float32Array(triangles * RECORD);
const others = [];
- const point = new Vector348;
+ const point = new Vector349;
const element = [0, 0, 0];
const texcoord = [0, 0];
const corner = new Float32Array(15);
@@ -54008,7 +54286,7 @@ async function revisionTotals(doc) {
const { vertices, geometry, uv } = await drawnGeometryDigests(doc);
const scene = doc.getRoot().getDefaultScene() ?? doc.getRoot().listScenes()[0];
const drawnBounds = scene ? drawnSceneBounds(scene) : null;
- const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector348(...drawnBounds.min), new Vector348(...drawnBounds.max)) : new Box329;
+ const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector349(...drawnBounds.min), new Vector349(...drawnBounds.max)) : new Box329;
return {
triangles: metrics.triangles,
vertices,
@@ -54101,7 +54379,7 @@ async function snapshot3(bytes) {
throw new Error("Revision comparison does not support node/mesh extensions (including instancing).");
const primitives = mesh?.listPrimitives() ?? [];
const own = new Box329;
- const matrix = parentWorld.clone().multiply(new Matrix419().fromArray(node.getMatrix()));
+ const matrix = parentWorld.clone().multiply(new Matrix420().fromArray(node.getMatrix()));
if (matrix.elements.some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite transforms.");
for (const primitive of primitives) {
@@ -54121,7 +54399,7 @@ async function snapshot3(bytes) {
if (!Number.isInteger(vertex) || vertex < 0 || vertex >= position.getCount())
throw new Error("Revision comparison found an invalid vertex index.");
position.getElement(vertex, element);
- const point = new Vector348(...element).applyMatrix4(matrix);
+ const point = new Vector349(...element).applyMatrix4(matrix);
if (point.toArray().some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite positions.");
own.expandByPoint(point);
@@ -54140,7 +54418,7 @@ async function snapshot3(bytes) {
if (scenes[0].listExtensions().length)
throw new Error("Revision comparison does not support scene extensions.");
const scenePath = `/${encodeURIComponent(scenes[0].getName() || "Scene")}[0]`;
- const box = visit(scenes[0].listChildren(), "", 0, new Matrix419);
+ const box = visit(scenes[0].listChildren(), "", 0, new Matrix420);
const nodePaths = new Map([...parts].map(([path, part]) => [part.node, path]));
const animation = new Map;
const clipNames = new Set;
@@ -54322,10 +54600,10 @@ var init_revision_comparison = __esm(() => {
// src/views/surface-distance.ts
import {
Box3 as Box330,
- Matrix4 as Matrix420,
+ Matrix4 as Matrix421,
Ray as Ray3,
Triangle as Triangle3,
- Vector3 as Vector349
+ Vector3 as Vector350
} from "three";
function hierarchy(triangles) {
const box = new Box330;
@@ -54334,7 +54612,7 @@ function hierarchy(triangles) {
const count = triangles.length;
if (count <= 4)
return { box, count, triangles };
- const size = box.getSize(new Vector349);
+ const size = box.getSize(new Vector350);
const axis = size.x >= size.y && size.x >= size.z ? "x" : size.y >= size.z ? "y" : "z";
const center = (triangle) => triangle.box.min[axis] / 2 + triangle.box.max[axis] / 2;
triangles.sort((a, b) => center(a) - center(b));
@@ -54377,7 +54655,7 @@ function collect(node, paths) {
for (let instance = 0;instance < instances; instance++) {
const matrix = mesh.matrixWorld.clone();
if (instanced.isInstancedMesh) {
- const local = new Matrix420;
+ const local = new Matrix421;
instanced.getMatrixAt(instance, local);
matrix.multiply(local);
}
@@ -54386,7 +54664,7 @@ function collect(node, paths) {
const id = index ? index.getX(i + offset) : i + offset;
if (!Number.isSafeInteger(id) || id < 0 || id >= position.count)
throw new Error("Surface distance encountered an invalid triangle index.");
- const point = new Vector349().fromBufferAttribute(position, id).applyMatrix4(matrix);
+ const point = new Vector350().fromBufferAttribute(position, id).applyMatrix4(matrix);
if (![point.x, point.y, point.z].every(Number.isFinite))
throw new Error("Surface distance encountered a non-finite world position.");
return point;
@@ -54445,10 +54723,10 @@ function trianglePair(a, b) {
const av = [a.a, a.b, a.c], bv = [b.a, b.b, b.c];
if (b.getArea() > 0)
for (const p of av)
- record(p, b.closestPointToPoint(p, new Vector349));
+ record(p, b.closestPointToPoint(p, new Vector350));
if (a.getArea() > 0)
for (const q of bv)
- record(a.closestPointToPoint(q, new Vector349), q);
+ record(a.closestPointToPoint(q, new Vector350), q);
for (let i = 0;i < 3; i++) {
const p = av[i], q = av[(i + 1) % 3];
for (let j = 0;j < 3; j++)
@@ -54461,9 +54739,9 @@ function trianglePair(a, b) {
const length = delta.length();
if (length === 0)
continue;
- const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector349);
+ const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector350);
if (hit && origin.distanceTo(hit) <= length) {
- const onFace = target.closestPointToPoint(hit, new Vector349);
+ const onFace = target.closestPointToPoint(hit, new Vector350);
if (vertices === av)
record(hit, onFace);
else
@@ -54629,7 +54907,7 @@ __export(exports_draw_diagnostics, {
});
import { Primitive as Primitive3 } from "@gltf-transform/core";
import { cloneDocument as cloneDocument2 } from "@gltf-transform/functions";
-import * as THREE61 from "three";
+import * as THREE62 from "three";
function withinLimits(doc) {
const root = doc.getRoot();
if (root.listNodes().length > MAX_NODES2 || root.listAccessors().length > 4096 || root.listMaterials().length > 2048 || root.listTextures().length > 256 || root.listScenes().length > 32 || doc.getGraph().listEdges().length > 32768)
@@ -54682,7 +54960,7 @@ function collect2(doc, keep) {
function overlaps(a, b) {
if (Math.abs(a.normal.dot(b.normal)) < 1 - 0.00000001 || !a.bounds.intersectsBox(b.bounds))
return false;
- const tolerance = Math.max(a.bounds.getSize(new THREE61.Vector3).length(), b.bounds.getSize(new THREE61.Vector3).length(), 0.000000000001) * 0.000001;
+ const tolerance = Math.max(a.bounds.getSize(new THREE62.Vector3).length(), b.bounds.getSize(new THREE62.Vector3).length(), 0.000000000001) * 0.000001;
if (b.points.some((p) => Math.abs(a.normal.dot(p.clone().sub(a.points[0]))) > tolerance))
return false;
const normal = a.normal.toArray().map(Math.abs);
@@ -54724,7 +55002,7 @@ function observe(uses) {
unexaminedPrimitiveUses++;
continue;
}
- const matrix = new THREE61.Matrix4().fromArray(node.getWorldMatrix());
+ const matrix = new THREE62.Matrix4().fromArray(node.getWorldMatrix());
if (primitive.getAttribute("TANGENT") && matrix.determinant() < 0)
mirrored.set(part.id, part);
const position = primitive.getAttribute("POSITION");
@@ -54738,14 +55016,14 @@ function observe(uses) {
const amount = Math.min(count, 8, MAX_SAMPLES - samples.length);
for (let i = 0;i < amount; i++) {
const start = Math.floor(i * count / amount) * 3;
- const points = [0, 1, 2].map((j) => new THREE61.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
+ const points = [0, 1, 2].map((j) => new THREE62.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
const normal = points[1].clone().sub(points[0]).cross(points[2].clone().sub(points[0]));
if (!Number.isFinite(normal.lengthSq()) || normal.lengthSq() === 0)
continue;
samples.push({
points,
normal: normal.normalize(),
- bounds: new THREE61.Box3().setFromPoints(points),
+ bounds: new THREE62.Box3().setFromPoints(points),
part
});
}
@@ -55047,7 +55325,7 @@ var init_export_root = __esm(() => {
// src/tools/registry.ts
import { z as z25 } from "zod";
-import * as THREE62 from "three";
+import * as THREE63 from "three";
function proceduralTextureMaterialContract(rendered, context) {
const required = [...new Set(context.requiredProceduralTextureUsages ?? [])];
if (required.length === 0)
@@ -55344,8 +55622,8 @@ function collectSceneMetrics(root) {
let meshes = 0;
const materialSet = new Set;
let lowestPart;
- const box = new THREE62.Box3;
- const point = new THREE62.Vector3;
+ const box = new THREE63.Box3;
+ const point = new THREE63.Vector3;
root.updateWorldMatrix(true, true);
root.traverseVisible((node) => {
const n = node;
@@ -55361,7 +55639,7 @@ function collectSceneMetrics(root) {
const mesh = node;
const position = mesh.geometry.getAttribute("position");
const index = mesh.geometry.index;
- const mb = new THREE62.Box3;
+ const mb = new THREE63.Box3;
if (position) {
for (let i = 0;i < (index?.count ?? position.count); i++) {
point.fromBufferAttribute(position, index ? index.getX(i) : i);
@@ -55376,7 +55654,7 @@ function collectSceneMetrics(root) {
});
let bbox;
if (!box.isEmpty()) {
- const size = new THREE62.Vector3;
+ const size = new THREE63.Vector3;
box.getSize(size);
bbox = {
min: [box.min.x, box.min.y, box.min.z],
@@ -56198,7 +56476,9 @@ function createProgramDefs(suppliedContext, presentation) {
createKilnEditDef(context)
].map((def) => withProgramReferences(def, store, context.readSourceFile)),
createKilnSourceDef(store),
- ...context.projectStore ? [createKilnProjectDef(context.projectStore, context.projectBundleReader)] : [],
+ ...context.projectStore ? [
+ createKilnProjectDef(context.projectStore, context.projectBundleReader, context.assetLibrary)
+ ] : [],
...context.materialLibrary ? [createKilnMaterialDef(context.materialLibrary, presentation)] : [],
...context.reviewStore && context.assetLibrary ? [
createKilnReviewDef({
@@ -56264,6 +56544,19 @@ async function parentRevisionComparison(parent, child) {
};
}
}
+async function savedComposition(context, library, { collection, assetId }, glb) {
+ const project = context.workspace?.current()?.project;
+ if (!project || !assetId || !project.inventory.some(({ asset, placement }) => placement && asset?.collectionId === collection && asset.assetId === assetId))
+ return;
+ await Promise.resolve().then(() => init_project_composition());
+ try {
+ return await composeProjectModules(project, library, {
+ subject: { collectionId: collection, assetId, glb }
+ });
+ } catch (error) {
+ return failedCompositionReport(project, error);
+ }
+}
async function buildProgramGlb(programRef, context) {
if (!context.programStore)
throw new Error("Building a programRef requires a program store.");
@@ -56428,9 +56721,15 @@ function createKilnAssetDefs(context, presentation = "grouped") {
}
const code = await context.programStore.get(input.programRef);
const draft = await buildProgramAssetDraft(code, callContext, backdrop);
- const asset = await target.save(input.collection, { ...input, ...draft });
+ const composition = await savedComposition(context, target, input, draft.glb);
+ const asset = await target.save(input.collection, {
+ ...input,
+ ...draft,
+ ...composition ? { build: { ...draft.build, composition } } : {}
+ });
return {
...await links(input.collection, asset),
+ ...composition ? { composition } : {},
...parent ? { comparison: await parentRevisionComparison(parent.files["asset.glb"], draft.glb) } : {}
};
}
@@ -58617,6 +58916,34 @@ async function exportMaterialMapsCommand(materials, positional, flags) {
}
};
}
+async function projectToolCall(action, positional, flags) {
+ if (action === "list")
+ return { action: "list" };
+ if (action === "get" || action === "check")
+ return {
+ action,
+ projectId: positional[0],
+ ...flags.revision ? { revisionId: flags.revision } : {}
+ };
+ if (action === "create") {
+ if (flags.file && (flags.name || flags.id))
+ throw new Error("Use --file or --name with optional --id, not both");
+ if (!flags.file && !flags.name)
+ throw new Error("project create requires --file or --name");
+ return {
+ action: "create",
+ draft: flags.file ? await jsonFile(flags.file, MAX_PROJECT_BYTES) : { name: flags.name, ...flags.id ? { projectId: flags.id } : {} }
+ };
+ }
+ if (!flags.file || !flags.expected)
+ throw new Error("project update requires --expected and --file");
+ return {
+ action: "update",
+ projectId: positional[0],
+ expectedRevision: flags.expected,
+ patch: await jsonFile(flags.file, MAX_PROJECT_BYTES)
+ };
+}
async function projectMain(argv) {
const [family, action] = argv;
if (argv.some((value) => value === "--help" || value === "-h")) {
@@ -58625,7 +58952,7 @@ async function projectMain(argv) {
}
if (family !== "project" && family !== "material")
throw new Error("Expected project or material command");
- const supported = family === "project" ? ["list", "get", "create", "update", "export", "import"] : ["list", "get", "procedural", "import", "export", "presets", "create-preset"];
+ const supported = family === "project" ? ["list", "get", "create", "update", "export", "import", "check"] : ["list", "get", "procedural", "import", "export", "presets", "create-preset"];
if (!action || !supported.includes(action))
throw new Error(`Unknown ${family} action. Run kiln ${family} --help.`);
const allowed = {
@@ -58635,6 +58962,7 @@ async function projectMain(argv) {
"project:update": ["file", "expected"],
"project:export": ["out", "revision", "profile"],
"project:import": ["id", "collection", "name"],
+ "project:check": ["revision"],
"material:list": [],
"material:presets": ["tag"],
"material:create-preset": ["file"],
@@ -58661,7 +58989,7 @@ async function projectMain(argv) {
throw new Error(`Missing value for ${value}`);
flags[key] = next;
}
- const expectedArgs = action === "get" || action === "export" ? family === "project" ? 1 : 2 : action === "update" || action === "import" && family === "project" ? 1 : 0;
+ const expectedArgs = action === "get" || action === "export" || action === "check" ? family === "project" ? 1 : 2 : action === "update" || action === "import" && family === "project" ? 1 : 0;
if (positional.length !== expectedArgs)
throw new Error(`${family} ${action} requires ${expectedArgs} positional argument${expectedArgs === 1 ? "" : "s"}`);
const workspace = new FileWorkspace(localWorkspaceRoot());
@@ -58686,36 +59014,8 @@ async function projectMain(argv) {
console.log(JSON.stringify({ ok: true, project }, null, 2));
return 0;
}
- const tool = createKilnProjectDef(store);
- let input;
- if (action === "list")
- input = { action: "list" };
- else if (action === "get")
- input = {
- action: "get",
- projectId: positional[0],
- ...flags.revision ? { revisionId: flags.revision } : {}
- };
- else if (action === "create") {
- if (flags.file && (flags.name || flags.id))
- throw new Error("Use --file or --name with optional --id, not both");
- if (!flags.file && !flags.name)
- throw new Error("project create requires --file or --name");
- input = {
- action: "create",
- draft: flags.file ? await jsonFile(flags.file, MAX_PROJECT_BYTES) : { name: flags.name, ...flags.id ? { projectId: flags.id } : {} }
- };
- } else {
- if (!flags.file || !flags.expected)
- throw new Error("project update requires --expected and --file");
- input = {
- action: "update",
- projectId: positional[0],
- expectedRevision: flags.expected,
- patch: await jsonFile(flags.file, MAX_PROJECT_BYTES)
- };
- }
- console.log(JSON.stringify(await tool.run(input), null, 2));
+ const tool = createKilnProjectDef(store, undefined, localAssetLibrary());
+ console.log(JSON.stringify(await tool.run(await projectToolCall(action, positional, flags)), null, 2));
return 0;
}
const materials = workspace.materials;
@@ -58788,6 +59088,7 @@ PROJECTS
kiln project update <id> --expected <revision> --file <project-patch.json>
kiln project export <id> --out <project.zip> [--revision <revision>] [--profile editable|runtime]
kiln project import <project.zip> --id <new-project-id> --collection <collection> [--name <name>]
+ kiln project check <id> [--revision <revision>]
MATERIALS
kiln material presets [--tag <tag>]
@@ -58816,6 +59117,12 @@ selects a project; --no-project overrides that configured default. Use --materia
with an array of exact resourceId/revisionId/sha256 pins for standalone materials.
All commands return JSON; export refuses to overwrite an existing destination.
+Project check composes the inventory items that state a placement, at their exact pinned
+revisions, and reports parts of different modules that share volume or where an open surface
+reaches inside a neighbour. An item with no placement is not composed. A placed item it cannot
+read is reported unmeasured rather than clear. Findings are measurements, not verdicts, so the
+command exits 0 with them.
+
Material export --maps writes <id>.<slot>.png for each map at --size pixels square,
<id>.preview.png (the material on a lit plane repeated --tiles × --tiles, default 3)
and the <id>.maps.json sidecar: each map's slot, colour space, size, sha256 and how it
diff --git a/dist/evaluator-worker.mjs b/dist/evaluator-worker.mjs
index 4439b72b..d1bea787 100644
--- a/dist/evaluator-worker.mjs
+++ b/dist/evaluator-worker.mjs
@@ -8287,7 +8287,7 @@ function inside(root, point, budget) {
}
return null;
}
-function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE) {
+function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE, options = {}) {
const evidence = {
schemaVersion: 1,
source: "engine-scene-analysis",
@@ -8310,11 +8310,15 @@ function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CON
const closed = parts.filter((part) => part.closed);
evidence.openParts = open.length;
evidence.closedParts = closed.length;
+ if (options.comparable)
+ evidence.openPartNames = open.map((part) => part.name);
const candidates = [];
let considered = 0;
broadPhase:
for (const surface of open) {
for (const solid of closed) {
+ if (options.comparable && !options.comparable(surface.mesh, solid.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
evidence.broadPhaseTruncated = true;
break broadPhase;
@@ -8853,7 +8857,7 @@ function meshToArrays(part) {
[tris[i + 1], tris[i + 2]] = [tris[i + 2], tris[i + 1]];
return { vertProperties: verts, triVerts: tris };
}
-async function analyzePartPenetration(root) {
+async function analyzePartPenetration(root, options = {}) {
const skipped = [];
const parts = collectParts4(root, skipped);
const base = {
@@ -8876,12 +8880,14 @@ async function analyzePartPenetration(root) {
broadPhase:
for (let i = 0;i < parts.length; i++) {
for (let j = i + 1;j < parts.length; j++) {
+ const a = parts[i];
+ const b = parts[j];
+ if (options.comparable && !options.comparable(a.mesh, b.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS2) {
base.broadPhaseTruncated = true;
break broadPhase;
}
- const a = parts[i];
- const b = parts[j];
if (!a.box.intersectsBox(b.box))
continue;
if (a.lod && b.lod && a.lod.parent === b.lod.parent && a.lod.stem === b.lod.stem && a.lod.level !== b.lod.level) {
diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjs
index c327d2a1..c44d7a63 100644
--- a/dist/mcp-engine.mjs
+++ b/dist/mcp-engine.mjs
@@ -2789,6 +2789,7 @@ var init_assets = __esm(() => {
warnings: z3.array(z3.string()),
integration: z3.unknown().optional(),
qa: z3.unknown().optional(),
+ composition: z3.unknown().optional(),
dependencies: z3.array(z3.unknown()).optional(),
rebuild: z3.enum(["engine-required", "external-dependencies-required"])
}).optional(),
@@ -16599,7 +16600,7 @@ function inside2(root, point, budget) {
}
return null;
}
-function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE) {
+function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CONTACT_TOLERANCE, options = {}) {
const evidence = {
schemaVersion: 1,
source: "engine-scene-analysis",
@@ -16622,11 +16623,15 @@ function analyzeOpenSurfacePenetration(root, contactTolerance = OPEN_SURFACE_CON
const closed = parts.filter((part) => part.closed);
evidence.openParts = open.length;
evidence.closedParts = closed.length;
+ if (options.comparable)
+ evidence.openPartNames = open.map((part) => part.name);
const candidates = [];
let considered = 0;
broadPhase:
for (const surface of open) {
for (const solid of closed) {
+ if (options.comparable && !options.comparable(surface.mesh, solid.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
evidence.broadPhaseTruncated = true;
break broadPhase;
@@ -17165,7 +17170,7 @@ function meshToArrays(part) {
[tris[i + 1], tris[i + 2]] = [tris[i + 2], tris[i + 1]];
return { vertProperties: verts, triVerts: tris };
}
-async function analyzePartPenetration(root) {
+async function analyzePartPenetration(root, options = {}) {
const skipped = [];
const parts = collectParts4(root, skipped);
const base = {
@@ -17188,12 +17193,14 @@ async function analyzePartPenetration(root) {
broadPhase:
for (let i = 0;i < parts.length; i++) {
for (let j = i + 1;j < parts.length; j++) {
+ const a = parts[i];
+ const b = parts[j];
+ if (options.comparable && !options.comparable(a.mesh, b.mesh))
+ continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS2) {
base.broadPhaseTruncated = true;
break broadPhase;
}
- const a = parts[i];
- const b = parts[j];
if (!a.box.intersectsBox(b.box))
continue;
if (a.lod && b.lod && a.lod.parent === b.lod.parent && a.lod.stem === b.lod.stem && a.lod.level !== b.lod.level) {
@@ -41798,7 +41805,7 @@ function checkContent(data, ctx) {
message: "Material role requires a locked resource"
});
}
-var MAX_PROJECT_BYTES, MAX_PROJECT_REVISIONS = 1e4, projectIdSchema, projectRevisionIdSchema, hash5, text6, resourceId2, assetReference, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectConflictError, ProjectNotFoundError, ProjectExistsError;
+var MAX_PROJECT_BYTES, MAX_PROJECT_REVISIONS = 1e4, projectIdSchema, projectRevisionIdSchema, hash5, text6, resourceId2, assetReference, placementNumber, placementVector, placementScale, inventoryPlacementSchema, projectDesignSchema, projectMaterialDependencySchema, materialDependenciesSchema, content, projectDraftSchema, projectPatchSchema, projectRevisionSchema, ProjectConflictError, ProjectNotFoundError, ProjectExistsError;
var init_projects = __esm(() => {
MAX_PROJECT_BYTES = 1024 * 1024;
projectIdSchema = z9.string().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((value) => !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(value), "Reserved filesystem name");
@@ -41811,6 +41818,16 @@ var init_projects = __esm(() => {
assetId: projectIdSchema,
revisionId: projectIdSchema
}).strict();
+ placementNumber = z9.number().min(-1e6).max(1e6);
+ placementVector = z9.tuple([placementNumber, placementNumber, placementNumber]);
+ placementScale = placementNumber.min(-1000).max(1000).refine((value) => value !== 0, {
+ message: "A zero scale collapses the module."
+ });
+ inventoryPlacementSchema = z9.object({
+ translation: placementVector.optional(),
+ rotation: placementVector.optional(),
+ scale: z9.tuple([placementScale, placementScale, placementScale]).optional()
+ }).strict();
projectDesignSchema = z9.object({
style: text6.default(""),
scale: z9.string().max(1000).default(""),
@@ -41843,7 +41860,8 @@ var init_projects = __esm(() => {
kind: z9.enum(["asset", "environment"]).default("asset"),
brief: text6.default(""),
references: z9.array(projectIdSchema).max(64).default([]),
- asset: assetReference.optional()
+ asset: assetReference.optional(),
+ placement: inventoryPlacementSchema.optional()
}).strict()).max(1000).default([]),
deliveryProfiles: z9.array(z9.object({
id: projectIdSchema,
@@ -42177,6 +42195,258 @@ var init_source_check = __esm(() => {
init_protocol();
});
+// src/project-composition.ts
+import * as THREE60 from "three";
+function placementMatrix(placement) {
+ const [rx, ry, rz] = placement.rotation ?? [0, 0, 0];
+ return new THREE60.Matrix4().compose(new THREE60.Vector3(...placement.translation ?? [0, 0, 0]), new THREE60.Quaternion().setFromEuler(new THREE60.Euler(THREE60.MathUtils.degToRad(rx), THREE60.MathUtils.degToRad(ry), THREE60.MathUtils.degToRad(rz), "XYZ")), new THREE60.Vector3(...placement.scale ?? [1, 1, 1]));
+}
+function nameParts(name) {
+ const at = name.indexOf("/");
+ return { inventoryId: name.slice(0, at), part: name.slice(at + 1).slice(0, 200) };
+}
+function readFailure(item, error) {
+ const code = error?.code;
+ const message = error instanceof Error ? error.message : String(error);
+ const { collectionId, assetId, revisionId } = item.asset;
+ const pin = `${collectionId}/${assetId} at ${revisionId}`;
+ if (code === "ENOENT" || /Unknown collection/.test(message))
+ return {
+ inventoryId: item.id,
+ reason: "unavailable",
+ detail: `The pinned revision ${pin} is not in the configured collections.`
+ };
+ return {
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The pinned revision ${pin} could not be read (${code ?? message}).`
+ };
+}
+async function composeModule(moduleOf, index, item, glb) {
+ const loaded = (await loadGlbReviewScene(glb)).root;
+ const group = new THREE60.Group;
+ group.matrix.copy(placementMatrix(item.placement));
+ group.matrixAutoUpdate = false;
+ group.add(loaded);
+ let parts = 0;
+ let lodExcluded = 0;
+ loaded.traverse((node) => {
+ const mesh = node;
+ if (!mesh.isMesh)
+ return;
+ if ((lodLevel(mesh) ?? 0) > 0) {
+ mesh.visible = false;
+ lodExcluded++;
+ }
+ moduleOf.set(mesh, index);
+ mesh.name = moduleName(item.id, mesh.name || "(unnamed mesh)");
+ parts++;
+ });
+ return { parts, lodExcluded, group };
+}
+function failedCompositionReport(project, error) {
+ return {
+ ...emptyReport(project),
+ coverage: "failed",
+ error: error instanceof Error ? error.message : String(error)
+ };
+}
+function emptyReport(project) {
+ return {
+ schemaVersion: 1,
+ source: "host-composed-scene",
+ projectId: project.projectId,
+ projectRevision: project.revisionId,
+ coverage: "nothing-to-compare",
+ modules: [],
+ notComposed: { count: 0, ids: [] },
+ unmeasured: [],
+ overlaps: [],
+ overlapsOmitted: 0,
+ openSurfaces: [],
+ openSurfacesOmitted: 0,
+ unmeasuredParts: [],
+ unmeasuredPartsOmitted: 0,
+ lodAlternatesExcluded: 0,
+ solids: { candidatePairs: 0, pairsTested: 0, pairsUnmeasurable: 0, pairsNotReached: 0 },
+ surfaces: { candidatePairs: 0, pairsTested: 0, pairsNotReached: 0, verticesUnresolved: 0 },
+ truncated: false,
+ note: COMPOSITION_NOTE
+ };
+}
+async function composeProjectModules(project, library, options = {}) {
+ const limits = { ...PROJECT_COMPOSITION_LIMITS, ...options.limits };
+ const report = emptyReport(project);
+ const { subject } = options;
+ const holdsSubject = (item) => subject !== undefined && item.asset?.collectionId === subject.collectionId && item.asset.assetId === subject.assetId;
+ const placed = project.inventory.filter((item) => item.placement);
+ const outside = project.inventory.filter((item) => !item.placement);
+ report.notComposed = {
+ count: outside.length,
+ ids: outside.slice(0, limits.maxListed).map((item) => item.id)
+ };
+ const held = placed.filter(holdsSubject);
+ if (subject)
+ report.subject = held.map((item) => item.id);
+ const scene = new THREE60.Group;
+ const moduleOf = new Map;
+ const subjectModules = new Set;
+ let bytes = 0;
+ let parts = 0;
+ let exhausted = false;
+ const overBudget = (item, detail) => {
+ exhausted = true;
+ report.unmeasured.push({ inventoryId: item.id, reason: "budget", detail });
+ };
+ for (const item of [...held, ...placed.filter((item) => !holdsSubject(item))]) {
+ if (!item.asset) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unpinned",
+ detail: "This item states a placement but links no saved revision."
+ });
+ continue;
+ }
+ if (exhausted || report.modules.length >= limits.maxModules) {
+ overBudget(item, `Not loaded: the check composes at most ${limits.maxModules} modules, ${limits.maxBytes} bytes and ${limits.maxParts} parts.`);
+ continue;
+ }
+ const saved = holdsSubject(item);
+ let glb;
+ if (saved)
+ glb = subject.glb;
+ else {
+ try {
+ const { collectionId, assetId, revisionId } = item.asset;
+ glb = (await library.read(collectionId, assetId, revisionId)).files["asset.glb"];
+ } catch (error) {
+ report.unmeasured.push(readFailure(item, error));
+ continue;
+ }
+ if (!glb) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: "The pinned revision has no asset.glb."
+ });
+ continue;
+ }
+ }
+ if (bytes + glb.length > limits.maxBytes) {
+ overBudget(item, `Not loaded: the check loads at most ${limits.maxBytes} GLB bytes.`);
+ continue;
+ }
+ bytes += glb.length;
+ let module;
+ try {
+ module = await composeModule(moduleOf, report.modules.length, item, glb);
+ } catch (error) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: "unreadable",
+ detail: `The GLB could not be loaded (${error instanceof Error ? error.message : String(error)}).`
+ });
+ continue;
+ }
+ if (parts + module.parts > limits.maxParts) {
+ overBudget(item, `Not composed: the check composes at most ${limits.maxParts} parts.`);
+ continue;
+ }
+ parts += module.parts;
+ report.lodAlternatesExcluded += module.lodExcluded;
+ scene.add(module.group);
+ if (saved)
+ subjectModules.add(report.modules.length);
+ report.modules.push({
+ inventoryId: item.id,
+ collectionId: item.asset.collectionId,
+ assetId: item.asset.assetId,
+ ...saved ? { saved: true } : { revisionId: item.asset.revisionId },
+ parts: module.parts
+ });
+ }
+ let failed = false;
+ if (report.modules.length >= 2) {
+ const comparable = (a, b) => {
+ const left = moduleOf.get(a);
+ const right = moduleOf.get(b);
+ if (left === right)
+ return false;
+ return !subject || subjectModules.has(left) || subjectModules.has(right);
+ };
+ const unmeasured = [];
+ let open = new Set;
+ try {
+ const surfaces = analyzeOpenSurfacePenetration(scene, undefined, { comparable });
+ open = new Set(surfaces.openPartNames);
+ report.surfaces = {
+ candidatePairs: surfaces.candidatePairs,
+ pairsTested: surfaces.pairsTested,
+ pairsNotReached: surfaces.pairsNotReached,
+ verticesUnresolved: surfaces.verticesUnresolved
+ };
+ report.truncated ||= surfaces.truncated;
+ report.openSurfaces = surfaces.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ open: nameParts(pair.open),
+ solid: nameParts(pair.solid),
+ depth: pair.depth,
+ vertices: pair.vertices,
+ tested: pair.tested
+ }));
+ report.openSurfacesOmitted = surfaces.penetrations.length - report.openSurfaces.length;
+ for (const { part, reason } of surfaces.skipped)
+ unmeasured.push({ ...nameParts(part), pass: "surfaces", reason });
+ } catch {
+ report.surfaces.failed = true;
+ failed = true;
+ }
+ try {
+ const solids = await analyzePartPenetration(scene, { comparable });
+ report.solids = {
+ candidatePairs: solids.candidatePairs,
+ pairsTested: solids.pairsTested,
+ pairsUnmeasurable: solids.pairsUnmeasurable,
+ pairsNotReached: solids.pairsNotReached
+ };
+ report.truncated ||= solids.truncated;
+ report.overlaps = solids.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ a: nameParts(pair.a),
+ b: nameParts(pair.b),
+ volume: pair.volume,
+ fraction: pair.fraction
+ }));
+ report.overlapsOmitted = solids.penetrations.length - report.overlaps.length;
+ for (const { part, reason } of [...solids.skipped, ...solids.acknowledged ?? []])
+ if (!open.has(part))
+ unmeasured.push({ ...nameParts(part), pass: "solids", reason });
+ } catch {
+ report.solids.failed = true;
+ failed = true;
+ }
+ report.unmeasuredParts = unmeasured.slice(0, limits.maxListed);
+ report.unmeasuredPartsOmitted = unmeasured.length - report.unmeasuredParts.length;
+ report.truncated ||= report.overlapsOmitted > 0 || report.openSurfacesOmitted > 0;
+ failed ||= unmeasured.length > 0;
+ }
+ report.truncated ||= exhausted;
+ report.coverage = failed || report.truncated || report.unmeasured.length > 0 ? "partial" : report.modules.length < 2 ? "nothing-to-compare" : "complete";
+ return report;
+}
+var PROJECT_COMPOSITION_LIMITS, COMPOSITION_NOTE = "A positive is a measurement, not a verdict: a fitting socketed into a neighbour is reported as a bolt in a hole is. Measured at rest over visible static parts; open surfaces are not measured against each other, and a solid thinner than a surface’s facet spacing can pass between its vertices. A clean result is not a fit audit.", moduleName = (inventoryId, part) => `${inventoryId}/${part}`;
+var init_project_composition = __esm(() => {
+ init_lod2();
+ init_open_surface_penetration();
+ init_self_intersection();
+ init_glb();
+ PROJECT_COMPOSITION_LIMITS = Object.freeze({
+ maxModules: 64,
+ maxBytes: 256 * 1024 * 1024,
+ maxParts: 4096,
+ maxReportedPairs: 100,
+ maxListed: 32
+ });
+});
+
// src/views/port.ts
async function sha256Bytes(bytes) {
const input = new Uint8Array(bytes.byteLength);
@@ -42390,12 +42660,12 @@ var exports_part_placement = {};
__export(exports_part_placement, {
createPartPlacementReader: () => createPartPlacementReader
});
-import * as THREE60 from "three";
+import * as THREE61 from "three";
function createPartPlacementReader(root) {
const bounds = createPartBoundsReader(root);
- const position = new THREE60.Vector3;
- const quaternion = new THREE60.Quaternion;
- const scale = new THREE60.Vector3;
+ const position = new THREE61.Vector3;
+ const quaternion = new THREE61.Quaternion;
+ const scale = new THREE61.Vector3;
return (node) => {
node.matrixWorld.decompose(position, quaternion, scale);
const box = bounds(node);
@@ -42546,7 +42816,7 @@ var init_inspect = __esm(() => {
});
// src/views/measurement.ts
-import { Box3 as Box328, Vector3 as Vector347 } from "three";
+import { Box3 as Box328, Vector3 as Vector348 } from "three";
function describeSubjectFrame(root, subject) {
const selected = selectCameraSubject(root, subject);
selected.node.updateWorldMatrix(true, true);
@@ -42563,10 +42833,10 @@ function describeSubjectFrame(root, subject) {
if (!attr)
return;
for (let i = 0;i < attr.count; i++)
- local.expandByPoint(new Vector347().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
+ local.expandByPoint(new Vector348().fromBufferAttribute(attr, i).applyMatrix4(mesh.matrixWorld).applyMatrix4(inverse));
});
const box = (b) => b.isEmpty() ? null : { min: b.min.toArray(), max: b.max.toArray() };
- const axis = (i) => new Vector347().setFromMatrixColumn(matrix, i).normalize().toArray();
+ const axis = (i) => new Vector348().setFromMatrixColumn(matrix, i).normalize().toArray();
return {
path: selected.path,
name: selected.name,
@@ -42576,7 +42846,7 @@ function describeSubjectFrame(root, subject) {
invertible,
worldMatrix: matrix.toArray(),
axes: { frame: "world", x: axis(0), y: axis(1), z: axis(2) },
- origin: new Vector347().setFromMatrixPosition(matrix).toArray()
+ origin: new Vector348().setFromMatrixPosition(matrix).toArray()
};
}
function measureAttachment(root, input) {
@@ -42589,7 +42859,7 @@ function measureAttachment(root, input) {
return {
path: selected.path,
local: [...local],
- world: new Vector347(...local).applyMatrix4(selected.node.matrixWorld).toArray()
+ world: new Vector348(...local).applyMatrix4(selected.node.matrixWorld).toArray()
};
};
const from = endpoint(input.from), to = endpoint(input.to);
@@ -42599,7 +42869,7 @@ function measureAttachment(root, input) {
method: "straight-line anchor distance",
from,
to,
- distance: new Vector347(...from.world).distanceTo(new Vector347(...to.world))
+ distance: new Vector348(...from.world).distanceTo(new Vector348(...to.world))
};
}
var init_measurement = __esm(() => {
@@ -42611,7 +42881,7 @@ import {
PropertyType as PropertyType6
} from "@gltf-transform/core";
import { ALL_EXTENSIONS as ALL_EXTENSIONS2 } from "@gltf-transform/extensions";
-import { Box3 as Box329, Matrix4 as Matrix419, Quaternion as Quaternion23, Vector3 as Vector348 } from "three";
+import { Box3 as Box329, Matrix4 as Matrix420, Quaternion as Quaternion24, Vector3 as Vector349 } from "three";
async function accessorFingerprint(accessor) {
const array = accessor?.getArray();
if (!accessor || !array)
@@ -42630,7 +42900,7 @@ function bounds(box) {
return box.isEmpty() ? null : {
min: box.min.toArray(),
max: box.max.toArray(),
- size: box.getSize(new Vector348).toArray()
+ size: box.getSize(new Vector349).toArray()
};
}
async function digest8(bytes) {
@@ -42638,7 +42908,7 @@ async function digest8(bytes) {
return `sha256:${[...hash].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
}
function placements(node) {
- const world = new Matrix419().fromArray(node.getWorldMatrix());
+ const world = new Matrix420().fromArray(node.getWorldMatrix());
const instances = node.getExtension("EXT_mesh_gpu_instancing");
if (!instances)
return [world];
@@ -42646,7 +42916,7 @@ function placements(node) {
const rotation = instances.getAttribute("ROTATION");
const scale = instances.getAttribute("SCALE");
const count = translation?.getCount() ?? rotation?.getCount() ?? scale?.getCount() ?? 1;
- return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix419().compose(new Vector348().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion23().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector348().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
+ return Array.from({ length: count }, (_, i) => world.clone().multiply(new Matrix420().compose(new Vector349().fromArray(translation?.getElement(i, []) ?? [0, 0, 0]), new Quaternion24().fromArray(rotation?.getElement(i, []) ?? [0, 0, 0, 1]), new Vector349().fromArray(scale?.getElement(i, []) ?? [1, 1, 1]))));
}
function triangleCorners(mode, count) {
const corners = [];
@@ -42713,7 +42983,7 @@ async function drawnGeometryDigests(doc) {
}
const data = new Float32Array(triangles * RECORD);
const others = [];
- const point = new Vector348;
+ const point = new Vector349;
const element = [0, 0, 0];
const texcoord = [0, 0];
const corner = new Float32Array(15);
@@ -42796,7 +43066,7 @@ async function revisionTotals(doc) {
const { vertices, geometry, uv } = await drawnGeometryDigests(doc);
const scene = doc.getRoot().getDefaultScene() ?? doc.getRoot().listScenes()[0];
const drawnBounds = scene ? drawnSceneBounds(scene) : null;
- const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector348(...drawnBounds.min), new Vector348(...drawnBounds.max)) : new Box329;
+ const box = drawnBounds && [...drawnBounds.min, ...drawnBounds.max].every(Number.isFinite) ? new Box329(new Vector349(...drawnBounds.min), new Vector349(...drawnBounds.max)) : new Box329;
return {
triangles: metrics.triangles,
vertices,
@@ -42889,7 +43159,7 @@ async function snapshot3(bytes) {
throw new Error("Revision comparison does not support node/mesh extensions (including instancing).");
const primitives = mesh?.listPrimitives() ?? [];
const own = new Box329;
- const matrix = parentWorld.clone().multiply(new Matrix419().fromArray(node.getMatrix()));
+ const matrix = parentWorld.clone().multiply(new Matrix420().fromArray(node.getMatrix()));
if (matrix.elements.some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite transforms.");
for (const primitive of primitives) {
@@ -42909,7 +43179,7 @@ async function snapshot3(bytes) {
if (!Number.isInteger(vertex) || vertex < 0 || vertex >= position.getCount())
throw new Error("Revision comparison found an invalid vertex index.");
position.getElement(vertex, element);
- const point = new Vector348(...element).applyMatrix4(matrix);
+ const point = new Vector349(...element).applyMatrix4(matrix);
if (point.toArray().some((value) => !Number.isFinite(value)))
throw new Error("Revision comparison requires finite positions.");
own.expandByPoint(point);
@@ -42928,7 +43198,7 @@ async function snapshot3(bytes) {
if (scenes[0].listExtensions().length)
throw new Error("Revision comparison does not support scene extensions.");
const scenePath = `/${encodeURIComponent(scenes[0].getName() || "Scene")}[0]`;
- const box = visit(scenes[0].listChildren(), "", 0, new Matrix419);
+ const box = visit(scenes[0].listChildren(), "", 0, new Matrix420);
const nodePaths = new Map([...parts].map(([path, part]) => [part.node, path]));
const animation = new Map;
const clipNames = new Set;
@@ -43110,10 +43380,10 @@ var init_revision_comparison = __esm(() => {
// src/views/surface-distance.ts
import {
Box3 as Box330,
- Matrix4 as Matrix420,
+ Matrix4 as Matrix421,
Ray as Ray3,
Triangle as Triangle3,
- Vector3 as Vector349
+ Vector3 as Vector350
} from "three";
function hierarchy(triangles) {
const box = new Box330;
@@ -43122,7 +43392,7 @@ function hierarchy(triangles) {
const count = triangles.length;
if (count <= 4)
return { box, count, triangles };
- const size = box.getSize(new Vector349);
+ const size = box.getSize(new Vector350);
const axis = size.x >= size.y && size.x >= size.z ? "x" : size.y >= size.z ? "y" : "z";
const center = (triangle) => triangle.box.min[axis] / 2 + triangle.box.max[axis] / 2;
triangles.sort((a, b) => center(a) - center(b));
@@ -43165,7 +43435,7 @@ function collect(node, paths) {
for (let instance = 0;instance < instances; instance++) {
const matrix = mesh.matrixWorld.clone();
if (instanced.isInstancedMesh) {
- const local = new Matrix420;
+ const local = new Matrix421;
instanced.getMatrixAt(instance, local);
matrix.multiply(local);
}
@@ -43174,7 +43444,7 @@ function collect(node, paths) {
const id = index ? index.getX(i + offset) : i + offset;
if (!Number.isSafeInteger(id) || id < 0 || id >= position.count)
throw new Error("Surface distance encountered an invalid triangle index.");
- const point = new Vector349().fromBufferAttribute(position, id).applyMatrix4(matrix);
+ const point = new Vector350().fromBufferAttribute(position, id).applyMatrix4(matrix);
if (![point.x, point.y, point.z].every(Number.isFinite))
throw new Error("Surface distance encountered a non-finite world position.");
return point;
@@ -43233,10 +43503,10 @@ function trianglePair(a, b) {
const av = [a.a, a.b, a.c], bv = [b.a, b.b, b.c];
if (b.getArea() > 0)
for (const p of av)
- record(p, b.closestPointToPoint(p, new Vector349));
+ record(p, b.closestPointToPoint(p, new Vector350));
if (a.getArea() > 0)
for (const q of bv)
- record(a.closestPointToPoint(q, new Vector349), q);
+ record(a.closestPointToPoint(q, new Vector350), q);
for (let i = 0;i < 3; i++) {
const p = av[i], q = av[(i + 1) % 3];
for (let j = 0;j < 3; j++)
@@ -43249,9 +43519,9 @@ function trianglePair(a, b) {
const length = delta.length();
if (length === 0)
continue;
- const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector349);
+ const hit = new Ray3(origin, delta.divideScalar(length)).intersectTriangle(target.a, target.b, target.c, false, new Vector350);
if (hit && origin.distanceTo(hit) <= length) {
- const onFace = target.closestPointToPoint(hit, new Vector349);
+ const onFace = target.closestPointToPoint(hit, new Vector350);
if (vertices === av)
record(hit, onFace);
else
@@ -43417,7 +43687,7 @@ __export(exports_draw_diagnostics, {
});
import { Primitive as Primitive3 } from "@gltf-transform/core";
import { cloneDocument as cloneDocument2 } from "@gltf-transform/functions";
-import * as THREE61 from "three";
+import * as THREE62 from "three";
function withinLimits(doc) {
const root = doc.getRoot();
if (root.listNodes().length > MAX_NODES2 || root.listAccessors().length > 4096 || root.listMaterials().length > 2048 || root.listTextures().length > 256 || root.listScenes().length > 32 || doc.getGraph().listEdges().length > 32768)
@@ -43470,7 +43740,7 @@ function collect2(doc, keep) {
function overlaps(a, b) {
if (Math.abs(a.normal.dot(b.normal)) < 1 - 0.00000001 || !a.bounds.intersectsBox(b.bounds))
return false;
- const tolerance = Math.max(a.bounds.getSize(new THREE61.Vector3).length(), b.bounds.getSize(new THREE61.Vector3).length(), 0.000000000001) * 0.000001;
+ const tolerance = Math.max(a.bounds.getSize(new THREE62.Vector3).length(), b.bounds.getSize(new THREE62.Vector3).length(), 0.000000000001) * 0.000001;
if (b.points.some((p) => Math.abs(a.normal.dot(p.clone().sub(a.points[0]))) > tolerance))
return false;
const normal = a.normal.toArray().map(Math.abs);
@@ -43512,7 +43782,7 @@ function observe(uses) {
unexaminedPrimitiveUses++;
continue;
}
- const matrix = new THREE61.Matrix4().fromArray(node.getWorldMatrix());
+ const matrix = new THREE62.Matrix4().fromArray(node.getWorldMatrix());
if (primitive.getAttribute("TANGENT") && matrix.determinant() < 0)
mirrored.set(part.id, part);
const position = primitive.getAttribute("POSITION");
@@ -43526,14 +43796,14 @@ function observe(uses) {
const amount = Math.min(count, 8, MAX_SAMPLES - samples.length);
for (let i = 0;i < amount; i++) {
const start = Math.floor(i * count / amount) * 3;
- const points = [0, 1, 2].map((j) => new THREE61.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
+ const points = [0, 1, 2].map((j) => new THREE62.Vector3().fromArray(position.getElement(indices ? indices.getScalar(start + j) : start + j, [])).applyMatrix4(matrix));
const normal = points[1].clone().sub(points[0]).cross(points[2].clone().sub(points[0]));
if (!Number.isFinite(normal.lengthSq()) || normal.lengthSq() === 0)
continue;
samples.push({
points,
normal: normal.normalize(),
- bounds: new THREE61.Box3().setFromPoints(points),
+ bounds: new THREE62.Box3().setFromPoints(points),
part
});
}
@@ -52567,7 +52837,7 @@ function flattenIssuePaths(issues, prefix = []) {
}
// src/tools/projects.ts
-var PROJECT_ACTIONS = ["list", "get", "create", "update", "export"];
+var PROJECT_ACTIONS = ["list", "get", "create", "update", "export", "check"];
var REQUIREMENTS = {
list: { required: [] },
get: { required: ["projectId"] },
@@ -52576,25 +52846,26 @@ var REQUIREMENTS = {
required: ["projectId", "expectedRevision", "patch"],
shapes: { patch: "shape:project-patch" }
},
- export: { required: ["projectId"] }
+ export: { required: ["projectId"] },
+ check: { required: ["projectId"] }
};
var record10 = (description) => z18.record(z18.string(), z18.unknown()).optional().describe(description);
function projectToolInput(actions = PROJECT_ACTIONS) {
return z18.strictObject({
action: z18.enum(actions),
- projectId: projectIdSchema.optional().describe("get, update, export."),
- revisionId: projectRevisionIdSchema.optional().describe("get, export: an exact revision; omit for the current one."),
+ projectId: projectIdSchema.optional().describe("get, update, export, check."),
+ revisionId: projectRevisionIdSchema.optional().describe("get, export, check: an exact revision; omit for the current one."),
expectedRevision: projectRevisionIdSchema.optional().describe("update: the revision being replaced; a stale value is a conflict."),
draft: record10(nestedRecordDescription("create: name, brief, design, inventory, deliveryProfiles, materialDependencies, references, reviews; optional projectId.", "shape:project-draft")),
patch: record10(nestedRecordDescription("update: the same top-level fields as draft; each supplied field replaces its previous value whole.", "shape:project-patch")),
profile: z18.enum(["editable", "runtime"]).optional().describe("export: editable (default) keeps source and resources; runtime is GLB plus metadata.")
});
}
-function createKilnProjectDef(store, bundleReader) {
- const schema = projectToolInput(bundleReader ? PROJECT_ACTIONS : PROJECT_ACTIONS.filter((action) => action !== "export"));
+function createKilnProjectDef(store, bundleReader, assetLibrary) {
+ const schema = projectToolInput(PROJECT_ACTIONS.filter((action) => (action !== "export" || bundleReader) && (action !== "check" || assetLibrary)));
return {
name: "kiln_project",
- description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : ""),
+ description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release." + (bundleReader ? " export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded." : "") + (assetLibrary ? " check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict." : ""),
inputSchema: schema,
annotations: {
readOnlyHint: false,
@@ -52627,6 +52898,13 @@ function createKilnProjectDef(store, bundleReader) {
ok: true,
project: await store.update(input.projectId, input.expectedRevision, projectPatchSchema.parse(input.patch))
};
+ case "check": {
+ await Promise.resolve().then(() => init_project_composition());
+ return {
+ ok: true,
+ composition: await composeProjectModules(await store.read(input.projectId, input.revisionId), assetLibrary)
+ };
+ }
case "export": {
const profile = input.profile ?? "editable";
const project = await store.read(input.projectId, input.revisionId);
@@ -53836,7 +54114,7 @@ init_render();
init_requirements_context();
init_evaluator();
init_material_resources();
-import * as THREE62 from "three";
+import * as THREE63 from "three";
// src/render-route.ts
var GPU_SERVES = new Set([
@@ -54437,8 +54715,8 @@ function collectSceneMetrics(root) {
let meshes = 0;
const materialSet = new Set;
let lowestPart;
- const box = new THREE62.Box3;
- const point = new THREE62.Vector3;
+ const box = new THREE63.Box3;
+ const point = new THREE63.Vector3;
root.updateWorldMatrix(true, true);
root.traverseVisible((node) => {
const n = node;
@@ -54454,7 +54732,7 @@ function collectSceneMetrics(root) {
const mesh = node;
const position = mesh.geometry.getAttribute("position");
const index = mesh.geometry.index;
- const mb = new THREE62.Box3;
+ const mb = new THREE63.Box3;
if (position) {
for (let i = 0;i < (index?.count ?? position.count); i++) {
point.fromBufferAttribute(position, index ? index.getX(i) : i);
@@ -54469,7 +54747,7 @@ function collectSceneMetrics(root) {
});
let bbox;
if (!box.isEmpty()) {
- const size = new THREE62.Vector3;
+ const size = new THREE63.Vector3;
box.getSize(size);
bbox = {
min: [box.min.x, box.min.y, box.min.z],
@@ -55356,7 +55634,9 @@ function createProgramDefs(suppliedContext, presentation) {
createKilnEditDef(context)
].map((def) => withProgramReferences(def, store, context.readSourceFile)),
createKilnSourceDef(store),
- ...context.projectStore ? [createKilnProjectDef(context.projectStore, context.projectBundleReader)] : [],
+ ...context.projectStore ? [
+ createKilnProjectDef(context.projectStore, context.projectBundleReader, context.assetLibrary)
+ ] : [],
...context.materialLibrary ? [createKilnMaterialDef(context.materialLibrary, presentation)] : [],
...context.reviewStore && context.assetLibrary ? [
createKilnReviewDef({
@@ -55458,6 +55738,19 @@ async function parentRevisionComparison(parent, child) {
};
}
}
+async function savedComposition(context, library, { collection, assetId }, glb) {
+ const project = context.workspace?.current()?.project;
+ if (!project || !assetId || !project.inventory.some(({ asset, placement }) => placement && asset?.collectionId === collection && asset.assetId === assetId))
+ return;
+ await Promise.resolve().then(() => init_project_composition());
+ try {
+ return await composeProjectModules(project, library, {
+ subject: { collectionId: collection, assetId, glb }
+ });
+ } catch (error) {
+ return failedCompositionReport(project, error);
+ }
+}
async function buildProgramGlb(programRef, context) {
if (!context.programStore)
throw new Error("Building a programRef requires a program store.");
@@ -55622,9 +55915,15 @@ function createKilnAssetDefs(context, presentation = "grouped") {
}
const code = await context.programStore.get(input.programRef);
const draft = await buildProgramAssetDraft(code, callContext, backdrop);
- const asset = await target.save(input.collection, { ...input, ...draft });
+ const composition = await savedComposition(context, target, input, draft.glb);
+ const asset = await target.save(input.collection, {
+ ...input,
+ ...draft,
+ ...composition ? { build: { ...draft.build, composition } } : {}
+ });
return {
...await links(input.collection, asset),
+ ...composition ? { composition } : {},
...parent ? { comparison: await parentRevisionComparison(parent.files["asset.glb"], draft.glb) } : {}
};
}
diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjs
index fcd5e245..78d164db 100644
--- a/dist/mcp-server.mjs
+++ b/dist/mcp-server.mjs
@@ -1252,7 +1252,7 @@ var mcp_manifest_default = {
},
{
name: "kiln_project",
- description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded.",
+ description: "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded. check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict.",
inputSchema: {
type: "object",
properties: {
@@ -1263,16 +1263,17 @@ var mcp_manifest_default = {
"get",
"create",
"update",
- "export"
+ "export",
+ "check"
]
},
projectId: {
- description: "get, update, export.",
+ description: "get, update, export, check.",
type: "string",
pattern: "^[a-z][a-z0-9_-]{0,79}$"
},
revisionId: {
- description: "get, export: an exact revision; omit for the current one.",
+ description: "get, export, check: an exact revision; omit for the current one.",
type: "string",
pattern: "^r_[0-9]{10}_[a-f0-9]{64}$"
},
diff --git a/dist/viewer/app.js b/dist/viewer/app.js
index 5c2142a5..719794ef 100644
--- a/dist/viewer/app.js
+++ b/dist/viewer/app.js
@@ -1,12 +1,12 @@
-var sI=Object.create;var{getPrototypeOf:aI,defineProperty:Uf,getOwnPropertyNames:oI}=Object;var Db=Object.prototype.hasOwnProperty;function cI(e){return this[e]}var lI,uI,Bf=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?lI??=new WeakMap:uI??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?sI(aI(e)):{};let a=t||!e||!e.__esModule||!Db.call(e,"default")?Uf(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of oI(e))if(!Db.call(a,o))Uf(a,o,{get:cI.bind(e,o),enumerable:!0})}if(i)r.set(e,a);return a};var Jr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dI=(e)=>e;function fI(e,t){this[e]=dI.bind(null,t)}var Lb=(e,t)=>{for(var n in t)Uf(e,n,{get:t[n],enumerable:!0,configurable:!0,set:fI.bind(t,n)})};var ut=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var ir;var Tc=ut(()=>{ir=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"]});function BC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_SOLID_FAILED")return'PROFILE_SOLID_FAILED: extrudeProfile or revolveProfile could not build a solid from this outline. Reduce bevel or set it to 0. Keep the outline one simple closed loop: no self-intersections, repeated points or zero-length edges, and no neck narrower than twice the bevel. Holes must lie inside the outline and leave material. For revolveProfile, keep points off the axis (x = 0) unless the solid should close there. Keep coordinates at asset scale. Render that helper call alone with kiln_render and simplify the outline until it builds. Call kiln_discover with ids ["extrudeProfile", "revolveProfile"].';if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}var ua;var Ac=ut(()=>{ua=class ua extends Error{diagnostic;constructor(e,t=BC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}});function Ru(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new yt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new yt(`${t} must not contain symbol keys.`);if(zC.has(i))throw new yt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new yt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new yt(`${t}.${i} must be a plain JSON data field.`)}return e}function VC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new yt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new yt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new yt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new yt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function ts(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new yt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Ni(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new yt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function da(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new yt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Uv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new yt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function qh(e,t,n){return Uv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function jC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>kv||n)throw new yt(`${t} must be 1..${kv} visible characters.`);return e}function HC(e,t,n){if(e===void 0)return n;if(!ir.includes(e))throw new yt(`${t} must be one of ${ir.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function Fv(e,t){let i=(Uv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function GC(e,t){let n=e.blend??"normal";if(!Lv.includes(n))throw new yt(`${t}.blend ${JSON.stringify(n)} is not one of ${Lv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function $C(e,t){let n=`proceduralTexture.layers[${t}]`,i=Ru(e,n),r=i.op;if(!Dv.includes(r))throw new yt(`${n}.op ${JSON.stringify(r)} is not one of ${Dv.join(", ")}.`);let s=GC(i,n),a=qh(i.opacity,`${n}.opacity`,1),o={blend:t===0?"normal":s,opacity:t===0?1:a};switch(r){case"solid":return ts(i,["op","color","blend","opacity"],n),{op:r,color:Ni(i.color,`${n}.color`),...o};case"checker":return ts(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),squares:da(i.squares,`${n}.squares`,8,1,fa),...o};case"stripes":return ts(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),count:da(i.count,`${n}.count`,8,1,fa),angleDeg:Fv(i.angleDeg,`${n}.angleDeg`),...o};case"gradient":return ts(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Ni(i.from,`${n}.from`),to:Ni(i.to,`${n}.to`),angleDeg:Fv(i.angleDeg,`${n}.angleDeg`),...o};case"bricks":return ts(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Ni(i.brick,`${n}.brick`),mortar:Ni(i.mortar,`${n}.mortar`),rows:da(i.rows,`${n}.rows`,8,1,fa),cols:da(i.cols,`${n}.cols`,4,1,fa),mortarWidth:qh(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:qh(i.stagger,`${n}.stagger`,0.5),...o};case"noise":return ts(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Ni(i.colorA,`${n}.colorA`),colorB:Ni(i.colorB,`${n}.colorB`),scale:da(i.scale,`${n}.scale`,8,1,fa),octaves:da(i.octaves,`${n}.octaves`,3,1,Jh),seed:da(i.seed,`${n}.seed`,0,-2147483648,2147483647),...o};default:throw new yt(`${n}.op is unsupported.`)}}function KC(e){let t=Ru(e,"proceduralTexture");if(ts(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new yt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function wc(e){let t=Ru(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Ru(KC(t),"proceduralTexture"):t;if(ts(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new yt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<Su||i>wu||(i&i-1)!==0)throw new yt(`proceduralTexture.size must be a power of two between ${Su} and ${wu}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new yt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=VC(r,"proceduralTexture.layers");if(s.length>Mu)throw new yt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${Mu}.`);let a=jC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:HC(n.usage,"proceduralTexture.usage","albedo"),...a!==void 0?{name:a}:{},layers:s.map($C)}}function qa(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let x=0;x<16;x++)o[x]=s.getUint32(c+x*4,!1);for(let x=16;x<64;x++){let _=o[x-15],y=o[x-2],v=rr(_,7)^rr(_,18)^_>>>3,E=rr(y,17)^rr(y,19)^y>>>10;o[x]=o[x-16]+v+o[x-7]+E>>>0}let[l,u,d,f,h,b,m,g]=a;for(let x=0;x<64;x++){let _=rr(h,6)^rr(h,11)^rr(h,25),y=h&b^~h&m,v=g+_+y+WC[x]+o[x]>>>0,E=rr(l,2)^rr(l,13)^rr(l,22),w=l&u^l&d^u&d,T=E+w>>>0;g=m,m=b,b=h,h=f+v>>>0,f=d,d=u,u=l,l=v+T>>>0}let p=[l,u,d,f,h,b,m,g];for(let x=0;x<8;x++)a[x]=a[x]+p[x]>>>0}return[...a].map((c)=>c.toString(16).padStart(8,"0")).join("")}var wu=1024,Su=4,Mu=8,Jh=6,kv=80,fa=256,yt,Dv,Lv,zC,WC,rr=(e,t)=>e>>>t|e<<32-t;var Ja=ut(()=>{Tc();Ac();yt=class yt extends ua{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}};Dv=["solid","checker","stripes","gradient","bricks","noise"],Lv=["normal","multiply","screen","overlay"],zC=new Set(["__proto__","prototype","constructor"]);WC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])});function bt(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new yt(`proceduralTexture V3: ${e}`,t)}function ZC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)bt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)bt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))bt(`${r} must be finite.`);return}if(typeof i!=="object")bt(`${r} must contain only JSON data.`);let a=Array.isArray(i),o=Object.getPrototypeOf(i);if(a?o!==Array.prototype:o!==Object.prototype&&o!==null)bt(`${r} must be a plain JSON ${a?"array":"object"}.`);let c=a?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(a&&(typeof c!=="number"||c>1024))bt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)bt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||JC.has(d))bt(`${r} has a forbidden key.`);if(a&&d==="length")continue;let f=u[d];if(!f.enumerable||!("value"in f))bt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(a&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))bt(`${r} has an invalid array key.`)}if(a&&l.length!==c+1)bt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!a)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function bi(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))bt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))bt(`${n} has unknown field ${r}.`);return i}function jn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)bt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function zv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")bt(`${t} must be boolean.`);return e}function Iu(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)bt(`${n} must be a ${t}-element array.`);return e.map((s,a)=>jn(s,i,r,`${n}[${a}]`))}function Vv(e,t){let n=Iu(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function jv(e,t,n){let i=bi(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:jn(i.x,-4096,4096,`${t}.x`),y:jn(i.y,-4096,4096,`${t}.y`),width:jn(i.width,1,2048,`${t}.width`),height:jn(i.height,1,2048,`${t}.height`)}}function YC(e,t){let n=bi(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...jv(n,t,n.kind)};if(n.kind==="polygon"){bi(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>Cu)bt(`${t}.points requires 3..${Cu} vertices.`);return{kind:"polygon",points:i.map((r,s)=>Iu(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return bi(n,["kind","from","to","width"],t),{kind:"line",from:Iu(n.from,2,`${t}.from`,-4096,4096),to:Iu(n.to,2,`${t}.to`,-4096,4096),width:jn(n.width,1,2048,`${t}.width`)};return bt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function Hv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function QC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function eN(e,t,n,i=0,r=0){let[s,a,o,c]=Hv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(a+r-0.5)),Math.min(t,Math.floor(o+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function Pu(e){ZC(e);let t=bi(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)bt("schemaVersion must be 3.");let n=jn(t.width,4,Mc,"width"),i=jn(t.height,4,Mc,"height"),r=n*i;if(r>XC)bt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!ir.includes(s))bt("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let a=s==="albedo"||s==="emissive",o=t.name;if(o!==void 0&&(typeof o!=="string"||!o.length||o.length>80||[...o].some((g)=>g.charCodeAt(0)<32||g.charCodeAt(0)===127)))bt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>Rc)bt(`operations must be an array with at most ${Rc} entries.`);let l=r,u=0,d=0,f=c.map((g,p)=>{let x=`operations[${p}]`,_=bi(g,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],x);if(_.op==="legacy-v2"){bi(_,["op","spec","alpha","opacity"],x);let K=bi(_.spec,["schemaVersion","size","usage","name","layers"],`${x}.spec`);if(K.schemaVersion!==2)bt(`${x}.spec requires explicit schemaVersion 2.`);let B=wc(K);if(B.size!==n||B.size!==i||B.usage!==s)bt(`${x} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+B.layers.reduce((X,q)=>X+(q.op==="noise"?q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:B,alpha:jn(_.alpha,0,255,`${x}.alpha`,255),opacity:jn(_.opacity,0,255,`${x}.opacity`,255)}}let y=YC(_.shape,`${x}.shape`),v=QC(y),[E,w,T,A]=eN(y,n,i),P=Math.max(0,T-E)*Math.max(0,A-w);if(_.op==="mask")return bi(_,["op","shape","alpha","invert"],x),l+=r+P*v,{op:"mask",shape:y,alpha:jn(_.alpha,0,255,`${x}.alpha`,255),invert:zv(_.invert,`${x}.invert`)};if(_.op!=="paint"&&_.op!=="stamps")return bt(`${x}.op must be paint, mask, stamps or legacy-v2.`);let S={shape:y,rgba:Vv(_.rgba,`${x}.rgba`),opacity:jn(_.opacity,0,255,`${x}.opacity`,255)};if(_.op==="paint")return bi(_,["op","shape","rgba","opacity"],x),l+=P*(v+1),{op:"paint",...S};bi(_,["op","shape","rgba","opacity","count","seed","area","periodic"],x);let R=jn(_.count,1,Sc,`${x}.count`),k=zv(_.periodic,`${x}.periodic`),[C,U,L,O]=Hv(y);if(k&&(L-C>n||O-U>i))bt(`${x} periodic shape bounds must fit one surface period.`);if(u+=R*(k?9:1),u>Sc)bt(`expanded stamps budget exceeds ${Sc}.`);return l+=R*(k?9:1)*Math.min(n,Math.ceil(L-C)+1)*Math.min(i,Math.ceil(O-U)+1)*(v+1),{op:"stamps",...S,count:R,seed:jn(_.seed,0,4294967295,`${x}.seed`),area:jv(_.area,`${x}.area`),periodic:k}}),h;if(t.palette!==void 0){if(!a)bt("palette and dither are supported only for color usages albedo and emissive.");let g=bi(t.palette,["colors","dither"],"palette"),p=g.colors;if(!Array.isArray(p)||p.length<1||p.length>Nu)bt(`palette.colors requires 1..${Nu} entries.`);let x=g.dither===void 0?"none":g.dither;if(x!=="none"&&x!=="bayer4")bt("palette.dither must be none or bayer4.");h={colors:p.map((_,y)=>jn(_,0,16777215,`palette.colors[${y}]`)),dither:x},l+=r*(p.length+1)}if(l>Bv)bt(`estimated work budget ${l} exceeds ${Bv}.`);if(r*4+d>qC)bt("transient allocation budget exceeded.");let b={schemaVersion:3,width:n,height:i,usage:s,...o!==void 0?{name:o}:{},background:t.background===void 0?[0,0,0,0]:Vv(t.background,"background"),operations:f,...h?{palette:h}:{}},m=JSON.stringify(b);if(m.length>262144)bt("canonical JSON byte budget exceeded.");return{spec:b,canonicalJson:m,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Zh(e){return Pu(e).spec}function tN(e){return Pu(e).canonicalJson}function Yh(e){return`sha256:${qa(`${Za}
-${tN(e)}`)}`}var Za="kiln.procedural-rgba.v3.1",Mc=1024,XC=1048576,Rc=64,Cu=64,Sc=256,Nu=32,Bv=64000000,qC=67108864,JC;var Ou=ut(()=>{Ja();Tc();JC=new Set(["__proto__","prototype","constructor"])});function ku(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new yt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new yt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new yt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:Qh,magFilter:ep,wrapS:Ic,wrapT:Ic};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new yt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new yt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Qh,ep,Ic;var Du=ut(()=>{Ja();Qh=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],ep=["nearest","linear"],Ic=["repeat","clamp-to-edge","mirrored-repeat"]});function Xv(e){return e.pack===void 0?Kv:Wv}function nN(e){return e.pack===void 0?ha:Nr}function He(e){throw new qv(e)}function ip(e){let t=0,n=0,i=new TextEncoder,r=(a)=>{if(n+=a,n>ha.jsonBytes)He("JSON byte budget exceeded.")},s=(a,o)=>{if(++t>65536||o>16)He("JSON node/depth budget exceeded.");if(a===null||typeof a==="boolean"){r(a===!1?5:4);return}if(typeof a==="number"){if(!Number.isFinite(a))He("JSON numbers must be finite.");r(JSON.stringify(a).length);return}if(typeof a==="string"){if(a.length>4096)He("JSON string budget exceeded.");r(i.encode(JSON.stringify(a)).length);return}if(typeof a!=="object")He("plain JSON data is required.");let c=Array.isArray(a),l=Object.getPrototypeOf(a);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)He("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(a,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))He("JSON array budget exceeded.");let d=Reflect.ownKeys(a);if(d.length>1024||c&&d.length!==u+1)He("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let f of d){if(c&&f==="length")continue;if(typeof f!=="string"||["__proto__","prototype","constructor"].includes(f))He("forbidden JSON field.");if(f.length>4096)He("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(f)).length+1);let h=Object.getOwnPropertyDescriptor(a,f);if(!h.enumerable||!("value"in h))He("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(f)||Number(f)>=u))He("invalid JSON array key.");s(h.value,o+1)}};s(e,0)}function Hn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))He(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))He(`${n} has an unknown field.`);return i}function si(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)He(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function ns(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))He(`${t} must be an exact SHA-256 hash.`);return e}function Gv(e,t){let n=Hn(e,["x","y","width","height"],t);return{x:si(n.x,0,4096,`${t}.x`),y:si(n.y,0,4096,`${t}.y`),width:si(n.width,1,4096,`${t}.width`),height:si(n.height,1,4096,`${t}.height`)}}function Ya(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Jv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)He("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)He("source crop/content dimensions must match; resampling is unsupported.")}function tp(e){return e.kind==="procedural"?`procedural:${Yh(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function rN(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(o)=>{let c=[];for(let l of r){if(!iN(l,o)){c.push(l);continue}if(o.x>l.x)c.push({x:l.x,y:l.y,width:o.x-l.x,height:l.height});if(o.x+o.width<l.x+l.width)c.push({x:o.x+o.width,y:l.y,width:l.x+l.width-o.x-o.width,height:l.height});if(o.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:o.y-l.y});if(o.y+o.height<l.y+l.height)c.push({x:l.x,y:o.y+o.height,width:l.width,height:l.y+l.height-o.y-o.height})}if(r=c.filter((l,u)=>!c.some((d,f)=>f!==u&&$v(d,l)&&(!$v(l,d)||f<u))),r.length>16384)He("pack: free-space bookkeeping budget exceeded.")};for(let o of n)s(o);let a=[...i].sort((o,c)=>c.width*c.height-o.width*o.height||(o.region.name<c.region.name?-1:o.region.name>c.region.name?1:0));for(let o of a){let c,l;for(let u of r){if(u.width<o.width||u.height<o.height)continue;let d=u.width-o.width,f=u.height-o.height,h=[Math.min(d,f),Math.max(d,f),u.y,u.x];if(!l||h[0]<l[0]||h[0]===l[0]&&(h[1]<l[1]||h[1]===l[1]&&(h[2]<l[2]||h[2]===l[2]&&h[3]<l[3])))c=u,l=h}if(!c)He(`pack: region ${o.region.name} (${o.width}x${o.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);o.region.content={x:c.x+o.region.gutter,y:c.y+o.region.gutter,width:o.region.content.width,height:o.region.content.height},s({x:c.x,y:c.y,width:o.width,height:o.height})}}function pa(e){ip(e);let t=Hn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)He("schemaVersion must be 1.");let n;if(t.pack!==void 0){let f=Hn(t.pack,["edge","gutter","algorithm"],"pack");if(!np.includes(f.edge))He("pack.edge must be 1024 or 2048.");if(f.algorithm!==void 0&&f.algorithm!=="maxrects")He("pack.algorithm must be 'maxrects'.");n={edge:f.edge,gutter:f.gutter===void 0?2:si(f.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Nr:ha,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:si(t.width,4,r,"width"),a=n&&t.height===void 0?n.edge:si(t.height,4,r,"height");if(s*a>i.outputTexels)He("output texel budget exceeded.");if(!ir.includes(t.usage))He("usage must be a texture usage.");let o=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)He(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((f,h)=>{let b=Hn(f,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${h}]`);if(typeof b.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(b.name))He("region name must be a stable lowercase identifier.");let m=b.content!==void 0;if(!m&&!n)He(`region ${b.name}: content is required unless the atlas sets pack.`);if(b.packed!==void 0&&(b.packed!==!0||!n||!m))He("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let g=m?Gv(b.content,"content"):void 0,p=b.gutter===void 0?n?.gutter??2:si(b.gutter,0,32,"gutter"),x=b.edgeMode===void 0?"copy-edge":b.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(x))He("unsupported edgeMode.");if(x==="mask-rgb-dilate"&&o!=="albedo"&&o!=="emissive")He("mask RGB dilation requires color usage.");let _=Hn(b.source,["kind","spec","resourceId","pin","expected"],"source"),y,v=b.crop===void 0?void 0:Gv(b.crop,"crop");if(_.kind==="procedural"){Hn(_,["kind","spec"],"procedural source");let w=Pu(_.spec);if(w.spec.usage!==o)He("source usage does not match atlas usage.");y={kind:"procedural",spec:w.spec},v??={x:0,y:0,width:w.spec.width,height:w.spec.height},g??={x:0,y:0,width:v.width,height:v.height},Jv(v,g,w.spec.width,w.spec.height)}else if(_.kind==="resource"){if(Hn(_,["kind","resourceId","pin","expected"],"resource source"),typeof _.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(_.resourceId))He("source resourceId must be an exact returned map ID.");let w=Hn(_.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof w.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(w.resourceId))He("pin resourceId must be a material ID.");let T=ns(w.revisionId,"pin revisionId"),A=ns(w.sha256,"pin sha256");if(T!==A)He("source pin revision/hash mismatch.");let P;if(_.expected!==void 0){let S=Hn(_.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");P={...S.width===void 0?{}:{width:si(S.width,1,4096,"expected.width")},...S.height===void 0?{}:{height:si(S.height,1,4096,"expected.height")},...S.imageSha256===void 0?{}:{imageSha256:ns(S.imageSha256,"expected.imageSha256")},...S.decodedPixelHash===void 0?{}:{decodedPixelHash:ns(S.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:_.resourceId,pin:{resourceId:w.resourceId,revisionId:T,sha256:A},...P?{expected:P}:{}},!g){let S=v??(P?.width!==void 0&&P.height!==void 0?{width:P.width,height:P.height}:He(`region ${b.name}: a packed resource region needs a crop or expected width and height (its size).`));g={x:0,y:0,width:S.width,height:S.height}}if(v&&(v.width!==g.width||v.height!==g.height))He("source crop/content dimensions must match; resampling is unsupported.")}else He("source kind must be procedural or pinned resource.");let E={name:b.name,content:g,gutter:p,edgeMode:x,source:y,...v?{crop:v}:{},...n&&(!m||b.packed===!0)?{packed:!0}:{}};if(!m)c.push({region:E,width:E.content.width+2*p,height:E.content.height+2*p});return E}).sort((f,h)=>f.name<h.name?-1:f.name>h.name?1:0);if(new Set(l.map((f)=>f.name)).size!==l.length)He("duplicate region name.");if(c.length){let f=new Set(c.map((h)=>h.region));rN(s,a,l.filter((h)=>!f.has(h)).map((h)=>Ya(h)),c)}for(let f of l){let h=Ya(f);if(h.x<0||h.y<0||h.x+h.width>s||h.y+h.height>a)He("padded allocation is out of bounds.")}for(let f=0;f<l.length;f++)for(let h=f+1;h<l.length;h++){let b=Ya(l[f]),m=Ya(l[h]);if(b.x<m.x+m.width&&m.x<b.x+b.width&&b.y<m.y+m.height&&m.y<b.y+b.height)He(`padded allocations overlap: ${l[f].name}, ${l[h].name}.`)}if(new Set(l.map((f)=>tp(f.source))).size>i.sources)He(`distinct source budget exceeds ${i.sources}.`);let u;try{u=ku(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(f){He(`sampler: ${f.message}`)}let d={schemaVersion:1,width:s,height:a,usage:o,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>ha.jsonBytes)He("canonical JSON byte budget exceeded.");return d}function sN(e){let t=pa(e);return`sha256:${qa(`${Xv(t)}
-${JSON.stringify(t)}`)}`}function Rn(e){ip(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function aN(e){return`sha256:${qa(`kiln.atlas-layout.v1
-${Rn({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ya(t)}))})}`)}`}function Cc(e,t){ip(e);let n=pa(t),i=Hn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==Xv(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")He("manifest version/compiler/dimensions/usage/origin mismatch.");if(Rn(i.sampler)!==Rn(n.sampler)||i.specHash!==sN(n)||i.layoutHash!==aN(n))He("manifest sampler/spec/layout identity mismatch.");ns(i.decodedPixelHash,"manifest decodedPixelHash"),ns(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[tp(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)He("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=Hn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))He("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)He("manifest source identity mismatch.");let d=si(l.width,1,4096,"manifest source width"),f=si(l.height,1,4096,"manifest source height");if(ns(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(Hn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||f!==u.spec.height||l.recipeHash!==Yh(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")He("manifest procedural source identity mismatch.")}else{Hn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let h=Hn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),b={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(h.materialId!==u.pin.resourceId||h.revisionId!==u.pin.revisionId||h.resourceId!==u.resourceId||h.width!==d||h.height!==f||h.usage!==n.usage||typeof h.slot!=="string"||b[h.slot]!==n.usage||h.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))He("manifest pinned resource descriptor mismatch.");if(ns(h.imageSha256,"manifest source imageSha256"),si(h.encodedByteLength,1,nN(n).encodedSourceBytes,"manifest encodedByteLength"),h.decodedPixelHash!==void 0&&h.decodedPixelHash!==l.decodedPixelHash)He("manifest source decodedPixelHash mismatch.");for(let m of["width","height","imageSha256","decodedPixelHash"]){let g=u.expected?.[m];if(g!==void 0&&g!==(m==="decodedPixelHash"?l[m]:h[m]))He("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:f})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=Hn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=tp(l.source),f=s.get(d),h=l.crop??{x:0,y:0,width:f.width,height:f.height};if(Jv(h,l.content,f.width,f.height),u.name!==l.name||u.sourceId!==d||Rn(u.content)!==Rn(l.content)||Rn(u.allocation)!==Rn(Ya(l))||Rn(u.crop)!==Rn(h))He("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:a,...o}=i;if(a!==`sha256:${qa(`kiln.atlas-manifest.v1
-${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kiln.texture-atlas.v1.1",Wv="kiln.texture-atlas.v1.2",Lu,ha,Nr,np,qv,iN=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,$v=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;var Fu=ut(()=>{Du();Ou();Ja();Tc();Ac();Lu=Object.freeze([Kv,Wv]),ha=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Nr=Object.freeze({...ha,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),np=Object.freeze([1024,2048]);qv=class qv extends ua{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}});function _N(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function vN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vo(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function $T(){let e=vo("canvas");return e.style.display="block",e}function Wc(...e){let t="THREE."+e.shift();if(Eo)Eo("log",t,...e);else console.log(t,...e)}function KT(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function je(...e){e=KT(e);let t="THREE."+e.shift();if(Eo)Eo("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Ye(...e){e=KT(e);let t="THREE."+e.shift();if(Eo)Eo("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function ya(...e){let t=e.join(" ");if(t in pE)return;pE[t]=!0,je(...e)}function WT(e,t,n){return new Promise(function(i,r){function s(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}class Vi{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}function Fi(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(On[e&255]+On[e>>8&255]+On[e>>16&255]+On[e>>24&255]+"-"+On[t&255]+On[t>>8&255]+"-"+On[t>>16&15|64]+On[t>>24&255]+"-"+On[n&63|128]+On[n>>8&255]+"-"+On[n>>16&255]+On[n>>24&255]+On[i&255]+On[i>>8&255]+On[i>>16&255]+On[i>>24&255]).toLowerCase()}function ct(e,t,n){return Math.max(t,Math.min(n,e))}function km(e,t){return(e%t+t)%t}function EN(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function TN(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function Kc(e,t,n){return(1-n)*e+n*t}function AN(e,t,n,i){return Kc(e,t,1-Math.exp(-n*i))}function wN(e,t=1){return t-Math.abs(km(e,t*2)-t)}function SN(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 MN(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 RN(e,t){return e+Math.floor(Math.random()*(t-e+1))}function IN(e,t){return e+Math.random()*(t-e)}function CN(e){return e*(0.5-Math.random())}function NN(e){if(e!==void 0)mE=e;let t=mE+=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 PN(e){return e*$c}function ON(e){return e*_a}function kN(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function DN(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function LN(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function FN(e,t,n,i,r){let{cos:s,sin:a}=Math,o=s(n/2),c=a(n/2),l=s((t+i)/2),u=a((t+i)/2),d=s((t-i)/2),f=a((t-i)/2),h=s((i-t)/2),b=a((i-t)/2);switch(r){case"XYX":e.set(o*u,c*d,c*f,o*l);break;case"YZY":e.set(c*f,o*u,c*d,o*l);break;case"ZXZ":e.set(c*d,c*f,o*u,o*l);break;case"XZX":e.set(o*u,c*b,c*h,o*l);break;case"YXY":e.set(c*h,o*u,c*b,o*l);break;case"ZYZ":e.set(c*b,c*h,o*u,o*l);break;default:je("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Li(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 Nt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}function UN(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,a){if(this.enabled===!1||s===a||!s||!a)return r;if(this.spaces[s].transfer==="srgb")r.r=Ur(r.r),r.g=Ur(r.g),r.b=Ur(r.b);if(this.spaces[s].primaries!==this.spaces[a].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ);if(this.spaces[a].transfer==="srgb")r.r=_o(r.r),r.g=_o(r.g),r.b=_o(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return ya("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return ya("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:bE,fromXYZ:xE,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:bE,fromXYZ:xE,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}function Ur(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function _o(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}class Dm{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(so===void 0)so=vo("canvas");so.width=e.width,so.height=e.height;let i=so.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=so}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=vo("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]=Ur(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(Ur(t[n]/255)*255);else t[n]=Ur(t[n]);return{data:t,width:e.width,height:e.height}}else return je("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class tl{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:BN++}),this.uuid=Fi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,a=i.length;s<a;s++)if(i[s].isDataTexture)r.push(fp(i[s].image));else r.push(fp(i[s]))}else r=fp(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function fp(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Dm.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return je("Texture: Unable to serialize Texture."),{}}class Md{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}class nl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new cr,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 cr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new cr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,a=this._targetRay,o=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let b of e.hand.values()){let m=t.getJointPose(b,n),g=this._getHandJoint(c,b);if(m!==null)g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius;g.visible=m!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),f=0.02,h=0.005;if(c.inputState.pinching&&d>f+h)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=f-h)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity);else o.hasLinearVelocity=!1;if(r.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity);else o.hasAngularVelocity=!1;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(a!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity);else a.hasLinearVelocity=!1;if(i.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity);else a.hasAngularVelocity=!1;this.dispatchEvent(WN)}}}if(a!==null)a.visible=i!==null;if(o!==null)o.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new cr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}function mp(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 _i{constructor(e=new j,t=new j,n=new j){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ki.subVectors(e,t),i.cross(ki);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){ki.subVectors(i,t),Or.subVectors(n,t),gp.subVectors(e,t);let s=ki.dot(ki),a=ki.dot(Or),o=ki.dot(gp),c=Or.dot(Or),l=Or.dot(gp),u=s*c-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(c*o-a*l)*d,h=(s*l-a*o)*d;return r.set(1-f-h,h,f)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,kr)===null)return!1;return kr.x>=0&&kr.y>=0&&kr.x+kr.y<=1}static getInterpolation(e,t,n,i,r,s,a,o){if(this.getBarycoord(e,t,n,i,kr)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(r,kr.x),o.addScaledVector(s,kr.y),o.addScaledVector(a,kr.z),o}static getInterpolatedAttribute(e,t,n,i,r,s){return _p.setScalar(0),vp.setScalar(0),Ep.setScalar(0),_p.fromBufferAttribute(e,t),vp.fromBufferAttribute(e,n),Ep.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(_p,r.x),s.addScaledVector(vp,r.y),s.addScaledVector(Ep,r.z),s}static isFrontFacing(e,t,n,i){return ki.subVectors(n,t),Or.subVectors(e,t),ki.cross(Or).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 ki.subVectors(this.c,this.b),Or.subVectors(this.a,this.b),ki.cross(Or).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return _i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return _i.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return _i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,a;lo.subVectors(i,n),uo.subVectors(r,n),bp.subVectors(e,n);let o=lo.dot(bp),c=uo.dot(bp);if(o<=0&&c<=0)return t.copy(n);xp.subVectors(e,i);let l=lo.dot(xp),u=uo.dot(xp);if(l>=0&&u<=l)return t.copy(i);let d=o*u-l*c;if(d<=0&&o>=0&&l<=0)return s=o/(o-l),t.copy(n).addScaledVector(lo,s);yp.subVectors(e,r);let f=lo.dot(yp),h=uo.dot(yp);if(h>=0&&f<=h)return t.copy(r);let b=f*c-o*h;if(b<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(uo,a);let m=l*h-f*u;if(m<=0&&u-l>=0&&f-h>=0)return SE.subVectors(r,i),a=(u-l)/(u-l+(f-h)),t.copy(i).addScaledVector(SE,a);let g=1/(m+b+d);return s=b*g,a=d*g,t.copy(n).addScaledVector(lo,s).addScaledVector(uo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class pn{constructor(e=new j(1/0,1/0,1/0),t=new j(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Di.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Di.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=Di.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,a=r.count;s<a;s++){if(e.isMesh===!0)e.getVertexPosition(s,Di);else Di.fromBufferAttribute(r,s);Di.applyMatrix4(e.matrixWorld),this.expandByPoint(Di)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();ju.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();ju.copy(n.boundingBox)}ju.applyMatrix4(e.matrixWorld),this.union(ju)}}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,Di),Di.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(Uc),Hu.subVectors(this.max,Uc),fo.subVectors(e.a,Uc),ho.subVectors(e.b,Uc),po.subVectors(e.c,Uc),ss.subVectors(ho,fo),as.subVectors(po,ho),ma.subVectors(fo,po);let t=[0,-ss.z,ss.y,0,-as.z,as.y,0,-ma.z,ma.y,ss.z,0,-ss.x,as.z,0,-as.x,ma.z,0,-ma.x,-ss.y,ss.x,0,-as.y,as.x,0,-ma.y,ma.x,0];if(!Tp(t,fo,ho,po,Hu))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Tp(t,fo,ho,po,Hu))return!1;return Gu.crossVectors(ss,as),t=[Gu.x,Gu.y,Gu.z],Tp(t,fo,ho,po,Hu)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Di).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Di).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 Dr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dr),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}function Tp(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){ga.fromArray(e,s);let o=r.x*Math.abs(ga.x)+r.y*Math.abs(ga.y)+r.z*Math.abs(ga.z),c=t.dot(ga),l=n.dot(ga),u=i.dot(ga);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}class ui{constructor(e=new j,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else qN.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;Bc.subVectors(e,this.center);let t=Bc.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(Bc,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 Ap.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bc.copy(e.center).add(Ap)),this.expandByPoint(Bc.copy(e.center).sub(Ap));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}class il{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=Fi()}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=Fi();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=Fi();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}class Oo{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyMatrix4(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyNormalMatrix(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.transformDirection(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Li(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=Nt(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=Li(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Li(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Li(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Li(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(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=Nt(t,this.array),n=Nt(n,this.array),i=Nt(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=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array),r=Nt(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){Wc("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 En(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 Oo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){Wc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}class yi{constructor(e=new j(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Sp.subVectors(n,t).cross(ZN.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(Sp),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||YN.getNormalMatrix(e),i=this.coplanarPoint(Sp).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}class ms{constructor(e=new j,t=new j(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Lr)),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=Lr.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Lr.copy(this.origin).addScaledVector(this.direction,t),Lr.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Mp.copy(e).add(t).multiplyScalar(0.5),Ku.copy(t).sub(e).normalize(),Wu.copy(this.origin).sub(Mp);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ku),a=Wu.dot(this.direction),o=-Wu.dot(Ku),c=Wu.lengthSq(),l=Math.abs(1-s*s),u,d,f,h;if(l>0)if(u=s*o-a,d=s*a-o,h=r*l,u>=0)if(d>=-h)if(d<=h){let b=1/l;u*=b,d*=b,f=u*(u+s*d+2*a)+d*(s*u+d+2*o)+c}else d=r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else d=-r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;else if(d<=-h)u=Math.max(0,-(-s*r+a)),d=u>0?-r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else if(d<=h)u=0,d=Math.min(Math.max(-r,-o),r),f=d*(d+2*o)+c;else u=Math.max(0,-(s*r+a)),d=u>0?r:Math.min(Math.max(-r,-o),r),f=-u*u+d*(d+2*o)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+a)),f=-u*u+d*(d+2*o)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Mp).addScaledVector(Ku,d);return f}intersectSphere(e,t){if(e.radius<0)return null;Lr.subVectors(e.center,this.origin);let n=Lr.dot(this.direction),i=Lr.dot(Lr)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),a=n-s,o=n+s;if(o<0)return null;if(a<0)return this.at(o,t);return this.at(a,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,a,o,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)a=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else a=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||a>i)return null;if(a>n||n!==n)n=a;if(o<i||i!==i)i=o;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Lr)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,a=this.direction,{x:o,y:c,z:l}=a,u=e.x-s.x,d=e.y-s.y,f=e.z-s.z,h=t.x-s.x,b=t.y-s.y,m=t.z-s.z,g=n.x-s.x,p=n.y-s.y,x=n.z-s.z,_=Math.abs(o),y=Math.abs(c),v=Math.abs(l),E,w,T,A,P,S,R,k,C,U,L,O;if(_>=y&&_>=v)if(T=o,S=u,C=h,O=g,o>=0)E=c,w=l,A=d,P=f,R=b,k=m,U=p,L=x;else E=l,w=c,A=f,P=d,R=m,k=b,U=x,L=p;else if(y>=v)if(T=c,S=d,C=b,O=p,c>=0)E=l,w=o,A=f,P=u,R=m,k=h,U=x,L=g;else E=o,w=l,A=u,P=f,R=h,k=m,U=g,L=x;else if(T=l,S=f,C=m,O=x,l>=0)E=o,w=c,A=u,P=d,R=h,k=b,U=g,L=p;else E=c,w=o,A=d,P=u,R=b,k=h,U=p,L=g;if(T===0)return null;let K=E/T,B=w/T,X=1/T,q=A-K*S,le=P-B*S,de=R-K*C,Me=k-B*C,pe=U-K*O,J=L-B*O,F=pe*Me-J*de,W=q*J-le*pe,ne=de*le-Me*q;if(i){if(F<0||W<0||ne<0)return null}else if((F<0||W<0||ne<0)&&(F>0||W>0||ne>0))return null;let ie=F+W+ne;if(ie===0)return null;let ce=X*(F*S+W*C+ne*O);if(ie>0?ce<0:ce>0)return null;return this.at(ce/ie,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}function eP(e,t,n,i,r,s,a,o){let c;if(t.side===1)c=i.intersectTriangle(a,s,r,!0,o);else c=i.intersectTriangle(r,s,a,t.side===0,o);if(c===null)return null;Qu.copy(o),Qu.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Qu);if(l<n.near||l>n.far)return null;return{distance:l,point:Qu.clone(),object:e}}function ed(e,t,n,i,r,s,a,o,c,l){e.getVertexPosition(o,qu),e.getVertexPosition(c,Ju),e.getVertexPosition(l,Zu);let u=eP(e,t,n,i,qu,Ju,Zu,IE);if(u){let d=new j;if(_i.getBarycoord(IE,qu,Ju,Zu,d),r)u.uv=_i.getInterpolatedAttribute(r,o,c,l,d,new Ke);if(s)u.uv1=_i.getInterpolatedAttribute(s,o,c,l,d,new Ke);if(a){if(u.normal=_i.getInterpolatedAttribute(a,o,c,l,d,new j),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let f={a:o,b:c,c:l,normal:new j,materialIndex:0};_i.getNormal(qu,Ju,Zu,f.normal),u.face=f,u.barycoord=d}return u}class al{constructor(e=[],t=[]){this.uuid=Fi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){je("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Je;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let a=e[r]?e[r].matrixWorld:nP;kE.multiplyMatrices(a,t[r]),kE.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new al(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 sl(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)je("Skeleton: No bone found with UUID:",r),s=new rl;this.bones.push(s),this.boneInverses.push(new Je().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}}class ol{constructor(e=new yi,t=new yi,n=new yi,i=new yi,r=new yi,s=new yi){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],c=r[3],l=r[4],u=r[5],d=r[6],f=r[7],h=r[8],b=r[9],m=r[10],g=r[11],p=r[12],x=r[13],_=r[14],y=r[15];if(i[0].setComponents(c-s,f-l,g-h,y-p).normalize(),i[1].setComponents(c+s,f+l,g+h,y+p).normalize(),i[2].setComponents(c+a,f+u,g+b,y+x).normalize(),i[3].setComponents(c-a,f-u,g-b,y-x).normalize(),n)i[4].setComponents(o,d,m,_).normalize(),i[5].setComponents(c-o,f-d,g-m,y-_).normalize();else if(i[4].setComponents(c-o,f-d,g-m,y-_).normalize(),t===2000)i[5].setComponents(c+o,f+d,g+m,y+_).normalize();else if(t===2001)i[5].setComponents(o,d,m,_).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();xa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();xa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xa)}intersectsSprite(e){xa.center.set(0,0,0);let t=rP.distanceTo(e.center);return xa.radius=0.7071067811865476+t,xa.applyMatrix4(e.matrixWorld),this.intersectsSphere(xa)}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(id.x=i.normal.x>0?e.max.x:e.min.x,id.y=i.normal.y>0?e.max.y:e.min.y,id.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(id)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function sd(e,t,n,i,r,s,a){let o=e.geometry.attributes.position;if(dd.fromBufferAttribute(o,r),fd.fromBufferAttribute(o,s),n.distanceSqToSegment(dd,fd,Np,UE)>i)return;Np.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Np);if(l<t.near||l>t.far)return;return{distance:l,point:UE.clone().applyMatrix4(e.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:e}}function jE(e,t,n,i,r,s,a){let o=kp.distanceSqToPoint(e);if(o<n){let c=new j;kp.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}function Ra(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(HE(r))if(r.isRenderTargetTexture)je("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(HE(r[0])){let s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();t[n][i]=s}else t[n][i]=r.slice();else t[n][i]=r}}return t}function Fn(e){let t={};for(let n=0;n<e.length;n++){let i=Ra(e[n]);for(let r in i)t[r]=i[r]}return t}function HE(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function sP(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Bm(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return ot.workingColorSpace}function cs(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 ud(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function cP(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 GE(e,t,n){let i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){let o=n[s]*t;for(let c=0;c!==t;++c)r[a++]=e[o+c]}return r}function lP(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let a=s[i];if(a===void 0)return;if(Array.isArray(a))do{if(a=s[i],a!==void 0)t.push(s.time),n.push(...a);s=e[r++]}while(s!==void 0);else if(a.toArray!==void 0)do{if(a=s[i],a!==void 0)t.push(s.time),a.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(a=s[i],a!==void 0)t.push(s.time),n.push(a);s=e[r++]}while(s!==void 0)}class Vr{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let a=t[1];if(e<a)n=2,r=a;for(let o=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let a=n+s>>>1;if(e<t[a])s=a;else n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}function ZT(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 uP(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 dP(e,t,n,i,r){let s=(e-t)/(r-t);for(let a=0;a<8;a++){let o=ZT(s,t,n,i,r)-e;if(Math.abs(o)<0.0000000001)break;let c=uP(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-o/c))}return s}class fi{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=cs(t,this.TimeBufferType),this.values=cs(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:cs(e.times,Array),values:cs(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(ud(e.settings))n.settings={inTangents:cs(e.settings.inTangents,Array),outTangents:cs(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Gm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ld(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Hm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new $m(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return je("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(ud(this.settings))$E(this.settings.inTangents,e),$E(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let a=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*a,s*a)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Ye("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Ye("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let a=0;a!==r;a++){let o=n[a];if(typeof o==="number"&&isNaN(o)){Ye("KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(s!==null&&s>o){Ye("KeyframeTrack: Out of order keys.",this,a,o,s),e=!1;break}s=o}if(i!==void 0){if(vN(i))for(let a=0,o=i.length;a!==o;++a){let c=i[a];if(isNaN(c)){Ye("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let a=1;a<r;++a){let o=!1,c=e[a],l=e[a+1];if(c!==l&&(a!==1||c!==e[0]))if(!i){let u=a*n,d=u-n,f=u+n;for(let h=0;h!==n;++h){let b=t[u+h];if(b!==t[d+h]||b!==t[f+h]){o=!0;break}}}else o=!0;if(o){if(a!==s){e[s]=e[a];let u=a*n,d=s*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++s}}if(r>0){e[s]=e[r];for(let a=r*n,o=s*n,c=0;c!==n;++c)t[o+c]=t[a+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,ud(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function $E(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}class To{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Fi(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,a=n.length;s!==a;++s)t.push(hP(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(fi.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let a=0;a<r;a++){let o=[],c=[];o.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);let l=cP(o);if(o=GE(o,1,l),c=GE(c,1,l),!i&&o[0]===0)o.push(r),c.push(c[0]);s.push(new ys(".morphTargetInfluences["+t[a].name+"]",o,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let c=e[a],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let a in i)s.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function fP(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ys;case"vector":case"vector2":case"vector3":case"vector4":return Ia;case"color":return Fd;case"quaternion":return _s;case"bool":case"boolean":return xs;case"string":return vs}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function hP(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=fP(e.type);if(e.times===void 0){let i=[],r=[];lP(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(ud(e.settings))n.settings={inTangents:cs(e.settings.inTangents,Float32Array),outTangents:cs(e.settings.outTangents,Float32Array)};return n}function KE(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class dl{constructor(e,t,n){let i=this,r=!1,s=0,a=0,o=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(a++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,a)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,a);if(s===a){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),o)return o(l);return l},this.setURLModifier=function(l){return o=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],h=c[u+1];if(f.global)f.lastIndex=0;if(f.test(l))return h}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}class jr{constructor(e){if(this.manager=e!==void 0?e:YT,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}class hl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ke(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ol,this._frameExtents=new Ke(1,1),this._viewportCount=1,this._viewports=[new Pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;WE.setFromMatrixPosition(e.matrixWorld),t.position.copy(WE),XE.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(XE),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){Pp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Pp,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,s=i?i.z/r.x:1,a=i?i.w/r.y:1,o=i?i.x/r.x:0,c=i?i.y/r.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,1,0,0,0,0,1);else t.set(0.5*s,0,0,0.5*s+o,0,0.5*a,0,0.5*a+c,0,0,0.5,0.5,0,0,0,1);t.multiply(Pp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Es{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}class Jm{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let a=0;a!==i;++a)n[r+a]=n[a];s=t}else{s+=t;let a=t/s;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let o=t*this._origIndex;this._mixBufferRegion(n,i,o,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,c=t+t;o!==c;++o)if(n[o]!==n[o+t]){a.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){ln.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;ln.multiplyQuaternionsFlat(e,s,e,t,e,n),ln.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let a=0;a!==r;++a){let o=t+a;e[o]=e[o]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let a=t+s;e[a]=e[a]+e[n+s]*i}}}class iA{constructor(e,t,n){let i=n||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Tt{constructor(e,t,n){this.path=t,this.parsedPath=n||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new Tt(e,t,n);else return new Tt.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(pP,"")}static parseTrackName(e){let t=_P.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(vP.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let a=r[s];if(a.name===t||a.uuid===t)return a;let o=n(a.children);if(o)return o}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=Tt.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){je("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Ye("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ye("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){Ye("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){Ye("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ye("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){Ye("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Ye("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;Ye("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)a=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)a=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){Ye("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ye("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))o=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}class Qm{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,s=r.length,a=Array(s),o={endingStart:2400,endingEnd:2400};for(let c=0;c!==s;++c){let l=r[c].createInterpolant(null);a[c]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){let i=this._clip.duration,r=e._clip.duration,s=r/i,a=i/r;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,s,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;if(e!==null)this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,s=this.timeScale,a=this._timeScaleInterpolant;if(a===null)a=i._lendControlInterpolant(),this._timeScaleInterpolant=a;let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,o[1]=r+n,c[0]=e/s,c[1]=t/s,this}stopWarping(){let e=this._timeScaleInterpolant;if(e!==null)this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e);return this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}let r=this._startTime;if(r!==null){let o=(e-r)*n;if(o<0||n===0)t=0;else this._startTime=null,t=n*o}t*=this._updateTimeScale(e);let s=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulateAdditive(a);break;case 2500:default:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(s),c[l].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(this.stopFading(),i===0)this.enabled=!1}}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(e)[0];if(t*=i,e>n.parameterPositions[1]){if(t===0)this.paused=!0;else{if(this._restoreTimeScale!==null)t=this._restoreTimeScale;this.timeScale=t}this.stopWarping()}}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,s=n===2202;if(e===0){if(r===-1)return i;return s&&(r&1)===1?t-i:i}if(n===2200){if(r===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1)if(e>=0)r=0,this._setEndings(!0,this.repetitions===0,s);else this._setEndings(this.repetitions===0,!0,s);if(i>=t||i<0){let a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);let o=this.repetitions-r;if(o<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(o===1){let c=e<0;this._setEndings(c,!c,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this._loopCount=r,this.time=i;if(s&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;if(n)i.endingStart=2401,i.endingEnd=2401;else{if(e)i.endingStart=this.zeroSlopeAtStart?2401:2400;else i.endingStart=2402;if(t)i.endingEnd=this.zeroSlopeAtEnd?2401:2400;else i.endingEnd=2402}}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,s=this._weightInterpolant;if(s===null)s=i._lendControlInterpolant(),this._weightInterpolant=s;let a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}class pl{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=ct(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(ct(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}function tg(e,t,n,i){let r=TP(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 TP(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var ZE="186",us,ds,YE=0,Dp=1,QE=2,Xc=1,eT=2,Ao=3,fs=0,Dn=1,vi=2,dr=0,qc=1,Lp=2,Fp=3,Up=4,tT=5,wo=100,nT=101,iT=102,rT=103,sT=104,aT=200,oT=201,cT=202,lT=203,uT=204,dT=205,fT=206,hT=207,pT=208,mT=209,gT=210,bT=211,xT=212,yT=213,_T=214,vT=0,ET=1,TT=2,Bp=3,AT=4,wT=5,ST=6,MT=7,RT=0,IT=1,CT=2,Ui=0,zp=1,Vp=2,jp=3,Jc=4,Hp=5,Gp=6,$p=7,So=301,va=302,hd=303,pd=304,Zc=306,Mo=1000,Ro=1001,md=1002,Bi=1003,gd=1004,Ea=1005,Tn=1006,Io=1007,fr=1008,zi=1009,NT=1010,PT=1011,Yc=1012,Kp=1013,hs=1014,Br=1015,hr=1016,Wp=1017,Xp=1018,Co=1020,OT=35902,kT=35899,DT=1021,LT=1022,pr=1023,Ta=1026,Aa=1027,FT=1028,qp=1029,wa=1030,Jp=1031,Zp=1033,bd=33776,xd=33777,yd=33778,_d=33779,Yp=35840,Qp=35841,em=35842,tm=35843,nm=36196,im=37492,rm=37496,sm=37488,am=37489,vd=37490,om=37491,cm=37808,lm=37809,um=37810,dm=37811,fm=37812,hm=37813,pm=37814,mm=37815,gm=37816,bm=37817,xm=37818,ym=37819,_m=37820,vm=37821,Em=36492,Tm=36494,Am=36495,wm=36283,Sm=36284,Ed=36285,Mm=36286,Rm=2300,Td=2301,Im=0,Qc=1,No=2,Cm=0,UT=1,Sa="",ps="srgb",ci="srgb-linear",Nm="linear",Bt="srgb",BT=512,zT=513,VT=514,Ad=515,jT=516,HT=517,wd=518,GT=519,Pm="300 es",Om=2000,pE,Eo=null,XT,On,mE=1234567,$c,_a,el,Ke,ln,j,up,gE,tt,dp,bE,xE,ot,so,BN=0,zN=0,hp,en,Pt,Lm,li,Sd,Fm,Je,ao,Oi,VN,jN,is,Bu,ai,yE,_E,ur,HN=0,vE,oo,Pr,zu,Fc,GN,$N,EE,TE,AE,wE,KN,co,pp,Dt,cr,WN,qT,rs,Vu,qe,kn,Po,ki,Or,gp,kr,lo,uo,SE,bp,xp,yp,_p,vp,Ep,Dr,Di,ju,fo,ho,po,ss,as,ma,Uc,Hu,Gu,ga,cn,$u,XN=0,En,Rd,Id,Xn,qN,Bc,Ap,JN=0,xi,wp,mo,oi,zc,vn,Ln,Gn,Sp,ZN,YN,QN=0,qn,Lr,Mp,Ku,Wu,mr,ME,ba,Xu,RE,qu,Ju,Zu,Rp,Yu,IE,Qu,jt,Vc,CE,NE,tP,PE,td,Ip,OE,Cp,Cd,rl,sl,kE,nP,ls,go,DE,nd,LE,iP,jc,Hc,ko,xa,rP,id,cl,dd,fd,FE,Gc,rd,Np,UE,gs,BE,zE,Nd,Pd,ll,VE,kp,ad,od,Do,Od,Ma,Um,kd,bs,ul,JT,aP=`void main() {
+var EI=Object.create;var{getPrototypeOf:AI,defineProperty:Jf,getOwnPropertyNames:TI}=Object;var Wb=Object.prototype.hasOwnProperty;function wI(e){return this[e]}var MI,SI,Zf=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var i=t?MI??=new WeakMap:SI??=new WeakMap,a=i.get(e);if(a)return a}n=e!=null?EI(AI(e)):{};let s=t||!e||!e.__esModule||!Wb.call(e,"default")?Jf(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of TI(e))if(!Wb.call(s,o))Jf(s,o,{get:wI.bind(e,o),enumerable:!0})}if(r)i.set(e,s);return s};var ta=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var RI=(e)=>e;function II(e,t){this[e]=RI.bind(null,t)}var Xb=(e,t)=>{for(var n in t)Jf(e,n,{get:t[n],enumerable:!0,configurable:!0,set:II.bind(t,n)})};var ot=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};function iN(e){let{jitterX:t,jitterY:n,metricX:r,metricY:i,weight:a}=e,s=(1+t)/2,o=(1+n)/2,c=1+t/2,l=1+n/2,u=op(r*s,i*o)+a,d=Math.min(op(r*c,i*o),op(r*s,i*l))+a,f=e.feature==="facet"?Math.max(d,u+e.facetBlend):d;return{x:Math.max(1,Math.ceil(f/r+s-1)),y:Math.max(1,Math.ceil(f/i+o-1))}}function $0(e){let{x:t,y:n}=iN(e),r=46+Math.ceil((2*t+1)*(2*n+1)/8)+(e.weight>0?10:0);if(e.feature==="border")return r+8;if(e.feature==="facet")return r+32+Math.ceil(e.facetBlend*30);return r}function K0(e){return e.cellsX*e.cellsY*12}function W0(e){return e.cellsX*e.cellsY*48+4096}var ps,Pi=1,Oi=4,eo=1,op=(e,t)=>Math.sqrt(e*e+t*t);var Cc=ot(()=>{ps=["f1","f2","f2-f1","cell","border","facet"]});var ai;var Nc=ot(()=>{ai=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"]});function aN(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws?, images?, decodedBytes?, materialTier? }) takes positive integers for triangles and draws, non-negative integers for images and decodedBytes, and a reference tier such as "web.portable.v1/standard" for materialTier; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="MATERIAL_NAME")return'A material name is the key a destination runtime groups draws by, so it is 1 to 200 visible characters: a plain string, no control characters. gameMaterial, basicMaterial, glassMaterial and lambertMaterial take it in their options object, pbrMaterial and foliageMaterial in theirs, for example gameMaterial(0x25342a, { roughness: 0.58, name: "ParkerisedSteel" }). Omit it to leave the material unnamed; materialRecipe and the portable material specs name their output already.';if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_SOLID_FAILED")return'PROFILE_SOLID_FAILED: extrudeProfile or revolveProfile could not build a solid from this outline. Reduce bevel or set it to 0. Keep the outline one simple closed loop: no self-intersections, repeated points or zero-length edges, and no neck narrower than twice the bevel. Holes must lie inside the outline and leave material. For revolveProfile, keep points off the axis (x = 0) unless the solid should close there. Keep coordinates at asset scale. Render that helper call alone with kiln_render and simplify the outline until it builds. Call kiln_discover with ids ["extrudeProfile", "revolveProfile"].';if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}var ms;var Pc=ot(()=>{ms=class ms extends Error{diagnostic;constructor(e,t=aN(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}});function Uu(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new bt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new bt(`${t} must be a plain JSON object with no custom prototype.`);for(let r of Reflect.ownKeys(e)){if(typeof r!=="string")throw new bt(`${t} must not contain symbol keys.`);if(sN.has(r))throw new bt(`${t} contains forbidden key ${JSON.stringify(r)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,r))throw new bt(`${t}.${r} must be an enumerable JSON field.`);let i=Object.getOwnPropertyDescriptor(e,r);if(!i||!("value"in i))throw new bt(`${t}.${r} must be a plain JSON data field.`)}return e}function oN(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new bt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new bt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new bt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new bt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Li(e,t,n){let r=new Set(t);for(let i of Object.keys(e))if(!r.has(i))throw new bt(`${n} has unknown key ${JSON.stringify(i)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function or(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new bt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function si(e,t,n,r,i){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<r||e>i)throw new bt(`${t} must be a whole number between ${r} and ${i}, got ${JSON.stringify(e)}.`);return e}function to(e,t,n,r,i,a){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<r||e>i)throw new bt(`${t} must be a finite number between ${r} and ${i}, got ${JSON.stringify(e)}.`,a);return e}function Oc(e,t,n){return to(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function cN(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((r)=>{let i=r.charCodeAt(0);return i<32||i===127});if(typeof e!=="string"||e.length===0||e.length>X0||n)throw new bt(`${t} must be 1..${X0} visible characters.`);return e}function lN(e,t,n){if(e===void 0)return n;if(!ai.includes(e))throw new bt(`${t} must be one of ${ai.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function Z0(e,t){let r=(to(e,t,0,-36000,36000)%360+360)%360;return Object.is(r,-0)?0:r}function uN(e,t){let n=e.blend??"normal";if(!J0.includes(n))throw new bt(`${t}.blend ${JSON.stringify(n)} is not one of ${J0.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function kc(e,t,n,r,i){let{name:a,fallback:s,min:o,max:c}=r,l=to(e[a],`${t}.${a}`,s,o,c);if(l!==s&&!i.includes(n)){let u=i.length>1?"features":"feature",d=i.length>1?i.join(", "):JSON.stringify(i[0]);throw new bt(`${t}.${a} applies only to ${u} ${d}, not ${JSON.stringify(n)}. Remove it or change feature.`)}return l}function dN(e,t){let n=e??"f1";if(!ps.includes(n))throw new bt(`${t}.feature ${JSON.stringify(n)} is not one of ${ps.join(", ")}.`);return n}function fN(e,t){let n=`proceduralTexture.layers[${t}]`,r=Uu(e,n),i=r.op;if(!q0.includes(i))throw new bt(`${n}.op ${JSON.stringify(i)} is not one of ${q0.join(", ")}.`);let a=uN(r,n),s=Oc(r.opacity,`${n}.opacity`,1),o={blend:t===0?"normal":a,opacity:t===0?1:s};switch(i){case"solid":return Li(r,["op","color","blend","opacity"],n),{op:i,color:or(r.color,`${n}.color`),...o};case"checker":return Li(r,["op","colorA","colorB","squares","blend","opacity"],n),{op:i,colorA:or(r.colorA,`${n}.colorA`),colorB:or(r.colorB,`${n}.colorB`),squares:si(r.squares,`${n}.squares`,8,1,ki),...o};case"stripes":return Li(r,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:i,colorA:or(r.colorA,`${n}.colorA`),colorB:or(r.colorB,`${n}.colorB`),count:si(r.count,`${n}.count`,8,1,ki),angleDeg:Z0(r.angleDeg,`${n}.angleDeg`),...o};case"gradient":return Li(r,["op","from","to","angleDeg","blend","opacity"],n),{op:i,from:or(r.from,`${n}.from`),to:or(r.to,`${n}.to`),angleDeg:Z0(r.angleDeg,`${n}.angleDeg`),...o};case"bricks":return Li(r,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:i,brick:or(r.brick,`${n}.brick`),mortar:or(r.mortar,`${n}.mortar`),rows:si(r.rows,`${n}.rows`,8,1,ki),cols:si(r.cols,`${n}.cols`,4,1,ki),mortarWidth:Oc(r.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Oc(r.stagger,`${n}.stagger`,0.5),...o};case"noise":return Li(r,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:i,colorA:or(r.colorA,`${n}.colorA`),colorB:or(r.colorB,`${n}.colorB`),scale:si(r.scale,`${n}.scale`,8,1,ki),octaves:si(r.octaves,`${n}.octaves`,3,1,cp),seed:si(r.seed,`${n}.seed`,0,-2147483648,2147483647),...o};case"cellular":{Li(r,["op","colorA","colorB","cellsX","cellsY","seed","jitterX","jitterY","metricX","metricY","weight","feature","range","borderOpen","borderWidth","facetSlope","facetBlend","blend","opacity"],n);let c=dN(r.feature,n);return{op:i,colorA:or(r.colorA,`${n}.colorA`),colorB:or(r.colorB,`${n}.colorB`),cellsX:si(r.cellsX,`${n}.cellsX`,8,1,ki),cellsY:si(r.cellsY,`${n}.cellsY`,8,1,ki),seed:si(r.seed,`${n}.seed`,0,-2147483648,2147483647),jitterX:Oc(r.jitterX,`${n}.jitterX`,1),jitterY:Oc(r.jitterY,`${n}.jitterY`,1),metricX:to(r.metricX,`${n}.metricX`,1,Pi,Oi),metricY:to(r.metricY,`${n}.metricY`,1,Pi,Oi),weight:to(r.weight,`${n}.weight`,0,0,eo),feature:c,range:kc(r,n,c,{name:"range",fallback:1,min:0.01,max:8},["f1","f2","f2-f1","cell"]),borderOpen:kc(r,n,c,{name:"borderOpen",fallback:0.5,min:0,max:1},["border"]),borderWidth:kc(r,n,c,{name:"borderWidth",fallback:0.05,min:0.001,max:1},["border"]),facetSlope:kc(r,n,c,{name:"facetSlope",fallback:0.5,min:0,max:1},["facet"]),facetBlend:kc(r,n,c,{name:"facetBlend",fallback:0.1,min:0.001,max:1},["facet"]),...o}}default:throw new bt(`${n}.op is unsupported.`)}}function hN(e){let t=Uu(e,"proceduralTexture");if(Li(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new bt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function Lc(e){let t=Uu(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Uu(hN(t),"proceduralTexture"):t;if(Li(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new bt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let r=n.size??256;if(typeof r!=="number"||!Number.isInteger(r)||r<Du||r>Lu||(r&r-1)!==0)throw new bt(`proceduralTexture.size must be a power of two between ${Du} and ${Lu}, got ${JSON.stringify(n.size)}.`);let i=n.layers;if(!Array.isArray(i)||i.length===0)throw new bt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let a=oN(i,"proceduralTexture.layers");if(a.length>Fu)throw new bt(`proceduralTexture: ${a.length} layers exceeds the maximum of ${Fu}.`);let s=cN(n.name,"proceduralTexture.name");return{schemaVersion:2,size:r,usage:lN(n.usage,"proceduralTexture.usage","albedo"),...s!==void 0?{name:s}:{},layers:a.map(fN)}}function no(e){let t=new TextEncoder().encode(e),n=t.length*8,r=Math.ceil((t.length+9)/64)*64,i=new Uint8Array(r);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(r-8,Math.floor(n/4294967296),!1),a.setUint32(r-4,n>>>0,!1);let s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),o=new Uint32Array(64);for(let c=0;c<i.length;c+=64){for(let y=0;y<16;y++)o[y]=a.getUint32(c+y*4,!1);for(let y=16;y<64;y++){let v=o[y-15],x=o[y-2],_=oi(v,7)^oi(v,18)^v>>>3,E=oi(x,17)^oi(x,19)^x>>>10;o[y]=o[y-16]+_+o[y-7]+E>>>0}let[l,u,d,f,h,b,m,g]=s;for(let y=0;y<64;y++){let v=oi(h,6)^oi(h,11)^oi(h,25),x=h&b^~h&m,_=g+v+x+pN[y]+o[y]>>>0,E=oi(l,2)^oi(l,13)^oi(l,22),w=l&u^l&d^u&d,A=E+w>>>0;g=m,m=b,b=h,h=f+_>>>0,f=d,d=u,u=l,l=_+A>>>0}let p=[l,u,d,f,h,b,m,g];for(let y=0;y<8;y++)s[y]=s[y]+p[y]>>>0}return[...s].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Lu=1024,Du=4,Fu=8,cp=6,X0=80,ki=256,bt,q0,J0,sN,pN,oi=(e,t)=>e>>>t|e<<32-t;var ro=ot(()=>{Cc();Nc();Pc();bt=class bt extends ms{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}};q0=["solid","checker","stripes","gradient","bricks","noise","cellular"],J0=["normal","multiply","screen","overlay"],sN=new Set(["__proto__","prototype","constructor"]);pN=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])});function xt(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new bt(`proceduralTexture V3: ${e}`,t)}function xN(e){let t=0,n=(r,i,a)=>{if(++t>16384||a>10)xt(`${i} exceeds the JSON size/depth budget.`);if(r===null||typeof r==="boolean")return;if(typeof r==="string"){if(r.length>4096)xt(`${i} string is too long.`);return}if(typeof r==="number"){if(!Number.isFinite(r))xt(`${i} must be finite.`);return}if(typeof r!=="object")xt(`${i} must contain only JSON data.`);let s=Array.isArray(r),o=Object.getPrototypeOf(r);if(s?o!==Array.prototype:o!==Object.prototype&&o!==null)xt(`${i} must be a plain JSON ${s?"array":"object"}.`);let c=s?Object.getOwnPropertyDescriptor(r,"length")?.value:void 0;if(s&&(typeof c!=="number"||c>1024))xt(`${i} array is too long.`);let l=Reflect.ownKeys(r);if(l.length>1024)xt(`${i} has too many fields.`);let u=Object.getOwnPropertyDescriptors(r);for(let d of l){if(typeof d!=="string"||bN.has(d))xt(`${i} has a forbidden key.`);if(s&&d==="length")continue;let f=u[d];if(!f.enumerable||!("value"in f))xt(`${i}.${d} must be an enumerable JSON data field, never an accessor.`);if(s&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))xt(`${i} has an invalid array key.`)}if(s&&l.length!==c+1)xt(`${i} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!s)n(u[d].value,`${i}.${String(d)}`,a+1)};n(e,"recipe",0)}function vr(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))xt(`${n} must be a JSON object.`);let r=e;for(let i of Object.keys(r))if(!t.includes(i))xt(`${n} has unknown field ${i}.`);return r}function Vn(e,t,n,r,i){if(e===void 0&&i!==void 0)return i;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)xt(`${r} must be an integer ${t}..${n}.`);return e===0?0:e}function Q0(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")xt(`${t} must be boolean.`);return e}function zu(e,t,n,r,i){if(!Array.isArray(e)||e.length!==t)xt(`${n} must be a ${t}-element array.`);return e.map((a,s)=>Vn(a,r,i,`${n}[${s}]`))}function eE(e,t){let n=zu(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function tE(e,t,n){let r=vr(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:Vn(r.x,-4096,4096,`${t}.x`),y:Vn(r.y,-4096,4096,`${t}.y`),width:Vn(r.width,1,2048,`${t}.width`),height:Vn(r.height,1,2048,`${t}.height`)}}function yN(e,t){let n=vr(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...tE(n,t,n.kind)};if(n.kind==="polygon"){vr(n,["kind","points"],t);let r=n.points;if(!Array.isArray(r)||r.length<3||r.length>Bu)xt(`${t}.points requires 3..${Bu} vertices.`);return{kind:"polygon",points:r.map((i,a)=>zu(i,2,`${t}.points[${a}]`,-4096,4096))}}if(n.kind==="line")return vr(n,["kind","from","to","width"],t),{kind:"line",from:zu(n.from,2,`${t}.from`,-4096,4096),to:zu(n.to,2,`${t}.to`,-4096,4096),width:Vn(n.width,1,2048,`${t}.width`)};return xt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function nE(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((r)=>r[0]))-n,Math.min(...t.map((r)=>r[1]))-n,Math.max(...t.map((r)=>r[0]))+n,Math.max(...t.map((r)=>r[1]))+n]}function _N(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function vN(e,t,n,r=0,i=0){let[a,s,o,c]=nE(e);return[Math.max(0,Math.ceil(a+r-0.5)),Math.max(0,Math.ceil(s+i-0.5)),Math.min(t,Math.floor(o+r-0.5)+1),Math.min(n,Math.floor(c+i-0.5)+1)]}function Vu(e){xN(e);let t=vr(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)xt("schemaVersion must be 3.");let n=Vn(t.width,4,Fc,"width"),r=Vn(t.height,4,Fc,"height"),i=n*r;if(i>mN)xt("output texel budget exceeded.");let a=t.usage===void 0?"albedo":t.usage;if(!ai.includes(a))xt("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let s=a==="albedo"||a==="emissive",o=t.name;if(o!==void 0&&(typeof o!=="string"||!o.length||o.length>80||[...o].some((g)=>g.charCodeAt(0)<32||g.charCodeAt(0)===127)))xt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>Uc)xt(`operations must be an array with at most ${Uc} entries.`);let l=i,u=0,d=0,f=c.map((g,p)=>{let y=`operations[${p}]`,v=vr(g,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],y);if(v.op==="legacy-v2"){vr(v,["op","spec","alpha","opacity"],y);let K=vr(v.spec,["schemaVersion","size","usage","name","layers"],`${y}.spec`);if(K.schemaVersion!==2)xt(`${y}.spec requires explicit schemaVersion 2.`);let z=Lc(K);if(z.size!==n||z.size!==r||z.usage!==a)xt(`${y} legacy-v2 dimensions and usage must match the V3 surface.`);l+=i*(1+z.layers.reduce((W,q)=>W+(q.op==="noise"?q.octaves*16:q.op==="cellular"?$0(q):4),0)),d+=i*4;for(let W of z.layers){if(W.op!=="cellular")continue;l+=K0(W),d+=W0(W)}return{op:"legacy-v2",spec:z,alpha:Vn(v.alpha,0,255,`${y}.alpha`,255),opacity:Vn(v.opacity,0,255,`${y}.opacity`,255)}}let x=yN(v.shape,`${y}.shape`),_=_N(x),[E,w,A,T]=vN(x,n,r),N=Math.max(0,A-E)*Math.max(0,T-w);if(v.op==="mask")return vr(v,["op","shape","alpha","invert"],y),l+=i+N*_,{op:"mask",shape:x,alpha:Vn(v.alpha,0,255,`${y}.alpha`,255),invert:Q0(v.invert,`${y}.invert`)};if(v.op!=="paint"&&v.op!=="stamps")return xt(`${y}.op must be paint, mask, stamps or legacy-v2.`);let M={shape:x,rgba:eE(v.rgba,`${y}.rgba`),opacity:Vn(v.opacity,0,255,`${y}.opacity`,255)};if(v.op==="paint")return vr(v,["op","shape","rgba","opacity"],y),l+=N*(_+1),{op:"paint",...M};vr(v,["op","shape","rgba","opacity","count","seed","area","periodic"],y);let R=Vn(v.count,1,Dc,`${y}.count`),k=Q0(v.periodic,`${y}.periodic`),[C,U,D,P]=nE(x);if(k&&(D-C>n||P-U>r))xt(`${y} periodic shape bounds must fit one surface period.`);if(u+=R*(k?9:1),u>Dc)xt(`expanded stamps budget exceeds ${Dc}.`);return l+=R*(k?9:1)*Math.min(n,Math.ceil(D-C)+1)*Math.min(r,Math.ceil(P-U)+1)*(_+1),{op:"stamps",...M,count:R,seed:Vn(v.seed,0,4294967295,`${y}.seed`),area:tE(v.area,`${y}.area`),periodic:k}}),h;if(t.palette!==void 0){if(!s)xt("palette and dither are supported only for color usages albedo and emissive.");let g=vr(t.palette,["colors","dither"],"palette"),p=g.colors;if(!Array.isArray(p)||p.length<1||p.length>ju)xt(`palette.colors requires 1..${ju} entries.`);let y=g.dither===void 0?"none":g.dither;if(y!=="none"&&y!=="bayer4")xt("palette.dither must be none or bayer4.");h={colors:p.map((v,x)=>Vn(v,0,16777215,`palette.colors[${x}]`)),dither:y},l+=i*(p.length+1)}if(l>Y0)xt(`estimated work budget ${l} exceeds ${Y0}.`);if(i*4+d>gN)xt("transient allocation budget exceeded.");let b={schemaVersion:3,width:n,height:r,usage:a,...o!==void 0?{name:o}:{},background:t.background===void 0?[0,0,0,0]:eE(t.background,"background"),operations:f,...h?{palette:h}:{}},m=JSON.stringify(b);if(m.length>262144)xt("canonical JSON byte budget exceeded.");return{spec:b,canonicalJson:m,estimatedWorkUnits:l,conservativePixelAllocationBytes:i*4+d}}function lp(e){return Vu(e).spec}function EN(e){return Vu(e).canonicalJson}function up(e){return`sha256:${no(`${io}
+${EN(e)}`)}`}var io="kiln.procedural-rgba.v3.1",Fc=1024,mN=1048576,Uc=64,Bu=64,Dc=256,ju=32,Y0=64000000,gN=67108864,bN;var Gu=ot(()=>{Cc();ro();Nc();bN=new Set(["__proto__","prototype","constructor"])});function Hu(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new bt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new bt("portableSampler must be plain JSON data.");for(let i of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,i);if(typeof i!=="string"||!a.enumerable||!("value"in a))throw new bt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,r={minFilter:dp,magFilter:fp,wrapS:zc,wrapT:zc};if(Object.keys(n).some((i)=>!Object.hasOwn(r,i)))throw new bt("portableSampler contains an unsupported field.");for(let[i,a]of Object.entries(r))if(!a.includes(n[i]))throw new bt(`portableSampler.${i} requires one of ${a.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var dp,fp,zc;var $u=ot(()=>{ro();dp=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],fp=["nearest","linear"],zc=["repeat","clamp-to-edge","mirrored-repeat"]});function oE(e){return e.pack===void 0?aE:sE}function AN(e){return e.pack===void 0?gs:Di}function $e(e){throw new cE(e)}function mp(e){let t=0,n=0,r=new TextEncoder,i=(s)=>{if(n+=s,n>gs.jsonBytes)$e("JSON byte budget exceeded.")},a=(s,o)=>{if(++t>65536||o>16)$e("JSON node/depth budget exceeded.");if(s===null||typeof s==="boolean"){i(s===!1?5:4);return}if(typeof s==="number"){if(!Number.isFinite(s))$e("JSON numbers must be finite.");i(JSON.stringify(s).length);return}if(typeof s==="string"){if(s.length>4096)$e("JSON string budget exceeded.");i(r.encode(JSON.stringify(s)).length);return}if(typeof s!=="object")$e("plain JSON data is required.");let c=Array.isArray(s),l=Object.getPrototypeOf(s);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)$e("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(s,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))$e("JSON array budget exceeded.");let d=Reflect.ownKeys(s);if(d.length>1024||c&&d.length!==u+1)$e("dense bounded JSON fields are required.");i(2+Math.max(0,d.length-(c?1:0)-1));for(let f of d){if(c&&f==="length")continue;if(typeof f!=="string"||["__proto__","prototype","constructor"].includes(f))$e("forbidden JSON field.");if(f.length>4096)$e("JSON field name budget exceeded.");if(!c)i(r.encode(JSON.stringify(f)).length+1);let h=Object.getOwnPropertyDescriptor(s,f);if(!h.enumerable||!("value"in h))$e("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(f)||Number(f)>=u))$e("invalid JSON array key.");a(h.value,o+1)}};a(e,0)}function Gn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))$e(`${n} must be a JSON object.`);let r=e;if(Object.keys(r).some((i)=>!t.includes(i)))$e(`${n} has an unknown field.`);return r}function cr(e,t,n,r){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)$e(`${r} must be an integer ${t}..${n}.`);return e===0?0:e}function oa(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))$e(`${t} must be an exact SHA-256 hash.`);return e}function rE(e,t){let n=Gn(e,["x","y","width","height"],t);return{x:cr(n.x,0,4096,`${t}.x`),y:cr(n.y,0,4096,`${t}.y`),width:cr(n.width,1,4096,`${t}.width`),height:cr(n.height,1,4096,`${t}.height`)}}function ao(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function lE(e,t,n,r){if(e.x+e.width>n||e.y+e.height>r)$e("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)$e("source crop/content dimensions must match; resampling is unsupported.")}function hp(e){return e.kind==="procedural"?`procedural:${up(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}function wN(e,t,n,r){let i=[{x:0,y:0,width:e,height:t}],a=(o)=>{let c=[];for(let l of i){if(!TN(l,o)){c.push(l);continue}if(o.x>l.x)c.push({x:l.x,y:l.y,width:o.x-l.x,height:l.height});if(o.x+o.width<l.x+l.width)c.push({x:o.x+o.width,y:l.y,width:l.x+l.width-o.x-o.width,height:l.height});if(o.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:o.y-l.y});if(o.y+o.height<l.y+l.height)c.push({x:l.x,y:o.y+o.height,width:l.width,height:l.y+l.height-o.y-o.height})}if(i=c.filter((l,u)=>!c.some((d,f)=>f!==u&&iE(d,l)&&(!iE(l,d)||f<u))),i.length>16384)$e("pack: free-space bookkeeping budget exceeded.")};for(let o of n)a(o);let s=[...r].sort((o,c)=>c.width*c.height-o.width*o.height||(o.region.name<c.region.name?-1:o.region.name>c.region.name?1:0));for(let o of s){let c,l;for(let u of i){if(u.width<o.width||u.height<o.height)continue;let d=u.width-o.width,f=u.height-o.height,h=[Math.min(d,f),Math.max(d,f),u.y,u.x];if(!l||h[0]<l[0]||h[0]===l[0]&&(h[1]<l[1]||h[1]===l[1]&&(h[2]<l[2]||h[2]===l[2]&&h[3]<l[3])))c=u,l=h}if(!c)$e(`pack: region ${o.region.name} (${o.width}x${o.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);o.region.content={x:c.x+o.region.gutter,y:c.y+o.region.gutter,width:o.region.content.width,height:o.region.content.height},a({x:c.x,y:c.y,width:o.width,height:o.height})}}function bs(e){mp(e);let t=Gn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)$e("schemaVersion must be 1.");let n;if(t.pack!==void 0){let f=Gn(t.pack,["edge","gutter","algorithm"],"pack");if(!pp.includes(f.edge))$e("pack.edge must be 1024 or 2048.");if(f.algorithm!==void 0&&f.algorithm!=="maxrects")$e("pack.algorithm must be 'maxrects'.");n={edge:f.edge,gutter:f.gutter===void 0?2:cr(f.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let r=n?Di:gs,i=n?n.edge:r.edge,a=n&&t.width===void 0?n.edge:cr(t.width,4,i,"width"),s=n&&t.height===void 0?n.edge:cr(t.height,4,i,"height");if(a*s>r.outputTexels)$e("output texel budget exceeded.");if(!ai.includes(t.usage))$e("usage must be a texture usage.");let o=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>r.regions)$e(`regions must contain 1..${r.regions} entries.`);let c=[],l=t.regions.map((f,h)=>{let b=Gn(f,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${h}]`);if(typeof b.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(b.name))$e("region name must be a stable lowercase identifier.");let m=b.content!==void 0;if(!m&&!n)$e(`region ${b.name}: content is required unless the atlas sets pack.`);if(b.packed!==void 0&&(b.packed!==!0||!n||!m))$e("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let g=m?rE(b.content,"content"):void 0,p=b.gutter===void 0?n?.gutter??2:cr(b.gutter,0,32,"gutter"),y=b.edgeMode===void 0?"copy-edge":b.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(y))$e("unsupported edgeMode.");if(y==="mask-rgb-dilate"&&o!=="albedo"&&o!=="emissive")$e("mask RGB dilation requires color usage.");let v=Gn(b.source,["kind","spec","resourceId","pin","expected"],"source"),x,_=b.crop===void 0?void 0:rE(b.crop,"crop");if(v.kind==="procedural"){Gn(v,["kind","spec"],"procedural source");let w=Vu(v.spec);if(w.spec.usage!==o)$e("source usage does not match atlas usage.");x={kind:"procedural",spec:w.spec},_??={x:0,y:0,width:w.spec.width,height:w.spec.height},g??={x:0,y:0,width:_.width,height:_.height},lE(_,g,w.spec.width,w.spec.height)}else if(v.kind==="resource"){if(Gn(v,["kind","resourceId","pin","expected"],"resource source"),typeof v.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(v.resourceId))$e("source resourceId must be an exact returned map ID.");let w=Gn(v.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof w.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(w.resourceId))$e("pin resourceId must be a material ID.");let A=oa(w.revisionId,"pin revisionId"),T=oa(w.sha256,"pin sha256");if(A!==T)$e("source pin revision/hash mismatch.");let N;if(v.expected!==void 0){let M=Gn(v.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");N={...M.width===void 0?{}:{width:cr(M.width,1,4096,"expected.width")},...M.height===void 0?{}:{height:cr(M.height,1,4096,"expected.height")},...M.imageSha256===void 0?{}:{imageSha256:oa(M.imageSha256,"expected.imageSha256")},...M.decodedPixelHash===void 0?{}:{decodedPixelHash:oa(M.decodedPixelHash,"expected.decodedPixelHash")}}}if(x={kind:"resource",resourceId:v.resourceId,pin:{resourceId:w.resourceId,revisionId:A,sha256:T},...N?{expected:N}:{}},!g){let M=_??(N?.width!==void 0&&N.height!==void 0?{width:N.width,height:N.height}:$e(`region ${b.name}: a packed resource region needs a crop or expected width and height (its size).`));g={x:0,y:0,width:M.width,height:M.height}}if(_&&(_.width!==g.width||_.height!==g.height))$e("source crop/content dimensions must match; resampling is unsupported.")}else $e("source kind must be procedural or pinned resource.");let E={name:b.name,content:g,gutter:p,edgeMode:y,source:x,..._?{crop:_}:{},...n&&(!m||b.packed===!0)?{packed:!0}:{}};if(!m)c.push({region:E,width:E.content.width+2*p,height:E.content.height+2*p});return E}).sort((f,h)=>f.name<h.name?-1:f.name>h.name?1:0);if(new Set(l.map((f)=>f.name)).size!==l.length)$e("duplicate region name.");if(c.length){let f=new Set(c.map((h)=>h.region));wN(a,s,l.filter((h)=>!f.has(h)).map((h)=>ao(h)),c)}for(let f of l){let h=ao(f);if(h.x<0||h.y<0||h.x+h.width>a||h.y+h.height>s)$e("padded allocation is out of bounds.")}for(let f=0;f<l.length;f++)for(let h=f+1;h<l.length;h++){let b=ao(l[f]),m=ao(l[h]);if(b.x<m.x+m.width&&m.x<b.x+b.width&&b.y<m.y+m.height&&m.y<b.y+b.height)$e(`padded allocations overlap: ${l[f].name}, ${l[h].name}.`)}if(new Set(l.map((f)=>hp(f.source))).size>r.sources)$e(`distinct source budget exceeds ${r.sources}.`);let u;try{u=Hu(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(f){$e(`sampler: ${f.message}`)}let d={schemaVersion:1,width:a,height:s,usage:o,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>gs.jsonBytes)$e("canonical JSON byte budget exceeded.");return d}function MN(e){let t=bs(e);return`sha256:${no(`${oE(t)}
+${JSON.stringify(t)}`)}`}function Rn(e){mp(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([r],[i])=>r<i?-1:r>i?1:0).map(([r,i])=>[r,t(i)])):n;return JSON.stringify(t(e))}function SN(e){return`sha256:${no(`kiln.atlas-layout.v1
+${Rn({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:ao(t)}))})}`)}`}function Bc(e,t){mp(e);let n=bs(t),r=Gn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(r.version!=="kiln.atlas-manifest.v1"||r.compilerId!==oE(n)||r.width!==n.width||r.height!==n.height||r.usage!==n.usage||r.origin!=="top-left")$e("manifest version/compiler/dimensions/usage/origin mismatch.");if(Rn(r.sampler)!==Rn(n.sampler)||r.specHash!==MN(n)||r.layoutHash!==SN(n))$e("manifest sampler/spec/layout identity mismatch.");oa(r.decodedPixelHash,"manifest decodedPixelHash"),oa(r.atlasPixelHash,"manifest atlasPixelHash");let i=new Map(n.regions.map((c)=>[hp(c.source),c.source]));if(!Array.isArray(r.sources)||r.sources.length!==i.size||!Array.isArray(r.regions)||r.regions.length!==n.regions.length)$e("manifest source/region inventory mismatch.");let a=new Map;for(let c of r.sources){let l=Gn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||a.has(l.id))$e("duplicate/invalid manifest source identity.");let u=i.get(l.id);if(!u||l.kind!==u.kind)$e("manifest source identity mismatch.");let d=cr(l.width,1,4096,"manifest source width"),f=cr(l.height,1,4096,"manifest source height");if(oa(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(Gn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||f!==u.spec.height||l.recipeHash!==up(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")$e("manifest procedural source identity mismatch.")}else{Gn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let h=Gn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),b={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(h.materialId!==u.pin.resourceId||h.revisionId!==u.pin.revisionId||h.resourceId!==u.resourceId||h.width!==d||h.height!==f||h.usage!==n.usage||typeof h.slot!=="string"||b[h.slot]!==n.usage||h.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))$e("manifest pinned resource descriptor mismatch.");if(oa(h.imageSha256,"manifest source imageSha256"),cr(h.encodedByteLength,1,AN(n).encodedSourceBytes,"manifest encodedByteLength"),h.decodedPixelHash!==void 0&&h.decodedPixelHash!==l.decodedPixelHash)$e("manifest source decodedPixelHash mismatch.");for(let m of["width","height","imageSha256","decodedPixelHash"]){let g=u.expected?.[m];if(g!==void 0&&g!==(m==="decodedPixelHash"?l[m]:h[m]))$e("manifest source expectation mismatch.")}}a.set(l.id,{width:d,height:f})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=Gn(r.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=hp(l.source),f=a.get(d),h=l.crop??{x:0,y:0,width:f.width,height:f.height};if(lE(h,l.content,f.width,f.height),u.name!==l.name||u.sourceId!==d||Rn(u.content)!==Rn(l.content)||Rn(u.allocation)!==Rn(ao(l))||Rn(u.crop)!==Rn(h))$e("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:s,...o}=r;if(s!==`sha256:${no(`kiln.atlas-manifest.v1
+${Rn(o)}`)}`)$e("manifest hash mismatch.");return structuredClone(e)}var aE="kiln.texture-atlas.v1.1",sE="kiln.texture-atlas.v1.2",Ku,gs,Di,pp,cE,TN=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,iE=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;var Wu=ot(()=>{$u();Gu();ro();Nc();Pc();Ku=Object.freeze([aE,sE]),gs=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Di=Object.freeze({...gs,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),pp=Object.freeze([1024,2048]);cE=class cE extends ms{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}});function VN(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function GN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function So(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function iT(){let e=So("canvas");return e.style.display="block",e}function nl(...e){let t="THREE."+e.shift();if(Ro)Ro("log",t,...e);else console.log(t,...e)}function aT(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 Ve(...e){e=aT(e);let t="THREE."+e.shift();if(Ro)Ro("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Qe(...e){e=aT(e);let t="THREE."+e.shift();if(Ro)Ro("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Ts(...e){let t=e.join(" ");if(t in SE)return;SE[t]=!0,Ve(...e)}function sT(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}class Gr{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 r=n[e];if(r!==void 0){let i=r.indexOf(t);if(i!==-1)r.splice(i,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 r=n.slice(0);for(let i=0,a=r.length;i<a;i++)r[i].call(this,e);e.target=null}}}function zr(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(On[e&255]+On[e>>8&255]+On[e>>16&255]+On[e>>24&255]+"-"+On[t&255]+On[t>>8&255]+"-"+On[t>>16&15|64]+On[t>>24&255]+"-"+On[n&63|128]+On[n>>8&255]+"-"+On[n>>16&255]+On[n>>24&255]+On[r&255]+On[r>>8&255]+On[r>>16&255]+On[r>>24&255]).toLowerCase()}function ut(e,t,n){return Math.max(t,Math.min(n,e))}function Km(e,t){return(e%t+t)%t}function HN(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function $N(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function tl(e,t,n){return(1-n)*e+n*t}function KN(e,t,n,r){return tl(e,t,1-Math.exp(-n*r))}function WN(e,t=1){return t-Math.abs(Km(e,t*2)-t)}function XN(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 qN(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 JN(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ZN(e,t){return e+Math.random()*(t-e)}function YN(e){return e*(0.5-Math.random())}function QN(e){if(e!==void 0)RE=e;let t=RE+=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 eP(e){return e*el}function tP(e){return e*ws}function nP(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function rP(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function iP(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function aP(e,t,n,r,i){let{cos:a,sin:s}=Math,o=a(n/2),c=s(n/2),l=a((t+r)/2),u=s((t+r)/2),d=a((t-r)/2),f=s((t-r)/2),h=a((r-t)/2),b=s((r-t)/2);switch(i){case"XYX":e.set(o*u,c*d,c*f,o*l);break;case"YZY":e.set(c*f,o*u,c*d,o*l);break;case"ZXZ":e.set(c*d,c*f,o*u,o*l);break;case"XZX":e.set(o*u,c*b,c*h,o*l);break;case"YXY":e.set(c*h,o*u,c*b,o*l);break;case"ZYZ":e.set(c*b,c*h,o*u,o*l);break;default:Ve("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ur(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 Nt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}function sP(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(i,a,s){if(this.enabled===!1||a===s||!a||!s)return i;if(this.spaces[a].transfer==="srgb")i.r=Gi(i.r),i.g=Gi(i.g),i.b=Gi(i.b);if(this.spaces[a].primaries!==this.spaces[s].primaries)i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ);if(this.spaces[s].transfer==="srgb")i.r=Mo(i.r),i.g=Mo(i.g),i.b=Mo(i.b);return i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){if(i==="")return"linear";return this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return Ts("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return Ts("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(i,a)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],r=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:r,transfer:"linear",toXYZ:CE,fromXYZ:NE,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:r,transfer:"srgb",toXYZ:CE,fromXYZ:NE,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}function Gi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function Mo(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}class Wm{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(fo===void 0)fo=So("canvas");fo.width=e.width,fo.height=e.height;let r=fo.getContext("2d");if(e instanceof ImageData)r.putImageData(e,0,0);else r.drawImage(e,0,0,e.width,e.height);n=fo}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=So("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let a=0;a<i.length;a++)i[a]=Gi(i[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Gi(t[n]/255)*255);else t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Ve("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class ul{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:oP++}),this.uuid=zr(),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:""},r=this.data;if(r!==null){let i;if(Array.isArray(r)){i=[];for(let a=0,s=r.length;a<s;a++)if(r[a].isDataTexture)i.push(Tp(r[a].image));else i.push(Tp(r[a]))}else i=Tp(r);n.url=i}if(!t)e.images[this.uuid]=n;return n}}function Tp(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Wm.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 Ve("Texture: Unable to serialize Texture."),{}}class Fd{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}class dl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new li,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new V,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new V;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new V,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new V,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 r=null,i=null,a=null,s=this._targetRay,o=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(let b of e.hand.values()){let m=t.getJointPose(b,n),g=this._getHandJoint(c,b);if(m!==null)g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius;g.visible=m!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),f=0.02,h=0.005;if(c.inputState.pinching&&d>f+h)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=f-h)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(o!==null&&e.gripSpace){if(i=t.getPose(e.gripSpace,n),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;if(o.eventsEnabled)o.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(s!==null){if(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null)r=i;if(r!==null){if(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity)s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity);else s.hasLinearVelocity=!1;if(r.angularVelocity)s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity);else s.hasAngularVelocity=!1;this.dispatchEvent(mP)}}}if(s!==null)s.visible=r!==null;if(o!==null)o.visible=i!==null;if(c!==null)c.visible=a!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}function Sp(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 Tr{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Dr.subVectors(e,t),r.cross(Dr);let i=r.lengthSq();if(i>0)return r.multiplyScalar(1/Math.sqrt(i));return r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Dr.subVectors(r,t),Ui.subVectors(n,t),Rp.subVectors(e,t);let a=Dr.dot(Dr),s=Dr.dot(Ui),o=Dr.dot(Rp),c=Ui.dot(Ui),l=Ui.dot(Rp),u=a*c-s*s;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*o-s*l)*d,h=(a*l-s*o)*d;return i.set(1-f-h,h,f)}static containsPoint(e,t,n,r){if(this.getBarycoord(e,t,n,r,zi)===null)return!1;return zi.x>=0&&zi.y>=0&&zi.x+zi.y<=1}static getInterpolation(e,t,n,r,i,a,s,o){if(this.getBarycoord(e,t,n,r,zi)===null){if(o.x=0,o.y=0,"z"in o)o.z=0;if("w"in o)o.w=0;return null}return o.setScalar(0),o.addScaledVector(i,zi.x),o.addScaledVector(a,zi.y),o.addScaledVector(s,zi.z),o}static getInterpolatedAttribute(e,t,n,r,i,a){return Pp.setScalar(0),Op.setScalar(0),kp.setScalar(0),Pp.fromBufferAttribute(e,t),Op.fromBufferAttribute(e,n),kp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Pp,i.x),a.addScaledVector(Op,i.y),a.addScaledVector(kp,i.z),a}static isFrontFacing(e,t,n,r){return Dr.subVectors(n,t),Ui.subVectors(e,t),Dr.cross(Ui).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 Dr.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Dr.cross(Ui).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Tr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Tr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,i){return Tr.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return Tr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Tr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,s;go.subVectors(r,n),bo.subVectors(i,n),Ip.subVectors(e,n);let o=go.dot(Ip),c=bo.dot(Ip);if(o<=0&&c<=0)return t.copy(n);Cp.subVectors(e,r);let l=go.dot(Cp),u=bo.dot(Cp);if(l>=0&&u<=l)return t.copy(r);let d=o*u-l*c;if(d<=0&&o>=0&&l<=0)return a=o/(o-l),t.copy(n).addScaledVector(go,a);Np.subVectors(e,i);let f=go.dot(Np),h=bo.dot(Np);if(h>=0&&f<=h)return t.copy(i);let b=f*c-o*h;if(b<=0&&c>=0&&h<=0)return s=c/(c-h),t.copy(n).addScaledVector(bo,s);let m=l*h-f*u;if(m<=0&&u-l>=0&&f-h>=0)return zE.subVectors(i,r),s=(u-l)/(u-l+(f-h)),t.copy(r).addScaledVector(zE,s);let g=1/(m+b+d);return a=b*g,s=d*g,t.copy(n).addScaledVector(go,a).addScaledVector(bo,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class pn{constructor(e=new V(1/0,1/0,1/0),t=new V(-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(Fr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Fr.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=Fr.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 i=n.getAttribute("position");if(t===!0&&i!==void 0&&e.isInstancedMesh!==!0)for(let a=0,s=i.count;a<s;a++){if(e.isMesh===!0)e.getVertexPosition(a,Fr);else Fr.fromBufferAttribute(i,a);Fr.applyMatrix4(e.matrixWorld),this.expandByPoint(Fr)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Yu.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Yu.copy(n.boundingBox)}Yu.applyMatrix4(e.matrixWorld),this.union(Yu)}}let r=e.children;for(let i=0,a=r.length;i<a;i++)this.expandByObject(r[i],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,Fr),Fr.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(Wc),Qu.subVectors(this.max,Wc),xo.subVectors(e.a,Wc),yo.subVectors(e.b,Wc),_o.subVectors(e.c,Wc),ua.subVectors(yo,xo),da.subVectors(_o,yo),_s.subVectors(xo,_o);let t=[0,-ua.z,ua.y,0,-da.z,da.y,0,-_s.z,_s.y,ua.z,0,-ua.x,da.z,0,-da.x,_s.z,0,-_s.x,-ua.y,ua.x,0,-da.y,da.x,0,-_s.y,_s.x,0];if(!Lp(t,xo,yo,_o,Qu))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Lp(t,xo,yo,_o,Qu))return!1;return ed.crossVectors(ua,da),t=[ed.x,ed.y,ed.z],Lp(t,xo,yo,_o,Qu)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Fr).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Fr).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}function Lp(e,t,n,r,i){for(let a=0,s=e.length-3;a<=s;a+=3){vs.fromArray(e,a);let o=i.x*Math.abs(vs.x)+i.y*Math.abs(vs.y)+i.z*Math.abs(vs.z),c=t.dot(vs),l=n.dot(vs),u=r.dot(vs);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}class pr{constructor(e=new V,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 bP.setFromPoints(e).getCenter(n);let r=0;for(let i=0,a=e.length;i<a;i++)r=Math.max(r,n.distanceToSquared(e[i]));return this.radius=Math.sqrt(r),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;Xc.subVectors(e,this.center);let t=Xc.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*0.5;this.center.addScaledVector(Xc,r/n),this.radius+=r}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 Dp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Xc.copy(e.center).add(Dp)),this.expandByPoint(Xc.copy(e.center).sub(Dp));return this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}class fl{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=zr()}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 r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];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=zr();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=zr();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}class zo{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)$n.fromBufferAttribute(this,t),$n.applyMatrix4(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.applyNormalMatrix(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.transformDirection(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Ur(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=Nt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=Nt(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=Ur(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Ur(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Ur(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Ur(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){if(e=e*this.data.stride+this.offset,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array),i=Nt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(e===void 0){nl("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)t.push(this.data.array[r+i])}return new En(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 zo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){nl("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let i=0;i<this.itemSize;i++)t.push(this.data.array[r+i])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}class Ar{constructor(e=new V(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Up.subVectors(n,t).cross(yP.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 r=e.delta(Up),i=this.normal.dot(r);if(i===0){if(this.distanceToPoint(e.start)===0)return t.copy(e.start);return null}let a=-(e.start.dot(this.normal)+this.constant)/i;if(n===!0&&(a<0||a>1))return null;return t.copy(e.start).addScaledVector(r,a)}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||_P.getNormalMatrix(e),r=this.coplanarPoint(Up).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}}class _a{constructor(e=new V,t=new V(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,ji)),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=ji.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ji.copy(this.origin).addScaledVector(this.direction,t),ji.distanceToSquared(e)}distanceSqToSegment(e,t,n,r){zp.copy(e).add(t).multiplyScalar(0.5),nd.copy(t).sub(e).normalize(),rd.copy(this.origin).sub(zp);let i=e.distanceTo(t)*0.5,a=-this.direction.dot(nd),s=rd.dot(this.direction),o=-rd.dot(nd),c=rd.lengthSq(),l=Math.abs(1-a*a),u,d,f,h;if(l>0)if(u=a*o-s,d=a*s-o,h=i*l,u>=0)if(d>=-h)if(d<=h){let b=1/l;u*=b,d*=b,f=u*(u+a*d+2*s)+d*(a*u+d+2*o)+c}else d=i,u=Math.max(0,-(a*d+s)),f=-u*u+d*(d+2*o)+c;else d=-i,u=Math.max(0,-(a*d+s)),f=-u*u+d*(d+2*o)+c;else if(d<=-h)u=Math.max(0,-(-a*i+s)),d=u>0?-i:Math.min(Math.max(-i,-o),i),f=-u*u+d*(d+2*o)+c;else if(d<=h)u=0,d=Math.min(Math.max(-i,-o),i),f=d*(d+2*o)+c;else u=Math.max(0,-(a*i+s)),d=u>0?i:Math.min(Math.max(-i,-o),i),f=-u*u+d*(d+2*o)+c;else d=a>0?-i:i,u=Math.max(0,-(a*d+s)),f=-u*u+d*(d+2*o)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(r)r.copy(zp).addScaledVector(nd,d);return f}intersectSphere(e,t){if(e.radius<0)return null;ji.subVectors(e.center,this.origin);let n=ji.dot(this.direction),r=ji.dot(ji)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),s=n-a,o=n+a;if(o<0)return null;if(s<0)return this.at(o,t);return this.at(s,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,r,i,a,s,o,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c;if(l>=0)i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l;else i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l;if(n>a||i>r)return null;if(i>n||isNaN(n))n=i;if(a<r||isNaN(r))r=a;if(u>=0)s=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u;else s=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u;if(n>o||s>r)return null;if(s>n||n!==n)n=s;if(o<r||r!==r)r=o;if(r<0)return null;return this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ji)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,s=this.direction,{x:o,y:c,z:l}=s,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,h=t.x-a.x,b=t.y-a.y,m=t.z-a.z,g=n.x-a.x,p=n.y-a.y,y=n.z-a.z,v=Math.abs(o),x=Math.abs(c),_=Math.abs(l),E,w,A,T,N,M,R,k,C,U,D,P;if(v>=x&&v>=_)if(A=o,M=u,C=h,P=g,o>=0)E=c,w=l,T=d,N=f,R=b,k=m,U=p,D=y;else E=l,w=c,T=f,N=d,R=m,k=b,U=y,D=p;else if(x>=_)if(A=c,M=d,C=b,P=p,c>=0)E=l,w=o,T=f,N=u,R=m,k=h,U=y,D=g;else E=o,w=l,T=u,N=f,R=h,k=m,U=g,D=y;else if(A=l,M=f,C=m,P=y,l>=0)E=o,w=c,T=u,N=d,R=h,k=b,U=g,D=p;else E=c,w=o,T=d,N=u,R=b,k=h,U=p,D=g;if(A===0)return null;let K=E/A,z=w/A,W=1/A,q=T-K*M,le=N-z*M,he=R-K*C,xe=k-z*C,pe=U-K*P,J=D-z*P,F=pe*xe-J*he,X=q*J-le*pe,ne=he*le-xe*q;if(r){if(F<0||X<0||ne<0)return null}else if((F<0||X<0||ne<0)&&(F>0||X>0||ne>0))return null;let re=F+X+ne;if(re===0)return null;let ce=W*(F*M+X*C+ne*P);if(re>0?ce<0:ce>0)return null;return this.at(ce/re,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}function EP(e,t,n,r,i,a,s,o){let c;if(t.side===1)c=r.intersectTriangle(s,a,i,!0,o);else c=r.intersectTriangle(i,a,s,t.side===0,o);if(c===null)return null;ld.copy(o),ld.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(ld);if(l<n.near||l>n.far)return null;return{distance:l,point:ld.clone(),object:e}}function ud(e,t,n,r,i,a,s,o,c,l){e.getVertexPosition(o,ad),e.getVertexPosition(c,sd),e.getVertexPosition(l,od);let u=EP(e,t,n,r,ad,sd,od,VE);if(u){let d=new V;if(Tr.getBarycoord(VE,ad,sd,od,d),i)u.uv=Tr.getInterpolatedAttribute(i,o,c,l,d,new We);if(a)u.uv1=Tr.getInterpolatedAttribute(a,o,c,l,d,new We);if(s){if(u.normal=Tr.getInterpolatedAttribute(s,o,c,l,d,new V),u.normal.dot(r.direction)>0)u.normal.multiplyScalar(-1)}let f={a:o,b:c,c:l,normal:new V,materialIndex:0};Tr.getNormal(ad,sd,od,f.normal),u.face=f,u.barycoord=d}return u}class ml{constructor(e=[],t=[]){this.uuid=zr(),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){Ve("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Ze;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,r=this.boneTexture;for(let i=0,a=e.length;i<a;i++){let s=e[i]?e[i].matrixWorld:TP;WE.multiplyMatrices(s,t[i]),WE.toArray(n,i*16)}if(r!==null)r.needsUpdate=!0}clone(){return new ml(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 pl(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 r=this.bones[t];if(r.name===e)return r}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let i=e.bones[n],a=t[i];if(a===void 0)Ve("Skeleton: No bone found with UUID:",i),a=new hl;this.bones.push(a),this.boneInverses.push(new Ze().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 r=0,i=t.length;r<i;r++){let a=t[r];e.bones.push(a.uuid);let s=n[r];e.boneInverses.push(s.toArray())}return e}}class gl{constructor(e=new Ar,t=new Ar,n=new Ar,r=new Ar,i=new Ar,a=new Ar){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(r),s[4].copy(i),s[5].copy(a),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 r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],h=i[8],b=i[9],m=i[10],g=i[11],p=i[12],y=i[13],v=i[14],x=i[15];if(r[0].setComponents(c-a,f-l,g-h,x-p).normalize(),r[1].setComponents(c+a,f+l,g+h,x+p).normalize(),r[2].setComponents(c+s,f+u,g+b,x+y).normalize(),r[3].setComponents(c-s,f-u,g-b,x-y).normalize(),n)r[4].setComponents(o,d,m,v).normalize(),r[5].setComponents(c-o,f-d,g-m,x-v).normalize();else if(r[4].setComponents(c-o,f-d,g-m,x-v).normalize(),t===2000)r[5].setComponents(c+o,f+d,g+m,x+v).normalize();else if(t===2001)r[5].setComponents(o,d,m,v).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();As.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();As.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(As)}intersectsSprite(e){As.center.set(0,0,0);let t=MP.distanceTo(e.center);return As.radius=0.7071067811865476+t,As.applyMatrix4(e.matrixWorld),this.intersectsSphere(As)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let i=0;i<6;i++)if(t[i].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(hd.x=r.normal.x>0?e.max.x:e.min.x,hd.y=r.normal.y>0?e.max.y:e.min.y,hd.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(hd)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function md(e,t,n,r,i,a,s){let o=e.geometry.attributes.position;if(vd.fromBufferAttribute(o,i),Ed.fromBufferAttribute(o,a),n.distanceSqToSegment(vd,Ed,Gp,ZE)>r)return;Gp.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(Gp);if(l<t.near||l>t.far)return;return{distance:l,point:ZE.clone().applyMatrix4(e.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:e}}function tA(e,t,n,r,i,a,s){let o=Kp.distanceSqToPoint(e);if(o<n){let c=new V;Kp.closestPointToPoint(e,c),c.applyMatrix4(r);let l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}function Os(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(nA(i))if(i.isRenderTargetTexture)Ve("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][r]=null;else t[n][r]=i.clone();else if(Array.isArray(i))if(nA(i[0])){let a=[];for(let s=0,o=i.length;s<o;s++)a[s]=i[s].clone();t[n][r]=a}else t[n][r]=i.slice();else t[n][r]=i}}return t}function Fn(e){let t={};for(let n=0;n<e.length;n++){let r=Os(e[n]);for(let i in r)t[i]=r[i]}return t}function nA(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function SP(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Zm(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return lt.workingColorSpace}function ha(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 _d(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function CP(e){function t(i,a){return e[i]-e[a]}let n=e.length,r=Array(n);for(let i=0;i!==n;++i)r[i]=i;return r.sort(t),r}function rA(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,s=0;s!==r;++a){let o=n[a]*t;for(let c=0;c!==t;++c)i[s++]=e[o+c]}return i}function NP(e,t,n,r){let i=1,a=e[0];while(a!==void 0&&a[r]===void 0)a=e[i++];if(a===void 0)return;let s=a[r];if(s===void 0)return;if(Array.isArray(s))do{if(s=a[r],s!==void 0)t.push(a.time),n.push(...s);a=e[i++]}while(a!==void 0);else if(s.toArray!==void 0)do{if(s=a[r],s!==void 0)t.push(a.time),s.toArray(n,n.length);a=e[i++]}while(a!==void 0);else do{if(s=a[r],s!==void 0)t.push(a.time),n.push(s);a=e[i++]}while(a!==void 0)}class Ki{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];e:{t:{let a;n:{r:if(!(e<r)){for(let s=n+2;;){if(r===void 0){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===s)break;if(i=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=i)){let s=t[1];if(e<s)n=2,i=s;for(let o=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(r=i,i=t[--n-1],e>=i)break t}a=n,n=0;break n}break e}while(n<a){let s=n+a>>>1;if(e<t[s])a=s;else n=s+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let a=0;a!==r;++a)t[a]=n[i+a];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}function uT(e,t,n,r,i){let a=1-e;return a*a*a*t+3*a*a*e*n+3*a*e*e*r+e*e*e*i}function PP(e,t,n,r,i){let a=1-e;return 3*a*a*(n-t)+6*a*e*(r-n)+3*e*e*(i-r)}function OP(e,t,n,r,i){let a=(e-t)/(i-t);for(let s=0;s<8;s++){let o=uT(a,t,n,r,i)-e;if(Math.abs(o)<0.0000000001)break;let c=PP(a,t,n,r,i);if(Math.abs(c)<0.0000000001)break;a=Math.max(0,Math.min(1,a-o/c))}return a}class gr{constructor(e,t,n,r){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=ha(t,this.TimeBufferType),this.values=ha(n,this.ValueBufferType),this.setInterpolation(r||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:ha(e.times,Array),values:ha(e.values,Array)};let r=e.getInterpolation();if(r!==e.DefaultInterpolation)n.interpolation=r;if(_d(e.settings))n.settings={inTangents:ha(e.settings.inTangents,Array),outTangents:ha(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ng(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Kd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new tg(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new rg(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 Ve("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,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e;if(_d(this.settings))iA(this.settings.inTangents,e),iA(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;while(i!==r&&n[i]<e)++i;while(a!==-1&&n[a]>t)--a;if(++a,i!==0||a!==r){if(i>=a)a=Math.max(a,1),i=a-1;let s=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*s,a*s)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)Qe("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,r=this.values,i=n.length;if(i===0)Qe("KeyframeTrack: Track is empty.",this),e=!1;let a=null;for(let s=0;s!==i;s++){let o=n[s];if(typeof o==="number"&&isNaN(o)){Qe("KeyframeTrack: Time is not a valid number.",this,s,o),e=!1;break}if(a!==null&&a>o){Qe("KeyframeTrack: Out of order keys.",this,s,o,a),e=!1;break}a=o}if(r!==void 0){if(GN(r))for(let s=0,o=r.length;s!==o;++s){let c=r[s];if(isNaN(c)){Qe("KeyframeTrack: Value is not a valid number.",this,s,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===2302,i=e.length-1,a=1;for(let s=1;s<i;++s){let o=!1,c=e[s],l=e[s+1];if(c!==l&&(s!==1||c!==e[0]))if(!r){let u=s*n,d=u-n,f=u+n;for(let h=0;h!==n;++h){let b=t[u+h];if(b!==t[d+h]||b!==t[f+h]){o=!0;break}}}else o=!0;if(o){if(s!==a){e[a]=e[s];let u=s*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(i>0){e[a]=e[i];for(let s=i*n,o=a*n,c=0;c!==n;++c)t[o+c]=t[s+c];++a}if(a!==e.length)this.times=e.slice(0,a),this.values=t.slice(0,a*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),r=new this.constructor(this.name,e,t);if(r.createInterpolant=this.createInterpolant,_d(this.settings))r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return r}}function iA(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}class Io{constructor(e="",t=-1,n=[],r=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=zr(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,s=n.length;a!==s;++a)t.push(LP(n[a]).scale(r));let i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i.userData=JSON.parse(e.userData||"{}"),i}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let i=0,a=n.length;i!==a;++i)t.push(gr.toJSON(n[i]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let i=t.length,a=[];for(let s=0;s<i;s++){let o=[],c=[];o.push((s+i-1)%i,s,(s+1)%i),c.push(0,1,0);let l=CP(o);if(o=rA(o,1,l),c=rA(c,1,l),!r&&o[0]===0)o.push(i),c.push(c[0]);a.push(new Ta(".morphTargetInfluences["+t[s].name+"]",o,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},i=/^([\w-]*?)([\d]+)$/;for(let s=0,o=e.length;s<o;s++){let c=e[s],l=c.name.match(i);if(l&&l.length>1){let u=l[1],d=r[u];if(!d)r[u]=d=[];d.push(c)}}let a=[];for(let s in r)a.push(this.CreateFromMorphTargetSequence(s,r[s],t,n));return a}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let i=this.tracks[n];t=Math.max(t,i.times[i.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 kP(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ta;case"vector":case"vector2":case"vector3":case"vector4":return ks;case"color":return Wd;case"quaternion":return wa;case"bool":case"boolean":return Aa;case"string":return Ma}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function LP(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=kP(e.type);if(e.times===void 0){let r=[],i=[];NP(e.keys,r,i,"value"),e.times=r,e.values=i}let n;if(t.parse!==void 0)n=t.parse(e);else n=new t(e.name,e.times,e.values,e.interpolation);if(_d(e.settings))n.settings={inTangents:ha(e.settings.inTangents,Float32Array),outTangents:ha(e.settings.outTangents,Float32Array)};return n}function aA(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class _l{constructor(e,t,n){let r=this,i=!1,a=0,s=0,o=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(s++,i===!1){if(r.onStart!==void 0)r.onStart(l,a,s)}i=!0},this.itemEnd=function(l){if(a++,r.onProgress!==void 0)r.onProgress(l,a,s);if(a===s){if(i=!1,r.onLoad!==void 0)r.onLoad()}},this.itemError=function(l){if(r.onError!==void 0)r.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),o)return o(l);return l},this.setURLModifier=function(l){return o=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],h=c[u+1];if(f.global)f.lastIndex=0;if(f.test(l))return h}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}class Wi{constructor(e){if(this.manager=e!==void 0?e:dT,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(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}class El{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 We(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gl,this._frameExtents=new We(1,1),this._viewportCount=1,this._viewports=[new Pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;sA.setFromMatrixPosition(e.matrixWorld),t.position.copy(sA),oA.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(oA),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,r){Hp.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Hp,e.coordinateSystem,e.reversedDepth);let i=this._frameExtents,a=r?r.z/i.x:1,s=r?r.w/i.y:1,o=r?r.x/i.x:0,c=r?r.y/i.y:0;if(e.coordinateSystem===2001||e.reversedDepth)t.set(0.5*a,0,0,0.5*a+o,0,0.5*s,0,0.5*s+c,0,0,1,0,0,0,0,1);else t.set(0.5*a,0,0,0.5*a+o,0,0.5*s,0,0.5*s+c,0,0,0.5,0.5,0,0,0,1);t.multiply(Hp)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){if(this.map)this.map.dispose();if(this.mapPass)this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Sa{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}class cg{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,i,a;switch(t){case"quaternion":r=this._slerp,i=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,a=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:r=this._lerp,i=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=a,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,r=this.valueSize,i=e*r+r,a=this.cumulativeWeight;if(a===0){for(let s=0;s!==r;++s)n[i+s]=n[s];a=t}else{a+=t;let s=t/a;this._mixBufferRegion(n,i,0,s,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,a=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){let o=t*this._origIndex;this._mixBufferRegion(n,r,o,1-i,t)}if(a>0)this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let o=t,c=t+t;o!==c;++o)if(n[o]!==n[o+t]){s.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let i=n,a=r;i!==a;++i)t[i]=t[r+i%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,r,i){if(r>=0.5)for(let a=0;a!==i;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){ln.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){let a=this._workIndex*i;ln.multiplyQuaternionsFlat(e,a,e,t,e,n),ln.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,i){let a=1-r;for(let s=0;s!==i;++s){let o=t+s;e[o]=e[o]*a+e[n+s]*r}}_lerpAdditive(e,t,n,r,i){for(let a=0;a!==i;++a){let s=t+a;e[s]=e[s]+e[n+a]*r}}}class gT{constructor(e,t,n){let r=n||At.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];if(r!==void 0)r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].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 At{constructor(e,t,n){this.path=t,this.parsedPath=n||At.parseTrackName(t),this.node=At.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 At(e,t,n);else return new At.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(DP,"")}static parseTrackName(e){let t=VP.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]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let i=n.nodeName.substring(r+1);if(GP.indexOf(i)!==-1)n.nodeName=n.nodeName.substring(0,r),n.objectName=i}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(i){for(let a=0;a<i.length;a++){let s=i[a];if(s.name===t||s.uuid===t)return s;let o=n(s.children);if(o)return o}return null},r=n(e.children);if(r)return r}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 r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_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 r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=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:r,propertyIndex:i}=t;if(!e)e=At.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ve("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Qe("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){Qe("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){Qe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Qe("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){Qe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Qe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let a=e[r];if(a===void 0){let c=t.nodeName;Qe("PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let s=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)s=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)s=this.Versioning.MatrixWorldNeedsUpdate;let o=this.BindingType.Direct;if(i!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Qe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Qe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[i]!==void 0)i=e.morphTargetDictionary[i]}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=i}else if(a.fromArray!==void 0&&a.toArray!==void 0)o=this.BindingType.HasFromToArray,this.resolvedProperty=a;else if(Array.isArray(a))o=this.BindingType.EntireArray,this.resolvedProperty=a;else this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}class dg{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let i=t.tracks,a=i.length,s=Array(a),o={endingStart:2400,endingEnd:2400};for(let c=0;c!==a;++c){let l=i[c].createInterpolant(null);s[c]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=Array(a),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 r=this._clip.duration,i=e._clip.duration,a=i/r,s=r/i;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,a,t),this.warp(s,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 r=this._mixer,i=r.time,a=this.timeScale,s=this._timeScaleInterpolant;if(s===null)s=r._lendControlInterpolant(),this._timeScaleInterpolant=s;let o=s.parameterPositions,c=s.sampleValues;return o[0]=i,o[1]=i+n,c[0]=e/a,c[1]=t/a,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,r){if(!this.enabled){this._updateWeight(e);return}let i=this._startTime;if(i!==null){let o=(e-i)*n;if(o<0||n===0)t=0;else this._startTime=null,t=n*o}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let o=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case 2501:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(a),c[l].accumulateAdditive(s);break;case 2500:default:for(let l=0,u=o.length;l!==u;++l)o[l].evaluate(a),c[l].accumulate(r,s)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];if(t*=r,e>n.parameterPositions[1]){if(this.stopFading(),r===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 r=n.evaluate(e)[0];if(t*=r,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,r=this.time+e,i=this._loopCount,a=n===2202;if(e===0){if(i===-1)return r;return a&&(i&1)===1?t-r:r}if(n===2200){if(i===-1)this._loopCount=0,this._setEndings(!0,!0,!1);e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(i===-1)if(e>=0)i=0,this._setEndings(!0,this.repetitions===0,a);else this._setEndings(this.repetitions===0,!0,a);if(r>=t||r<0){let s=Math.floor(r/t);r-=t*s,i+=Math.abs(s);let o=this.repetitions-i;if(o<=0){if(this.clampWhenFinished)this.paused=!0;else this.enabled=!1;r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1})}else{if(o===1){let c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}}else this._loopCount=i,this.time=r;if(a&&(i&1)===1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;if(n)r.endingStart=2401,r.endingEnd=2401;else{if(e)r.endingStart=this.zeroSlopeAtStart?2401:2400;else r.endingStart=2402;if(t)r.endingEnd=this.zeroSlopeAtEnd?2401:2400;else r.endingEnd=2402}}_scheduleFading(e,t,n){let r=this._mixer,i=r.time,a=this._weightInterpolant;if(a===null)a=r._lendControlInterpolant(),this._weightInterpolant=a;let s=a.parameterPositions,o=a.sampleValues;return s[0]=i,o[0]=t,s[1]=i+e,o[1]=n,this}}class Al{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=ut(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(ut(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}function hg(e,t,n,r){let i=$P(r);switch(n){case 1021:return e*t;case 1028:return e*t/i.components*i.byteLength;case 1029:return e*t/i.components*i.byteLength;case 1030:return e*t*2/i.components*i.byteLength;case 1031:return e*t*2/i.components*i.byteLength;case 1022:return e*t*3/i.components*i.byteLength;case 1023:return e*t*4/i.components*i.byteLength;case 1033:return e*t*4/i.components*i.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 $P(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var uA="186",ma,ga,dA=0,Wp=1,fA=2,rl=1,hA=2,Co=3,ba=0,Ln=1,wr=2,fi=0,il=1,Xp=2,qp=3,Jp=4,pA=5,No=100,mA=101,gA=102,bA=103,xA=104,yA=200,_A=201,vA=202,EA=203,AA=204,TA=205,wA=206,MA=207,SA=208,RA=209,IA=210,CA=211,NA=212,PA=213,OA=214,kA=0,LA=1,DA=2,Zp=3,FA=4,UA=5,zA=6,BA=7,jA=0,VA=1,GA=2,Br=0,Yp=1,Qp=2,em=3,al=4,tm=5,nm=6,rm=7,Po=301,Ms=302,Ad=303,Td=304,sl=306,Oo=1000,ko=1001,wd=1002,jr=1003,Md=1004,Ss=1005,An=1006,Lo=1007,hi=1008,Vr=1009,HA=1010,$A=1011,ol=1012,im=1013,xa=1014,Hi=1015,pi=1016,am=1017,sm=1018,Do=1020,KA=35902,WA=35899,XA=1021,qA=1022,mi=1023,Rs=1026,Is=1027,JA=1028,om=1029,Cs=1030,cm=1031,lm=1033,Sd=33776,Rd=33777,Id=33778,Cd=33779,um=35840,dm=35841,fm=35842,hm=35843,pm=36196,mm=37492,gm=37496,bm=37488,xm=37489,Nd=37490,ym=37491,_m=37808,vm=37809,Em=37810,Am=37811,Tm=37812,wm=37813,Mm=37814,Sm=37815,Rm=37816,Im=37817,Cm=37818,Nm=37819,Pm=37820,Om=37821,km=36492,Lm=36494,Dm=36495,Fm=36283,Um=36284,Pd=36285,zm=36286,Bm=2300,Od=2301,jm=0,cl=1,Fo=2,Vm=0,ZA=1,Ns="",ya="srgb",fr="srgb-linear",Gm="linear",Bt="srgb",YA=512,QA=513,eT=514,kd=515,tT=516,nT=517,Ld=518,rT=519,Hm="300 es",$m=2000,SE,Ro=null,oT,On,RE=1234567,el,ws,ll,We,ln,V,Ep,IE,nt,Ap,CE,NE,lt,fo,oP=0,cP=0,wp,en,Pt,Xm,hr,Dd,qm,Ze,ho,Lr,lP,uP,ca,qu,ur,PE,OE,di,dP=0,kE,po,Fi,Ju,Kc,fP,hP,LE,DE,FE,UE,pP,mo,Mp,Lt,li,mP,cT,la,Zu,Je,kn,Uo,Dr,Ui,Rp,zi,go,bo,zE,Ip,Cp,Np,Pp,Op,kp,Bi,Fr,Yu,xo,yo,_o,ua,da,_s,Wc,Qu,ed,vs,cn,td,gP=0,En,Ud,zd,Jn,bP,Xc,Dp,xP=0,Er,Fp,vo,dr,qc,vn,Dn,$n,Up,yP,_P,vP=0,Zn,ji,zp,nd,rd,gi,BE,Es,id,jE,ad,sd,od,Bp,cd,VE,ld,Gt,Jc,GE,HE,AP,$E,dd,jp,KE,Vp,Bd,hl,pl,WE,TP,pa,Eo,XE,fd,qE,wP,Zc,Yc,Bo,As,MP,hd,bl,vd,Ed,JE,Qc,pd,Gp,ZE,va,YE,QE,jd,Vd,xl,eA,Kp,gd,bd,jo,Gd,Ps,Jm,Hd,Ea,yl,lT,RP=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,oP=`void main() {
+}`,IP=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`,Ei,zm,zr,di,Dd,Vm,jm,Hm,Ld,Gm,$m,xs,Fd,ys,Km,_s,vs,Ia,lr,YT,Fr,QT,fl,bo,Wm,Lo,Fo,Ud,Pp,WE,XE,cd,ld,or,Bd,os,qE,JE,hn,eA,zd,tA,Uo,Ca,nA,Bo,Op,Vd,xo=-90,yo=1,Xm,qm,Zm="\\[\\]\\.:\\/",pP,Ym,mP,gP,bP,xP,yP,_P,vP,EP,jd,eg,Hd;var ng=ut(()=>{us={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ds={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};pE={};XT={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};On=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],$c=Math.PI/180,_a=180/Math.PI;el={DEG2RAD:$c,RAD2DEG:_a,generateUUID:Fi,clamp:ct,euclideanModulo:km,mapLinear:EN,inverseLerp:TN,lerp:Kc,damp:AN,pingpong:wN,smoothstep:SN,smootherstep:MN,randInt:RN,randFloat:IN,randFloatSpread:CN,seededRandom:NN,degToRad:PN,radToDeg:ON,isPowerOfTwo:kN,ceilPowerOfTwo:DN,floorPowerOfTwo:LN,setQuaternionFromProperEuler:FN,normalize:Nt,denormalize:Li};Ke=class Ke{static{Ke.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ln=class ln{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,a){let o=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],f=r[s+1],h=r[s+2],b=r[s+3];if(u!==b||o!==d||c!==f||l!==h){let m=o*d+c*f+l*h+u*b;if(m<0)d=-d,f=-f,h=-h,b=-b,m=-m;let g=1-a;if(m<0.9995){let p=Math.acos(m),x=Math.sin(p);g=Math.sin(g*p)/x,a=Math.sin(a*p)/x,o=o*g+d*a,c=c*g+f*a,l=l*g+h*a,u=u*g+b*a}else{o=o*g+d*a,c=c*g+f*a,l=l*g+h*a,u=u*g+b*a;let p=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=p,c*=p,l*=p,u*=p}}e[t]=o,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let a=n[i],o=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],f=r[s+2],h=r[s+3];return e[t]=a*h+l*u+o*f-c*d,e[t+1]=o*h+l*d+c*u-a*f,e[t+2]=c*h+l*f+a*d-o*u,e[t+3]=l*h-a*u-o*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:a,sin:o}=Math,c=a(n/2),l=a(i/2),u=a(r/2),d=o(n/2),f=o(i/2),h=o(r/2);switch(s){case"XYZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"YXZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"ZXY":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"ZYX":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"YZX":this._x=d*l*u+c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u-d*f*h;break;case"XZY":this._x=d*l*u-c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u+d*f*h;break;default:je("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],c=t[2],l=t[6],u=t[10],d=n+a+u;if(d>0){let f=0.5/Math.sqrt(d+1);this._w=0.25/f,this._x=(l-o)*f,this._y=(r-c)*f,this._z=(s-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(l-o)/f,this._x=0.25*f,this._y=(i+s)/f,this._z=(r+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-c)/f,this._x=(i+s)/f,this._y=0.25*f,this._z=(o+l)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(s-i)/f,this._x=(r+c)/f,this._y=(o+l)/f,this._z=0.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ct(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:a,_y:o,_z:c,_w:l}=t;return this._x=n*l+s*a+i*c-r*o,this._y=i*l+s*o+r*a-n*c,this._z=r*l+s*c+n*o-i*a,this._w=s*l-n*a-i*o-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,a=this.dot(e);if(a<0)n=-n,i=-i,r=-r,s=-s,a=-a;let o=1-t;if(a<0.9995){let c=Math.acos(a),l=Math.sin(c);o=Math.sin(o*c)/l,t=Math.sin(t*c)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}};j=class j{static{j.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(gE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(gE.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:a,w:o}=e,c=2*(s*i-a*n),l=2*(a*t-r*i),u=2*(r*n-s*t);return this.x=t+o*c+s*u-a*l,this.y=n+o*l+a*c-r*u,this.z=i+o*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:a,z:o}=t;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return up.copy(this).projectOnVector(e),this.sub(up)}reflect(e){return this.sub(up.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ct(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};up=new j,gE=new ln;tt=class tt{static{tt.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,a,o,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c)}set(e,t,n,i,r,s,a,o,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=a,l[3]=t,l[4]=r,l[5]=o,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],h=n[8],b=i[0],m=i[3],g=i[6],p=i[1],x=i[4],_=i[7],y=i[2],v=i[5],E=i[8];return r[0]=s*b+a*p+o*y,r[3]=s*m+a*x+o*v,r[6]=s*g+a*_+o*E,r[1]=c*b+l*p+u*y,r[4]=c*m+l*x+u*v,r[7]=c*g+l*_+u*E,r[2]=d*b+f*p+h*y,r[5]=d*m+f*x+h*v,r[8]=d*g+f*_+h*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8];return t*s*l-t*a*c-n*r*l+n*a*o+i*r*c-i*s*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=l*s-a*c,d=a*o-l*r,f=c*r-s*o,h=t*u+n*d+i*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let b=1/h;return e[0]=u*b,e[1]=(i*c-l*n)*b,e[2]=(a*n-i*s)*b,e[3]=d*b,e[4]=(l*t-i*o)*b,e[5]=(i*r-a*t)*b,e[6]=f*b,e[7]=(n*o-c*t)*b,e[8]=(s*t-n*r)*b,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){let o=Math.cos(r),c=Math.sin(r);return this.set(n*o,n*c,-n*(o*s+c*a)+s+e,-i*c,i*o,-i*(-c*s+o*a)+a+t,0,0,1),this}scale(e,t){return ya("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(dp.makeScale(e,t)),this}rotate(e){return ya("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(dp.makeRotation(-e)),this}translate(e,t){return ya("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(dp.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)}};dp=new tt,bE=new tt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),xE=new tt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);ot=UN();hp=new j;en=class en extends Vi{constructor(e=en.DEFAULT_IMAGE,t=en.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,a=1023,o=1009,c=en.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:zN++}),this.uuid=Fi(),this.name="",this.source=new tl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Ke(0,0),this.repeat=new Ke(1,1),this.center=new Ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new tt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hp).x}get height(){return this.source.getSize(hp).y}get depth(){return this.source.getSize(hp).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){je(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}};en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=300;en.DEFAULT_ANISOTROPY=1;Pt=class Pt{static{Pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,a=0.1,o=e.elements,c=o[0],l=o[4],u=o[8],d=o[1],f=o[5],h=o[9],b=o[2],m=o[6],g=o[10];if(Math.abs(l-d)<0.01&&Math.abs(u-b)<0.01&&Math.abs(h-m)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+b)<0.1&&Math.abs(h+m)<0.1&&Math.abs(c+f+g-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let x=(c+1)/2,_=(f+1)/2,y=(g+1)/2,v=(l+d)/4,E=(u+b)/4,w=(h+m)/4;if(x>_&&x>y)if(x<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(x),i=v/n,r=E/n;else if(_>y)if(_<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(_),n=v/i,r=w/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=E/r,i=w/r;return this.set(n,i,r,t),this}let p=Math.sqrt((m-h)*(m-h)+(u-b)*(u-b)+(d-l)*(d-l));if(Math.abs(p)<0.001)p=1;return this.x=(m-h)/p,this.y=(u-b)/p,this.z=(d-l)/p,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ct(this.x,e.x,t.x),this.y=ct(this.y,e.y,t.y),this.z=ct(this.z,e.z,t.z),this.w=ct(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ct(this.x,e,t),this.y=ct(this.y,e,t),this.z=ct(this.z,e,t),this.w=ct(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ct(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Lm=class Lm extends Vi{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Pt(0,0,e,t),this.scissorTest=!1,this.viewport=new Pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new en(i),s=n.count;for(let a=0;a<s;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new tl(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"})}};li=class li extends Lm{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}};Sd=class Sd extends en{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()}};Fm=class Fm extends en{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}};Je=class Je{static{Je.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m)}set(e,t,n,i,r,s,a,o,c,l,u,d,f,h,b,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=h,g[11]=b,g[15]=m,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 Je().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/ao.setFromMatrixColumn(e,0).length(),r=1/ao.setFromMatrixColumn(e,1).length(),s=1/ao.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,f=s*u,h=a*l,b=a*u;t[0]=o*l,t[4]=-o*u,t[8]=c,t[1]=f+h*c,t[5]=d-b*c,t[9]=-a*o,t[2]=b-d*c,t[6]=h+f*c,t[10]=s*o}else if(e.order==="YXZ"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d+b*a,t[4]=h*a-f,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-a,t[2]=f*a-h,t[6]=b+d*a,t[10]=s*o}else if(e.order==="ZXY"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d-b*a,t[4]=-s*u,t[8]=h+f*a,t[1]=f+h*a,t[5]=s*l,t[9]=b-d*a,t[2]=-s*c,t[6]=a,t[10]=s*o}else if(e.order==="ZYX"){let d=s*l,f=s*u,h=a*l,b=a*u;t[0]=o*l,t[4]=h*c-f,t[8]=d*c+b,t[1]=o*u,t[5]=b*c+d,t[9]=f*c-h,t[2]=-c,t[6]=a*o,t[10]=s*o}else if(e.order==="YZX"){let d=s*o,f=s*c,h=a*o,b=a*c;t[0]=o*l,t[4]=b-d*u,t[8]=h*u+f,t[1]=u,t[5]=s*l,t[9]=-a*l,t[2]=-c*l,t[6]=f*u+h,t[10]=d-b*u}else if(e.order==="XZY"){let d=s*o,f=s*c,h=a*o,b=a*c;t[0]=o*l,t[4]=-u,t[8]=c*l,t[1]=d*u+b,t[5]=s*l,t[9]=f*u-h,t[2]=h*u-f,t[6]=a*l,t[10]=b*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(VN,e,jN)}lookAt(e,t,n){let i=this.elements;if(ai.subVectors(e,t),ai.lengthSq()===0)ai.z=1;if(ai.normalize(),is.crossVectors(n,ai),is.lengthSq()===0){if(Math.abs(n.z)===1)ai.x+=0.0001;else ai.z+=0.0001;ai.normalize(),is.crossVectors(n,ai)}return is.normalize(),Bu.crossVectors(ai,is),i[0]=is.x,i[4]=Bu.x,i[8]=ai.x,i[1]=is.y,i[5]=Bu.y,i[9]=ai.y,i[2]=is.z,i[6]=Bu.z,i[10]=ai.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],h=n[2],b=n[6],m=n[10],g=n[14],p=n[3],x=n[7],_=n[11],y=n[15],v=i[0],E=i[4],w=i[8],T=i[12],A=i[1],P=i[5],S=i[9],R=i[13],k=i[2],C=i[6],U=i[10],L=i[14],O=i[3],K=i[7],B=i[11],X=i[15];return r[0]=s*v+a*A+o*k+c*O,r[4]=s*E+a*P+o*C+c*K,r[8]=s*w+a*S+o*U+c*B,r[12]=s*T+a*R+o*L+c*X,r[1]=l*v+u*A+d*k+f*O,r[5]=l*E+u*P+d*C+f*K,r[9]=l*w+u*S+d*U+f*B,r[13]=l*T+u*R+d*L+f*X,r[2]=h*v+b*A+m*k+g*O,r[6]=h*E+b*P+m*C+g*K,r[10]=h*w+b*S+m*U+g*B,r[14]=h*T+b*R+m*L+g*X,r[3]=p*v+x*A+_*k+y*O,r[7]=p*E+x*P+_*C+y*K,r[11]=p*w+x*S+_*U+y*B,r[15]=p*T+x*R+_*L+y*X,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],h=e[3],b=e[7],m=e[11],g=e[15],p=o*f-c*d,x=a*f-c*u,_=a*d-o*u,y=s*f-c*l,v=s*d-o*l,E=s*u-a*l;return t*(b*p-m*x+g*_)-n*(h*p-m*y+g*v)+i*(h*x-b*y+g*E)-r*(h*_-b*v+m*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],a=e[9],o=e[2],c=e[6],l=e[10];return t*(s*l-a*c)-n*(r*l-a*o)+i*(r*c-s*o)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*a-n*s,x=t*o-i*s,_=t*c-r*s,y=n*o-i*a,v=n*c-r*a,E=i*c-r*o,w=l*b-u*h,T=l*m-d*h,A=l*g-f*h,P=u*m-d*b,S=u*g-f*b,R=d*g-f*m,k=p*R-x*S+_*P+y*A-v*T+E*w;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]=(a*R-o*S+c*P)*C,e[1]=(i*S-n*R-r*P)*C,e[2]=(b*E-m*v+g*y)*C,e[3]=(d*v-u*E-f*y)*C,e[4]=(o*A-s*R-c*T)*C,e[5]=(t*R-i*A+r*T)*C,e[6]=(m*_-h*E-g*x)*C,e[7]=(l*E-d*_+f*x)*C,e[8]=(s*S-a*A+c*w)*C,e[9]=(n*A-t*S-r*w)*C,e[10]=(h*v-b*_+g*p)*C,e[11]=(u*_-l*v-f*p)*C,e[12]=(a*T-s*P-o*w)*C,e[13]=(t*P-n*T+i*w)*C,e[14]=(b*x-h*y-m*p)*C,e[15]=(l*y-u*x+d*p)*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:a,z:o}=e,c=r*s,l=r*a;return this.set(c*s+n,c*a-i*o,c*o+i*a,0,c*a+i*o,l*a+n,l*o-i*s,0,c*o-i*a,l*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:a,_w:o}=t,c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,b=s*l,m=s*u,g=a*u,p=o*c,x=o*l,_=o*u,{x:y,y:v,z:E}=n;return i[0]=(1-(b+g))*y,i[1]=(f+_)*y,i[2]=(h-x)*y,i[3]=0,i[4]=(f-_)*v,i[5]=(1-(d+g))*v,i[6]=(m+p)*v,i[7]=0,i[8]=(h+x)*E,i[9]=(m-p)*E,i[10]=(1-(d+b))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=ao.set(i[0],i[1],i[2]).length(),a=ao.set(i[4],i[5],i[6]).length(),o=ao.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Oi.copy(this);let c=1/s,l=1/a,u=1/o;return Oi.elements[0]*=c,Oi.elements[1]*=c,Oi.elements[2]*=c,Oi.elements[4]*=l,Oi.elements[5]*=l,Oi.elements[6]*=l,Oi.elements[8]*=u,Oi.elements[9]*=u,Oi.elements[10]*=u,t.setFromRotationMatrix(Oi),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i),h,b;if(o)h=r/(s-r),b=s*r/(s-r);else if(a===2000)h=-(s+r)/(s-r),b=-2*s*r/(s-r);else if(a===2001)h=-s/(s-r),b=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=h,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2000,o=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i),h,b;if(o)h=1/(s-r),b=s/(s-r);else if(a===2000)h=-2/(s-r),b=-(s+r)/(s-r);else if(a===2001)h=-1/(s-r),b=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=h,c[14]=b,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}};ao=new j,Oi=new Je,VN=new j(0,0,0),jN=new j(1,1,1),is=new j,Bu=new j,ai=new j,yE=new Je,_E=new ln;ur=class ur{constructor(e=0,t=0,n=0,i=ur.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],c=i[5],l=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":if(this._y=Math.asin(ct(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,f),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-ct(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(a,f),this._z=Math.atan2(o,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(ct(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,f),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(o,r);break;case"ZYX":if(this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,f),this._z=Math.atan2(o,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(ct(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(a,f);break;case"XZY":if(this._z=Math.asin(-ct(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(a,r);else this._x=Math.atan2(-l,f),this._y=0;break;default:je("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return yE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yE,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _E.setFromEuler(this),this.setFromQuaternion(_E,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}};ur.DEFAULT_ORDER="XYZ";vE=new j,oo=new ln,Pr=new Je,zu=new j,Fc=new j,GN=new j,$N=new ln,EE=new j(1,0,0),TE=new j(0,1,0),AE=new j(0,0,1),wE={type:"added"},KN={type:"removed"},co={type:"childadded",child:null},pp={type:"childremoved",child:null};Dt=class Dt extends Vi{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:HN++}),this.uuid=Fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dt.DEFAULT_UP.clone();let e=new j,t=new ur,n=new ln,i=new j(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Je},normalMatrix:{value:new tt}}),this.matrix=new Je,this.matrixWorld=new Je,this.matrixAutoUpdate=Dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Md,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 oo.setFromAxisAngle(e,t),this.quaternion.multiply(oo),this}rotateOnWorldAxis(e,t){return oo.setFromAxisAngle(e,t),this.quaternion.premultiply(oo),this}rotateX(e){return this.rotateOnAxis(EE,e)}rotateY(e){return this.rotateOnAxis(TE,e)}rotateZ(e){return this.rotateOnAxis(AE,e)}translateOnAxis(e,t){return vE.copy(e).applyQuaternion(this.quaternion),this.position.add(vE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(EE,e)}translateY(e){return this.translateOnAxis(TE,e)}translateZ(e){return this.translateOnAxis(AE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pr.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)zu.copy(e);else zu.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),Fc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Pr.lookAt(Fc,zu,this.up);else Pr.lookAt(zu,Fc,this.up);if(this.quaternion.setFromRotationMatrix(Pr),i)Pr.extractRotation(i.matrixWorld),oo.setFromRotationMatrix(Pr),this.quaternion.premultiply(oo.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 Ye("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(wE),co.child=e,this.dispatchEvent(co),co.child=null;else Ye("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(KN),pp.child=e,this.dispatchEvent(pp),pp.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),Pr.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Pr.multiply(e.parent.matrixWorld);return e.applyMatrix4(Pr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(wE),co.child=e,this.dispatchEvent(co),co.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(Fc,e,GN),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fc,$N,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((a)=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((a)=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(a,o){if(a[o.uuid]===void 0)a[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let o=a.shapes;if(Array.isArray(o))for(let c=0,l=o.length;c<l;c++){let u=o[c];r(e.shapes,u)}else r(e.shapes,o)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let o=0,c=this.material.length;o<c;o++)a.push(r(e.materials,this.material[o]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let o=this.animations[a];i.animations.push(r(e.animations,o))}}if(t){let a=s(e.geometries),o=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),f=s(e.animations),h=s(e.nodes);if(a.length>0)n.geometries=a;if(o.length>0)n.materials=o;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(f.length>0)n.animations=f;if(h.length>0)n.nodes=h}return n.object=i,n;function s(a){let o=[];for(let c in a){let l=a[c];delete l.metadata,o.push(l)}return o}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Dt.DEFAULT_UP=new j(0,1,0);Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;cr=class cr extends Dt{constructor(){super();this.isGroup=!0,this.type="Group"}};WN={type:"move"};qT={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},rs={h:0,s:0,l:0},Vu={h:0,s:0,l:0};qe=class qe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ot.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=ot.workingColorSpace){return this.r=e,this.g=t,this.b=n,ot.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=ot.workingColorSpace){if(e=km(e,1),t=ct(t,0,1),n=ct(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=mp(s,r,e+0.3333333333333333),this.g=mp(s,r,e),this.b=mp(s,r,e-0.3333333333333333)}return ot.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)je("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:je("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else je("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=qT[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else je("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ur(e.r),this.g=Ur(e.g),this.b=Ur(e.b),this}copyLinearToSRGB(e){return this.r=_o(e.r),this.g=_o(e.g),this.b=_o(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return ot.workingToColorSpace(kn.copy(this),e),Math.round(ct(kn.r*255,0,255))*65536+Math.round(ct(kn.g*255,0,255))*256+Math.round(ct(kn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ot.workingColorSpace){ot.workingToColorSpace(kn.copy(this),t);let{r:n,g:i,b:r}=kn,s=Math.max(n,i,r),a=Math.min(n,i,r),o,c,l=(a+s)/2;if(a===s)o=0,c=0;else{let u=s-a;switch(c=l<=0.5?u/(s+a):u/(2-s-a),s){case n:o=(i-r)/u+(i<r?6:0);break;case i:o=(r-n)/u+2;break;case r:o=(n-i)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getRGB(e,t=ot.workingColorSpace){return ot.workingToColorSpace(kn.copy(this),t),e.r=kn.r,e.g=kn.g,e.b=kn.b,e}getStyle(e="srgb"){ot.workingToColorSpace(kn.copy(this),e);let{r:t,g:n,b:i}=kn;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(rs),this.setHSL(rs.h+e,rs.s+t,rs.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(rs),e.getHSL(Vu);let n=Kc(rs.h,Vu.h,t),i=Kc(rs.s,Vu.s,t),r=Kc(rs.l,Vu.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};kn=new qe;qe.NAMES=qT;Po=class Po extends Dt{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 ur,this.environmentIntensity=1,this.environmentRotation=new ur,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}};ki=new j,Or=new j,gp=new j,kr=new j,lo=new j,uo=new j,SE=new j,bp=new j,xp=new j,yp=new j,_p=new Pt,vp=new Pt,Ep=new Pt;Dr=[new j,new j,new j,new j,new j,new j,new j,new j],Di=new j,ju=new pn,fo=new j,ho=new j,po=new j,ss=new j,as=new j,ma=new j,Uc=new j,Hu=new j,Gu=new j,ga=new j;cn=new j,$u=new Ke;En=class En extends Vi{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:XN++}),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++)$u.fromBufferAttribute(this,t),$u.applyMatrix3(e),this.setXY(t,$u.x,$u.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Li(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(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=Li(t,this.array);return t}setX(e,t){if(this.normalized)t=Nt(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=Li(t,this.array);return t}setY(e,t){if(this.normalized)t=Nt(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=Li(t,this.array);return t}setZ(e,t){if(this.normalized)t=Nt(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=Li(t,this.array);return t}setW(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(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=Nt(t,this.array),n=Nt(n,this.array),i=Nt(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=Nt(t,this.array),n=Nt(n,this.array),i=Nt(i,this.array),r=Nt(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"})}};Rd=class Rd extends En{constructor(e,t,n){super(new Uint16Array(e),t,n)}};Id=class Id extends En{constructor(e,t,n){super(new Uint32Array(e),t,n)}};Xn=class Xn extends En{constructor(e,t,n){super(new Float32Array(e),t,n)}};qN=new pn,Bc=new j,Ap=new j;xi=new Je,wp=new Dt,mo=new j,oi=new pn,zc=new pn,vn=new j;Ln=class Ln extends Vi{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:JN++}),this.uuid=Fi(),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((_N(e))?Id:Rd)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new tt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return xi.makeRotationFromQuaternion(e),this.applyMatrix4(xi),this}rotateX(e){return xi.makeRotationX(e),this.applyMatrix4(xi),this}rotateY(e){return xi.makeRotationY(e),this.applyMatrix4(xi),this}rotateZ(e){return xi.makeRotationZ(e),this.applyMatrix4(xi),this}translate(e,t,n){return xi.makeTranslation(e,t,n),this.applyMatrix4(xi),this}scale(e,t,n){return xi.makeScale(e,t,n),this.applyMatrix4(xi),this}lookAt(e){return wp.lookAt(e),wp.updateMatrix(),this.applyMatrix4(wp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mo).negate(),this.translate(mo.x,mo.y,mo.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Xn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)je("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new pn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(oi.setFromBufferAttribute(r),this.morphTargetsRelative)vn.addVectors(this.boundingBox.min,oi.min),this.boundingBox.expandByPoint(vn),vn.addVectors(this.boundingBox.max,oi.max),this.boundingBox.expandByPoint(vn);else this.boundingBox.expandByPoint(oi.min),this.boundingBox.expandByPoint(oi.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Ye('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 ui;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ye("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new j,1/0);return}if(e){let n=this.boundingSphere.center;if(oi.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let a=t[r];if(zc.setFromBufferAttribute(a),this.morphTargetsRelative)vn.addVectors(oi.min,zc.min),oi.expandByPoint(vn),vn.addVectors(oi.max,zc.max),oi.expandByPoint(vn);else oi.expandByPoint(zc.min),oi.expandByPoint(zc.max)}oi.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)vn.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(vn));if(t)for(let r=0,s=t.length;r<s;r++){let a=t[r],o=this.morphTargetsRelative;for(let c=0,l=a.count;c<l;c++){if(vn.fromBufferAttribute(a,c),o)mo.fromBufferAttribute(e,c),vn.add(mo);i=Math.max(i,n.distanceToSquared(vn))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Ye('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){Ye("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 En(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let a=[],o=[];for(let w=0;w<n.count;w++)a[w]=new j,o[w]=new j;let c=new j,l=new j,u=new j,d=new Ke,f=new Ke,h=new Ke,b=new j,m=new j;function g(w,T,A){c.fromBufferAttribute(n,w),l.fromBufferAttribute(n,T),u.fromBufferAttribute(n,A),d.fromBufferAttribute(r,w),f.fromBufferAttribute(r,T),h.fromBufferAttribute(r,A),l.sub(c),u.sub(c),f.sub(d),h.sub(d);let P=1/(f.x*h.y-h.x*f.y);if(!isFinite(P))return;b.copy(l).multiplyScalar(h.y).addScaledVector(u,-f.y).multiplyScalar(P),m.copy(u).multiplyScalar(f.x).addScaledVector(l,-h.x).multiplyScalar(P),a[w].add(b),a[T].add(b),a[A].add(b),o[w].add(m),o[T].add(m),o[A].add(m)}let p=this.groups;if(p.length===0)p=[{start:0,count:e.count}];for(let w=0,T=p.length;w<T;++w){let A=p[w],{start:P,count:S}=A;for(let R=P,k=P+S;R<k;R+=3)g(e.getX(R+0),e.getX(R+1),e.getX(R+2))}let x=new j,_=new j,y=new j,v=new j;function E(w){y.fromBufferAttribute(i,w),v.copy(y);let T=a[w];x.copy(T),x.sub(y.multiplyScalar(y.dot(T))).normalize(),_.crossVectors(v,T);let P=_.dot(o[w])<0?-1:1;s.setXYZW(w,x.x,x.y,x.z,P)}for(let w=0,T=p.length;w<T;++w){let A=p[w],{start:P,count:S}=A;for(let R=P,k=P+S;R<k;R+=3)E(e.getX(R+0)),E(e.getX(R+1)),E(e.getX(R+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 En(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new j,r=new j,s=new j,a=new j,o=new j,c=new j,l=new j,u=new j;if(e)for(let d=0,f=e.count;d<f;d+=3){let h=e.getX(d+0),b=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,b),s.fromBufferAttribute(t,m),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),a.fromBufferAttribute(n,h),o.fromBufferAttribute(n,b),c.fromBufferAttribute(n,m),a.add(l),o.add(l),c.add(l),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(b,o.x,o.y,o.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)vn.fromBufferAttribute(e,t),vn.normalize(),e.setXYZ(t,vn.x,vn.y,vn.z)}toNonIndexed(){function e(a,o){let{array:c,itemSize:l,normalized:u}=a,d=new c.constructor(o.length*l),f=0,h=0;for(let b=0,m=o.length;b<m;b++){if(a.isInterleavedBufferAttribute)f=o[b]*a.data.stride+a.offset;else f=o[b]*l;for(let g=0;g<l;g++)d[h++]=c[f++]}return new En(d,l,u)}if(this.index===null)return je("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Ln,n=this.index.array,i=this.attributes;for(let a in i){let o=i[a],c=e(o,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let o=[],c=r[a];for(let l=0,u=c.length;l<u;l++){let d=c[l],f=e(d,n);o.push(f)}t.morphAttributes[a]=o}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let a=0,o=s.length;a<o;a++){let c=s[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let c in o)if(o[c]!==void 0)e[c]=o[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let c=n[o];e.data.attributes[o]=c.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let c=this.morphAttributes[o],l=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];l.push(f.toJSON(e.data))}if(l.length>0)i[o]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let a=this.boundingSphere;if(a!==null)e.data.boundingSphere=a.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,f=u.length;d<f;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;if(a!==null)this.boundingBox=a.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};Gn=new j;Sp=new j,ZN=new j,YN=new tt;qn=class qn extends Vi{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:QN++}),this.uuid=Fi(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){je(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){je(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let a in r){let o=r[a];delete o.metadata,s.push(o)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new qe().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new yi().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ke().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ke().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}};Lr=new j,Mp=new j,Ku=new j,Wu=new j;mr=class mr extends qn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ur,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}};ME=new Je,ba=new ms,Xu=new ui,RE=new j,qu=new j,Ju=new j,Zu=new j,Rp=new j,Yu=new j,IE=new j,Qu=new j;jt=class jt extends Dt{constructor(e=new Ln,t=new mr){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(r&&a){Yu.set(0,0,0);for(let o=0,c=r.length;o<c;o++){let l=a[o],u=r[o];if(l===0)continue;if(Rp.fromBufferAttribute(u,e),s)Yu.addScaledVector(Rp,l);else Yu.addScaledVector(Rp.sub(t),l)}t.add(Yu)}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(Xu.copy(n.boundingSphere),Xu.applyMatrix4(r),ba.copy(e.ray).recast(e.near),Xu.containsPoint(ba.origin)===!1){if(ba.intersectSphere(Xu,RE)===null)return;if(ba.origin.distanceToSquared(RE)>(e.far-e.near)**2)return}if(ME.copy(r).invert(),ba.copy(e.ray).applyMatrix4(ME),n.boundingBox!==null){if(ba.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,ba)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:f}=r;if(a!==null)if(Array.isArray(s))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=s[m.materialIndex],p=Math.max(m.start,f.start),x=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let _=p,y=x;_<y;_+=3){let v=a.getX(_),E=a.getX(_+1),w=a.getX(_+2);if(i=ed(this,g,e,n,c,l,u,v,E,w),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),b=Math.min(a.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=a.getX(m),x=a.getX(m+1),_=a.getX(m+2);if(i=ed(this,s,e,n,c,l,u,p,x,_),i)i.faceIndex=Math.floor(m/3),t.push(i)}}else if(o!==void 0)if(Array.isArray(s))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=s[m.materialIndex],p=Math.max(m.start,f.start),x=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=p,y=x;_<y;_+=3){let v=_,E=_+1,w=_+2;if(i=ed(this,g,e,n,c,l,u,v,E,w),i)i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i)}}else{let h=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=m,x=m+1,_=m+2;if(i=ed(this,s,e,n,c,l,u,p,x,_),i)i.faceIndex=Math.floor(m/3),t.push(i)}}}};Vc=new Pt,CE=new Pt,NE=new Pt,tP=new Pt,PE=new Je,td=new j,Ip=new ui,OE=new Je,Cp=new ms;Cd=class Cd extends jt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Je,this.bindMatrixInverse=new Je,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new pn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,td),this.boundingBox.expandByPoint(td)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new ui;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,td),this.boundingSphere.expandByPoint(td)}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(Ip.copy(this.boundingSphere),Ip.applyMatrix4(i),e.ray.intersectsSphere(Ip)===!1)return;if(OE.copy(i).invert(),Cp.copy(e.ray).applyMatrix4(OE),this.boundingBox!==null){if(Cp.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Cp)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else je("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(CE.fromBufferAttribute(i.attributes.skinIndex,e),NE.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)Vc.copy(t),t.set(0,0,0,0);else Vc.set(...t,1),t.set(0,0,0);Vc.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=NE.getComponent(r);if(s!==0){let a=CE.getComponent(r);PE.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(tP.copy(Vc).applyMatrix4(PE),s)}}if(t.isVector4)t.w=Vc.w;return t.applyMatrix4(this.bindMatrixInverse)}};rl=class rl extends Dt{constructor(){super();this.isBone=!0,this.type="Bone"}};sl=class sl extends en{constructor(e=null,t=1,n=1,i,r,s,a,o,c=1003,l=1003,u,d){super(null,s,a,o,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};kE=new Je,nP=new Je;ls=class ls extends En{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}};go=new Je,DE=new Je,nd=[],LE=new pn,iP=new Je,jc=new jt,Hc=new ui;ko=class ko extends jt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ls(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,iP)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new pn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,go),LE.copy(e.boundingBox).applyMatrix4(go),this.boundingBox.union(LE)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new ui;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,go),Hc.copy(e.boundingSphere).applyMatrix4(go),this.boundingSphere.union(Hc)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[s+a]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(jc.geometry=this.geometry,jc.material=this.material,jc.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Hc.copy(this.boundingSphere),Hc.applyMatrix4(n),e.ray.intersectsSphere(Hc)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,go),DE.multiplyMatrices(n,go),jc.matrixWorld=DE,jc.raycast(e,nd);for(let s=0,a=nd.length;s<a;s++){let o=nd[s];o.instanceId=r,o.object=this,t.push(o)}nd.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ls(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 sl(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let a=this.geometry.morphTargetsRelative?1:1-s,o=i*e;return r[o]=a,r.set(n,o+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}};xa=new ui,rP=new Ke(0.5,0.5),id=new j;cl=class cl extends qn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};dd=new j,fd=new j,FE=new Je,Gc=new ms,rd=new ui,Np=new j,UE=new j;gs=class gs extends Dt{constructor(e=new Ln,t=new cl){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++)dd.fromBufferAttribute(t,i-1),fd.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=dd.distanceTo(fd);e.setAttribute("lineDistance",new Xn(n,1))}else je("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(rd.copy(n.boundingSphere),rd.applyMatrix4(i),rd.radius+=r,e.ray.intersectsSphere(rd)===!1)return;FE.copy(i).invert(),Gc.copy(e.ray).applyMatrix4(FE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,s.start),h=Math.min(l.count,s.start+s.count);for(let b=f,m=h-1;b<m;b+=c){let g=l.getX(b),p=l.getX(b+1),x=sd(this,e,Gc,o,g,p,b);if(x)t.push(x)}if(this.isLineLoop){let b=l.getX(h-1),m=l.getX(f),g=sd(this,e,Gc,o,b,m,h-1);if(g)t.push(g)}}else{let f=Math.max(0,s.start),h=Math.min(d.count,s.start+s.count);for(let b=f,m=h-1;b<m;b+=c){let g=sd(this,e,Gc,o,b,b+1,b);if(g)t.push(g)}if(this.isLineLoop){let b=sd(this,e,Gc,o,h-1,f,h-1);if(b)t.push(b)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};BE=new j,zE=new j;Nd=class Nd extends gs{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)BE.fromBufferAttribute(t,i),zE.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+BE.distanceTo(zE);e.setAttribute("lineDistance",new Xn(n,1))}else je("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};Pd=class Pd extends gs{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}};ll=class ll extends qn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};VE=new Je,kp=new ms,ad=new ui,od=new j;Do=class Do extends Dt{constructor(e=new Ln,t=new ll){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(ad.copy(n.boundingSphere),ad.applyMatrix4(i),ad.radius+=r,e.ray.intersectsSphere(ad)===!1)return;VE.copy(i).invert(),kp.copy(e.ray).applyMatrix4(VE);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),f=Math.min(c.count,s.start+s.count);for(let h=d,b=f;h<b;h++){let m=c.getX(h);od.fromBufferAttribute(u,m),jE(od,m,o,i,e,t,this)}}else{let d=Math.max(0,s.start),f=Math.min(u.count,s.start+s.count);for(let h=d,b=f;h<b;h++)od.fromBufferAttribute(u,h),jE(od,h,o,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};Od=class Od extends en{constructor(e=[],t=301,n,i,r,s,a,o,c,l){super(e,t,n,i,r,s,a,o,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};Ma=class Ma extends en{constructor(e,t,n=1014,i,r,s,a=1003,o=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,a,o,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new tl(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}};Um=class Um extends Ma{constructor(e,t=1014,n=301,i,r,s=1003,a=1003,o,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,a,o,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};kd=class kd extends en{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};bs=class bs extends Ln{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let o=[],c=[],l=[],u=[],d=0,f=0;h("z","y","x",-1,-1,n,t,e,s,r,0),h("z","y","x",1,-1,n,t,-e,s,r,1),h("x","z","y",1,1,e,n,t,i,s,2),h("x","z","y",1,-1,e,n,-t,i,s,3),h("x","y","z",1,-1,e,t,n,i,r,4),h("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Xn(c,3)),this.setAttribute("normal",new Xn(l,3)),this.setAttribute("uv",new Xn(u,2));function h(b,m,g,p,x,_,y,v,E,w,T){let A=_/E,P=y/w,S=_/2,R=y/2,k=v/2,C=E+1,U=w+1,L=0,O=0,K=new j;for(let B=0;B<U;B++){let X=B*P-R;for(let q=0;q<C;q++){let le=q*A-S;K[b]=le*p,K[m]=X*x,K[g]=k,c.push(K.x,K.y,K.z),K[b]=0,K[m]=0,K[g]=v>0?1:-1,l.push(K.x,K.y,K.z),u.push(q/E),u.push(1-B/w),L+=1}}for(let B=0;B<w;B++)for(let X=0;X<E;X++){let q=d+X+C*B,le=d+X+C*(B+1),de=d+(X+1)+C*(B+1),Me=d+(X+1)+C*B;o.push(q,le,Me),o.push(le,de,Me),O+=6}a.addGroup(f,O,T),f+=O,d+=L}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};ul=class ul extends Ln{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,a=Math.floor(n),o=Math.floor(i),c=a+1,l=o+1,u=e/a,d=t/o,f=[],h=[],b=[],m=[];for(let g=0;g<l;g++){let p=g*d-s;for(let x=0;x<c;x++){let _=x*u-r;h.push(_,-p,0),b.push(0,0,1),m.push(x/a),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let p=0;p<a;p++){let x=p+c*g,_=p+c*(g+1),y=p+1+c*(g+1),v=p+1+c*g;f.push(x,_,v),f.push(_,y,v)}this.setIndex(f),this.setAttribute("position",new Xn(h,3)),this.setAttribute("normal",new Xn(b,3)),this.setAttribute("uv",new Xn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ul(e.width,e.height,e.widthSegments,e.heightSegments)}};JT={clone:Ra,merge:Fn};Ei=class Ei extends qn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=aP,this.fragmentShader=oP,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=Ra(e.uniforms),this.uniformsGroups=sP(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new qe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new j().fromArray(i.value);break;case"v4":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new tt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Je().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}};zm=class zm extends Ei{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};zr=class zr extends qn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ur,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}};di=class di extends zr{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ct(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};Dd=class Dd extends qn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ur,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};Vm=class Vm extends qn{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}};jm=class jm extends qn{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}};Hm=class Hm extends Vr{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,a=i[r],o=i[s];if(a===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,a=2*t-n;break;case 2402:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,o=2*n-t;break;case 2402:s=1,o=n+i[1]-i[0];break;default:s=e-1,o=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(o-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(i-t),b=h*h,m=b*h,g=-d*m+2*d*b-d*h,p=(1+d)*m+(-1.5-2*d)*b+(-0.5+d)*h+1,x=(-1-f)*m+(1.5+f)*b+0.5*h,_=f*m-f*b;for(let y=0;y!==a;++y)r[y]=g*s[l+y]+p*s[c+y]+x*s[o+y]+_*s[u+y];return r}};Ld=class Ld extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==a;++d)r[d]=s[c+d]*u+s[o+d]*l;return r}};Gm=class Gm extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}};$m=class $m extends Vr{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,c=o-a,l=this.inTangents,u=this.outTangents;if(!l||!u){let h=(n-t)/(i-t),b=1-h;for(let m=0;m!==a;++m)r[m]=s[c+m]*b+s[o+m]*h;return r}let d=a*2,f=e-1;for(let h=0;h!==a;++h){let b=s[c+h],m=s[o+h],g=f*d+h*2,p=u[g],x=u[g+1],_=e*d+h*2,y=l[_],v=l[_+1],E=dP(n,t,p,y,i);r[h]=ZT(E,b,x,v,m)}return r}};fi.prototype.ValueTypeName="";fi.prototype.TimeBufferType=Float32Array;fi.prototype.ValueBufferType=Float32Array;fi.prototype.DefaultInterpolation=2301;xs=class xs extends fi{constructor(e,t,n){super(e,t,n)}};xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=2300;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;Fd=class Fd extends fi{constructor(e,t,n,i){super(e,t,n,i)}};Fd.prototype.ValueTypeName="color";ys=class ys extends fi{constructor(e,t,n,i){super(e,t,n,i)}};ys.prototype.ValueTypeName="number";Km=class Km extends Vr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t),c=e*a;for(let l=c+a;c!==l;c+=4)ln.slerpFlat(r,0,s,c-a,s,c,o);return r}};_s=class _s extends fi{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Km(this.times,this.values,this.getValueSize(),e)}};_s.prototype.ValueTypeName="quaternion";_s.prototype.InterpolantFactoryMethodSmooth=void 0;vs=class vs extends fi{constructor(e,t,n){super(e,t,n)}};vs.prototype.ValueTypeName="string";vs.prototype.ValueBufferType=Array;vs.prototype.DefaultInterpolation=2300;vs.prototype.InterpolantFactoryMethodLinear=void 0;vs.prototype.InterpolantFactoryMethodSmooth=void 0;Ia=class Ia extends fi{constructor(e,t,n,i){super(e,t,n,i)}};Ia.prototype.ValueTypeName="vector";lr={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(KE(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(KE(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};YT=new dl;jr.DEFAULT_MATERIAL_NAME="__DEFAULT";Fr={};QT=class QT extends Error{constructor(e,t){super(e);this.response=t}};fl=class fl extends jr{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=lr.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Fr[e]!==void 0){Fr[e].push({onLoad:t,onProgress:n,onError:i});return}Fr[e]=[],Fr[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)je("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Fr[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,h=f!==0,b=0,m=new ReadableStream({start(g){p();function p(){u.read().then(({done:x,value:_})=>{if(x)g.close();else{b+=_.byteLength;let y=new ProgressEvent("progress",{lengthComputable:h,loaded:b,total:f});for(let v=0,E=l.length;v<E;v++){let w=l[v];if(w.onProgress)w.onProgress(y)}g.enqueue(_),p()}},(x)=>{g.error(x)})}}});return new Response(m)}else throw new QT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(o){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,a));case"json":return c.json();default:if(a==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then((h)=>f.decode(h))}}}).then((c)=>{lr.add(`file:${e}`,c);let l=Fr[e];delete Fr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onLoad)f.onLoad(c)}}).catch((c)=>{let l=Fr[e];if(l===void 0)throw this.manager.itemError(e),c;delete Fr[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onError)f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};bo=new WeakMap;Wm=class Wm extends jr{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=lr.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=bo.get(s);if(u===void 0)u=[],bo.set(s,u);u.push({onLoad:t,onError:i})}return s}let a=vo("img");function o(){if(l(),t)t(this);let u=bo.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];if(f.onLoad)f.onLoad(this)}bo.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);lr.remove(`image:${e}`);let d=bo.get(this)||[];for(let f=0;f<d.length;f++){let h=d[f];if(h.onError)h.onError(u)}bo.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){a.removeEventListener("load",o,!1),a.removeEventListener("error",c,!1)}if(a.addEventListener("load",o,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)a.crossOrigin=this.crossOrigin}return lr.add(`image:${e}`,a),r.manager.itemStart(e),a.src=e,a}};Lo=class Lo extends jr{constructor(e){super(e)}load(e,t,n,i){let r=new en,s=new Wm(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(a){if(r.image=a,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}};Fo=class Fo extends Dt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new qe(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}};Ud=class Ud extends Fo{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}};Pp=new Je,WE=new j,XE=new j;cd=new j,ld=new ln,or=new j;Bd=class Bd extends Dt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Je,this.projectionMatrix=new Je,this.projectionMatrixInverse=new Je,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(cd,ld,or),or.x===1&&or.y===1&&or.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(cd,ld,or.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(cd,ld,or),or.x===1&&or.y===1&&or.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(cd,ld,or.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};os=new j,qE=new Ke,JE=new Ke;hn=class hn extends Bd{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=_a*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan($c*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return _a*2*Math.atan(Math.tan($c*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){os.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(os.x,os.y).multiplyScalar(-e/os.z),os.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(os.x,os.y).multiplyScalar(-e/os.z)}getViewSize(e,t){return this.getViewBounds(e,qE,JE),t.subVectors(JE,qE)}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($c*0.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-0.5*i,s=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:c}=s;r+=s.offsetX*i/o,t-=s.offsetY*n/c,i*=s.width/o,n*=s.height/c}let a=this.filmOffset;if(a!==0)r+=e*a/this.getFilmWidth();this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null)t.object.view=Object.assign({},this.view);return t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};eA=class eA extends hl{constructor(){super(new hn(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=_a*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}};zd=class zd extends Fo{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(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new eA}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}};tA=class tA extends hl{constructor(){super(new hn(90,1,0.5,500));this.isPointLightShadow=!0}};Uo=class Uo extends Fo{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 tA}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}};Ca=class Ca extends Bd{constructor(e=-1,t=1,n=1,i=-1,r=0.1,s=2000){super();this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){if(this.view===null)this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1};this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,s=n+e,a=i+t,o=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,s=r+c*this.view.width,a-=l*this.view.offsetY,o=a-l*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}};nA=class nA extends hl{constructor(){super(new Ca(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}};Bo=class Bo extends Fo{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dt.DEFAULT_UP),this.updateMatrix(),this.target=new Dt,this.shadow=new nA}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}};Op=new WeakMap;Vd=class Vd extends jr{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")je("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")je("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=lr.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Op.has(s)===!0){if(i)i(Op.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(lr.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Op.set(o,c),lr.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});lr.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};Xm=class Xm extends Dt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new hn(xo,yo,e,t);i.layers=this.layers,this.add(i);let r=new hn(xo,yo,e,t);r.layers=this.layers,this.add(r);let s=new hn(xo,yo,e,t);s.layers=this.layers,this.add(s);let a=new hn(xo,yo,e,t);a.layers=this.layers,this.add(a);let o=new hn(xo,yo,e,t);o.layers=this.layers,this.add(o);let c=new hn(xo,yo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,a,o,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),h=e.xr.enabled;e.xr.enabled=!1;let b=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;if(e.isWebGLRenderer===!0)m=e.state.buffers.depth.getReversed();else m=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,3,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,i),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=b,e.setRenderTarget(n,5,i),m&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}};qm=class qm extends hn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};pP=new RegExp("["+Zm+"]","g"),Ym="[^"+Zm+"]",mP="[^"+Zm.replace("\\.","")+"]",gP=/((?:WC+[\/:])*)/.source.replace("WC",Ym),bP=/(WCOD+)?/.source.replace("WCOD",mP),xP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ym),yP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ym),_P=new RegExp("^"+gP+bP+xP+yP+"$"),vP=["material","materials","bones","map"];Tt.Composite=iA;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];EP=new Float32Array(1);jd=class jd extends Vi{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:a}=e,o=n.uuid,c=this._bindingsByRootAndName,l=c[o];if(l===void 0)l={},c[o]=l;for(let u=0;u!==r;++u){let d=i[u],f=d.name,h=l[f];if(h!==void 0)++h.referenceCount,s[u]=h;else{if(h=s[u],h!==void 0){if(h._cacheIndex===null)++h.referenceCount,this._addInactiveBinding(h,o,f);continue}let b=t&&t._propertyBindings[u].binding.parsedPath;h=new Jm(Tt.create(n,f,b),d.ValueTypeName,d.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,f),s[u]=h}a[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let a=s.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,c=o[o.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,o[l]=c,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],o.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,a=s[i],o=t[t.length-1],c=e._cacheIndex;if(o._cacheIndex=c,t[c]=o,t.pop(),delete a[r],Object.keys(a).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Ld(new Float32Array(2),new Float32Array(2),1,EP),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"?To.findByName(i,e):e,a=s!==null?s.uuid:e,o=this._actionsByClip[a],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(o!==void 0){let u=o.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=o.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new Qm(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,a,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?To.findByName(n,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];if(a!==void 0)return a.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let a=this._bindings,o=this._nActiveBindings;for(let c=0;c!==o;++c)a[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let a=0,o=s.length;a!==o;++a){let c=s[a];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let a=n[s].actionByRoot,o=a[t];if(o!==void 0)this._deactivateAction(o),this._removeInactiveAction(o)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let a=r[s];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}};eg=class eg{static{eg.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}};Hd=class Hd extends Vi{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}};if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)je("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186"});function wA(){let e=null,t=!1,n=null,i=null;function r(s,a){i=e.requestAnimationFrame(r),n(s,a)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;i=e.requestAnimationFrame(r),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(i);t=!1},setAnimationLoop:function(s){n=s},setContext:function(s){e=s}}}function AP(e){let t=new WeakMap;function n(o,c){let{array:l,usage:u}=o,d=l.byteLength,f=e.createBuffer();e.bindBuffer(c,f),e.bufferData(c,l,u),o.onUploadCallback();let h;if(l instanceof Float32Array)h=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)h=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(o.isFloat16BufferAttribute)h=e.HALF_FLOAT;else h=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)h=e.SHORT;else if(l instanceof Uint32Array)h=e.UNSIGNED_INT;else if(l instanceof Int32Array)h=e.INT;else if(l instanceof Int8Array)h=e.BYTE;else if(l instanceof Uint8Array)h=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)h=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:h,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,o),d.length===0)e.bufferSubData(l,0,u);else{d.sort((h,b)=>h.start-b.start);let f=0;for(let h=1;h<d.length;h++){let b=d[f],m=d[h];if(m.start<=b.start+b.count+1)b.count=Math.max(b.count,m.start+m.count-b.start);else++f,d[f]=m}d.length=f+1;for(let h=0,b=d.length;h<b;h++){let m=d[h];e.bufferSubData(l,m.start*u.BYTES_PER_ELEMENT,u,m.start,m.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function s(o){if(o.isInterleavedBufferAttribute)o=o.data;let c=t.get(o);if(c)e.deleteBuffer(c.buffer),t.delete(o)}function a(o,c){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,n(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}function aD(e,t,n,i,r,s){let a=new qe(0),o=r===!0?0:1,c,l,u=null,d=0,f=null;function h(x){let _=x.isScene===!0?x.background:null;if(_&&_.isTexture){let y=x.backgroundBlurriness>0;_=t.get(_,y)}return _}function b(x){let _=!1,y=h(x);if(y===null)g(a,o);else if(y&&y.isColor)g(y,1),_=!0;let v=e.xr.getEnvironmentBlendMode();if(v==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(v==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||_)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function m(x,_){let y=h(_);if(y&&(y.isCubeTexture||y.mapping===Zc)){if(l===void 0)l=new jt(new bs(1,1,1),new Ei({name:"BackgroundCubeMaterial",uniforms:Ra(br.backgroundCube.uniforms),vertexShader:br.backgroundCube.vertexShader,fragmentShader:br.backgroundCube.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(v,E,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(sD.makeRotationFromEuler(_.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(SA);if(l.material.toneMapped=ot.getTransfer(y.colorSpace)!==Bt,u!==y||d!==y.version||f!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,f=e.toneMapping;l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new jt(new ul(2,2),new Ei({name:"BackgroundMaterial",uniforms:Ra(br.background.uniforms),vertexShader:br.background.vertexShader,fragmentShader:br.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.toneMapped=ot.getTransfer(y.colorSpace)!==Bt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||f!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,f=e.toneMapping;c.layers.enableAll(),x.unshift(c,c.geometry,c.material,0,0,null)}}function g(x,_){x.getRGB(Gd,Bm(e)),n.buffers.color.setClear(Gd.r,Gd.g,Gd.b,_,s)}function p(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return a},setClearColor:function(x,_=1){a.set(x),o=_,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(x){o=x,g(a,o)},render:b,addToRenderList:m,dispose:p}}function oD(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=f(null),s=r,a=!1;function o(S,R,k,C,U){let L=!1,O=d(S,C,k,R);if(s!==O)s=O,l(s.object);if(L=h(S,C,k,U),L)b(S,C,k,U);if(U!==null)t.update(U,e.ELEMENT_ARRAY_BUFFER);if(L||a){if(a=!1,y(S,R,k,C),U!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(U).buffer)}}function c(){return e.createVertexArray()}function l(S){return e.bindVertexArray(S)}function u(S){return e.deleteVertexArray(S)}function d(S,R,k,C){let U=C.wireframe===!0,L=i[R.id];if(L===void 0)L={},i[R.id]=L;let O=S.isInstancedMesh===!0?S.id:0,K=L[O];if(K===void 0)K={},L[O]=K;let B=K[k.id];if(B===void 0)B={},K[k.id]=B;let X=B[U];if(X===void 0)X=f(c()),B[U]=X;return X}function f(S){let R=[],k=[],C=[];for(let U=0;U<n;U++)R[U]=0,k[U]=0,C[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:C,object:S,attributes:{},index:null}}function h(S,R,k,C){let U=s.attributes,L=R.attributes,O=0,K=k.getAttributes();for(let B in K)if(K[B].location>=0){let q=U[B],le=L[B];if(le===void 0){if(B==="instanceMatrix"&&S.instanceMatrix)le=S.instanceMatrix;if(B==="instanceColor"&&S.instanceColor)le=S.instanceColor}if(q===void 0)return!0;if(q.attribute!==le)return!0;if(le&&q.data!==le.data)return!0;O++}if(s.attributesNum!==O)return!0;if(s.index!==C)return!0;return!1}function b(S,R,k,C){let U={},L=R.attributes,O=0,K=k.getAttributes();for(let B in K)if(K[B].location>=0){let q=L[B];if(q===void 0){if(B==="instanceMatrix"&&S.instanceMatrix)q=S.instanceMatrix;if(B==="instanceColor"&&S.instanceColor)q=S.instanceColor}let le={};if(le.attribute=q,q&&q.data)le.data=q.data;U[B]=le,O++}s.attributes=U,s.attributesNum=O,s.index=C}function m(){let S=s.newAttributes;for(let R=0,k=S.length;R<k;R++)S[R]=0}function g(S){p(S,0)}function p(S,R){let k=s.newAttributes,C=s.enabledAttributes,U=s.attributeDivisors;if(k[S]=1,C[S]===0)e.enableVertexAttribArray(S),C[S]=1;if(U[S]!==R)e.vertexAttribDivisor(S,R),U[S]=R}function x(){let S=s.newAttributes,R=s.enabledAttributes;for(let k=0,C=R.length;k<C;k++)if(R[k]!==S[k])e.disableVertexAttribArray(k),R[k]=0}function _(S,R,k,C,U,L,O){if(O===!0)e.vertexAttribIPointer(S,R,k,U,L);else e.vertexAttribPointer(S,R,k,C,U,L)}function y(S,R,k,C){m();let U=C.attributes,L=k.getAttributes(),O=R.defaultAttributeValues;for(let K in L){let B=L[K];if(B.location>=0){let X=U[K];if(X===void 0){if(K==="instanceMatrix"&&S.instanceMatrix)X=S.instanceMatrix;if(K==="instanceColor"&&S.instanceColor)X=S.instanceColor}if(X!==void 0){let q=X.normalized,le=X.itemSize,de=t.get(X);if(de===void 0)continue;let{buffer:Me,type:pe,bytesPerElement:J}=de,F=pe===e.INT||pe===e.UNSIGNED_INT||X.gpuType===Kp;if(X.isInterleavedBufferAttribute){let W=X.data,ne=W.stride,ie=X.offset;if(W.isInstancedInterleavedBuffer){for(let ce=0;ce<B.locationSize;ce++)p(B.location+ce,W.meshPerAttribute);if(S.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=W.meshPerAttribute*W.count}else for(let ce=0;ce<B.locationSize;ce++)g(B.location+ce);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let ce=0;ce<B.locationSize;ce++)_(B.location+ce,le/B.locationSize,pe,q,ne*J,(ie+le/B.locationSize*ce)*J,F)}else{if(X.isInstancedBufferAttribute){for(let W=0;W<B.locationSize;W++)p(B.location+W,X.meshPerAttribute);if(S.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=X.meshPerAttribute*X.count}else for(let W=0;W<B.locationSize;W++)g(B.location+W);e.bindBuffer(e.ARRAY_BUFFER,Me);for(let W=0;W<B.locationSize;W++)_(B.location+W,le/B.locationSize,pe,q,le*J,le/B.locationSize*W*J,F)}}else if(O!==void 0){let q=O[K];if(q!==void 0)switch(q.length){case 2:e.vertexAttrib2fv(B.location,q);break;case 3:e.vertexAttrib3fv(B.location,q);break;case 4:e.vertexAttrib4fv(B.location,q);break;default:e.vertexAttrib1fv(B.location,q)}}}}x()}function v(){A();for(let S in i){let R=i[S];for(let k in R){let C=R[k];for(let U in C){let L=C[U];for(let O in L)u(L[O].object),delete L[O];delete C[U]}}delete i[S]}}function E(S){if(i[S.id]===void 0)return;let R=i[S.id];for(let k in R){let C=R[k];for(let U in C){let L=C[U];for(let O in L)u(L[O].object),delete L[O];delete C[U]}}delete i[S.id]}function w(S){for(let R in i){let k=i[R];for(let C in k){let U=k[C];if(U[S.id]===void 0)continue;let L=U[S.id];for(let O in L)u(L[O].object),delete L[O];delete U[S.id]}}}function T(S){for(let R in i){let k=i[R],C=S.isInstancedMesh===!0?S.id:0,U=k[C];if(U===void 0)continue;for(let L in U){let O=U[L];for(let K in O)u(O[K].object),delete O[K];delete U[L]}if(delete k[C],Object.keys(k).length===0)delete i[R]}}function A(){if(P(),a=!0,s===r)return;s=r,l(s.object)}function P(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:A,resetDefaultState:P,dispose:v,releaseStatesOfGeometry:E,releaseStatesOfObject:T,releaseStatesOfProgram:w,initAttributes:m,enableAttribute:g,disableUnusedAttributes:x}}function cD(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function a(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function o(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let f=0;for(let h=0;h<u;h++)f+=l[h];n.update(f,i,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function lD(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let w=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){if(w!==pr&&i.convert(w)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(w){let T=w===hr&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(w!==zi&&w!==Br&&!T&&i.convert(w)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(w){if(w==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";w="mediump"}if(w==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)je("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&f===!1)je("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),b=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),x=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:h,maxVertexTextures:b,maxTextureSize:m,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:x,maxVaryings:_,maxFragmentUniforms:y,maxSamples:v,samples:E}}function uD(e){let t=this,n=null,i=0,r=!1,s=!1,a=new yi,o=new tt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let h=d.length!==0||f||i!==0||r;return r=f,i=d.length,h},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){n=u(d,f,0)},this.setState=function(d,f,h){let{clippingPlanes:b,clipIntersection:m,clipShadows:g}=d,p=e.get(d);if(!r||b===null||b.length===0||s&&!g)if(s)u(null);else l();else{let x=s?0:i,_=x*4,y=p.clippingState||null;c.value=y,y=u(b,f,_,h);for(let v=0;v!==_;++v)y[v]=n[v];p.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=x}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,f,h,b){let m=d!==null?d.length:0,g=null;if(m!==0){if(g=c.value,b!==!0||g===null){let p=h+m*4,x=f.matrixWorldInverse;if(o.getNormalMatrix(x),g===null||g.length<p)g=new Float32Array(p);for(let _=0,y=h;_!==m;++_,y+=4)a.copy(d[_]).applyMatrix4(x,o),a.normal.toArray(g,y),g[y+3]=a.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}class yl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=0.1,i=100,r={}){let{size:s=256,position:a=pD}=r;ig=this._renderer.getRenderTarget(),rg=this._renderer.getActiveCubeFace(),sg=this._renderer.getActiveMipmapLevel(),ag=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,a),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=oA(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=aA(),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(ig,rg,sg),this._renderer.xr.enabled=ag,e.scissorTest=!1,zo(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===So||e.mapping===va)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);ig=this._renderer.getRenderTarget(),rg=this._renderer.getActiveCubeFace(),sg=this._renderer.getActiveMipmapLevel(),ag=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:Tn,minFilter:Tn,generateMipmaps:!1,type:hr,format:pr,colorSpace:ci,depthBuffer:!1},i=sA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=sA(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=mD(r)),this._blurMaterial=bD(r,e,t),this._ggxMaterial=gD(r,e,t)}return i}_compileMaterial(e){let t=new jt(new Ln,e);this._renderer.compile(t,ml)}_sceneToCubeUV(e,t,n,i,r){let o=new hn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:f}=u;if(u.getClearColor(rA),u.toneMapping=Ui,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new jt(new bs,new mr({name:"PMREM.Background",side:Dn,depthWrite:!1,depthTest:!1}));let b=this._backgroundBox,m=b.material,g=!1,p=e.background;if(p){if(p.isColor)m.color.copy(p),e.background=null,g=!0}else m.color.copy(rA),g=!0;for(let x=0;x<6;x++){let _=x%3;if(_===0)o.up.set(0,c[x],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x+l[x],r.y,r.z);else if(_===1)o.up.set(0,0,c[x]),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y+l[x],r.z);else o.up.set(0,c[x],0),o.position.set(r.x,r.y,r.z),o.lookAt(r.x,r.y,r.z+l[x]);let y=this._cubeSize;if(zo(i,_*y,x>2?y:0,y,y),u.setRenderTarget(i),g)u.render(b,o);u.render(e,o)}u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===So||e.mapping===va;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=oA();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=aA();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let a=r.uniforms;a.envMap.value=e;let o=this._cubeSize;zo(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(s,ml)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[n];a.material=s;let o=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,f=u*d,{_lodMax:h}=this,b=this._sizeLods[n],m=3*b*(n>h-Vo?n-h+Vo:0),g=4*(this._cubeSize-b);o.envMap.value=e.texture,o.roughness.value=f,o.mipInt.value=h-t,zo(r,m,g,3*b,2*b),i.setRenderTarget(r),i.render(a,ml),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,zo(e,m,g,3*b,2*b),i.setRenderTarget(e),i.render(a,ml)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,a=this._blurMaterial,o=this._lodMeshes[i];o.material=a;let c=a.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Vo?i-this._lodMax+Vo:0),d=4*(this._cubeSize-l);zo(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(o,ml)}}function mD(e){let t=[],n=[],i=e,r=e-Vo+1+dD;for(let s=0;s<r;s++){let a=Math.pow(2,i);t.push(a);let o=1/(a-2),c=-o,l=1+o,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,f=6,h=3,b=new Float32Array(h*f*d),m=new Float32Array(h*f*d);for(let p=0;p<d;p++){let x=p%3*2/3-1,_=p>2?0:-1,y=[x,_,0,x+0.6666666666666666,_,0,x+0.6666666666666666,_+1,0,x,_,0,x+0.6666666666666666,_+1,0,x,_+1,0];b.set(y,h*f*p);for(let v=0;v<f;v++){let E=u[v*2]*2-1,w=u[v*2+1]*2-1;if(p===0)Na.set(1,w,E);else if(p===1)Na.set(-E,1,-w);else if(p===2)Na.set(-E,w,1);else if(p===3)Na.set(-1,w,-E);else if(p===4)Na.set(-E,-1,w);else Na.set(E,w,-1);Na.toArray(m,(p*f+v)*h)}}let g=new Ln;if(g.setAttribute("position",new En(b,h)),g.setAttribute("outputDirection",new En(m,h)),n.push(new jt(g,null)),i>Vo)i--}return{lodMeshes:n,sizeLods:t}}function sA(e,t,n){let i=new li(e,t,n);return i.texture.mapping=Zc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zo(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function gD(e,t,n){return new Ei({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hD,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:Kd(),fragmentShader:`
+}`,Mr,Ym,$i,mr,$d,Qm,eg,tg,Kd,ng,rg,Aa,Wd,Ta,ig,wa,Ma,ks,ui,dT,Vi,fT,vl,Ao,ag,Vo,Go,Xd,Hp,sA,oA,xd,yd,ci,qd,fa,cA,lA,hn,hT,Jd,pT,Ho,Ls,mT,$o,$p,Zd,To=-90,wo=1,sg,og,lg="\\[\\]\\.:\\/",DP,ug,FP,UP,zP,BP,jP,VP,GP,HP,Yd,fg,Qd;var pg=ot(()=>{ma={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ga={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};SE={};oT={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};On=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],el=Math.PI/180,ws=180/Math.PI;ll={DEG2RAD:el,RAD2DEG:ws,generateUUID:zr,clamp:ut,euclideanModulo:Km,mapLinear:HN,inverseLerp:$N,lerp:tl,damp:KN,pingpong:WN,smoothstep:XN,smootherstep:qN,randInt:JN,randFloat:ZN,randFloatSpread:YN,seededRandom:QN,degToRad:eP,radToDeg:tP,isPowerOfTwo:nP,ceilPowerOfTwo:rP,floorPowerOfTwo:iP,setQuaternionFromProperEuler:aP,normalize:Nt,denormalize:Ur};We=class We{static{We.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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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=ut(this.x,e.x,t.x),this.y=ut(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ut(this.x,e,t),this.y=ut(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ut(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(ut(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),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ln=class ln{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,s){let o=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],h=i[a+2],b=i[a+3];if(u!==b||o!==d||c!==f||l!==h){let m=o*d+c*f+l*h+u*b;if(m<0)d=-d,f=-f,h=-h,b=-b,m=-m;let g=1-s;if(m<0.9995){let p=Math.acos(m),y=Math.sin(p);g=Math.sin(g*p)/y,s=Math.sin(s*p)/y,o=o*g+d*s,c=c*g+f*s,l=l*g+h*s,u=u*g+b*s}else{o=o*g+d*s,c=c*g+f*s,l=l*g+h*s,u=u*g+b*s;let p=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=p,c*=p,l*=p,u*=p}}e[t]=o,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let s=n[r],o=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],h=i[a+3];return e[t]=s*h+l*u+o*f-c*d,e[t+1]=o*h+l*d+c*u-s*f,e[t+2]=c*h+l*f+s*d-o*u,e[t+3]=l*h-s*u-o*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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:r,_z:i,_order:a}=e,{cos:s,sin:o}=Math,c=s(n/2),l=s(r/2),u=s(i/2),d=o(n/2),f=o(r/2),h=o(i/2);switch(a){case"XYZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"YXZ":this._x=d*l*u+c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"ZXY":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u-d*f*h;break;case"ZYX":this._x=d*l*u-c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u+d*f*h;break;case"YZX":this._x=d*l*u+c*f*h,this._y=c*f*u+d*l*h,this._z=c*l*h-d*f*u,this._w=c*l*u-d*f*h;break;case"XZY":this._x=d*l*u-c*f*h,this._y=c*f*u-d*l*h,this._z=c*l*h+d*f*u,this._w=c*l*u+d*f*h;break;default:Ve("Quaternion: .setFromEuler() encountered an unknown order: "+a)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],s=t[5],o=t[9],c=t[2],l=t[6],u=t[10],d=n+s+u;if(d>0){let f=0.5/Math.sqrt(d+1);this._w=0.25/f,this._x=(l-o)*f,this._y=(i-c)*f,this._z=(a-r)*f}else if(n>s&&n>u){let f=2*Math.sqrt(1+n-s-u);this._w=(l-o)/f,this._x=0.25*f,this._y=(r+a)/f,this._z=(i+c)/f}else if(s>u){let f=2*Math.sqrt(1+s-n-u);this._w=(i-c)/f,this._x=(r+a)/f,this._y=0.25*f,this._z=(o+l)/f}else{let f=2*Math.sqrt(1+u-n-s);this._w=(a-r)/f,this._x=(i+c)/f,this._y=(o+l)/f,this._z=0.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ut(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),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:r,_z:i,_w:a}=e,{_x:s,_y:o,_z:c,_w:l}=t;return this._x=n*l+a*s+r*c-i*o,this._y=r*l+a*o+i*s-n*c,this._z=i*l+a*c+n*o-r*s,this._w=a*l-n*s-r*o-i*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:r,_z:i,_w:a}=e,s=this.dot(e);if(s<0)n=-n,r=-r,i=-i,a=-a,s=-s;let o=1-t;if(s<0.9995){let c=Math.acos(s),l=Math.sin(c);o=Math.sin(o*c)/l,t=Math.sin(t*c)/l,this._x=this._x*o+n*t,this._y=this._y*o+r*t,this._z=this._z*o+i*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+r*t,this._z=this._z*o+i*t,this._w=this._w*o+a*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(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}};V=class V{static{V.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(IE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(IE.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,{x:i,y:a,z:s,w:o}=e,c=2*(a*r-s*n),l=2*(s*t-i*r),u=2*(i*n-a*t);return this.x=t+o*c+a*u-s*l,this.y=n+o*l+s*c-i*u,this.z=r+o*u+i*l-a*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,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,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=ut(this.x,e.x,t.x),this.y=ut(this.y,e.y,t.y),this.z=ut(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ut(this.x,e,t),this.y=ut(this.y,e,t),this.z=ut(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ut(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:r,z:i}=e,{x:a,y:s,z:o}=t;return this.x=r*o-i*s,this.y=i*a-n*o,this.z=n*s-r*a,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 Ep.copy(this).projectOnVector(e),this.sub(Ep)}reflect(e){return this.sub(Ep.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(ut(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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 r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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}};Ep=new V,IE=new ln;nt=class nt{static{nt.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,s,o,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,r,i,a,s,o,c)}set(e,t,n,r,i,a,s,o,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=s,l[3]=t,l[4]=i,l[5]=o,l[6]=n,l[7]=a,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,r=t.elements,i=this.elements,a=n[0],s=n[3],o=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],h=n[8],b=r[0],m=r[3],g=r[6],p=r[1],y=r[4],v=r[7],x=r[2],_=r[5],E=r[8];return i[0]=a*b+s*p+o*x,i[3]=a*m+s*y+o*_,i[6]=a*g+s*v+o*E,i[1]=c*b+l*p+u*x,i[4]=c*m+l*y+u*_,i[7]=c*g+l*v+u*E,i[2]=d*b+f*p+h*x,i[5]=d*m+f*y+h*_,i[8]=d*g+f*v+h*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],s=e[5],o=e[6],c=e[7],l=e[8];return t*a*l-t*s*c-n*i*l+n*s*o+r*i*c-r*a*o}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],s=e[5],o=e[6],c=e[7],l=e[8],u=l*a-s*c,d=s*o-l*i,f=c*i-a*o,h=t*u+n*d+r*f;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);let b=1/h;return e[0]=u*b,e[1]=(r*c-l*n)*b,e[2]=(s*n-r*a)*b,e[3]=d*b,e[4]=(l*t-r*o)*b,e[5]=(r*i-s*t)*b,e[6]=f*b,e[7]=(n*o-c*t)*b,e[8]=(a*t-n*i)*b,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,r,i,a,s){let o=Math.cos(i),c=Math.sin(i);return this.set(n*o,n*c,-n*(o*a+c*s)+a+e,-r*c,r*o,-r*(-c*a+o*s)+s+t,0,0,1),this}scale(e,t){return Ts("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ap.makeScale(e,t)),this}rotate(e){return Ts("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ap.makeRotation(-e)),this}translate(e,t){return Ts("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ap.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 r=0;r<9;r++)if(t[r]!==n[r])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)}};Ap=new nt,CE=new nt().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),NE=new nt().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);lt=sP();wp=new V;en=class en extends Gr{constructor(e=en.DEFAULT_IMAGE,t=en.DEFAULT_MAPPING,n=1001,r=1001,i=1006,a=1008,s=1023,o=1009,c=en.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:cP++}),this.uuid=zr(),this.name="",this.source=new ul(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=c,this.format=s,this.internalFormat=null,this.type=o,this.offset=new We(0,0),this.repeat=new We(1,1),this.center=new We(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new nt,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(wp).x}get height(){return this.source.getSize(wp).y}get depth(){return this.source.getSize(wp).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){Ve(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Ve(`Texture.setValues(): property '${t}' does not exist.`);continue}if(r&&n&&(r.isVector2&&n.isVector2))r.copy(n);else if(r&&n&&(r.isVector3&&n.isVector3))r.copy(n);else if(r&&n&&(r.isMatrix3&&n.isMatrix3))r.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++}};en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=300;en.DEFAULT_ANISOTROPY=1;Pt=class Pt{static{Pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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,r,i,a=0.01,s=0.1,o=e.elements,c=o[0],l=o[4],u=o[8],d=o[1],f=o[5],h=o[9],b=o[2],m=o[6],g=o[10];if(Math.abs(l-d)<0.01&&Math.abs(u-b)<0.01&&Math.abs(h-m)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+b)<0.1&&Math.abs(h+m)<0.1&&Math.abs(c+f+g-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let y=(c+1)/2,v=(f+1)/2,x=(g+1)/2,_=(l+d)/4,E=(u+b)/4,w=(h+m)/4;if(y>v&&y>x)if(y<0.01)n=0,r=0.707106781,i=0.707106781;else n=Math.sqrt(y),r=_/n,i=E/n;else if(v>x)if(v<0.01)n=0.707106781,r=0,i=0.707106781;else r=Math.sqrt(v),n=_/r,i=w/r;else if(x<0.01)n=0.707106781,r=0.707106781,i=0;else i=Math.sqrt(x),n=E/i,r=w/i;return this.set(n,r,i,t),this}let p=Math.sqrt((m-h)*(m-h)+(u-b)*(u-b)+(d-l)*(d-l));if(Math.abs(p)<0.001)p=1;return this.x=(m-h)/p,this.y=(u-b)/p,this.z=(d-l)/p,this.w=Math.acos((c+f+g-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=ut(this.x,e.x,t.x),this.y=ut(this.y,e.y,t.y),this.z=ut(this.z,e.z,t.z),this.w=ut(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ut(this.x,e,t),this.y=ut(this.y,e,t),this.z=ut(this.z,e,t),this.w=ut(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ut(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}};Xm=class Xm extends Gr{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Pt(0,0,e,t),this.scissorTest=!1,this.viewport=new Pt(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:n.depth},i=new en(r),a=n.count;for(let s=0;s<a;s++)this.textures[s]=i.clone(),this.textures[s].isRenderTargetTexture=!0,this.textures[s].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 r=0,i=this.textures.length;r<i;r++)if(this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0)this.textures[r].isArrayTexture=this.textures[r].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 r=Object.assign({},e.textures[t].image);this.textures[t].source=new ul(r)}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"})}};hr=class hr extends Xm{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}};Dd=class Dd extends en{constructor(e=null,t=1,n=1,r=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},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()}};qm=class qm extends en{constructor(e=null,t=1,n=1,r=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},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}};Ze=class Ze{static{Ze.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,s,o,c,l,u,d,f,h,b,m){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,r,i,a,s,o,c,l,u,d,f,h,b,m)}set(e,t,n,r,i,a,s,o,c,l,u,d,f,h,b,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=s,g[13]=o,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=h,g[11]=b,g[15]=m,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 Ze().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,r=1/ho.setFromMatrixColumn(e,0).length(),i=1/ho.setFromMatrixColumn(e,1).length(),a=1/ho.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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:r,z:i}=e,a=Math.cos(n),s=Math.sin(n),o=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order==="XYZ"){let d=a*l,f=a*u,h=s*l,b=s*u;t[0]=o*l,t[4]=-o*u,t[8]=c,t[1]=f+h*c,t[5]=d-b*c,t[9]=-s*o,t[2]=b-d*c,t[6]=h+f*c,t[10]=a*o}else if(e.order==="YXZ"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d+b*s,t[4]=h*s-f,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-s,t[2]=f*s-h,t[6]=b+d*s,t[10]=a*o}else if(e.order==="ZXY"){let d=o*l,f=o*u,h=c*l,b=c*u;t[0]=d-b*s,t[4]=-a*u,t[8]=h+f*s,t[1]=f+h*s,t[5]=a*l,t[9]=b-d*s,t[2]=-a*c,t[6]=s,t[10]=a*o}else if(e.order==="ZYX"){let d=a*l,f=a*u,h=s*l,b=s*u;t[0]=o*l,t[4]=h*c-f,t[8]=d*c+b,t[1]=o*u,t[5]=b*c+d,t[9]=f*c-h,t[2]=-c,t[6]=s*o,t[10]=a*o}else if(e.order==="YZX"){let d=a*o,f=a*c,h=s*o,b=s*c;t[0]=o*l,t[4]=b-d*u,t[8]=h*u+f,t[1]=u,t[5]=a*l,t[9]=-s*l,t[2]=-c*l,t[6]=f*u+h,t[10]=d-b*u}else if(e.order==="XZY"){let d=a*o,f=a*c,h=s*o,b=s*c;t[0]=o*l,t[4]=-u,t[8]=c*l,t[1]=d*u+b,t[5]=a*l,t[9]=f*u-h,t[2]=h*u-f,t[6]=s*l,t[10]=b*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lP,e,uP)}lookAt(e,t,n){let r=this.elements;if(ur.subVectors(e,t),ur.lengthSq()===0)ur.z=1;if(ur.normalize(),ca.crossVectors(n,ur),ca.lengthSq()===0){if(Math.abs(n.z)===1)ur.x+=0.0001;else ur.z+=0.0001;ur.normalize(),ca.crossVectors(n,ur)}return ca.normalize(),qu.crossVectors(ur,ca),r[0]=ca.x,r[4]=qu.x,r[8]=ur.x,r[1]=ca.y,r[5]=qu.y,r[9]=ur.y,r[2]=ca.z,r[6]=qu.z,r[10]=ur.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],s=n[4],o=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],h=n[2],b=n[6],m=n[10],g=n[14],p=n[3],y=n[7],v=n[11],x=n[15],_=r[0],E=r[4],w=r[8],A=r[12],T=r[1],N=r[5],M=r[9],R=r[13],k=r[2],C=r[6],U=r[10],D=r[14],P=r[3],K=r[7],z=r[11],W=r[15];return i[0]=a*_+s*T+o*k+c*P,i[4]=a*E+s*N+o*C+c*K,i[8]=a*w+s*M+o*U+c*z,i[12]=a*A+s*R+o*D+c*W,i[1]=l*_+u*T+d*k+f*P,i[5]=l*E+u*N+d*C+f*K,i[9]=l*w+u*M+d*U+f*z,i[13]=l*A+u*R+d*D+f*W,i[2]=h*_+b*T+m*k+g*P,i[6]=h*E+b*N+m*C+g*K,i[10]=h*w+b*M+m*U+g*z,i[14]=h*A+b*R+m*D+g*W,i[3]=p*_+y*T+v*k+x*P,i[7]=p*E+y*N+v*C+x*K,i[11]=p*w+y*M+v*U+x*z,i[15]=p*A+y*R+v*D+x*W,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],r=e[8],i=e[12],a=e[1],s=e[5],o=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],h=e[3],b=e[7],m=e[11],g=e[15],p=o*f-c*d,y=s*f-c*u,v=s*d-o*u,x=a*f-c*l,_=a*d-o*l,E=a*u-s*l;return t*(b*p-m*y+g*v)-n*(h*p-m*x+g*_)+r*(h*y-b*x+g*E)-i*(h*v-b*_+m*E)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],s=e[9],o=e[2],c=e[6],l=e[10];return t*(a*l-s*c)-n*(i*l-s*o)+r*(i*c-a*o)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;if(e.isVector3)r[12]=e.x,r[13]=e.y,r[14]=e.z;else r[12]=e,r[13]=t,r[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],s=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*s-n*a,y=t*o-r*a,v=t*c-i*a,x=n*o-r*s,_=n*c-i*s,E=r*c-i*o,w=l*b-u*h,A=l*m-d*h,T=l*g-f*h,N=u*m-d*b,M=u*g-f*b,R=d*g-f*m,k=p*R-y*M+v*N+x*T-_*A+E*w;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]=(s*R-o*M+c*N)*C,e[1]=(r*M-n*R-i*N)*C,e[2]=(b*E-m*_+g*x)*C,e[3]=(d*_-u*E-f*x)*C,e[4]=(o*T-a*R-c*A)*C,e[5]=(t*R-r*T+i*A)*C,e[6]=(m*v-h*E-g*y)*C,e[7]=(l*E-d*v+f*y)*C,e[8]=(a*M-s*T+c*w)*C,e[9]=(n*T-t*M-i*w)*C,e[10]=(h*_-b*v+g*p)*C,e[11]=(u*v-l*_-f*p)*C,e[12]=(s*A-a*N-o*w)*C,e[13]=(t*N-n*A+r*w)*C,e[14]=(b*y-h*x-m*p)*C,e[15]=(l*x-u*y+d*p)*C,this}scale(e){let t=this.elements,{x:n,y:r,z:i}=e;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}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),r=Math.sin(t),i=1-n,{x:a,y:s,z:o}=e,c=i*a,l=i*s;return this.set(c*a+n,c*s-r*o,c*o+r*s,0,c*s+r*o,l*s+n,l*o-r*a,0,c*o-r*s,l*o+r*a,i*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,{_x:i,_y:a,_z:s,_w:o}=t,c=i+i,l=a+a,u=s+s,d=i*c,f=i*l,h=i*u,b=a*l,m=a*u,g=s*u,p=o*c,y=o*l,v=o*u,{x,y:_,z:E}=n;return r[0]=(1-(b+g))*x,r[1]=(f+v)*x,r[2]=(h-y)*x,r[3]=0,r[4]=(f-v)*_,r[5]=(1-(d+g))*_,r[6]=(m+p)*_,r[7]=0,r[8]=(h+y)*E,r[9]=(m-p)*E,r[10]=(1-(d+b))*E,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=ho.set(r[0],r[1],r[2]).length(),s=ho.set(r[4],r[5],r[6]).length(),o=ho.set(r[8],r[9],r[10]).length();if(i<0)a=-a;Lr.copy(this);let c=1/a,l=1/s,u=1/o;return Lr.elements[0]*=c,Lr.elements[1]*=c,Lr.elements[2]*=c,Lr.elements[4]*=l,Lr.elements[5]*=l,Lr.elements[6]*=l,Lr.elements[8]*=u,Lr.elements[9]*=u,Lr.elements[10]*=u,t.setFromRotationMatrix(Lr),n.x=a,n.y=s,n.z=o,this}makePerspective(e,t,n,r,i,a,s=2000,o=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),h,b;if(o)h=i/(a-i),b=a*i/(a-i);else if(s===2000)h=-(a+i)/(a-i),b=-2*a*i/(a-i);else if(s===2001)h=-a/(a-i),b=-a*i/(a-i);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=h,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,s=2000,o=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),h,b;if(o)h=1/(a-i),b=a/(a-i);else if(s===2000)h=-2/(a-i),b=-(a+i)/(a-i);else if(s===2001)h=-1/(a-i),b=-i/(a-i);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=h,c[14]=b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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}};ho=new V,Lr=new Ze,lP=new V(0,0,0),uP=new V(1,1,1),ca=new V,qu=new V,ur=new V,PE=new Ze,OE=new ln;di=class di{constructor(e=0,t=0,n=0,r=di.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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 r=e.elements,i=r[0],a=r[4],s=r[8],o=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case"XYZ":if(this._y=Math.asin(ut(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-ut(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(s,f),this._z=Math.atan2(o,c);else this._y=Math.atan2(-u,i),this._z=0;break;case"ZXY":if(this._x=Math.asin(ut(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c);else this._y=0,this._z=Math.atan2(o,i);break;case"ZYX":if(this._y=Math.asin(-ut(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,f),this._z=Math.atan2(o,i);else this._x=0,this._z=Math.atan2(-a,c);break;case"YZX":if(this._z=Math.asin(ut(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i);else this._x=0,this._y=Math.atan2(s,f);break;case"XZY":if(this._z=Math.asin(-ut(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(s,i);else this._x=Math.atan2(-l,f),this._y=0;break;default:Ve("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return PE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(PE,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return OE.setFromEuler(this),this.setFromQuaternion(OE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};di.DEFAULT_ORDER="XYZ";kE=new V,po=new ln,Fi=new Ze,Ju=new V,Kc=new V,fP=new V,hP=new ln,LE=new V(1,0,0),DE=new V(0,1,0),FE=new V(0,0,1),UE={type:"added"},pP={type:"removed"},mo={type:"childadded",child:null},Mp={type:"childremoved",child:null};Lt=class Lt extends Gr{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:dP++}),this.uuid=zr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Lt.DEFAULT_UP.clone();let e=new V,t=new di,n=new ln,r=new V(1,1,1);function i(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(i),n._onChange(a),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:r},modelViewMatrix:{value:new Ze},normalMatrix:{value:new nt}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=Lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Fd,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 po.setFromAxisAngle(e,t),this.quaternion.multiply(po),this}rotateOnWorldAxis(e,t){return po.setFromAxisAngle(e,t),this.quaternion.premultiply(po),this}rotateX(e){return this.rotateOnAxis(LE,e)}rotateY(e){return this.rotateOnAxis(DE,e)}rotateZ(e){return this.rotateOnAxis(FE,e)}translateOnAxis(e,t){return kE.copy(e).applyQuaternion(this.quaternion),this.position.add(kE.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(LE,e)}translateY(e){return this.translateOnAxis(DE,e)}translateZ(e){return this.translateOnAxis(FE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ju.copy(e);else Ju.set(e,t,n);let r=this.parent;if(this.updateWorldMatrix(!0,!1),Kc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Fi.lookAt(Kc,Ju,this.up);else Fi.lookAt(Ju,Kc,this.up);if(this.quaternion.setFromRotationMatrix(Fi),r)Fi.extractRotation(r.matrixWorld),po.setFromRotationMatrix(Fi),this.quaternion.premultiply(po.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 Qe("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(UE),mo.child=e,this.dispatchEvent(mo),mo.child=null;else Qe("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(pP),Mp.child=e,this.dispatchEvent(Mp),Mp.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Fi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Fi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Fi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(UE),mo.child=e,this.dispatchEvent(mo),mo.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,r=this.children.length;n<r;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].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(Kc,e,fP),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kc,hP,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;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:r}=e,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}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,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null)r.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 i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].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 r={};if(r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)r.userData=this.userData;if(r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null)r.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)r.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)r.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map((s)=>({...s,boundingBox:s.boundingBox?s.boundingBox.toJSON():void 0,boundingSphere:s.boundingSphere?s.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map((s)=>({...s})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)r.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)r.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)r.boundingBox=this.boundingBox.toJSON()}function i(s,o){if(s[o.uuid]===void 0)s[o.uuid]=o.toJSON(e);return o.uuid}if(this.isScene){if(this.background){if(this.background.isColor)r.background=this.background.toJSON();else if(this.background.isTexture)r.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)r.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let s=this.geometry.parameters;if(s!==void 0&&s.shapes!==void 0){let o=s.shapes;if(Array.isArray(o))for(let c=0,l=o.length;c<l;c++){let u=o[c];i(e.shapes,u)}else i(e.shapes,o)}}if(this.isSkinnedMesh){if(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let s=[];for(let o=0,c=this.material.length;o<c;o++)s.push(i(e.materials,this.material[o]));r.material=s}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let s=0;s<this.children.length;s++)r.children.push(this.children[s].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let s=0;s<this.animations.length;s++){let o=this.animations[s];r.animations.push(i(e.animations,o))}}if(t){let s=a(e.geometries),o=a(e.materials),c=a(e.textures),l=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),h=a(e.nodes);if(s.length>0)n.geometries=s;if(o.length>0)n.materials=o;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(f.length>0)n.animations=f;if(h.length>0)n.nodes=h}return n.object=r,n;function a(s){let o=[];for(let c in s){let l=s[c];delete l.metadata,o.push(l)}return o}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let r=e.children[n];this.add(r.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Lt.DEFAULT_UP=new V(0,1,0);Lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;li=class li extends Lt{constructor(){super();this.isGroup=!0,this.type="Group"}};mP={type:"move"};cT={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},la={h:0,s:0,l:0},Zu={h:0,s:0,l:0};Je=class Je{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 r=e;if(r&&r.isColor)this.copy(r);else if(typeof r==="number")this.setHex(r);else if(typeof r==="string")this.setStyle(r)}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,lt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=lt.workingColorSpace){return this.r=e,this.g=t,this.b=n,lt.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=lt.workingColorSpace){if(e=Km(e,1),t=ut(t,0,1),n=ut(n,0,1),t===0)this.r=this.g=this.b=n;else{let i=n<=0.5?n*(1+t):n+t-n*t,a=2*n-i;this.r=Sp(a,i,e+0.3333333333333333),this.g=Sp(a,i,e),this.b=Sp(a,i,e-0.3333333333333333)}return lt.colorSpaceToWorking(this,r),this}setStyle(e,t="srgb"){function n(i){if(i===void 0)return;if(parseFloat(i)<1)Ve("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],s=r[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Ve("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=r[1],a=i.length;if(a===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);else if(a===6)return this.setHex(parseInt(i,16),t);else Ve("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=cT[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Ve("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=Mo(e.r),this.g=Mo(e.g),this.b=Mo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return lt.workingToColorSpace(kn.copy(this),e),Math.round(ut(kn.r*255,0,255))*65536+Math.round(ut(kn.g*255,0,255))*256+Math.round(ut(kn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=lt.workingColorSpace){lt.workingToColorSpace(kn.copy(this),t);let{r:n,g:r,b:i}=kn,a=Math.max(n,r,i),s=Math.min(n,r,i),o,c,l=(s+a)/2;if(s===a)o=0,c=0;else{let u=a-s;switch(c=l<=0.5?u/(a+s):u/(2-a-s),a){case n:o=(r-i)/u+(r<i?6:0);break;case r:o=(i-n)/u+2;break;case i:o=(n-r)/u+4;break}o/=6}return e.h=o,e.s=c,e.l=l,e}getRGB(e,t=lt.workingColorSpace){return lt.workingToColorSpace(kn.copy(this),t),e.r=kn.r,e.g=kn.g,e.b=kn.b,e}getStyle(e="srgb"){lt.workingToColorSpace(kn.copy(this),e);let{r:t,g:n,b:r}=kn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(la),this.setHSL(la.h+e,la.s+t,la.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(la),e.getHSL(Zu);let n=tl(la.h,Zu.h,t),r=tl(la.s,Zu.s,t),i=tl(la.l,Zu.l,t);return this.setHSL(n,r,i),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,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,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}};kn=new Je;Je.NAMES=cT;Uo=class Uo 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 di,this.environmentIntensity=1,this.environmentRotation=new di,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}};Dr=new V,Ui=new V,Rp=new V,zi=new V,go=new V,bo=new V,zE=new V,Ip=new V,Cp=new V,Np=new V,Pp=new Pt,Op=new Pt,kp=new Pt;Bi=[new V,new V,new V,new V,new V,new V,new V,new V],Fr=new V,Yu=new pn,xo=new V,yo=new V,_o=new V,ua=new V,da=new V,_s=new V,Wc=new V,Qu=new V,ed=new V,vs=new V;cn=new V,td=new We;En=class En extends Gr{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:gP++}),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 r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];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++)td.fromBufferAttribute(this,t),td.applyMatrix3(e),this.setXY(t,td.x,td.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Ur(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=Nt(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=Ur(t,this.array);return t}setX(e,t){if(this.normalized)t=Nt(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=Ur(t,this.array);return t}setY(e,t){if(this.normalized)t=Nt(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=Ur(t,this.array);return t}setZ(e,t){if(this.normalized)t=Nt(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=Ur(t,this.array);return t}setW(e,t){if(this.normalized)t=Nt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){if(e*=this.itemSize,this.normalized)t=Nt(t,this.array),n=Nt(n,this.array),r=Nt(r,this.array),i=Nt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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"})}};Ud=class Ud extends En{constructor(e,t,n){super(new Uint16Array(e),t,n)}};zd=class zd extends En{constructor(e,t,n){super(new Uint32Array(e),t,n)}};Jn=class Jn extends En{constructor(e,t,n){super(new Float32Array(e),t,n)}};bP=new pn,Xc=new V,Dp=new V;Er=new Ze,Fp=new Lt,vo=new V,dr=new pn,qc=new pn,vn=new V;Dn=class Dn extends Gr{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xP++}),this.uuid=zr(),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((VN(e))?zd:Ud)(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 i=new nt().getNormalMatrix(e);n.applyNormalMatrix(i),n.needsUpdate=!0}let r=this.attributes.tangent;if(r!==void 0)r.transformDirection(e),r.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Er.makeRotationFromQuaternion(e),this.applyMatrix4(Er),this}rotateX(e){return Er.makeRotationX(e),this.applyMatrix4(Er),this}rotateY(e){return Er.makeRotationY(e),this.applyMatrix4(Er),this}rotateZ(e){return Er.makeRotationZ(e),this.applyMatrix4(Er),this}translate(e,t,n){return Er.makeTranslation(e,t,n),this.applyMatrix4(Er),this}scale(e,t,n){return Er.makeScale(e,t,n),this.applyMatrix4(Er),this}lookAt(e){return Fp.lookAt(e),Fp.updateMatrix(),this.applyMatrix4(Fp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vo).negate(),this.translate(vo.x,vo.y,vo.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,i=e.length;r<i;r++){let a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Jn(n,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let i=e[r];t.setXYZ(r,i.x,i.y,i.z||0)}if(e.length>t.count)Ve("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 pn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){let i=t[n];if(dr.setFromBufferAttribute(i),this.morphTargetsRelative)vn.addVectors(this.boundingBox.min,dr.min),this.boundingBox.expandByPoint(vn),vn.addVectors(this.boundingBox.max,dr.max),this.boundingBox.expandByPoint(vn);else this.boundingBox.expandByPoint(dr.min),this.boundingBox.expandByPoint(dr.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))Qe('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 pr;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new V,1/0);return}if(e){let n=this.boundingSphere.center;if(dr.setFromBufferAttribute(e),t)for(let i=0,a=t.length;i<a;i++){let s=t[i];if(qc.setFromBufferAttribute(s),this.morphTargetsRelative)vn.addVectors(dr.min,qc.min),dr.expandByPoint(vn),vn.addVectors(dr.max,qc.max),dr.expandByPoint(vn);else dr.expandByPoint(qc.min),dr.expandByPoint(qc.max)}dr.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)vn.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(vn));if(t)for(let i=0,a=t.length;i<a;i++){let s=t[i],o=this.morphTargetsRelative;for(let c=0,l=s.count;c<l;c++){if(vn.fromBufferAttribute(s,c),o)vo.fromBufferAttribute(e,c),vn.add(vo);r=Math.max(r,n.distanceToSquared(vn))}}if(this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius))Qe('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){Qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:r,uv:i}=t,a=this.getAttribute("tangent");if(a===void 0||a.count!==n.count)a=new En(new Float32Array(4*n.count),4),this.setAttribute("tangent",a);let s=[],o=[];for(let w=0;w<n.count;w++)s[w]=new V,o[w]=new V;let c=new V,l=new V,u=new V,d=new We,f=new We,h=new We,b=new V,m=new V;function g(w,A,T){c.fromBufferAttribute(n,w),l.fromBufferAttribute(n,A),u.fromBufferAttribute(n,T),d.fromBufferAttribute(i,w),f.fromBufferAttribute(i,A),h.fromBufferAttribute(i,T),l.sub(c),u.sub(c),f.sub(d),h.sub(d);let N=1/(f.x*h.y-h.x*f.y);if(!isFinite(N))return;b.copy(l).multiplyScalar(h.y).addScaledVector(u,-f.y).multiplyScalar(N),m.copy(u).multiplyScalar(f.x).addScaledVector(l,-h.x).multiplyScalar(N),s[w].add(b),s[A].add(b),s[T].add(b),o[w].add(m),o[A].add(m),o[T].add(m)}let p=this.groups;if(p.length===0)p=[{start:0,count:e.count}];for(let w=0,A=p.length;w<A;++w){let T=p[w],{start:N,count:M}=T;for(let R=N,k=N+M;R<k;R+=3)g(e.getX(R+0),e.getX(R+1),e.getX(R+2))}let y=new V,v=new V,x=new V,_=new V;function E(w){x.fromBufferAttribute(r,w),_.copy(x);let A=s[w];y.copy(A),y.sub(x.multiplyScalar(x.dot(A))).normalize(),v.crossVectors(_,A);let N=v.dot(o[w])<0?-1:1;a.setXYZW(w,y.x,y.y,y.z,N)}for(let w=0,A=p.length;w<A;++w){let T=p[w],{start:N,count:M}=T;for(let R=N,k=N+M;R<k;R+=3)E(e.getX(R+0)),E(e.getX(R+1)),E(e.getX(R+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 En(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let r=new V,i=new V,a=new V,s=new V,o=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let h=e.getX(d+0),b=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,h),i.fromBufferAttribute(t,b),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),s.fromBufferAttribute(n,h),o.fromBufferAttribute(n,b),c.fromBufferAttribute(n,m),s.add(l),o.add(l),c.add(l),n.setXYZ(h,s.x,s.y,s.z),n.setXYZ(b,o.x,o.y,o.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)r.fromBufferAttribute(t,d+0),i.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)vn.fromBufferAttribute(e,t),vn.normalize(),e.setXYZ(t,vn.x,vn.y,vn.z)}toNonIndexed(){function e(s,o){let{array:c,itemSize:l,normalized:u}=s,d=new c.constructor(o.length*l),f=0,h=0;for(let b=0,m=o.length;b<m;b++){if(s.isInterleavedBufferAttribute)f=o[b]*s.data.stride+s.offset;else f=o[b]*l;for(let g=0;g<l;g++)d[h++]=c[f++]}return new En(d,l,u)}if(this.index===null)return Ve("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Dn,n=this.index.array,r=this.attributes;for(let s in r){let o=r[s],c=e(o,n);t.setAttribute(s,c)}let i=this.morphAttributes;for(let s in i){let o=[],c=i[s];for(let l=0,u=c.length;l<u;l++){let d=c[l],f=e(d,n);o.push(f)}t.morphAttributes[s]=o}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let s=0,o=a.length;s<o;s++){let c=a[s];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let o=this.parameters;for(let c in o)if(o[c]!==void 0)e[c]=o[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let o in n){let c=n[o];e.data.attributes[o]=c.toJSON(e.data)}let r={},i=!1;for(let o in this.morphAttributes){let c=this.morphAttributes[o],l=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];l.push(f.toJSON(e.data))}if(l.length>0)r[o]=l,i=!0}if(i)e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;if(a.length>0)e.data.groups=JSON.parse(JSON.stringify(a));let s=this.boundingSphere;if(s!==null)e.data.boundingSphere=s.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 r=e.attributes;for(let c in r){let l=r[c];this.setAttribute(c,l.clone(t))}let i=e.morphAttributes;for(let c in i){let l=[],u=i[c];for(let d=0,f=u.length;d<f;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let c=0,l=a.length;c<l;c++){let u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}let s=e.boundingBox;if(s!==null)this.boundingBox=s.clone();let o=e.boundingSphere;if(o!==null)this.boundingSphere=o.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};$n=new V;Up=new V,yP=new V,_P=new nt;Zn=class Zn extends Gr{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:vP++}),this.uuid=zr(),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 Je(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){Ve(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Ve(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(r&&r.isColor)r.set(n);else if(r&&r.isVector2&&(n&&n.isVector2)||r&&r.isEuler&&(n&&n.isEuler)||r&&r.isVector3&&(n&&n.isVector3))r.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((i)=>i.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 r(i){let a=[];for(let s in i){let o=i[s];delete o.metadata,a.push(o)}return a}if(t){let i=r(e.textures),a=r(e.images);if(i.length>0)n.textures=i;if(a.length>0)n.images=a}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 Je().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 Ar().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 We().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 We().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 r=t.length;n=Array(r);for(let i=0;i!==r;++i)n[i]=t[i].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++}};ji=new V,zp=new V,nd=new V,rd=new V;gi=class gi extends Zn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new di,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};BE=new Ze,Es=new _a,id=new pr,jE=new V,ad=new V,sd=new V,od=new V,Bp=new V,cd=new V,VE=new V,ld=new V;Gt=class Gt extends Lt{constructor(e=new Dn,t=new gi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,a=r.length;i<a;i++){let s=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=i}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let s=this.morphTargetInfluences;if(i&&s){cd.set(0,0,0);for(let o=0,c=i.length;o<c;o++){let l=s[o],u=i[o];if(l===0)continue;if(Bp.fromBufferAttribute(u,e),a)cd.addScaledVector(Bp,l);else cd.addScaledVector(Bp.sub(t),l)}t.add(cd)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;if(r===void 0)return;if(n.boundingSphere===null)n.computeBoundingSphere();if(id.copy(n.boundingSphere),id.applyMatrix4(i),Es.copy(e.ray).recast(e.near),id.containsPoint(Es.origin)===!1){if(Es.intersectSphere(id,jE)===null)return;if(Es.origin.distanceToSquared(jE)>(e.far-e.near)**2)return}if(BE.copy(i).invert(),Es.copy(e.ray).applyMatrix4(BE),n.boundingBox!==null){if(Es.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Es)}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,s=i.index,o=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,{groups:d,drawRange:f}=i;if(s!==null)if(Array.isArray(a))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=a[m.materialIndex],p=Math.max(m.start,f.start),y=Math.min(s.count,Math.min(m.start+m.count,f.start+f.count));for(let v=p,x=y;v<x;v+=3){let _=s.getX(v),E=s.getX(v+1),w=s.getX(v+2);if(r=ud(this,g,e,n,c,l,u,_,E,w),r)r.faceIndex=Math.floor(v/3),r.face.materialIndex=m.materialIndex,t.push(r)}}else{let h=Math.max(0,f.start),b=Math.min(s.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=s.getX(m),y=s.getX(m+1),v=s.getX(m+2);if(r=ud(this,a,e,n,c,l,u,p,y,v),r)r.faceIndex=Math.floor(m/3),t.push(r)}}else if(o!==void 0)if(Array.isArray(a))for(let h=0,b=d.length;h<b;h++){let m=d[h],g=a[m.materialIndex],p=Math.max(m.start,f.start),y=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let v=p,x=y;v<x;v+=3){let _=v,E=v+1,w=v+2;if(r=ud(this,g,e,n,c,l,u,_,E,w),r)r.faceIndex=Math.floor(v/3),r.face.materialIndex=m.materialIndex,t.push(r)}}else{let h=Math.max(0,f.start),b=Math.min(o.count,f.start+f.count);for(let m=h,g=b;m<g;m+=3){let p=m,y=m+1,v=m+2;if(r=ud(this,a,e,n,c,l,u,p,y,v),r)r.faceIndex=Math.floor(m/3),t.push(r)}}}};Jc=new Pt,GE=new Pt,HE=new Pt,AP=new Pt,$E=new Ze,dd=new V,jp=new pr,KE=new Ze,Vp=new _a;Bd=class Bd extends Gt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new pn;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,dd),this.boundingBox.expandByPoint(dd)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new pr;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,dd),this.boundingSphere.expandByPoint(dd)}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,r=this.matrixWorld;if(n===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(jp.copy(this.boundingSphere),jp.applyMatrix4(r),e.ray.intersectsSphere(jp)===!1)return;if(KE.copy(r).invert(),Vp.copy(e.ray).applyMatrix4(KE),this.boundingBox!==null){if(Vp.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Vp)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Pt,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let i=1/e.manhattanLength();if(i!==1/0)e.multiplyScalar(i);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 Ve("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;if(GE.fromBufferAttribute(r.attributes.skinIndex,e),HE.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4)Jc.copy(t),t.set(0,0,0,0);else Jc.set(...t,1),t.set(0,0,0);Jc.applyMatrix4(this.bindMatrix);for(let i=0;i<4;i++){let a=HE.getComponent(i);if(a!==0){let s=GE.getComponent(i);$E.multiplyMatrices(n.bones[s].matrixWorld,n.boneInverses[s]),t.addScaledVector(AP.copy(Jc).applyMatrix4($E),a)}}if(t.isVector4)t.w=Jc.w;return t.applyMatrix4(this.bindMatrixInverse)}};hl=class hl extends Lt{constructor(){super();this.isBone=!0,this.type="Bone"}};pl=class pl extends en{constructor(e=null,t=1,n=1,r,i,a,s,o,c=1003,l=1003,u,d){super(null,a,s,o,c,l,r,i,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};WE=new Ze,TP=new Ze;pa=class pa extends En{constructor(e,t,n,r=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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}};Eo=new Ze,XE=new Ze,fd=[],qE=new pn,wP=new Ze,Zc=new Gt,Yc=new pr;Bo=class Bo extends Gt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new pa(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,wP)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new pn;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Eo),qE.copy(e.boundingBox).applyMatrix4(Eo),this.boundingBox.union(qE)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new pr;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Eo),Yc.copy(e.boundingSphere).applyMatrix4(Eo),this.boundingSphere.union(Yc)}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,r=this.morphTexture.source.data.data,i=n.length+1,a=e*i+1;for(let s=0;s<n.length;s++)n[s]=r[a+s]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(Zc.geometry=this.geometry,Zc.material=this.material,Zc.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(Yc.copy(this.boundingSphere),Yc.applyMatrix4(n),e.ray.intersectsSphere(Yc)===!1)return;for(let i=0;i<r;i++){this.getMatrixAt(i,Eo),XE.multiplyMatrices(n,Eo),Zc.matrixWorld=XE,Zc.raycast(e,fd);for(let a=0,s=fd.length;a<s;a++){let o=fd[a];o.instanceId=i,o.object=this,t.push(o)}fd.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new pa(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,r=n.length+1;if(this.morphTexture===null)this.morphTexture=new pl(new Float32Array(r*this.count),r,this.count,1028,1015);let i=this.morphTexture.source.data.data,a=0;for(let c=0;c<n.length;c++)a+=n[c];let s=this.geometry.morphTargetsRelative?1:1-a,o=r*e;return i[o]=s,i.set(n,o+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}};As=new pr,MP=new We(0.5,0.5),hd=new V;bl=class bl extends Zn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Je(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}};vd=new V,Ed=new V,JE=new Ze,Qc=new _a,pd=new pr,Gp=new V,ZE=new V;va=class va extends Lt{constructor(e=new Dn,t=new bl){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 r=1,i=t.count;r<i;r++)vd.fromBufferAttribute(t,r-1),Ed.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=vd.distanceTo(Ed);e.setAttribute("lineDistance",new Jn(n,1))}else Ve("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(pd.copy(n.boundingSphere),pd.applyMatrix4(r),pd.radius+=i,e.ray.intersectsSphere(pd)===!1)return;JE.copy(r).invert(),Qc.copy(e.ray).applyMatrix4(JE);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let f=Math.max(0,a.start),h=Math.min(l.count,a.start+a.count);for(let b=f,m=h-1;b<m;b+=c){let g=l.getX(b),p=l.getX(b+1),y=md(this,e,Qc,o,g,p,b);if(y)t.push(y)}if(this.isLineLoop){let b=l.getX(h-1),m=l.getX(f),g=md(this,e,Qc,o,b,m,h-1);if(g)t.push(g)}}else{let f=Math.max(0,a.start),h=Math.min(d.count,a.start+a.count);for(let b=f,m=h-1;b<m;b+=c){let g=md(this,e,Qc,o,b,b+1,b);if(g)t.push(g)}if(this.isLineLoop){let b=md(this,e,Qc,o,h-1,f,h-1);if(b)t.push(b)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,a=r.length;i<a;i++){let s=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=i}}}}};YE=new V,QE=new V;jd=class jd extends va{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 r=0,i=t.count;r<i;r+=2)YE.fromBufferAttribute(t,r),QE.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+YE.distanceTo(QE);e.setAttribute("lineDistance",new Jn(n,1))}else Ve("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};Vd=class Vd extends va{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}};xl=class xl extends Zn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Je(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}};eA=new Ze,Kp=new _a,gd=new pr,bd=new V;jo=class jo extends Lt{constructor(e=new Dn,t=new xl){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,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(gd.copy(n.boundingSphere),gd.applyMatrix4(r),gd.radius+=i,e.ray.intersectsSphere(gd)===!1)return;eA.copy(r).invert(),Kp.copy(e.ray).applyMatrix4(eA);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let h=d,b=f;h<b;h++){let m=c.getX(h);bd.fromBufferAttribute(u,m),tA(bd,m,o,r,e,t,this)}}else{let d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let h=d,b=f;h<b;h++)bd.fromBufferAttribute(u,h),tA(bd,h,o,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let i=0,a=r.length;i<a;i++){let s=r[i].name||String(i);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=i}}}}};Gd=class Gd extends en{constructor(e=[],t=301,n,r,i,a,s,o,c,l){super(e,t,n,r,i,a,s,o,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};Ps=class Ps extends en{constructor(e,t,n=1014,r,i,a,s=1003,o=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,r,i,a,s,o,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ul(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}};Jm=class Jm extends Ps{constructor(e,t=1014,n=301,r,i,a=1003,s=1003,o,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,s,o,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}};Hd=class Hd extends en{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}};Ea=class Ea extends Dn{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let s=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let o=[],c=[],l=[],u=[],d=0,f=0;h("z","y","x",-1,-1,n,t,e,a,i,0),h("z","y","x",1,-1,n,t,-e,a,i,1),h("x","z","y",1,1,e,n,t,r,a,2),h("x","z","y",1,-1,e,n,-t,r,a,3),h("x","y","z",1,-1,e,t,n,r,i,4),h("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(o),this.setAttribute("position",new Jn(c,3)),this.setAttribute("normal",new Jn(l,3)),this.setAttribute("uv",new Jn(u,2));function h(b,m,g,p,y,v,x,_,E,w,A){let T=v/E,N=x/w,M=v/2,R=x/2,k=_/2,C=E+1,U=w+1,D=0,P=0,K=new V;for(let z=0;z<U;z++){let W=z*N-R;for(let q=0;q<C;q++){let le=q*T-M;K[b]=le*p,K[m]=W*y,K[g]=k,c.push(K.x,K.y,K.z),K[b]=0,K[m]=0,K[g]=_>0?1:-1,l.push(K.x,K.y,K.z),u.push(q/E),u.push(1-z/w),D+=1}}for(let z=0;z<w;z++)for(let W=0;W<E;W++){let q=d+W+C*z,le=d+W+C*(z+1),he=d+(W+1)+C*(z+1),xe=d+(W+1)+C*z;o.push(q,le,xe),o.push(le,he,xe),P+=6}s.addGroup(f,P,A),f+=P,d+=D}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ea(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};yl=class yl extends Dn{constructor(e=1,t=1,n=1,r=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,s=Math.floor(n),o=Math.floor(r),c=s+1,l=o+1,u=e/s,d=t/o,f=[],h=[],b=[],m=[];for(let g=0;g<l;g++){let p=g*d-a;for(let y=0;y<c;y++){let v=y*u-i;h.push(v,-p,0),b.push(0,0,1),m.push(y/s),m.push(1-g/o)}}for(let g=0;g<o;g++)for(let p=0;p<s;p++){let y=p+c*g,v=p+c*(g+1),x=p+1+c*(g+1),_=p+1+c*g;f.push(y,v,_),f.push(v,x,_)}this.setIndex(f),this.setAttribute("position",new Jn(h,3)),this.setAttribute("normal",new Jn(b,3)),this.setAttribute("uv",new Jn(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yl(e.width,e.height,e.widthSegments,e.heightSegments)}};lT={clone:Os,merge:Fn};Mr=class Mr extends Zn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=RP,this.fragmentShader=IP,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=Os(e.uniforms),this.uniformsGroups=SP(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 r in this.uniforms){let a=this.uniforms[r].value;if(a&&a.isTexture)t.uniforms[r]={type:"t",value:a.toJSON(e).uuid};else if(a&&a.isColor)t.uniforms[r]={type:"c",value:a.getHex()};else if(a&&a.isVector2)t.uniforms[r]={type:"v2",value:a.toArray()};else if(a&&a.isVector3)t.uniforms[r]={type:"v3",value:a.toArray()};else if(a&&a.isVector4)t.uniforms[r]={type:"v4",value:a.toArray()};else if(a&&a.isMatrix3)t.uniforms[r]={type:"m3",value:a.toArray()};else if(a&&a.isMatrix4)t.uniforms[r]={type:"m4",value:a.toArray()};else t.uniforms[r]={value:a}}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 r in this.extensions)if(this.extensions[r]===!0)n[r]=!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 r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new Je().setHex(r.value);break;case"v2":this.uniforms[n].value=new We().fromArray(r.value);break;case"v3":this.uniforms[n].value=new V().fromArray(r.value);break;case"v4":this.uniforms[n].value=new Pt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new nt().fromArray(r.value);break;case"m4":this.uniforms[n].value=new Ze().fromArray(r.value);break;default:this.uniforms[n].value=r.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}};Ym=class Ym extends Mr{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};$i=class $i extends Zn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Je(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 Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new di,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};mr=class mr extends $i{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new We(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ut(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 Je(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 Je(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Je(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}};$d=class $d extends Zn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Je(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Je(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new di,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};Qm=class Qm extends Zn{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}};eg=class eg extends Zn{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}};tg=class tg extends Ki{constructor(e,t,n,r){super(e,t,n,r);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,s=r[i],o=r[a];if(s===void 0)switch(this.getSettings_().endingStart){case 2401:i=e,s=2*t-n;break;case 2402:i=r.length-2,s=t+r[i]-r[i+1];break;default:i=e,s=n}if(o===void 0)switch(this.getSettings_().endingEnd){case 2401:a=e,o=2*n-t;break;case 2402:a=1,o=n+r[1]-r[0];break;default:a=e-1,o=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-s),this._weightNext=c/(o-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,c=o-s,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(r-t),b=h*h,m=b*h,g=-d*m+2*d*b-d*h,p=(1+d)*m+(-1.5-2*d)*b+(-0.5+d)*h+1,y=(-1-f)*m+(1.5+f)*b+0.5*h,v=f*m-f*b;for(let x=0;x!==s;++x)i[x]=g*a[l+x]+p*a[c+x]+y*a[o+x]+v*a[u+x];return i}};Kd=class Kd extends Ki{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,c=o-s,l=(n-t)/(r-t),u=1-l;for(let d=0;d!==s;++d)i[d]=a[c+d]*u+a[o+d]*l;return i}};ng=class ng extends Ki{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}};rg=class rg extends Ki{interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,c=o-s,l=this.inTangents,u=this.outTangents;if(!l||!u){let h=(n-t)/(r-t),b=1-h;for(let m=0;m!==s;++m)i[m]=a[c+m]*b+a[o+m]*h;return i}let d=s*2,f=e-1;for(let h=0;h!==s;++h){let b=a[c+h],m=a[o+h],g=f*d+h*2,p=u[g],y=u[g+1],v=e*d+h*2,x=l[v],_=l[v+1],E=OP(n,t,p,x,r);i[h]=uT(E,b,y,_,m)}return i}};gr.prototype.ValueTypeName="";gr.prototype.TimeBufferType=Float32Array;gr.prototype.ValueBufferType=Float32Array;gr.prototype.DefaultInterpolation=2301;Aa=class Aa extends gr{constructor(e,t,n){super(e,t,n)}};Aa.prototype.ValueTypeName="bool";Aa.prototype.ValueBufferType=Array;Aa.prototype.DefaultInterpolation=2300;Aa.prototype.InterpolantFactoryMethodLinear=void 0;Aa.prototype.InterpolantFactoryMethodSmooth=void 0;Wd=class Wd extends gr{constructor(e,t,n,r){super(e,t,n,r)}};Wd.prototype.ValueTypeName="color";Ta=class Ta extends gr{constructor(e,t,n,r){super(e,t,n,r)}};Ta.prototype.ValueTypeName="number";ig=class ig extends Ki{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(r-t),c=e*s;for(let l=c+s;c!==l;c+=4)ln.slerpFlat(i,0,a,c-s,a,c,o);return i}};wa=class wa extends gr{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new ig(this.times,this.values,this.getValueSize(),e)}};wa.prototype.ValueTypeName="quaternion";wa.prototype.InterpolantFactoryMethodSmooth=void 0;Ma=class Ma extends gr{constructor(e,t,n){super(e,t,n)}};Ma.prototype.ValueTypeName="string";Ma.prototype.ValueBufferType=Array;Ma.prototype.DefaultInterpolation=2300;Ma.prototype.InterpolantFactoryMethodLinear=void 0;Ma.prototype.InterpolantFactoryMethodSmooth=void 0;ks=class ks extends gr{constructor(e,t,n,r){super(e,t,n,r)}};ks.prototype.ValueTypeName="vector";ui={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(aA(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(aA(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};dT=new _l;Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";Vi={};fT=class fT extends Error{constructor(e,t){super(e);this.response=t}};vl=class vl extends Wi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,r){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let i=ui.get(`file:${e}`);if(i!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(i);this.manager.itemEnd(e)},0);return}if(Vi[e]!==void 0){Vi[e].push({onLoad:t,onProgress:n,onError:r});return}Vi[e]=[],Vi[e].push({onLoad:t,onProgress:n,onError:r});let a=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}),s=this.mimeType,o=this.responseType;fetch(a).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Ve("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Vi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,h=f!==0,b=0,m=new ReadableStream({start(g){p();function p(){u.read().then(({done:y,value:v})=>{if(y)g.close();else{b+=v.byteLength;let x=new ProgressEvent("progress",{lengthComputable:h,loaded:b,total:f});for(let _=0,E=l.length;_<E;_++){let w=l[_];if(w.onProgress)w.onProgress(x)}g.enqueue(v),p()}},(y)=>{g.error(y)})}}});return new Response(m)}else throw new fT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(o){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,s));case"json":return c.json();default:if(s==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(s),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then((h)=>f.decode(h))}}}).then((c)=>{ui.add(`file:${e}`,c);let l=Vi[e];delete Vi[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onLoad)f.onLoad(c)}}).catch((c)=>{let l=Vi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Vi[e];for(let u=0,d=l.length;u<d;u++){let f=l[u];if(f.onError)f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};Ao=new WeakMap;ag=class ag extends Wi{constructor(e){super(e)}load(e,t,n,r){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let i=this,a=ui.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)i.manager.itemStart(e),setTimeout(function(){if(t)t(a);i.manager.itemEnd(e)},0);else{let u=Ao.get(a);if(u===void 0)u=[],Ao.set(a,u);u.push({onLoad:t,onError:r})}return a}let s=So("img");function o(){if(l(),t)t(this);let u=Ao.get(this)||[];for(let d=0;d<u.length;d++){let f=u[d];if(f.onLoad)f.onLoad(this)}Ao.delete(this),i.manager.itemEnd(e)}function c(u){if(l(),r)r(u);ui.remove(`image:${e}`);let d=Ao.get(this)||[];for(let f=0;f<d.length;f++){let h=d[f];if(h.onError)h.onError(u)}Ao.delete(this),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){s.removeEventListener("load",o,!1),s.removeEventListener("error",c,!1)}if(s.addEventListener("load",o,!1),s.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)s.crossOrigin=this.crossOrigin}return ui.add(`image:${e}`,s),i.manager.itemStart(e),s.src=e,s}};Vo=class Vo extends Wi{constructor(e){super(e)}load(e,t,n,r){let i=new en,a=new ag(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(s){if(i.image=s,i.needsUpdate=!0,t!==void 0)t(i)},n,r),i}};Go=class Go extends Lt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new Je(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}};Xd=class Xd extends Go{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Lt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Je(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}};Hp=new Ze,sA=new V,oA=new V;xd=new V,yd=new ln,ci=new V;qd=class qd extends Lt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,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(xd,yd,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(xd,yd,ci.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(xd,yd,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(xd,yd,ci.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}};fa=new V,cA=new We,lA=new We;hn=class hn extends qd{constructor(e=50,t=1,n=0.1,r=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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=ws*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(el*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return ws*2*Math.atan(Math.tan(el*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){fa.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(fa.x,fa.y).multiplyScalar(-e/fa.z),fa.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(fa.x,fa.y).multiplyScalar(-e/fa.z)}getViewSize(e,t){return this.getViewBounds(e,cA,lA),t.subVectors(lA,cA)}setViewOffset(e,t,n,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){if(this.view!==null)this.view.enabled=!1;this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(el*0.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-0.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let{fullWidth:o,fullHeight:c}=a;i+=a.offsetX*r/o,t-=a.offsetY*n/c,r*=a.width/o,n*=a.height/c}let s=this.filmOffset;if(s!==0)i+=e*s/this.getFilmWidth();this.projectionMatrix.makePerspective(i,i+r,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}};hT=class hT extends El{constructor(){super(new hn(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=ws*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,i=e.distance||t.far;if(n!==t.fov||r!==t.aspect||i!==t.far)t.fov=n,t.aspect=r,t.far=i,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}};Jd=class Jd extends Go{constructor(e,t,n=0,r=Math.PI/3,i=0,a=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=r,this.penumbra=i,this.decay=a,this.map=null,this.shadow=new hT}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);if(t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture)t.object.map=this.map.toJSON(e).uuid;return t.object.shadow=this.shadow.toJSON(),t}};pT=class pT extends El{constructor(){super(new hn(90,1,0.5,500));this.isPointLightShadow=!0}};Ho=class Ho extends Go{constructor(e,t,n=0,r=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new pT}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}};Ls=class Ls extends qd{constructor(e=-1,t=1,n=1,r=-1,i=0.1,a=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=r,this.near=i,this.far=a,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,r,i,a){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=r,this.view.width=i,this.view.height=a,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,r=(this.top+this.bottom)/2,i=n-e,a=n+e,s=r+t,o=r-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;i+=c*this.view.offsetX,a=i+c*this.view.width,s-=l*this.view.offsetY,o=s-l*this.view.height}this.projectionMatrix.makeOrthographic(i,a,s,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);if(t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null)t.object.view=Object.assign({},this.view);return t}};mT=class mT extends El{constructor(){super(new Ls(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}};$o=class $o extends Go{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 mT}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}};$p=new WeakMap;Zd=class Zd extends Wi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Ve("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Ve("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let i=this,a=ui.get(`image-bitmap:${e}`);if(a!==void 0){if(i.manager.itemStart(e),a.then){a.then((c)=>{if($p.has(a)===!0){if(r)r($p.get(a));i.manager.itemError(e),i.manager.itemEnd(e)}else{if(t)t(c);i.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(a);i.manager.itemEnd(e)},0);return}let s={};s.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",s.headers=this.requestHeader,s.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,s).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},i.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ui.add(`image-bitmap:${e}`,c),t)t(c);return i.manager.itemEnd(e),c}).catch(function(c){if(r)r(c);$p.set(o,c),ui.remove(`image-bitmap:${e}`),i.manager.itemError(e),i.manager.itemEnd(e)});ui.add(`image-bitmap:${e}`,o),i.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};sg=class sg extends Lt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new hn(To,wo,e,t);r.layers=this.layers,this.add(r);let i=new hn(To,wo,e,t);i.layers=this.layers,this.add(i);let a=new hn(To,wo,e,t);a.layers=this.layers,this.add(a);let s=new hn(To,wo,e,t);s.layers=this.layers,this.add(s);let o=new hn(To,wo,e,t);o.layers=this.layers,this.add(o);let c=new hn(To,wo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,s,o]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[i,a,s,o,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),h=e.xr.enabled;e.xr.enabled=!1;let b=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;if(e.isWebGLRenderer===!0)m=e.state.buffers.depth.getReversed();else m=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,r),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,i),e.setRenderTarget(n,1,r),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,2,r),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,3,r),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,4,r),m&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=b,e.setRenderTarget(n,5,r),m&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}};og=class og extends hn{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};DP=new RegExp("["+lg+"]","g"),ug="[^"+lg+"]",FP="[^"+lg.replace("\\.","")+"]",UP=/((?:WC+[\/:])*)/.source.replace("WC",ug),zP=/(WCOD+)?/.source.replace("WCOD",FP),BP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ug),jP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ug),VP=new RegExp("^"+UP+zP+BP+jP+"$"),GP=["material","materials","bones","map"];At.Composite=gT;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];HP=new Float32Array(1);Yd=class Yd extends Gr{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,r=e._clip.tracks,i=r.length,{_propertyBindings:a,_interpolants:s}=e,o=n.uuid,c=this._bindingsByRootAndName,l=c[o];if(l===void 0)l={},c[o]=l;for(let u=0;u!==i;++u){let d=r[u],f=d.name,h=l[f];if(h!==void 0)++h.referenceCount,a[u]=h;else{if(h=a[u],h!==void 0){if(h._cacheIndex===null)++h.referenceCount,this._addInactiveBinding(h,o,f);continue}let b=t&&t._propertyBindings[u].binding.parsedPath;h=new cg(At.create(n,f,b),d.ValueTypeName,d.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,f),a[u]=h}s[u].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,r=e._clip.uuid,i=this._actionsByClip[r];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,r,n)}let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let i=t[n];if(i.useCount++===0)this._lendBinding(i),i.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let i=t[n];if(--i.useCount===0)i.restoreOriginalState(),this._takeBackBinding(i)}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 r=this._actions,i=this._actionsByClip,a=i[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=a;else{let s=a.knownActions;e._byClipCacheIndex=s.length,s.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let i=e._clip.uuid,a=this._actionsByClip,s=a[i],o=s.knownActions,c=o[o.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,o[l]=c,o.pop(),e._byClipCacheIndex=null;let u=s.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],o.length===0)delete a[i];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let i=t[n];if(--i.referenceCount===0)this._removeInactiveBinding(i)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,i=this._bindings,a=r[t];if(a===void 0)a={},r[t]=a;a[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,a=this._bindingsByRootAndName,s=a[r],o=t[t.length-1],c=e._cacheIndex;if(o._cacheIndex=c,t[c]=o,t.pop(),delete s[i],Object.keys(s).length===0)delete a[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Kd(new Float32Array(2),new Float32Array(2),1,HP),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){let r=t||this._root,i=r.uuid,a=typeof e==="string"?Io.findByName(r,e):e,s=a!==null?a.uuid:e,o=this._actionsByClip[s],c=null;if(n===void 0)if(a!==null)n=a.blendMode;else n=2500;if(o!==void 0){let u=o.actionByRoot[i];if(u!==void 0&&u.blendMode===n)return u;if(c=o.knownActions[0],a===null)a=c._clip}if(a===null)return null;let l=new dg(this,a,t,n);return this._bindAction(l,c),this._addInactiveAction(l,s,i),l}existingAction(e,t){let n=t||this._root,r=n.uuid,i=typeof e==="string"?Io.findByName(n,e):e,a=i?i.uuid:e,s=this._actionsByClip[a];if(s!==void 0)return s.actionByRoot[r]||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,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(r,e,i,a);let s=this._bindings,o=this._nActiveBindings;for(let c=0;c!==o;++c)s[c].apply(a);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,r=this._actionsByClip,i=r[n];if(i!==void 0){let a=i.knownActions;for(let s=0,o=a.length;s!==o;++s){let c=a[s];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 r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let a in n){let s=n[a].actionByRoot,o=s[t];if(o!==void 0)this._deactivateAction(o),this._removeInactiveAction(o)}let r=this._bindingsByRootAndName,i=r[t];if(i!==void 0)for(let a in i){let s=i[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}};fg=class fg{static{fg.prototype.isMatrix2=!0}constructor(e,t,n,r){if(this.elements=[1,0,0,1],e!==void 0)this.set(e,t,n,r)}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,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};Qd=class Qd extends Gr{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}};if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Ve("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186"});function UT(){let e=null,t=!1,n=null,r=null;function i(a,s){r=e.requestAnimationFrame(i),n(a,s)}return{start:function(){if(t===!0)return;if(n===null)return;if(e===null)return;r=e.requestAnimationFrame(i),t=!0},stop:function(){if(e!==null)e.cancelAnimationFrame(r);t=!1},setAnimationLoop:function(a){n=a},setContext:function(a){e=a}}}function KP(e){let t=new WeakMap;function n(o,c){let{array:l,usage:u}=o,d=l.byteLength,f=e.createBuffer();e.bindBuffer(c,f),e.bufferData(c,l,u),o.onUploadCallback();let h;if(l instanceof Float32Array)h=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)h=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(o.isFloat16BufferAttribute)h=e.HALF_FLOAT;else h=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)h=e.SHORT;else if(l instanceof Uint32Array)h=e.UNSIGNED_INT;else if(l instanceof Int32Array)h=e.INT;else if(l instanceof Int8Array)h=e.BYTE;else if(l instanceof Uint8Array)h=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)h=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:h,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function r(o,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,o),d.length===0)e.bufferSubData(l,0,u);else{d.sort((h,b)=>h.start-b.start);let f=0;for(let h=1;h<d.length;h++){let b=d[f],m=d[h];if(m.start<=b.start+b.count+1)b.count=Math.max(b.count,m.start+m.count-b.start);else++f,d[f]=m}d.length=f+1;for(let h=0,b=d.length;h<b;h++){let m=d[h];e.bufferSubData(l,m.start*u.BYTES_PER_ELEMENT,u,m.start,m.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){if(o.isInterleavedBufferAttribute)o=o.data;return t.get(o)}function a(o){if(o.isInterleavedBufferAttribute)o=o.data;let c=t.get(o);if(c)e.deleteBuffer(c.buffer),t.delete(o)}function s(o,c){if(o.isInterleavedBufferAttribute)o=o.data;if(o.isGLBufferAttribute){let u=t.get(o);if(!u||u.version<o.version)t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,n(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(l.buffer,o,c),l.version=o.version}}return{get:i,remove:a,update:s}}function Rk(e,t,n,r,i,a){let s=new Je(0),o=i===!0?0:1,c,l,u=null,d=0,f=null;function h(y){let v=y.isScene===!0?y.background:null;if(v&&v.isTexture){let x=y.backgroundBlurriness>0;v=t.get(v,x)}return v}function b(y){let v=!1,x=h(y);if(x===null)g(s,o);else if(x&&x.isColor)g(x,1),v=!0;let _=e.xr.getEnvironmentBlendMode();if(_==="additive")n.buffers.color.setClear(0,0,0,1,a);else if(_==="alpha-blend")n.buffers.color.setClear(0,0,0,0,a);if(e.autoClear||v)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function m(y,v){let x=h(v);if(x&&(x.isCubeTexture||x.mapping===sl)){if(l===void 0)l=new Gt(new Ea(1,1,1),new Mr({name:"BackgroundCubeMaterial",uniforms:Os(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:Ln,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(_,E,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l);if(l.material.uniforms.envMap.value=x,l.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Sk.makeRotationFromEuler(v.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(zT);if(l.material.toneMapped=lt.getTransfer(x.colorSpace)!==Bt,u!==x||d!==x.version||f!==e.toneMapping)l.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null)}else if(x&&x.isTexture){if(c===void 0)c=new Gt(new yl(2,2),new Mr({name:"BackgroundMaterial",uniforms:Os(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ba,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c);if(c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=lt.getTransfer(x.colorSpace)!==Bt,x.matrixAutoUpdate===!0)x.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(x.matrix),u!==x||d!==x.version||f!==e.toneMapping)c.material.needsUpdate=!0,u=x,d=x.version,f=e.toneMapping;c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)}}function g(y,v){y.getRGB(ef,Zm(e)),n.buffers.color.setClear(ef.r,ef.g,ef.b,v,a)}function p(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return s},setClearColor:function(y,v=1){s.set(y),o=v,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(y){o=y,g(s,o)},render:b,addToRenderList:m,dispose:p}}function Ik(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,s=!1;function o(M,R,k,C,U){let D=!1,P=d(M,C,k,R);if(a!==P)a=P,l(a.object);if(D=h(M,C,k,U),D)b(M,C,k,U);if(U!==null)t.update(U,e.ELEMENT_ARRAY_BUFFER);if(D||s){if(s=!1,x(M,R,k,C),U!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(U).buffer)}}function c(){return e.createVertexArray()}function l(M){return e.bindVertexArray(M)}function u(M){return e.deleteVertexArray(M)}function d(M,R,k,C){let U=C.wireframe===!0,D=r[R.id];if(D===void 0)D={},r[R.id]=D;let P=M.isInstancedMesh===!0?M.id:0,K=D[P];if(K===void 0)K={},D[P]=K;let z=K[k.id];if(z===void 0)z={},K[k.id]=z;let W=z[U];if(W===void 0)W=f(c()),z[U]=W;return W}function f(M){let R=[],k=[],C=[];for(let U=0;U<n;U++)R[U]=0,k[U]=0,C[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:k,attributeDivisors:C,object:M,attributes:{},index:null}}function h(M,R,k,C){let U=a.attributes,D=R.attributes,P=0,K=k.getAttributes();for(let z in K)if(K[z].location>=0){let q=U[z],le=D[z];if(le===void 0){if(z==="instanceMatrix"&&M.instanceMatrix)le=M.instanceMatrix;if(z==="instanceColor"&&M.instanceColor)le=M.instanceColor}if(q===void 0)return!0;if(q.attribute!==le)return!0;if(le&&q.data!==le.data)return!0;P++}if(a.attributesNum!==P)return!0;if(a.index!==C)return!0;return!1}function b(M,R,k,C){let U={},D=R.attributes,P=0,K=k.getAttributes();for(let z in K)if(K[z].location>=0){let q=D[z];if(q===void 0){if(z==="instanceMatrix"&&M.instanceMatrix)q=M.instanceMatrix;if(z==="instanceColor"&&M.instanceColor)q=M.instanceColor}let le={};if(le.attribute=q,q&&q.data)le.data=q.data;U[z]=le,P++}a.attributes=U,a.attributesNum=P,a.index=C}function m(){let M=a.newAttributes;for(let R=0,k=M.length;R<k;R++)M[R]=0}function g(M){p(M,0)}function p(M,R){let k=a.newAttributes,C=a.enabledAttributes,U=a.attributeDivisors;if(k[M]=1,C[M]===0)e.enableVertexAttribArray(M),C[M]=1;if(U[M]!==R)e.vertexAttribDivisor(M,R),U[M]=R}function y(){let M=a.newAttributes,R=a.enabledAttributes;for(let k=0,C=R.length;k<C;k++)if(R[k]!==M[k])e.disableVertexAttribArray(k),R[k]=0}function v(M,R,k,C,U,D,P){if(P===!0)e.vertexAttribIPointer(M,R,k,U,D);else e.vertexAttribPointer(M,R,k,C,U,D)}function x(M,R,k,C){m();let U=C.attributes,D=k.getAttributes(),P=R.defaultAttributeValues;for(let K in D){let z=D[K];if(z.location>=0){let W=U[K];if(W===void 0){if(K==="instanceMatrix"&&M.instanceMatrix)W=M.instanceMatrix;if(K==="instanceColor"&&M.instanceColor)W=M.instanceColor}if(W!==void 0){let q=W.normalized,le=W.itemSize,he=t.get(W);if(he===void 0)continue;let{buffer:xe,type:pe,bytesPerElement:J}=he,F=pe===e.INT||pe===e.UNSIGNED_INT||W.gpuType===im;if(W.isInterleavedBufferAttribute){let X=W.data,ne=X.stride,re=W.offset;if(X.isInstancedInterleavedBuffer){for(let ce=0;ce<z.locationSize;ce++)p(z.location+ce,X.meshPerAttribute);if(M.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=X.meshPerAttribute*X.count}else for(let ce=0;ce<z.locationSize;ce++)g(z.location+ce);e.bindBuffer(e.ARRAY_BUFFER,xe);for(let ce=0;ce<z.locationSize;ce++)v(z.location+ce,le/z.locationSize,pe,q,ne*J,(re+le/z.locationSize*ce)*J,F)}else{if(W.isInstancedBufferAttribute){for(let X=0;X<z.locationSize;X++)p(z.location+X,W.meshPerAttribute);if(M.isInstancedMesh!==!0&&C._maxInstanceCount===void 0)C._maxInstanceCount=W.meshPerAttribute*W.count}else for(let X=0;X<z.locationSize;X++)g(z.location+X);e.bindBuffer(e.ARRAY_BUFFER,xe);for(let X=0;X<z.locationSize;X++)v(z.location+X,le/z.locationSize,pe,q,le*J,le/z.locationSize*X*J,F)}}else if(P!==void 0){let q=P[K];if(q!==void 0)switch(q.length){case 2:e.vertexAttrib2fv(z.location,q);break;case 3:e.vertexAttrib3fv(z.location,q);break;case 4:e.vertexAttrib4fv(z.location,q);break;default:e.vertexAttrib1fv(z.location,q)}}}}y()}function _(){T();for(let M in r){let R=r[M];for(let k in R){let C=R[k];for(let U in C){let D=C[U];for(let P in D)u(D[P].object),delete D[P];delete C[U]}}delete r[M]}}function E(M){if(r[M.id]===void 0)return;let R=r[M.id];for(let k in R){let C=R[k];for(let U in C){let D=C[U];for(let P in D)u(D[P].object),delete D[P];delete C[U]}}delete r[M.id]}function w(M){for(let R in r){let k=r[R];for(let C in k){let U=k[C];if(U[M.id]===void 0)continue;let D=U[M.id];for(let P in D)u(D[P].object),delete D[P];delete U[M.id]}}}function A(M){for(let R in r){let k=r[R],C=M.isInstancedMesh===!0?M.id:0,U=k[C];if(U===void 0)continue;for(let D in U){let P=U[D];for(let K in P)u(P[K].object),delete P[K];delete U[D]}if(delete k[C],Object.keys(k).length===0)delete r[R]}}function T(){if(N(),s=!0,a===i)return;a=i,l(a.object)}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:T,resetDefaultState:N,dispose:_,releaseStatesOfGeometry:E,releaseStatesOfObject:A,releaseStatesOfProgram:w,initAttributes:m,enableAttribute:g,disableUnusedAttributes:y}}function Ck(e,t,n){let r;function i(c){r=c}function a(c,l){e.drawArrays(r,c,l),n.update(l,r,1)}function s(c,l,u){if(u===0)return;e.drawArraysInstanced(r,c,l,u),n.update(l,r,u)}function o(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,l,0,u);let f=0;for(let h=0;h<u;h++)f+=l[h];n.update(f,r,1)}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function Nk(e,t,n,r){let i;function a(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){let w=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(w){if(w!==mi&&r.convert(w)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function o(w){let A=w===pi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(w!==Vr&&w!==Hi&&!A&&r.convert(w)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(w){if(w==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";w="mediump"}if(w==="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)Ve("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&f===!1)Ve("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),b=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),y=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),x=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=e.getParameter(e.MAX_SAMPLES),E=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:h,maxVertexTextures:b,maxTextureSize:m,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:x,maxSamples:_,samples:E}}function Pk(e){let t=this,n=null,r=0,i=!1,a=!1,s=new Ar,o=new nt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){let h=d.length!==0||f||r!==0||i;return i=f,r=d.length,h},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,f){n=u(d,f,0)},this.setState=function(d,f,h){let{clippingPlanes:b,clipIntersection:m,clipShadows:g}=d,p=e.get(d);if(!i||b===null||b.length===0||a&&!g)if(a)u(null);else l();else{let y=a?0:r,v=y*4,x=p.clippingState||null;c.value=x,x=u(b,f,v,h);for(let _=0;_!==v;++_)x[_]=n[_];p.clippingState=x,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=y}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=r>0;t.numPlanes=r,t.numIntersection=0}function u(d,f,h,b){let m=d!==null?d.length:0,g=null;if(m!==0){if(g=c.value,b!==!0||g===null){let p=h+m*4,y=f.matrixWorldInverse;if(o.getNormalMatrix(y),g===null||g.length<p)g=new Float32Array(p);for(let v=0,x=h;v!==m;++v,x+=4)s.copy(d[v]).applyMatrix4(y,o),s.normal.toArray(g,x),g[x+3]=s.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}class Rl{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,r=100,i={}){let{size:a=256,position:s=Dk}=i;mg=this._renderer.getRenderTarget(),gg=this._renderer.getActiveCubeFace(),bg=this._renderer.getActiveMipmapLevel(),xg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let o=this._allocateTargets();if(o.depthBuffer=!0,this._sceneToCubeUV(e,n,r,o,s),t>0)this._blur(o,0,0,t);return this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=_T(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=yT(),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(mg,gg,bg),this._renderer.xr.enabled=xg,e.scissorTest=!1,Ko(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Po||e.mapping===Ms)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);mg=this._renderer.getRenderTarget(),gg=this._renderer.getActiveCubeFace(),bg=this._renderer.getActiveMipmapLevel(),xg=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:An,minFilter:An,generateMipmaps:!1,type:pi,format:mi,colorSpace:fr,depthBuffer:!1},r=xT(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=xT(e,t,n);let{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=Fk(i)),this._blurMaterial=zk(i,e,t),this._ggxMaterial=Uk(i,e,t)}return r}_compileMaterial(e){let t=new Gt(new Dn,e);this._renderer.compile(t,Tl)}_sceneToCubeUV(e,t,n,r,i){let o=new hn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:f}=u;if(u.getClearColor(bT),u.toneMapping=Br,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(r),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Gt(new Ea,new gi({name:"PMREM.Background",side:Ln,depthWrite:!1,depthTest:!1}));let b=this._backgroundBox,m=b.material,g=!1,p=e.background;if(p){if(p.isColor)m.color.copy(p),e.background=null,g=!0}else m.color.copy(bT),g=!0;for(let y=0;y<6;y++){let v=y%3;if(v===0)o.up.set(0,c[y],0),o.position.set(i.x,i.y,i.z),o.lookAt(i.x+l[y],i.y,i.z);else if(v===1)o.up.set(0,0,c[y]),o.position.set(i.x,i.y,i.z),o.lookAt(i.x,i.y+l[y],i.z);else o.up.set(0,c[y],0),o.position.set(i.x,i.y,i.z),o.lookAt(i.x,i.y,i.z+l[y]);let x=this._cubeSize;if(Ko(r,v*x,y>2?x:0,x,x),u.setRenderTarget(r),g)u.render(b,o);u.render(e,o)}u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===Po||e.mapping===Ms;if(r){if(this._cubemapMaterial===null)this._cubemapMaterial=_T();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=yT();let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let s=i.uniforms;s.envMap.value=e;let o=this._cubeSize;Ko(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Tl)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let i=1;i<r;i++)this._applyGGXFilter(e,i-1,i);t.autoClear=n}_applyGGXFilter(e,t,n){let r=this._renderer,i=this._pingPongRenderTarget,a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;let o=a.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,f=u*d,{_lodMax:h}=this,b=this._sizeLods[n],m=3*b*(n>h-Wo?n-h+Wo:0),g=4*(this._cubeSize-b);o.envMap.value=e.texture,o.roughness.value=f,o.mipInt.value=h-t,Ko(i,m,g,3*b,2*b),r.setRenderTarget(i),r.render(s,Tl),o.envMap.value=i.texture,o.roughness.value=0,o.mipInt.value=h-n,Ko(e,m,g,3*b,2*b),r.setRenderTarget(e),r.render(s,Tl)}_blur(e,t,n,r){let i=this._pingPongRenderTarget,a=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,i,t,n,a),this._blurPass(i,e,n,n,a)}_blurPass(e,t,n,r,i){let a=this._renderer,s=this._blurMaterial,o=this._lodMeshes[r];o.material=s;let c=s.uniforms;c.envMap.value=e.texture,c.sigma.value=i,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[r],u=3*l*(r>this._lodMax-Wo?r-this._lodMax+Wo:0),d=4*(this._cubeSize-l);Ko(t,u,d,3*l,2*l),a.setRenderTarget(t),a.render(o,Tl)}}function Fk(e){let t=[],n=[],r=e,i=e-Wo+1+Ok;for(let a=0;a<i;a++){let s=Math.pow(2,r);t.push(s);let o=1/(s-2),c=-o,l=1+o,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,f=6,h=3,b=new Float32Array(h*f*d),m=new Float32Array(h*f*d);for(let p=0;p<d;p++){let y=p%3*2/3-1,v=p>2?0:-1,x=[y,v,0,y+0.6666666666666666,v,0,y+0.6666666666666666,v+1,0,y,v,0,y+0.6666666666666666,v+1,0,y,v+1,0];b.set(x,h*f*p);for(let _=0;_<f;_++){let E=u[_*2]*2-1,w=u[_*2+1]*2-1;if(p===0)Ds.set(1,w,E);else if(p===1)Ds.set(-E,1,-w);else if(p===2)Ds.set(-E,w,1);else if(p===3)Ds.set(-1,w,-E);else if(p===4)Ds.set(-E,-1,w);else Ds.set(E,w,-1);Ds.toArray(m,(p*f+_)*h)}}let g=new Dn;if(g.setAttribute("position",new En(b,h)),g.setAttribute("outputDirection",new En(m,h)),n.push(new Gt(g,null)),r>Wo)r--}return{lodMeshes:n,sizeLods:t}}function xT(e,t,n){let r=new hr(e,t,n);return r.texture.mapping=sl,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ko(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Uk(e,t,n){return new Mr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Lk,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:nf(),fragmentShader:`
precision highp float;
precision highp int;
@@ -110,7 +110,7 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:dr,depthTest:!1,depthWrite:!1})}function bD(e,t,n){return new Ei({name:"SphericalGaussianBlur",defines:{SAMPLES:fD,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:Kd(),fragmentShader:`
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function zk(e,t,n){return new Mr({name:"SphericalGaussianBlur",defines:{SAMPLES:kk,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:nf(),fragmentShader:`
precision highp float;
precision highp int;
@@ -170,7 +170,7 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:dr,depthTest:!1,depthWrite:!1})}function aA(){return new Ei({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Kd(),fragmentShader:`
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function yT(){return new Mr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nf(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -189,7 +189,7 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:dr,depthTest:!1,depthWrite:!1})}function oA(){return new Ei({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Kd(),fragmentShader:`
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function _T(){return new Mr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nf(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -205,7 +205,7 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:dr,depthTest:!1,depthWrite:!1})}function Kd(){return`
+ `,blending:fi,depthTest:!1,depthWrite:!1})}function nf(){return`
precision mediump float;
precision mediump int;
@@ -220,7 +220,7 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
gl_Position = vec4( position, 1.0 );
}
- `}function xD(e){let t=new WeakMap,n=new WeakMap,i=null;function r(f,h=!1){if(f===null||f===void 0)return null;if(h)return a(f);return s(f)}function s(f){if(f&&f.isTexture){let h=f.mapping;if(h===hd||h===pd)if(t.has(f)){let b=t.get(f).texture;return o(b,f.mapping)}else{let b=f.image;if(b&&b.height>0){let m=new dg(b.height);return m.fromEquirectangularTexture(e,f),t.set(f,m),f.addEventListener("dispose",l),o(m.texture,f.mapping)}else return null}}return f}function a(f){if(f&&f.isTexture){let h=f.mapping,b=h===hd||h===pd,m=h===So||h===va;if(b||m){let g=n.get(f),p=g!==void 0?g.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p){if(i===null)i=new yl(e);return g=b?i.fromEquirectangular(f,g):i.fromCubemap(f,g),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),g.texture}else if(g!==void 0)return g.texture;else{let x=f.image;if(b&&x&&x.height>0||m&&x&&c(x)){if(i===null)i=new yl(e);return g=b?i.fromEquirectangular(f):i.fromCubemap(f),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),f.addEventListener("dispose",u),g.texture}else return null}}}return f}function o(f,h){if(h===hd)f.mapping=So;else if(h===pd)f.mapping=va;return f}function c(f){let h=0,b=6;for(let m=0;m<b;m++)if(f[m]!==void 0)h++;return h===b}function l(f){let h=f.target;h.removeEventListener("dispose",l);let b=t.get(h);if(b!==void 0)t.delete(h),b.dispose()}function u(f){let h=f.target;h.removeEventListener("dispose",u);let b=n.get(h);if(b!==void 0)n.delete(h),b.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function yD(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)ya("WebGLRenderer: "+i+" extension not supported.");return r}}}function _D(e,t,n,i){let r={},s=new WeakMap;function a(d){let f=d.target;if(f.index!==null)t.remove(f.index);for(let b in f.attributes)t.remove(f.attributes[b]);f.removeEventListener("dispose",a),delete r[f.id];let h=s.get(f);if(h)t.remove(h),s.delete(f);if(i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0)delete f._maxInstanceCount;n.memory.geometries--}function o(d,f){if(r[f.id]===!0)return f;return f.addEventListener("dispose",a),r[f.id]=!0,n.memory.geometries++,f}function c(d){let f=d.attributes;for(let h in f)t.update(f[h],e.ARRAY_BUFFER)}function l(d){let f=[],h=d.index,b=d.attributes.position,m=0;if(b===void 0)return;if(h!==null){let x=h.array;m=h.version;for(let _=0,y=x.length;_<y;_+=3){let v=x[_+0],E=x[_+1],w=x[_+2];f.push(v,E,E,w,w,v)}}else{let x=b.array;m=b.version;for(let _=0,y=x.length/3-1;_<y;_+=3){let v=_+0,E=_+1,w=_+2;f.push(v,E,E,w,w,v)}}let g=new(b.count>=65535?Id:Rd)(f,1);g.version=m;let p=s.get(d);if(p)t.remove(p);s.set(d,g)}function u(d){let f=s.get(d);if(f){let h=d.index;if(h!==null){if(f.version<h.version)l(d)}}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function vD(e,t,n){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function c(d,f){e.drawElements(i,f,s,d*a),n.update(f,i,1)}function l(d,f,h){if(h===0)return;e.drawElementsInstanced(i,f,s,d*a,h),n.update(f,i,h)}function u(d,f,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,f,0,s,d,0,h);let m=0;for(let g=0;g<h;g++)m+=f[g];n.update(m,i,1)}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function ED(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(n.calls++,a){case e.TRIANGLES:n.triangles+=o*(s/3);break;case e.LINES:n.lines+=o*(s/2);break;case e.LINE_STRIP:n.lines+=o*(s-1);break;case e.LINE_LOOP:n.lines+=o*s;break;case e.POINTS:n.points+=o*s;break;default:Ye("WebGLInfo: Unknown draw mode:",a);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function TD(e,t,n){let i=new WeakMap,r=new Pt;function s(a,o,c){let l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,f=i.get(o);if(f===void 0||f.count!==d){let A=function(){w.dispose(),i.delete(o),o.removeEventListener("dispose",A)};if(f!==void 0)f.texture.dispose();let h=o.morphAttributes.position!==void 0,b=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],x=o.morphAttributes.color||[],_=0;if(h===!0)_=1;if(b===!0)_=2;if(m===!0)_=3;let y=o.attributes.position.count*_,v=1;if(y>t.maxTextureSize)v=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let E=new Float32Array(y*v*4*d),w=new Sd(E,y,v,d);w.type=Br,w.needsUpdate=!0;let T=_*4;for(let P=0;P<d;P++){let S=g[P],R=p[P],k=x[P],C=y*v*4*P;for(let U=0;U<S.count;U++){let L=U*T;if(h===!0)r.fromBufferAttribute(S,U),E[C+L+0]=r.x,E[C+L+1]=r.y,E[C+L+2]=r.z,E[C+L+3]=0;if(b===!0)r.fromBufferAttribute(R,U),E[C+L+4]=r.x,E[C+L+5]=r.y,E[C+L+6]=r.z,E[C+L+7]=0;if(m===!0)r.fromBufferAttribute(k,U),E[C+L+8]=r.x,E[C+L+9]=r.y,E[C+L+10]=r.z,E[C+L+11]=k.itemSize===4?r.w:1}}f={count:d,texture:w,size:new Ke(y,v)},i.set(o,f),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let h=0;for(let m=0;m<l.length;m++)h+=l[m];let b=o.morphTargetsRelative?1:1-h;c.getUniforms().setValue(e,"morphTargetBaseInfluence",b),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}return{update:s}}function AD(e,t,n,i,r){let s=new WeakMap;function a(l){let u=r.render.frame,d=l.geometry,f=t.get(l,d);if(s.get(f)!==u)t.update(f),s.set(f,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let h=l.skeleton;if(s.get(h)!==u)h.update(),s.set(h,u)}return f}function o(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:a,dispose:o}}function SD(e,t,n,i,r,s){let a=new li(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new Ln;l.setAttribute("position",new Xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Xn([0,2,0,0,2,0],2));let u=new zm({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `}function Bk(e){let t=new WeakMap,n=new WeakMap,r=null;function i(f,h=!1){if(f===null||f===void 0)return null;if(h)return s(f);return a(f)}function a(f){if(f&&f.isTexture){let h=f.mapping;if(h===Ad||h===Td)if(t.has(f)){let b=t.get(f).texture;return o(b,f.mapping)}else{let b=f.image;if(b&&b.height>0){let m=new Ag(b.height);return m.fromEquirectangularTexture(e,f),t.set(f,m),f.addEventListener("dispose",l),o(m.texture,f.mapping)}else return null}}return f}function s(f){if(f&&f.isTexture){let h=f.mapping,b=h===Ad||h===Td,m=h===Po||h===Ms;if(b||m){let g=n.get(f),p=g!==void 0?g.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==p){if(r===null)r=new Rl(e);return g=b?r.fromEquirectangular(f,g):r.fromCubemap(f,g),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),g.texture}else if(g!==void 0)return g.texture;else{let y=f.image;if(b&&y&&y.height>0||m&&y&&c(y)){if(r===null)r=new Rl(e);return g=b?r.fromEquirectangular(f):r.fromCubemap(f),g.texture.pmremVersion=f.pmremVersion,n.set(f,g),f.addEventListener("dispose",u),g.texture}else return null}}}return f}function o(f,h){if(h===Ad)f.mapping=Po;else if(h===Td)f.mapping=Ms;return f}function c(f){let h=0,b=6;for(let m=0;m<b;m++)if(f[m]!==void 0)h++;return h===b}function l(f){let h=f.target;h.removeEventListener("dispose",l);let b=t.get(h);if(b!==void 0)t.delete(h),b.dispose()}function u(f){let h=f.target;h.removeEventListener("dispose",u);let b=n.get(h);if(b!==void 0)n.delete(h),b.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,r!==null)r.dispose(),r=null}return{get:i,dispose:d}}function jk(e){let t={};function n(r){if(t[r]!==void 0)return t[r];let i=e.getExtension(r);return t[r]=i,i}return{has:function(r){return n(r)!==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(r){let i=n(r);if(i===null)Ts("WebGLRenderer: "+r+" extension not supported.");return i}}}function Vk(e,t,n,r){let i={},a=new WeakMap;function s(d){let f=d.target;if(f.index!==null)t.remove(f.index);for(let b in f.attributes)t.remove(f.attributes[b]);f.removeEventListener("dispose",s),delete i[f.id];let h=a.get(f);if(h)t.remove(h),a.delete(f);if(r.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0)delete f._maxInstanceCount;n.memory.geometries--}function o(d,f){if(i[f.id]===!0)return f;return f.addEventListener("dispose",s),i[f.id]=!0,n.memory.geometries++,f}function c(d){let f=d.attributes;for(let h in f)t.update(f[h],e.ARRAY_BUFFER)}function l(d){let f=[],h=d.index,b=d.attributes.position,m=0;if(b===void 0)return;if(h!==null){let y=h.array;m=h.version;for(let v=0,x=y.length;v<x;v+=3){let _=y[v+0],E=y[v+1],w=y[v+2];f.push(_,E,E,w,w,_)}}else{let y=b.array;m=b.version;for(let v=0,x=y.length/3-1;v<x;v+=3){let _=v+0,E=v+1,w=v+2;f.push(_,E,E,w,w,_)}}let g=new(b.count>=65535?zd:Ud)(f,1);g.version=m;let p=a.get(d);if(p)t.remove(p);a.set(d,g)}function u(d){let f=a.get(d);if(f){let h=d.index;if(h!==null){if(f.version<h.version)l(d)}}else l(d);return a.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function Gk(e,t,n){let r;function i(d){r=d}let a,s;function o(d){a=d.type,s=d.bytesPerElement}function c(d,f){e.drawElements(r,f,a,d*s),n.update(f,r,1)}function l(d,f,h){if(h===0)return;e.drawElementsInstanced(r,f,a,d*s,h),n.update(f,r,h)}function u(d,f,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,f,0,a,d,0,h);let m=0;for(let g=0;g<h;g++)m+=f[g];n.update(m,r,1)}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function Hk(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case e.TRIANGLES:n.triangles+=o*(a/3);break;case e.LINES:n.lines+=o*(a/2);break;case e.LINE_STRIP:n.lines+=o*(a-1);break;case e.LINE_LOOP:n.lines+=o*a;break;case e.POINTS:n.points+=o*a;break;default:Qe("WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:i,update:r}}function $k(e,t,n){let r=new WeakMap,i=new Pt;function a(s,o,c){let l=s.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0,f=r.get(o);if(f===void 0||f.count!==d){let T=function(){w.dispose(),r.delete(o),o.removeEventListener("dispose",T)};if(f!==void 0)f.texture.dispose();let h=o.morphAttributes.position!==void 0,b=o.morphAttributes.normal!==void 0,m=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],y=o.morphAttributes.color||[],v=0;if(h===!0)v=1;if(b===!0)v=2;if(m===!0)v=3;let x=o.attributes.position.count*v,_=1;if(x>t.maxTextureSize)_=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize;let E=new Float32Array(x*_*4*d),w=new Dd(E,x,_,d);w.type=Hi,w.needsUpdate=!0;let A=v*4;for(let N=0;N<d;N++){let M=g[N],R=p[N],k=y[N],C=x*_*4*N;for(let U=0;U<M.count;U++){let D=U*A;if(h===!0)i.fromBufferAttribute(M,U),E[C+D+0]=i.x,E[C+D+1]=i.y,E[C+D+2]=i.z,E[C+D+3]=0;if(b===!0)i.fromBufferAttribute(R,U),E[C+D+4]=i.x,E[C+D+5]=i.y,E[C+D+6]=i.z,E[C+D+7]=0;if(m===!0)i.fromBufferAttribute(k,U),E[C+D+8]=i.x,E[C+D+9]=i.y,E[C+D+10]=i.z,E[C+D+11]=k.itemSize===4?i.w:1}}f={count:d,texture:w,size:new We(x,_)},r.set(o,f),o.addEventListener("dispose",T)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",s.morphTexture,n);else{let h=0;for(let m=0;m<l.length;m++)h+=l[m];let b=o.morphTargetsRelative?1:1-h;c.getUniforms().setValue(e,"morphTargetBaseInfluence",b),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",f.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}return{update:a}}function Kk(e,t,n,r,i){let a=new WeakMap;function s(l){let u=i.render.frame,d=l.geometry,f=t.get(l,d);if(a.get(f)!==u)t.update(f),a.set(f,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(a.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);a.set(l,u)}}if(l.isSkinnedMesh){let h=l.skeleton;if(a.get(h)!==u)h.update(),a.set(h,u)}return f}function o(){a=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),r.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:s,dispose:o}}function Xk(e,t,n,r,i,a){let s=new hr(t,n,{type:e,depthBuffer:i,stencilBuffer:a,samples:r?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=new Dn;l.setAttribute("position",new Jn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Jn([0,2,0,0,2,0],2));let u=new Ym({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
@@ -266,17 +266,17 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
- }`,depthTest:!1,depthWrite:!1}),d=new jt(l,u),f=new Ca(-1,1,1,-1,0,1),h=null,b=null,m=!1,g,p=null,x=[],_=!1;this.setSize=function(y,v){if(a.setSize(y,v),o!==null)o.setSize(y,v);if(c!==null)c.setSize(y,v);for(let E=0;E<x.length;E++){let w=x[E];if(w.setSize)w.setSize(y,v)}},this.setEffects=function(y){x=y,_=x.length>0&&x[0].isRenderPass===!0;let{width:v,height:E}=a;if(x.length>0&&o===null)o=new li(v,E,{type:hr,depthBuffer:!1,stencilBuffer:!1}),c=new li(v,E,{type:hr,depthBuffer:!1,stencilBuffer:!1});for(let w=0;w<x.length;w++){let T=x[w];if(T.setSize)T.setSize(v,E)}},this.begin=function(y,v){if(m)return!1;if(y.toneMapping===Ui&&x.length===0)return!1;if(p=v,v!==null){let{width:E,height:w}=v;if(a.width!==E||a.height!==w)this.setSize(E,w)}if(_===!1)y.setRenderTarget(a);return g=y.toneMapping,y.toneMapping=Ui,!0},this.hasRenderPass=function(){return _},this.end=function(y,v){y.toneMapping=g,m=!0;let E=a,w=o;for(let T=0;T<x.length;T++){let A=x[T];if(A.enabled===!1)continue;if(A.render(y,w,E,v),A.needsSwap!==!1)E=w,w=w===o?c:o}if(h!==y.outputColorSpace||b!==y.toneMapping){if(h=y.outputColorSpace,b=y.toneMapping,u.defines={},ot.getTransfer(h)===Bt)u.defines.SRGB_TRANSFER="";let T=wD[b];if(T)u.defines[T]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,y.setRenderTarget(p),y.render(d,f),p=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){if(a.dispose(),o!==null)o.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}function jo(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=cA[r];if(s===void 0)s=new Float32Array(r),cA[r]=s;if(t!==0){i.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=n,e[a].toArray(s,o)}return s}function mn(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 gn(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Wd(e,t){let n=lA[t];if(n===void 0)n=new Int32Array(t),lA[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function MD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function RD(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(mn(n,t))return;e.uniform2fv(this.addr,t),gn(n,t)}}function ID(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(mn(n,t))return;e.uniform3fv(this.addr,t),gn(n,t)}}function CD(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(mn(n,t))return;e.uniform4fv(this.addr,t),gn(n,t)}}function ND(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(mn(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,i))return;fA.set(i),e.uniformMatrix2fv(this.addr,!1,fA),gn(n,i)}}function PD(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(mn(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,i))return;dA.set(i),e.uniformMatrix3fv(this.addr,!1,dA),gn(n,i)}}function OD(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(mn(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,i))return;uA.set(i),e.uniformMatrix4fv(this.addr,!1,uA),gn(n,i)}}function kD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function DD(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(mn(n,t))return;e.uniform2iv(this.addr,t),gn(n,t)}}function LD(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(mn(n,t))return;e.uniform3iv(this.addr,t),gn(n,t)}}function FD(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(mn(n,t))return;e.uniform4iv(this.addr,t),gn(n,t)}}function UD(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function BD(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(mn(n,t))return;e.uniform2uiv(this.addr,t),gn(n,t)}}function zD(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(mn(n,t))return;e.uniform3uiv(this.addr,t),gn(n,t)}}function VD(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(mn(n,t))return;e.uniform4uiv(this.addr,t),gn(n,t)}}function jD(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)lg.compareFunction=n.isReversedDepthBuffer()?wd:Ad,s=lg;else s=MA;n.setTexture2D(t||s,r)}function HD(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||IA,r)}function GD(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||CA,r)}function $D(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||RA,r)}function KD(e){switch(e){case 5126:return MD;case 35664:return RD;case 35665:return ID;case 35666:return CD;case 35674:return ND;case 35675:return PD;case 35676:return OD;case 5124:case 35670:return kD;case 35667:case 35671:return DD;case 35668:case 35672:return LD;case 35669:case 35673:return FD;case 5125:return UD;case 36294:return BD;case 36295:return zD;case 36296:return VD;case 35678:case 36198:case 36298:case 36306:case 35682:return jD;case 35679:case 36299:case 36307:return HD;case 35680:case 36300:case 36308:case 36293:return GD;case 36289:case 36303:case 36311:case 36292:return $D}}function WD(e,t){e.uniform1fv(this.addr,t)}function XD(e,t){let n=jo(t,this.size,2);e.uniform2fv(this.addr,n)}function qD(e,t){let n=jo(t,this.size,3);e.uniform3fv(this.addr,n)}function JD(e,t){let n=jo(t,this.size,4);e.uniform4fv(this.addr,n)}function ZD(e,t){let n=jo(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function YD(e,t){let n=jo(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function QD(e,t){let n=jo(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function eL(e,t){e.uniform1iv(this.addr,t)}function tL(e,t){e.uniform2iv(this.addr,t)}function nL(e,t){e.uniform3iv(this.addr,t)}function iL(e,t){e.uniform4iv(this.addr,t)}function rL(e,t){e.uniform1uiv(this.addr,t)}function sL(e,t){e.uniform2uiv(this.addr,t)}function aL(e,t){e.uniform3uiv(this.addr,t)}function oL(e,t){e.uniform4uiv(this.addr,t)}function cL(e,t,n){let i=this.cache,r=t.length,s=Wd(n,r);if(!mn(i,s))e.uniform1iv(this.addr,s),gn(i,s);let a;if(this.type===e.SAMPLER_2D_SHADOW)a=lg;else a=MA;for(let o=0;o!==r;++o)n.setTexture2D(t[o]||a,s[o])}function lL(e,t,n){let i=this.cache,r=t.length,s=Wd(n,r);if(!mn(i,s))e.uniform1iv(this.addr,s),gn(i,s);for(let a=0;a!==r;++a)n.setTexture3D(t[a]||IA,s[a])}function uL(e,t,n){let i=this.cache,r=t.length,s=Wd(n,r);if(!mn(i,s))e.uniform1iv(this.addr,s),gn(i,s);for(let a=0;a!==r;++a)n.setTextureCube(t[a]||CA,s[a])}function dL(e,t,n){let i=this.cache,r=t.length,s=Wd(n,r);if(!mn(i,s))e.uniform1iv(this.addr,s),gn(i,s);for(let a=0;a!==r;++a)n.setTexture2DArray(t[a]||RA,s[a])}function fL(e){switch(e){case 5126:return WD;case 35664:return XD;case 35665:return qD;case 35666:return JD;case 35674:return ZD;case 35675:return YD;case 35676:return QD;case 5124:case 35670:return eL;case 35667:case 35671:return tL;case 35668:case 35672:return nL;case 35669:case 35673:return iL;case 5125:return rL;case 36294:return sL;case 36295:return aL;case 36296:return oL;case 35678:case 36198:case 36298:case 36306:case 35682:return cL;case 35679:case 36299:case 36307:return lL;case 35680:case 36300:case 36308:case 36293:return uL;case 36289:case 36303:case 36311:case 36292:return dL}}class NA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=KD(t.type)}}class PA{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=fL(t.type)}}class OA{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,s=i.length;r!==s;++r){let a=i[r];a.setValue(e,t[a.id],n)}}}function hA(e,t){e.seq.push(t),e.map[t.id]=t}function hL(e,t,n){let i=e.name,r=i.length;og.lastIndex=0;while(!0){let s=og.exec(i),a=og.lastIndex,o=s[1],c=s[2]==="]",l=s[3];if(c)o=o|0;if(l===void 0||l==="["&&a+2===r){hA(n,l===void 0?new NA(o,e,t):new PA(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new OA(o),hA(n,d);n=d}}}class xl{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let a=e.getActiveUniform(t,s),o=e.getUniformLocation(t,a.name);hL(a,o,this)}let i=[],r=[];for(let s of this.seq)if(s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW)i.push(s);else r.push(s);if(i.length>0)this.seq=i.concat(r)}setValue(e,t,n,i){let r=this.map[t];if(r!==void 0)r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];if(i!==void 0)this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,s=t.length;r!==s;++r){let a=t[r],o=n[a.id];if(o.needsUpdate!==!1)a.setValue(e,o.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let s=e[i];if(s.id in t)n.push(s)}return n}}function pA(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}function gL(e,t){let n=e.split(`
-`),i=[],r=Math.max(t-6,0),s=Math.min(t+6,n.length);for(let a=r;a<s;a++){let o=a+1;i.push(`${o===t?">":" "} ${o}: ${n[a]}`)}return i.join(`
-`)}function bL(e){ot._getMatrix(mA,ot.workingColorSpace,e);let t=`mat3( ${mA.elements.map((n)=>n.toFixed(4))} )`;switch(ot.getTransfer(e)){case Nm:return[t,"LinearTransferOETF"];case Bt:return[t,"sRGBTransferOETF"];default:return je("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function gA(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let o=parseInt(a[1]);return n.toUpperCase()+`
+ }`,depthTest:!1,depthWrite:!1}),d=new Gt(l,u),f=new Ls(-1,1,1,-1,0,1),h=null,b=null,m=!1,g,p=null,y=[],v=!1;this.setSize=function(x,_){if(s.setSize(x,_),o!==null)o.setSize(x,_);if(c!==null)c.setSize(x,_);for(let E=0;E<y.length;E++){let w=y[E];if(w.setSize)w.setSize(x,_)}},this.setEffects=function(x){y=x,v=y.length>0&&y[0].isRenderPass===!0;let{width:_,height:E}=s;if(y.length>0&&o===null)o=new hr(_,E,{type:pi,depthBuffer:!1,stencilBuffer:!1}),c=new hr(_,E,{type:pi,depthBuffer:!1,stencilBuffer:!1});for(let w=0;w<y.length;w++){let A=y[w];if(A.setSize)A.setSize(_,E)}},this.begin=function(x,_){if(m)return!1;if(x.toneMapping===Br&&y.length===0)return!1;if(p=_,_!==null){let{width:E,height:w}=_;if(s.width!==E||s.height!==w)this.setSize(E,w)}if(v===!1)x.setRenderTarget(s);return g=x.toneMapping,x.toneMapping=Br,!0},this.hasRenderPass=function(){return v},this.end=function(x,_){x.toneMapping=g,m=!0;let E=s,w=o;for(let A=0;A<y.length;A++){let T=y[A];if(T.enabled===!1)continue;if(T.render(x,w,E,_),T.needsSwap!==!1)E=w,w=w===o?c:o}if(h!==x.outputColorSpace||b!==x.toneMapping){if(h=x.outputColorSpace,b=x.toneMapping,u.defines={},lt.getTransfer(h)===Bt)u.defines.SRGB_TRANSFER="";let A=Wk[b];if(A)u.defines[A]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=E.texture,x.setRenderTarget(p),x.render(d,f),p=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){if(s.dispose(),o!==null)o.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}function Xo(e,t,n){let r=e[0];if(r<=0||r>0)return e;let i=t*n,a=vT[i];if(a===void 0)a=new Float32Array(i),vT[i]=a;if(t!==0){r.toArray(a,0);for(let s=1,o=0;s!==t;++s)o+=n,e[s].toArray(a,o)}return a}function mn(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function gn(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function rf(e,t){let n=ET[t];if(n===void 0)n=new Int32Array(t),ET[t]=n;for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function qk(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function Jk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(mn(n,t))return;e.uniform2fv(this.addr,t),gn(n,t)}}function Zk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.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(mn(n,t))return;e.uniform3fv(this.addr,t),gn(n,t)}}function Yk(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.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(mn(n,t))return;e.uniform4fv(this.addr,t),gn(n,t)}}function Qk(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(mn(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,r))return;wT.set(r),e.uniformMatrix2fv(this.addr,!1,wT),gn(n,r)}}function eL(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(mn(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,r))return;TT.set(r),e.uniformMatrix3fv(this.addr,!1,TT),gn(n,r)}}function tL(e,t){let n=this.cache,r=t.elements;if(r===void 0){if(mn(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),gn(n,t)}else{if(mn(n,r))return;AT.set(r),e.uniformMatrix4fv(this.addr,!1,AT),gn(n,r)}}function nL(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function rL(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(mn(n,t))return;e.uniform2iv(this.addr,t),gn(n,t)}}function iL(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(mn(n,t))return;e.uniform3iv(this.addr,t),gn(n,t)}}function aL(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(mn(n,t))return;e.uniform4iv(this.addr,t),gn(n,t)}}function sL(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function oL(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(mn(n,t))return;e.uniform2uiv(this.addr,t),gn(n,t)}}function cL(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(mn(n,t))return;e.uniform3uiv(this.addr,t),gn(n,t)}}function lL(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(mn(n,t))return;e.uniform4uiv(this.addr,t),gn(n,t)}}function uL(e,t,n){let r=this.cache,i=n.allocateTextureUnit();if(r[0]!==i)e.uniform1i(this.addr,i),r[0]=i;let a;if(this.type===e.SAMPLER_2D_SHADOW)vg.compareFunction=n.isReversedDepthBuffer()?Ld:kd,a=vg;else a=BT;n.setTexture2D(t||a,i)}function dL(e,t,n){let r=this.cache,i=n.allocateTextureUnit();if(r[0]!==i)e.uniform1i(this.addr,i),r[0]=i;n.setTexture3D(t||VT,i)}function fL(e,t,n){let r=this.cache,i=n.allocateTextureUnit();if(r[0]!==i)e.uniform1i(this.addr,i),r[0]=i;n.setTextureCube(t||GT,i)}function hL(e,t,n){let r=this.cache,i=n.allocateTextureUnit();if(r[0]!==i)e.uniform1i(this.addr,i),r[0]=i;n.setTexture2DArray(t||jT,i)}function pL(e){switch(e){case 5126:return qk;case 35664:return Jk;case 35665:return Zk;case 35666:return Yk;case 35674:return Qk;case 35675:return eL;case 35676:return tL;case 5124:case 35670:return nL;case 35667:case 35671:return rL;case 35668:case 35672:return iL;case 35669:case 35673:return aL;case 5125:return sL;case 36294:return oL;case 36295:return cL;case 36296:return lL;case 35678:case 36198:case 36298:case 36306:case 35682:return uL;case 35679:case 36299:case 36307:return dL;case 35680:case 36300:case 36308:case 36293:return fL;case 36289:case 36303:case 36311:case 36292:return hL}}function mL(e,t){e.uniform1fv(this.addr,t)}function gL(e,t){let n=Xo(t,this.size,2);e.uniform2fv(this.addr,n)}function bL(e,t){let n=Xo(t,this.size,3);e.uniform3fv(this.addr,n)}function xL(e,t){let n=Xo(t,this.size,4);e.uniform4fv(this.addr,n)}function yL(e,t){let n=Xo(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function _L(e,t){let n=Xo(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function vL(e,t){let n=Xo(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function EL(e,t){e.uniform1iv(this.addr,t)}function AL(e,t){e.uniform2iv(this.addr,t)}function TL(e,t){e.uniform3iv(this.addr,t)}function wL(e,t){e.uniform4iv(this.addr,t)}function ML(e,t){e.uniform1uiv(this.addr,t)}function SL(e,t){e.uniform2uiv(this.addr,t)}function RL(e,t){e.uniform3uiv(this.addr,t)}function IL(e,t){e.uniform4uiv(this.addr,t)}function CL(e,t,n){let r=this.cache,i=t.length,a=rf(n,i);if(!mn(r,a))e.uniform1iv(this.addr,a),gn(r,a);let s;if(this.type===e.SAMPLER_2D_SHADOW)s=vg;else s=BT;for(let o=0;o!==i;++o)n.setTexture2D(t[o]||s,a[o])}function NL(e,t,n){let r=this.cache,i=t.length,a=rf(n,i);if(!mn(r,a))e.uniform1iv(this.addr,a),gn(r,a);for(let s=0;s!==i;++s)n.setTexture3D(t[s]||VT,a[s])}function PL(e,t,n){let r=this.cache,i=t.length,a=rf(n,i);if(!mn(r,a))e.uniform1iv(this.addr,a),gn(r,a);for(let s=0;s!==i;++s)n.setTextureCube(t[s]||GT,a[s])}function OL(e,t,n){let r=this.cache,i=t.length,a=rf(n,i);if(!mn(r,a))e.uniform1iv(this.addr,a),gn(r,a);for(let s=0;s!==i;++s)n.setTexture2DArray(t[s]||jT,a[s])}function kL(e){switch(e){case 5126:return mL;case 35664:return gL;case 35665:return bL;case 35666:return xL;case 35674:return yL;case 35675:return _L;case 35676:return vL;case 5124:case 35670:return EL;case 35667:case 35671:return AL;case 35668:case 35672:return TL;case 35669:case 35673:return wL;case 5125:return ML;case 36294:return SL;case 36295:return RL;case 36296:return IL;case 35678:case 36198:case 36298:case 36306:case 35682:return CL;case 35679:case 36299:case 36307:return NL;case 35680:case 36300:case 36308:case 36293:return PL;case 36289:case 36303:case 36311:case 36292:return OL}}class HT{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=pL(t.type)}}class $T{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=kL(t.type)}}class KT{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let i=0,a=r.length;i!==a;++i){let s=r[i];s.setValue(e,t[s.id],n)}}}function MT(e,t){e.seq.push(t),e.map[t.id]=t}function LL(e,t,n){let r=e.name,i=r.length;yg.lastIndex=0;while(!0){let a=yg.exec(r),s=yg.lastIndex,o=a[1],c=a[2]==="]",l=a[3];if(c)o=o|0;if(l===void 0||l==="["&&s+2===i){MT(n,l===void 0?new HT(o,e,t):new $T(o,e,t));break}else{let d=n.map[o];if(d===void 0)d=new KT(o),MT(n,d);n=d}}}class Sl{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let s=e.getActiveUniform(t,a),o=e.getUniformLocation(t,s.name);LL(s,o,this)}let r=[],i=[];for(let a of this.seq)if(a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW)r.push(a);else i.push(a);if(r.length>0)this.seq=r.concat(i)}setValue(e,t,n,r){let i=this.map[t];if(i!==void 0)i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];if(r!==void 0)this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let s=t[i],o=n[s.id];if(o.needsUpdate!==!1)s.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let a=e[r];if(a.id in t)n.push(a)}return n}}function ST(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function UL(e,t){let n=e.split(`
+`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let s=i;s<a;s++){let o=s+1;r.push(`${o===t?">":" "} ${o}: ${n[s]}`)}return r.join(`
+`)}function zL(e){lt._getMatrix(RT,lt.workingColorSpace,e);let t=`mat3( ${RT.elements.map((n)=>n.toFixed(4))} )`;switch(lt.getTransfer(e)){case Gm:return[t,"LinearTransferOETF"];case Bt:return[t,"sRGBTransferOETF"];default:return Ve("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function IT(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(r&&a==="")return"";let s=/ERROR: 0:(\d+)/.exec(a);if(s){let o=parseInt(s[1]);return n.toUpperCase()+`
-`+s+`
+`+a+`
-`+gL(e.getShaderSource(t),o)}else return s}function xL(e,t){let n=bL(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}function _L(e,t){let n=yL[t];if(n===void 0)return je("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function vL(){ot.getLuminanceCoefficients($d);let e=$d.x.toFixed(4),t=$d.y.toFixed(4),n=$d.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function EL(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(bl).join(`
-`)}function TL(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 AL(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let s=e.getActiveAttrib(t,r),a=s.name,o=1;if(s.type===e.FLOAT_MAT2)o=2;if(s.type===e.FLOAT_MAT3)o=3;if(s.type===e.FLOAT_MAT4)o=4;n[a]={type:s.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}function bl(e){return e!==""}function bA(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 xA(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function ug(e){return e.replace(wL,ML)}function ML(e,t){let n=st[t];if(n===void 0){let i=SL.get(t);if(i!==void 0)n=st[i],je('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return ug(n)}function yA(e){return e.replace(RL,IL)}function IL(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 _A(e){let t=`precision ${e.precision} float;
+`+UL(e.getShaderSource(t),o)}else return a}function BL(e,t){let n=zL(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}function VL(e,t){let n=jL[t];if(n===void 0)return Ve("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function GL(){lt.getLuminanceCoefficients(tf);let e=tf.x.toFixed(4),t=tf.y.toFixed(4),n=tf.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function HL(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ml).join(`
+`)}function $L(e){let t=[];for(let n in e){let r=e[n];if(r===!1)continue;t.push("#define "+n+" "+r)}return t.join(`
+`)}function KL(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){let a=e.getActiveAttrib(t,i),s=a.name,o=1;if(a.type===e.FLOAT_MAT2)o=2;if(a.type===e.FLOAT_MAT3)o=3;if(a.type===e.FLOAT_MAT4)o=4;n[s]={type:a.type,location:e.getAttribLocation(t,s),locationSize:o}}return n}function Ml(e){return e!==""}function CT(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 NT(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Eg(e){return e.replace(WL,qL)}function qL(e,t){let n=ct[t];if(n===void 0){let r=XL.get(t);if(r!==void 0)n=ct[r],Ve('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,r);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Eg(n)}function PT(e){return e.replace(JL,ZL)}function ZL(e,t,n,r){let i="";for(let a=parseInt(t);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function OT(e){let t=`precision ${e.precision} float;
precision ${e.precision} int;
precision ${e.precision} sampler2D;
precision ${e.precision} samplerCube;
@@ -296,30 +296,30 @@ ${Rn(o)}`)}`)He("manifest hash mismatch.");return structuredClone(e)}var Kv="kil
`;if(e.precision==="highp")t+=`
#define HIGH_PRECISION`;else if(e.precision==="mediump")t+=`
#define MEDIUM_PRECISION`;else if(e.precision==="lowp")t+=`
-#define LOW_PRECISION`;return t}function NL(e){return CL[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function OL(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return PL[e.envMapMode]||"ENVMAP_TYPE_CUBE"}function DL(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return kL[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}function FL(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return LL[e.combine]||"ENVMAP_BLENDING_NONE"}function UL(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 BL(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:a,fragmentShader:o}=n,c=NL(n),l=OL(n),u=DL(n),d=FL(n),f=UL(n),h=EL(n),b=TL(s),m=r.createProgram(),g,p,x=n.glslVersion?"#version "+n.glslVersion+`
-`:"";if(n.isRawShaderMaterial){if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(bl).join(`
+#define LOW_PRECISION`;return t}function QL(e){return YL[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}function tD(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return eD[e.envMapMode]||"ENVMAP_TYPE_CUBE"}function rD(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return nD[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}function aD(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return iD[e.combine]||"ENVMAP_BLENDING_NONE"}function sD(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function oD(e,t,n,r){let i=e.getContext(),{defines:a,vertexShader:s,fragmentShader:o}=n,c=QL(n),l=tD(n),u=rD(n),d=aD(n),f=sD(n),h=HL(n),b=$L(a),m=i.createProgram(),g,p,y=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Ml).join(`
`),g.length>0)g+=`
-`;if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(bl).join(`
+`;if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Ml).join(`
`),p.length>0)p+=`
-`}else g=[_A(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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(bl).join(`
-`),p=[_A(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ui?"#define TONE_MAPPING":"",n.toneMapping!==Ui?st.tonemapping_pars_fragment:"",n.toneMapping!==Ui?_L("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",st.colorspace_pars_fragment,xL("linearToOutputTexel",n.outputColorSpace),vL(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(bl).join(`
-`);if(a=ug(a),a=bA(a,n),a=xA(a,n),o=ug(o),o=bA(o,n),o=xA(o,n),a=yA(a),o=yA(o),n.isRawShaderMaterial!==!0)x=`#version 300 es
+`}else g=[OT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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(Ml).join(`
+`),p=[OT(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Br?"#define TONE_MAPPING":"",n.toneMapping!==Br?ct.tonemapping_pars_fragment:"",n.toneMapping!==Br?VL("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ct.colorspace_pars_fragment,BL("linearToOutputTexel",n.outputColorSpace),GL(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(Ml).join(`
+`);if(s=Eg(s),s=CT(s,n),s=NT(s,n),o=Eg(o),o=CT(o,n),o=NT(o,n),s=PT(s),o=PT(o),n.isRawShaderMaterial!==!0)y=`#version 300 es
`,g=[h,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+g,p=["#define varying in",n.glslVersion===Pm?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Pm?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+g,p=["#define varying in",n.glslVersion===Hm?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Hm?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+p;let _=x+g+a,y=x+p+o,v=pA(r,r.VERTEX_SHADER,_),E=pA(r,r.FRAGMENT_SHADER,y);if(r.attachShader(m,v),r.attachShader(m,E),n.index0AttributeName!==void 0)r.bindAttribLocation(m,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(m,0,"position");r.linkProgram(m);function w(S){if(e.debug.checkShaderErrors){let R=r.getProgramInfoLog(m)||"",k=r.getShaderInfoLog(v)||"",C=r.getShaderInfoLog(E)||"",U=R.trim(),L=k.trim(),O=C.trim(),K=!0,B=!0;if(r.getProgramParameter(m,r.LINK_STATUS)===!1)if(K=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,m,v,E);else{let X=gA(r,v,"vertex"),q=gA(r,E,"fragment");Ye("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+`
+`+p;let v=y+g+s,x=y+p+o,_=ST(i,i.VERTEX_SHADER,v),E=ST(i,i.FRAGMENT_SHADER,x);if(i.attachShader(m,_),i.attachShader(m,E),n.index0AttributeName!==void 0)i.bindAttribLocation(m,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)i.bindAttribLocation(m,0,"position");i.linkProgram(m);function w(M){if(e.debug.checkShaderErrors){let R=i.getProgramInfoLog(m)||"",k=i.getShaderInfoLog(_)||"",C=i.getShaderInfoLog(E)||"",U=R.trim(),D=k.trim(),P=C.trim(),K=!0,z=!0;if(i.getProgramParameter(m,i.LINK_STATUS)===!1)if(K=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(i,m,_,E);else{let W=IT(i,_,"vertex"),q=IT(i,E,"fragment");Qe("WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,i.VALIDATE_STATUS)+`
-Material Name: `+S.name+`
-Material Type: `+S.type+`
+Material Name: `+M.name+`
+Material Type: `+M.type+`
Program Info Log: `+U+`
-`+X+`
-`+q)}else if(U!=="")je("WebGLProgram: Program Info Log:",U);else if(L===""||O==="")B=!1;if(B)S.diagnostics={runnable:K,programLog:U,vertexShader:{log:L,prefix:g},fragmentShader:{log:O,prefix:p}}}r.deleteShader(v),r.deleteShader(E),T=new xl(r,m),A=AL(r,m)}let T;this.getUniforms=function(){if(T===void 0)w(this);return T};let A;this.getAttributes=function(){if(A===void 0)w(this);return A};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(P===!1)P=r.getProgramParameter(m,pL);return P},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mL++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=v,this.fragmentShader=E,this}class kA{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 DA(e),t.set(e,n);return n}}class DA{constructor(e){this.id=zL++,this.code=e,this.usedTimes=0}}function VL(e){return e===wa||e===vd||e===Ed}function jL(e,t,n,i,r,s){let a=new Md,o=new kA,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:f}=i,h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(T){if(c.add(T),T===0)return"uv";return`uv${T}`}function m(T,A,P,S,R,k){let C=S.fog,U=R.geometry,L=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?S.environment:null,O=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap,K=t.get(T.envMap||L,O),B=!!K&&K.mapping===Zc?K.image.height:null,X=h[T.type];if(T.precision!==null){if(f=i.getMaxPrecision(T.precision),f!==T.precision)je("WebGLProgram.getParameters:",T.precision,"not supported, using",f,"instead.")}let q=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,le=q!==void 0?q.length:0,de=0;if(U.morphAttributes.position!==void 0)de=1;if(U.morphAttributes.normal!==void 0)de=2;if(U.morphAttributes.color!==void 0)de=3;let Me,pe,J,F;if(X){let zt=br[X];Me=zt.vertexShader,pe=zt.fragmentShader}else{Me=T.vertexShader,pe=T.fragmentShader;let zt=o.getVertexShaderStage(T),Mt=o.getFragmentShaderStage(T);o.update(T,zt,Mt),J=zt.id,F=Mt.id}let W=e.getRenderTarget(),ne=e.state.buffers.depth.getReversed(),ie=R.isInstancedMesh===!0,ce=R.isBatchedMesh===!0,_e=!!T.map,Re=!!T.matcap,ke=!!K,We=!!T.aoMap,Qe=!!T.lightMap,Wt=!!T.bumpMap&&T.wireframe===!1,lt=!!T.normalMap,Lt=!!T.displacementMap,Qt=!!T.emissiveMap,nn=!!T.metalnessMap,z=!!T.roughnessMap,_n=T.anisotropy>0,St=T.clearcoat>0,Xt=T.dispersion>0,N=T.retroreflectivity>0,M=T.iridescence>0,V=T.sheen>0,ee=T.transmission>0,he=_n&&!!T.anisotropyMap,ge=St&&!!T.clearcoatMap,ve=St&&!!T.clearcoatNormalMap,re=St&&!!T.clearcoatRoughnessMap,oe=M&&!!T.iridescenceMap,Ie=M&&!!T.iridescenceThicknessMap,Ve=V&&!!T.sheenColorMap,Ee=V&&!!T.sheenRoughnessMap,me=!!T.specularMap,Ge=!!T.specularColorMap,Xe=!!T.specularIntensityMap,vt=ee&&!!T.transmissionMap,G=ee&&!!T.thicknessMap,xe=!!T.gradientMap,ae=!!T.alphaMap,ye=T.alphaTest>0,Ce=!!T.alphaHash,fe=!!T.extensions,Ae=Ui;if(T.toneMapped){if(W===null||W.isXRRenderTarget===!0)Ae=e.toneMapping}let it={shaderID:X,shaderType:T.type,shaderName:T.name,vertexShader:Me,fragmentShader:pe,defines:T.defines,customVertexShaderID:J,customFragmentShaderID:F,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:f,batching:ce,batchingColor:ce&&R._colorsTexture!==null,instancing:ie,instancingColor:ie&&R.instanceColor!==null,instancingMorph:ie&&R.morphTexture!==null,outputColorSpace:W===null?e.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:ot.workingColorSpace,alphaToCoverage:!!T.alphaToCoverage,map:_e,matcap:Re,envMap:ke,envMapMode:ke&&K.mapping,envMapCubeUVHeight:B,aoMap:We,lightMap:Qe,bumpMap:Wt,normalMap:lt,displacementMap:Lt,emissiveMap:Qt,normalMapObjectSpace:lt&&T.normalMapType===UT,normalMapTangentSpace:lt&&T.normalMapType===Cm,packedNormalMap:lt&&T.normalMapType===Cm&&VL(T.normalMap.format),metalnessMap:nn,roughnessMap:z,anisotropy:_n,anisotropyMap:he,clearcoat:St,clearcoatMap:ge,clearcoatNormalMap:ve,clearcoatRoughnessMap:re,dispersion:Xt,retroreflection:N,iridescence:M,iridescenceMap:oe,iridescenceThicknessMap:Ie,sheen:V,sheenColorMap:Ve,sheenRoughnessMap:Ee,specularMap:me,specularColorMap:Ge,specularIntensityMap:Xe,transmission:ee,transmissionMap:vt,thicknessMap:G,gradientMap:xe,opaque:T.transparent===!1&&T.blending===qc&&T.alphaToCoverage===!1,alphaMap:ae,alphaTest:ye,alphaHash:Ce,combine:T.combine,mapUv:_e&&b(T.map.channel),aoMapUv:We&&b(T.aoMap.channel),lightMapUv:Qe&&b(T.lightMap.channel),bumpMapUv:Wt&&b(T.bumpMap.channel),normalMapUv:lt&&b(T.normalMap.channel),displacementMapUv:Lt&&b(T.displacementMap.channel),emissiveMapUv:Qt&&b(T.emissiveMap.channel),metalnessMapUv:nn&&b(T.metalnessMap.channel),roughnessMapUv:z&&b(T.roughnessMap.channel),anisotropyMapUv:he&&b(T.anisotropyMap.channel),clearcoatMapUv:ge&&b(T.clearcoatMap.channel),clearcoatNormalMapUv:ve&&b(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&b(T.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&b(T.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&b(T.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&b(T.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&b(T.sheenRoughnessMap.channel),specularMapUv:me&&b(T.specularMap.channel),specularColorMapUv:Ge&&b(T.specularColorMap.channel),specularIntensityMapUv:Xe&&b(T.specularIntensityMap.channel),transmissionMapUv:vt&&b(T.transmissionMap.channel),thicknessMapUv:G&&b(T.thicknessMap.channel),alphaMapUv:ae&&b(T.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(lt||_n),vertexNormals:!!U.attributes.normal,vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!U.attributes.uv&&(_e||ae),fog:!!C,useFog:T.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:T.wireframe===!1&&(T.flatShading===!0||U.attributes.normal===void 0&&lt===!1&&(T.isMeshLambertMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isMeshPhysicalMaterial)),sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ne,skinning:R.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:de,numSunLights:A.sun.length,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numSunLightShadows:A.sunShadowMap.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:k.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:T.dithering,shadowMapEnabled:e.shadowMap.enabled&&P.length>0,shadowMapType:e.shadowMap.type,toneMapping:Ae,decodeVideoTexture:_e&&T.map.isVideoTexture===!0&&ot.getTransfer(T.map.colorSpace)===Bt,decodeVideoTextureEmissive:Qt&&T.emissiveMap.isVideoTexture===!0&&ot.getTransfer(T.emissiveMap.colorSpace)===Bt,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===vi,flipSided:T.side===Dn,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:fe&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&T.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return it.vertexUv1s=c.has(1),it.vertexUv2s=c.has(2),it.vertexUv3s=c.has(3),c.clear(),it}function g(T){let A=[];if(T.shaderID)A.push(T.shaderID);else A.push(T.customVertexShaderID),A.push(T.customFragmentShaderID);if(T.defines!==void 0)for(let P in T.defines)A.push(P),A.push(T.defines[P]);if(T.isRawShaderMaterial===!1)p(A,T),x(A,T),A.push(e.outputColorSpace);return A.push(T.customProgramCacheKey),A.join()}function p(T,A){T.push(A.precision),T.push(A.outputColorSpace),T.push(A.envMapMode),T.push(A.envMapCubeUVHeight),T.push(A.mapUv),T.push(A.alphaMapUv),T.push(A.lightMapUv),T.push(A.aoMapUv),T.push(A.bumpMapUv),T.push(A.normalMapUv),T.push(A.displacementMapUv),T.push(A.emissiveMapUv),T.push(A.metalnessMapUv),T.push(A.roughnessMapUv),T.push(A.anisotropyMapUv),T.push(A.clearcoatMapUv),T.push(A.clearcoatNormalMapUv),T.push(A.clearcoatRoughnessMapUv),T.push(A.iridescenceMapUv),T.push(A.iridescenceThicknessMapUv),T.push(A.sheenColorMapUv),T.push(A.sheenRoughnessMapUv),T.push(A.specularMapUv),T.push(A.specularColorMapUv),T.push(A.specularIntensityMapUv),T.push(A.transmissionMapUv),T.push(A.thicknessMapUv),T.push(A.combine),T.push(A.fogExp2),T.push(A.sizeAttenuation),T.push(A.morphTargetsCount),T.push(A.morphAttributeCount),T.push(A.numSunLights),T.push(A.numDirLights),T.push(A.numPointLights),T.push(A.numSpotLights),T.push(A.numSpotLightMaps),T.push(A.numHemiLights),T.push(A.numRectAreaLights),T.push(A.numSunLightShadows),T.push(A.numDirLightShadows),T.push(A.numPointLightShadows),T.push(A.numSpotLightShadows),T.push(A.numSpotLightShadowsWithMaps),T.push(A.numLightProbes),T.push(A.shadowMapType),T.push(A.toneMapping),T.push(A.numClippingPlanes),T.push(A.numClipIntersection),T.push(A.depthPacking)}function x(T,A){if(a.disableAll(),A.instancing)a.enable(0);if(A.instancingColor)a.enable(1);if(A.instancingMorph)a.enable(2);if(A.matcap)a.enable(3);if(A.envMap)a.enable(4);if(A.normalMapObjectSpace)a.enable(5);if(A.normalMapTangentSpace)a.enable(6);if(A.clearcoat)a.enable(7);if(A.iridescence)a.enable(8);if(A.alphaTest)a.enable(9);if(A.vertexColors)a.enable(10);if(A.vertexAlphas)a.enable(11);if(A.vertexUv1s)a.enable(12);if(A.vertexUv2s)a.enable(13);if(A.vertexUv3s)a.enable(14);if(A.vertexTangents)a.enable(15);if(A.anisotropy)a.enable(16);if(A.alphaHash)a.enable(17);if(A.batching)a.enable(18);if(A.dispersion)a.enable(19);if(A.retroreflection)a.enable(24);if(A.batchingColor)a.enable(20);if(A.gradientMap)a.enable(21);if(A.packedNormalMap)a.enable(22);if(A.vertexNormals)a.enable(23);if(T.push(a.mask),a.disableAll(),A.fog)a.enable(0);if(A.useFog)a.enable(1);if(A.flatShading)a.enable(2);if(A.logarithmicDepthBuffer)a.enable(3);if(A.reversedDepthBuffer)a.enable(4);if(A.skinning)a.enable(5);if(A.morphTargets)a.enable(6);if(A.morphNormals)a.enable(7);if(A.morphColors)a.enable(8);if(A.premultipliedAlpha)a.enable(9);if(A.shadowMapEnabled)a.enable(10);if(A.doubleSided)a.enable(11);if(A.flipSided)a.enable(12);if(A.useDepthPacking)a.enable(13);if(A.dithering)a.enable(14);if(A.transmission)a.enable(15);if(A.sheen)a.enable(16);if(A.opaque)a.enable(17);if(A.pointsUvs)a.enable(18);if(A.decodeVideoTexture)a.enable(19);if(A.decodeVideoTextureEmissive)a.enable(20);if(A.alphaToCoverage)a.enable(21);if(A.numLightProbeGrids>0)a.enable(22);if(A.hasPositionAttribute)a.enable(23);T.push(a.mask)}function _(T){let A=h[T.type],P;if(A){let S=br[A];P=JT.clone(S.uniforms)}else P=T.uniforms;return P}function y(T,A){let P=u.get(A);if(P!==void 0)++P.usedTimes;else P=new BL(e,A,T,r),l.push(P),u.set(A,P);return P}function v(T){if(--T.usedTimes===0){let A=l.indexOf(T);l[A]=l[l.length-1],l.pop(),u.delete(T.cacheKey),T.destroy()}}function E(T){o.remove(T)}function w(){o.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:_,acquireProgram:y,releaseProgram:v,releaseShaderCache:E,programs:l,dispose:w}}function HL(){let e=new WeakMap;function t(a){return e.has(a)}function n(a){let o=e.get(a);if(o===void 0)o={},e.set(a,o);return o}function i(a){e.delete(a)}function r(a,o,c){e.get(a)[o]=c}function s(){e=new WeakMap}return{has:t,get:n,remove:i,update:r,dispose:s}}function GL(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 vA(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 EA(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function a(f){let h=0;if(f.isInstancedMesh)h+=2;if(f.isSkinnedMesh)h+=1;return h}function o(f,h,b,m,g,p){let x=e[t];if(x===void 0)x={id:f.id,object:f,geometry:h,material:b,materialVariant:a(f),groupOrder:m,renderOrder:f.renderOrder,z:g,group:p},e[t]=x;else x.id=f.id,x.object=f,x.geometry=h,x.material=b,x.materialVariant=a(f),x.groupOrder=m,x.renderOrder=f.renderOrder,x.z=g,x.group=p;return t++,x}function c(f,h,b,m,g,p,x){if(x.reversedDepth===!0)g=-g;let _=o(f,h,b,m,g,p);if(b.transmission>0)i.push(_);else if(b.transparent===!0)r.push(_);else n.push(_)}function l(f,h,b,m,g,p){let x=o(f,h,b,m,g,p);if(b.transmission>0)i.unshift(x);else if(b.transparent===!0)r.unshift(x);else n.unshift(x)}function u(f,h){if(n.length>1)n.sort(f||GL);if(i.length>1)i.sort(h||vA);if(r.length>1)r.sort(h||vA)}function d(){for(let f=t,h=e.length;f<h;f++){let b=e[f];if(b.id===null)break;b.id=null,b.object=null,b.geometry=null,b.material=null,b.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function $L(){let e=new WeakMap;function t(i,r){let s=e.get(i),a;if(s===void 0)a=new EA,e.set(i,[a]);else if(r>=s.length)a=new EA,s.push(a);else a=s[r];return a}function n(){e=new WeakMap}return{get:t,dispose:n}}function KL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new j,color:new qe};break;case"SpotLight":n={position:new j,direction:new j,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new j,color:new qe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new j,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":n={color:new qe,position:new j,halfWidth:new j,halfHeight:new j};break}return e[t.id]=n,n}}}function WL(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ke,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}function qL(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function JL(e){let t=new KL,n=WL(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new j);let r=new j,s=new Je,a=new Je;function o(l){let u=0,d=0,f=0;for(let R=0;R<9;R++)i.probe[R].set(0,0,0);let h=0,b=0,m=0,g=0,p=0,x=0,_=0,y=0,v=0,E=0,w=0,T=0,A=0,P=0;l.sort(qL);for(let R=0,k=l.length;R<k;R++){let C=l[R],{color:U,intensity:L,distance:O}=C,K=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===wa)K=C.shadow.map.texture;else K=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=U.r*L,d+=U.g*L,f+=U.b*L;else if(C.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(C.sh.coefficients[B],L);P++}else if(C.isSunLight){let B=t.get(C);if(B.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let X=C.shadow,q=n.get(C);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize.copy(X.mapSize).multiply(X.getFrameExtents()),i.sunShadow[b]=q,i.sunShadowMap[b]=K;let le=X.getViewportCount();for(let de=0;de<le;de++)i.sunShadowMatrix[m+de]=X.getMatrix(de),i.sunShadowCascade[m+de]=X._cascadeData[de];m+=le,b++}i.sun[h]=B,h++}else if(C.isDirectionalLight){let B=t.get(C);if(B.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let X=C.shadow,q=n.get(C);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.directionalShadow[g]=q,i.directionalShadowMap[g]=K,i.directionalShadowMatrix[g]=C.shadow.matrix,v++}i.directional[g]=B,g++}else if(C.isSpotLight){let B=t.get(C);B.position.setFromMatrixPosition(C.matrixWorld),B.color.copy(U).multiplyScalar(L),B.distance=O,B.coneCos=Math.cos(C.angle),B.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),B.decay=C.decay,i.spot[x]=B;let X=C.shadow;if(C.map){if(i.spotLightMap[T]=C.map,T++,X.updateMatrices(C),C.castShadow)A++}if(i.spotLightMatrix[x]=X.matrix,C.castShadow){let q=n.get(C);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,i.spotShadow[x]=q,i.spotShadowMap[x]=K,w++}x++}else if(C.isRectAreaLight){let B=t.get(C);B.color.copy(U).multiplyScalar(L),B.halfWidth.set(C.width*0.5,0,0),B.halfHeight.set(0,C.height*0.5,0),i.rectArea[_]=B,_++}else if(C.isPointLight){let B=t.get(C);if(B.color.copy(C.color).multiplyScalar(C.intensity),B.distance=C.distance,B.decay=C.decay,C.castShadow){let X=C.shadow,q=n.get(C);q.shadowIntensity=X.intensity,q.shadowBias=X.bias,q.shadowNormalBias=X.normalBias,q.shadowRadius=X.radius,q.shadowMapSize=X.mapSize,q.shadowCameraNear=X.camera.near,q.shadowCameraFar=X.camera.far,i.pointShadow[p]=q,i.pointShadowMap[p]=K,i.pointShadowMatrix[p]=C.shadow.matrix,E++}i.point[p]=B,p++}else if(C.isHemisphereLight){let B=t.get(C);B.skyColor.copy(C.color).multiplyScalar(L),B.groundColor.copy(C.groundColor).multiplyScalar(L),i.hemi[y]=B,y++}}if(_>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=Te.LTC_FLOAT_1,i.rectAreaLTC2=Te.LTC_FLOAT_2;else i.rectAreaLTC1=Te.LTC_HALF_1,i.rectAreaLTC2=Te.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=f;let S=i.hash;if(S.sunLength!==h||S.directionalLength!==g||S.pointLength!==p||S.spotLength!==x||S.rectAreaLength!==_||S.hemiLength!==y||S.numSunShadows!==b||S.numDirectionalShadows!==v||S.numPointShadows!==E||S.numSpotShadows!==w||S.numSpotMaps!==T||S.numLightProbes!==P)i.sun.length=h,i.directional.length=g,i.spot.length=x,i.rectArea.length=_,i.point.length=p,i.hemi.length=y,i.sunShadow.length=b,i.sunShadowMap.length=b,i.sunShadowMatrix.length=m,i.sunShadowCascade.length=m,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.directionalShadowMatrix.length=v,i.pointShadow.length=E,i.pointShadowMap.length=E,i.pointShadowMatrix.length=E,i.spotShadow.length=w,i.spotShadowMap.length=w,i.spotLightMatrix.length=w+T-A,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=A,i.numLightProbes=P,S.sunLength=h,S.directionalLength=g,S.pointLength=p,S.spotLength=x,S.rectAreaLength=_,S.hemiLength=y,S.numSunShadows=b,S.numDirectionalShadows=v,S.numPointShadows=E,S.numSpotShadows=w,S.numSpotMaps=T,S.numLightProbes=P,i.version=XL++}function c(l,u){let d=0,f=0,h=0,b=0,m=0,g=0,p=u.matrixWorldInverse;for(let x=0,_=l.length;x<_;x++){let y=l[x];if(y.isSunLight){let v=i.sun[d];v.direction.setFromMatrixPosition(y.matrixWorld),v.direction.transformDirection(p),d++}else if(y.isDirectionalLight){let v=i.directional[f];v.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),f++}else if(y.isSpotLight){let v=i.spot[b];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),v.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),v.direction.sub(r),v.direction.transformDirection(p),b++}else if(y.isRectAreaLight){let v=i.rectArea[m];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),a.identity(),s.copy(y.matrixWorld),s.premultiply(p),a.extractRotation(s),v.halfWidth.set(y.width*0.5,0,0),v.halfHeight.set(0,y.height*0.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),m++}else if(y.isPointLight){let v=i.point[h];v.position.setFromMatrixPosition(y.matrixWorld),v.position.applyMatrix4(p),h++}else if(y.isHemisphereLight){let v=i.hemi[g];v.direction.setFromMatrixPosition(y.matrixWorld),v.direction.transformDirection(p),g++}}}return{setup:o,setupView:c,state:i}}function TA(e){let t=new JL(e),n=[],i=[],r=[];function s(f){d.camera=f,n.length=0,i.length=0,r.length=0}function a(f){n.push(f)}function o(f){i.push(f)}function c(f){r.push(f)}function l(){t.setup(n)}function u(f){t.setupView(n,f)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function ZL(e){let t=new WeakMap;function n(r,s=0){let a=t.get(r),o;if(a===void 0)o=new TA(e),t.set(r,[o]);else if(s>=a.length)o=new TA(e),a.push(o);else o=a[s];return o}function i(){t=new WeakMap}return{get:n,dispose:i}}function n8(e,t,n){let i=new ol,r=new Ke,s=new Ke,a=new Pt,o=new Vm,c=new jm,l={},u=n.maxTextureSize,d={[fs]:Dn,[Dn]:fs,[vi]:vi},f=new Ei({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ke},radius:{value:4}},vertexShader:YL,fragmentShader:QL}),h=f.clone();h.defines.HORIZONTAL_PASS=1;let b=new Ln;b.setAttribute("position",new En(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let m=new jt(b,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xc;let p=this.type;this.render=function(E,w,T){if(g.enabled===!1)return;if(g.autoUpdate===!1&&g.needsUpdate===!1)return;if(E.length===0)return;if(this.type===eT)je("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Xc;let A=e.getRenderTarget(),P=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),R=e.state;if(R.setBlending(dr),R.buffers.depth.getReversed()===!0)R.buffers.color.setClear(0,0,0,0);else R.buffers.color.setClear(1,1,1,1);R.buffers.depth.setTest(!0),R.setScissorTest(!1);let k=p!==this.type;if(k)w.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((U)=>U.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,U=E.length;C<U;C++){let L=E[C],O=L.shadow;if(O===void 0){je("WebGLShadowMap:",L,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;r.copy(O.mapSize);let K=O.getFrameExtents();if(r.multiply(K),s.copy(O.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/K.x),r.x=s.x*K.x,O.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/K.y),r.y=s.y*K.y,O.mapSize.y=s.y}let B=e.state.buffers.depth.getReversed();if(O.camera._reversedDepth=B,O.map===null||k===!0){if(O.map!==null){if(O.map.depthTexture!==null)O.map.depthTexture.dispose(),O.map.depthTexture=null;O.map.dispose()}if(this.type===Ao){if(L.isPointLight){je("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}O.map=new li(r.x,r.y,{format:wa,type:hr,minFilter:Tn,magFilter:Tn,generateMipmaps:!1}),O.map.texture.name=L.name+".shadowMap",O.map.depthTexture=new Ma(r.x,r.y,Br),O.map.depthTexture.name=L.name+".shadowMapDepth",O.map.depthTexture.format=Ta,O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Bi,O.map.depthTexture.magFilter=Bi}else{if(L.isPointLight)O.map=new dg(r.x),O.map.depthTexture=new Um(r.x,hs);else O.map=new li(r.x,r.y),O.map.depthTexture=new Ma(r.x,r.y,hs);if(O.map.depthTexture.name=L.name+".shadowMap",O.map.depthTexture.format=Ta,this.type===Xc)O.map.depthTexture.compareFunction=B?wd:Ad,O.map.depthTexture.minFilter=Tn,O.map.depthTexture.magFilter=Tn;else O.map.depthTexture.compareFunction=null,O.map.depthTexture.minFilter=Bi,O.map.depthTexture.magFilter=Bi}O.camera.updateProjectionMatrix()}if(O.map.isWebGLCubeRenderTarget!==!0&&(O.map.width!==r.x||O.map.height!==r.y))O.map.setSize(r.x,r.y);let X=O.map.isWebGLCubeRenderTarget?6:O.getViewportCount();if(L.isPointLight!==!0)O.updateMatrices(L,T);for(let q=0;q<X;q++){let le=O.getCamera(q);if(L.isPointLight){let{camera:de,matrix:Me}=O,pe=L.distance||de.far;if(pe!==de.far)de.far=pe,de.updateProjectionMatrix();gl.setFromMatrixPosition(L.matrixWorld),de.position.copy(gl),cg.copy(de.position),cg.add(e8[q]),de.up.copy(t8[q]),de.lookAt(cg),de.updateMatrixWorld(),Me.makeTranslation(-gl.x,-gl.y,-gl.z),AA.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),O._frustum.setFromProjectionMatrix(AA,de.coordinateSystem,de.reversedDepth)}if(O.map.isWebGLCubeRenderTarget)e.setRenderTarget(O.map,q),e.clear();else{if(q===0)e.setRenderTarget(O.map),e.clear();let de=O.getViewport(q);a.set(s.x*de.x,s.y*de.y,s.x*de.z,s.y*de.w),R.viewport(a)}i=O.getFrustum(q),y(w,T,le,L,this.type)}if(O.isPointLightShadow!==!0&&this.type===Ao)x(O,T);O.needsUpdate=!1}p=this.type,g.needsUpdate=!1,e.setRenderTarget(A,P,S)};function x(E,w){let T=t.update(m);if(f.defines.VSM_SAMPLES!==E.blurSamples)f.defines.VSM_SAMPLES=E.blurSamples,h.defines.VSM_SAMPLES=E.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new li(r.x,r.y,{format:wa,type:hr});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);f.uniforms.shadow_pass.value=E.map.depthTexture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(w,null,T,f,m,null),h.uniforms.shadow_pass.value=E.mapPass.texture,h.uniforms.resolution.value.set(E.map.width,E.map.height),h.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(w,null,T,h,m,null)}function _(E,w,T,A){let P=null,S=T.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(S!==void 0)P=S;else if(P=T.isPointLight===!0?c:o,e.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){let R=P.uuid,k=w.uuid,C=l[R];if(C===void 0)C={},l[R]=C;let U=C[k];if(U===void 0)U=P.clone(),C[k]=U,w.addEventListener("dispose",v);P=U}if(P.visible=w.visible,P.wireframe=w.wireframe,A===Ao)P.side=w.shadowSide!==null?w.shadowSide:w.side;else P.side=w.shadowSide!==null?w.shadowSide:d[w.side];if(P.alphaMap=w.alphaMap,P.alphaTest=w.alphaToCoverage===!0?0.5:w.alphaTest,P.map=w.map,P.clipShadows=w.clipShadows,P.clippingPlanes=w.clippingPlanes,P.clipIntersection=w.clipIntersection,P.displacementMap=w.displacementMap,P.displacementScale=w.displacementScale,P.displacementBias=w.displacementBias,P.wireframeLinewidth=w.wireframeLinewidth,P.linewidth=w.linewidth,T.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let R=e.properties.get(P);R.light=T}return P}function y(E,w,T,A,P){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&P===Ao)&&(!E.frustumCulled||E.intersectsFrustum(i))){E.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,E.matrixWorld);let k=t.update(E),C=E.material;if(Array.isArray(C)){let U=k.groups;for(let L=0,O=U.length;L<O;L++){let K=U[L],B=C[K.materialIndex];if(B&&B.visible){let X=_(E,B,A,P);E.onBeforeShadow(e,E,w,T,k,X,K),e.renderBufferDirect(T,null,k,X,E,K),E.onAfterShadow(e,E,w,T,k,X,K)}}}else if(C.visible){let U=_(E,C,A,P);E.onBeforeShadow(e,E,w,T,k,U,null),e.renderBufferDirect(T,null,k,U,E,null),E.onAfterShadow(e,E,w,T,k,U,null)}}}let R=E.children;for(let k=0,C=R.length;k<C;k++)y(R[k],w,T,A,P)}function v(E){E.target.removeEventListener("dispose",v);for(let T in l){let A=l[T],P=E.target.uuid;if(P in A)A[P].dispose(),delete A[P]}}}function i8(e,t){function n(){let G=!1,xe=new Pt,ae=null,ye=new Pt(0,0,0,0);return{setMask:function(Ce){if(ae!==Ce&&!G)e.colorMask(Ce,Ce,Ce,Ce),ae=Ce},setLocked:function(Ce){G=Ce},setClear:function(Ce,fe,Ae,it,zt){if(zt===!0)Ce*=it,fe*=it,Ae*=it;if(xe.set(Ce,fe,Ae,it),ye.equals(xe)===!1)e.clearColor(Ce,fe,Ae,it),ye.copy(xe)},reset:function(){G=!1,ae=null,ye.set(-1,0,0,0)}}}function i(){let G=!1,xe=!1,ae=null,ye=null,Ce=null;return{setReversed:function(fe){if(xe!==fe){let Ae=t.get("EXT_clip_control");if(fe)Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT);else Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT);xe=fe;let it=Ce;Ce=null,this.setClear(it)}},getReversed:function(){return xe},setTest:function(fe){if(fe)W(e.DEPTH_TEST);else ne(e.DEPTH_TEST)},setMask:function(fe){if(ae!==fe&&!G)e.depthMask(fe),ae=fe},setFunc:function(fe){if(xe)fe=XT[fe];if(ye!==fe){switch(fe){case vT:e.depthFunc(e.NEVER);break;case ET:e.depthFunc(e.ALWAYS);break;case TT:e.depthFunc(e.LESS);break;case Bp:e.depthFunc(e.LEQUAL);break;case AT:e.depthFunc(e.EQUAL);break;case wT:e.depthFunc(e.GEQUAL);break;case ST:e.depthFunc(e.GREATER);break;case MT:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}ye=fe}},setLocked:function(fe){G=fe},setClear:function(fe){if(Ce!==fe){if(Ce=fe,xe)fe=1-fe;e.clearDepth(fe)}},reset:function(){G=!1,ae=null,ye=null,Ce=null,xe=!1}}}function r(){let G=!1,xe=null,ae=null,ye=null,Ce=null,fe=null,Ae=null,it=null,zt=null;return{setTest:function(Mt){if(!G)if(Mt)W(e.STENCIL_TEST);else ne(e.STENCIL_TEST)},setMask:function(Mt){if(xe!==Mt&&!G)e.stencilMask(Mt),xe=Mt},setFunc:function(Mt,Xi,wr){if(ae!==Mt||ye!==Xi||Ce!==wr)e.stencilFunc(Mt,Xi,wr),ae=Mt,ye=Xi,Ce=wr},setOp:function(Mt,Xi,wr){if(fe!==Mt||Ae!==Xi||it!==wr)e.stencilOp(Mt,Xi,wr),fe=Mt,Ae=Xi,it=wr},setLocked:function(Mt){G=Mt},setClear:function(Mt){if(zt!==Mt)e.clearStencil(Mt),zt=Mt},reset:function(){G=!1,xe=null,ae=null,ye=null,Ce=null,fe=null,Ae=null,it=null,zt=null}}}let s=new n,a=new i,o=new r,c=new WeakMap,l=new WeakMap,u={},d={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,x=null,_=null,y=null,v=null,E=null,w=null,T=new qe(0,0,0),A=0,P=!1,S=null,R=null,k=null,C=null,U=null,L=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,K=0,B=e.getParameter(e.VERSION);if(B.indexOf("WebGL")!==-1)K=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=K>=1;else if(B.indexOf("OpenGL ES")!==-1)K=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=K>=2;let X=null,q={},le=e.getParameter(e.SCISSOR_BOX),de=e.getParameter(e.VIEWPORT),Me=new Pt().fromArray(le),pe=new Pt().fromArray(de);function J(G,xe,ae,ye){let Ce=new Uint8Array(4),fe=e.createTexture();e.bindTexture(G,fe),e.texParameteri(G,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(G,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let Ae=0;Ae<ae;Ae++)if(G===e.TEXTURE_3D||G===e.TEXTURE_2D_ARRAY)e.texImage3D(xe,0,e.RGBA,1,1,ye,0,e.RGBA,e.UNSIGNED_BYTE,Ce);else e.texImage2D(xe+Ae,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Ce);return fe}let F={};F[e.TEXTURE_2D]=J(e.TEXTURE_2D,e.TEXTURE_2D,1),F[e.TEXTURE_CUBE_MAP]=J(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),F[e.TEXTURE_2D_ARRAY]=J(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),F[e.TEXTURE_3D]=J(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),W(e.DEPTH_TEST),a.setFunc(Bp),Wt(!1),lt(Dp),W(e.CULL_FACE),We(dr);function W(G){if(u[G]!==!0)e.enable(G),u[G]=!0}function ne(G){if(u[G]!==!1)e.disable(G),u[G]=!1}function ie(G,xe){if(f[G]!==xe){if(e.bindFramebuffer(G,xe),f[G]=xe,G===e.DRAW_FRAMEBUFFER)f[e.FRAMEBUFFER]=xe;if(G===e.FRAMEBUFFER)f[e.DRAW_FRAMEBUFFER]=xe;return!0}return!1}function ce(G,xe){let ae=b,ye=!1;if(G){if(ae=h.get(xe),ae===void 0)ae=[],h.set(xe,ae);let Ce=G.textures;if(ae.length!==Ce.length||ae[0]!==e.COLOR_ATTACHMENT0){for(let fe=0,Ae=Ce.length;fe<Ae;fe++)ae[fe]=e.COLOR_ATTACHMENT0+fe;ae.length=Ce.length,ye=!0}}else if(ae[0]!==e.BACK)ae[0]=e.BACK,ye=!0;if(ye)e.drawBuffers(ae)}function _e(G){if(m!==G)return e.useProgram(G),m=G,!0;return!1}let Re={[wo]:e.FUNC_ADD,[nT]:e.FUNC_SUBTRACT,[iT]:e.FUNC_REVERSE_SUBTRACT};Re[rT]=e.MIN,Re[sT]=e.MAX;let ke={[aT]:e.ZERO,[oT]:e.ONE,[cT]:e.SRC_COLOR,[uT]:e.SRC_ALPHA,[gT]:e.SRC_ALPHA_SATURATE,[pT]:e.DST_COLOR,[fT]:e.DST_ALPHA,[lT]:e.ONE_MINUS_SRC_COLOR,[dT]:e.ONE_MINUS_SRC_ALPHA,[mT]:e.ONE_MINUS_DST_COLOR,[hT]:e.ONE_MINUS_DST_ALPHA,[bT]:e.CONSTANT_COLOR,[xT]:e.ONE_MINUS_CONSTANT_COLOR,[yT]:e.CONSTANT_ALPHA,[_T]:e.ONE_MINUS_CONSTANT_ALPHA};function We(G,xe,ae,ye,Ce,fe,Ae,it,zt,Mt){if(G===dr){if(g===!0)ne(e.BLEND),g=!1;return}if(g===!1)W(e.BLEND),g=!0;if(G!==tT){if(G!==p||Mt!==P){if(x!==wo||v!==wo)e.blendEquation(e.FUNC_ADD),x=wo,v=wo;if(Mt)switch(G){case qc:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Lp:e.blendFunc(e.ONE,e.ONE);break;case Fp:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Up:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Ye("WebGLState: Invalid blending: ",G);break}else switch(G){case qc:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Lp:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Fp:Ye("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Up:Ye("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ye("WebGLState: Invalid blending: ",G);break}_=null,y=null,E=null,w=null,T.set(0,0,0),A=0,p=G,P=Mt}return}if(Ce=Ce||xe,fe=fe||ae,Ae=Ae||ye,xe!==x||Ce!==v)e.blendEquationSeparate(Re[xe],Re[Ce]),x=xe,v=Ce;if(ae!==_||ye!==y||fe!==E||Ae!==w)e.blendFuncSeparate(ke[ae],ke[ye],ke[fe],ke[Ae]),_=ae,y=ye,E=fe,w=Ae;if(it.equals(T)===!1||zt!==A)e.blendColor(it.r,it.g,it.b,zt),T.copy(it),A=zt;p=G,P=!1}function Qe(G,xe){G.side===vi?ne(e.CULL_FACE):W(e.CULL_FACE);let ae=G.side===Dn;if(xe)ae=!ae;Wt(ae),G.blending===qc&&G.transparent===!1?We(dr):We(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.blendColor,G.blendAlpha,G.premultipliedAlpha),a.setFunc(G.depthFunc),a.setTest(G.depthTest),a.setMask(G.depthWrite),s.setMask(G.colorWrite);let ye=G.stencilWrite;if(o.setTest(ye),ye)o.setMask(G.stencilWriteMask),o.setFunc(G.stencilFunc,G.stencilRef,G.stencilFuncMask),o.setOp(G.stencilFail,G.stencilZFail,G.stencilZPass);Qt(G.polygonOffset,G.polygonOffsetFactor,G.polygonOffsetUnits),G.alphaToCoverage===!0?W(e.SAMPLE_ALPHA_TO_COVERAGE):ne(e.SAMPLE_ALPHA_TO_COVERAGE)}function Wt(G){if(S!==G){if(G)e.frontFace(e.CW);else e.frontFace(e.CCW);S=G}}function lt(G){if(G!==YE){if(W(e.CULL_FACE),G!==R)if(G===Dp)e.cullFace(e.BACK);else if(G===QE)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else ne(e.CULL_FACE);R=G}function Lt(G){if(G!==k){if(O)e.lineWidth(G);k=G}}function Qt(G,xe,ae){if(G){if(W(e.POLYGON_OFFSET_FILL),C!==xe||U!==ae){if(C=xe,U=ae,a.getReversed())xe=-xe;e.polygonOffset(xe,ae)}}else ne(e.POLYGON_OFFSET_FILL)}function nn(G){if(G)W(e.SCISSOR_TEST);else ne(e.SCISSOR_TEST)}function z(G){if(G===void 0)G=e.TEXTURE0+L-1;if(X!==G)e.activeTexture(G),X=G}function _n(G,xe,ae){if(ae===void 0)if(X===null)ae=e.TEXTURE0+L-1;else ae=X;let ye=q[ae];if(ye===void 0)ye={type:void 0,texture:void 0},q[ae]=ye;if(ye.type!==G||ye.texture!==xe){if(X!==ae)e.activeTexture(ae),X=ae;e.bindTexture(G,xe||F[G]),ye.type=G,ye.texture=xe}}function St(){let G=q[X];if(G!==void 0&&G.type!==void 0)e.bindTexture(G.type,null),G.type=void 0,G.texture=void 0}function Xt(){try{e.compressedTexImage2D(...arguments)}catch(G){Ye("WebGLState:",G)}}function N(){try{e.compressedTexImage3D(...arguments)}catch(G){Ye("WebGLState:",G)}}function M(){try{e.texSubImage2D(...arguments)}catch(G){Ye("WebGLState:",G)}}function V(){try{e.texSubImage3D(...arguments)}catch(G){Ye("WebGLState:",G)}}function ee(){try{e.compressedTexSubImage2D(...arguments)}catch(G){Ye("WebGLState:",G)}}function he(){try{e.compressedTexSubImage3D(...arguments)}catch(G){Ye("WebGLState:",G)}}function ge(){try{e.texStorage2D(...arguments)}catch(G){Ye("WebGLState:",G)}}function ve(){try{e.texStorage3D(...arguments)}catch(G){Ye("WebGLState:",G)}}function re(){try{e.texImage2D(...arguments)}catch(G){Ye("WebGLState:",G)}}function oe(){try{e.texImage3D(...arguments)}catch(G){Ye("WebGLState:",G)}}function Ie(G){if(d[G]!==void 0)return d[G];else return e.getParameter(G)}function Ve(G,xe){if(d[G]!==xe)e.pixelStorei(G,xe),d[G]=xe}function Ee(G){if(Me.equals(G)===!1)e.scissor(G.x,G.y,G.z,G.w),Me.copy(G)}function me(G){if(pe.equals(G)===!1)e.viewport(G.x,G.y,G.z,G.w),pe.copy(G)}function Ge(G,xe){let ae=l.get(xe);if(ae===void 0)ae=new WeakMap,l.set(xe,ae);let ye=ae.get(G);if(ye===void 0)ye=e.getUniformBlockIndex(xe,G.name),ae.set(G,ye)}function Xe(G,xe){let ye=l.get(xe).get(G);if(c.get(xe)!==ye)e.uniformBlockBinding(xe,ye,G.__bindingPointIndex),c.set(xe,ye)}function vt(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),a.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},X=null,q={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,x=null,_=null,y=null,v=null,E=null,w=null,T=new qe(0,0,0),A=0,P=!1,S=null,R=null,k=null,C=null,U=null,Me.set(0,0,e.canvas.width,e.canvas.height),pe.set(0,0,e.canvas.width,e.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:W,disable:ne,bindFramebuffer:ie,drawBuffers:ce,useProgram:_e,setBlending:We,setMaterial:Qe,setFlipSided:Wt,setCullFace:lt,setLineWidth:Lt,setPolygonOffset:Qt,setScissorTest:nn,activeTexture:z,bindTexture:_n,unbindTexture:St,compressedTexImage2D:Xt,compressedTexImage3D:N,texImage2D:re,texImage3D:oe,pixelStorei:Ve,getParameter:Ie,updateUBOMapping:Ge,uniformBlockBinding:Xe,texStorage2D:ge,texStorage3D:ve,texSubImage2D:M,texSubImage3D:V,compressedTexSubImage2D:ee,compressedTexSubImage3D:he,scissor:Ee,viewport:me,reset:vt}}function r8(e,t,n,i,r,s,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ke,u=new WeakMap,d=new Set,f,h=new WeakMap,b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(N){}function m(N,M){return b?new OffscreenCanvas(N,M):vo("canvas")}function g(N,M,V){let ee=1,he=Xt(N);if(he.width>V||he.height>V)ee=V/Math.max(he.width,he.height);if(ee<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){let ge=Math.floor(ee*he.width),ve=Math.floor(ee*he.height);if(f===void 0)f=m(ge,ve);let re=M?m(ge,ve):f;return re.width=ge,re.height=ve,re.getContext("2d").drawImage(N,0,0,ge,ve),je("WebGLRenderer: Texture has been resized from ("+he.width+"x"+he.height+") to ("+ge+"x"+ve+")."),re}else{if("data"in N)je("WebGLRenderer: Image in DataTexture is too big ("+he.width+"x"+he.height+").");return N}return N}function p(N){return N.generateMipmaps}function x(N){e.generateMipmap(N)}function _(N){if(N.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(N.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(N,M,V,ee,he,ge=!1){if(N!==null){if(e[N]!==void 0)return e[N];je("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let ve;if(ee){if(ve=t.get("EXT_texture_norm16"),!ve)je("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let re=M;if(M===e.RED){if(V===e.FLOAT)re=e.R32F;if(V===e.HALF_FLOAT)re=e.R16F;if(V===e.UNSIGNED_BYTE)re=e.R8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.R16_EXT;if(V===e.SHORT&&ve)re=ve.R16_SNORM_EXT}if(M===e.RED_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.R8UI;if(V===e.UNSIGNED_SHORT)re=e.R16UI;if(V===e.UNSIGNED_INT)re=e.R32UI;if(V===e.BYTE)re=e.R8I;if(V===e.SHORT)re=e.R16I;if(V===e.INT)re=e.R32I}if(M===e.RG){if(V===e.FLOAT)re=e.RG32F;if(V===e.HALF_FLOAT)re=e.RG16F;if(V===e.UNSIGNED_BYTE)re=e.RG8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RG16_EXT;if(V===e.SHORT&&ve)re=ve.RG16_SNORM_EXT}if(M===e.RG_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RG8UI;if(V===e.UNSIGNED_SHORT)re=e.RG16UI;if(V===e.UNSIGNED_INT)re=e.RG32UI;if(V===e.BYTE)re=e.RG8I;if(V===e.SHORT)re=e.RG16I;if(V===e.INT)re=e.RG32I}if(M===e.RGB_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGB8UI;if(V===e.UNSIGNED_SHORT)re=e.RGB16UI;if(V===e.UNSIGNED_INT)re=e.RGB32UI;if(V===e.BYTE)re=e.RGB8I;if(V===e.SHORT)re=e.RGB16I;if(V===e.INT)re=e.RGB32I}if(M===e.RGBA_INTEGER){if(V===e.UNSIGNED_BYTE)re=e.RGBA8UI;if(V===e.UNSIGNED_SHORT)re=e.RGBA16UI;if(V===e.UNSIGNED_INT)re=e.RGBA32UI;if(V===e.BYTE)re=e.RGBA8I;if(V===e.SHORT)re=e.RGBA16I;if(V===e.INT)re=e.RGBA32I}if(M===e.RGB){if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGB16_EXT;if(V===e.SHORT&&ve)re=ve.RGB16_SNORM_EXT;if(V===e.UNSIGNED_INT_5_9_9_9_REV)re=e.RGB9_E5;if(V===e.UNSIGNED_INT_10F_11F_11F_REV)re=e.R11F_G11F_B10F}if(M===e.RGBA){let oe=ge?Nm:ot.getTransfer(he);if(V===e.FLOAT)re=e.RGBA32F;if(V===e.HALF_FLOAT)re=e.RGBA16F;if(V===e.UNSIGNED_BYTE)re=oe===Bt?e.SRGB8_ALPHA8:e.RGBA8;if(V===e.UNSIGNED_SHORT&&ve)re=ve.RGBA16_EXT;if(V===e.SHORT&&ve)re=ve.RGBA16_SNORM_EXT;if(V===e.UNSIGNED_SHORT_4_4_4_4)re=e.RGBA4;if(V===e.UNSIGNED_SHORT_5_5_5_1)re=e.RGB5_A1}if(re===e.R16F||re===e.R32F||re===e.RG16F||re===e.RG32F||re===e.RGBA16F||re===e.RGBA32F)t.get("EXT_color_buffer_float");return re}function v(N,M){let V;if(N){if(M===null||M===hs||M===Co)V=e.DEPTH24_STENCIL8;else if(M===Br)V=e.DEPTH32F_STENCIL8;else if(M===Yc)V=e.DEPTH24_STENCIL8,je("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(M===null||M===hs||M===Co)V=e.DEPTH_COMPONENT24;else if(M===Br)V=e.DEPTH_COMPONENT32F;else if(M===Yc)V=e.DEPTH_COMPONENT16;return V}function E(N,M){if(p(N)===!0||N.isFramebufferTexture&&N.minFilter!==Bi&&N.minFilter!==Tn)return Math.log2(Math.max(M.width,M.height))+1;else if(N.mipmaps!==void 0&&N.mipmaps.length>0)return N.mipmaps.length;else if(N.isCompressedTexture&&Array.isArray(N.image))return M.mipmaps.length;else return 1}function w(N){let M=N.target;if(M.removeEventListener("dispose",w),A(M),M.isVideoTexture)u.delete(M);if(M.isHTMLTexture)d.delete(M)}function T(N){let M=N.target;M.removeEventListener("dispose",T),S(M)}function A(N){let M=i.get(N);if(M.__webglInit===void 0)return;let V=N.source,ee=h.get(V);if(ee){let he=ee[M.__cacheKey];if(he.usedTimes--,he.usedTimes===0)P(N);if(Object.keys(ee).length===0)h.delete(V)}i.remove(N)}function P(N){let M=i.get(N);e.deleteTexture(M.__webglTexture);let V=N.source,ee=h.get(V);delete ee[M.__cacheKey],a.memory.textures--}function S(N){let M=i.get(N);if(N.depthTexture)N.depthTexture.dispose(),i.remove(N.depthTexture);if(N.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(M.__webglFramebuffer[ee]))for(let he=0;he<M.__webglFramebuffer[ee].length;he++)e.deleteFramebuffer(M.__webglFramebuffer[ee][he]);else e.deleteFramebuffer(M.__webglFramebuffer[ee]);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer[ee])}else{if(Array.isArray(M.__webglFramebuffer))for(let ee=0;ee<M.__webglFramebuffer.length;ee++)e.deleteFramebuffer(M.__webglFramebuffer[ee]);else e.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer)e.deleteRenderbuffer(M.__webglDepthbuffer);if(M.__webglMultisampledFramebuffer)e.deleteFramebuffer(M.__webglMultisampledFramebuffer);if(M.__webglColorRenderbuffer){for(let ee=0;ee<M.__webglColorRenderbuffer.length;ee++)if(M.__webglColorRenderbuffer[ee])e.deleteRenderbuffer(M.__webglColorRenderbuffer[ee])}if(M.__webglDepthRenderbuffer)e.deleteRenderbuffer(M.__webglDepthRenderbuffer)}let V=N.textures;for(let ee=0,he=V.length;ee<he;ee++){let ge=i.get(V[ee]);if(ge.__webglTexture)e.deleteTexture(ge.__webglTexture),a.memory.textures--;i.remove(V[ee])}i.remove(N)}let R=0;function k(){R=0}function C(){return R}function U(N){R=N}function L(){let N=R;if(N>=r.maxTextures)je("WebGLTextures: Trying to use "+(N+1)+" texture units while this GPU supports only "+r.maxTextures);return R+=1,N}function O(N){let M=[];return M.push(N.wrapS),M.push(N.wrapT),M.push(N.wrapR||0),M.push(N.magFilter),M.push(N.minFilter),M.push(N.anisotropy),M.push(N.internalFormat),M.push(N.format),M.push(N.type),M.push(N.generateMipmaps),M.push(N.premultiplyAlpha),M.push(N.flipY),M.push(N.unpackAlignment),M.push(N.colorSpace),M.join()}function K(N,M){let V=i.get(N);if(N.isVideoTexture)_n(N);if(N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&V.__version!==N.version){let ee=N.image;if(ee===null)je("WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)je("WebGLRenderer: Texture marked for update but image is incomplete");else{ne(V,N,M);return}}else if(N.isExternalTexture)V.__webglTexture=N.sourceTexture?N.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,V.__webglTexture,e.TEXTURE0+M)}function B(N,M){let V=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&V.__version!==N.version){ne(V,N,M);return}else if(N.isExternalTexture)V.__webglTexture=N.sourceTexture?N.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,V.__webglTexture,e.TEXTURE0+M)}function X(N,M){let V=i.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&V.__version!==N.version){ne(V,N,M);return}n.bindTexture(e.TEXTURE_3D,V.__webglTexture,e.TEXTURE0+M)}function q(N,M){let V=i.get(N);if(N.isCubeDepthTexture!==!0&&N.version>0&&V.__version!==N.version){ie(V,N,M);return}n.bindTexture(e.TEXTURE_CUBE_MAP,V.__webglTexture,e.TEXTURE0+M)}let le={[Mo]:e.REPEAT,[Ro]:e.CLAMP_TO_EDGE,[md]:e.MIRRORED_REPEAT},de={[Bi]:e.NEAREST,[gd]:e.NEAREST_MIPMAP_NEAREST,[Ea]:e.NEAREST_MIPMAP_LINEAR,[Tn]:e.LINEAR,[Io]:e.LINEAR_MIPMAP_NEAREST,[fr]:e.LINEAR_MIPMAP_LINEAR},Me={[BT]:e.NEVER,[GT]:e.ALWAYS,[zT]:e.LESS,[Ad]:e.LEQUAL,[VT]:e.EQUAL,[wd]:e.GEQUAL,[jT]:e.GREATER,[HT]:e.NOTEQUAL};function pe(N,M){if(M.type===Br&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Tn||M.magFilter===Io||M.magFilter===Ea||M.magFilter===fr||M.minFilter===Tn||M.minFilter===Io||M.minFilter===Ea||M.minFilter===fr))je("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(N,e.TEXTURE_WRAP_S,le[M.wrapS]),e.texParameteri(N,e.TEXTURE_WRAP_T,le[M.wrapT]),N===e.TEXTURE_3D||N===e.TEXTURE_2D_ARRAY)e.texParameteri(N,e.TEXTURE_WRAP_R,le[M.wrapR]);if(e.texParameteri(N,e.TEXTURE_MAG_FILTER,de[M.magFilter]),e.texParameteri(N,e.TEXTURE_MIN_FILTER,de[M.minFilter]),M.compareFunction)e.texParameteri(N,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(N,e.TEXTURE_COMPARE_FUNC,Me[M.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===Bi)return;if(M.minFilter!==Ea&&M.minFilter!==fr)return;if(M.type===Br&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||i.get(M).__currentAnisotropy){let V=t.get("EXT_texture_filter_anisotropic");e.texParameterf(N,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy}}}function J(N,M){let V=!1;if(N.__webglInit===void 0)N.__webglInit=!0,M.addEventListener("dispose",w);let ee=M.source,he=h.get(ee);if(he===void 0)he={},h.set(ee,he);let ge=O(M);if(ge!==N.__cacheKey){if(he[ge]===void 0)he[ge]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,V=!0;he[ge].usedTimes++;let ve=he[N.__cacheKey];if(ve!==void 0){if(he[N.__cacheKey].usedTimes--,ve.usedTimes===0)P(M)}N.__cacheKey=ge,N.__webglTexture=he[ge].texture}return V}function F(N,M,V){return Math.floor(Math.floor(N/V)/M)}function W(N,M,V,ee){let ge=N.updateRanges;if(ge.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,M.width,M.height,V,ee,M.data);else{ge.sort((Ve,Ee)=>Ve.start-Ee.start);let ve=0;for(let Ve=1;Ve<ge.length;Ve++){let Ee=ge[ve],me=ge[Ve],Ge=Ee.start+Ee.count,Xe=F(me.start,M.width,4),vt=F(Ee.start,M.width,4);if(me.start<=Ge+1&&Xe===vt&&F(me.start+me.count-1,M.width,4)===Xe)Ee.count=Math.max(Ee.count,me.start+me.count-Ee.start);else++ve,ge[ve]=me}ge.length=ve+1;let re=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ie=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,M.width);for(let Ve=0,Ee=ge.length;Ve<Ee;Ve++){let me=ge[Ve],Ge=Math.floor(me.start/4),Xe=Math.ceil(me.count/4),vt=Ge%M.width,G=Math.floor(Ge/M.width),xe=Xe,ae=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,vt),n.pixelStorei(e.UNPACK_SKIP_ROWS,G),n.texSubImage2D(e.TEXTURE_2D,0,vt,G,xe,1,V,ee,M.data)}N.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,re),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ie)}}function ne(N,M,V){let ee=e.TEXTURE_2D;if(M.isDataArrayTexture||M.isCompressedArrayTexture)ee=e.TEXTURE_2D_ARRAY;if(M.isData3DTexture)ee=e.TEXTURE_3D;let he=J(N,M),ge=M.source;n.bindTexture(ee,N.__webglTexture,e.TEXTURE0+V);let ve=i.get(ge);if(ge.version!==ve.__version||he===!0){if(n.activeTexture(e.TEXTURE0+V),(typeof ImageBitmap<"u"&&M.image instanceof ImageBitmap)===!1){let ae=ot.getPrimaries(ot.workingColorSpace),ye=M.colorSpace===Sa?null:ot.getPrimaries(M.colorSpace),Ce=M.colorSpace===Sa||ae===ye?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ce)}n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment);let oe=g(M.image,!1,r.maxTextureSize);oe=St(M,oe);let Ie=s.convert(M.format,M.colorSpace),Ve=s.convert(M.type),Ee=y(M.internalFormat,Ie,Ve,M.normalized,M.colorSpace,M.isVideoTexture);pe(ee,M);let me,Ge=M.mipmaps,Xe=M.isVideoTexture!==!0,vt=ve.__version===void 0||he===!0,G=ge.dataReady,xe=E(M,oe);if(M.isDepthTexture){if(Ee=v(M.format===Aa,M.type),vt)if(Xe)n.texStorage2D(e.TEXTURE_2D,1,Ee,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,null)}else if(M.isDataTexture)if(Ge.length>0){if(Xe&&vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,Ge[0].width,Ge[0].height);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data);M.generateMipmaps=!1}else if(Xe){if(vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,oe.width,oe.height);if(G)W(M,oe,Ie,Ve)}else n.texImage2D(e.TEXTURE_2D,0,Ee,oe.width,oe.height,0,Ie,Ve,oe.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){if(Xe&&vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,xe,Ee,Ge[0].width,Ge[0].height,oe.depth);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],M.format!==pr)if(Ie!==null)if(Xe){if(G)if(M.layerUpdates.size>0){let Ce=tg(me.width,me.height,M.format,M.type);for(let fe of M.layerUpdates){let Ae=me.data.subarray(fe*Ce/me.data.BYTES_PER_ELEMENT,(fe+1)*Ce/me.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,fe,me.width,me.height,1,Ie,Ae)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,me.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,me.data,0,0);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ae,0,0,0,me.width,me.height,oe.depth,Ie,Ve,me.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ae,Ee,me.width,me.height,oe.depth,0,Ie,Ve,me.data);if(M.layerUpdates.size>0)M.clearLayerUpdates()}else{if(Xe&&vt)n.texStorage2D(e.TEXTURE_2D,xe,Ee,Ge[0].width,Ge[0].height);for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],M.format!==pr)if(Ie!==null)if(Xe){if(G)n.compressedTexSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,me.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,me.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,me.width,me.height,Ie,Ve,me.data)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,me.width,me.height,0,Ie,Ve,me.data)}else if(M.isDataArrayTexture)if(Xe){if(vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,xe,Ee,oe.width,oe.height,oe.depth);if(G)if(M.layerUpdates.size>0){let ae=tg(oe.width,oe.height,M.format,M.type);for(let ye of M.layerUpdates){let Ce=oe.data.subarray(ye*ae/oe.data.BYTES_PER_ELEMENT,(ye+1)*ae/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,ye,oe.width,oe.height,1,Ie,Ve,Ce)}M.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isData3DTexture)if(Xe){if(vt)n.texStorage3D(e.TEXTURE_3D,xe,Ee,oe.width,oe.height,oe.depth);if(G)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ie,Ve,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,Ee,oe.width,oe.height,oe.depth,0,Ie,Ve,oe.data);else if(M.isFramebufferTexture){if(vt)if(Xe)n.texStorage2D(e.TEXTURE_2D,xe,Ee,oe.width,oe.height);else{let ae=oe.width,ye=oe.height;for(let Ce=0;Ce<xe;Ce++)n.texImage2D(e.TEXTURE_2D,Ce,Ee,ae,ye,0,Ie,Ve,null),ae>>=1,ye>>=1}}else if(M.isHTMLTexture){if("texElementImage2D"in e){let ae=e.canvas;if(!ae.hasAttribute("layoutsubtree"))ae.setAttribute("layoutsubtree","true");if(oe.parentNode!==ae){ae.appendChild(oe),d.add(M),ae.onpaint=(ye)=>{let Ce=ye.changedElements;for(let fe of d)if(Ce.includes(fe.image))fe.needsUpdate=!0},ae.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Ce,RGBA:fe,UNSIGNED_BYTE:Ae}=e;e.texElementImage2D(e.TEXTURE_2D,0,Ce,fe,Ae,oe)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Ge.length>0){if(Xe&&vt){let ae=Xt(Ge[0]);n.texStorage2D(e.TEXTURE_2D,xe,Ee,ae.width,ae.height)}for(let ae=0,ye=Ge.length;ae<ye;ae++)if(me=Ge[ae],Xe){if(G)n.texSubImage2D(e.TEXTURE_2D,ae,0,0,Ie,Ve,me)}else n.texImage2D(e.TEXTURE_2D,ae,Ee,Ie,Ve,me);M.generateMipmaps=!1}else if(Xe){if(vt){let ae=Xt(oe);n.texStorage2D(e.TEXTURE_2D,xe,Ee,ae.width,ae.height)}if(G)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ie,Ve,oe)}else n.texImage2D(e.TEXTURE_2D,0,Ee,Ie,Ve,oe);if(p(M))x(ee);if(ve.__version=ge.version,M.onUpdate)M.onUpdate(M)}N.__version=M.version}function ie(N,M,V){if(M.image.length!==6)return;let ee=J(N,M),he=M.source;n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+V);let ge=i.get(he);if(he.version!==ge.__version||ee===!0){n.activeTexture(e.TEXTURE0+V);let ve=ot.getPrimaries(ot.workingColorSpace),re=M.colorSpace===Sa?null:ot.getPrimaries(M.colorSpace),oe=M.colorSpace===Sa||ve===re?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,M.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,M.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,Ve=M.image[0]&&M.image[0].isDataTexture,Ee=[];for(let fe=0;fe<6;fe++){if(!Ie&&!Ve)Ee[fe]=g(M.image[fe],!0,r.maxCubemapSize);else Ee[fe]=Ve?M.image[fe].image:M.image[fe];Ee[fe]=St(M,Ee[fe])}let me=Ee[0],Ge=s.convert(M.format,M.colorSpace),Xe=s.convert(M.type),vt=y(M.internalFormat,Ge,Xe,M.normalized,M.colorSpace),G=M.isVideoTexture!==!0,xe=ge.__version===void 0||ee===!0,ae=he.dataReady,ye=E(M,me);pe(e.TEXTURE_CUBE_MAP,M);let Ce;if(Ie){if(G&&xe)n.texStorage2D(e.TEXTURE_CUBE_MAP,ye,vt,me.width,me.height);for(let fe=0;fe<6;fe++){Ce=Ee[fe].mipmaps;for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(M.format!==pr)if(Ge!==null)if(G){if(ae)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,it.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,vt,it.width,it.height,0,it.data);else je("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,0,0,it.width,it.height,Ge,Xe,it.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae,vt,it.width,it.height,0,Ge,Xe,it.data)}}}else{if(Ce=M.mipmaps,G&&xe){if(Ce.length>0)ye++;let fe=Xt(Ee[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,ye,vt,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(Ve){if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ee[fe].width,Ee[fe].height,Ge,Xe,Ee[fe].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,vt,Ee[fe].width,Ee[fe].height,0,Ge,Xe,Ee[fe].data);for(let Ae=0;Ae<Ce.length;Ae++){let zt=Ce[Ae].image[fe].image;if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,zt.width,zt.height,Ge,Xe,zt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,vt,zt.width,zt.height,0,Ge,Xe,zt.data)}}else{if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,Ge,Xe,Ee[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,vt,Ge,Xe,Ee[fe]);for(let Ae=0;Ae<Ce.length;Ae++){let it=Ce[Ae];if(G){if(ae)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,0,0,Ge,Xe,it.image[fe])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+fe,Ae+1,vt,Ge,Xe,it.image[fe])}}}if(p(M))x(e.TEXTURE_CUBE_MAP);if(ge.__version=he.version,M.onUpdate)M.onUpdate(M)}N.__version=M.version}function ce(N,M,V,ee,he,ge){let ve=s.convert(V.format,V.colorSpace),re=s.convert(V.type),oe=y(V.internalFormat,ve,re,V.normalized,V.colorSpace),Ie=i.get(M),Ve=i.get(V);if(Ve.__renderTarget=M,!Ie.__hasExternalTextures){let Ee=Math.max(1,M.width>>ge),me=Math.max(1,M.height>>ge);if(he===e.TEXTURE_3D||he===e.TEXTURE_2D_ARRAY)n.texImage3D(he,ge,oe,Ee,me,M.depth,0,ve,re,null);else n.texImage2D(he,ge,oe,Ee,me,0,ve,re,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,N),z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,ee,he,Ve.__webglTexture,0,nn(M));else if(he===e.TEXTURE_2D||he>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&he<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,ee,he,Ve.__webglTexture,ge);n.bindFramebuffer(e.FRAMEBUFFER,null)}function _e(N,M,V){if(e.bindRenderbuffer(e.RENDERBUFFER,N),M.depthBuffer){let ee=M.depthTexture,he=ee&&ee.isDepthTexture?ee.type:null,ge=v(M.stencilBuffer,he),ve=M.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(M),ge,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(M),ge,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,ge,M.width,M.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,ve,e.RENDERBUFFER,N)}else{let ee=M.textures;for(let he=0;he<ee.length;he++){let ge=ee[he],ve=s.convert(ge.format,ge.colorSpace),re=s.convert(ge.type),oe=y(ge.internalFormat,ve,re,ge.normalized,ge.colorSpace);if(z(M))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(M),oe,M.width,M.height);else if(V)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(M),oe,M.width,M.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,M.width,M.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Re(N,M,V){let ee=M.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,N),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let he=i.get(M.depthTexture);if(he.__renderTarget=M,!he.__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0;if(ee){if(he.__webglInit===void 0)he.__webglInit=!0,M.depthTexture.addEventListener("dispose",w);if(he.__webglTexture===void 0){he.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,he.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M.depthTexture);let Ie=s.convert(M.depthTexture.format),Ve=s.convert(M.depthTexture.type),Ee;if(M.depthTexture.format===Ta)Ee=e.DEPTH_COMPONENT24;else if(M.depthTexture.format===Aa)Ee=e.DEPTH24_STENCIL8;for(let me=0;me<6;me++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,Ee,M.width,M.height,0,Ie,Ve,null)}}else K(M.depthTexture,0);let ge=he.__webglTexture,ve=nn(M),re=ee?e.TEXTURE_CUBE_MAP_POSITIVE_X+V:e.TEXTURE_2D,oe=M.depthTexture.format===Aa?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(M.depthTexture.format===Ta)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else if(M.depthTexture.format===Aa)if(z(M))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,re,ge,0,ve);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,re,ge,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ke(N){let M=i.get(N),V=N.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==N.depthTexture){let ee=N.depthTexture;if(M.__depthDisposeCallback)M.__depthDisposeCallback();if(ee){let he=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,ee.removeEventListener("dispose",he)};ee.addEventListener("dispose",he),M.__depthDisposeCallback=he}M.__boundDepthTexture=ee}if(N.depthTexture&&!M.__autoAllocateDepthBuffer)if(V)for(let ee=0;ee<6;ee++)Re(M.__webglFramebuffer[ee],N,ee);else{let ee=N.texture.mipmaps;if(ee&&ee.length>0)Re(M.__webglFramebuffer[0],N,0);else Re(M.__webglFramebuffer,N,0)}else if(V){M.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)if(n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[ee]),M.__webglDepthbuffer[ee]===void 0)M.__webglDepthbuffer[ee]=e.createRenderbuffer(),_e(M.__webglDepthbuffer[ee],N,!1);else{let he=N.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer[ee];e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}else{let ee=N.texture.mipmaps;if(ee&&ee.length>0)n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,M.__webglFramebuffer);if(M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=e.createRenderbuffer(),_e(M.__webglDepthbuffer,N,!1);else{let he=N.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ge=M.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ge),e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,ge)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function We(N,M,V){let ee=i.get(N);if(M!==void 0)ce(ee.__webglFramebuffer,N,N.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(V!==void 0)ke(N)}function Qe(N){let M=N.texture,V=i.get(N),ee=i.get(M);N.addEventListener("dispose",T);let he=N.textures,ge=N.isWebGLCubeRenderTarget===!0,ve=he.length>1;if(!ve){if(ee.__webglTexture===void 0)ee.__webglTexture=e.createTexture();ee.__version=M.version,a.memory.textures++}if(ge){V.__webglFramebuffer=[];for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[re]=[];for(let oe=0;oe<M.mipmaps.length;oe++)V.__webglFramebuffer[re][oe]=e.createFramebuffer()}else V.__webglFramebuffer[re]=e.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer=[];for(let re=0;re<M.mipmaps.length;re++)V.__webglFramebuffer[re]=e.createFramebuffer()}else V.__webglFramebuffer=e.createFramebuffer();if(ve)for(let re=0,oe=he.length;re<oe;re++){let Ie=i.get(he[re]);if(Ie.__webglTexture===void 0)Ie.__webglTexture=e.createTexture(),a.memory.textures++}if(N.samples>0&&z(N)===!1){V.__webglMultisampledFramebuffer=e.createFramebuffer(),V.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let re=0;re<he.length;re++){let oe=he[re];V.__webglColorRenderbuffer[re]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,V.__webglColorRenderbuffer[re]);let Ie=s.convert(oe.format,oe.colorSpace),Ve=s.convert(oe.type),Ee=y(oe.internalFormat,Ie,Ve,oe.normalized,oe.colorSpace,N.isXRRenderTarget===!0),me=nn(N);e.renderbufferStorageMultisample(e.RENDERBUFFER,me,Ee,N.width,N.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+re,e.RENDERBUFFER,V.__webglColorRenderbuffer[re])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),N.depthBuffer)V.__webglDepthRenderbuffer=e.createRenderbuffer(),_e(V.__webglDepthRenderbuffer,N,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ge){n.bindTexture(e.TEXTURE_CUBE_MAP,ee.__webglTexture),pe(e.TEXTURE_CUBE_MAP,M);for(let re=0;re<6;re++)if(M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[re][oe],N,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,oe);else ce(V.__webglFramebuffer[re],N,M,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);if(p(M))x(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(ve){for(let re=0,oe=he.length;re<oe;re++){let Ie=he[re],Ve=i.get(Ie),Ee=e.TEXTURE_2D;if(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)Ee=N.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Ee,Ve.__webglTexture),pe(Ee,Ie),ce(V.__webglFramebuffer,N,Ie,e.COLOR_ATTACHMENT0+re,Ee,0),p(Ie))x(Ee)}n.unbindTexture()}else{let re=e.TEXTURE_2D;if(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)re=N.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(re,ee.__webglTexture),pe(re,M),M.mipmaps&&M.mipmaps.length>0)for(let oe=0;oe<M.mipmaps.length;oe++)ce(V.__webglFramebuffer[oe],N,M,e.COLOR_ATTACHMENT0,re,oe);else ce(V.__webglFramebuffer,N,M,e.COLOR_ATTACHMENT0,re,0);if(p(M))x(re);n.unbindTexture()}if(N.depthBuffer)ke(N)}function Wt(N){let M=N.textures;for(let V=0,ee=M.length;V<ee;V++){let he=M[V];if(p(he)){let ge=_(N),ve=i.get(he).__webglTexture;n.bindTexture(ge,ve),x(ge),n.unbindTexture()}}}let lt=[],Lt=[];function Qt(N){if(N.samples>0){if(z(N)===!1){let{textures:M,width:V,height:ee}=N,he=e.COLOR_BUFFER_BIT,ge=N.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ve=i.get(N),re=M.length>1;if(re)for(let Ie=0;Ie<M.length;Ie++)n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);let oe=N.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){if(N.resolveDepthBuffer){if(N.depthBuffer)he|=e.DEPTH_BUFFER_BIT;if(N.stencilBuffer&&N.resolveStencilBuffer)he|=e.STENCIL_BUFFER_BIT}if(re){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ve,0)}if(e.blitFramebuffer(0,0,V,ee,0,0,V,ee,he,e.NEAREST),c===!0){if(lt.length=0,Lt.length=0,lt.push(e.COLOR_ATTACHMENT0+Ie),N.depthBuffer&&N.storeMultisampledDepthBuffer===!1)lt.push(ge),Lt.push(ge),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Lt);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,lt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),re)for(let Ie=0;Ie<M.length;Ie++){n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,ve.__webglColorRenderbuffer[Ie]);let Ve=i.get(M[Ie]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,ve.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,Ve,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.storeMultisampledDepthBuffer===!1&&c){let M=N.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[M])}}}function nn(N){return Math.min(r.maxSamples,N.samples)}function z(N){let M=i.get(N);return N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function _n(N){let M=a.render.frame;if(u.get(N)!==M)u.set(N,M),N.update()}function St(N,M){let{colorSpace:V,format:ee,type:he}=N;if(N.isCompressedTexture===!0||N.isVideoTexture===!0)return M;if(V!==ci&&V!==Sa)if(ot.getTransfer(V)===Bt){if(ee!==pr||he!==zi)je("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Ye("WebGLTextures: Unsupported texture color space:",V);return M}function Xt(N){if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement)l.width=N.naturalWidth||N.width,l.height=N.naturalHeight||N.height;else if(typeof VideoFrame<"u"&&N instanceof VideoFrame)l.width=N.displayWidth,l.height=N.displayHeight;else l.width=N.width,l.height=N.height;return l}this.allocateTextureUnit=L,this.resetTextureUnits=k,this.getTextureUnits=C,this.setTextureUnits=U,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=X,this.setTextureCube=q,this.rebindTextures=We,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=Wt,this.updateMultisampleRenderTarget=Qt,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=z,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function s8(e,t){function n(i,r=Sa){let s,a=ot.getTransfer(r);if(i===zi)return e.UNSIGNED_BYTE;if(i===Wp)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Xp)return e.UNSIGNED_SHORT_5_5_5_1;if(i===OT)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===kT)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===NT)return e.BYTE;if(i===PT)return e.SHORT;if(i===Yc)return e.UNSIGNED_SHORT;if(i===Kp)return e.INT;if(i===hs)return e.UNSIGNED_INT;if(i===Br)return e.FLOAT;if(i===hr)return e.HALF_FLOAT;if(i===DT)return e.ALPHA;if(i===LT)return e.RGB;if(i===pr)return e.RGBA;if(i===Ta)return e.DEPTH_COMPONENT;if(i===Aa)return e.DEPTH_STENCIL;if(i===FT)return e.RED;if(i===qp)return e.RED_INTEGER;if(i===wa)return e.RG;if(i===Jp)return e.RG_INTEGER;if(i===Zp)return e.RGBA_INTEGER;if(i===bd||i===xd||i===yd||i===_d)if(a===Bt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===bd)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===xd)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===yd)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===_d)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===bd)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===xd)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===yd)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===_d)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Yp||i===Qp||i===em||i===tm)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Yp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Qp)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===em)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===tm)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===nm||i===im||i===rm||i===sm||i===am||i===vd||i===om)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===nm||i===im)return a===Bt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===rm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===sm)return s.COMPRESSED_R11_EAC;if(i===am)return s.COMPRESSED_SIGNED_R11_EAC;if(i===vd)return s.COMPRESSED_RG11_EAC;if(i===om)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===cm||i===lm||i===um||i===dm||i===fm||i===hm||i===pm||i===mm||i===gm||i===bm||i===xm||i===ym||i===_m||i===vm)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===cm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===lm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===um)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===dm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===fm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===hm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===pm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===mm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===gm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===bm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===xm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ym)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===_m)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===vm)return a===Bt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Em||i===Tm||i===Am)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Em)return a===Bt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Tm)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Am)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===wm||i===Sm||i===Ed||i===Mm)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===wm)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Sm)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ed)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Mm)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Co)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}class LA{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new kd(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 Ei({vertexShader:a8,fragmentShader:o8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jt(new ul(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}function l8(e,t){function n(g,p){if(g.matrixAutoUpdate===!0)g.updateMatrix();p.value.copy(g.matrix)}function i(g,p){if(p.color.getRGB(g.fogColor.value,Bm(e)),p.isFog)g.fogNear.value=p.near,g.fogFar.value=p.far;else if(p.isFogExp2)g.fogDensity.value=p.density}function r(g,p,x,_,y){if(p.isNodeMaterial)p.uniformsNeedUpdate=!1;else if(p.isMeshBasicMaterial)s(g,p);else if(p.isMeshLambertMaterial){if(s(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshToonMaterial)s(g,p),d(g,p);else if(p.isMeshPhongMaterial){if(s(g,p),u(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshStandardMaterial){if(s(g,p),f(g,p),p.isMeshPhysicalMaterial)h(g,p,y)}else if(p.isMeshMatcapMaterial)s(g,p),b(g,p);else if(p.isMeshDepthMaterial)s(g,p);else if(p.isMeshDistanceMaterial)s(g,p),m(g,p);else if(p.isMeshNormalMaterial)s(g,p);else if(p.isLineBasicMaterial){if(a(g,p),p.isLineDashedMaterial)o(g,p)}else if(p.isPointsMaterial)c(g,p,x,_);else if(p.isSpriteMaterial)l(g,p);else if(p.isShadowMaterial)g.color.value.copy(p.color),g.opacity.value=p.opacity;else if(p.isShaderMaterial)p.uniformsNeedUpdate=!1}function s(g,p){if(g.opacity.value=p.opacity,p.color)g.diffuse.value.copy(p.color);if(p.emissive)g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity);if(p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.bumpMap){if(g.bumpMap.value=p.bumpMap,n(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===Dn)g.bumpScale.value*=-1}if(p.normalMap){if(g.normalMap.value=p.normalMap,n(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===Dn)g.normalScale.value.negate()}if(p.displacementMap)g.displacementMap.value=p.displacementMap,n(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias;if(p.emissiveMap)g.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,g.emissiveMapTransform);if(p.specularMap)g.specularMap.value=p.specularMap,n(p.specularMap,g.specularMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest;let x=t.get(p),{envMap:_,envMapRotation:y}=x;if(_){if(g.envMap.value=_,g.envMapRotation.value.setFromMatrix4(c8.makeRotationFromEuler(y)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1)g.envMapRotation.value.premultiply(UA);g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio}if(p.lightMap)g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,g.lightMapTransform);if(p.aoMap)g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,g.aoMapTransform)}function a(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map)g.map.value=p.map,n(p.map,g.mapTransform)}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,x,_){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*x,g.scale.value=_*0.5,p.map)g.map.value=p.map,n(p.map,g.uvTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function l(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,0.0001)}function d(g,p){if(p.gradientMap)g.gradientMap.value=p.gradientMap}function f(g,p){if(g.metalness.value=p.metalness,p.metalnessMap)g.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,g.metalnessMapTransform);if(g.roughness.value=p.roughness,p.roughnessMap)g.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,g.roughnessMapTransform);if(p.envMap)g.envMapIntensity.value=p.envMapIntensity}function h(g,p,x){if(g.ior.value=p.ior,p.sheen>0){if(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap)g.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,g.sheenColorMapTransform);if(p.sheenRoughnessMap)g.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,g.sheenRoughnessMapTransform)}if(p.clearcoat>0){if(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap)g.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,g.clearcoatMapTransform);if(p.clearcoatRoughnessMap)g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform);if(p.clearcoatNormalMap){if(g.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Dn)g.clearcoatNormalScale.value.negate()}}if(p.dispersion>0)g.dispersion.value=p.dispersion;if(p.retroreflectivity>0)g.retroreflectivity.value=p.retroreflectivity;if(p.iridescence>0){if(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap)g.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,g.iridescenceMapTransform);if(p.iridescenceThicknessMap)g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform)}if(p.transmission>0){if(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),p.transmissionMap)g.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,g.transmissionMapTransform);if(g.thickness.value=p.thickness,p.thicknessMap)g.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,g.thicknessMapTransform);g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)}if(p.anisotropy>0){if(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap)g.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,g.anisotropyMapTransform)}if(g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap)g.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,g.specularColorMapTransform);if(p.specularIntensityMap)g.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,g.specularIntensityMapTransform)}function b(g,p){if(p.matcap)g.matcap.value=p.matcap}function m(g,p){let x=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function u8(e,t,n,i){let r={},s={},a=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,v){let E=v.program;i.uniformBlockBinding(y,E)}function l(y,v){let E=r[y.id];if(E===void 0)g(y),E=u(y),r[y.id]=E,y.addEventListener("dispose",x);let w=v.program;i.updateUBOMapping(y,w);let T=t.render.frame;if(s[y.id]!==T)f(y),s[y.id]=T}function u(y){let v=d();y.__bindingPointIndex=v;let E=e.createBuffer(),{__size:w,usage:T}=y;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,w,T),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,v,E),E}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return Ye("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){let v=r[y.id],{uniforms:E,__cache:w}=y;e.bindBuffer(e.UNIFORM_BUFFER,v);for(let T=0,A=E.length;T<A;T++){let P=E[T];if(Array.isArray(P))for(let S=0,R=P.length;S<R;S++)h(P[S],T,S,w);else h(P,T,0,w)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function h(y,v,E,w){if(m(y,v,E,w)===!0){let{__offset:T,value:A}=y;if(Array.isArray(A)){let P=0;for(let S=0;S<A.length;S++){let R=A[S],k=p(R);if(b(R,y.__data,P),typeof R!=="number"&&typeof R!=="boolean"&&!R.isMatrix3&&!ArrayBuffer.isView(R))P+=k.storage/Float32Array.BYTES_PER_ELEMENT}}else b(A,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,T,y.__data)}}function b(y,v,E){if(typeof y==="number"||typeof y==="boolean")v[0]=y;else if(y.isMatrix3)v[0]=y.elements[0],v[1]=y.elements[1],v[2]=y.elements[2],v[3]=0,v[4]=y.elements[3],v[5]=y.elements[4],v[6]=y.elements[5],v[7]=0,v[8]=y.elements[6],v[9]=y.elements[7],v[10]=y.elements[8],v[11]=0;else if(ArrayBuffer.isView(y))v.set(new y.constructor(y.buffer,y.byteOffset,v.length));else y.toArray(v,E)}function m(y,v,E,w){let T=y.value,A=v+"_"+E;if(w[A]===void 0){if(typeof T==="number"||typeof T==="boolean")w[A]=T;else if(ArrayBuffer.isView(T))w[A]=T.slice();else w[A]=T.clone();return!0}else{let P=w[A];if(typeof T==="number"||typeof T==="boolean"){if(P!==T)return w[A]=T,!0}else if(ArrayBuffer.isView(T))return!0;else if(P.equals(T)===!1)return P.copy(T),!0}return!1}function g(y){let v=y.uniforms,E=0,w=16;for(let A=0,P=v.length;A<P;A++){let S=Array.isArray(v[A])?v[A]:[v[A]];for(let R=0,k=S.length;R<k;R++){let C=S[R],U=Array.isArray(C.value)?C.value:[C.value];for(let L=0,O=U.length;L<O;L++){let K=U[L],B=p(K),X=E%w,q=X%B.boundary,le=X+q;if(E+=q,le!==0&&w-le<B.storage)E+=w-le;C.__data=new Float32Array(B.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=E,E+=B.storage}}}let T=E%w;if(T>0)E+=w-T;return y.__size=E,y.__cache={},this}function p(y){let v={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")v.boundary=4,v.storage=4;else if(y.isVector2)v.boundary=8,v.storage=8;else if(y.isVector3||y.isColor)v.boundary=16,v.storage=12;else if(y.isVector4)v.boundary=16,v.storage=16;else if(y.isMatrix3)v.boundary=48,v.storage=48;else if(y.isMatrix4)v.boundary=64,v.storage=64;else if(y.isTexture)je("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))v.boundary=16,v.storage=y.byteLength;else je("WebGLRenderer: Unsupported uniform value type.",y);return v}function x(y){let v=y.target;v.removeEventListener("dispose",x);let E=a.indexOf(v.__bindingPointIndex);a.splice(E,1),e.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function _(){for(let y in r)e.deleteBuffer(r[y]);a=[],r={},s={}}return{bind:c,update:l,dispose:_}}function f8(){if(gr===null)gr=new sl(d8,16,16,wa,hr),gr.name="DFG_LUT",gr.minFilter=Tn,gr.magFilter=Tn,gr.wrapS=Ro,gr.wrapT=Ro,gr.generateMipmaps=!1,gr.needsUpdate=!0;return gr}class fg{constructor(e={}){let{canvas:t=$T(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:a=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=zi}=e;this.isWebGLRenderer=!0;let h;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=n.getContextAttributes().alpha}else h=s;let b=f,m=new Set([Zp,Jp,qp]),g=new Set([zi,hs,Yc,Co,Wp,Xp]),p=new Uint32Array(4),x=new Int32Array(4),_=new j,y=null,v=null,E=[],w=[],T=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ui,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let A=this,P=!1,S=null,R=null,k=null,C=null;this._outputColorSpace=ps;let U=0,L=0,O=null,K=-1,B=null,X=new Pt,q=new Pt,le=null,de=new qe(0),Me=0,{width:pe,height:J}=t,F=1,W=null,ne=null,ie=new Pt(0,0,pe,J),ce=new Pt(0,0,pe,J),_e=!1,Re=new ol,ke=!1,We=!1,Qe=new Je,Wt=new j,lt=new Pt,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Qt=!1;function nn(){return O===null?F:1}let z=n;function _n(I,H){return t.getContext(I,H)}let St,Xt,N,M,V,ee,he,ge,ve,re,oe,Ie,Ve,Ee,me,Ge,Xe,vt,G,xe,ae,ye,Ce;try{let I={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${ZE}`);if(t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",zt,!1),t.addEventListener("webglcontextcreationerror",Mt,!1),z===null){if(z=_n("webgl2",I),z===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}fe()}catch(I){throw t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",Mt,!1),Ye("WebGLRenderer: "+I.message),I}function fe(){if(St=new yD(z),St.init(),ae=new s8(z,St),Xt=new lD(z,St,e,ae),N=new i8(z,St),Xt.reversedDepthBuffer&&d)N.buffers.depth.setReversed(!0);R=z.createFramebuffer(),k=z.createFramebuffer(),C=z.createFramebuffer(),M=new ED(z),V=new HL,ee=new r8(z,St,N,V,Xt,ae,M),he=new xD(A),ge=new AP(z),ye=new oD(z,ge),ve=new _D(z,ge,M,ye),re=new AD(z,ve,ge,ye,M),vt=new TD(z,Xt,ee),me=new uD(V),oe=new jL(A,he,St,Xt,ye,me),Ie=new l8(A,V),Ve=new $L,Ee=new ZL(St),Xe=new aD(A,he,N,re,h,o),Ge=new n8(A,re,Xt),Ce=new u8(z,M,Xt,N),G=new cD(z,St,M),xe=new vD(z,St,M),M.programs=oe.programs,A.capabilities=Xt,A.extensions=St,A.properties=V,A.renderLists=Ve,A.shadowMap=Ge,A.state=N,A.info=M}if(b!==zi)T=new SD(b,t.width,t.height,a,i,r);let Ae=new FA(A,z);this.xr=Ae,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let I=St.get("WEBGL_lose_context");if(I)I.loseContext()},this.forceContextRestore=function(){let I=St.get("WEBGL_lose_context");if(I)I.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(I){if(I===void 0)return;F=I,this.setSize(pe,J,!1)},this.getSize=function(I){return I.set(pe,J)},this.setSize=function(I,H,te=!0){if(Ae.isPresenting){je("WebGLRenderer: Can't change size while VR device is presenting.");return}if(pe=I,J=H,t.width=Math.floor(I*F),t.height=Math.floor(H*F),te===!0)t.style.width=I+"px",t.style.height=H+"px";if(T!==null)T.setSize(t.width,t.height);this.setViewport(0,0,I,H)},this.getDrawingBufferSize=function(I){return I.set(pe*F,J*F).floor()},this.setDrawingBufferSize=function(I,H,te){pe=I,J=H,F=te,t.width=Math.floor(I*te),t.height=Math.floor(H*te),this.setViewport(0,0,I,H)},this.setEffects=function(I){if(b===zi){Ye("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(I){for(let H=0;H<I.length;H++)if(I[H].isOutputPass===!0){je("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(I||[])},this.getCurrentViewport=function(I){return I.copy(X)},this.getViewport=function(I){return I.copy(ie)},this.setViewport=function(I,H,te,Z){if(I.isVector4)ie.set(I.x,I.y,I.z,I.w);else ie.set(I,H,te,Z);N.viewport(X.copy(ie).multiplyScalar(F).round())},this.getScissor=function(I){return I.copy(ce)},this.setScissor=function(I,H,te,Z){if(I.isVector4)ce.set(I.x,I.y,I.z,I.w);else ce.set(I,H,te,Z);N.scissor(q.copy(ce).multiplyScalar(F).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(I){N.setScissorTest(_e=I)},this.setOpaqueSort=function(I){W=I},this.setTransparentSort=function(I){ne=I},this.getClearColor=function(I){return I.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(I=!0,H=!0,te=!0){let Z=0;if(I){let Y=!1;if(O!==null){let Se=O.texture.format;Y=m.has(Se)}if(Y){let Se=O.texture.type,Pe=g.has(Se),we=Xe.getClearColor(),De=Xe.getClearAlpha(),{r:ze,g:rt,b:ht}=we;if(Pe)p[0]=ze,p[1]=rt,p[2]=ht,p[3]=De,z.clearBufferuiv(z.COLOR,0,p);else x[0]=ze,x[1]=rt,x[2]=ht,x[3]=De,z.clearBufferiv(z.COLOR,0,x)}else Z|=z.COLOR_BUFFER_BIT}if(H)Z|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(te)Z|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)z.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(I){I.setRenderer(this),S=I},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",zt,!1),t.removeEventListener("webglcontextcreationerror",Mt,!1),Xe.dispose(),Ve.dispose(),Ee.dispose(),V.dispose(),he.dispose(),re.dispose(),ye.dispose(),Ce.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",Sb),Ae.removeEventListener("sessionend",Mb),ia.stop()};function it(I){I.preventDefault(),Wc("WebGLRenderer: Context Lost."),P=!0}function zt(){Wc("WebGLRenderer: Context Restored."),P=!1;let I=M.autoReset,H=Ge.enabled,te=Ge.autoUpdate,Z=Ge.needsUpdate,Y=Ge.type;fe(),M.autoReset=I,Ge.enabled=H,Ge.autoUpdate=te,Ge.needsUpdate=Z,Ge.type=Y}function Mt(I){Ye("WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function Xi(I){let H=I.target;H.removeEventListener("dispose",Xi),wr(H)}function wr(I){QR(I),V.remove(I)}function QR(I){let H=V.get(I).programs;if(H!==void 0){if(H.forEach(function(te){oe.releaseProgram(te)}),I.isShaderMaterial)oe.releaseShaderCache(I)}}this.renderBufferDirect=function(I,H,te,Z,Y,Se){if(H===null)H=Lt;let Pe=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,we=nI(I,H,te,Z,Y);N.setMaterial(Z,Pe);let De=te.index,ze=1;if(Z.wireframe===!0){if(De=ve.getWireframeAttribute(te),De===void 0)return;ze=2}let rt=te.drawRange,ht=te.attributes.position,Le=rt.start*ze,Rt=(rt.start+rt.count)*ze;if(Se!==null)Le=Math.max(Le,Se.start*ze),Rt=Math.min(Rt,(Se.start+Se.count)*ze);if(De!==null)Le=Math.max(Le,0),Rt=Math.min(Rt,De.count);else if(ht!==void 0&&ht!==null)Le=Math.max(Le,0),Rt=Math.min(Rt,ht.count);let on=Rt-Le;if(on<0||on===1/0)return;ye.setup(Y,Z,we,te,De);let Gt,Ft=G;if(De!==null)Gt=ge.get(De),Ft=xe,Ft.setIndex(Gt);if(Y.isMesh)if(Z.wireframe===!0)N.setLineWidth(Z.wireframeLinewidth*nn()),Ft.setMode(z.LINES);else Ft.setMode(z.TRIANGLES);else if(Y.isLine){let Cn=Z.linewidth;if(Cn===void 0)Cn=1;if(N.setLineWidth(Cn*nn()),Y.isLineSegments)Ft.setMode(z.LINES);else if(Y.isLineLoop)Ft.setMode(z.LINE_LOOP);else Ft.setMode(z.LINE_STRIP)}else if(Y.isPoints)Ft.setMode(z.POINTS);else if(Y.isSprite)Ft.setMode(z.TRIANGLES);if(Y.isBatchedMesh)if(!St.get("WEBGL_multi_draw")){let{_multiDrawStarts:Cn,_multiDrawCounts:Ne,_multiDrawCount:Un}=Y,xt=De?ge.get(De).bytesPerElement:1,pi=V.get(Z).currentProgram.getUniforms();for(let qi=0;qi<Un;qi++)pi.setValue(z,"_gl_DrawID",qi),Ft.render(Cn[qi]/xt,Ne[qi])}else Ft.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else if(Y.isInstancedMesh)Ft.renderInstances(Le,on,Y.count);else if(te.isInstancedBufferGeometry){let Cn=te._maxInstanceCount!==void 0?te._maxInstanceCount:1/0,Ne=Math.min(te.instanceCount,Cn);Ft.renderInstances(Le,on,Ne)}else Ft.render(Le,on)};function wb(I,H,te,Z){if(S!==null&&I.isNodeMaterial)S.setObject(Z,I);if(ke===!0)me.setState(I,te,!1);if(I.transparent===!0&&I.side===vi&&I.forceSinglePass===!1)I.side=Dn,I.needsUpdate=!0,$l(I,H,Z),I.side=fs,I.needsUpdate=!0,$l(I,H,Z),I.side=vi;else $l(I,H,Z)}this.compile=function(I,H,te=null){if(te===null)te=I;if(S!==null)S.renderStart(I,H,te);if(v=Ee.get(te),v.init(H),w.push(v),te.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}}),I!==te)I.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(H.layers)){if(v.pushLight(Y),Y.castShadow)v.pushShadow(Y)}});if(v.setupLights(),S!==null)S.updateLights(v.state.lightsArray);if(We=this.localClippingEnabled,ke=me.init(this.clippingPlanes,We),ke===!0)me.setGlobalState(this.clippingPlanes,H);if(S!==null)Ge.render(v.state.shadowsArray,te,H);let Z=new Set;if(I.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;let Se=Y.material;if(Se)if(Array.isArray(Se))for(let Pe=0;Pe<Se.length;Pe++){let we=Se[Pe];wb(we,te,H,Y),Z.add(we)}else wb(Se,te,H,Y),Z.add(Se)}),v=w.pop(),S!==null)S.renderEnd();return Z},this.compileAsync=function(I,H,te=null){let Z=this.compile(I,H,te);return new Promise((Y)=>{function Se(){if(Z.forEach(function(Pe){let De=V.get(Pe).currentProgram;if(De===void 0||De.isReady())Z.delete(Pe)}),Z.size===0){Y(I);return}setTimeout(Se,10)}if(St.get("KHR_parallel_shader_compile")!==null)Se();else setTimeout(Se,10)})};let Lf=null;function eI(I){if(Lf)Lf(I)}function Sb(){ia.stop()}function Mb(){ia.start()}let ia=new wA;if(ia.setAnimationLoop(eI),typeof self<"u")ia.setContext(self);this.setAnimationLoop=function(I){Lf=I,Ae.setAnimationLoop(I),I===null?ia.stop():ia.start()},Ae.addEventListener("sessionstart",Sb),Ae.addEventListener("sessionend",Mb),this.render=function(I,H){if(H!==void 0&&H.isCamera!==!0){Ye("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(S!==null)S.renderStart(I,H);let te=Ae.enabled===!0&&Ae.isPresenting===!0,Z=T!==null&&(O===null||te)&&T.begin(A,O);if(I.matrixWorldAutoUpdate===!0)I.updateMatrixWorld();if(H.parent===null&&H.matrixWorldAutoUpdate===!0)H.updateMatrixWorld();if(Ae.enabled===!0&&Ae.isPresenting===!0&&(T===null||T.isCompositing()===!1)){if(Ae.cameraAutoUpdate===!0)Ae.updateCamera(H);H=Ae.getCamera()}if(I.isScene===!0)I.onBeforeRender(A,I,H,O);if(v=Ee.get(I,w.length),v.init(H),v.state.textureUnits=ee.getTextureUnits(),w.push(v),Qe.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),Re.setFromProjectionMatrix(Qe,Om,H.reversedDepth),We=this.localClippingEnabled,ke=me.init(this.clippingPlanes,We),y=Ve.get(I,E.length),y.init(),E.push(y),Ae.enabled===!0&&Ae.isPresenting===!0){let Pe=A.xr.getDepthSensingMesh();if(Pe!==null)Ff(Pe,H,-1/0,A.sortObjects)}if(Ff(I,H,0,A.sortObjects),y.finish(),S!==null)S.updateLights(v.state.lightsArray);if(A.sortObjects===!0)y.sort(W,ne);if(Qt=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,Qt)Xe.addToRenderList(y,I);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(ke===!0)me.beginShadows();let Y=v.state.shadowsArray;if(Ge.render(Y,I,H),ke===!0)me.endShadows();if((Z&&T.hasRenderPass())===!1){let Pe=y.opaque,we=y.transmissive;if(v.setupLights(),H.isArrayCamera){let De=H.cameras;if(we.length>0)for(let ze=0,rt=De.length;ze<rt;ze++){let ht=De[ze];Ib(Pe,we,I,ht)}if(Qt)Xe.render(I);for(let ze=0,rt=De.length;ze<rt;ze++){let ht=De[ze];Rb(y,I,ht,ht.viewport)}}else{if(we.length>0)Ib(Pe,we,I,H);if(Qt)Xe.render(I);Rb(y,I,H)}}if(O!==null&&L===0)ee.updateMultisampleRenderTarget(O),ee.updateRenderTargetMipmap(O);if(Z)T.end(A);if(I.isScene===!0)I.onAfterRender(A,I,H);if(ye.resetDefaultState(),K=-1,B=null,w.pop(),w.length>0){if(v=w[w.length-1],ee.setTextureUnits(v.state.textureUnits),ke===!0)me.setGlobalState(A.clippingPlanes,v.state.camera)}else v=null;if(E.pop(),E.length>0)y=E[E.length-1];else y=null;if(S!==null)S.renderEnd()};function Ff(I,H,te,Z){if(I.visible===!1)return;if(I.layers.test(H.layers)){if(I.isGroup)te=I.renderOrder;else if(I.isLOD){if(I.autoUpdate===!0)I.update(H)}else if(I.isLightProbeGrid)v.pushLightProbeGrid(I);else if(I.isLight){if(v.pushLight(I),I.castShadow)v.pushShadow(I)}else if(I.isSprite){if(!I.frustumCulled||I.intersectsFrustum(Re)){if(Z)lt.setFromMatrixPosition(I.matrixWorld).applyMatrix4(Qe);let Pe=re.update(I),we=I.material;if(we.visible)y.push(I,Pe,we,te,lt.z,null,H)}}else if(I.isMesh||I.isLine||I.isPoints){if(!I.frustumCulled||I.intersectsFrustum(Re)){let Pe=re.update(I),we=I.material;if(Z){if(I.boundingSphere!==void 0){if(I.boundingSphere===null)I.computeBoundingSphere();lt.copy(I.boundingSphere.center)}else{if(Pe.boundingSphere===null)Pe.computeBoundingSphere();lt.copy(Pe.boundingSphere.center)}lt.applyMatrix4(I.matrixWorld).applyMatrix4(Qe)}if(Array.isArray(we)){let De=Pe.groups;for(let ze=0,rt=De.length;ze<rt;ze++){let ht=De[ze],Le=we[ht.materialIndex];if(Le&&Le.visible)y.push(I,Pe,Le,te,lt.z,ht,H)}}else if(we.visible)y.push(I,Pe,we,te,lt.z,null,H)}}}let Se=I.children;for(let Pe=0,we=Se.length;Pe<we;Pe++)Ff(Se[Pe],H,te,Z)}function Rb(I,H,te,Z){let{opaque:Y,transmissive:Se,transparent:Pe}=I;if(v.setupLightsView(te),ke===!0)me.setGlobalState(A.clippingPlanes,te);if(Z)N.viewport(X.copy(Z));if(Y.length>0)Gl(Y,H,te);if(Se.length>0)Gl(Se,H,te);if(Pe.length>0)Gl(Pe,H,te);N.buffers.depth.setTest(!0),N.buffers.depth.setMask(!0),N.buffers.color.setMask(!0),N.setPolygonOffset(!1)}function Ib(I,H,te,Z){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(v.state.transmissionRenderTarget[Z.id]===void 0){let Le=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");v.state.transmissionRenderTarget[Z.id]=new li(1,1,{generateMipmaps:!0,type:Le?hr:zi,minFilter:fr,samples:Math.max(4,Xt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:ot.workingColorSpace})}let Se=v.state.transmissionRenderTarget[Z.id],Pe=Z.viewport||X;Se.setSize(Pe.z*A.transmissionResolutionScale,Pe.w*A.transmissionResolutionScale);let we=A.getRenderTarget(),De=A.getActiveCubeFace(),ze=A.getActiveMipmapLevel();if(A.setRenderTarget(Se),A.getClearColor(de),Me=A.getClearAlpha(),Me<1)A.setClearColor(16777215,0.5);if(A.clear(),Qt)Xe.render(te);let rt=A.toneMapping;A.toneMapping=Ui;let ht=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(v.setupLightsView(Z),ke===!0)me.setGlobalState(A.clippingPlanes,Z);if(Gl(I,te,Z),ee.updateMultisampleRenderTarget(Se),ee.updateRenderTargetMipmap(Se),St.has("WEBGL_multisampled_render_to_texture")===!1){let Le=!1;for(let Rt=0,on=H.length;Rt<on;Rt++){let Gt=H[Rt],{object:Ft,geometry:Cn,material:Ne,group:Un}=Gt;if(Ne.side===vi&&Ft.layers.test(Z.layers)){let xt=Ne.side;Ne.side=Dn,Ne.needsUpdate=!0,Cb(Ft,te,Z,Cn,Ne,Un),Ne.side=xt,Ne.needsUpdate=!0,Le=!0}}if(Le===!0)ee.updateMultisampleRenderTarget(Se),ee.updateRenderTargetMipmap(Se)}if(A.setRenderTarget(we,De,ze),A.setClearColor(de,Me),ht!==void 0)Z.viewport=ht;A.toneMapping=rt}function Gl(I,H,te){let Z=H.isScene===!0?H.overrideMaterial:null;for(let Y=0,Se=I.length;Y<Se;Y++){let Pe=I[Y],{object:we,geometry:De,group:ze}=Pe,rt=Pe.material;if(rt.allowOverride===!0&&Z!==null)rt=Z;if(we.layers.test(te.layers))Cb(we,H,te,De,rt,ze)}}function Cb(I,H,te,Z,Y,Se){if(S!==null&&Y.isNodeMaterial)S.setObject(I,Y);if(I.onBeforeRender(A,H,te,Z,Y,Se),I.modelViewMatrix.multiplyMatrices(te.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),Y.onBeforeRender(A,H,te,Z,I,Se),Y.transparent===!0&&Y.side===vi&&Y.forceSinglePass===!1)Y.side=Dn,Y.needsUpdate=!0,A.renderBufferDirect(te,H,Z,Y,I,Se),Y.side=fs,Y.needsUpdate=!0,A.renderBufferDirect(te,H,Z,Y,I,Se),Y.side=vi;else A.renderBufferDirect(te,H,Z,Y,I,Se);I.onAfterRender(A,H,te,Z,Y,Se)}function $l(I,H,te){if(H.isScene!==!0)H=Lt;let Z=V.get(I),Y=v.state.lights,Se=v.state.shadowsArray,Pe=Y.state.version,we=oe.getParameters(I,Y.state,Se,H,te,v.state.lightProbeGridArray),De=oe.getProgramCacheKey(we),ze=Z.programs;Z.environment=I.isMeshStandardMaterial||I.isMeshLambertMaterial||I.isMeshPhongMaterial?H.environment:null,Z.fog=H.fog;let rt=I.isMeshStandardMaterial||I.isMeshLambertMaterial&&!I.envMap||I.isMeshPhongMaterial&&!I.envMap;if(Z.envMap=he.get(I.envMap||Z.environment,rt),Z.envMapRotation=Z.environment!==null&&I.envMap===null?H.environmentRotation:I.envMapRotation,ze===void 0)I.addEventListener("dispose",Xi),ze=new Map,Z.programs=ze;let ht=ze.get(De);if(ht!==void 0){if(Z.currentProgram===ht&&Z.lightsStateVersion===Pe)return Pb(I,we),ht}else{if(we.uniforms=oe.getUniforms(I),S!==null&&I.isNodeMaterial)S.build(I,te,we);I.onBeforeCompile(we,A),ht=oe.acquireProgram(we,De),ze.set(De,ht),Z.uniforms=we.uniforms}let Le=Z.uniforms;if(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)Le.clippingPlanes=me.uniform;if(Pb(I,we),Z.needsLights=rI(I),Z.lightsStateVersion=Pe,Z.needsLights)Le.ambientLightColor.value=Y.state.ambient,Le.lightProbe.value=Y.state.probe,Le.sunLights.value=Y.state.sun,Le.sunLightShadows.value=Y.state.sunShadow,Le.directionalLights.value=Y.state.directional,Le.directionalLightShadows.value=Y.state.directionalShadow,Le.spotLights.value=Y.state.spot,Le.spotLightShadows.value=Y.state.spotShadow,Le.rectAreaLights.value=Y.state.rectArea,Le.ltc_1.value=Y.state.rectAreaLTC1,Le.ltc_2.value=Y.state.rectAreaLTC2,Le.pointLights.value=Y.state.point,Le.pointLightShadows.value=Y.state.pointShadow,Le.hemisphereLights.value=Y.state.hemi,Le.sunShadowMatrix.value=Y.state.sunShadowMatrix,Le.sunShadowCascade.value=Y.state.sunShadowCascade,Le.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,Le.spotLightMatrix.value=Y.state.spotLightMatrix,Le.spotLightMap.value=Y.state.spotLightMap,Le.pointShadowMatrix.value=Y.state.pointShadowMatrix;return Z.lightProbeGrid=v.state.lightProbeGridArray.length>0,Z.currentProgram=ht,Z.uniformsList=null,ht}function Nb(I){if(I.uniformsList===null){let H=I.currentProgram.getUniforms();I.uniformsList=xl.seqWithValue(H.seq,I.uniforms)}return I.uniformsList}function Pb(I,H){let te=V.get(I);te.outputColorSpace=H.outputColorSpace,te.batching=H.batching,te.batchingColor=H.batchingColor,te.instancing=H.instancing,te.instancingColor=H.instancingColor,te.instancingMorph=H.instancingMorph,te.skinning=H.skinning,te.morphTargets=H.morphTargets,te.morphNormals=H.morphNormals,te.morphColors=H.morphColors,te.morphTargetsCount=H.morphTargetsCount,te.numClippingPlanes=H.numClippingPlanes,te.numIntersection=H.numClipIntersection,te.vertexAlphas=H.vertexAlphas,te.vertexTangents=H.vertexTangents,te.toneMapping=H.toneMapping}function tI(I,H){if(I.length===0)return null;if(I.length===1)return I[0].texture!==null?I[0]:null;_.setFromMatrixPosition(H.matrixWorld);for(let te=0,Z=I.length;te<Z;te++){let Y=I[te];if(Y.texture!==null&&Y.boundingBox.containsPoint(_))return Y}return null}function nI(I,H,te,Z,Y){if(H.isScene!==!0)H=Lt;ee.resetTextureUnits();let Se=H.fog,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?H.environment:null,we=O===null?A.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:ot.workingColorSpace,De=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,ze=he.get(Z.envMap||Pe,De),rt=Z.vertexColors===!0&&!!te.attributes.color&&te.attributes.color.itemSize===4,ht=!!te.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),Le=!!te.morphAttributes.position,Rt=!!te.morphAttributes.normal,on=!!te.morphAttributes.color,Gt=Ui;if(Z.toneMapped){if(O===null||O.isXRRenderTarget===!0)Gt=A.toneMapping}let Ft=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Cn=Ft!==void 0?Ft.length:0,Ne=V.get(Z),Un=v.state.lights;if(ke===!0){if(We===!0||I!==B){let Vt=I===B&&Z.id===K;me.setState(Z,I,Vt)}}let xt=!1;if(Z.version===Ne.__version){if(Ne.needsLights&&Ne.lightsStateVersion!==Un.state.version)xt=!0;else if(Ne.outputColorSpace!==we)xt=!0;else if(Y.isBatchedMesh&&Ne.batching===!1)xt=!0;else if(!Y.isBatchedMesh&&Ne.batching===!0)xt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!0&&Y._colorsTexture===null)xt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!1&&Y._colorsTexture!==null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancing===!1)xt=!0;else if(!Y.isInstancedMesh&&Ne.instancing===!0)xt=!0;else if(Y.isSkinnedMesh&&Ne.skinning===!1)xt=!0;else if(!Y.isSkinnedMesh&&Ne.skinning===!0)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!0&&Y.instanceColor===null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!1&&Y.instanceColor!==null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!0&&Y.morphTexture===null)xt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!1&&Y.morphTexture!==null)xt=!0;else if(Ne.envMap!==ze)xt=!0;else if(Z.fog===!0&&Ne.fog!==Se)xt=!0;else if(Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==me.numPlanes||Ne.numIntersection!==me.numIntersection))xt=!0;else if(Ne.vertexAlphas!==rt)xt=!0;else if(Ne.vertexTangents!==ht)xt=!0;else if(Ne.morphTargets!==Le)xt=!0;else if(Ne.morphNormals!==Rt)xt=!0;else if(Ne.morphColors!==on)xt=!0;else if(Ne.toneMapping!==Gt)xt=!0;else if(Ne.morphTargetsCount!==Cn)xt=!0;else if(!!Ne.lightProbeGrid!==v.state.lightProbeGridArray.length>0)xt=!0}else xt=!0,Ne.__version=Z.version;let pi=Ne.currentProgram;if(xt===!0){if(pi=$l(Z,H,Y),S&&Z.isNodeMaterial)S.onUpdateProgram(Z,pi,Ne)}let qi=!1,Wr=!1,Va=!1,kt=pi.getUniforms(),rn=Ne.uniforms;if(N.useProgram(pi.program))qi=!0,Wr=!0,Va=!0;if(Z.id!==K)K=Z.id,Wr=!0;if(Ne.needsLights){let Vt=tI(v.state.lightProbeGridArray,Y);if(Ne.lightProbeGrid!==Vt)Ne.lightProbeGrid=Vt,Wr=!0}if(qi||B!==I){if(N.buffers.depth.getReversed()&&I.reversedDepth!==!0)I._reversedDepth=!0,I.updateProjectionMatrix();kt.setValue(z,"projectionMatrix",I.projectionMatrix),kt.setValue(z,"viewMatrix",I.matrixWorldInverse);let qr=kt.map.cameraPosition;if(qr!==void 0)qr.setValue(z,Wt.setFromMatrixPosition(I.matrixWorld));if(Xt.logarithmicDepthBuffer)kt.setValue(z,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)kt.setValue(z,"isOrthographic",I.isOrthographicCamera===!0);if(B!==I)B=I,Wr=!0,Va=!0}if(Ne.needsLights){if(Un.state.sunShadowMap.length>0)kt.setValue(z,"sunShadowMap",Un.state.sunShadowMap,ee);if(Un.state.directionalShadowMap.length>0)kt.setValue(z,"directionalShadowMap",Un.state.directionalShadowMap,ee);if(Un.state.spotShadowMap.length>0)kt.setValue(z,"spotShadowMap",Un.state.spotShadowMap,ee);if(Un.state.pointShadowMap.length>0)kt.setValue(z,"pointShadowMap",Un.state.pointShadowMap,ee)}if(Y.isSkinnedMesh){kt.setOptional(z,Y,"bindMatrix"),kt.setOptional(z,Y,"bindMatrixInverse");let Vt=Y.skeleton;if(Vt){if(Vt.boneTexture===null)Vt.computeBoneTexture();kt.setValue(z,"boneTexture",Vt.boneTexture,ee)}}if(Y.isBatchedMesh){if(kt.setOptional(z,Y,"batchingTexture"),kt.setValue(z,"batchingTexture",Y._matricesTexture,ee),kt.setOptional(z,Y,"batchingIdTexture"),kt.setValue(z,"batchingIdTexture",Y._indirectTexture,ee),kt.setOptional(z,Y,"batchingColorTexture"),Y._colorsTexture!==null)kt.setValue(z,"batchingColorTexture",Y._colorsTexture,ee)}let Xr=te.morphAttributes;if(Xr.position!==void 0||Xr.normal!==void 0||Xr.color!==void 0)vt.update(Y,te,pi);if(Wr||Ne.receiveShadow!==Y.receiveShadow)Ne.receiveShadow=Y.receiveShadow,kt.setValue(z,"receiveShadow",Y.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&H.environment!==null)rn.envMapIntensity.value=H.environmentIntensity;if(rn.dfgLUT!==void 0)rn.dfgLUT.value=f8();if(Wr){if(kt.setValue(z,"toneMappingExposure",A.toneMappingExposure),Ne.needsLights)iI(rn,Va);if(Se&&Z.fog===!0)Ie.refreshFogUniforms(rn,Se);if(Ie.refreshMaterialUniforms(rn,Z,F,J,v.state.transmissionRenderTarget[I.id]),Ne.needsLights&&Ne.lightProbeGrid){let Vt=Ne.lightProbeGrid;rn.probesSH.value=Vt.texture,rn.probesMin.value.copy(Vt.boundingBox.min),rn.probesMax.value.copy(Vt.boundingBox.max),rn.probesResolution.value.copy(Vt.resolution)}xl.upload(z,Nb(Ne),rn,ee)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)xl.upload(z,Nb(Ne),rn,ee),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)kt.setValue(z,"center",Y.center);if(kt.setValue(z,"modelViewMatrix",Y.modelViewMatrix),kt.setValue(z,"normalMatrix",Y.normalMatrix),kt.setValue(z,"modelMatrix",Y.matrixWorld),Z.uniformsGroups!==void 0){let Vt=Z.uniformsGroups;for(let qr=0,ja=Vt.length;qr<ja;qr++){let kb=Vt[qr];Ce.update(kb,pi),Ce.bind(kb,pi)}}return pi}function iI(I,H){I.ambientLightColor.needsUpdate=H,I.lightProbe.needsUpdate=H,I.sunLights.needsUpdate=H,I.sunLightShadows.needsUpdate=H,I.directionalLights.needsUpdate=H,I.directionalLightShadows.needsUpdate=H,I.pointLights.needsUpdate=H,I.pointLightShadows.needsUpdate=H,I.spotLights.needsUpdate=H,I.spotLightShadows.needsUpdate=H,I.rectAreaLights.needsUpdate=H,I.hemisphereLights.needsUpdate=H}function rI(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return L},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(I,H,te){let Z=V.get(I);if(Z.__autoAllocateDepthBuffer=I.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;V.get(I.texture).__webglTexture=H,V.get(I.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:te,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(I,H){let te=V.get(I);te.__webglFramebuffer=H,te.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(I,H=0,te=0){O=I,U=H,L=te;let Z=null,Y=!1,Se=!1;if(I){let we=V.get(I);if(we.__useDefaultFramebuffer!==void 0){N.bindFramebuffer(z.FRAMEBUFFER,we.__webglFramebuffer),X.copy(I.viewport),q.copy(I.scissor),le=I.scissorTest,N.viewport(X),N.scissor(q),N.setScissorTest(le),K=-1;return}else if(we.__webglFramebuffer===void 0)ee.setupRenderTarget(I);else if(we.__hasExternalTextures)ee.rebindTextures(I,V.get(I.texture).__webglTexture,V.get(I.depthTexture).__webglTexture);else if(I.depthBuffer){let rt=I.depthTexture;if(we.__boundDepthTexture!==rt){if(rt!==null&&V.has(rt)&&(I.width!==rt.image.width||I.height!==rt.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");ee.setupDepthRenderbuffer(I)}}let De=I.texture;if(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)Se=!0;let ze=V.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget){if(Array.isArray(ze[H]))Z=ze[H][te];else Z=ze[H];Y=!0}else if(I.samples>0&&ee.useMultisampledRTT(I)===!1)Z=V.get(I).__webglMultisampledFramebuffer;else if(Array.isArray(ze))Z=ze[te];else Z=ze;X.copy(I.viewport),q.copy(I.scissor),le=I.scissorTest}else X.copy(ie).multiplyScalar(F).floor(),q.copy(ce).multiplyScalar(F).floor(),le=_e;if(te!==0)Z=R;if(N.bindFramebuffer(z.FRAMEBUFFER,Z))N.drawBuffers(I,Z);if(N.viewport(X),N.scissor(q),N.setScissorTest(le),Y){let we=V.get(I.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,we.__webglTexture,te)}else if(Se){let we=H;for(let De=0;De<I.textures.length;De++){let ze=V.get(I.textures[De]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+De,ze.__webglTexture,te,we)}}else if(I!==null&&te!==0){let we=V.get(I.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,we.__webglTexture,te)}K=-1};function Ob(I){let H=V.get(I);if(H.__readFormat!==I.format||H.__readType!==I.type)H.__readFormat=I.format,H.__readType=I.type,H.__formatReadable=Xt.textureFormatReadable(I.format),H.__typeReadable=Xt.textureTypeReadable(I.type);return H}if(this.readRenderTargetPixels=function(I,H,te,Z,Y,Se,Pe,we=0){if(!(I&&I.isWebGLRenderTarget)){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=V.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Pe!==void 0)De=De[Pe];if(De){N.bindFramebuffer(z.FRAMEBUFFER,De);try{let ze=I.textures[we],{format:rt,type:ht}=ze;if(I.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+we);let Le=Ob(ze);if(Le.__formatReadable===!1){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Le.__typeReadable===!1){Ye("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(H>=0&&H<=I.width-Z&&(te>=0&&te<=I.height-Y))z.readPixels(H,te,Z,Y,ae.convert(rt),ae.convert(ht),Se)}finally{let ze=O!==null?V.get(O).__webglFramebuffer:null;N.bindFramebuffer(z.FRAMEBUFFER,ze)}}},this.readRenderTargetPixelsAsync=async function(I,H,te,Z,Y,Se,Pe,we=0){if(!(I&&I.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let De=V.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Pe!==void 0)De=De[Pe];if(De)if(H>=0&&H<=I.width-Z&&(te>=0&&te<=I.height-Y)){N.bindFramebuffer(z.FRAMEBUFFER,De);let ze=I.textures[we],{format:rt,type:ht}=ze;if(I.textures.length>1)z.readBuffer(z.COLOR_ATTACHMENT0+we);let Le=Ob(ze);if(Le.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Le.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Rt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,Rt),z.bufferData(z.PIXEL_PACK_BUFFER,Se.byteLength,z.STREAM_READ),z.readPixels(H,te,Z,Y,ae.convert(rt),ae.convert(ht),0),z.bindBuffer(z.PIXEL_PACK_BUFFER,null);let on=O!==null?V.get(O).__webglFramebuffer:null;N.bindFramebuffer(z.FRAMEBUFFER,on);let Gt=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await WT(z,Gt,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,Rt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,Se),z.bindBuffer(z.PIXEL_PACK_BUFFER,null),z.deleteBuffer(Rt),z.deleteSync(Gt),Se}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(I,H=null,te=0){let Z=Math.pow(2,-te),Y=Math.floor(I.image.width*Z),Se=Math.floor(I.image.height*Z),Pe=H!==null?H.x:0,we=H!==null?H.y:0;ee.setTexture2D(I,0),z.copyTexSubImage2D(z.TEXTURE_2D,te,0,0,Pe,we,Y,Se),N.unbindTexture()},this.copyTextureToTexture=function(I,H,te=null,Z=null,Y=0,Se=0){let Pe,we,De,ze,rt,ht,Le,Rt,on,Gt=I.isCompressedTexture?I.mipmaps[Se]:I.image;if(te!==null)Pe=te.max.x-te.min.x,we=te.max.y-te.min.y,De=te.isBox3?te.max.z-te.min.z:1,ze=te.min.x,rt=te.min.y,ht=te.isBox3?te.min.z:0;else{let rn=Math.pow(2,-Y);if(Pe=Math.floor(Gt.width*rn),we=Math.floor(Gt.height*rn),I.isDataArrayTexture)De=Gt.depth;else if(I.isData3DTexture)De=Math.floor(Gt.depth*rn);else De=1;ze=0,rt=0,ht=0}if(Z!==null)Le=Z.x,Rt=Z.y,on=Z.z;else Le=0,Rt=0,on=0;let Ft=ae.convert(H.format),Cn=ae.convert(H.type),Ne;if(H.isData3DTexture)ee.setTexture3D(H,0),Ne=z.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)ee.setTexture2DArray(H,0),Ne=z.TEXTURE_2D_ARRAY;else ee.setTexture2D(H,0),Ne=z.TEXTURE_2D;N.activeTexture(z.TEXTURE0),N.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),N.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),N.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);let Un=N.getParameter(z.UNPACK_ROW_LENGTH),xt=N.getParameter(z.UNPACK_IMAGE_HEIGHT),pi=N.getParameter(z.UNPACK_SKIP_PIXELS),qi=N.getParameter(z.UNPACK_SKIP_ROWS),Wr=N.getParameter(z.UNPACK_SKIP_IMAGES);N.pixelStorei(z.UNPACK_ROW_LENGTH,Gt.width),N.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Gt.height),N.pixelStorei(z.UNPACK_SKIP_PIXELS,ze),N.pixelStorei(z.UNPACK_SKIP_ROWS,rt),N.pixelStorei(z.UNPACK_SKIP_IMAGES,ht);let Va=I.isDataArrayTexture||I.isData3DTexture,kt=H.isDataArrayTexture||H.isData3DTexture;if(I.isDepthTexture){let rn=V.get(I),Xr=V.get(H),Vt=V.get(rn.__renderTarget),qr=V.get(Xr.__renderTarget);N.bindFramebuffer(z.READ_FRAMEBUFFER,Vt.__webglFramebuffer),N.bindFramebuffer(z.DRAW_FRAMEBUFFER,qr.__webglFramebuffer);for(let ja=0;ja<De;ja++){if(Va)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(I).__webglTexture,Y,ht+ja),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,V.get(H).__webglTexture,Se,on+ja);z.blitFramebuffer(ze,rt,Pe,we,Le,Rt,Pe,we,z.DEPTH_BUFFER_BIT,z.NEAREST)}N.bindFramebuffer(z.READ_FRAMEBUFFER,null),N.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Y!==0||I.isRenderTargetTexture||V.has(I)){let rn=V.get(I),Xr=V.get(H);N.bindFramebuffer(z.READ_FRAMEBUFFER,k),N.bindFramebuffer(z.DRAW_FRAMEBUFFER,C);for(let Vt=0;Vt<De;Vt++){if(Va)z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,rn.__webglTexture,Y,ht+Vt);else z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,rn.__webglTexture,Y);if(kt)z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Xr.__webglTexture,Se,on+Vt);else z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Xr.__webglTexture,Se);if(Y!==0)z.blitFramebuffer(ze,rt,Pe,we,Le,Rt,Pe,we,z.COLOR_BUFFER_BIT,z.NEAREST);else if(kt)z.copyTexSubImage3D(Ne,Se,Le,Rt,on+Vt,ze,rt,Pe,we);else z.copyTexSubImage2D(Ne,Se,Le,Rt,ze,rt,Pe,we)}N.bindFramebuffer(z.READ_FRAMEBUFFER,null),N.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(kt)if(I.isDataTexture||I.isData3DTexture)z.texSubImage3D(Ne,Se,Le,Rt,on,Pe,we,De,Ft,Cn,Gt.data);else if(H.isCompressedArrayTexture)z.compressedTexSubImage3D(Ne,Se,Le,Rt,on,Pe,we,De,Ft,Gt.data);else z.texSubImage3D(Ne,Se,Le,Rt,on,Pe,we,De,Ft,Cn,Gt);else if(I.isDataTexture)z.texSubImage2D(z.TEXTURE_2D,Se,Le,Rt,Pe,we,Ft,Cn,Gt.data);else if(I.isCompressedTexture)z.compressedTexSubImage2D(z.TEXTURE_2D,Se,Le,Rt,Gt.width,Gt.height,Ft,Gt.data);else z.texSubImage2D(z.TEXTURE_2D,Se,Le,Rt,Pe,we,Ft,Cn,Gt);if(N.pixelStorei(z.UNPACK_ROW_LENGTH,Un),N.pixelStorei(z.UNPACK_IMAGE_HEIGHT,xt),N.pixelStorei(z.UNPACK_SKIP_PIXELS,pi),N.pixelStorei(z.UNPACK_SKIP_ROWS,qi),N.pixelStorei(z.UNPACK_SKIP_IMAGES,Wr),Se===0&&H.generateMipmaps)z.generateMipmap(Ne);N.unbindTexture()},this.initRenderTarget=function(I){if(V.get(I).__webglFramebuffer===void 0)ee.setupRenderTarget(I)},this.initTexture=function(I){if(I.isCubeTexture)ee.setTextureCube(I,0);else if(I.isData3DTexture)ee.setTexture3D(I,0);else if(I.isDataArrayTexture||I.isCompressedArrayTexture)ee.setTexture2DArray(I,0);else ee.setTexture2D(I,0);N.unbindTexture()},this.resetState=function(){U=0,L=0,O=null,N.reset(),ye.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Om}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}var wP=`#ifdef USE_ALPHAHASH
+`+W+`
+`+q)}else if(U!=="")Ve("WebGLProgram: Program Info Log:",U);else if(D===""||P==="")z=!1;if(z)M.diagnostics={runnable:K,programLog:U,vertexShader:{log:D,prefix:g},fragmentShader:{log:P,prefix:p}}}i.deleteShader(_),i.deleteShader(E),A=new Sl(i,m),T=KL(i,m)}let A;this.getUniforms=function(){if(A===void 0)w(this);return A};let T;this.getAttributes=function(){if(T===void 0)w(this);return T};let N=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(N===!1)N=i.getProgramParameter(m,DL);return N},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=FL++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=_,this.fragmentShader=E,this}class WT{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);if(r.has(t)===!1)r.add(t),t.usedTimes++;if(r.has(n)===!1)r.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 XT(e),t.set(e,n);return n}}class XT{constructor(e){this.id=cD++,this.code=e,this.usedTimes=0}}function lD(e){return e===Cs||e===Nd||e===Pd}function uD(e,t,n,r,i,a){let s=new Fd,o=new WT,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:f}=r,h={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(A){if(c.add(A),A===0)return"uv";return`uv${A}`}function m(A,T,N,M,R,k){let C=M.fog,U=R.geometry,D=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?M.environment:null,P=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap,K=t.get(A.envMap||D,P),z=!!K&&K.mapping===sl?K.image.height:null,W=h[A.type];if(A.precision!==null){if(f=r.getMaxPrecision(A.precision),f!==A.precision)Ve("WebGLProgram.getParameters:",A.precision,"not supported, using",f,"instead.")}let q=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,le=q!==void 0?q.length:0,he=0;if(U.morphAttributes.position!==void 0)he=1;if(U.morphAttributes.normal!==void 0)he=2;if(U.morphAttributes.color!==void 0)he=3;let xe,pe,J,F;if(W){let jt=xi[W];xe=jt.vertexShader,pe=jt.fragmentShader}else{xe=A.vertexShader,pe=A.fragmentShader;let jt=o.getVertexShaderStage(A),Rt=o.getFragmentShaderStage(A);o.update(A,jt,Rt),J=jt.id,F=Rt.id}let X=e.getRenderTarget(),ne=e.state.buffers.depth.getReversed(),re=R.isInstancedMesh===!0,ce=R.isBatchedMesh===!0,ve=!!A.map,Re=!!A.matcap,ke=!!K,Xe=!!A.aoMap,et=!!A.lightMap,Wt=!!A.bumpMap&&A.wireframe===!1,dt=!!A.normalMap,Ft=!!A.displacementMap,Qt=!!A.emissiveMap,nn=!!A.metalnessMap,B=!!A.roughnessMap,_n=A.anisotropy>0,St=A.clearcoat>0,Xt=A.dispersion>0,O=A.retroreflectivity>0,S=A.iridescence>0,j=A.sheen>0,ee=A.transmission>0,fe=_n&&!!A.anisotropyMap,be=St&&!!A.clearcoatMap,Ee=St&&!!A.clearcoatNormalMap,ie=St&&!!A.clearcoatRoughnessMap,oe=S&&!!A.iridescenceMap,Ie=S&&!!A.iridescenceThicknessMap,je=j&&!!A.sheenColorMap,Ae=j&&!!A.sheenRoughnessMap,me=!!A.specularMap,Ke=!!A.specularColorMap,qe=!!A.specularIntensityMap,vt=ee&&!!A.transmissionMap,H=ee&&!!A.thicknessMap,ye=!!A.gradientMap,se=!!A.alphaMap,_e=A.alphaTest>0,Ce=!!A.alphaHash,de=!!A.extensions,we=Br;if(A.toneMapped){if(X===null||X.isXRRenderTarget===!0)we=e.toneMapping}let it={shaderID:W,shaderType:A.type,shaderName:A.name,vertexShader:xe,fragmentShader:pe,defines:A.defines,customVertexShaderID:J,customFragmentShaderID:F,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:f,batching:ce,batchingColor:ce&&R._colorsTexture!==null,instancing:re,instancingColor:re&&R.instanceColor!==null,instancingMorph:re&&R.morphTexture!==null,outputColorSpace:X===null?e.outputColorSpace:X.isXRRenderTarget===!0?X.texture.colorSpace:lt.workingColorSpace,alphaToCoverage:!!A.alphaToCoverage,map:ve,matcap:Re,envMap:ke,envMapMode:ke&&K.mapping,envMapCubeUVHeight:z,aoMap:Xe,lightMap:et,bumpMap:Wt,normalMap:dt,displacementMap:Ft,emissiveMap:Qt,normalMapObjectSpace:dt&&A.normalMapType===ZA,normalMapTangentSpace:dt&&A.normalMapType===Vm,packedNormalMap:dt&&A.normalMapType===Vm&&lD(A.normalMap.format),metalnessMap:nn,roughnessMap:B,anisotropy:_n,anisotropyMap:fe,clearcoat:St,clearcoatMap:be,clearcoatNormalMap:Ee,clearcoatRoughnessMap:ie,dispersion:Xt,retroreflection:O,iridescence:S,iridescenceMap:oe,iridescenceThicknessMap:Ie,sheen:j,sheenColorMap:je,sheenRoughnessMap:Ae,specularMap:me,specularColorMap:Ke,specularIntensityMap:qe,transmission:ee,transmissionMap:vt,thicknessMap:H,gradientMap:ye,opaque:A.transparent===!1&&A.blending===il&&A.alphaToCoverage===!1,alphaMap:se,alphaTest:_e,alphaHash:Ce,combine:A.combine,mapUv:ve&&b(A.map.channel),aoMapUv:Xe&&b(A.aoMap.channel),lightMapUv:et&&b(A.lightMap.channel),bumpMapUv:Wt&&b(A.bumpMap.channel),normalMapUv:dt&&b(A.normalMap.channel),displacementMapUv:Ft&&b(A.displacementMap.channel),emissiveMapUv:Qt&&b(A.emissiveMap.channel),metalnessMapUv:nn&&b(A.metalnessMap.channel),roughnessMapUv:B&&b(A.roughnessMap.channel),anisotropyMapUv:fe&&b(A.anisotropyMap.channel),clearcoatMapUv:be&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:Ee&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:oe&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:je&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:Ae&&b(A.sheenRoughnessMap.channel),specularMapUv:me&&b(A.specularMap.channel),specularColorMapUv:Ke&&b(A.specularColorMap.channel),specularIntensityMapUv:qe&&b(A.specularIntensityMap.channel),transmissionMapUv:vt&&b(A.transmissionMap.channel),thicknessMapUv:H&&b(A.thicknessMap.channel),alphaMapUv:se&&b(A.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(dt||_n),vertexNormals:!!U.attributes.normal,vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!U.attributes.uv&&(ve||se),fog:!!C,useFog:A.fog===!0,fogExp2:!!C&&C.isFogExp2,flatShading:A.wireframe===!1&&(A.flatShading===!0||U.attributes.normal===void 0&&dt===!1&&(A.isMeshLambertMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isMeshPhysicalMaterial)),sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ne,skinning:R.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:le,morphTextureStride:he,numSunLights:T.sun.length,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numSunLightShadows:T.sunShadowMap.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:k.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:A.dithering,shadowMapEnabled:e.shadowMap.enabled&&N.length>0,shadowMapType:e.shadowMap.type,toneMapping:we,decodeVideoTexture:ve&&A.map.isVideoTexture===!0&&lt.getTransfer(A.map.colorSpace)===Bt,decodeVideoTextureEmissive:Qt&&A.emissiveMap.isVideoTexture===!0&&lt.getTransfer(A.emissiveMap.colorSpace)===Bt,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===wr,flipSided:A.side===Ln,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:de&&A.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(de&&A.extensions.multiDraw===!0||ce)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return it.vertexUv1s=c.has(1),it.vertexUv2s=c.has(2),it.vertexUv3s=c.has(3),c.clear(),it}function g(A){let T=[];if(A.shaderID)T.push(A.shaderID);else T.push(A.customVertexShaderID),T.push(A.customFragmentShaderID);if(A.defines!==void 0)for(let N in A.defines)T.push(N),T.push(A.defines[N]);if(A.isRawShaderMaterial===!1)p(T,A),y(T,A),T.push(e.outputColorSpace);return T.push(A.customProgramCacheKey),T.join()}function p(A,T){A.push(T.precision),A.push(T.outputColorSpace),A.push(T.envMapMode),A.push(T.envMapCubeUVHeight),A.push(T.mapUv),A.push(T.alphaMapUv),A.push(T.lightMapUv),A.push(T.aoMapUv),A.push(T.bumpMapUv),A.push(T.normalMapUv),A.push(T.displacementMapUv),A.push(T.emissiveMapUv),A.push(T.metalnessMapUv),A.push(T.roughnessMapUv),A.push(T.anisotropyMapUv),A.push(T.clearcoatMapUv),A.push(T.clearcoatNormalMapUv),A.push(T.clearcoatRoughnessMapUv),A.push(T.iridescenceMapUv),A.push(T.iridescenceThicknessMapUv),A.push(T.sheenColorMapUv),A.push(T.sheenRoughnessMapUv),A.push(T.specularMapUv),A.push(T.specularColorMapUv),A.push(T.specularIntensityMapUv),A.push(T.transmissionMapUv),A.push(T.thicknessMapUv),A.push(T.combine),A.push(T.fogExp2),A.push(T.sizeAttenuation),A.push(T.morphTargetsCount),A.push(T.morphAttributeCount),A.push(T.numSunLights),A.push(T.numDirLights),A.push(T.numPointLights),A.push(T.numSpotLights),A.push(T.numSpotLightMaps),A.push(T.numHemiLights),A.push(T.numRectAreaLights),A.push(T.numSunLightShadows),A.push(T.numDirLightShadows),A.push(T.numPointLightShadows),A.push(T.numSpotLightShadows),A.push(T.numSpotLightShadowsWithMaps),A.push(T.numLightProbes),A.push(T.shadowMapType),A.push(T.toneMapping),A.push(T.numClippingPlanes),A.push(T.numClipIntersection),A.push(T.depthPacking)}function y(A,T){if(s.disableAll(),T.instancing)s.enable(0);if(T.instancingColor)s.enable(1);if(T.instancingMorph)s.enable(2);if(T.matcap)s.enable(3);if(T.envMap)s.enable(4);if(T.normalMapObjectSpace)s.enable(5);if(T.normalMapTangentSpace)s.enable(6);if(T.clearcoat)s.enable(7);if(T.iridescence)s.enable(8);if(T.alphaTest)s.enable(9);if(T.vertexColors)s.enable(10);if(T.vertexAlphas)s.enable(11);if(T.vertexUv1s)s.enable(12);if(T.vertexUv2s)s.enable(13);if(T.vertexUv3s)s.enable(14);if(T.vertexTangents)s.enable(15);if(T.anisotropy)s.enable(16);if(T.alphaHash)s.enable(17);if(T.batching)s.enable(18);if(T.dispersion)s.enable(19);if(T.retroreflection)s.enable(24);if(T.batchingColor)s.enable(20);if(T.gradientMap)s.enable(21);if(T.packedNormalMap)s.enable(22);if(T.vertexNormals)s.enable(23);if(A.push(s.mask),s.disableAll(),T.fog)s.enable(0);if(T.useFog)s.enable(1);if(T.flatShading)s.enable(2);if(T.logarithmicDepthBuffer)s.enable(3);if(T.reversedDepthBuffer)s.enable(4);if(T.skinning)s.enable(5);if(T.morphTargets)s.enable(6);if(T.morphNormals)s.enable(7);if(T.morphColors)s.enable(8);if(T.premultipliedAlpha)s.enable(9);if(T.shadowMapEnabled)s.enable(10);if(T.doubleSided)s.enable(11);if(T.flipSided)s.enable(12);if(T.useDepthPacking)s.enable(13);if(T.dithering)s.enable(14);if(T.transmission)s.enable(15);if(T.sheen)s.enable(16);if(T.opaque)s.enable(17);if(T.pointsUvs)s.enable(18);if(T.decodeVideoTexture)s.enable(19);if(T.decodeVideoTextureEmissive)s.enable(20);if(T.alphaToCoverage)s.enable(21);if(T.numLightProbeGrids>0)s.enable(22);if(T.hasPositionAttribute)s.enable(23);A.push(s.mask)}function v(A){let T=h[A.type],N;if(T){let M=xi[T];N=lT.clone(M.uniforms)}else N=A.uniforms;return N}function x(A,T){let N=u.get(T);if(N!==void 0)++N.usedTimes;else N=new oD(e,T,A,i),l.push(N),u.set(T,N);return N}function _(A){if(--A.usedTimes===0){let T=l.indexOf(A);l[T]=l[l.length-1],l.pop(),u.delete(A.cacheKey),A.destroy()}}function E(A){o.remove(A)}function w(){o.dispose()}return{getParameters:m,getProgramCacheKey:g,getUniforms:v,acquireProgram:x,releaseProgram:_,releaseShaderCache:E,programs:l,dispose:w}}function dD(){let e=new WeakMap;function t(s){return e.has(s)}function n(s){let o=e.get(s);if(o===void 0)o={},e.set(s,o);return o}function r(s){e.delete(s)}function i(s,o,c){e.get(s)[o]=c}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function fD(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 kT(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 LT(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function s(f){let h=0;if(f.isInstancedMesh)h+=2;if(f.isSkinnedMesh)h+=1;return h}function o(f,h,b,m,g,p){let y=e[t];if(y===void 0)y={id:f.id,object:f,geometry:h,material:b,materialVariant:s(f),groupOrder:m,renderOrder:f.renderOrder,z:g,group:p},e[t]=y;else y.id=f.id,y.object=f,y.geometry=h,y.material=b,y.materialVariant=s(f),y.groupOrder=m,y.renderOrder=f.renderOrder,y.z=g,y.group=p;return t++,y}function c(f,h,b,m,g,p,y){if(y.reversedDepth===!0)g=-g;let v=o(f,h,b,m,g,p);if(b.transmission>0)r.push(v);else if(b.transparent===!0)i.push(v);else n.push(v)}function l(f,h,b,m,g,p){let y=o(f,h,b,m,g,p);if(b.transmission>0)r.unshift(y);else if(b.transparent===!0)i.unshift(y);else n.unshift(y)}function u(f,h){if(n.length>1)n.sort(f||fD);if(r.length>1)r.sort(h||kT);if(i.length>1)i.sort(h||kT)}function d(){for(let f=t,h=e.length;f<h;f++){let b=e[f];if(b.id===null)break;b.id=null,b.object=null,b.geometry=null,b.material=null,b.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:c,unshift:l,finish:d,sort:u}}function hD(){let e=new WeakMap;function t(r,i){let a=e.get(r),s;if(a===void 0)s=new LT,e.set(r,[s]);else if(i>=a.length)s=new LT,a.push(s);else s=a[i];return s}function n(){e=new WeakMap}return{get:t,dispose:n}}function pD(){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 V,color:new Je};break;case"SpotLight":n={position:new V,direction:new V,color:new Je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new V,color:new Je,distance:0,decay:0};break;case"HemisphereLight":n={direction:new V,skyColor:new Je,groundColor:new Je};break;case"RectAreaLight":n={color:new Je,position:new V,halfWidth:new V,halfHeight:new V};break}return e[t.id]=n,n}}}function mD(){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 We};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new We,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}function bD(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function xD(e){let t=new pD,n=mD(),r={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++)r.probe.push(new V);let i=new V,a=new Ze,s=new Ze;function o(l){let u=0,d=0,f=0;for(let R=0;R<9;R++)r.probe[R].set(0,0,0);let h=0,b=0,m=0,g=0,p=0,y=0,v=0,x=0,_=0,E=0,w=0,A=0,T=0,N=0;l.sort(bD);for(let R=0,k=l.length;R<k;R++){let C=l[R],{color:U,intensity:D,distance:P}=C,K=null;if(C.shadow&&C.shadow.map)if(C.shadow.map.texture.format===Cs)K=C.shadow.map.texture;else K=C.shadow.map.depthTexture||C.shadow.map.texture;if(C.isAmbientLight)u+=U.r*D,d+=U.g*D,f+=U.b*D;else if(C.isLightProbe){for(let z=0;z<9;z++)r.probe[z].addScaledVector(C.sh.coefficients[z],D);N++}else if(C.isSunLight){let z=t.get(C);if(z.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let W=C.shadow,q=n.get(C);q.shadowIntensity=W.intensity,q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize.copy(W.mapSize).multiply(W.getFrameExtents()),r.sunShadow[b]=q,r.sunShadowMap[b]=K;let le=W.getViewportCount();for(let he=0;he<le;he++)r.sunShadowMatrix[m+he]=W.getMatrix(he),r.sunShadowCascade[m+he]=W._cascadeData[he];m+=le,b++}r.sun[h]=z,h++}else if(C.isDirectionalLight){let z=t.get(C);if(z.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let W=C.shadow,q=n.get(C);q.shadowIntensity=W.intensity,q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,r.directionalShadow[g]=q,r.directionalShadowMap[g]=K,r.directionalShadowMatrix[g]=C.shadow.matrix,_++}r.directional[g]=z,g++}else if(C.isSpotLight){let z=t.get(C);z.position.setFromMatrixPosition(C.matrixWorld),z.color.copy(U).multiplyScalar(D),z.distance=P,z.coneCos=Math.cos(C.angle),z.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),z.decay=C.decay,r.spot[y]=z;let W=C.shadow;if(C.map){if(r.spotLightMap[A]=C.map,A++,W.updateMatrices(C),C.castShadow)T++}if(r.spotLightMatrix[y]=W.matrix,C.castShadow){let q=n.get(C);q.shadowIntensity=W.intensity,q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,r.spotShadow[y]=q,r.spotShadowMap[y]=K,w++}y++}else if(C.isRectAreaLight){let z=t.get(C);z.color.copy(U).multiplyScalar(D),z.halfWidth.set(C.width*0.5,0,0),z.halfHeight.set(0,C.height*0.5,0),r.rectArea[v]=z,v++}else if(C.isPointLight){let z=t.get(C);if(z.color.copy(C.color).multiplyScalar(C.intensity),z.distance=C.distance,z.decay=C.decay,C.castShadow){let W=C.shadow,q=n.get(C);q.shadowIntensity=W.intensity,q.shadowBias=W.bias,q.shadowNormalBias=W.normalBias,q.shadowRadius=W.radius,q.shadowMapSize=W.mapSize,q.shadowCameraNear=W.camera.near,q.shadowCameraFar=W.camera.far,r.pointShadow[p]=q,r.pointShadowMap[p]=K,r.pointShadowMatrix[p]=C.shadow.matrix,E++}r.point[p]=z,p++}else if(C.isHemisphereLight){let z=t.get(C);z.skyColor.copy(C.color).multiplyScalar(D),z.groundColor.copy(C.groundColor).multiplyScalar(D),r.hemi[x]=z,x++}}if(v>0)if(e.has("OES_texture_float_linear")===!0)r.rectAreaLTC1=Te.LTC_FLOAT_1,r.rectAreaLTC2=Te.LTC_FLOAT_2;else r.rectAreaLTC1=Te.LTC_HALF_1,r.rectAreaLTC2=Te.LTC_HALF_2;r.ambient[0]=u,r.ambient[1]=d,r.ambient[2]=f;let M=r.hash;if(M.sunLength!==h||M.directionalLength!==g||M.pointLength!==p||M.spotLength!==y||M.rectAreaLength!==v||M.hemiLength!==x||M.numSunShadows!==b||M.numDirectionalShadows!==_||M.numPointShadows!==E||M.numSpotShadows!==w||M.numSpotMaps!==A||M.numLightProbes!==N)r.sun.length=h,r.directional.length=g,r.spot.length=y,r.rectArea.length=v,r.point.length=p,r.hemi.length=x,r.sunShadow.length=b,r.sunShadowMap.length=b,r.sunShadowMatrix.length=m,r.sunShadowCascade.length=m,r.directionalShadow.length=_,r.directionalShadowMap.length=_,r.directionalShadowMatrix.length=_,r.pointShadow.length=E,r.pointShadowMap.length=E,r.pointShadowMatrix.length=E,r.spotShadow.length=w,r.spotShadowMap.length=w,r.spotLightMatrix.length=w+A-T,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=T,r.numLightProbes=N,M.sunLength=h,M.directionalLength=g,M.pointLength=p,M.spotLength=y,M.rectAreaLength=v,M.hemiLength=x,M.numSunShadows=b,M.numDirectionalShadows=_,M.numPointShadows=E,M.numSpotShadows=w,M.numSpotMaps=A,M.numLightProbes=N,r.version=gD++}function c(l,u){let d=0,f=0,h=0,b=0,m=0,g=0,p=u.matrixWorldInverse;for(let y=0,v=l.length;y<v;y++){let x=l[y];if(x.isSunLight){let _=r.sun[d];_.direction.setFromMatrixPosition(x.matrixWorld),_.direction.transformDirection(p),d++}else if(x.isDirectionalLight){let _=r.directional[f];_.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(p),f++}else if(x.isSpotLight){let _=r.spot[b];_.position.setFromMatrixPosition(x.matrixWorld),_.position.applyMatrix4(p),_.direction.setFromMatrixPosition(x.matrixWorld),i.setFromMatrixPosition(x.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(p),b++}else if(x.isRectAreaLight){let _=r.rectArea[m];_.position.setFromMatrixPosition(x.matrixWorld),_.position.applyMatrix4(p),s.identity(),a.copy(x.matrixWorld),a.premultiply(p),s.extractRotation(a),_.halfWidth.set(x.width*0.5,0,0),_.halfHeight.set(0,x.height*0.5,0),_.halfWidth.applyMatrix4(s),_.halfHeight.applyMatrix4(s),m++}else if(x.isPointLight){let _=r.point[h];_.position.setFromMatrixPosition(x.matrixWorld),_.position.applyMatrix4(p),h++}else if(x.isHemisphereLight){let _=r.hemi[g];_.direction.setFromMatrixPosition(x.matrixWorld),_.direction.transformDirection(p),g++}}}return{setup:o,setupView:c,state:r}}function DT(e){let t=new xD(e),n=[],r=[],i=[];function a(f){d.camera=f,n.length=0,r.length=0,i.length=0}function s(f){n.push(f)}function o(f){r.push(f)}function c(f){i.push(f)}function l(){t.setup(n)}function u(f){t.setupView(n,f)}let d={lightsArray:n,shadowsArray:r,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:d,setupLights:l,setupLightsView:u,pushLight:s,pushShadow:o,pushLightProbeGrid:c}}function yD(e){let t=new WeakMap;function n(i,a=0){let s=t.get(i),o;if(s===void 0)o=new DT(e),t.set(i,[o]);else if(a>=s.length)o=new DT(e),s.push(o);else o=s[a];return o}function r(){t=new WeakMap}return{get:n,dispose:r}}function TD(e,t,n){let r=new gl,i=new We,a=new We,s=new Pt,o=new Qm,c=new eg,l={},u=n.maxTextureSize,d={[ba]:Ln,[Ln]:ba,[wr]:wr},f=new Mr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new We},radius:{value:4}},vertexShader:_D,fragmentShader:vD}),h=f.clone();h.defines.HORIZONTAL_PASS=1;let b=new Dn;b.setAttribute("position",new En(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let m=new Gt(b,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rl;let p=this.type;this.render=function(E,w,A){if(g.enabled===!1)return;if(g.autoUpdate===!1&&g.needsUpdate===!1)return;if(E.length===0)return;if(this.type===hA)Ve("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=rl;let T=e.getRenderTarget(),N=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),R=e.state;if(R.setBlending(fi),R.buffers.depth.getReversed()===!0)R.buffers.color.setClear(0,0,0,0);else R.buffers.color.setClear(1,1,1,1);R.buffers.depth.setTest(!0),R.setScissorTest(!1);let k=p!==this.type;if(k)w.traverse(function(C){if(C.material)if(Array.isArray(C.material))C.material.forEach((U)=>U.needsUpdate=!0);else C.material.needsUpdate=!0});for(let C=0,U=E.length;C<U;C++){let D=E[C],P=D.shadow;if(P===void 0){Ve("WebGLShadowMap:",D,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;i.copy(P.mapSize);let K=P.getFrameExtents();if(i.multiply(K),a.copy(P.mapSize),i.x>u||i.y>u){if(i.x>u)a.x=Math.floor(u/K.x),i.x=a.x*K.x,P.mapSize.x=a.x;if(i.y>u)a.y=Math.floor(u/K.y),i.y=a.y*K.y,P.mapSize.y=a.y}let z=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=z,P.map===null||k===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Co){if(D.isPointLight){Ve("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new hr(i.x,i.y,{format:Cs,type:pi,minFilter:An,magFilter:An,generateMipmaps:!1}),P.map.texture.name=D.name+".shadowMap",P.map.depthTexture=new Ps(i.x,i.y,Hi),P.map.depthTexture.name=D.name+".shadowMapDepth",P.map.depthTexture.format=Rs,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=jr,P.map.depthTexture.magFilter=jr}else{if(D.isPointLight)P.map=new Ag(i.x),P.map.depthTexture=new Jm(i.x,xa);else P.map=new hr(i.x,i.y),P.map.depthTexture=new Ps(i.x,i.y,xa);if(P.map.depthTexture.name=D.name+".shadowMap",P.map.depthTexture.format=Rs,this.type===rl)P.map.depthTexture.compareFunction=z?Ld:kd,P.map.depthTexture.minFilter=An,P.map.depthTexture.magFilter=An;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=jr,P.map.depthTexture.magFilter=jr}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==i.x||P.map.height!==i.y))P.map.setSize(i.x,i.y);let W=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(D.isPointLight!==!0)P.updateMatrices(D,A);for(let q=0;q<W;q++){let le=P.getCamera(q);if(D.isPointLight){let{camera:he,matrix:xe}=P,pe=D.distance||he.far;if(pe!==he.far)he.far=pe,he.updateProjectionMatrix();wl.setFromMatrixPosition(D.matrixWorld),he.position.copy(wl),_g.copy(he.position),_g.add(ED[q]),he.up.copy(AD[q]),he.lookAt(_g),he.updateMatrixWorld(),xe.makeTranslation(-wl.x,-wl.y,-wl.z),FT.multiplyMatrices(he.projectionMatrix,he.matrixWorldInverse),P._frustum.setFromProjectionMatrix(FT,he.coordinateSystem,he.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,q),e.clear();else{if(q===0)e.setRenderTarget(P.map),e.clear();let he=P.getViewport(q);s.set(a.x*he.x,a.y*he.y,a.x*he.z,a.y*he.w),R.viewport(s)}r=P.getFrustum(q),x(w,A,le,D,this.type)}if(P.isPointLightShadow!==!0&&this.type===Co)y(P,A);P.needsUpdate=!1}p=this.type,g.needsUpdate=!1,e.setRenderTarget(T,N,M)};function y(E,w){let A=t.update(m);if(f.defines.VSM_SAMPLES!==E.blurSamples)f.defines.VSM_SAMPLES=E.blurSamples,h.defines.VSM_SAMPLES=E.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0;if(E.mapPass===null)E.mapPass=new hr(i.x,i.y,{format:Cs,type:pi});else if(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)E.mapPass.setSize(E.map.width,E.map.height);f.uniforms.shadow_pass.value=E.map.depthTexture,f.uniforms.resolution.value.set(E.map.width,E.map.height),f.uniforms.radius.value=E.radius,e.setRenderTarget(E.mapPass),e.clear(),e.renderBufferDirect(w,null,A,f,m,null),h.uniforms.shadow_pass.value=E.mapPass.texture,h.uniforms.resolution.value.set(E.map.width,E.map.height),h.uniforms.radius.value=E.radius,e.setRenderTarget(E.map),e.clear(),e.renderBufferDirect(w,null,A,h,m,null)}function v(E,w,A,T){let N=null,M=A.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(M!==void 0)N=M;else if(N=A.isPointLight===!0?c:o,e.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){let R=N.uuid,k=w.uuid,C=l[R];if(C===void 0)C={},l[R]=C;let U=C[k];if(U===void 0)U=N.clone(),C[k]=U,w.addEventListener("dispose",_);N=U}if(N.visible=w.visible,N.wireframe=w.wireframe,T===Co)N.side=w.shadowSide!==null?w.shadowSide:w.side;else N.side=w.shadowSide!==null?w.shadowSide:d[w.side];if(N.alphaMap=w.alphaMap,N.alphaTest=w.alphaToCoverage===!0?0.5:w.alphaTest,N.map=w.map,N.clipShadows=w.clipShadows,N.clippingPlanes=w.clippingPlanes,N.clipIntersection=w.clipIntersection,N.displacementMap=w.displacementMap,N.displacementScale=w.displacementScale,N.displacementBias=w.displacementBias,N.wireframeLinewidth=w.wireframeLinewidth,N.linewidth=w.linewidth,A.isPointLight===!0&&N.isMeshDistanceMaterial===!0){let R=e.properties.get(N);R.light=A}return N}function x(E,w,A,T,N){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)){if((E.castShadow||E.receiveShadow&&N===Co)&&(!E.frustumCulled||E.intersectsFrustum(r))){E.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,E.matrixWorld);let k=t.update(E),C=E.material;if(Array.isArray(C)){let U=k.groups;for(let D=0,P=U.length;D<P;D++){let K=U[D],z=C[K.materialIndex];if(z&&z.visible){let W=v(E,z,T,N);E.onBeforeShadow(e,E,w,A,k,W,K),e.renderBufferDirect(A,null,k,W,E,K),E.onAfterShadow(e,E,w,A,k,W,K)}}}else if(C.visible){let U=v(E,C,T,N);E.onBeforeShadow(e,E,w,A,k,U,null),e.renderBufferDirect(A,null,k,U,E,null),E.onAfterShadow(e,E,w,A,k,U,null)}}}let R=E.children;for(let k=0,C=R.length;k<C;k++)x(R[k],w,A,T,N)}function _(E){E.target.removeEventListener("dispose",_);for(let A in l){let T=l[A],N=E.target.uuid;if(N in T)T[N].dispose(),delete T[N]}}}function wD(e,t){function n(){let H=!1,ye=new Pt,se=null,_e=new Pt(0,0,0,0);return{setMask:function(Ce){if(se!==Ce&&!H)e.colorMask(Ce,Ce,Ce,Ce),se=Ce},setLocked:function(Ce){H=Ce},setClear:function(Ce,de,we,it,jt){if(jt===!0)Ce*=it,de*=it,we*=it;if(ye.set(Ce,de,we,it),_e.equals(ye)===!1)e.clearColor(Ce,de,we,it),_e.copy(ye)},reset:function(){H=!1,se=null,_e.set(-1,0,0,0)}}}function r(){let H=!1,ye=!1,se=null,_e=null,Ce=null;return{setReversed:function(de){if(ye!==de){let we=t.get("EXT_clip_control");if(de)we.clipControlEXT(we.LOWER_LEFT_EXT,we.ZERO_TO_ONE_EXT);else we.clipControlEXT(we.LOWER_LEFT_EXT,we.NEGATIVE_ONE_TO_ONE_EXT);ye=de;let it=Ce;Ce=null,this.setClear(it)}},getReversed:function(){return ye},setTest:function(de){if(de)X(e.DEPTH_TEST);else ne(e.DEPTH_TEST)},setMask:function(de){if(se!==de&&!H)e.depthMask(de),se=de},setFunc:function(de){if(ye)de=oT[de];if(_e!==de){switch(de){case kA:e.depthFunc(e.NEVER);break;case LA:e.depthFunc(e.ALWAYS);break;case DA:e.depthFunc(e.LESS);break;case Zp:e.depthFunc(e.LEQUAL);break;case FA:e.depthFunc(e.EQUAL);break;case UA:e.depthFunc(e.GEQUAL);break;case zA:e.depthFunc(e.GREATER);break;case BA:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}_e=de}},setLocked:function(de){H=de},setClear:function(de){if(Ce!==de){if(Ce=de,ye)de=1-de;e.clearDepth(de)}},reset:function(){H=!1,se=null,_e=null,Ce=null,ye=!1}}}function i(){let H=!1,ye=null,se=null,_e=null,Ce=null,de=null,we=null,it=null,jt=null;return{setTest:function(Rt){if(!H)if(Rt)X(e.STENCIL_TEST);else ne(e.STENCIL_TEST)},setMask:function(Rt){if(ye!==Rt&&!H)e.stencilMask(Rt),ye=Rt},setFunc:function(Rt,Jr,Mi){if(se!==Rt||_e!==Jr||Ce!==Mi)e.stencilFunc(Rt,Jr,Mi),se=Rt,_e=Jr,Ce=Mi},setOp:function(Rt,Jr,Mi){if(de!==Rt||we!==Jr||it!==Mi)e.stencilOp(Rt,Jr,Mi),de=Rt,we=Jr,it=Mi},setLocked:function(Rt){H=Rt},setClear:function(Rt){if(jt!==Rt)e.clearStencil(Rt),jt=Rt},reset:function(){H=!1,ye=null,se=null,_e=null,Ce=null,de=null,we=null,it=null,jt=null}}}let a=new n,s=new r,o=new i,c=new WeakMap,l=new WeakMap,u={},d={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,y=null,v=null,x=null,_=null,E=null,w=null,A=new Je(0,0,0),T=0,N=!1,M=null,R=null,k=null,C=null,U=null,D=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,K=0,z=e.getParameter(e.VERSION);if(z.indexOf("WebGL")!==-1)K=parseFloat(/^WebGL (\d)/.exec(z)[1]),P=K>=1;else if(z.indexOf("OpenGL ES")!==-1)K=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),P=K>=2;let W=null,q={},le=e.getParameter(e.SCISSOR_BOX),he=e.getParameter(e.VIEWPORT),xe=new Pt().fromArray(le),pe=new Pt().fromArray(he);function J(H,ye,se,_e){let Ce=new Uint8Array(4),de=e.createTexture();e.bindTexture(H,de),e.texParameteri(H,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(H,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let we=0;we<se;we++)if(H===e.TEXTURE_3D||H===e.TEXTURE_2D_ARRAY)e.texImage3D(ye,0,e.RGBA,1,1,_e,0,e.RGBA,e.UNSIGNED_BYTE,Ce);else e.texImage2D(ye+we,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,Ce);return de}let F={};F[e.TEXTURE_2D]=J(e.TEXTURE_2D,e.TEXTURE_2D,1),F[e.TEXTURE_CUBE_MAP]=J(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),F[e.TEXTURE_2D_ARRAY]=J(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),F[e.TEXTURE_3D]=J(e.TEXTURE_3D,e.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),X(e.DEPTH_TEST),s.setFunc(Zp),Wt(!1),dt(Wp),X(e.CULL_FACE),Xe(fi);function X(H){if(u[H]!==!0)e.enable(H),u[H]=!0}function ne(H){if(u[H]!==!1)e.disable(H),u[H]=!1}function re(H,ye){if(f[H]!==ye){if(e.bindFramebuffer(H,ye),f[H]=ye,H===e.DRAW_FRAMEBUFFER)f[e.FRAMEBUFFER]=ye;if(H===e.FRAMEBUFFER)f[e.DRAW_FRAMEBUFFER]=ye;return!0}return!1}function ce(H,ye){let se=b,_e=!1;if(H){if(se=h.get(ye),se===void 0)se=[],h.set(ye,se);let Ce=H.textures;if(se.length!==Ce.length||se[0]!==e.COLOR_ATTACHMENT0){for(let de=0,we=Ce.length;de<we;de++)se[de]=e.COLOR_ATTACHMENT0+de;se.length=Ce.length,_e=!0}}else if(se[0]!==e.BACK)se[0]=e.BACK,_e=!0;if(_e)e.drawBuffers(se)}function ve(H){if(m!==H)return e.useProgram(H),m=H,!0;return!1}let Re={[No]:e.FUNC_ADD,[mA]:e.FUNC_SUBTRACT,[gA]:e.FUNC_REVERSE_SUBTRACT};Re[bA]=e.MIN,Re[xA]=e.MAX;let ke={[yA]:e.ZERO,[_A]:e.ONE,[vA]:e.SRC_COLOR,[AA]:e.SRC_ALPHA,[IA]:e.SRC_ALPHA_SATURATE,[SA]:e.DST_COLOR,[wA]:e.DST_ALPHA,[EA]:e.ONE_MINUS_SRC_COLOR,[TA]:e.ONE_MINUS_SRC_ALPHA,[RA]:e.ONE_MINUS_DST_COLOR,[MA]:e.ONE_MINUS_DST_ALPHA,[CA]:e.CONSTANT_COLOR,[NA]:e.ONE_MINUS_CONSTANT_COLOR,[PA]:e.CONSTANT_ALPHA,[OA]:e.ONE_MINUS_CONSTANT_ALPHA};function Xe(H,ye,se,_e,Ce,de,we,it,jt,Rt){if(H===fi){if(g===!0)ne(e.BLEND),g=!1;return}if(g===!1)X(e.BLEND),g=!0;if(H!==pA){if(H!==p||Rt!==N){if(y!==No||_!==No)e.blendEquation(e.FUNC_ADD),y=No,_=No;if(Rt)switch(H){case il:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Xp:e.blendFunc(e.ONE,e.ONE);break;case qp:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Jp:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Qe("WebGLState: Invalid blending: ",H);break}else switch(H){case il:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Xp:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case qp:Qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Jp:Qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Qe("WebGLState: Invalid blending: ",H);break}v=null,x=null,E=null,w=null,A.set(0,0,0),T=0,p=H,N=Rt}return}if(Ce=Ce||ye,de=de||se,we=we||_e,ye!==y||Ce!==_)e.blendEquationSeparate(Re[ye],Re[Ce]),y=ye,_=Ce;if(se!==v||_e!==x||de!==E||we!==w)e.blendFuncSeparate(ke[se],ke[_e],ke[de],ke[we]),v=se,x=_e,E=de,w=we;if(it.equals(A)===!1||jt!==T)e.blendColor(it.r,it.g,it.b,jt),A.copy(it),T=jt;p=H,N=!1}function et(H,ye){H.side===wr?ne(e.CULL_FACE):X(e.CULL_FACE);let se=H.side===Ln;if(ye)se=!se;Wt(se),H.blending===il&&H.transparent===!1?Xe(fi):Xe(H.blending,H.blendEquation,H.blendSrc,H.blendDst,H.blendEquationAlpha,H.blendSrcAlpha,H.blendDstAlpha,H.blendColor,H.blendAlpha,H.premultipliedAlpha),s.setFunc(H.depthFunc),s.setTest(H.depthTest),s.setMask(H.depthWrite),a.setMask(H.colorWrite);let _e=H.stencilWrite;if(o.setTest(_e),_e)o.setMask(H.stencilWriteMask),o.setFunc(H.stencilFunc,H.stencilRef,H.stencilFuncMask),o.setOp(H.stencilFail,H.stencilZFail,H.stencilZPass);Qt(H.polygonOffset,H.polygonOffsetFactor,H.polygonOffsetUnits),H.alphaToCoverage===!0?X(e.SAMPLE_ALPHA_TO_COVERAGE):ne(e.SAMPLE_ALPHA_TO_COVERAGE)}function Wt(H){if(M!==H){if(H)e.frontFace(e.CW);else e.frontFace(e.CCW);M=H}}function dt(H){if(H!==dA){if(X(e.CULL_FACE),H!==R)if(H===Wp)e.cullFace(e.BACK);else if(H===fA)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else ne(e.CULL_FACE);R=H}function Ft(H){if(H!==k){if(P)e.lineWidth(H);k=H}}function Qt(H,ye,se){if(H){if(X(e.POLYGON_OFFSET_FILL),C!==ye||U!==se){if(C=ye,U=se,s.getReversed())ye=-ye;e.polygonOffset(ye,se)}}else ne(e.POLYGON_OFFSET_FILL)}function nn(H){if(H)X(e.SCISSOR_TEST);else ne(e.SCISSOR_TEST)}function B(H){if(H===void 0)H=e.TEXTURE0+D-1;if(W!==H)e.activeTexture(H),W=H}function _n(H,ye,se){if(se===void 0)if(W===null)se=e.TEXTURE0+D-1;else se=W;let _e=q[se];if(_e===void 0)_e={type:void 0,texture:void 0},q[se]=_e;if(_e.type!==H||_e.texture!==ye){if(W!==se)e.activeTexture(se),W=se;e.bindTexture(H,ye||F[H]),_e.type=H,_e.texture=ye}}function St(){let H=q[W];if(H!==void 0&&H.type!==void 0)e.bindTexture(H.type,null),H.type=void 0,H.texture=void 0}function Xt(){try{e.compressedTexImage2D(...arguments)}catch(H){Qe("WebGLState:",H)}}function O(){try{e.compressedTexImage3D(...arguments)}catch(H){Qe("WebGLState:",H)}}function S(){try{e.texSubImage2D(...arguments)}catch(H){Qe("WebGLState:",H)}}function j(){try{e.texSubImage3D(...arguments)}catch(H){Qe("WebGLState:",H)}}function ee(){try{e.compressedTexSubImage2D(...arguments)}catch(H){Qe("WebGLState:",H)}}function fe(){try{e.compressedTexSubImage3D(...arguments)}catch(H){Qe("WebGLState:",H)}}function be(){try{e.texStorage2D(...arguments)}catch(H){Qe("WebGLState:",H)}}function Ee(){try{e.texStorage3D(...arguments)}catch(H){Qe("WebGLState:",H)}}function ie(){try{e.texImage2D(...arguments)}catch(H){Qe("WebGLState:",H)}}function oe(){try{e.texImage3D(...arguments)}catch(H){Qe("WebGLState:",H)}}function Ie(H){if(d[H]!==void 0)return d[H];else return e.getParameter(H)}function je(H,ye){if(d[H]!==ye)e.pixelStorei(H,ye),d[H]=ye}function Ae(H){if(xe.equals(H)===!1)e.scissor(H.x,H.y,H.z,H.w),xe.copy(H)}function me(H){if(pe.equals(H)===!1)e.viewport(H.x,H.y,H.z,H.w),pe.copy(H)}function Ke(H,ye){let se=l.get(ye);if(se===void 0)se=new WeakMap,l.set(ye,se);let _e=se.get(H);if(_e===void 0)_e=e.getUniformBlockIndex(ye,H.name),se.set(H,_e)}function qe(H,ye){let _e=l.get(ye).get(H);if(c.get(ye)!==_e)e.uniformBlockBinding(ye,_e,H.__bindingPointIndex),c.set(ye,_e)}function vt(){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),s.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},W=null,q={},f={},h=new WeakMap,b=[],m=null,g=!1,p=null,y=null,v=null,x=null,_=null,E=null,w=null,A=new Je(0,0,0),T=0,N=!1,M=null,R=null,k=null,C=null,U=null,xe.set(0,0,e.canvas.width,e.canvas.height),pe.set(0,0,e.canvas.width,e.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:X,disable:ne,bindFramebuffer:re,drawBuffers:ce,useProgram:ve,setBlending:Xe,setMaterial:et,setFlipSided:Wt,setCullFace:dt,setLineWidth:Ft,setPolygonOffset:Qt,setScissorTest:nn,activeTexture:B,bindTexture:_n,unbindTexture:St,compressedTexImage2D:Xt,compressedTexImage3D:O,texImage2D:ie,texImage3D:oe,pixelStorei:je,getParameter:Ie,updateUBOMapping:Ke,uniformBlockBinding:qe,texStorage2D:be,texStorage3D:Ee,texSubImage2D:S,texSubImage3D:j,compressedTexSubImage2D:ee,compressedTexSubImage3D:fe,scissor:Ae,viewport:me,reset:vt}}function MD(e,t,n,r,i,a,s){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new We,u=new WeakMap,d=new Set,f,h=new WeakMap,b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(O){}function m(O,S){return b?new OffscreenCanvas(O,S):So("canvas")}function g(O,S,j){let ee=1,fe=Xt(O);if(fe.width>j||fe.height>j)ee=j/Math.max(fe.width,fe.height);if(ee<1)if(typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&O instanceof ImageBitmap||typeof VideoFrame<"u"&&O instanceof VideoFrame){let be=Math.floor(ee*fe.width),Ee=Math.floor(ee*fe.height);if(f===void 0)f=m(be,Ee);let ie=S?m(be,Ee):f;return ie.width=be,ie.height=Ee,ie.getContext("2d").drawImage(O,0,0,be,Ee),Ve("WebGLRenderer: Texture has been resized from ("+fe.width+"x"+fe.height+") to ("+be+"x"+Ee+")."),ie}else{if("data"in O)Ve("WebGLRenderer: Image in DataTexture is too big ("+fe.width+"x"+fe.height+").");return O}return O}function p(O){return O.generateMipmaps}function y(O){e.generateMipmap(O)}function v(O){if(O.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(O.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(O.isWebGLArrayRenderTarget||O.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function x(O,S,j,ee,fe,be=!1){if(O!==null){if(e[O]!==void 0)return e[O];Ve("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+O+"'")}let Ee;if(ee){if(Ee=t.get("EXT_texture_norm16"),!Ee)Ve("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let ie=S;if(S===e.RED){if(j===e.FLOAT)ie=e.R32F;if(j===e.HALF_FLOAT)ie=e.R16F;if(j===e.UNSIGNED_BYTE)ie=e.R8;if(j===e.UNSIGNED_SHORT&&Ee)ie=Ee.R16_EXT;if(j===e.SHORT&&Ee)ie=Ee.R16_SNORM_EXT}if(S===e.RED_INTEGER){if(j===e.UNSIGNED_BYTE)ie=e.R8UI;if(j===e.UNSIGNED_SHORT)ie=e.R16UI;if(j===e.UNSIGNED_INT)ie=e.R32UI;if(j===e.BYTE)ie=e.R8I;if(j===e.SHORT)ie=e.R16I;if(j===e.INT)ie=e.R32I}if(S===e.RG){if(j===e.FLOAT)ie=e.RG32F;if(j===e.HALF_FLOAT)ie=e.RG16F;if(j===e.UNSIGNED_BYTE)ie=e.RG8;if(j===e.UNSIGNED_SHORT&&Ee)ie=Ee.RG16_EXT;if(j===e.SHORT&&Ee)ie=Ee.RG16_SNORM_EXT}if(S===e.RG_INTEGER){if(j===e.UNSIGNED_BYTE)ie=e.RG8UI;if(j===e.UNSIGNED_SHORT)ie=e.RG16UI;if(j===e.UNSIGNED_INT)ie=e.RG32UI;if(j===e.BYTE)ie=e.RG8I;if(j===e.SHORT)ie=e.RG16I;if(j===e.INT)ie=e.RG32I}if(S===e.RGB_INTEGER){if(j===e.UNSIGNED_BYTE)ie=e.RGB8UI;if(j===e.UNSIGNED_SHORT)ie=e.RGB16UI;if(j===e.UNSIGNED_INT)ie=e.RGB32UI;if(j===e.BYTE)ie=e.RGB8I;if(j===e.SHORT)ie=e.RGB16I;if(j===e.INT)ie=e.RGB32I}if(S===e.RGBA_INTEGER){if(j===e.UNSIGNED_BYTE)ie=e.RGBA8UI;if(j===e.UNSIGNED_SHORT)ie=e.RGBA16UI;if(j===e.UNSIGNED_INT)ie=e.RGBA32UI;if(j===e.BYTE)ie=e.RGBA8I;if(j===e.SHORT)ie=e.RGBA16I;if(j===e.INT)ie=e.RGBA32I}if(S===e.RGB){if(j===e.UNSIGNED_SHORT&&Ee)ie=Ee.RGB16_EXT;if(j===e.SHORT&&Ee)ie=Ee.RGB16_SNORM_EXT;if(j===e.UNSIGNED_INT_5_9_9_9_REV)ie=e.RGB9_E5;if(j===e.UNSIGNED_INT_10F_11F_11F_REV)ie=e.R11F_G11F_B10F}if(S===e.RGBA){let oe=be?Gm:lt.getTransfer(fe);if(j===e.FLOAT)ie=e.RGBA32F;if(j===e.HALF_FLOAT)ie=e.RGBA16F;if(j===e.UNSIGNED_BYTE)ie=oe===Bt?e.SRGB8_ALPHA8:e.RGBA8;if(j===e.UNSIGNED_SHORT&&Ee)ie=Ee.RGBA16_EXT;if(j===e.SHORT&&Ee)ie=Ee.RGBA16_SNORM_EXT;if(j===e.UNSIGNED_SHORT_4_4_4_4)ie=e.RGBA4;if(j===e.UNSIGNED_SHORT_5_5_5_1)ie=e.RGB5_A1}if(ie===e.R16F||ie===e.R32F||ie===e.RG16F||ie===e.RG32F||ie===e.RGBA16F||ie===e.RGBA32F)t.get("EXT_color_buffer_float");return ie}function _(O,S){let j;if(O){if(S===null||S===xa||S===Do)j=e.DEPTH24_STENCIL8;else if(S===Hi)j=e.DEPTH32F_STENCIL8;else if(S===ol)j=e.DEPTH24_STENCIL8,Ve("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(S===null||S===xa||S===Do)j=e.DEPTH_COMPONENT24;else if(S===Hi)j=e.DEPTH_COMPONENT32F;else if(S===ol)j=e.DEPTH_COMPONENT16;return j}function E(O,S){if(p(O)===!0||O.isFramebufferTexture&&O.minFilter!==jr&&O.minFilter!==An)return Math.log2(Math.max(S.width,S.height))+1;else if(O.mipmaps!==void 0&&O.mipmaps.length>0)return O.mipmaps.length;else if(O.isCompressedTexture&&Array.isArray(O.image))return S.mipmaps.length;else return 1}function w(O){let S=O.target;if(S.removeEventListener("dispose",w),T(S),S.isVideoTexture)u.delete(S);if(S.isHTMLTexture)d.delete(S)}function A(O){let S=O.target;S.removeEventListener("dispose",A),M(S)}function T(O){let S=r.get(O);if(S.__webglInit===void 0)return;let j=O.source,ee=h.get(j);if(ee){let fe=ee[S.__cacheKey];if(fe.usedTimes--,fe.usedTimes===0)N(O);if(Object.keys(ee).length===0)h.delete(j)}r.remove(O)}function N(O){let S=r.get(O);e.deleteTexture(S.__webglTexture);let j=O.source,ee=h.get(j);delete ee[S.__cacheKey],s.memory.textures--}function M(O){let S=r.get(O);if(O.depthTexture)O.depthTexture.dispose(),r.remove(O.depthTexture);if(O.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(S.__webglFramebuffer[ee]))for(let fe=0;fe<S.__webglFramebuffer[ee].length;fe++)e.deleteFramebuffer(S.__webglFramebuffer[ee][fe]);else e.deleteFramebuffer(S.__webglFramebuffer[ee]);if(S.__webglDepthbuffer)e.deleteRenderbuffer(S.__webglDepthbuffer[ee])}else{if(Array.isArray(S.__webglFramebuffer))for(let ee=0;ee<S.__webglFramebuffer.length;ee++)e.deleteFramebuffer(S.__webglFramebuffer[ee]);else e.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer)e.deleteRenderbuffer(S.__webglDepthbuffer);if(S.__webglMultisampledFramebuffer)e.deleteFramebuffer(S.__webglMultisampledFramebuffer);if(S.__webglColorRenderbuffer){for(let ee=0;ee<S.__webglColorRenderbuffer.length;ee++)if(S.__webglColorRenderbuffer[ee])e.deleteRenderbuffer(S.__webglColorRenderbuffer[ee])}if(S.__webglDepthRenderbuffer)e.deleteRenderbuffer(S.__webglDepthRenderbuffer)}let j=O.textures;for(let ee=0,fe=j.length;ee<fe;ee++){let be=r.get(j[ee]);if(be.__webglTexture)e.deleteTexture(be.__webglTexture),s.memory.textures--;r.remove(j[ee])}r.remove(O)}let R=0;function k(){R=0}function C(){return R}function U(O){R=O}function D(){let O=R;if(O>=i.maxTextures)Ve("WebGLTextures: Trying to use "+(O+1)+" texture units while this GPU supports only "+i.maxTextures);return R+=1,O}function P(O){let S=[];return S.push(O.wrapS),S.push(O.wrapT),S.push(O.wrapR||0),S.push(O.magFilter),S.push(O.minFilter),S.push(O.anisotropy),S.push(O.internalFormat),S.push(O.format),S.push(O.type),S.push(O.generateMipmaps),S.push(O.premultiplyAlpha),S.push(O.flipY),S.push(O.unpackAlignment),S.push(O.colorSpace),S.join()}function K(O,S){let j=r.get(O);if(O.isVideoTexture)_n(O);if(O.isRenderTargetTexture===!1&&O.isExternalTexture!==!0&&O.version>0&&j.__version!==O.version){let ee=O.image;if(ee===null)Ve("WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)Ve("WebGLRenderer: Texture marked for update but image is incomplete");else{ne(j,O,S);return}}else if(O.isExternalTexture)j.__webglTexture=O.sourceTexture?O.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,j.__webglTexture,e.TEXTURE0+S)}function z(O,S){let j=r.get(O);if(O.isRenderTargetTexture===!1&&O.version>0&&j.__version!==O.version){ne(j,O,S);return}else if(O.isExternalTexture)j.__webglTexture=O.sourceTexture?O.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,j.__webglTexture,e.TEXTURE0+S)}function W(O,S){let j=r.get(O);if(O.isRenderTargetTexture===!1&&O.version>0&&j.__version!==O.version){ne(j,O,S);return}n.bindTexture(e.TEXTURE_3D,j.__webglTexture,e.TEXTURE0+S)}function q(O,S){let j=r.get(O);if(O.isCubeDepthTexture!==!0&&O.version>0&&j.__version!==O.version){re(j,O,S);return}n.bindTexture(e.TEXTURE_CUBE_MAP,j.__webglTexture,e.TEXTURE0+S)}let le={[Oo]:e.REPEAT,[ko]:e.CLAMP_TO_EDGE,[wd]:e.MIRRORED_REPEAT},he={[jr]:e.NEAREST,[Md]:e.NEAREST_MIPMAP_NEAREST,[Ss]:e.NEAREST_MIPMAP_LINEAR,[An]:e.LINEAR,[Lo]:e.LINEAR_MIPMAP_NEAREST,[hi]:e.LINEAR_MIPMAP_LINEAR},xe={[YA]:e.NEVER,[rT]:e.ALWAYS,[QA]:e.LESS,[kd]:e.LEQUAL,[eT]:e.EQUAL,[Ld]:e.GEQUAL,[tT]:e.GREATER,[nT]:e.NOTEQUAL};function pe(O,S){if(S.type===Hi&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===An||S.magFilter===Lo||S.magFilter===Ss||S.magFilter===hi||S.minFilter===An||S.minFilter===Lo||S.minFilter===Ss||S.minFilter===hi))Ve("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(O,e.TEXTURE_WRAP_S,le[S.wrapS]),e.texParameteri(O,e.TEXTURE_WRAP_T,le[S.wrapT]),O===e.TEXTURE_3D||O===e.TEXTURE_2D_ARRAY)e.texParameteri(O,e.TEXTURE_WRAP_R,le[S.wrapR]);if(e.texParameteri(O,e.TEXTURE_MAG_FILTER,he[S.magFilter]),e.texParameteri(O,e.TEXTURE_MIN_FILTER,he[S.minFilter]),S.compareFunction)e.texParameteri(O,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(O,e.TEXTURE_COMPARE_FUNC,xe[S.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===jr)return;if(S.minFilter!==Ss&&S.minFilter!==hi)return;if(S.type===Hi&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||r.get(S).__currentAnisotropy){let j=t.get("EXT_texture_filter_anisotropic");e.texParameterf(O,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),r.get(S).__currentAnisotropy=S.anisotropy}}}function J(O,S){let j=!1;if(O.__webglInit===void 0)O.__webglInit=!0,S.addEventListener("dispose",w);let ee=S.source,fe=h.get(ee);if(fe===void 0)fe={},h.set(ee,fe);let be=P(S);if(be!==O.__cacheKey){if(fe[be]===void 0)fe[be]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,j=!0;fe[be].usedTimes++;let Ee=fe[O.__cacheKey];if(Ee!==void 0){if(fe[O.__cacheKey].usedTimes--,Ee.usedTimes===0)N(S)}O.__cacheKey=be,O.__webglTexture=fe[be].texture}return j}function F(O,S,j){return Math.floor(Math.floor(O/j)/S)}function X(O,S,j,ee){let be=O.updateRanges;if(be.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,S.width,S.height,j,ee,S.data);else{be.sort((je,Ae)=>je.start-Ae.start);let Ee=0;for(let je=1;je<be.length;je++){let Ae=be[Ee],me=be[je],Ke=Ae.start+Ae.count,qe=F(me.start,S.width,4),vt=F(Ae.start,S.width,4);if(me.start<=Ke+1&&qe===vt&&F(me.start+me.count-1,S.width,4)===qe)Ae.count=Math.max(Ae.count,me.start+me.count-Ae.start);else++Ee,be[Ee]=me}be.length=Ee+1;let ie=n.getParameter(e.UNPACK_ROW_LENGTH),oe=n.getParameter(e.UNPACK_SKIP_PIXELS),Ie=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,S.width);for(let je=0,Ae=be.length;je<Ae;je++){let me=be[je],Ke=Math.floor(me.start/4),qe=Math.ceil(me.count/4),vt=Ke%S.width,H=Math.floor(Ke/S.width),ye=qe,se=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,vt),n.pixelStorei(e.UNPACK_SKIP_ROWS,H),n.texSubImage2D(e.TEXTURE_2D,0,vt,H,ye,1,j,ee,S.data)}O.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,ie),n.pixelStorei(e.UNPACK_SKIP_PIXELS,oe),n.pixelStorei(e.UNPACK_SKIP_ROWS,Ie)}}function ne(O,S,j){let ee=e.TEXTURE_2D;if(S.isDataArrayTexture||S.isCompressedArrayTexture)ee=e.TEXTURE_2D_ARRAY;if(S.isData3DTexture)ee=e.TEXTURE_3D;let fe=J(O,S),be=S.source;n.bindTexture(ee,O.__webglTexture,e.TEXTURE0+j);let Ee=r.get(be);if(be.version!==Ee.__version||fe===!0){if(n.activeTexture(e.TEXTURE0+j),(typeof ImageBitmap<"u"&&S.image instanceof ImageBitmap)===!1){let se=lt.getPrimaries(lt.workingColorSpace),_e=S.colorSpace===Ns?null:lt.getPrimaries(S.colorSpace),Ce=S.colorSpace===Ns||se===_e?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ce)}n.pixelStorei(e.UNPACK_ALIGNMENT,S.unpackAlignment);let oe=g(S.image,!1,i.maxTextureSize);oe=St(S,oe);let Ie=a.convert(S.format,S.colorSpace),je=a.convert(S.type),Ae=x(S.internalFormat,Ie,je,S.normalized,S.colorSpace,S.isVideoTexture);pe(ee,S);let me,Ke=S.mipmaps,qe=S.isVideoTexture!==!0,vt=Ee.__version===void 0||fe===!0,H=be.dataReady,ye=E(S,oe);if(S.isDepthTexture){if(Ae=_(S.format===Is,S.type),vt)if(qe)n.texStorage2D(e.TEXTURE_2D,1,Ae,oe.width,oe.height);else n.texImage2D(e.TEXTURE_2D,0,Ae,oe.width,oe.height,0,Ie,je,null)}else if(S.isDataTexture)if(Ke.length>0){if(qe&&vt)n.texStorage2D(e.TEXTURE_2D,ye,Ae,Ke[0].width,Ke[0].height);for(let se=0,_e=Ke.length;se<_e;se++)if(me=Ke[se],qe){if(H)n.texSubImage2D(e.TEXTURE_2D,se,0,0,me.width,me.height,Ie,je,me.data)}else n.texImage2D(e.TEXTURE_2D,se,Ae,me.width,me.height,0,Ie,je,me.data);S.generateMipmaps=!1}else if(qe){if(vt)n.texStorage2D(e.TEXTURE_2D,ye,Ae,oe.width,oe.height);if(H)X(S,oe,Ie,je)}else n.texImage2D(e.TEXTURE_2D,0,Ae,oe.width,oe.height,0,Ie,je,oe.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){if(qe&&vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ae,Ke[0].width,Ke[0].height,oe.depth);for(let se=0,_e=Ke.length;se<_e;se++)if(me=Ke[se],S.format!==mi)if(Ie!==null)if(qe){if(H)if(S.layerUpdates.size>0){let Ce=hg(me.width,me.height,S.format,S.type);for(let de of S.layerUpdates){let we=me.data.subarray(de*Ce/me.data.BYTES_PER_ELEMENT,(de+1)*Ce/me.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,se,0,0,de,me.width,me.height,1,Ie,we)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,se,0,0,0,me.width,me.height,oe.depth,Ie,me.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,se,Ae,me.width,me.height,oe.depth,0,me.data,0,0);else Ve("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(qe){if(H)n.texSubImage3D(e.TEXTURE_2D_ARRAY,se,0,0,0,me.width,me.height,oe.depth,Ie,je,me.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,se,Ae,me.width,me.height,oe.depth,0,Ie,je,me.data);if(S.layerUpdates.size>0)S.clearLayerUpdates()}else{if(qe&&vt)n.texStorage2D(e.TEXTURE_2D,ye,Ae,Ke[0].width,Ke[0].height);for(let se=0,_e=Ke.length;se<_e;se++)if(me=Ke[se],S.format!==mi)if(Ie!==null)if(qe){if(H)n.compressedTexSubImage2D(e.TEXTURE_2D,se,0,0,me.width,me.height,Ie,me.data)}else n.compressedTexImage2D(e.TEXTURE_2D,se,Ae,me.width,me.height,0,me.data);else Ve("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(qe){if(H)n.texSubImage2D(e.TEXTURE_2D,se,0,0,me.width,me.height,Ie,je,me.data)}else n.texImage2D(e.TEXTURE_2D,se,Ae,me.width,me.height,0,Ie,je,me.data)}else if(S.isDataArrayTexture)if(qe){if(vt)n.texStorage3D(e.TEXTURE_2D_ARRAY,ye,Ae,oe.width,oe.height,oe.depth);if(H)if(S.layerUpdates.size>0){let se=hg(oe.width,oe.height,S.format,S.type);for(let _e of S.layerUpdates){let Ce=oe.data.subarray(_e*se/oe.data.BYTES_PER_ELEMENT,(_e+1)*se/oe.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,_e,oe.width,oe.height,1,Ie,je,Ce)}S.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,Ie,je,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,Ae,oe.width,oe.height,oe.depth,0,Ie,je,oe.data);else if(S.isData3DTexture)if(qe){if(vt)n.texStorage3D(e.TEXTURE_3D,ye,Ae,oe.width,oe.height,oe.depth);if(H)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,Ie,je,oe.data)}else n.texImage3D(e.TEXTURE_3D,0,Ae,oe.width,oe.height,oe.depth,0,Ie,je,oe.data);else if(S.isFramebufferTexture){if(vt)if(qe)n.texStorage2D(e.TEXTURE_2D,ye,Ae,oe.width,oe.height);else{let se=oe.width,_e=oe.height;for(let Ce=0;Ce<ye;Ce++)n.texImage2D(e.TEXTURE_2D,Ce,Ae,se,_e,0,Ie,je,null),se>>=1,_e>>=1}}else if(S.isHTMLTexture){if("texElementImage2D"in e){let se=e.canvas;if(!se.hasAttribute("layoutsubtree"))se.setAttribute("layoutsubtree","true");if(oe.parentNode!==se){se.appendChild(oe),d.add(S),se.onpaint=(_e)=>{let Ce=_e.changedElements;for(let de of d)if(Ce.includes(de.image))de.needsUpdate=!0},se.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,oe);else{let{RGBA:Ce,RGBA:de,UNSIGNED_BYTE:we}=e;e.texElementImage2D(e.TEXTURE_2D,0,Ce,de,we,oe)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Ke.length>0){if(qe&&vt){let se=Xt(Ke[0]);n.texStorage2D(e.TEXTURE_2D,ye,Ae,se.width,se.height)}for(let se=0,_e=Ke.length;se<_e;se++)if(me=Ke[se],qe){if(H)n.texSubImage2D(e.TEXTURE_2D,se,0,0,Ie,je,me)}else n.texImage2D(e.TEXTURE_2D,se,Ae,Ie,je,me);S.generateMipmaps=!1}else if(qe){if(vt){let se=Xt(oe);n.texStorage2D(e.TEXTURE_2D,ye,Ae,se.width,se.height)}if(H)n.texSubImage2D(e.TEXTURE_2D,0,0,0,Ie,je,oe)}else n.texImage2D(e.TEXTURE_2D,0,Ae,Ie,je,oe);if(p(S))y(ee);if(Ee.__version=be.version,S.onUpdate)S.onUpdate(S)}O.__version=S.version}function re(O,S,j){if(S.image.length!==6)return;let ee=J(O,S),fe=S.source;n.bindTexture(e.TEXTURE_CUBE_MAP,O.__webglTexture,e.TEXTURE0+j);let be=r.get(fe);if(fe.version!==be.__version||ee===!0){n.activeTexture(e.TEXTURE0+j);let Ee=lt.getPrimaries(lt.workingColorSpace),ie=S.colorSpace===Ns?null:lt.getPrimaries(S.colorSpace),oe=S.colorSpace===Ns||Ee===ie?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,S.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,S.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe);let Ie=S.isCompressedTexture||S.image[0].isCompressedTexture,je=S.image[0]&&S.image[0].isDataTexture,Ae=[];for(let de=0;de<6;de++){if(!Ie&&!je)Ae[de]=g(S.image[de],!0,i.maxCubemapSize);else Ae[de]=je?S.image[de].image:S.image[de];Ae[de]=St(S,Ae[de])}let me=Ae[0],Ke=a.convert(S.format,S.colorSpace),qe=a.convert(S.type),vt=x(S.internalFormat,Ke,qe,S.normalized,S.colorSpace),H=S.isVideoTexture!==!0,ye=be.__version===void 0||ee===!0,se=fe.dataReady,_e=E(S,me);pe(e.TEXTURE_CUBE_MAP,S);let Ce;if(Ie){if(H&&ye)n.texStorage2D(e.TEXTURE_CUBE_MAP,_e,vt,me.width,me.height);for(let de=0;de<6;de++){Ce=Ae[de].mipmaps;for(let we=0;we<Ce.length;we++){let it=Ce[we];if(S.format!==mi)if(Ke!==null)if(H){if(se)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we,0,0,it.width,it.height,Ke,it.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we,vt,it.width,it.height,0,it.data);else Ve("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(H){if(se)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we,0,0,it.width,it.height,Ke,qe,it.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we,vt,it.width,it.height,0,Ke,qe,it.data)}}}else{if(Ce=S.mipmaps,H&&ye){if(Ce.length>0)_e++;let de=Xt(Ae[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,_e,vt,de.width,de.height)}for(let de=0;de<6;de++)if(je){if(H){if(se)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Ae[de].width,Ae[de].height,Ke,qe,Ae[de].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,vt,Ae[de].width,Ae[de].height,0,Ke,qe,Ae[de].data);for(let we=0;we<Ce.length;we++){let jt=Ce[we].image[de].image;if(H){if(se)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we+1,0,0,jt.width,jt.height,Ke,qe,jt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we+1,vt,jt.width,jt.height,0,Ke,qe,jt.data)}}else{if(H){if(se)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Ke,qe,Ae[de])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,vt,Ke,qe,Ae[de]);for(let we=0;we<Ce.length;we++){let it=Ce[we];if(H){if(se)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we+1,0,0,Ke,qe,it.image[de])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+de,we+1,vt,Ke,qe,it.image[de])}}}if(p(S))y(e.TEXTURE_CUBE_MAP);if(be.__version=fe.version,S.onUpdate)S.onUpdate(S)}O.__version=S.version}function ce(O,S,j,ee,fe,be){let Ee=a.convert(j.format,j.colorSpace),ie=a.convert(j.type),oe=x(j.internalFormat,Ee,ie,j.normalized,j.colorSpace),Ie=r.get(S),je=r.get(j);if(je.__renderTarget=S,!Ie.__hasExternalTextures){let Ae=Math.max(1,S.width>>be),me=Math.max(1,S.height>>be);if(fe===e.TEXTURE_3D||fe===e.TEXTURE_2D_ARRAY)n.texImage3D(fe,be,oe,Ae,me,S.depth,0,Ee,ie,null);else n.texImage2D(fe,be,oe,Ae,me,0,Ee,ie,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,O),B(S))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,ee,fe,je.__webglTexture,0,nn(S));else if(fe===e.TEXTURE_2D||fe>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&fe<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,ee,fe,je.__webglTexture,be);n.bindFramebuffer(e.FRAMEBUFFER,null)}function ve(O,S,j){if(e.bindRenderbuffer(e.RENDERBUFFER,O),S.depthBuffer){let ee=S.depthTexture,fe=ee&&ee.isDepthTexture?ee.type:null,be=_(S.stencilBuffer,fe),Ee=S.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(B(S))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(S),be,S.width,S.height);else if(j)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(S),be,S.width,S.height);else e.renderbufferStorage(e.RENDERBUFFER,be,S.width,S.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,Ee,e.RENDERBUFFER,O)}else{let ee=S.textures;for(let fe=0;fe<ee.length;fe++){let be=ee[fe],Ee=a.convert(be.format,be.colorSpace),ie=a.convert(be.type),oe=x(be.internalFormat,Ee,ie,be.normalized,be.colorSpace);if(B(S))o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,nn(S),oe,S.width,S.height);else if(j)e.renderbufferStorageMultisample(e.RENDERBUFFER,nn(S),oe,S.width,S.height);else e.renderbufferStorage(e.RENDERBUFFER,oe,S.width,S.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Re(O,S,j){let ee=S.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,O),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let fe=r.get(S.depthTexture);if(fe.__renderTarget=S,!fe.__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0;if(ee){if(fe.__webglInit===void 0)fe.__webglInit=!0,S.depthTexture.addEventListener("dispose",w);if(fe.__webglTexture===void 0){fe.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,fe.__webglTexture),pe(e.TEXTURE_CUBE_MAP,S.depthTexture);let Ie=a.convert(S.depthTexture.format),je=a.convert(S.depthTexture.type),Ae;if(S.depthTexture.format===Rs)Ae=e.DEPTH_COMPONENT24;else if(S.depthTexture.format===Is)Ae=e.DEPTH24_STENCIL8;for(let me=0;me<6;me++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+me,0,Ae,S.width,S.height,0,Ie,je,null)}}else K(S.depthTexture,0);let be=fe.__webglTexture,Ee=nn(S),ie=ee?e.TEXTURE_CUBE_MAP_POSITIVE_X+j:e.TEXTURE_2D,oe=S.depthTexture.format===Is?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(S.depthTexture.format===Rs)if(B(S))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,ie,be,0,Ee);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,ie,be,0);else if(S.depthTexture.format===Is)if(B(S))o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,oe,ie,be,0,Ee);else e.framebufferTexture2D(e.FRAMEBUFFER,oe,ie,be,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ke(O){let S=r.get(O),j=O.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==O.depthTexture){let ee=O.depthTexture;if(S.__depthDisposeCallback)S.__depthDisposeCallback();if(ee){let fe=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,ee.removeEventListener("dispose",fe)};ee.addEventListener("dispose",fe),S.__depthDisposeCallback=fe}S.__boundDepthTexture=ee}if(O.depthTexture&&!S.__autoAllocateDepthBuffer)if(j)for(let ee=0;ee<6;ee++)Re(S.__webglFramebuffer[ee],O,ee);else{let ee=O.texture.mipmaps;if(ee&&ee.length>0)Re(S.__webglFramebuffer[0],O,0);else Re(S.__webglFramebuffer,O,0)}else if(j){S.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)if(n.bindFramebuffer(e.FRAMEBUFFER,S.__webglFramebuffer[ee]),S.__webglDepthbuffer[ee]===void 0)S.__webglDepthbuffer[ee]=e.createRenderbuffer(),ve(S.__webglDepthbuffer[ee],O,!1);else{let fe=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,be=S.__webglDepthbuffer[ee];e.bindRenderbuffer(e.RENDERBUFFER,be),e.framebufferRenderbuffer(e.FRAMEBUFFER,fe,e.RENDERBUFFER,be)}}else{let ee=O.texture.mipmaps;if(ee&&ee.length>0)n.bindFramebuffer(e.FRAMEBUFFER,S.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,S.__webglFramebuffer);if(S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=e.createRenderbuffer(),ve(S.__webglDepthbuffer,O,!1);else{let fe=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,be=S.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,be),e.framebufferRenderbuffer(e.FRAMEBUFFER,fe,e.RENDERBUFFER,be)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function Xe(O,S,j){let ee=r.get(O);if(S!==void 0)ce(ee.__webglFramebuffer,O,O.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(j!==void 0)ke(O)}function et(O){let S=O.texture,j=r.get(O),ee=r.get(S);O.addEventListener("dispose",A);let fe=O.textures,be=O.isWebGLCubeRenderTarget===!0,Ee=fe.length>1;if(!Ee){if(ee.__webglTexture===void 0)ee.__webglTexture=e.createTexture();ee.__version=S.version,s.memory.textures++}if(be){j.__webglFramebuffer=[];for(let ie=0;ie<6;ie++)if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer[ie]=[];for(let oe=0;oe<S.mipmaps.length;oe++)j.__webglFramebuffer[ie][oe]=e.createFramebuffer()}else j.__webglFramebuffer[ie]=e.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){j.__webglFramebuffer=[];for(let ie=0;ie<S.mipmaps.length;ie++)j.__webglFramebuffer[ie]=e.createFramebuffer()}else j.__webglFramebuffer=e.createFramebuffer();if(Ee)for(let ie=0,oe=fe.length;ie<oe;ie++){let Ie=r.get(fe[ie]);if(Ie.__webglTexture===void 0)Ie.__webglTexture=e.createTexture(),s.memory.textures++}if(O.samples>0&&B(O)===!1){j.__webglMultisampledFramebuffer=e.createFramebuffer(),j.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,j.__webglMultisampledFramebuffer);for(let ie=0;ie<fe.length;ie++){let oe=fe[ie];j.__webglColorRenderbuffer[ie]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,j.__webglColorRenderbuffer[ie]);let Ie=a.convert(oe.format,oe.colorSpace),je=a.convert(oe.type),Ae=x(oe.internalFormat,Ie,je,oe.normalized,oe.colorSpace,O.isXRRenderTarget===!0),me=nn(O);e.renderbufferStorageMultisample(e.RENDERBUFFER,me,Ae,O.width,O.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+ie,e.RENDERBUFFER,j.__webglColorRenderbuffer[ie])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),O.depthBuffer)j.__webglDepthRenderbuffer=e.createRenderbuffer(),ve(j.__webglDepthRenderbuffer,O,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(be){n.bindTexture(e.TEXTURE_CUBE_MAP,ee.__webglTexture),pe(e.TEXTURE_CUBE_MAP,S);for(let ie=0;ie<6;ie++)if(S.mipmaps&&S.mipmaps.length>0)for(let oe=0;oe<S.mipmaps.length;oe++)ce(j.__webglFramebuffer[ie][oe],O,S,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,oe);else ce(j.__webglFramebuffer[ie],O,S,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0);if(p(S))y(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(Ee){for(let ie=0,oe=fe.length;ie<oe;ie++){let Ie=fe[ie],je=r.get(Ie),Ae=e.TEXTURE_2D;if(O.isWebGL3DRenderTarget||O.isWebGLArrayRenderTarget)Ae=O.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Ae,je.__webglTexture),pe(Ae,Ie),ce(j.__webglFramebuffer,O,Ie,e.COLOR_ATTACHMENT0+ie,Ae,0),p(Ie))y(Ae)}n.unbindTexture()}else{let ie=e.TEXTURE_2D;if(O.isWebGL3DRenderTarget||O.isWebGLArrayRenderTarget)ie=O.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(ie,ee.__webglTexture),pe(ie,S),S.mipmaps&&S.mipmaps.length>0)for(let oe=0;oe<S.mipmaps.length;oe++)ce(j.__webglFramebuffer[oe],O,S,e.COLOR_ATTACHMENT0,ie,oe);else ce(j.__webglFramebuffer,O,S,e.COLOR_ATTACHMENT0,ie,0);if(p(S))y(ie);n.unbindTexture()}if(O.depthBuffer)ke(O)}function Wt(O){let S=O.textures;for(let j=0,ee=S.length;j<ee;j++){let fe=S[j];if(p(fe)){let be=v(O),Ee=r.get(fe).__webglTexture;n.bindTexture(be,Ee),y(be),n.unbindTexture()}}}let dt=[],Ft=[];function Qt(O){if(O.samples>0){if(B(O)===!1){let{textures:S,width:j,height:ee}=O,fe=e.COLOR_BUFFER_BIT,be=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,Ee=r.get(O),ie=S.length>1;if(ie)for(let Ie=0;Ie<S.length;Ie++)n.bindFramebuffer(e.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,Ee.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,Ee.__webglMultisampledFramebuffer);let oe=O.texture.mipmaps;if(oe&&oe.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,Ee.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,Ee.__webglFramebuffer);for(let Ie=0;Ie<S.length;Ie++){if(O.resolveDepthBuffer){if(O.depthBuffer)fe|=e.DEPTH_BUFFER_BIT;if(O.stencilBuffer&&O.resolveStencilBuffer)fe|=e.STENCIL_BUFFER_BIT}if(ie){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,Ee.__webglColorRenderbuffer[Ie]);let je=r.get(S[Ie]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,je,0)}if(e.blitFramebuffer(0,0,j,ee,0,0,j,ee,fe,e.NEAREST),c===!0){if(dt.length=0,Ft.length=0,dt.push(e.COLOR_ATTACHMENT0+Ie),O.depthBuffer&&O.storeMultisampledDepthBuffer===!1)dt.push(be),Ft.push(be),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,Ft);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,dt)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),ie)for(let Ie=0;Ie<S.length;Ie++){n.bindFramebuffer(e.FRAMEBUFFER,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.RENDERBUFFER,Ee.__webglColorRenderbuffer[Ie]);let je=r.get(S[Ie]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,Ee.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+Ie,e.TEXTURE_2D,je,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,Ee.__webglMultisampledFramebuffer)}else if(O.depthBuffer&&O.storeMultisampledDepthBuffer===!1&&c){let S=O.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[S])}}}function nn(O){return Math.min(i.maxSamples,O.samples)}function B(O){let S=r.get(O);return O.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function _n(O){let S=s.render.frame;if(u.get(O)!==S)u.set(O,S),O.update()}function St(O,S){let{colorSpace:j,format:ee,type:fe}=O;if(O.isCompressedTexture===!0||O.isVideoTexture===!0)return S;if(j!==fr&&j!==Ns)if(lt.getTransfer(j)===Bt){if(ee!==mi||fe!==Vr)Ve("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Qe("WebGLTextures: Unsupported texture color space:",j);return S}function Xt(O){if(typeof HTMLImageElement<"u"&&O instanceof HTMLImageElement)l.width=O.naturalWidth||O.width,l.height=O.naturalHeight||O.height;else if(typeof VideoFrame<"u"&&O instanceof VideoFrame)l.width=O.displayWidth,l.height=O.displayHeight;else l.width=O.width,l.height=O.height;return l}this.allocateTextureUnit=D,this.resetTextureUnits=k,this.getTextureUnits=C,this.setTextureUnits=U,this.setTexture2D=K,this.setTexture2DArray=z,this.setTexture3D=W,this.setTextureCube=q,this.rebindTextures=Xe,this.setupRenderTarget=et,this.updateRenderTargetMipmap=Wt,this.updateMultisampleRenderTarget=Qt,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=B,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function SD(e,t){function n(r,i=Ns){let a,s=lt.getTransfer(i);if(r===Vr)return e.UNSIGNED_BYTE;if(r===am)return e.UNSIGNED_SHORT_4_4_4_4;if(r===sm)return e.UNSIGNED_SHORT_5_5_5_1;if(r===KA)return e.UNSIGNED_INT_5_9_9_9_REV;if(r===WA)return e.UNSIGNED_INT_10F_11F_11F_REV;if(r===HA)return e.BYTE;if(r===$A)return e.SHORT;if(r===ol)return e.UNSIGNED_SHORT;if(r===im)return e.INT;if(r===xa)return e.UNSIGNED_INT;if(r===Hi)return e.FLOAT;if(r===pi)return e.HALF_FLOAT;if(r===XA)return e.ALPHA;if(r===qA)return e.RGB;if(r===mi)return e.RGBA;if(r===Rs)return e.DEPTH_COMPONENT;if(r===Is)return e.DEPTH_STENCIL;if(r===JA)return e.RED;if(r===om)return e.RED_INTEGER;if(r===Cs)return e.RG;if(r===cm)return e.RG_INTEGER;if(r===lm)return e.RGBA_INTEGER;if(r===Sd||r===Rd||r===Id||r===Cd)if(s===Bt)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===Sd)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Rd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Id)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Cd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===Sd)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Rd)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Id)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Cd)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===um||r===dm||r===fm||r===hm)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===um)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===dm)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===fm)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===hm)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===pm||r===mm||r===gm||r===bm||r===xm||r===Nd||r===ym)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(r===pm||r===mm)return s===Bt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===gm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===bm)return a.COMPRESSED_R11_EAC;if(r===xm)return a.COMPRESSED_SIGNED_R11_EAC;if(r===Nd)return a.COMPRESSED_RG11_EAC;if(r===ym)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===_m||r===vm||r===Em||r===Am||r===Tm||r===wm||r===Mm||r===Sm||r===Rm||r===Im||r===Cm||r===Nm||r===Pm||r===Om)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(r===_m)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===vm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Em)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Am)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Tm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===wm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Mm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Sm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Rm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Im)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Cm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Nm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Pm)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Om)return s===Bt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===km||r===Lm||r===Dm)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(r===km)return s===Bt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Lm)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Dm)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===Fm||r===Um||r===Pd||r===zm)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(r===Fm)return a.COMPRESSED_RED_RGTC1_EXT;if(r===Um)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Pd)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===zm)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(r===Do)return e.UNSIGNED_INT_24_8;return e[r]!==void 0?e[r]:null}return{convert:n}}class qT{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Hd(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 Mr({vertexShader:RD,fragmentShader:ID,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Gt(new yl(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}function ND(e,t){function n(g,p){if(g.matrixAutoUpdate===!0)g.updateMatrix();p.value.copy(g.matrix)}function r(g,p){if(p.color.getRGB(g.fogColor.value,Zm(e)),p.isFog)g.fogNear.value=p.near,g.fogFar.value=p.far;else if(p.isFogExp2)g.fogDensity.value=p.density}function i(g,p,y,v,x){if(p.isNodeMaterial)p.uniformsNeedUpdate=!1;else if(p.isMeshBasicMaterial)a(g,p);else if(p.isMeshLambertMaterial){if(a(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshToonMaterial)a(g,p),d(g,p);else if(p.isMeshPhongMaterial){if(a(g,p),u(g,p),p.envMap)g.envMapIntensity.value=p.envMapIntensity}else if(p.isMeshStandardMaterial){if(a(g,p),f(g,p),p.isMeshPhysicalMaterial)h(g,p,x)}else if(p.isMeshMatcapMaterial)a(g,p),b(g,p);else if(p.isMeshDepthMaterial)a(g,p);else if(p.isMeshDistanceMaterial)a(g,p),m(g,p);else if(p.isMeshNormalMaterial)a(g,p);else if(p.isLineBasicMaterial){if(s(g,p),p.isLineDashedMaterial)o(g,p)}else if(p.isPointsMaterial)c(g,p,y,v);else if(p.isSpriteMaterial)l(g,p);else if(p.isShadowMaterial)g.color.value.copy(p.color),g.opacity.value=p.opacity;else if(p.isShaderMaterial)p.uniformsNeedUpdate=!1}function a(g,p){if(g.opacity.value=p.opacity,p.color)g.diffuse.value.copy(p.color);if(p.emissive)g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity);if(p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.bumpMap){if(g.bumpMap.value=p.bumpMap,n(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===Ln)g.bumpScale.value*=-1}if(p.normalMap){if(g.normalMap.value=p.normalMap,n(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===Ln)g.normalScale.value.negate()}if(p.displacementMap)g.displacementMap.value=p.displacementMap,n(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias;if(p.emissiveMap)g.emissiveMap.value=p.emissiveMap,n(p.emissiveMap,g.emissiveMapTransform);if(p.specularMap)g.specularMap.value=p.specularMap,n(p.specularMap,g.specularMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest;let y=t.get(p),{envMap:v,envMapRotation:x}=y;if(v){if(g.envMap.value=v,g.envMapRotation.value.setFromMatrix4(CD.makeRotationFromEuler(x)).transpose(),v.isCubeTexture&&v.isRenderTargetTexture===!1)g.envMapRotation.value.premultiply(ZT);g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio}if(p.lightMap)g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,n(p.lightMap,g.lightMapTransform);if(p.aoMap)g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,n(p.aoMap,g.aoMapTransform)}function s(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map)g.map.value=p.map,n(p.map,g.mapTransform)}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,y,v){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=v*0.5,p.map)g.map.value=p.map,n(p.map,g.uvTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function l(g,p){if(g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map)g.map.value=p.map,n(p.map,g.mapTransform);if(p.alphaMap)g.alphaMap.value=p.alphaMap,n(p.alphaMap,g.alphaMapTransform);if(p.alphaTest>0)g.alphaTest.value=p.alphaTest}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,0.0001)}function d(g,p){if(p.gradientMap)g.gradientMap.value=p.gradientMap}function f(g,p){if(g.metalness.value=p.metalness,p.metalnessMap)g.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,g.metalnessMapTransform);if(g.roughness.value=p.roughness,p.roughnessMap)g.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,g.roughnessMapTransform);if(p.envMap)g.envMapIntensity.value=p.envMapIntensity}function h(g,p,y){if(g.ior.value=p.ior,p.sheen>0){if(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap)g.sheenColorMap.value=p.sheenColorMap,n(p.sheenColorMap,g.sheenColorMapTransform);if(p.sheenRoughnessMap)g.sheenRoughnessMap.value=p.sheenRoughnessMap,n(p.sheenRoughnessMap,g.sheenRoughnessMapTransform)}if(p.clearcoat>0){if(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap)g.clearcoatMap.value=p.clearcoatMap,n(p.clearcoatMap,g.clearcoatMapTransform);if(p.clearcoatRoughnessMap)g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,n(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform);if(p.clearcoatNormalMap){if(g.clearcoatNormalMap.value=p.clearcoatNormalMap,n(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ln)g.clearcoatNormalScale.value.negate()}}if(p.dispersion>0)g.dispersion.value=p.dispersion;if(p.retroreflectivity>0)g.retroreflectivity.value=p.retroreflectivity;if(p.iridescence>0){if(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap)g.iridescenceMap.value=p.iridescenceMap,n(p.iridescenceMap,g.iridescenceMapTransform);if(p.iridescenceThicknessMap)g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,n(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform)}if(p.transmission>0){if(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap)g.transmissionMap.value=p.transmissionMap,n(p.transmissionMap,g.transmissionMapTransform);if(g.thickness.value=p.thickness,p.thicknessMap)g.thicknessMap.value=p.thicknessMap,n(p.thicknessMap,g.thicknessMapTransform);g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)}if(p.anisotropy>0){if(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap)g.anisotropyMap.value=p.anisotropyMap,n(p.anisotropyMap,g.anisotropyMapTransform)}if(g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap)g.specularColorMap.value=p.specularColorMap,n(p.specularColorMap,g.specularColorMapTransform);if(p.specularIntensityMap)g.specularIntensityMap.value=p.specularIntensityMap,n(p.specularIntensityMap,g.specularIntensityMapTransform)}function b(g,p){if(p.matcap)g.matcap.value=p.matcap}function m(g,p){let y=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function PD(e,t,n,r){let i={},a={},s=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,_){let E=_.program;r.uniformBlockBinding(x,E)}function l(x,_){let E=i[x.id];if(E===void 0)g(x),E=u(x),i[x.id]=E,x.addEventListener("dispose",y);let w=_.program;r.updateUBOMapping(x,w);let A=t.render.frame;if(a[x.id]!==A)f(x),a[x.id]=A}function u(x){let _=d();x.__bindingPointIndex=_;let E=e.createBuffer(),{__size:w,usage:A}=x;return e.bindBuffer(e.UNIFORM_BUFFER,E),e.bufferData(e.UNIFORM_BUFFER,w,A),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,_,E),E}function d(){for(let x=0;x<o;x++)if(s.indexOf(x)===-1)return s.push(x),x;return Qe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(x){let _=i[x.id],{uniforms:E,__cache:w}=x;e.bindBuffer(e.UNIFORM_BUFFER,_);for(let A=0,T=E.length;A<T;A++){let N=E[A];if(Array.isArray(N))for(let M=0,R=N.length;M<R;M++)h(N[M],A,M,w);else h(N,A,0,w)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function h(x,_,E,w){if(m(x,_,E,w)===!0){let{__offset:A,value:T}=x;if(Array.isArray(T)){let N=0;for(let M=0;M<T.length;M++){let R=T[M],k=p(R);if(b(R,x.__data,N),typeof R!=="number"&&typeof R!=="boolean"&&!R.isMatrix3&&!ArrayBuffer.isView(R))N+=k.storage/Float32Array.BYTES_PER_ELEMENT}}else b(T,x.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,A,x.__data)}}function b(x,_,E){if(typeof x==="number"||typeof x==="boolean")_[0]=x;else if(x.isMatrix3)_[0]=x.elements[0],_[1]=x.elements[1],_[2]=x.elements[2],_[3]=0,_[4]=x.elements[3],_[5]=x.elements[4],_[6]=x.elements[5],_[7]=0,_[8]=x.elements[6],_[9]=x.elements[7],_[10]=x.elements[8],_[11]=0;else if(ArrayBuffer.isView(x))_.set(new x.constructor(x.buffer,x.byteOffset,_.length));else x.toArray(_,E)}function m(x,_,E,w){let A=x.value,T=_+"_"+E;if(w[T]===void 0){if(typeof A==="number"||typeof A==="boolean")w[T]=A;else if(ArrayBuffer.isView(A))w[T]=A.slice();else w[T]=A.clone();return!0}else{let N=w[T];if(typeof A==="number"||typeof A==="boolean"){if(N!==A)return w[T]=A,!0}else if(ArrayBuffer.isView(A))return!0;else if(N.equals(A)===!1)return N.copy(A),!0}return!1}function g(x){let _=x.uniforms,E=0,w=16;for(let T=0,N=_.length;T<N;T++){let M=Array.isArray(_[T])?_[T]:[_[T]];for(let R=0,k=M.length;R<k;R++){let C=M[R],U=Array.isArray(C.value)?C.value:[C.value];for(let D=0,P=U.length;D<P;D++){let K=U[D],z=p(K),W=E%w,q=W%z.boundary,le=W+q;if(E+=q,le!==0&&w-le<z.storage)E+=w-le;C.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=E,E+=z.storage}}}let A=E%w;if(A>0)E+=w-A;return x.__size=E,x.__cache={},this}function p(x){let _={boundary:0,storage:0};if(typeof x==="number"||typeof x==="boolean")_.boundary=4,_.storage=4;else if(x.isVector2)_.boundary=8,_.storage=8;else if(x.isVector3||x.isColor)_.boundary=16,_.storage=12;else if(x.isVector4)_.boundary=16,_.storage=16;else if(x.isMatrix3)_.boundary=48,_.storage=48;else if(x.isMatrix4)_.boundary=64,_.storage=64;else if(x.isTexture)Ve("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(x))_.boundary=16,_.storage=x.byteLength;else Ve("WebGLRenderer: Unsupported uniform value type.",x);return _}function y(x){let _=x.target;_.removeEventListener("dispose",y);let E=s.indexOf(_.__bindingPointIndex);s.splice(E,1),e.deleteBuffer(i[_.id]),delete i[_.id],delete a[_.id]}function v(){for(let x in i)e.deleteBuffer(i[x]);s=[],i={},a={}}return{bind:c,update:l,dispose:v}}function kD(){if(bi===null)bi=new pl(OD,16,16,Cs,pi),bi.name="DFG_LUT",bi.minFilter=An,bi.magFilter=An,bi.wrapS=ko,bi.wrapT=ko,bi.generateMipmaps=!1,bi.needsUpdate=!0;return bi}class Tg{constructor(e={}){let{canvas:t=iT(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Vr}=e;this.isWebGLRenderer=!0;let h;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=n.getContextAttributes().alpha}else h=a;let b=f,m=new Set([lm,cm,om]),g=new Set([Vr,xa,ol,Do,am,sm]),p=new Uint32Array(4),y=new Int32Array(4),v=new V,x=null,_=null,E=[],w=[],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=Br,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,N=!1,M=null,R=null,k=null,C=null;this._outputColorSpace=ya;let U=0,D=0,P=null,K=-1,z=null,W=new Pt,q=new Pt,le=null,he=new Je(0),xe=0,{width:pe,height:J}=t,F=1,X=null,ne=null,re=new Pt(0,0,pe,J),ce=new Pt(0,0,pe,J),ve=!1,Re=new gl,ke=!1,Xe=!1,et=new Ze,Wt=new V,dt=new Pt,Ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Qt=!1;function nn(){return P===null?F:1}let B=n;function _n(I,G){return t.getContext(I,G)}let St,Xt,O,S,j,ee,fe,be,Ee,ie,oe,Ie,je,Ae,me,Ke,qe,vt,H,ye,se,_e,Ce;try{let I={alpha:!0,depth:r,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${uA}`);if(t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",jt,!1),t.addEventListener("webglcontextcreationerror",Rt,!1),B===null){if(B=_n("webgl2",I),B===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}de()}catch(I){throw t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",jt,!1),t.removeEventListener("webglcontextcreationerror",Rt,!1),Qe("WebGLRenderer: "+I.message),I}function de(){if(St=new jk(B),St.init(),se=new SD(B,St),Xt=new Nk(B,St,e,se),O=new wD(B,St),Xt.reversedDepthBuffer&&d)O.buffers.depth.setReversed(!0);R=B.createFramebuffer(),k=B.createFramebuffer(),C=B.createFramebuffer(),S=new Hk(B),j=new dD,ee=new MD(B,St,O,j,Xt,se,S),fe=new Bk(T),be=new KP(B),_e=new Ik(B,be),Ee=new Vk(B,be,S,_e),ie=new Kk(B,Ee,be,_e,S),vt=new $k(B,Xt,ee),me=new Pk(j),oe=new uD(T,fe,St,Xt,_e,me),Ie=new ND(T,j),je=new hD,Ae=new yD(St),qe=new Rk(T,fe,O,ie,h,o),Ke=new TD(T,ie,Xt),Ce=new PD(B,S,Xt,O),H=new Ck(B,St,S),ye=new Gk(B,St,S),S.programs=oe.programs,T.capabilities=Xt,T.extensions=St,T.properties=j,T.renderLists=je,T.shadowMap=Ke,T.state=O,T.info=S}if(b!==Vr)A=new Xk(b,t.width,t.height,s,r,i);let we=new JT(T,B);this.xr=we,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){let I=St.get("WEBGL_lose_context");if(I)I.loseContext()},this.forceContextRestore=function(){let I=St.get("WEBGL_lose_context");if(I)I.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(I){if(I===void 0)return;F=I,this.setSize(pe,J,!1)},this.getSize=function(I){return I.set(pe,J)},this.setSize=function(I,G,te=!0){if(we.isPresenting){Ve("WebGLRenderer: Can't change size while VR device is presenting.");return}if(pe=I,J=G,t.width=Math.floor(I*F),t.height=Math.floor(G*F),te===!0)t.style.width=I+"px",t.style.height=G+"px";if(A!==null)A.setSize(t.width,t.height);this.setViewport(0,0,I,G)},this.getDrawingBufferSize=function(I){return I.set(pe*F,J*F).floor()},this.setDrawingBufferSize=function(I,G,te){pe=I,J=G,F=te,t.width=Math.floor(I*te),t.height=Math.floor(G*te),this.setViewport(0,0,I,G)},this.setEffects=function(I){if(b===Vr){Qe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(I){for(let G=0;G<I.length;G++)if(I[G].isOutputPass===!0){Ve("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(I||[])},this.getCurrentViewport=function(I){return I.copy(W)},this.getViewport=function(I){return I.copy(re)},this.setViewport=function(I,G,te,Z){if(I.isVector4)re.set(I.x,I.y,I.z,I.w);else re.set(I,G,te,Z);O.viewport(W.copy(re).multiplyScalar(F).round())},this.getScissor=function(I){return I.copy(ce)},this.setScissor=function(I,G,te,Z){if(I.isVector4)ce.set(I.x,I.y,I.z,I.w);else ce.set(I,G,te,Z);O.scissor(q.copy(ce).multiplyScalar(F).round())},this.getScissorTest=function(){return ve},this.setScissorTest=function(I){O.setScissorTest(ve=I)},this.setOpaqueSort=function(I){X=I},this.setTransparentSort=function(I){ne=I},this.getClearColor=function(I){return I.copy(qe.getClearColor())},this.setClearColor=function(){qe.setClearColor(...arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha(...arguments)},this.clear=function(I=!0,G=!0,te=!0){let Z=0;if(I){let Y=!1;if(P!==null){let Se=P.texture.format;Y=m.has(Se)}if(Y){let Se=P.texture.type,Pe=g.has(Se),Me=qe.getClearColor(),Le=qe.getClearAlpha(),{r:Be,g:st,b:pt}=Me;if(Pe)p[0]=Be,p[1]=st,p[2]=pt,p[3]=Le,B.clearBufferuiv(B.COLOR,0,p);else y[0]=Be,y[1]=st,y[2]=pt,y[3]=Le,B.clearBufferiv(B.COLOR,0,y)}else Z|=B.COLOR_BUFFER_BIT}if(G)Z|=B.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(te)Z|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(Z!==0)B.clear(Z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(I){I.setRenderer(this),M=I},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",jt,!1),t.removeEventListener("webglcontextcreationerror",Rt,!1),qe.dispose(),je.dispose(),Ae.dispose(),j.dispose(),fe.dispose(),ie.dispose(),_e.dispose(),Ce.dispose(),oe.dispose(),we.dispose(),we.removeEventListener("sessionstart",Ub),we.removeEventListener("sessionend",zb),cs.stop()};function it(I){I.preventDefault(),nl("WebGLRenderer: Context Lost."),N=!0}function jt(){nl("WebGLRenderer: Context Restored."),N=!1;let I=S.autoReset,G=Ke.enabled,te=Ke.autoUpdate,Z=Ke.needsUpdate,Y=Ke.type;de(),S.autoReset=I,Ke.enabled=G,Ke.autoUpdate=te,Ke.needsUpdate=Z,Ke.type=Y}function Rt(I){Qe("WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function Jr(I){let G=I.target;G.removeEventListener("dispose",Jr),Mi(G)}function Mi(I){gI(I),j.remove(I)}function gI(I){let G=j.get(I).programs;if(G!==void 0){if(G.forEach(function(te){oe.releaseProgram(te)}),I.isShaderMaterial)oe.releaseShaderCache(I)}}this.renderBufferDirect=function(I,G,te,Z,Y,Se){if(G===null)G=Ft;let Pe=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,Me=yI(I,G,te,Z,Y);O.setMaterial(Z,Pe);let Le=te.index,Be=1;if(Z.wireframe===!0){if(Le=Ee.getWireframeAttribute(te),Le===void 0)return;Be=2}let st=te.drawRange,pt=te.attributes.position,De=st.start*Be,It=(st.start+st.count)*Be;if(Se!==null)De=Math.max(De,Se.start*Be),It=Math.min(It,(Se.start+Se.count)*Be);if(Le!==null)De=Math.max(De,0),It=Math.min(It,Le.count);else if(pt!==void 0&&pt!==null)De=Math.max(De,0),It=Math.min(It,pt.count);let on=It-De;if(on<0||on===1/0)return;_e.setup(Y,Z,Me,te,Le);let Ht,Ut=H;if(Le!==null)Ht=be.get(Le),Ut=ye,Ut.setIndex(Ht);if(Y.isMesh)if(Z.wireframe===!0)O.setLineWidth(Z.wireframeLinewidth*nn()),Ut.setMode(B.LINES);else Ut.setMode(B.TRIANGLES);else if(Y.isLine){let Cn=Z.linewidth;if(Cn===void 0)Cn=1;if(O.setLineWidth(Cn*nn()),Y.isLineSegments)Ut.setMode(B.LINES);else if(Y.isLineLoop)Ut.setMode(B.LINE_LOOP);else Ut.setMode(B.LINE_STRIP)}else if(Y.isPoints)Ut.setMode(B.POINTS);else if(Y.isSprite)Ut.setMode(B.TRIANGLES);if(Y.isBatchedMesh)if(!St.get("WEBGL_multi_draw")){let{_multiDrawStarts:Cn,_multiDrawCounts:Ne,_multiDrawCount:Un}=Y,yt=Le?be.get(Le).bytesPerElement:1,xr=j.get(Z).currentProgram.getUniforms();for(let Zr=0;Zr<Un;Zr++)xr.setValue(B,"_gl_DrawID",Zr),Ut.render(Cn[Zr]/yt,Ne[Zr])}else Ut.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else if(Y.isInstancedMesh)Ut.renderInstances(De,on,Y.count);else if(te.isInstancedBufferGeometry){let Cn=te._maxInstanceCount!==void 0?te._maxInstanceCount:1/0,Ne=Math.min(te.instanceCount,Cn);Ut.renderInstances(De,on,Ne)}else Ut.render(De,on)};function Fb(I,G,te,Z){if(M!==null&&I.isNodeMaterial)M.setObject(Z,I);if(ke===!0)me.setState(I,te,!1);if(I.transparent===!0&&I.side===wr&&I.forceSinglePass===!1)I.side=Ln,I.needsUpdate=!0,Ql(I,G,Z),I.side=ba,I.needsUpdate=!0,Ql(I,G,Z),I.side=wr;else Ql(I,G,Z)}this.compile=function(I,G,te=null){if(te===null)te=I;if(M!==null)M.renderStart(I,G,te);if(_=Ae.get(te),_.init(G),w.push(_),te.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(G.layers)){if(_.pushLight(Y),Y.castShadow)_.pushShadow(Y)}}),I!==te)I.traverseVisible(function(Y){if(Y.isLight&&Y.layers.test(G.layers)){if(_.pushLight(Y),Y.castShadow)_.pushShadow(Y)}});if(_.setupLights(),M!==null)M.updateLights(_.state.lightsArray);if(Xe=this.localClippingEnabled,ke=me.init(this.clippingPlanes,Xe),ke===!0)me.setGlobalState(this.clippingPlanes,G);if(M!==null)Ke.render(_.state.shadowsArray,te,G);let Z=new Set;if(I.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;let Se=Y.material;if(Se)if(Array.isArray(Se))for(let Pe=0;Pe<Se.length;Pe++){let Me=Se[Pe];Fb(Me,te,G,Y),Z.add(Me)}else Fb(Se,te,G,Y),Z.add(Se)}),_=w.pop(),M!==null)M.renderEnd();return Z},this.compileAsync=function(I,G,te=null){let Z=this.compile(I,G,te);return new Promise((Y)=>{function Se(){if(Z.forEach(function(Pe){let Le=j.get(Pe).currentProgram;if(Le===void 0||Le.isReady())Z.delete(Pe)}),Z.size===0){Y(I);return}setTimeout(Se,10)}if(St.get("KHR_parallel_shader_compile")!==null)Se();else setTimeout(Se,10)})};let Xf=null;function bI(I){if(Xf)Xf(I)}function Ub(){cs.stop()}function zb(){cs.start()}let cs=new UT;if(cs.setAnimationLoop(bI),typeof self<"u")cs.setContext(self);this.setAnimationLoop=function(I){Xf=I,we.setAnimationLoop(I),I===null?cs.stop():cs.start()},we.addEventListener("sessionstart",Ub),we.addEventListener("sessionend",zb),this.render=function(I,G){if(G!==void 0&&G.isCamera!==!0){Qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(M!==null)M.renderStart(I,G);let te=we.enabled===!0&&we.isPresenting===!0,Z=A!==null&&(P===null||te)&&A.begin(T,P);if(I.matrixWorldAutoUpdate===!0)I.updateMatrixWorld();if(G.parent===null&&G.matrixWorldAutoUpdate===!0)G.updateMatrixWorld();if(we.enabled===!0&&we.isPresenting===!0&&(A===null||A.isCompositing()===!1)){if(we.cameraAutoUpdate===!0)we.updateCamera(G);G=we.getCamera()}if(I.isScene===!0)I.onBeforeRender(T,I,G,P);if(_=Ae.get(I,w.length),_.init(G),_.state.textureUnits=ee.getTextureUnits(),w.push(_),et.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),Re.setFromProjectionMatrix(et,$m,G.reversedDepth),Xe=this.localClippingEnabled,ke=me.init(this.clippingPlanes,Xe),x=je.get(I,E.length),x.init(),E.push(x),we.enabled===!0&&we.isPresenting===!0){let Pe=T.xr.getDepthSensingMesh();if(Pe!==null)qf(Pe,G,-1/0,T.sortObjects)}if(qf(I,G,0,T.sortObjects),x.finish(),M!==null)M.updateLights(_.state.lightsArray);if(T.sortObjects===!0)x.sort(X,ne);if(Qt=we.enabled===!1||we.isPresenting===!1||we.hasDepthSensing()===!1,Qt)qe.addToRenderList(x,I);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(ke===!0)me.beginShadows();let Y=_.state.shadowsArray;if(Ke.render(Y,I,G),ke===!0)me.endShadows();if((Z&&A.hasRenderPass())===!1){let Pe=x.opaque,Me=x.transmissive;if(_.setupLights(),G.isArrayCamera){let Le=G.cameras;if(Me.length>0)for(let Be=0,st=Le.length;Be<st;Be++){let pt=Le[Be];jb(Pe,Me,I,pt)}if(Qt)qe.render(I);for(let Be=0,st=Le.length;Be<st;Be++){let pt=Le[Be];Bb(x,I,pt,pt.viewport)}}else{if(Me.length>0)jb(Pe,Me,I,G);if(Qt)qe.render(I);Bb(x,I,G)}}if(P!==null&&D===0)ee.updateMultisampleRenderTarget(P),ee.updateRenderTargetMipmap(P);if(Z)A.end(T);if(I.isScene===!0)I.onAfterRender(T,I,G);if(_e.resetDefaultState(),K=-1,z=null,w.pop(),w.length>0){if(_=w[w.length-1],ee.setTextureUnits(_.state.textureUnits),ke===!0)me.setGlobalState(T.clippingPlanes,_.state.camera)}else _=null;if(E.pop(),E.length>0)x=E[E.length-1];else x=null;if(M!==null)M.renderEnd()};function qf(I,G,te,Z){if(I.visible===!1)return;if(I.layers.test(G.layers)){if(I.isGroup)te=I.renderOrder;else if(I.isLOD){if(I.autoUpdate===!0)I.update(G)}else if(I.isLightProbeGrid)_.pushLightProbeGrid(I);else if(I.isLight){if(_.pushLight(I),I.castShadow)_.pushShadow(I)}else if(I.isSprite){if(!I.frustumCulled||I.intersectsFrustum(Re)){if(Z)dt.setFromMatrixPosition(I.matrixWorld).applyMatrix4(et);let Pe=ie.update(I),Me=I.material;if(Me.visible)x.push(I,Pe,Me,te,dt.z,null,G)}}else if(I.isMesh||I.isLine||I.isPoints){if(!I.frustumCulled||I.intersectsFrustum(Re)){let Pe=ie.update(I),Me=I.material;if(Z){if(I.boundingSphere!==void 0){if(I.boundingSphere===null)I.computeBoundingSphere();dt.copy(I.boundingSphere.center)}else{if(Pe.boundingSphere===null)Pe.computeBoundingSphere();dt.copy(Pe.boundingSphere.center)}dt.applyMatrix4(I.matrixWorld).applyMatrix4(et)}if(Array.isArray(Me)){let Le=Pe.groups;for(let Be=0,st=Le.length;Be<st;Be++){let pt=Le[Be],De=Me[pt.materialIndex];if(De&&De.visible)x.push(I,Pe,De,te,dt.z,pt,G)}}else if(Me.visible)x.push(I,Pe,Me,te,dt.z,null,G)}}}let Se=I.children;for(let Pe=0,Me=Se.length;Pe<Me;Pe++)qf(Se[Pe],G,te,Z)}function Bb(I,G,te,Z){let{opaque:Y,transmissive:Se,transparent:Pe}=I;if(_.setupLightsView(te),ke===!0)me.setGlobalState(T.clippingPlanes,te);if(Z)O.viewport(W.copy(Z));if(Y.length>0)Yl(Y,G,te);if(Se.length>0)Yl(Se,G,te);if(Pe.length>0)Yl(Pe,G,te);O.buffers.depth.setTest(!0),O.buffers.depth.setMask(!0),O.buffers.color.setMask(!0),O.setPolygonOffset(!1)}function jb(I,G,te,Z){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(_.state.transmissionRenderTarget[Z.id]===void 0){let De=St.has("EXT_color_buffer_half_float")||St.has("EXT_color_buffer_float");_.state.transmissionRenderTarget[Z.id]=new hr(1,1,{generateMipmaps:!0,type:De?pi:Vr,minFilter:hi,samples:Math.max(4,Xt.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:lt.workingColorSpace})}let Se=_.state.transmissionRenderTarget[Z.id],Pe=Z.viewport||W;Se.setSize(Pe.z*T.transmissionResolutionScale,Pe.w*T.transmissionResolutionScale);let Me=T.getRenderTarget(),Le=T.getActiveCubeFace(),Be=T.getActiveMipmapLevel();if(T.setRenderTarget(Se),T.getClearColor(he),xe=T.getClearAlpha(),xe<1)T.setClearColor(16777215,0.5);if(T.clear(),Qt)qe.render(te);let st=T.toneMapping;T.toneMapping=Br;let pt=Z.viewport;if(Z.viewport!==void 0)Z.viewport=void 0;if(_.setupLightsView(Z),ke===!0)me.setGlobalState(T.clippingPlanes,Z);if(Yl(I,te,Z),ee.updateMultisampleRenderTarget(Se),ee.updateRenderTargetMipmap(Se),St.has("WEBGL_multisampled_render_to_texture")===!1){let De=!1;for(let It=0,on=G.length;It<on;It++){let Ht=G[It],{object:Ut,geometry:Cn,material:Ne,group:Un}=Ht;if(Ne.side===wr&&Ut.layers.test(Z.layers)){let yt=Ne.side;Ne.side=Ln,Ne.needsUpdate=!0,Vb(Ut,te,Z,Cn,Ne,Un),Ne.side=yt,Ne.needsUpdate=!0,De=!0}}if(De===!0)ee.updateMultisampleRenderTarget(Se),ee.updateRenderTargetMipmap(Se)}if(T.setRenderTarget(Me,Le,Be),T.setClearColor(he,xe),pt!==void 0)Z.viewport=pt;T.toneMapping=st}function Yl(I,G,te){let Z=G.isScene===!0?G.overrideMaterial:null;for(let Y=0,Se=I.length;Y<Se;Y++){let Pe=I[Y],{object:Me,geometry:Le,group:Be}=Pe,st=Pe.material;if(st.allowOverride===!0&&Z!==null)st=Z;if(Me.layers.test(te.layers))Vb(Me,G,te,Le,st,Be)}}function Vb(I,G,te,Z,Y,Se){if(M!==null&&Y.isNodeMaterial)M.setObject(I,Y);if(I.onBeforeRender(T,G,te,Z,Y,Se),I.modelViewMatrix.multiplyMatrices(te.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),Y.onBeforeRender(T,G,te,Z,I,Se),Y.transparent===!0&&Y.side===wr&&Y.forceSinglePass===!1)Y.side=Ln,Y.needsUpdate=!0,T.renderBufferDirect(te,G,Z,Y,I,Se),Y.side=ba,Y.needsUpdate=!0,T.renderBufferDirect(te,G,Z,Y,I,Se),Y.side=wr;else T.renderBufferDirect(te,G,Z,Y,I,Se);I.onAfterRender(T,G,te,Z,Y,Se)}function Ql(I,G,te){if(G.isScene!==!0)G=Ft;let Z=j.get(I),Y=_.state.lights,Se=_.state.shadowsArray,Pe=Y.state.version,Me=oe.getParameters(I,Y.state,Se,G,te,_.state.lightProbeGridArray),Le=oe.getProgramCacheKey(Me),Be=Z.programs;Z.environment=I.isMeshStandardMaterial||I.isMeshLambertMaterial||I.isMeshPhongMaterial?G.environment:null,Z.fog=G.fog;let st=I.isMeshStandardMaterial||I.isMeshLambertMaterial&&!I.envMap||I.isMeshPhongMaterial&&!I.envMap;if(Z.envMap=fe.get(I.envMap||Z.environment,st),Z.envMapRotation=Z.environment!==null&&I.envMap===null?G.environmentRotation:I.envMapRotation,Be===void 0)I.addEventListener("dispose",Jr),Be=new Map,Z.programs=Be;let pt=Be.get(Le);if(pt!==void 0){if(Z.currentProgram===pt&&Z.lightsStateVersion===Pe)return Hb(I,Me),pt}else{if(Me.uniforms=oe.getUniforms(I),M!==null&&I.isNodeMaterial)M.build(I,te,Me);I.onBeforeCompile(Me,T),pt=oe.acquireProgram(Me,Le),Be.set(Le,pt),Z.uniforms=Me.uniforms}let De=Z.uniforms;if(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)De.clippingPlanes=me.uniform;if(Hb(I,Me),Z.needsLights=vI(I),Z.lightsStateVersion=Pe,Z.needsLights)De.ambientLightColor.value=Y.state.ambient,De.lightProbe.value=Y.state.probe,De.sunLights.value=Y.state.sun,De.sunLightShadows.value=Y.state.sunShadow,De.directionalLights.value=Y.state.directional,De.directionalLightShadows.value=Y.state.directionalShadow,De.spotLights.value=Y.state.spot,De.spotLightShadows.value=Y.state.spotShadow,De.rectAreaLights.value=Y.state.rectArea,De.ltc_1.value=Y.state.rectAreaLTC1,De.ltc_2.value=Y.state.rectAreaLTC2,De.pointLights.value=Y.state.point,De.pointLightShadows.value=Y.state.pointShadow,De.hemisphereLights.value=Y.state.hemi,De.sunShadowMatrix.value=Y.state.sunShadowMatrix,De.sunShadowCascade.value=Y.state.sunShadowCascade,De.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,De.spotLightMatrix.value=Y.state.spotLightMatrix,De.spotLightMap.value=Y.state.spotLightMap,De.pointShadowMatrix.value=Y.state.pointShadowMatrix;return Z.lightProbeGrid=_.state.lightProbeGridArray.length>0,Z.currentProgram=pt,Z.uniformsList=null,pt}function Gb(I){if(I.uniformsList===null){let G=I.currentProgram.getUniforms();I.uniformsList=Sl.seqWithValue(G.seq,I.uniforms)}return I.uniformsList}function Hb(I,G){let te=j.get(I);te.outputColorSpace=G.outputColorSpace,te.batching=G.batching,te.batchingColor=G.batchingColor,te.instancing=G.instancing,te.instancingColor=G.instancingColor,te.instancingMorph=G.instancingMorph,te.skinning=G.skinning,te.morphTargets=G.morphTargets,te.morphNormals=G.morphNormals,te.morphColors=G.morphColors,te.morphTargetsCount=G.morphTargetsCount,te.numClippingPlanes=G.numClippingPlanes,te.numIntersection=G.numClipIntersection,te.vertexAlphas=G.vertexAlphas,te.vertexTangents=G.vertexTangents,te.toneMapping=G.toneMapping}function xI(I,G){if(I.length===0)return null;if(I.length===1)return I[0].texture!==null?I[0]:null;v.setFromMatrixPosition(G.matrixWorld);for(let te=0,Z=I.length;te<Z;te++){let Y=I[te];if(Y.texture!==null&&Y.boundingBox.containsPoint(v))return Y}return null}function yI(I,G,te,Z,Y){if(G.isScene!==!0)G=Ft;ee.resetTextureUnits();let Se=G.fog,Pe=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?G.environment:null,Me=P===null?T.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:lt.workingColorSpace,Le=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,Be=fe.get(Z.envMap||Pe,Le),st=Z.vertexColors===!0&&!!te.attributes.color&&te.attributes.color.itemSize===4,pt=!!te.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),De=!!te.morphAttributes.position,It=!!te.morphAttributes.normal,on=!!te.morphAttributes.color,Ht=Br;if(Z.toneMapped){if(P===null||P.isXRRenderTarget===!0)Ht=T.toneMapping}let Ut=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Cn=Ut!==void 0?Ut.length:0,Ne=j.get(Z),Un=_.state.lights;if(ke===!0){if(Xe===!0||I!==z){let Vt=I===z&&Z.id===K;me.setState(Z,I,Vt)}}let yt=!1;if(Z.version===Ne.__version){if(Ne.needsLights&&Ne.lightsStateVersion!==Un.state.version)yt=!0;else if(Ne.outputColorSpace!==Me)yt=!0;else if(Y.isBatchedMesh&&Ne.batching===!1)yt=!0;else if(!Y.isBatchedMesh&&Ne.batching===!0)yt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!0&&Y._colorsTexture===null)yt=!0;else if(Y.isBatchedMesh&&Ne.batchingColor===!1&&Y._colorsTexture!==null)yt=!0;else if(Y.isInstancedMesh&&Ne.instancing===!1)yt=!0;else if(!Y.isInstancedMesh&&Ne.instancing===!0)yt=!0;else if(Y.isSkinnedMesh&&Ne.skinning===!1)yt=!0;else if(!Y.isSkinnedMesh&&Ne.skinning===!0)yt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!0&&Y.instanceColor===null)yt=!0;else if(Y.isInstancedMesh&&Ne.instancingColor===!1&&Y.instanceColor!==null)yt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!0&&Y.morphTexture===null)yt=!0;else if(Y.isInstancedMesh&&Ne.instancingMorph===!1&&Y.morphTexture!==null)yt=!0;else if(Ne.envMap!==Be)yt=!0;else if(Z.fog===!0&&Ne.fog!==Se)yt=!0;else if(Ne.numClippingPlanes!==void 0&&(Ne.numClippingPlanes!==me.numPlanes||Ne.numIntersection!==me.numIntersection))yt=!0;else if(Ne.vertexAlphas!==st)yt=!0;else if(Ne.vertexTangents!==pt)yt=!0;else if(Ne.morphTargets!==De)yt=!0;else if(Ne.morphNormals!==It)yt=!0;else if(Ne.morphColors!==on)yt=!0;else if(Ne.toneMapping!==Ht)yt=!0;else if(Ne.morphTargetsCount!==Cn)yt=!0;else if(!!Ne.lightProbeGrid!==_.state.lightProbeGridArray.length>0)yt=!0}else yt=!0,Ne.__version=Z.version;let xr=Ne.currentProgram;if(yt===!0){if(xr=Ql(Z,G,Y),M&&Z.isNodeMaterial)M.onUpdateProgram(Z,xr,Ne)}let Zr=!1,Yi=!1,Ks=!1,kt=xr.getUniforms(),rn=Ne.uniforms;if(O.useProgram(xr.program))Zr=!0,Yi=!0,Ks=!0;if(Z.id!==K)K=Z.id,Yi=!0;if(Ne.needsLights){let Vt=xI(_.state.lightProbeGridArray,Y);if(Ne.lightProbeGrid!==Vt)Ne.lightProbeGrid=Vt,Yi=!0}if(Zr||z!==I){if(O.buffers.depth.getReversed()&&I.reversedDepth!==!0)I._reversedDepth=!0,I.updateProjectionMatrix();kt.setValue(B,"projectionMatrix",I.projectionMatrix),kt.setValue(B,"viewMatrix",I.matrixWorldInverse);let ea=kt.map.cameraPosition;if(ea!==void 0)ea.setValue(B,Wt.setFromMatrixPosition(I.matrixWorld));if(Xt.logarithmicDepthBuffer)kt.setValue(B,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2));if(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)kt.setValue(B,"isOrthographic",I.isOrthographicCamera===!0);if(z!==I)z=I,Yi=!0,Ks=!0}if(Ne.needsLights){if(Un.state.sunShadowMap.length>0)kt.setValue(B,"sunShadowMap",Un.state.sunShadowMap,ee);if(Un.state.directionalShadowMap.length>0)kt.setValue(B,"directionalShadowMap",Un.state.directionalShadowMap,ee);if(Un.state.spotShadowMap.length>0)kt.setValue(B,"spotShadowMap",Un.state.spotShadowMap,ee);if(Un.state.pointShadowMap.length>0)kt.setValue(B,"pointShadowMap",Un.state.pointShadowMap,ee)}if(Y.isSkinnedMesh){kt.setOptional(B,Y,"bindMatrix"),kt.setOptional(B,Y,"bindMatrixInverse");let Vt=Y.skeleton;if(Vt){if(Vt.boneTexture===null)Vt.computeBoneTexture();kt.setValue(B,"boneTexture",Vt.boneTexture,ee)}}if(Y.isBatchedMesh){if(kt.setOptional(B,Y,"batchingTexture"),kt.setValue(B,"batchingTexture",Y._matricesTexture,ee),kt.setOptional(B,Y,"batchingIdTexture"),kt.setValue(B,"batchingIdTexture",Y._indirectTexture,ee),kt.setOptional(B,Y,"batchingColorTexture"),Y._colorsTexture!==null)kt.setValue(B,"batchingColorTexture",Y._colorsTexture,ee)}let Qi=te.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)vt.update(Y,te,xr);if(Yi||Ne.receiveShadow!==Y.receiveShadow)Ne.receiveShadow=Y.receiveShadow,kt.setValue(B,"receiveShadow",Y.receiveShadow);if((Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial)&&Z.envMap===null&&G.environment!==null)rn.envMapIntensity.value=G.environmentIntensity;if(rn.dfgLUT!==void 0)rn.dfgLUT.value=kD();if(Yi){if(kt.setValue(B,"toneMappingExposure",T.toneMappingExposure),Ne.needsLights)_I(rn,Ks);if(Se&&Z.fog===!0)Ie.refreshFogUniforms(rn,Se);if(Ie.refreshMaterialUniforms(rn,Z,F,J,_.state.transmissionRenderTarget[I.id]),Ne.needsLights&&Ne.lightProbeGrid){let Vt=Ne.lightProbeGrid;rn.probesSH.value=Vt.texture,rn.probesMin.value.copy(Vt.boundingBox.min),rn.probesMax.value.copy(Vt.boundingBox.max),rn.probesResolution.value.copy(Vt.resolution)}Sl.upload(B,Gb(Ne),rn,ee)}if(Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0)Sl.upload(B,Gb(Ne),rn,ee),Z.uniformsNeedUpdate=!1;if(Z.isSpriteMaterial)kt.setValue(B,"center",Y.center);if(kt.setValue(B,"modelViewMatrix",Y.modelViewMatrix),kt.setValue(B,"normalMatrix",Y.normalMatrix),kt.setValue(B,"modelMatrix",Y.matrixWorld),Z.uniformsGroups!==void 0){let Vt=Z.uniformsGroups;for(let ea=0,Ws=Vt.length;ea<Ws;ea++){let Kb=Vt[ea];Ce.update(Kb,xr),Ce.bind(Kb,xr)}}return xr}function _I(I,G){I.ambientLightColor.needsUpdate=G,I.lightProbe.needsUpdate=G,I.sunLights.needsUpdate=G,I.sunLightShadows.needsUpdate=G,I.directionalLights.needsUpdate=G,I.directionalLightShadows.needsUpdate=G,I.pointLights.needsUpdate=G,I.pointLightShadows.needsUpdate=G,I.spotLights.needsUpdate=G,I.spotLightShadows.needsUpdate=G,I.rectAreaLights.needsUpdate=G,I.hemisphereLights.needsUpdate=G}function vI(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(I,G,te){let Z=j.get(I);if(Z.__autoAllocateDepthBuffer=I.resolveDepthBuffer===!1,Z.__autoAllocateDepthBuffer===!1)Z.__useRenderToTexture=!1;j.get(I.texture).__webglTexture=G,j.get(I.depthTexture).__webglTexture=Z.__autoAllocateDepthBuffer?void 0:te,Z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(I,G){let te=j.get(I);te.__webglFramebuffer=G,te.__useDefaultFramebuffer=G===void 0},this.setRenderTarget=function(I,G=0,te=0){P=I,U=G,D=te;let Z=null,Y=!1,Se=!1;if(I){let Me=j.get(I);if(Me.__useDefaultFramebuffer!==void 0){O.bindFramebuffer(B.FRAMEBUFFER,Me.__webglFramebuffer),W.copy(I.viewport),q.copy(I.scissor),le=I.scissorTest,O.viewport(W),O.scissor(q),O.setScissorTest(le),K=-1;return}else if(Me.__webglFramebuffer===void 0)ee.setupRenderTarget(I);else if(Me.__hasExternalTextures)ee.rebindTextures(I,j.get(I.texture).__webglTexture,j.get(I.depthTexture).__webglTexture);else if(I.depthBuffer){let st=I.depthTexture;if(Me.__boundDepthTexture!==st){if(st!==null&&j.has(st)&&(I.width!==st.image.width||I.height!==st.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");ee.setupDepthRenderbuffer(I)}}let Le=I.texture;if(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)Se=!0;let Be=j.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget){if(Array.isArray(Be[G]))Z=Be[G][te];else Z=Be[G];Y=!0}else if(I.samples>0&&ee.useMultisampledRTT(I)===!1)Z=j.get(I).__webglMultisampledFramebuffer;else if(Array.isArray(Be))Z=Be[te];else Z=Be;W.copy(I.viewport),q.copy(I.scissor),le=I.scissorTest}else W.copy(re).multiplyScalar(F).floor(),q.copy(ce).multiplyScalar(F).floor(),le=ve;if(te!==0)Z=R;if(O.bindFramebuffer(B.FRAMEBUFFER,Z))O.drawBuffers(I,Z);if(O.viewport(W),O.scissor(q),O.setScissorTest(le),Y){let Me=j.get(I.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+G,Me.__webglTexture,te)}else if(Se){let Me=G;for(let Le=0;Le<I.textures.length;Le++){let Be=j.get(I.textures[Le]);B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0+Le,Be.__webglTexture,te,Me)}}else if(I!==null&&te!==0){let Me=j.get(I.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Me.__webglTexture,te)}K=-1};function $b(I){let G=j.get(I);if(G.__readFormat!==I.format||G.__readType!==I.type)G.__readFormat=I.format,G.__readType=I.type,G.__formatReadable=Xt.textureFormatReadable(I.format),G.__typeReadable=Xt.textureTypeReadable(I.type);return G}if(this.readRenderTargetPixels=function(I,G,te,Z,Y,Se,Pe,Me=0){if(!(I&&I.isWebGLRenderTarget)){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Le=j.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Pe!==void 0)Le=Le[Pe];if(Le){O.bindFramebuffer(B.FRAMEBUFFER,Le);try{let Be=I.textures[Me],{format:st,type:pt}=Be;if(I.textures.length>1)B.readBuffer(B.COLOR_ATTACHMENT0+Me);let De=$b(Be);if(De.__formatReadable===!1){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(De.__typeReadable===!1){Qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(G>=0&&G<=I.width-Z&&(te>=0&&te<=I.height-Y))B.readPixels(G,te,Z,Y,se.convert(st),se.convert(pt),Se)}finally{let Be=P!==null?j.get(P).__webglFramebuffer:null;O.bindFramebuffer(B.FRAMEBUFFER,Be)}}},this.readRenderTargetPixelsAsync=async function(I,G,te,Z,Y,Se,Pe,Me=0){if(!(I&&I.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Le=j.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Pe!==void 0)Le=Le[Pe];if(Le)if(G>=0&&G<=I.width-Z&&(te>=0&&te<=I.height-Y)){O.bindFramebuffer(B.FRAMEBUFFER,Le);let Be=I.textures[Me],{format:st,type:pt}=Be;if(I.textures.length>1)B.readBuffer(B.COLOR_ATTACHMENT0+Me);let De=$b(Be);if(De.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(De.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let It=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,It),B.bufferData(B.PIXEL_PACK_BUFFER,Se.byteLength,B.STREAM_READ),B.readPixels(G,te,Z,Y,se.convert(st),se.convert(pt),0),B.bindBuffer(B.PIXEL_PACK_BUFFER,null);let on=P!==null?j.get(P).__webglFramebuffer:null;O.bindFramebuffer(B.FRAMEBUFFER,on);let Ht=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await sT(B,Ht,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,It),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,Se),B.bindBuffer(B.PIXEL_PACK_BUFFER,null),B.deleteBuffer(It),B.deleteSync(Ht),Se}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(I,G=null,te=0){let Z=Math.pow(2,-te),Y=Math.floor(I.image.width*Z),Se=Math.floor(I.image.height*Z),Pe=G!==null?G.x:0,Me=G!==null?G.y:0;ee.setTexture2D(I,0),B.copyTexSubImage2D(B.TEXTURE_2D,te,0,0,Pe,Me,Y,Se),O.unbindTexture()},this.copyTextureToTexture=function(I,G,te=null,Z=null,Y=0,Se=0){let Pe,Me,Le,Be,st,pt,De,It,on,Ht=I.isCompressedTexture?I.mipmaps[Se]:I.image;if(te!==null)Pe=te.max.x-te.min.x,Me=te.max.y-te.min.y,Le=te.isBox3?te.max.z-te.min.z:1,Be=te.min.x,st=te.min.y,pt=te.isBox3?te.min.z:0;else{let rn=Math.pow(2,-Y);if(Pe=Math.floor(Ht.width*rn),Me=Math.floor(Ht.height*rn),I.isDataArrayTexture)Le=Ht.depth;else if(I.isData3DTexture)Le=Math.floor(Ht.depth*rn);else Le=1;Be=0,st=0,pt=0}if(Z!==null)De=Z.x,It=Z.y,on=Z.z;else De=0,It=0,on=0;let Ut=se.convert(G.format),Cn=se.convert(G.type),Ne;if(G.isData3DTexture)ee.setTexture3D(G,0),Ne=B.TEXTURE_3D;else if(G.isDataArrayTexture||G.isCompressedArrayTexture)ee.setTexture2DArray(G,0),Ne=B.TEXTURE_2D_ARRAY;else ee.setTexture2D(G,0),Ne=B.TEXTURE_2D;O.activeTexture(B.TEXTURE0),O.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,G.flipY),O.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),O.pixelStorei(B.UNPACK_ALIGNMENT,G.unpackAlignment);let Un=O.getParameter(B.UNPACK_ROW_LENGTH),yt=O.getParameter(B.UNPACK_IMAGE_HEIGHT),xr=O.getParameter(B.UNPACK_SKIP_PIXELS),Zr=O.getParameter(B.UNPACK_SKIP_ROWS),Yi=O.getParameter(B.UNPACK_SKIP_IMAGES);O.pixelStorei(B.UNPACK_ROW_LENGTH,Ht.width),O.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Ht.height),O.pixelStorei(B.UNPACK_SKIP_PIXELS,Be),O.pixelStorei(B.UNPACK_SKIP_ROWS,st),O.pixelStorei(B.UNPACK_SKIP_IMAGES,pt);let Ks=I.isDataArrayTexture||I.isData3DTexture,kt=G.isDataArrayTexture||G.isData3DTexture;if(I.isDepthTexture){let rn=j.get(I),Qi=j.get(G),Vt=j.get(rn.__renderTarget),ea=j.get(Qi.__renderTarget);O.bindFramebuffer(B.READ_FRAMEBUFFER,Vt.__webglFramebuffer),O.bindFramebuffer(B.DRAW_FRAMEBUFFER,ea.__webglFramebuffer);for(let Ws=0;Ws<Le;Ws++){if(Ks)B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,j.get(I).__webglTexture,Y,pt+Ws),B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,j.get(G).__webglTexture,Se,on+Ws);B.blitFramebuffer(Be,st,Pe,Me,De,It,Pe,Me,B.DEPTH_BUFFER_BIT,B.NEAREST)}O.bindFramebuffer(B.READ_FRAMEBUFFER,null),O.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(Y!==0||I.isRenderTargetTexture||j.has(I)){let rn=j.get(I),Qi=j.get(G);O.bindFramebuffer(B.READ_FRAMEBUFFER,k),O.bindFramebuffer(B.DRAW_FRAMEBUFFER,C);for(let Vt=0;Vt<Le;Vt++){if(Ks)B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,rn.__webglTexture,Y,pt+Vt);else B.framebufferTexture2D(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,rn.__webglTexture,Y);if(kt)B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Qi.__webglTexture,Se,on+Vt);else B.framebufferTexture2D(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Qi.__webglTexture,Se);if(Y!==0)B.blitFramebuffer(Be,st,Pe,Me,De,It,Pe,Me,B.COLOR_BUFFER_BIT,B.NEAREST);else if(kt)B.copyTexSubImage3D(Ne,Se,De,It,on+Vt,Be,st,Pe,Me);else B.copyTexSubImage2D(Ne,Se,De,It,Be,st,Pe,Me)}O.bindFramebuffer(B.READ_FRAMEBUFFER,null),O.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(kt)if(I.isDataTexture||I.isData3DTexture)B.texSubImage3D(Ne,Se,De,It,on,Pe,Me,Le,Ut,Cn,Ht.data);else if(G.isCompressedArrayTexture)B.compressedTexSubImage3D(Ne,Se,De,It,on,Pe,Me,Le,Ut,Ht.data);else B.texSubImage3D(Ne,Se,De,It,on,Pe,Me,Le,Ut,Cn,Ht);else if(I.isDataTexture)B.texSubImage2D(B.TEXTURE_2D,Se,De,It,Pe,Me,Ut,Cn,Ht.data);else if(I.isCompressedTexture)B.compressedTexSubImage2D(B.TEXTURE_2D,Se,De,It,Ht.width,Ht.height,Ut,Ht.data);else B.texSubImage2D(B.TEXTURE_2D,Se,De,It,Pe,Me,Ut,Cn,Ht);if(O.pixelStorei(B.UNPACK_ROW_LENGTH,Un),O.pixelStorei(B.UNPACK_IMAGE_HEIGHT,yt),O.pixelStorei(B.UNPACK_SKIP_PIXELS,xr),O.pixelStorei(B.UNPACK_SKIP_ROWS,Zr),O.pixelStorei(B.UNPACK_SKIP_IMAGES,Yi),Se===0&&G.generateMipmaps)B.generateMipmap(Ne);O.unbindTexture()},this.initRenderTarget=function(I){if(j.get(I).__webglFramebuffer===void 0)ee.setupRenderTarget(I)},this.initTexture=function(I){if(I.isCubeTexture)ee.setTextureCube(I,0);else if(I.isData3DTexture)ee.setTexture3D(I,0);else if(I.isDataArrayTexture||I.isCompressedArrayTexture)ee.setTexture2DArray(I,0);else ee.setTexture2D(I,0);O.unbindTexture()},this.resetState=function(){U=0,D=0,P=null,O.reset(),_e.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $m}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=lt._getDrawingBufferColorSpace(e),t.unpackColorSpace=lt._getUnpackColorSpace()}}var WP=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,SP=`#ifdef USE_ALPHAHASH
+#endif`,XP=`#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 ) ) ) );
@@ -354,20 +354,20 @@ Program Info Log: `+U+`
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
-#endif`,MP=`#ifdef USE_ALPHAMAP
+#endif`,qP=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,RP=`#ifdef USE_ALPHAMAP
+#endif`,JP=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,IP=`#ifdef USE_ALPHATEST
+#endif`,ZP=`#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`,CP=`#ifdef USE_ALPHATEST
+#endif`,YP=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,NP=`#ifdef USE_AOMAP
+#endif`,QP=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
@@ -380,10 +380,10 @@ Program Info Log: `+U+`
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
-#endif`,PP=`#ifdef USE_AOMAP
+#endif`,eO=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,OP=`#ifdef USE_BATCHING
+#endif`,tO=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
@@ -417,15 +417,15 @@ Program Info Log: `+U+`
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
}
-#endif`,kP=`#ifdef USE_BATCHING
+#endif`,nO=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,DP=`vec3 transformed = vec3( position );
+#endif`,rO=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,LP=`vec3 objectNormal = vec3( normal );
+#endif`,iO=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,FP=`float G_BlinnPhong_Implicit( ) {
+#endif`,aO=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -439,7 +439,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`,UP=`#ifdef USE_IRIDESCENCE
+} // validated`,sO=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
@@ -502,7 +502,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
}
return max( I, vec3( 0.0 ) );
}
-#endif`,BP=`#ifdef USE_BUMPMAP
+#endif`,oO=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
@@ -523,7 +523,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`,zP=`#if NUM_CLIPPING_PLANES > 0
+#endif`,cO=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
@@ -569,20 +569,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
if ( clipped ) discard;
#endif
#endif
-#endif`,VP=`#if NUM_CLIPPING_PLANES > 0
+#endif`,lO=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,jP=`#if NUM_CLIPPING_PLANES > 0
+#endif`,uO=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,HP=`#if NUM_CLIPPING_PLANES > 0
+#endif`,dO=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,GP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,fO=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,$P=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,hO=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,KP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,pO=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,WP=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,mO=`#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
@@ -595,7 +595,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`,XP=`#define PI 3.141592653589793
+#endif`,gO=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
@@ -666,7 +666,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`,qP=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,bO=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
@@ -759,7 +759,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`,JP=`vec3 transformedNormal = objectNormal;
+#endif`,xO=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
@@ -785,21 +785,21 @@ transformedNormal = normalMatrix * transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
-#endif`,ZP=`#ifdef USE_DISPLACEMENTMAP
+#endif`,yO=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,YP=`#ifdef USE_DISPLACEMENTMAP
+#endif`,_O=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,QP=`#ifdef USE_EMISSIVEMAP
+#endif`,vO=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,eO=`#ifdef USE_EMISSIVEMAP
+#endif`,EO=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,tO="gl_FragColor = linearToOutputTexel( gl_FragColor );",nO=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,AO="gl_FragColor = linearToOutputTexel( gl_FragColor );",TO=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -807,7 +807,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 );
-}`,iO=`#ifdef USE_ENVMAP
+}`,wO=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
@@ -834,7 +834,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
-#endif`,rO=`#ifdef USE_ENVMAP
+#endif`,MO=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
@@ -842,7 +842,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
uniform sampler2D envMap;
#endif
-#endif`,sO=`#ifdef USE_ENVMAP
+#endif`,SO=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
@@ -853,7 +853,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
#else
varying vec3 vReflect;
#endif
-#endif`,aO=`#ifdef USE_ENVMAP
+#endif`,RO=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
@@ -864,7 +864,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
varying vec3 vReflect;
uniform float refractionRatio;
#endif
-#endif`,oO=`#ifdef USE_ENVMAP
+#endif`,IO=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
@@ -881,18 +881,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
-#endif`,cO=`#ifdef USE_FOG
+#endif`,CO=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,lO=`#ifdef USE_FOG
+#endif`,NO=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,uO=`#ifdef USE_FOG
+#endif`,PO=`#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`,dO=`#ifdef USE_FOG
+#endif`,OO=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
@@ -901,7 +901,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
uniform float fogNear;
uniform float fogFar;
#endif
-#endif`,fO=`#ifdef USE_GRADIENTMAP
+#endif`,kO=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -913,12 +913,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
-}`,hO=`#ifdef USE_LIGHTMAP
+}`,LO=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,pO=`LambertMaterial material;
+#endif`,DO=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,mO=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,FO=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
@@ -932,7 +932,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`,gO=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,UO=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
@@ -1061,7 +1061,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
return irradiance;
}
#endif
-#include <lightprobes_pars_fragment>`,bO=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,zO=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -1118,8 +1118,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
}
#endif
#endif
-#endif`,xO=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,yO=`varying vec3 vViewPosition;
+#endif`,BO=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,jO=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
@@ -1131,11 +1131,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`,_O=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,VO=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,vO=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,GO=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
@@ -1152,7 +1152,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`,EO=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,HO=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
@@ -1245,7 +1245,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`,TO=`uniform sampler2D dfgLUT;
+#endif`,$O=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
@@ -1612,7 +1612,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 );
-}`,AO=`
+}`,KO=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1760,7 +1760,7 @@ IncidentLight directLight;
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,wO=`#if defined( RE_IndirectDiffuse )
+#endif`,WO=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1790,7 +1790,7 @@ IncidentLight directLight;
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
-#endif`,SO=`#if defined( RE_IndirectDiffuse )
+#endif`,XO=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
@@ -1798,7 +1798,7 @@ IncidentLight directLight;
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
-#endif`,MO=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,qO=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1843,27 +1843,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,RO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,JO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,IO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,ZO=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,CO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,YO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,NO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,QO=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,PO=`#ifdef USE_MAP
+#endif`,e8=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,OO=`#ifdef USE_MAP
+#endif`,t8=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,kO=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,n8=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
@@ -1875,7 +1875,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,DO=`#if defined( USE_POINTS_UV )
+#endif`,r8=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1887,19 +1887,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,LO=`float metalnessFactor = metalness;
+#endif`,i8=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,FO=`#ifdef USE_METALNESSMAP
+#endif`,a8=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,UO=`#ifdef USE_INSTANCING_MORPH
+#endif`,s8=`#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`,BO=`#if defined( USE_MORPHCOLORS )
+#endif`,o8=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
@@ -1908,12 +1908,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
-#endif`,zO=`#ifdef USE_MORPHNORMALS
+#endif`,c8=`#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`,VO=`#ifdef USE_MORPHTARGETS
+#endif`,l8=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1927,12 +1927,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
-#endif`,jO=`#ifdef USE_MORPHTARGETS
+#endif`,u8=`#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`,HO=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,d8=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
@@ -1973,7 +1973,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
tbn2[1] *= faceDirection;
#endif
#endif
-vec3 nonPerturbedNormal = normal;`,GO=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,f8=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
@@ -1991,19 +1991,19 @@ vec3 nonPerturbedNormal = normal;`,GO=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,$O=`#ifndef FLAT_SHADED
+#endif`,h8=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,KO=`#ifndef FLAT_SHADED
+#endif`,p8=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,WO=`#ifndef FLAT_SHADED
+#endif`,m8=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -2012,7 +2012,7 @@ vec3 nonPerturbedNormal = normal;`,GO=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,XO=`#ifdef USE_NORMALMAP
+#endif`,g8=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -2034,13 +2034,13 @@ vec3 nonPerturbedNormal = normal;`,GO=`#ifdef USE_NORMALMAP_OBJECTSPACE
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
-#endif`,qO=`#ifdef USE_CLEARCOAT
+#endif`,b8=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,JO=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,x8=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,ZO=`#ifdef USE_CLEARCOATMAP
+#endif`,y8=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -2049,18 +2049,18 @@ vec3 nonPerturbedNormal = normal;`,GO=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,YO=`#ifdef USE_IRIDESCENCEMAP
+#endif`,_8=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,QO=`#ifdef OPAQUE
+#endif`,v8=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ek=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,E8=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -2139,9 +2139,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
-}`,tk=`#ifdef PREMULTIPLIED_ALPHA
+}`,A8=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,nk=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,T8=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
@@ -2149,22 +2149,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,w8=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,rk=`#ifdef DITHERING
+#endif`,M8=`#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`,sk=`float roughnessFactor = roughness;
+#endif`,S8=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,ak=`#ifdef USE_ROUGHNESSMAP
+#endif`,R8=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,ok=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,I8=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
@@ -2415,7 +2415,7 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
}
#endif
#endif
-#endif`,ck=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,C8=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
@@ -2460,7 +2460,7 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,lk=`#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`,N8=`#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
@@ -2500,7 +2500,7 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,uk=`float getShadowMask() {
+#endif`,P8=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2541,12 +2541,12 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,dk=`#ifdef USE_SKINNING
+}`,O8=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,fk=`#ifdef USE_SKINNING
+#endif`,k8=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2561,7 +2561,7 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,hk=`#ifdef USE_SKINNING
+#endif`,L8=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2569,7 +2569,7 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,pk=`#ifdef USE_SKINNING
+#endif`,D8=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2580,17 +2580,17 @@ gl_Position = projectionMatrix * mvPosition;`,ik=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,mk=`float specularStrength;
+#endif`,F8=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,gk=`#ifdef USE_SPECULARMAP
+#endif`,U8=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,bk=`#if defined( TONE_MAPPING )
+#endif`,z8=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,xk=`#ifndef saturate
+#endif`,B8=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
@@ -2687,7 +2687,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; }`,yk=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,j8=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2708,7 +2708,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,_k=`#ifdef USE_TRANSMISSION
+#endif`,V8=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2834,7 +2834,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#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`,vk=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,G8=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2904,7 +2904,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Ek=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,H8=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2998,7 +2998,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Tk=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,$8=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
@@ -3069,7 +3069,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`,Ak=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`,K8=`#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;
@@ -3078,12 +3078,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,yk=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,wk=`varying vec2 vUv;
+#endif`,W8=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,Sk=`uniform sampler2D t2D;
+}`,X8=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
@@ -3095,14 +3095,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,Mk=`varying vec3 vWorldDirection;
+}`,q8=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Rk=`#ifdef ENVMAP_TYPE_CUBE
+}`,J8=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
@@ -3124,14 +3124,14 @@ void main() {
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,Ik=`varying vec3 vWorldDirection;
+}`,Z8=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Ck=`uniform samplerCube tCube;
+}`,Y8=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
@@ -3141,7 +3141,7 @@ void main() {
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,Nk=`#include <common>
+}`,Q8=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
@@ -3168,7 +3168,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
-}`,Pk=`#if DEPTH_PACKING == 3200
+}`,ek=`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
@@ -3206,7 +3206,7 @@ void main() {
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
-}`,Ok=`#define DISTANCE
+}`,tk=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3233,7 +3233,7 @@ void main() {
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
-}`,kk=`#define DISTANCE
+}`,nk=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
@@ -3256,13 +3256,13 @@ void main() {
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
-}`,Dk=`varying vec3 vWorldDirection;
+}`,rk=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,Lk=`uniform sampler2D tEquirect;
+}`,ik=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
@@ -3271,7 +3271,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
-}`,Fk=`uniform float scale;
+}`,ak=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
@@ -3293,7 +3293,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,Uk=`uniform vec3 diffuse;
+}`,sk=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
@@ -3321,7 +3321,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,Bk=`#include <common>
+}`,ok=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
@@ -3353,7 +3353,7 @@ void main() {
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
-}`,zk=`uniform vec3 diffuse;
+}`,ck=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
@@ -3401,7 +3401,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,Vk=`#define LAMBERT
+}`,lk=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3440,7 +3440,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,jk=`#define LAMBERT
+}`,uk=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3498,7 +3498,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,Hk=`#define MATCAP
+}`,dk=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3532,7 +3532,7 @@ void main() {
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
-}`,Gk=`#define MATCAP
+}`,fk=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
@@ -3578,7 +3578,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,$k=`#define NORMAL
+}`,hk=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
@@ -3611,7 +3611,7 @@ void main() {
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
-}`,Kk=`#define NORMAL
+}`,pk=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
@@ -3632,7 +3632,7 @@ void main() {
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
-}`,Wk=`#define PHONG
+}`,mk=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3671,7 +3671,7 @@ void main() {
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,Xk=`#define PHONG
+}`,gk=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
@@ -3731,7 +3731,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,qk=`#define STANDARD
+}`,bk=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3774,7 +3774,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,Jk=`#define STANDARD
+}`,xk=`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
@@ -3902,7 +3902,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,Zk=`#define TOON
+}`,yk=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
@@ -3939,7 +3939,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,Yk=`#define TOON
+}`,_k=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
@@ -3991,7 +3991,7 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
-}`,Qk=`uniform float size;
+}`,vk=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
@@ -4022,7 +4022,7 @@ void main() {
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
-}`,eD=`uniform vec3 diffuse;
+}`,Ek=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
@@ -4047,7 +4047,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,tD=`#include <common>
+}`,Ak=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
@@ -4070,7 +4070,7 @@ void main() {
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
-}`,nD=`uniform vec3 color;
+}`,Tk=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <fog_pars_fragment>
@@ -4086,7 +4086,7 @@ void main() {
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
-}`,iD=`uniform float rotation;
+}`,wk=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
@@ -4110,7 +4110,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
-}`,rD=`uniform vec3 diffuse;
+}`,Mk=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -4135,9 +4135,9 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,st,Te,br,Gd,sD,SA,Vo=4,dD=6,fD=20,hD=256,ml,rA,ig=null,rg=0,sg=0,ag=!1,pD,Na,dg,wD,MA,lg,RA,IA,CA,cA,lA,uA,dA,fA,og,pL=37297,mL=0,mA,yL,$d,wL,SL,RL,CL,PL,kL,LL,zL=0,XL=0,YL=`void main() {
+}`,ct,Te,xi,ef,Sk,zT,Wo=4,Ok=6,kk=20,Lk=256,Tl,bT,mg=null,gg=0,bg=0,xg=!1,Dk,Ds,Ag,Wk,BT,vg,jT,VT,GT,vT,ET,AT,TT,wT,yg,DL=37297,FL=0,RT,jL,tf,WL,XL,JL,YL,eD,nD,iD,cD=0,gD=0,_D=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,QL=`uniform sampler2D shadow_pass;
+}`,vD=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
@@ -4162,12 +4162,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 );
-}`,e8,t8,AA,gl,cg,a8=`
+}`,ED,AD,FT,wl,_g,RD=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,o8=`
+}`,ID=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4186,7 +4186,7 @@ void main() {
}
-}`,FA,c8,UA,d8,gr=null;var ji=ut(()=>{ng();ng();st={alphahash_fragment:wP,alphahash_pars_fragment:SP,alphamap_fragment:MP,alphamap_pars_fragment:RP,alphatest_fragment:IP,alphatest_pars_fragment:CP,aomap_fragment:NP,aomap_pars_fragment:PP,batching_pars_vertex:OP,batching_vertex:kP,begin_vertex:DP,beginnormal_vertex:LP,bsdfs:FP,iridescence_fragment:UP,bumpmap_pars_fragment:BP,clipping_planes_fragment:zP,clipping_planes_pars_fragment:VP,clipping_planes_pars_vertex:jP,clipping_planes_vertex:HP,color_fragment:GP,color_pars_fragment:$P,color_pars_vertex:KP,color_vertex:WP,common:XP,cube_uv_reflection_fragment:qP,defaultnormal_vertex:JP,displacementmap_pars_vertex:ZP,displacementmap_vertex:YP,emissivemap_fragment:QP,emissivemap_pars_fragment:eO,colorspace_fragment:tO,colorspace_pars_fragment:nO,envmap_fragment:iO,envmap_common_pars_fragment:rO,envmap_pars_fragment:sO,envmap_pars_vertex:aO,envmap_physical_pars_fragment:bO,envmap_vertex:oO,fog_vertex:cO,fog_pars_vertex:lO,fog_fragment:uO,fog_pars_fragment:dO,gradientmap_pars_fragment:fO,lightmap_pars_fragment:hO,lights_lambert_fragment:pO,lights_lambert_pars_fragment:mO,lights_pars_begin:gO,lights_toon_fragment:xO,lights_toon_pars_fragment:yO,lights_phong_fragment:_O,lights_phong_pars_fragment:vO,lights_physical_fragment:EO,lights_physical_pars_fragment:TO,lights_fragment_begin:AO,lights_fragment_maps:wO,lights_fragment_end:SO,lightprobes_pars_fragment:MO,logdepthbuf_fragment:RO,logdepthbuf_pars_fragment:IO,logdepthbuf_pars_vertex:CO,logdepthbuf_vertex:NO,map_fragment:PO,map_pars_fragment:OO,map_particle_fragment:kO,map_particle_pars_fragment:DO,metalnessmap_fragment:LO,metalnessmap_pars_fragment:FO,morphinstance_vertex:UO,morphcolor_vertex:BO,morphnormal_vertex:zO,morphtarget_pars_vertex:VO,morphtarget_vertex:jO,normal_fragment_begin:HO,normal_fragment_maps:GO,normal_pars_fragment:$O,normal_pars_vertex:KO,normal_vertex:WO,normalmap_pars_fragment:XO,clearcoat_normal_fragment_begin:qO,clearcoat_normal_fragment_maps:JO,clearcoat_pars_fragment:ZO,iridescence_pars_fragment:YO,opaque_fragment:QO,packing:ek,premultiplied_alpha_fragment:tk,project_vertex:nk,dithering_fragment:ik,dithering_pars_fragment:rk,roughnessmap_fragment:sk,roughnessmap_pars_fragment:ak,shadowmap_pars_fragment:ok,shadowmap_pars_vertex:ck,shadowmap_vertex:lk,shadowmask_pars_fragment:uk,skinbase_vertex:dk,skinning_pars_vertex:fk,skinning_vertex:hk,skinnormal_vertex:pk,specularmap_fragment:mk,specularmap_pars_fragment:gk,tonemapping_fragment:bk,tonemapping_pars_fragment:xk,transmission_fragment:yk,transmission_pars_fragment:_k,uv_pars_fragment:vk,uv_pars_vertex:Ek,uv_vertex:Tk,worldpos_vertex:Ak,background_vert:wk,background_frag:Sk,backgroundCube_vert:Mk,backgroundCube_frag:Rk,cube_vert:Ik,cube_frag:Ck,depth_vert:Nk,depth_frag:Pk,distance_vert:Ok,distance_frag:kk,equirect_vert:Dk,equirect_frag:Lk,linedashed_vert:Fk,linedashed_frag:Uk,meshbasic_vert:Bk,meshbasic_frag:zk,meshlambert_vert:Vk,meshlambert_frag:jk,meshmatcap_vert:Hk,meshmatcap_frag:Gk,meshnormal_vert:$k,meshnormal_frag:Kk,meshphong_vert:Wk,meshphong_frag:Xk,meshphysical_vert:qk,meshphysical_frag:Jk,meshtoon_vert:Zk,meshtoon_frag:Yk,points_vert:Qk,points_frag:eD,shadow_vert:tD,shadow_frag:nD,sprite_vert:iD,sprite_frag:rD},Te={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new tt}},envmap:{envMap:{value:null},envMapRotation:{value:new tt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new tt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new tt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new tt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new tt},normalScale:{value:new Ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new tt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new tt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new tt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new tt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new j},probesMax:{value:new j},probesResolution:{value:new j}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ke(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new tt},alphaMap:{value:null},alphaMapTransform:{value:new tt},alphaTest:{value:0}}},br={basic:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:st.meshbasic_vert,fragmentShader:st.meshbasic_frag},lambert:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},envMapIntensity:{value:1}}]),vertexShader:st.meshlambert_vert,fragmentShader:st.meshlambert_frag},phong:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:st.meshphong_vert,fragmentShader:st.meshphong_frag},standard:{uniforms:Fn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag},toon:{uniforms:Fn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new qe(0)}}]),vertexShader:st.meshtoon_vert,fragmentShader:st.meshtoon_frag},matcap:{uniforms:Fn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:st.meshmatcap_vert,fragmentShader:st.meshmatcap_frag},points:{uniforms:Fn([Te.points,Te.fog]),vertexShader:st.points_vert,fragmentShader:st.points_frag},dashed:{uniforms:Fn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:st.linedashed_vert,fragmentShader:st.linedashed_frag},depth:{uniforms:Fn([Te.common,Te.displacementmap]),vertexShader:st.depth_vert,fragmentShader:st.depth_frag},normal:{uniforms:Fn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:st.meshnormal_vert,fragmentShader:st.meshnormal_frag},sprite:{uniforms:Fn([Te.sprite,Te.fog]),vertexShader:st.sprite_vert,fragmentShader:st.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:st.background_vert,fragmentShader:st.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new tt}},vertexShader:st.backgroundCube_vert,fragmentShader:st.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:st.cube_vert,fragmentShader:st.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:st.equirect_vert,fragmentShader:st.equirect_frag},distance:{uniforms:Fn([Te.common,Te.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:st.distance_vert,fragmentShader:st.distance_frag},shadow:{uniforms:Fn([Te.lights,Te.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:st.shadow_vert,fragmentShader:st.shadow_frag}};br.physical={uniforms:Fn([br.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new tt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new tt},clearcoatNormalScale:{value:new Ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new tt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new tt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new tt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new tt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new tt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new tt},transmissionSamplerSize:{value:new Ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new tt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new tt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new tt},anisotropyVector:{value:new Ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new tt}}]),vertexShader:st.meshphysical_vert,fragmentShader:st.meshphysical_frag};Gd={r:0,b:0,g:0},sD=new Je,SA=new tt;SA.set(-1,0,0,0,1,0,0,0,1);ml=new Ca,rA=new qe,pD=new j,Na=new j;dg=class dg extends li{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 Od(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:`
+}`,JT,CD,ZT,OD,bi=null;var Hr=ot(()=>{pg();pg();ct={alphahash_fragment:WP,alphahash_pars_fragment:XP,alphamap_fragment:qP,alphamap_pars_fragment:JP,alphatest_fragment:ZP,alphatest_pars_fragment:YP,aomap_fragment:QP,aomap_pars_fragment:eO,batching_pars_vertex:tO,batching_vertex:nO,begin_vertex:rO,beginnormal_vertex:iO,bsdfs:aO,iridescence_fragment:sO,bumpmap_pars_fragment:oO,clipping_planes_fragment:cO,clipping_planes_pars_fragment:lO,clipping_planes_pars_vertex:uO,clipping_planes_vertex:dO,color_fragment:fO,color_pars_fragment:hO,color_pars_vertex:pO,color_vertex:mO,common:gO,cube_uv_reflection_fragment:bO,defaultnormal_vertex:xO,displacementmap_pars_vertex:yO,displacementmap_vertex:_O,emissivemap_fragment:vO,emissivemap_pars_fragment:EO,colorspace_fragment:AO,colorspace_pars_fragment:TO,envmap_fragment:wO,envmap_common_pars_fragment:MO,envmap_pars_fragment:SO,envmap_pars_vertex:RO,envmap_physical_pars_fragment:zO,envmap_vertex:IO,fog_vertex:CO,fog_pars_vertex:NO,fog_fragment:PO,fog_pars_fragment:OO,gradientmap_pars_fragment:kO,lightmap_pars_fragment:LO,lights_lambert_fragment:DO,lights_lambert_pars_fragment:FO,lights_pars_begin:UO,lights_toon_fragment:BO,lights_toon_pars_fragment:jO,lights_phong_fragment:VO,lights_phong_pars_fragment:GO,lights_physical_fragment:HO,lights_physical_pars_fragment:$O,lights_fragment_begin:KO,lights_fragment_maps:WO,lights_fragment_end:XO,lightprobes_pars_fragment:qO,logdepthbuf_fragment:JO,logdepthbuf_pars_fragment:ZO,logdepthbuf_pars_vertex:YO,logdepthbuf_vertex:QO,map_fragment:e8,map_pars_fragment:t8,map_particle_fragment:n8,map_particle_pars_fragment:r8,metalnessmap_fragment:i8,metalnessmap_pars_fragment:a8,morphinstance_vertex:s8,morphcolor_vertex:o8,morphnormal_vertex:c8,morphtarget_pars_vertex:l8,morphtarget_vertex:u8,normal_fragment_begin:d8,normal_fragment_maps:f8,normal_pars_fragment:h8,normal_pars_vertex:p8,normal_vertex:m8,normalmap_pars_fragment:g8,clearcoat_normal_fragment_begin:b8,clearcoat_normal_fragment_maps:x8,clearcoat_pars_fragment:y8,iridescence_pars_fragment:_8,opaque_fragment:v8,packing:E8,premultiplied_alpha_fragment:A8,project_vertex:T8,dithering_fragment:w8,dithering_pars_fragment:M8,roughnessmap_fragment:S8,roughnessmap_pars_fragment:R8,shadowmap_pars_fragment:I8,shadowmap_pars_vertex:C8,shadowmap_vertex:N8,shadowmask_pars_fragment:P8,skinbase_vertex:O8,skinning_pars_vertex:k8,skinning_vertex:L8,skinnormal_vertex:D8,specularmap_fragment:F8,specularmap_pars_fragment:U8,tonemapping_fragment:z8,tonemapping_pars_fragment:B8,transmission_fragment:j8,transmission_pars_fragment:V8,uv_pars_fragment:G8,uv_pars_vertex:H8,uv_vertex:$8,worldpos_vertex:K8,background_vert:W8,background_frag:X8,backgroundCube_vert:q8,backgroundCube_frag:J8,cube_vert:Z8,cube_frag:Y8,depth_vert:Q8,depth_frag:ek,distance_vert:tk,distance_frag:nk,equirect_vert:rk,equirect_frag:ik,linedashed_vert:ak,linedashed_frag:sk,meshbasic_vert:ok,meshbasic_frag:ck,meshlambert_vert:lk,meshlambert_frag:uk,meshmatcap_vert:dk,meshmatcap_frag:fk,meshnormal_vert:hk,meshnormal_frag:pk,meshphong_vert:mk,meshphong_frag:gk,meshphysical_vert:bk,meshphysical_frag:xk,meshtoon_vert:yk,meshtoon_frag:_k,points_vert:vk,points_frag:Ek,shadow_vert:Ak,shadow_frag:Tk,sprite_vert:wk,sprite_frag:Mk},Te={common:{diffuse:{value:new Je(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new nt},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new nt}},envmap:{envMap:{value:null},envMapRotation:{value:new nt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new nt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new nt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new nt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new nt},normalScale:{value:new We(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new nt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new nt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new nt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new nt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new Je(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 V},probesMax:{value:new V},probesResolution:{value:new V}},points:{diffuse:{value:new Je(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0},uvTransform:{value:new nt}},sprite:{diffuse:{value:new Je(16777215)},opacity:{value:1},center:{value:new We(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new nt},alphaMap:{value:null},alphaMapTransform:{value:new nt},alphaTest:{value:0}}},xi={basic:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.fog]),vertexShader:ct.meshbasic_vert,fragmentShader:ct.meshbasic_frag},lambert:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new Je(0)},envMapIntensity:{value:1}}]),vertexShader:ct.meshlambert_vert,fragmentShader:ct.meshlambert_frag},phong:{uniforms:Fn([Te.common,Te.specularmap,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,Te.lights,{emissive:{value:new Je(0)},specular:{value:new Je(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ct.meshphong_vert,fragmentShader:ct.meshphong_frag},standard:{uniforms:Fn([Te.common,Te.envmap,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.roughnessmap,Te.metalnessmap,Te.fog,Te.lights,{emissive:{value:new Je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ct.meshphysical_vert,fragmentShader:ct.meshphysical_frag},toon:{uniforms:Fn([Te.common,Te.aomap,Te.lightmap,Te.emissivemap,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.gradientmap,Te.fog,Te.lights,{emissive:{value:new Je(0)}}]),vertexShader:ct.meshtoon_vert,fragmentShader:ct.meshtoon_frag},matcap:{uniforms:Fn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,Te.fog,{matcap:{value:null}}]),vertexShader:ct.meshmatcap_vert,fragmentShader:ct.meshmatcap_frag},points:{uniforms:Fn([Te.points,Te.fog]),vertexShader:ct.points_vert,fragmentShader:ct.points_frag},dashed:{uniforms:Fn([Te.common,Te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ct.linedashed_vert,fragmentShader:ct.linedashed_frag},depth:{uniforms:Fn([Te.common,Te.displacementmap]),vertexShader:ct.depth_vert,fragmentShader:ct.depth_frag},normal:{uniforms:Fn([Te.common,Te.bumpmap,Te.normalmap,Te.displacementmap,{opacity:{value:1}}]),vertexShader:ct.meshnormal_vert,fragmentShader:ct.meshnormal_frag},sprite:{uniforms:Fn([Te.sprite,Te.fog]),vertexShader:ct.sprite_vert,fragmentShader:ct.sprite_frag},background:{uniforms:{uvTransform:{value:new nt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ct.background_vert,fragmentShader:ct.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new nt}},vertexShader:ct.backgroundCube_vert,fragmentShader:ct.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ct.cube_vert,fragmentShader:ct.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ct.equirect_vert,fragmentShader:ct.equirect_frag},distance:{uniforms:Fn([Te.common,Te.displacementmap,{referencePosition:{value:new V},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:ct.distance_vert,fragmentShader:ct.distance_frag},shadow:{uniforms:Fn([Te.lights,Te.fog,{color:{value:new Je(0)},opacity:{value:1}}]),vertexShader:ct.shadow_vert,fragmentShader:ct.shadow_frag}};xi.physical={uniforms:Fn([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new nt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new nt},clearcoatNormalScale:{value:new We(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new nt},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new nt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new nt},sheen:{value:0},sheenColor:{value:new Je(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new nt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new nt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new nt},transmissionSamplerSize:{value:new We},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new nt},attenuationDistance:{value:0},attenuationColor:{value:new Je(0)},specularColor:{value:new Je(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new nt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new nt},anisotropyVector:{value:new We},anisotropyMap:{value:null},anisotropyMapTransform:{value:new nt}}]),vertexShader:ct.meshphysical_vert,fragmentShader:ct.meshphysical_frag};ef={r:0,b:0,g:0},Sk=new Ze,zT=new nt;zT.set(-1,0,0,0,1,0,0,0,1);Tl=new Ls,bT=new Je,Dk=new V,Ds=new V;Ag=class Ag extends hr{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Gd(r),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;
@@ -4221,44 +4221,44 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new bs(5,5,5),r=new Ei({name:"CubemapFromEquirect",uniforms:Ra(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dn,blending:dr});r.uniforms.tEquirect.value=t;let s=new jt(i,r),a=t.minFilter;if(t.minFilter===fr)t.minFilter=Tn;return new Xm(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,n,i);e.setRenderTarget(r)}};wD={[zp]:"LINEAR_TONE_MAPPING",[Vp]:"REINHARD_TONE_MAPPING",[jp]:"CINEON_TONE_MAPPING",[Jc]:"ACES_FILMIC_TONE_MAPPING",[Gp]:"AGX_TONE_MAPPING",[$p]:"NEUTRAL_TONE_MAPPING",[Hp]:"CUSTOM_TONE_MAPPING"};MA=new en,lg=new Ma(1,1),RA=new Sd,IA=new Fm,CA=new Od,cA=[],lA=[],uA=new Float32Array(16),dA=new Float32Array(9),fA=new Float32Array(4);og=/(\w+)(\])?(\[|\.)?/g;mA=new tt;yL={[zp]:"Linear",[Vp]:"Reinhard",[jp]:"Cineon",[Jc]:"ACESFilmic",[Gp]:"AgX",[$p]:"Neutral",[Hp]:"Custom"};$d=new j;wL=/^[ \t]*#include +<([\w\d./]+)>/gm;SL=new Map;RL=/#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;CL={[Xc]:"SHADOWMAP_TYPE_PCF",[Ao]:"SHADOWMAP_TYPE_VSM"};PL={[So]:"ENVMAP_TYPE_CUBE",[va]:"ENVMAP_TYPE_CUBE",[Zc]:"ENVMAP_TYPE_CUBE_UV"};kL={[va]:"ENVMAP_MODE_REFRACTION"};LL={[RT]:"ENVMAP_BLENDING_MULTIPLY",[IT]:"ENVMAP_BLENDING_MIX",[CT]:"ENVMAP_BLENDING_ADD"};e8=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],t8=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],AA=new Je,gl=new j,cg=new j;FA=class FA extends Vi{constructor(e,t){super();let n=this,i=null,r=1,s=null,a="local-floor",o=1,c=null,l=null,u=null,d=null,f=null,h=null,b=typeof XRWebGLBinding<"u",m=new LA,g={},p=t.getContextAttributes(),x=null,_=null,y=[],v=[],E=new Ke,w=null,T=null,A=new hn;A.viewport=new Pt;let P=new hn;P.viewport=new Pt;let S=[A,P],R=new qm,k=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let F=y[J];if(F===void 0)F=new nl,y[J]=F;return F.getTargetRaySpace()},this.getControllerGrip=function(J){let F=y[J];if(F===void 0)F=new nl,y[J]=F;return F.getGripSpace()},this.getHand=function(J){let F=y[J];if(F===void 0)F=new nl,y[J]=F;return F.getHandSpace()};function U(J){let F=v.indexOf(J.inputSource);if(F===-1)return;let W=y[F];if(W!==void 0)W.update(J.inputSource,J.frame,c||s),W.dispatchEvent({type:J.type,data:J.inputSource})}function L(){i.removeEventListener("select",U),i.removeEventListener("selectstart",U),i.removeEventListener("selectend",U),i.removeEventListener("squeeze",U),i.removeEventListener("squeezestart",U),i.removeEventListener("squeezeend",U),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",O);for(let J=0;J<y.length;J++){let F=v[J];if(F===null)continue;v[J]=null,y[J].disconnect(F)}k=null,C=null,m.reset();for(let J in g)delete g[J];if(e.setRenderTarget(x),f=null,d=null,u=null,i=null,_=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(E.width,E.height,!1),T!==null){let J=T.camera;J.fov=T.fov,J.zoom=T.zoom,J.updateProjectionMatrix(),T=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){if(r=J,n.isPresenting===!0)je("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){if(a=J,n.isPresenting===!0)je("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){if(u===null&&b)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(J){if(i=J,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",U),i.addEventListener("selectstart",U),i.addEventListener("selectend",U),i.addEventListener("squeeze",U),i.addEventListener("squeezestart",U),i.addEventListener("squeezeend",U),i.addEventListener("end",L),i.addEventListener("inputsourceschange",O),p.xrCompatible!==!0)await t.makeXRCompatible();if(w=e.getPixelRatio(),e.getSize(E),!(b&&("createProjectionLayer"in XRWebGLBinding.prototype))){let W={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,W),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new li(f.framebufferWidth,f.framebufferHeight,{format:pr,type:zi,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let W=null,ne=null,ie=null;if(p.depth)ie=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,W=p.stencil?Aa:Ta,ne=p.stencil?Co:hs;let ce={colorFormat:t.RGBA8,depthFormat:ie,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(ce),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new li(d.textureWidth,d.textureHeight,{format:pr,type:zi,depthTexture:new Ma(d.textureWidth,d.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,W),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(o),c=null,s=await i.requestReferenceSpace(a),pe.setContext(i),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function O(J){for(let F=0;F<J.removed.length;F++){let W=J.removed[F],ne=v.indexOf(W);if(ne>=0)v[ne]=null,y[ne].disconnect(W)}for(let F=0;F<J.added.length;F++){let W=J.added[F],ne=v.indexOf(W);if(ne===-1){for(let ce=0;ce<y.length;ce++)if(ce>=v.length){v.push(W),ne=ce;break}else if(v[ce]===null){v[ce]=W,ne=ce;break}if(ne===-1)break}let ie=y[ne];if(ie)ie.connect(W)}}let K=new j,B=new j;function X(J,F,W){K.setFromMatrixPosition(F.matrixWorld),B.setFromMatrixPosition(W.matrixWorld);let ne=K.distanceTo(B),ie=F.projectionMatrix.elements,ce=W.projectionMatrix.elements,_e=ie[14]/(ie[10]-1),Re=ie[14]/(ie[10]+1),ke=(ie[9]+1)/ie[5],We=(ie[9]-1)/ie[5],Qe=(ie[8]-1)/ie[0],Wt=(ce[8]+1)/ce[0],lt=_e*Qe,Lt=_e*Wt,Qt=ne/(-Qe+Wt),nn=Qt*-Qe;if(F.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(nn),J.translateZ(Qt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),ie[10]===-1)J.projectionMatrix.copy(F.projectionMatrix),J.projectionMatrixInverse.copy(F.projectionMatrixInverse);else{let z=_e+Qt,_n=Re+Qt,St=lt-nn,Xt=Lt+(ne-nn),N=ke*Re/_n*z,M=We*Re/_n*z;J.projectionMatrix.makePerspective(St,Xt,N,M,z,_n),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,F){if(F===null)J.matrixWorld.copy(J.matrix);else J.matrixWorld.multiplyMatrices(F.matrixWorld,J.matrix);J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;let{near:F,far:W}=J;if(m.texture!==null){if(m.depthNear>0)F=m.depthNear;if(m.depthFar>0)W=m.depthFar}if(R.near=P.near=A.near=F,R.far=P.far=A.far=W,k!==R.near||C!==R.far)i.updateRenderState({depthNear:R.near,depthFar:R.far}),k=R.near,C=R.far;R.layers.mask=J.layers.mask|6,A.layers.mask=R.layers.mask&-5,P.layers.mask=R.layers.mask&-3;let ne=J.parent,ie=R.cameras;q(R,ne);for(let ce=0;ce<ie.length;ce++)q(ie[ce],ne);if(ie.length===2)X(R,A,P);else R.projectionMatrix.copy(A.projectionMatrix);if(T===null&&J.isPerspectiveCamera)T={camera:J,fov:J.fov,zoom:J.zoom};le(J,R,ne)};function le(J,F,W){if(W===null)J.matrix.copy(F.matrixWorld);else J.matrix.copy(W.matrixWorld),J.matrix.invert(),J.matrix.multiply(F.matrixWorld);if(J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(F.projectionMatrix),J.projectionMatrixInverse.copy(F.projectionMatrixInverse),J.isPerspectiveCamera)J.fov=_a*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1}this.getCamera=function(){return R},this.getFoveation=function(){if(d===null&&f===null)return;return o},this.setFoveation=function(J){if(o=J,d!==null)d.fixedFoveation=J;if(f!==null&&f.fixedFoveation!==void 0)f.fixedFoveation=J},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(R)},this.getCameraTexture=function(J){return g[J]};let de=null;function Me(J,F){if(l=F.getViewerPose(c||s),h=F,l!==null){let W=l.views;if(f!==null)e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_);let ne=!1;if(W.length!==R.cameras.length)R.cameras.length=0,ne=!0;for(let Re=0;Re<W.length;Re++){let ke=W[Re],We=null;if(f!==null)We=f.getViewport(ke);else{let Wt=u.getViewSubImage(d,ke);if(We=Wt.viewport,Re===0)e.setRenderTargetTextures(_,Wt.colorTexture,Wt.depthStencilTexture),e.setRenderTarget(_)}let Qe=S[Re];if(Qe===void 0)Qe=new hn,Qe.layers.enable(Re),Qe.viewport=new Pt,S[Re]=Qe;if(Qe.matrix.fromArray(ke.transform.matrix),Qe.matrix.decompose(Qe.position,Qe.quaternion,Qe.scale),Qe.projectionMatrix.fromArray(ke.projectionMatrix),Qe.projectionMatrixInverse.copy(Qe.projectionMatrix).invert(),Qe.viewport.set(We.x,We.y,We.width,We.height),Re===0)R.matrix.copy(Qe.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale);if(ne===!0)R.cameras.push(Qe)}let ie=i.enabledFeatures;if(ie&&ie.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){u=n.getBinding();let Re=u.getDepthInformation(W[0]);if(Re&&Re.isValid&&Re.texture)m.init(Re,i.renderState)}if(ie&&ie.includes("camera-access")&&b){e.state.unbindTexture(),u=n.getBinding();for(let Re=0;Re<W.length;Re++){let ke=W[Re].camera;if(ke){let We=g[ke];if(!We)We=new kd,g[ke]=We;let Qe=u.getCameraImage(ke);We.sourceTexture=Qe}}}}for(let W=0;W<y.length;W++){let ne=v[W],ie=y[W];if(ne!==null&&ie!==void 0)ie.update(ne,F,c||s)}if(de)de(J,F);if(F.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:F});h=null}let pe=new wA;pe.setAnimationLoop(Me),this.setAnimationLoop=function(J){de=J},this.dispose=function(){}}};c8=new Je,UA=new tt;UA.set(-1,0,0,0,1,0,0,0,1);d8=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])});async function Al(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}function U8(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=()=>{throw Error("Texture manifest cannot read image dimensions")},i=(s,a)=>{if(s+a>e.byteLength)n()};if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return i(16,8),{width:t.getUint32(16),height:t.getUint32(20)};if(Ng(e))return i(20,8),{width:t.getUint32(20,!0),height:t.getUint32(24,!0)};if(e[0]===255&&e[1]===216){let s=2;while(s+4<=e.byteLength){if(e[s]!==255)n();let a=e[s+1];if(a===255){s++;continue}if(a===216||a===1||a>=208&&a<=215){s+=2;continue}let o=t.getUint16(s+2);if(a>=192&&a<=207&&![196,200,204].includes(a))return i(s+5,4),{width:t.getUint16(s+7),height:t.getUint16(s+5)};s+=2+o}n()}let r=(s)=>String.fromCharCode(...e.subarray(s,Math.min(s+4,e.byteLength)));if(r(0)==="RIFF"&&r(8)==="WEBP"){i(12,19);let s=r(12);if(s==="VP8X")return{width:1+(t.getUint32(24,!0)&16777215),height:1+(t.getUint32(27,!0)&16777215)};if(s==="VP8L"){let a=t.getUint32(21,!0);return{width:1+(a&16383),height:1+(a>>14&16383)}}if(s==="VP8 ")return i(26,4),{width:t.getUint16(26,!0)&16383,height:t.getUint16(28,!0)&16383}}return n()}function B8(e){if(!Ss(e))return;let t=Ss(e.extensions)?e.extensions:{};for(let n of["KHR_texture_basisu","EXT_texture_webp","EXT_texture_avif"]){let i=t[n];if(Ss(i)&&ws(i.source)!==void 0)return ws(i.source)}return ws(e.source)}function z8(e){let t=Array.isArray(e.textures)?e.textures:[],n=new Set;for(let i of Array.isArray(e.materials)?e.materials:[]){if(!Ss(i))continue;let r=Ss(i.pbrMetallicRoughness)?i.pbrMetallicRoughness:{};for(let s of[r.baseColorTexture,i.emissiveTexture]){let a=Ss(s)?ws(s.index):void 0,o=a===void 0?void 0:B8(t[a]);if(o!==void 0)n.add(o)}}return n}function V8(e){let t=atob(e);return Uint8Array.from(t,(n)=>n.charCodeAt(0))}function j8(e,t){let n=Array.isArray(e.bufferViews)?e.bufferViews:[];return(Array.isArray(e.images)?e.images:[]).map((i)=>{if(!Ss(i))throw Error("Invalid glTF image");let r=ws(i.bufferView);if(r!==void 0){let a=n[r];if(!Ss(a)||ws(a.buffer)!==0||!t)throw Error("Texture manifest requires images embedded in the GLB binary chunk");let o=ws(a.byteOffset)??0,c=ws(a.byteLength);if(c===void 0||o+c>t.byteLength)throw Error("Invalid glTF image buffer view");if(typeof i.mimeType!=="string")throw Error("Embedded image needs a mimeType");return{bytes:t.subarray(o,o+c),mimeType:i.mimeType}}let s=typeof i.uri==="string"?/^data:([^;,]+);base64,(.*)$/s.exec(i.uri):null;if(!s)throw Error("Texture manifest requires embedded image bytes");return{bytes:V8(s[2]),mimeType:s[1]}})}async function Pw(e,t,n={}){let i=z8(e),r=[];for(let[s,{bytes:a,mimeType:o}]of j8(e,t).entries()){let c=`sha256:${await Al(a)}`,l=n.sources?.get(s),u=l??c,d=n.maps?.find((f)=>f.sha256===u);r.push({image:s,sha256:c,bytes:a.byteLength,mimeType:o,...U8(a),colorSpace:i.has(s)?"srgb":"linear",...l&&l!==c?{sourceSha256:l}:{},...d?{material:{pin:{...d.pin},slot:d.slot}}:{}})}return r}function Ow(e){let t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/ktx2":"ktx2"}[e];if(!t)throw Error(`External textures do not support ${e}`);return t}var Ss=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),ws=(e)=>Number.isInteger(e)&&e>=0?e:void 0,F8,Ng=(e)=>e.byteLength>=12&&F8.every((t,n)=>e[n]===t);var Pg=ut(()=>{F8=Object.freeze([171,75,84,88,32,50,48,187,13,10,26,10])});var kw=class{_listeners={};addEventListener(e,t){let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t);return this}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let i=n.indexOf(t);if(i!==-1)n.splice(i,1)}return this}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){let n=t.slice(0);for(let i=0,r=n.length;i<r;i++)n[i].call(this,e)}return this}dispose(){for(let e in this._listeners)delete this._listeners[e]}},Rs=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,n,i={}){if(this._name=e,this._parent=t,this._child=n,this._attributes=i,!t.isOnGraph(n))throw Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}},Og,xn=class{list=[];constructor(e){if(e)for(let t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){let t=this.list.indexOf(e);if(t>=0)this.list.splice(t,1)}removeChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);for(let n of t)this.remove(n);return t}listRefsByChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);return t}values(){return this.list}},It=class{set=new Set;map=new Map;constructor(e){if(e)for(let t of e)this.add(t)}add(e){let t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){let t=this.map.get(e)||null;if(t)this.remove(t);return t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},dn=class{map={};constructor(e){if(e)Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},At,Ms,Dw;var Lw=ut(()=>{Og=class extends kw{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){let t=new Set;for(let n of this.listParentEdges(e))t.add(n.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){let t=new Set;for(let n of this.listChildEdges(e))t.add(n.getChild());return Array.from(t)}disconnectParents(e,t){for(let n of this.listParentEdges(e))if(!t||t(n.getParent()))n.dispose();return this}_createEdge(e,t,n,i){let r=new Rs(e,t,n,i);this._edges.add(r);let s=r.getParent();if(!this._parentEdges.has(s))this._parentEdges.set(s,new Set);this._parentEdges.get(s).add(r);let a=r.getChild();if(!this._childEdges.has(a))this._childEdges.set(a,new Set);return this._childEdges.get(a).add(r),r}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},At=Symbol("attributes"),Ms=Symbol("immutableKeys"),Dw=class e extends kw{_disposed=!1;graph;[At];[Ms];constructor(t){super();this.graph=t,this[Ms]=new Set,this[At]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let t=this.getDefaults(),n={};for(let i in t){let r=t[i];if(r instanceof e){let s=this.graph._createEdge(i,this,r);this[Ms].add(i),n[i]=s}else n[i]=r}return n}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((t)=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(t,n){for(let i in this[At]){let r=this[At][i];if(r instanceof Rs){let s=r;if(s.getChild()===t)this.setRef(i,n,s.getAttributes())}else if(r instanceof xn)for(let s of r.listRefsByChild(t)){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}else if(r instanceof It){let s=r.getRefByChild(t);if(s){let a=s.getAttributes();this.removeRef(i,t),this.addRef(i,n,a)}}else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);if(a.getChild()===t)this.setRefMap(i,s,n,a.getAttributes())}}return this}get(t){return this[At][t]}set(t,n){return this[At][t]=n,this.dispatchEvent({type:"change",attribute:t})}getRef(t){let n=this[At][t];return n?n.getChild():null}setRef(t,n,i){if(this[Ms].has(t))throw Error(`Cannot overwrite immutable attribute, "${t}".`);let r=this[At][t];if(r)r.dispose();if(!n)return this;let s=this.graph._createEdge(t,this,n,i);return this[At][t]=s,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map((n)=>n.getChild())}addRef(t,n,i){let r=this.graph._createEdge(t,this,n,i);return this.assertRefList(t).add(r),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,n){let i=this.assertRefList(t);if(i instanceof xn)for(let r of i.listRefsByChild(n))r.dispose();else{let r=i.getRefByChild(n);if(r)r.dispose()}return this}assertRefList(t){let n=this[At][t];if(n instanceof xn||n instanceof It)return n;throw Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map((n)=>n.getChild())}getRefMap(t,n){let i=this.assertRefMap(t).get(n);return i?i.getChild():null}setRefMap(t,n,i,r){let s=this.assertRefMap(t),a=s.get(n);if(a)a.dispose();if(!i)return this;r=Object.assign(r||{},{key:n});let o=this.graph._createEdge(t,this,i,{...r,key:n});return s.set(n,o),this.dispatchEvent({type:"change",attribute:t,key:n})}assertRefMap(t){let n=this[At][t];if(n instanceof dn)return n;throw Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){let n=t.getName();if(this[At][n]===t){if(this[At][n]=null,this[Ms].has(n))t.getChild().dispose()}else if(this[At][n]instanceof xn)this[At][n].remove(t);else if(this[At][n]instanceof It)this[At][n].remove(t);else if(this[At][n]instanceof dn){let i=this[At][n];for(let r of i.keys())if(i.get(r)===t)i.delete(r)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:n})}}});function W8(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw TypeError("Invalid JPG, marker table corrupted");return e}function X8(){var e=new Lg(3);if(Lg!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function kg(e){var t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function q8(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function Ug(e){let t=Kw(),n=e.propertyType==="Node"?[e]:e.listChildren();for(let i of n)i.traverse((r)=>{let s=r.getMesh();if(!s)return;let a=J8(s,r.getWorldMatrix());if(a.min.every(isFinite)&&a.max.every(isFinite))Fg(a.min,t),Fg(a.max,t)});return t}function J8(e,t){let n=Kw();for(let i of e.listPrimitives()){let r=i.getAttribute("POSITION"),s=i.getIndices();if(!r)continue;let a=[0,0,0],o=[0,0,0];for(let c=0,l=s?s.getCount():r.getCount();c<l;c++){let u=s?s.getScalar(c):c;a=r.getElement(u,a),o=q8(o,a,t),Fg(o,n)}}return n}function Fg(e,t){for(let n=0;n<3;n++)t.min[n]=Math.min(e[n],t.min[n]),t.max[n]=Math.max(e[n],t.max[n])}function Kw(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function Uw(e){return Object.prototype.toString.call(e)==="[object Object]"}function Oa(e){if(Uw(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;if(Uw(n)===!1)return!1;if(Object.hasOwn(n,"isPrototypeOf")===!1)return!1;return!0}function Y8(e){var t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*a-n*s,x=t*o-i*s,_=n*o-i*a,y=l*b-u*h,v=l*m-d*h,E=u*m-d*b,w=t*E-n*v+i*y,T=s*E-a*v+o*y,A=l*_-u*x+d*p,P=h*_-b*x+m*p;return c*w-r*T+g*A-f*P}function Q8(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],x=t[15],_=n[0],y=n[1],v=n[2],E=n[3];return e[0]=_*i+y*o+v*d+E*m,e[1]=_*r+y*c+v*f+E*g,e[2]=_*s+y*l+v*h+E*p,e[3]=_*a+y*u+v*b+E*x,_=n[4],y=n[5],v=n[6],E=n[7],e[4]=_*i+y*o+v*d+E*m,e[5]=_*r+y*c+v*f+E*g,e[6]=_*s+y*l+v*h+E*p,e[7]=_*a+y*u+v*b+E*x,_=n[8],y=n[9],v=n[10],E=n[11],e[8]=_*i+y*o+v*d+E*m,e[9]=_*r+y*c+v*f+E*g,e[10]=_*s+y*l+v*h+E*p,e[11]=_*a+y*u+v*b+E*x,_=n[12],y=n[13],v=n[14],E=n[15],e[12]=_*i+y*o+v*d+E*m,e[13]=_*r+y*c+v*f+E*g,e[14]=_*s+y*l+v*h+E*p,e[15]=_*a+y*u+v*b+E*x,e}function eF(e,t){var n=t[0],i=t[1],r=t[2],s=t[4],a=t[5],o=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(s*s+a*a+o*o),e[2]=Math.sqrt(c*c+l*l+u*u),e}function tF(e,t){var n=new Lg(3);eF(n,t);var i=1/n[0],r=1/n[1],s=1/n[2],a=t[0]*i,o=t[1]*r,c=t[2]*s,l=t[4]*i,u=t[5]*r,d=t[6]*s,f=t[8]*i,h=t[9]*r,b=t[10]*s,m=a+u+b,g=0;if(m>0)g=Math.sqrt(m+1)*2,e[3]=0.25*g,e[0]=(d-h)/g,e[1]=(f-c)/g,e[2]=(o-l)/g;else if(a>u&&a>b)g=Math.sqrt(1+a-u-b)*2,e[3]=(d-h)/g,e[0]=0.25*g,e[1]=(o+l)/g,e[2]=(f+c)/g;else if(u>b)g=Math.sqrt(1+u-a-b)*2,e[3]=(f-c)/g,e[0]=(o+l)/g,e[1]=0.25*g,e[2]=(d+h)/g;else g=Math.sqrt(1+b-a-u)*2,e[3]=(o-l)/g,e[0]=(f+c)/g,e[1]=(d+h)/g,e[2]=0.25*g;return e}function nF(e,t){if(!!e!==!!t)return!1;let n=e.getChild(),i=t.getChild();return n===i||n.equals(i)}function iF(e,t){if(!!e!==!!t)return!1;let n=e.values(),i=t.values();if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++){let s=n[r],a=i[r];if(s.getChild()===a.getChild())continue;if(!s.getChild().equals(a.getChild()))return!1}return!0}function rF(e,t){if(!!e!==!!t)return!1;let n=e.keys(),i=t.keys();if(n.length!==i.length)return!1;for(let r of n){let s=e.get(r),a=t.get(r);if(!!s!==!!a)return!1;let o=s.getChild(),c=a.getChild();if(o===c)continue;if(!o.equals(c))return!1}return!0}function Ww(e,t){if(e===t)return!0;if(!!e!==!!t||!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Xw(e,t){if(e===t)return!0;if(!!e!==!!t)return!1;if(!Oa(e)||!Oa(t))return e===t;let n=e,i=t,r=0,s=0,a;for(a in n)r++;for(a in i)s++;if(r!==s)return!1;for(a in n){let o=n[a],c=i[a];if(nf(o)&&nf(c)){if(!Ww(o,c))return!1}else if(Oa(o)&&Oa(c)){if(!Xw(o,c))return!1}else if(o!==c)return!1}return!0}function nf(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function uF(e){switch(e.constructor){case Float32Array:return Oe.ComponentType.FLOAT;case Uint32Array:return Oe.ComponentType.UNSIGNED_INT;case Uint16Array:return Oe.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Oe.ComponentType.UNSIGNED_BYTE;case Int16Array:return Oe.ComponentType.SHORT;case Int8Array:return Oe.ComponentType.BYTE;case Float64Array:return Oe.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return Oe.ComponentType.FLOAT16;throw Error("Unknown accessor componentType.")}function mF(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=wl[e.componentType],a=Oe.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new s(e.count*a),u=new DataView(i.buffer,i.byteOffset,i.byteLength),d=r.byteStride;for(let f=0;f<e.count;f++)for(let h=0;h<a;h++){let b=c+f*d+h*o,m;switch(e.componentType){case Oe.ComponentType.FLOAT:m=u.getFloat32(b,!0);break;case Oe.ComponentType.UNSIGNED_INT:m=u.getUint32(b,!0);break;case Oe.ComponentType.UNSIGNED_SHORT:m=u.getUint16(b,!0);break;case Oe.ComponentType.UNSIGNED_BYTE:m=u.getUint8(b);break;case Oe.ComponentType.SHORT:m=u.getInt16(b,!0);break;case Oe.ComponentType.BYTE:m=u.getInt8(b);break;case Oe.ComponentType.FLOAT16:m=u.getFloat16(b,!0);break;case Oe.ComponentType.FLOAT64:m=u.getFloat64(b,!0);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}l[f*a+h]=m}return l}function tf(e,t){let n=t.jsonDoc,i=t.bufferViews[e.bufferView],r=n.json.bufferViews[e.bufferView],s=wl[e.componentType],a=Oe.getElementSize(e.type),o=s.BYTES_PER_ELEMENT,c=a*o;if(r.byteStride!==void 0&&r.byteStride!==c)return mF(e,t);let l=i.byteOffset+(e.byteOffset||0),u=e.count*a*o;return new s(i.buffer.slice(l,l+u))}function gF(e,t){let n=wl[e.componentType],i=Oe.getElementSize(e.type),r;if(e.bufferView!==void 0)r=tf(e,t);else r=new n(e.count*i);let s=e.sparse;if(!s)return r;let a=s.count,o={...e,...s.indices,count:a,type:"SCALAR"},c={...e,...s.values,count:a},l=tf(o,t),u=tf(c,t);for(let d=0;d<o.count;d++)for(let f=0;f<i;f++)r[l[d]*i+f]=u[d*i+f];return r}function bF(e,t){let n=e.getGraph().listParentEdges(t).find((i)=>i.getParent()!==e.getRoot());return n?n.getName().replace(/texture$/i,""):""}function TF(e){let t=[];for(let n in e){let i=e[n];if(Array.isArray(i)&&i.length===0)t.push(n);else if(i===null||i==="")t.push(n);else if(i&&typeof i==="object"&&Object.keys(i).length===0)t.push(n)}for(let n of t)delete e[n]}function wF(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function SF(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function jw(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var Hw="v4.5.1",Cs="@glb.bin",Q,H8,Ai,Gw,G8,wl,Ze=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){let t=atob(e.split(",")[1]),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}else{let t=e.split(",")[1],n=e.indexOf("base64")>=0;return Buffer.from(t,n?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let r of e)t+=r.byteLength;let n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.byteLength;return n}static pad(e,t=0){let n=this.padNumber(e.byteLength);if(n===e.byteLength)return e;let i=new Uint8Array(n);if(i.set(e),t!==0)for(let r=e.byteLength;r<n;r++)i[r]=t;return i}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let n=e.byteLength;while(n--)if(e[n]!==t[n])return!1;return!0}static toView(e,t=0,n=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,n))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},$w=class{static hexToFactor(e,t){e=Math.floor(e);let n=t;return n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[n,i,r]=this.convertLinearToSRGB(e,t);return n*255<<16^i*255<<8^r*255<<0}static convertSRGBToLinear(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.04045?n[r]*0.0773993808:Math.pow(n[r]*0.9478672986+0.0521327014,2.4);return t}static convertLinearToSRGB(e,t){let n=e,i=t;for(let r=0;r<3;r++)i[r]=n[r]<0.0031308?n[r]*12.92:1.055*Math.pow(n[r],0.41666)-0.055;return t}},$8=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),n,i;while(t.byteLength){if(n=t.getUint16(0,!1),W8(t,n),i=t.getUint8(n+1),i===192||i===193||i===194)return[t.getUint16(n+7,!1),t.getUint16(n+5,!1)];t=new DataView(e.buffer,t.byteOffset+n+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},K8=class e{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){let n=new DataView(t.buffer,t.byteOffset);if(Ze.decodeText(t.slice(12,16))===e.PNG_FRIED_CHUNK_NAME)return[n.getUint32(32,!1),n.getUint32(36,!1)];return[n.getUint32(16,!1),n.getUint32(20,!1)]}getChannels(t){return 4}},Gi,ka=class{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return Gi.mimeTypeToExtension(t)}else if(e.startsWith("data:model/gltf+json"))return"gltf";else if(e.startsWith("data:model/gltf-binary"))return"glb";else if(e.startsWith("data:application/"))return"bin";return e.split(/[\\/]/).pop().split(/[.]/).pop()}},Lg,Fw="https://null.example",Dg,Z8,La,mt=class e{static identity(t){return t}static eq(t,n,i=0.00001){if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-n[r])>i)return!1;return!0}static clamp(t,n,i){if(t<n)return n;if(t>i)return i;return t}static decodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return Math.round(e.clamp(t,0,1)*65535);case 5121:return Math.round(e.clamp(t,0,1)*255);case 5122:return Math.round(e.clamp(t,-1,1)*32767);case 5120:return Math.round(e.clamp(t,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(t,n,i,r){let s=kg([t[0],t[1],t[2]]),a=kg([t[4],t[5],t[6]]),o=kg([t[8],t[9],t[10]]);if(Y8(t)<0)s=-s;n[0]=t[12],n[1]=t[13],n[2]=t[14];let c=t.slice(),l=1/s,u=1/a,d=1/o;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,tF(i,c),r[0]=s,r[1]=a,r[2]=o}static compose(t,n,i,r){let s=r,a=n[0],o=n[1],c=n[2],l=n[3],u=a+a,d=o+o,f=c+c,h=a*u,b=a*d,m=a*f,g=o*d,p=o*f,x=c*f,_=l*u,y=l*d,v=l*f,E=i[0],w=i[1],T=i[2];return s[0]=(1-(g+x))*E,s[1]=(b+v)*E,s[2]=(m-y)*E,s[3]=0,s[4]=(b-v)*w,s[5]=(1-(h+x))*w,s[6]=(p+_)*w,s[7]=0,s[8]=(m+y)*T,s[9]=(p-_)*T,s[10]=(1-(h+g))*T,s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s[15]=1,s}},sF="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",aF=999,oF=6,Bw,cF=function(){let e="";for(let t=0;t<oF;t++)e+=sF.charAt(Math.floor(Math.random()*42));return e},qw=function(){for(let e=0;e<aF;e++){let t=cF();if(!Bw.has(t))return Bw.add(t),t}return""},Ns=(e)=>e,lF,Bg,$n,Oe,Jw,Fa,Sl,Zw,rf,nt,wt,Zd,Yd,Qd,dF,Da,zg,sf,Zn,Vg,af,Yw,Xo,Ps,of,_t=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=(n)=>{let i=n,r=i.target;if(r instanceof nt&&r.extensionName===this.extensionName){if(i.type==="node:create")this._addExtensionProperty(r);if(i.type==="node:dispose")this._removeExtensionProperty(r)}};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(let t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},fF=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){if(this.textureInfos.set(e,t),t.texCoord!==void 0)e.setTexCoord(t.texCoord);if(t.extras!==void 0)e.setExtras(t.extras);let n=this.jsonDoc.json.textures[t.index];if(n.sampler===void 0)return;let i=this.jsonDoc.json.samplers[n.sampler];if(i.magFilter!==void 0)e.setMagFilter(i.magFilter);if(i.minFilter!==void 0)e.setMinFilter(i.minFilter);if(i.wrapS!==void 0)e.setWrapS(i.wrapS);if(i.wrapT!==void 0)e.setWrapT(i.wrapT)}},zw,hF,pF=class{static read(e,t=zw){let n={...zw,...t},{json:i}=e,r=new of().setLogger(n.logger);this.validate(e,n);let s=new fF(e),a=i.asset,o=r.getRoot().getAsset();if(a.copyright)o.copyright=a.copyright;if(a.extras)o.extras=a.extras;if(i.extras!==void 0)r.getRoot().setExtras({...i.extras});let c=i.extensionsUsed||[],l=i.extensionsRequired||[];n.extensions.sort((p,x)=>p.EXTENSION_NAME>x.EXTENSION_NAME?1:-1);for(let p of n.extensions)if(c.includes(p.EXTENSION_NAME)){let x=r.createExtension(p).setRequired(l.includes(p.EXTENSION_NAME)),_=x.prereadTypes.filter((y)=>!hF.has(y));if(_.length)n.logger.warn(`Preread hooks for some types (${_.join()}), requested by extension ${x.extensionName}, are unsupported. Please file an issue or a PR.`);for(let y of x.readDependencies)x.install(y,n.dependencies[y])}let u=i.buffers||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Buffer")).forEach((p)=>p.preread(s,"Buffer")),s.buffers=u.map((p)=>{let x=r.createBuffer(p.name);if(p.extras)x.setExtras(p.extras);if(p.uri&&p.uri.indexOf("__")!==0)x.setURI(p.uri);return x}),s.bufferViewBuffers=(i.bufferViews||[]).map((p,x)=>{if(!s.bufferViews[x]){let _=e.json.buffers[p.buffer],y=_.uri?e.resources[_.uri]:e.resources[Cs],v=p.byteOffset||0;s.bufferViews[x]=Ze.toView(y,v,p.byteLength)}return s.buffers[p.buffer]});let d=i.accessors||[];s.accessors=d.map((p)=>{let x=s.bufferViewBuffers[p.bufferView],_=r.createAccessor(p.name,x).setType(p.type);if(p.extras)_.setExtras(p.extras);if(p.normalized!==void 0)_.setNormalized(p.normalized);if(p.bufferView===void 0)return _;return _.setArray(tf(p,s)),_});let f=i.images||[],h=i.textures||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Texture")).forEach((p)=>p.preread(s,"Texture")),s.textures=f.map((p)=>{let x=r.createTexture(p.name);if(p.extras)x.setExtras(p.extras);if(p.bufferView!==void 0){let _=i.bufferViews[p.bufferView],y=e.json.buffers[_.buffer],v=y.uri?e.resources[y.uri]:e.resources[Cs],E=_.byteOffset||0,w=_.byteLength,T=v.slice(E,E+w);x.setImage(T)}else if(p.uri!==void 0){if(x.setImage(e.resources[p.uri]),p.uri.indexOf("__")!==0)x.setURI(p.uri)}if(p.mimeType!==void 0)x.setMimeType(p.mimeType);else if(p.uri){let _=ka.extension(p.uri);x.setMimeType(Gi.extensionToMimeType(_))}return x}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Material")).forEach((p)=>p.preread(s,"Material")),s.materials=(i.materials||[]).map((p)=>{let x=r.createMaterial(p.name);if(p.extras)x.setExtras(p.extras);if(p.alphaMode!==void 0)x.setAlphaMode(p.alphaMode);if(p.alphaCutoff!==void 0)x.setAlphaCutoff(p.alphaCutoff);if(p.doubleSided!==void 0)x.setDoubleSided(p.doubleSided);let _=p.pbrMetallicRoughness||{};if(_.baseColorFactor!==void 0)x.setBaseColorFactor(_.baseColorFactor);if(p.emissiveFactor!==void 0)x.setEmissiveFactor(p.emissiveFactor);if(_.metallicFactor!==void 0)x.setMetallicFactor(_.metallicFactor);if(_.roughnessFactor!==void 0)x.setRoughnessFactor(_.roughnessFactor);if(_.baseColorTexture!==void 0){let y=_.baseColorTexture,v=s.textures[h[y.index].source];x.setBaseColorTexture(v),s.setTextureInfo(x.getBaseColorTextureInfo(),y)}if(p.emissiveTexture!==void 0){let y=p.emissiveTexture,v=s.textures[h[y.index].source];x.setEmissiveTexture(v),s.setTextureInfo(x.getEmissiveTextureInfo(),y)}if(p.normalTexture!==void 0){let y=p.normalTexture,v=s.textures[h[y.index].source];if(x.setNormalTexture(v),s.setTextureInfo(x.getNormalTextureInfo(),y),p.normalTexture.scale!==void 0)x.setNormalScale(p.normalTexture.scale)}if(p.occlusionTexture!==void 0){let y=p.occlusionTexture,v=s.textures[h[y.index].source];if(x.setOcclusionTexture(v),s.setTextureInfo(x.getOcclusionTextureInfo(),y),p.occlusionTexture.strength!==void 0)x.setOcclusionStrength(p.occlusionTexture.strength)}if(_.metallicRoughnessTexture!==void 0){let y=_.metallicRoughnessTexture,v=s.textures[h[y.index].source];x.setMetallicRoughnessTexture(v),s.setTextureInfo(x.getMetallicRoughnessTextureInfo(),y)}return x}),r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Mesh")).forEach((p)=>p.preread(s,"Mesh"));let b=i.meshes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Primitive")).forEach((p)=>p.preread(s,"Primitive")),s.meshes=b.map((p)=>{let x=r.createMesh(p.name);if(p.extras)x.setExtras(p.extras);if(p.weights!==void 0)x.setWeights(p.weights);return(p.primitives||[]).forEach((_)=>{let y=r.createPrimitive();if(_.extras)y.setExtras(_.extras);if(_.material!==void 0)y.setMaterial(s.materials[_.material]);if(_.mode!==void 0)y.setMode(_.mode);for(let[E,w]of Object.entries(_.attributes||{}))y.setAttribute(E,s.accessors[w]);if(_.indices!==void 0)y.setIndices(s.accessors[_.indices]);let v=p.extras&&p.extras.targetNames||[];(_.targets||[]).forEach((E,w)=>{let T=v[w]||w.toString(),A=r.createPrimitiveTarget(T);for(let[P,S]of Object.entries(E))A.setAttribute(P,s.accessors[S]);y.addTarget(A)}),x.addPrimitive(y)}),x}),s.cameras=(i.cameras||[]).map((p)=>{let x=r.createCamera(p.name).setType(p.type);if(p.extras)x.setExtras(p.extras);if(p.type===rf.Type.PERSPECTIVE){let _=p.perspective;if(x.setYFov(_.yfov),x.setZNear(_.znear),_.zfar!==void 0)x.setZFar(_.zfar);if(_.aspectRatio!==void 0)x.setAspectRatio(_.aspectRatio)}else{let _=p.orthographic;x.setZNear(_.znear).setZFar(_.zfar).setXMag(_.xmag).setYMag(_.ymag)}return x});let m=i.nodes||[];r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Node")).forEach((p)=>p.preread(s,"Node")),s.nodes=m.map((p)=>{let x=r.createNode(p.name);if(p.extras)x.setExtras(p.extras);if(p.translation!==void 0)x.setTranslation(p.translation);if(p.rotation!==void 0)x.setRotation(p.rotation);if(p.scale!==void 0)x.setScale(p.scale);if(p.matrix!==void 0){let _=[0,0,0],y=[0,0,0,1],v=[1,1,1];mt.decompose(p.matrix,_,y,v),x.setTranslation(_),x.setRotation(y),x.setScale(v)}if(p.weights!==void 0)x.setWeights(p.weights);return x}),s.skins=(i.skins||[]).map((p)=>{let x=r.createSkin(p.name);if(p.extras)x.setExtras(p.extras);if(p.inverseBindMatrices!==void 0)x.setInverseBindMatrices(s.accessors[p.inverseBindMatrices]);if(p.skeleton!==void 0)x.setSkeleton(s.nodes[p.skeleton]);for(let _ of p.joints)x.addJoint(s.nodes[_]);return x}),m.map((p,x)=>{let _=s.nodes[x];if((p.children||[]).forEach((y)=>_.addChild(s.nodes[y])),p.mesh!==void 0)_.setMesh(s.meshes[p.mesh]);if(p.camera!==void 0)_.setCamera(s.cameras[p.camera]);if(p.skin!==void 0)_.setSkin(s.skins[p.skin])}),s.animations=(i.animations||[]).map((p)=>{let x=r.createAnimation(p.name);if(p.extras)x.setExtras(p.extras);let _=(p.samplers||[]).map((y)=>{let v=r.createAnimationSampler().setInput(s.accessors[y.input]).setOutput(s.accessors[y.output]).setInterpolation(y.interpolation||Sl.Interpolation.LINEAR);if(y.extras)v.setExtras(y.extras);return x.addSampler(v),v});return(p.channels||[]).forEach((y)=>{let v=r.createAnimationChannel().setSampler(_[y.sampler]).setTargetPath(y.target.path);if(y.target.node!==void 0)v.setTargetNode(s.nodes[y.target.node]);if(y.extras)v.setExtras(y.extras);x.addChannel(v)}),x});let g=i.scenes||[];if(r.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Scene")).forEach((p)=>p.preread(s,"Scene")),s.scenes=g.map((p)=>{let x=r.createScene(p.name);if(p.extras)x.setExtras(p.extras);return(p.nodes||[]).map((_)=>s.nodes[_]).forEach((_)=>x.addChild(_)),x}),i.scene!==void 0)r.getRoot().setDefaultScene(s.scenes[i.scene]);return r.getRoot().listExtensionsUsed().forEach((p)=>p.read(s)),d.forEach((p,x)=>{let _=s.accessors[x],y=!!p.sparse,v=!p.bufferView&&!_.getArray();if(y||v)_.setSparse(!0).setArray(gF(p,s))}),r}static validate(e,t){let n=e.json;if(n.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${n.asset.version}".`);if(n.extensionsRequired){for(let i of n.extensionsRequired)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))throw Error(`Missing required extension, "${i}".`)}if(n.extensionsUsed){for(let i of n.extensionsUsed)if(!t.extensions.find((r)=>r.EXTENSION_NAME===i))t.logger.warn(`Missing optional extension, "${i}".`)}}},Qw,Is,Vw=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();else if(!this.multiple)return`${this.basename(e)}.${t}`;else{let n=this.basename(e);return this.counter[n]=this.counter[n]||1,`${n}_${this.counter[n]++}.${t}`}}},ef,xF,yF,_F,vF,EF=class{static write(e,t){let n=e.getGraph(),i=e.getRoot(),r={asset:{generator:`glTF-Transform ${Hw}`,...i.getAsset()},extras:{...i.getExtras()}},s={json:r,resources:{}},a=new Is(e,s,t),o=t.logger||La.DEFAULT_INSTANCE,c=new Set(t.extensions.map((m)=>m.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1);if(l.length<e.getRoot().listExtensionsUsed().length)o.warn("Some extensions were not registered for I/O, and will not be written.");for(let m of l){let g=m.prewriteTypes.filter((p)=>!vF.has(p));if(g.length)o.warn(`Prewrite hooks for some types (${g.join()}), requested by extension ${m.extensionName}, are unsupported. Please file an issue or a PR.`);for(let p of m.writeDependencies)m.install(p,t.dependencies[p])}function d(m,g,p,x){let _=[],y=0;for(let E of m){let w=a.createAccessorDef(E);w.bufferView=r.bufferViews.length;let T=E.getArray(),A=Ze.pad(Ze.toView(T));w.byteOffset=y,y+=A.byteLength,_.push(A),a.accessorIndexMap.set(E,r.accessors.length),r.accessors.push(w)}let v={buffer:g,byteOffset:p,byteLength:Ze.concat(_).byteLength};if(x)v.target=x;return r.bufferViews.push(v),{buffers:_,byteLength:y}}function f(m,g,p){let x=m[0].getCount(),_=0;for(let T of m){let A=a.createAccessorDef(T);A.bufferView=r.bufferViews.length,A.byteOffset=_;let P=T.getElementSize(),S=T.getComponentSize();_+=Ze.padNumber(P*S),a.accessorIndexMap.set(T,r.accessors.length),r.accessors.push(A)}let y=x*_,v=new ArrayBuffer(y),E=new DataView(v);for(let T=0;T<x;T++){let A=0;for(let P of m){let S=P.getElementSize(),R=P.getComponentSize(),k=P.getComponentType(),C=P.getArray();for(let U=0;U<S;U++){let L=T*_+A+U*R,O=C[T*S+U];switch(k){case Oe.ComponentType.FLOAT:E.setFloat32(L,O,!0);break;case Oe.ComponentType.BYTE:E.setInt8(L,O);break;case Oe.ComponentType.SHORT:E.setInt16(L,O,!0);break;case Oe.ComponentType.UNSIGNED_BYTE:E.setUint8(L,O);break;case Oe.ComponentType.UNSIGNED_SHORT:E.setUint16(L,O,!0);break;case Oe.ComponentType.UNSIGNED_INT:E.setUint32(L,O,!0);break;case Oe.ComponentType.FLOAT16:E.setFloat16(L,O,!0);break;case Oe.ComponentType.FLOAT64:E.setFloat64(L,O,!0);break;default:throw Error("Unexpected component type: "+k)}}A+=Ze.padNumber(S*R)}}let w={buffer:g,byteOffset:p,byteLength:y,byteStride:_,target:Is.BufferViewTarget.ARRAY_BUFFER};return r.bufferViews.push(w),{byteLength:y,buffers:[new Uint8Array(v)]}}function h(m,g,p){let x=[],_=0,y=new Map,v=-1/0,E=!1;for(let k of m){let C=a.createAccessorDef(k);r.accessors.push(C),a.accessorIndexMap.set(k,r.accessors.length-1);let U=[],L=[],O=[],K=Array(k.getElementSize()).fill(0);for(let le=0,de=k.getCount();le<de;le++){if(k.getElement(le,O),mt.eq(O,K,0))continue;v=Math.max(le,v),U.push(le);for(let Me=0;Me<O.length;Me++)L.push(O[Me])}let B=U.length,X={accessorDef:C,count:B};if(y.set(k,X),B===0)continue;if(B>k.getCount()/2)E=!0;let q=wl[k.getComponentType()];X.indices=U,X.values=new q(L)}if(!Number.isFinite(v))return{buffers:x,byteLength:_};if(E)o.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let w=v<255?Uint8Array:v<65535?Uint16Array:Uint32Array,T=v<255?_F:v<65535?yF:xF,A={buffer:g,byteOffset:p+_,byteLength:0};for(let k of m){let C=y.get(k);if(C.count===0)continue;C.indicesByteOffset=A.byteLength;let U=Ze.pad(Ze.toView(new w(C.indices)));x.push(U),_+=U.byteLength,A.byteLength+=U.byteLength}r.bufferViews.push(A);let P=r.bufferViews.length-1,S={buffer:g,byteOffset:p+_,byteLength:0};for(let k of m){let C=y.get(k);if(C.count===0)continue;C.valuesByteOffset=S.byteLength;let U=Ze.pad(Ze.toView(C.values));x.push(U),_+=U.byteLength,S.byteLength+=U.byteLength}r.bufferViews.push(S);let R=r.bufferViews.length-1;for(let k of m){let C=y.get(k);if(C.count===0)continue;C.accessorDef.sparse={count:C.count,indices:{bufferView:P,byteOffset:C.indicesByteOffset,componentType:T},values:{bufferView:R,byteOffset:C.valuesByteOffset}}}return{buffers:x,byteLength:_}}if(r.accessors=[],r.bufferViews=[],r.samplers=[],r.textures=[],r.images=i.listTextures().map((m,g)=>{let p=a.createPropertyDef(m);if(m.getMimeType())p.mimeType=m.getMimeType();let x=m.getImage();if(x)a.createImageData(p,x,m);return a.imageIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Accessor")).forEach((m)=>m.prewrite(a,"Accessor")),i.listAccessors().forEach((m)=>{let{accessorUsageGroupedByParent:g,accessorParents:p}=a;if(a.accessorIndexMap.has(m))return;let x=a.getAccessorUsage(m);if(a.addAccessorToUsageGroup(m,x),g.has(x)){let _=n.listParents(m).find((y)=>y.propertyType!=="Root");p.set(m,_)}}),l.filter((m)=>m.prewriteTypes.includes("Buffer")).forEach((m)=>m.prewrite(a,"Buffer")),(i.listAccessors().length>0||a.otherBufferViews.size>0||i.listTextures().length>0&&t.format==="GLB")&&i.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(r.buffers=[],i.listBuffers().forEach((m,g)=>{let p=a.createPropertyDef(m),x=a.accessorUsageGroupedByParent,_=m.listParents().filter((P)=>P instanceof Oe),y=new Set(_.map((P)=>a.accessorParents.get(P))),v=new Map(Array.from(y).map((P,S)=>[P,S])),E={};for(let P of _){if(a.accessorIndexMap.has(P))continue;let S=a.getAccessorUsage(P),R=S;if(x.has(S)){let k=a.accessorParents.get(P);R+=`:${v.get(k)}`}E[R]||={usage:S,accessors:[]},E[R].accessors.push(P)}let w=[],T=r.buffers.length,A=0;for(let{usage:P,accessors:S}of Object.values(E))if(P===ef.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){let R=f(S,T,A);A+=R.byteLength;for(let k of R.buffers)w.push(k)}else if(P===ef.ARRAY_BUFFER)for(let R of S){let k=f([R],T,A);A+=k.byteLength;for(let C of k.buffers)w.push(C)}else if(P===ef.SPARSE){let R=h(S,T,A);A+=R.byteLength;for(let k of R.buffers)w.push(k)}else if(P===ef.ELEMENT_ARRAY_BUFFER){let R=Is.BufferViewTarget.ELEMENT_ARRAY_BUFFER,k=d(S,T,A,R);A+=k.byteLength;for(let C of k.buffers)w.push(C)}else{let R=d(S,T,A);A+=R.byteLength;for(let k of R.buffers)w.push(k)}if(a.imageBufferViews.length&&g===0){for(let P=0;P<a.imageBufferViews.length;P++)if(r.bufferViews[r.images[P].bufferView].byteOffset=A,A+=a.imageBufferViews[P].byteLength,w.push(a.imageBufferViews[P]),A%8){let S=8-A%8;A+=S,w.push(new Uint8Array(S))}}if(a.otherBufferViews.has(m))for(let P of a.otherBufferViews.get(m))r.bufferViews.push({buffer:T,byteOffset:A,byteLength:P.byteLength}),a.otherBufferViewsIndexMap.set(P,r.bufferViews.length-1),A+=P.byteLength,w.push(P);if(A){let P;if(t.format==="GLB")P=Cs;else P=a.bufferURIGenerator.createURI(m,"bin"),p.uri=P;p.byteLength=A,a.assignResourceURI(P,Ze.concat(w),!0)}r.buffers.push(p),a.bufferIndexMap.set(m,g)}),i.listAccessors().find((m)=>!m.getBuffer()))o.warn("Skipped writing one or more Accessors: no Buffer assigned.");l.filter((m)=>m.prewriteTypes.includes("Material")).forEach((m)=>m.prewrite(a,"Material")),r.materials=i.listMaterials().map((m,g)=>{let p=a.createPropertyDef(m);if(m.getAlphaMode()!==Da.AlphaMode.OPAQUE)p.alphaMode=m.getAlphaMode();if(m.getAlphaMode()===Da.AlphaMode.MASK)p.alphaCutoff=m.getAlphaCutoff();if(m.getDoubleSided())p.doubleSided=!0;if(p.pbrMetallicRoughness={},!mt.eq(m.getBaseColorFactor(),[1,1,1,1]))p.pbrMetallicRoughness.baseColorFactor=m.getBaseColorFactor();if(!mt.eq(m.getEmissiveFactor(),[0,0,0]))p.emissiveFactor=m.getEmissiveFactor();if(m.getRoughnessFactor()!==1)p.pbrMetallicRoughness.roughnessFactor=m.getRoughnessFactor();if(m.getMetallicFactor()!==1)p.pbrMetallicRoughness.metallicFactor=m.getMetallicFactor();if(m.getBaseColorTexture()){let x=m.getBaseColorTexture(),_=m.getBaseColorTextureInfo();p.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(x,_)}if(m.getEmissiveTexture()){let x=m.getEmissiveTexture(),_=m.getEmissiveTextureInfo();p.emissiveTexture=a.createTextureInfoDef(x,_)}if(m.getNormalTexture()){let x=m.getNormalTexture(),_=m.getNormalTextureInfo(),y=a.createTextureInfoDef(x,_);if(m.getNormalScale()!==1)y.scale=m.getNormalScale();p.normalTexture=y}if(m.getOcclusionTexture()){let x=m.getOcclusionTexture(),_=m.getOcclusionTextureInfo(),y=a.createTextureInfoDef(x,_);if(m.getOcclusionStrength()!==1)y.strength=m.getOcclusionStrength();p.occlusionTexture=y}if(m.getMetallicRoughnessTexture()){let x=m.getMetallicRoughnessTexture(),_=m.getMetallicRoughnessTextureInfo();p.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(x,_)}return a.materialIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Mesh")).forEach((m)=>m.prewrite(a,"Mesh")),r.meshes=i.listMeshes().map((m,g)=>{let p=a.createPropertyDef(m),x=null;if(p.primitives=m.listPrimitives().map((_)=>{let y={attributes:{}};y.mode=_.getMode();let v=_.getMaterial();if(v)y.material=a.materialIndexMap.get(v);if(Object.keys(_.getExtras()).length)y.extras=_.getExtras();let E=_.getIndices();if(E)y.indices=a.accessorIndexMap.get(E);for(let w of _.listSemantics())y.attributes[w]=a.accessorIndexMap.get(_.getAttribute(w));for(let w of _.listTargets()){let T={};for(let A of w.listSemantics())T[A]=a.accessorIndexMap.get(w.getAttribute(A));y.targets=y.targets||[],y.targets.push(T)}if(_.listTargets().length&&!x)x=_.listTargets().map((w)=>w.getName());return y}),m.getWeights().length)p.weights=m.getWeights();if(x)p.extras=p.extras||{},p.extras.targetNames=x;return a.meshIndexMap.set(m,g),p}),r.cameras=i.listCameras().map((m,g)=>{let p=a.createPropertyDef(m);if(p.type=m.getType(),p.type===rf.Type.PERSPECTIVE){p.perspective={znear:m.getZNear(),zfar:m.getZFar(),yfov:m.getYFov()};let x=m.getAspectRatio();if(x!==null)p.perspective.aspectRatio=x}else p.orthographic={znear:m.getZNear(),zfar:m.getZFar(),xmag:m.getXMag(),ymag:m.getYMag()};return a.cameraIndexMap.set(m,g),p}),r.nodes=i.listNodes().map((m,g)=>{let p=a.createPropertyDef(m);if(!mt.eq(m.getTranslation(),[0,0,0]))p.translation=m.getTranslation();if(!mt.eq(m.getRotation(),[0,0,0,1]))p.rotation=m.getRotation();if(!mt.eq(m.getScale(),[1,1,1]))p.scale=m.getScale();if(m.getWeights().length)p.weights=m.getWeights();return a.nodeIndexMap.set(m,g),p}),r.skins=i.listSkins().map((m,g)=>{let p=a.createPropertyDef(m),x=m.getInverseBindMatrices();if(x)p.inverseBindMatrices=a.accessorIndexMap.get(x);let _=m.getSkeleton();if(_)p.skeleton=a.nodeIndexMap.get(_);return p.joints=m.listJoints().map((y)=>a.nodeIndexMap.get(y)),a.skinIndexMap.set(m,g),p}),i.listNodes().forEach((m,g)=>{let p=r.nodes[g],x=m.getMesh();if(x)p.mesh=a.meshIndexMap.get(x);let _=m.getCamera();if(_)p.camera=a.cameraIndexMap.get(_);let y=m.getSkin();if(y)p.skin=a.skinIndexMap.get(y);if(m.listChildren().length>0)p.children=m.listChildren().map((v)=>a.nodeIndexMap.get(v))}),r.animations=i.listAnimations().map((m,g)=>{let p=a.createPropertyDef(m),x=new Map;return p.samplers=m.listSamplers().map((_,y)=>{let v=a.createPropertyDef(_);return v.input=a.accessorIndexMap.get(_.getInput()),v.output=a.accessorIndexMap.get(_.getOutput()),v.interpolation=_.getInterpolation(),x.set(_,y),v}),p.channels=m.listChannels().map((_)=>{let y=a.createPropertyDef(_);return y.sampler=x.get(_.getSampler()),y.target={node:a.nodeIndexMap.get(_.getTargetNode()),path:_.getTargetPath()},y}),a.animationIndexMap.set(m,g),p}),r.scenes=i.listScenes().map((m,g)=>{let p=a.createPropertyDef(m);return p.nodes=m.listChildren().map((x)=>a.nodeIndexMap.get(x)),a.sceneIndexMap.set(m,g),p});let b=i.getDefaultScene();if(b)r.scene=i.listScenes().indexOf(b);return r.extensionsUsed=l.map((m)=>m.extensionName),r.extensionsRequired=u.map((m)=>m.extensionName),l.forEach((m)=>m.write(a)),TF(r),s}},AF=class{_logger=La.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let n=jw(t)?this._binaryToJSON(t):{json:JSON.parse(Ze.decodeText(t)),resources:{}};return await this._readResourcesExternal(n,this.dirname(e)),this._readResourcesInternal(n),n}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),pF.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(Ze.assertView(e));this._readResourcesInternal(t);let n=t.json;if(n.buffers&&n.buffers.some((i)=>wF(t,i)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(n.images&&n.images.some((i)=>SF(t,i)))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(Ze.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return EF.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:n}=await this.writeJSON(e,{format:"GLB"}),i=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),s=Ze.pad(Ze.encodeText(r),32),a=Ze.toView(new Uint32Array([s.byteLength,1313821514])),o=Ze.concat([a,s]);i[i.length-1]+=o.byteLength;let c=Object.values(n)[0];if(!c||!c.byteLength)return Ze.concat([Ze.toView(i),o]);let l=Ze.pad(c,0),u=Ze.toView(new Uint32Array([l.byteLength,5130562])),d=Ze.concat([u,l]);return i[i.length-1]+=d.byteLength,Ze.concat([Ze.toView(i),o,d])}async _readResourcesExternal(e,t){let n=e.json.images||[],i=e.json.buffers||[],r=[...n,...i].map(async(s)=>{let a=s.uri;if(!a||a.match(/data:/))return Promise.resolve();try{e.resources[a]=await this.readURI(this.resolve(t,a),"view"),this.lastReadBytes+=e.resources[a].byteLength}catch(o){if(!this._strictResources&&n.includes(s))this._logger.warn(`Failed to load image URI, "${a}". ${o}`),e.resources[a]=null;else throw o}});await Promise.all(r)}_readResourcesInternal(e){function t(n){if(!n.uri)return;if(n.uri in e.resources){Ze.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){let i=`__${qw()}.${ka.extension(n.uri)}`;e.resources[i]=Ze.createBufferFromDataURI(n.uri),n.uri=i}}(e.json.images||[]).forEach((n)=>{if(n.bufferView===void 0&&n.uri===void 0)throw Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:n}=e.json;if(e={json:{...e.json},resources:{...e.resources}},t)e.json.images=t.map((i)=>({...i}));if(n)e.json.buffers=n.map((i)=>({...i}));return e}_binaryToJSON(e){if(!jw(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw Error("Missing required GLB JSON chunk.");let n=20,i=t[0],r=Ze.decodeText(Ze.toView(e,n,i)),s=JSON.parse(r),a=n+i;if(e.byteLength<=a)return{json:s,resources:{}};let o=new Uint32Array(e.buffer,e.byteOffset+a,2);if(o[1]!==5130562)return{json:s,resources:{}};let c=o[0],l=Ze.toView(e,a+8,c);return{json:s,resources:{[Cs]:l}}}},eS;var qo=ut(()=>{Lw();Q=function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e}({}),H8=function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e}({}),Ai=function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e}({}),Gw=function(e){return e.GLTF="GLTF",e.GLB="GLB",e}({}),G8=class extends Float32Array{constructor(){super();throw Error("Unsupported typed array instantiation.")}},wl={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5131":typeof Float16Array<"u"?Float16Array:G8,"5126":Float32Array,"5130":Float64Array},Gi=class{static impls={"image/jpeg":new $8,"image/png":new K8};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){if(!this.impls[t])return null;return this.impls[t].getSize(e)}static getChannels(e,t){if(!this.impls[t])return null;return this.impls[t].getChannels(e)}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let n=0,i=4,r=this.getSize(e,t);if(!r)return null;while(r[0]>1||r[1]>1)n+=r[0]*r[1]*i,r[0]=Math.max(Math.floor(r[0]/2),1),r[1]=Math.max(Math.floor(r[1]/2),1);return n+=4,n}static mimeTypeToExtension(e){if(e==="image/jpeg")return"jpg";return e.split("/").pop()}static extensionToMimeType(e){if(e==="jpg")return"image/jpeg";if(!e)return"";return`image/${e}`}};Lg=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;(function(){var e=X8();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();Dg=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.substring(0,t+1)}static basename(e){return ka.basename(new URL(e,Fw).pathname)}static extension(e){return ka.extension(new URL(e,Fw).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let n=e.split("/"),i=t.split("/");n.pop();for(let r=0;r<i.length;r++){if(i[r]===".")continue;if(i[r]==="..")n.pop();else n.push(i[r])}return n.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};Z8=function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e}({}),La=class e{verbosity;static Verbosity=Z8;static DEFAULT_INSTANCE=new e(1);constructor(t){this.verbosity=t}debug(t){if(this.verbosity<=0)console.debug(t)}info(t){if(this.verbosity<=1)console.info(t)}warn(t){if(this.verbosity<=2)console.warn(t)}error(t){if(this.verbosity<=3)console.error(t)}};Bw=new Set,lF=new Set,Bg=class extends Dw{constructor(e,t=""){super(e);this[At].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){if(Array.isArray(t))t=t.slice();return super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,Ns)}copy(e,t=Ns){for(let n in this[At]){let i=this[At][n];if(i instanceof Rs){if(!this[Ms].has(n))i.dispose()}else if(i instanceof xn||i instanceof It)for(let r of i.values())r.dispose();else if(i instanceof dn)for(let r of i.values())r.dispose()}for(let n in e[At]){let i=this[At][n],r=e[At][n];if(r instanceof Rs)if(this[Ms].has(n))i.getChild().copy(t(r.getChild()),t);else this.setRef(n,t(r.getChild()),r.getAttributes());else if(r instanceof It||r instanceof xn)for(let s of r.values())this.addRef(n,t(s.getChild()),s.getAttributes());else if(r instanceof dn)for(let s of r.keys()){let a=r.get(s);this.setRefMap(n,s,t(a.getChild()),a.getAttributes())}else if(Oa(r))this[At][n]=JSON.parse(JSON.stringify(r));else if(Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r))this[At][n]=r.slice();else this[At][n]=r}return this}equals(e,t=lF){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let n in this[At]){if(t.has(n))continue;let i=this[At][n],r=e[At][n];if(i instanceof Rs||r instanceof Rs){if(!nF(i,r))return!1}else if(i instanceof It||r instanceof It||i instanceof xn||r instanceof xn){if(!iF(i,r))return!1}else if(i instanceof dn||r instanceof dn){if(!rF(i,r))return!1}else if(Oa(i)||Oa(r)){if(!Xw(i,r))return!1}else if(nf(i)||nf(r)){if(!Ww(i,r))return!1}else if(i!==r)return!1}return!0}detach(){return this.graph.disconnectParents(this,(e)=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},$n=class extends Bg{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new dn})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){if(t)t._validateParent(this);return this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},Oe=class e extends $n{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:e.Type.SCALAR,componentType:e.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case e.Type.SCALAR:return 1;case e.Type.VEC2:return 2;case e.Type.VEC3:return 3;case e.Type.VEC4:return 4;case e.Type.MAT2:return 4;case e.Type.MAT3:return 9;case e.Type.MAT4:return 16;default:throw Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case e.ComponentType.BYTE:case e.ComponentType.UNSIGNED_BYTE:return 1;case e.ComponentType.SHORT:case e.ComponentType.UNSIGNED_SHORT:return 2;case e.ComponentType.UNSIGNED_INT:case e.ComponentType.FLOAT:return 4;case e.ComponentType.FLOAT16:return 2;case e.ComponentType.FLOAT64:return 8;default:throw Error("Unexpected component type: "+t)}}getMinNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMin(t),n)for(let s=0;s<i;s++)t[s]=mt.decodeNormalizedInt(t[s],r);return t}getMin(t){let n=this.getArray(),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.min(t[a],o)}return t}getMaxNormalized(t){let n=this.getNormalized(),i=this.getElementSize(),r=this.getComponentType();if(this.getMax(t),n)for(let s=0;s<i;s++)t[s]=mt.decodeNormalizedInt(t[s],r);return t}getMax(t){let n=this.get("array"),i=this.getCount(),r=this.getElementSize();for(let s=0;s<r;s++)t[s]=-1/0;for(let s=0;s<i*r;s+=r)for(let a=0;a<r;a++){let o=n[s+a];if(Number.isFinite(o))t[a]=Math.max(t[a],o)}return t}getCount(){let t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return e.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){let n=this.getElementSize(),i=this.getComponentType(),r=this.getArray();if(this.getNormalized())return mt.decodeNormalizedInt(r[t*n],i);return r[t*n]}setScalar(t,n){let i=this.getElementSize(),r=this.getComponentType(),s=this.getArray();if(this.getNormalized())s[t*i]=mt.encodeNormalizedInt(n,r);else s[t*i]=n;return this}getElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)n[o]=mt.decodeNormalizedInt(a[t*r+o],s);else n[o]=a[t*r+o];return n}setElement(t,n){let i=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType(),a=this.getArray();for(let o=0;o<r;o++)if(i)a[t*r+o]=mt.encodeNormalizedInt(n[o],s);else a[t*r+o]=n[o];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?uF(t):e.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){let t=this.get("array");return t?t.byteLength:0}};Jw=class extends $n{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new It,samplers:new It})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},Fa=class extends $n{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},Sl=class e extends $n{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:e.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},Zw=class extends $n{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},rf=class e extends $n{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:e.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},nt=class extends Bg{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},wt=class e extends $n{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:e.WrapMode.REPEAT,wrapT:e.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}},{R:Zd,G:Yd,B:Qd,A:dF}=Ai,Da=class e extends $n{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:e.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new wt(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new wt(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new wt(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new wt(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new wt(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){let n=this.get("baseColorFactor").slice();return n[3]=t,this.set("baseColorFactor",n)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:Zd|Yd|Qd|dF,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:Zd|Yd|Qd,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:Zd|Yd|Qd})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:Zd})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:Yd|Qd})}},zg=class extends $n{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new It})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},sf=class extends $n{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new It})}copy(e,t=Ns){if(t===Ns)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return mt.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),n=this.get("rotation").slice(),i=this.get("scale").slice();return mt.decompose(e,t,n,i),this.set("translation",t).set("rotation",n).set("scale",i)}getWorldTranslation(){let e=[0,0,0];return mt.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return mt.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return mt.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e=[];for(let i=this;i!=null;i=i.getParentNode())e.push(i);let t,n=e.pop().getMatrix();while(t=e.pop())Q8(n,n,t.getMatrix());return n}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);for(let n of e.listParents())if(n.propertyType==="Scene")n.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(let t of this.listChildren())t.traverse(e);return this}},Zn=class e extends $n{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:e.Mode.TRIANGLES,material:null,indices:null,attributes:new dn,targets:new It})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,n){return this.setRefMap("attributes",t,n,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},Vg=class extends Bg{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},af=class extends $n{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new It})}copy(e,t=Ns){if(t===Ns)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}},Yw=class extends $n{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new It})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},Xo=class extends $n{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||Gi.extensionToMimeType(ka.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=Gi.extensionToMimeType(ka.extension(e));if(t)this.set("mimeType",t);return this}getImage(){return this.get("image")}setImage(e){return this.set("image",Ze.assertView(e))}getSize(){let e=this.get("image");if(!e)return null;return Gi.getSize(e,this.getMimeType())}},Ps=class extends $n{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Hw}`,version:"2.0"},defaultScene:null,accessors:new It,animations:new It,buffers:new It,cameras:new It,materials:new It,meshes:new It,nodes:new It,scenes:new It,skins:new It,textures:new It})}constructor(e){super(e);e.addEventListener("node:create",(t)=>{this._addChildOfRoot(t.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=Ns){if(t===Ns)throw Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(let n of e.listRefMapKeys("extensions")){let i=e.getExtension(n);this.setExtension(n,t(i))}return this}_addChildOfRoot(e){if(e instanceof af)this.addRef("scenes",e);else if(e instanceof sf)this.addRef("nodes",e);else if(e instanceof rf)this.addRef("cameras",e);else if(e instanceof Yw)this.addRef("skins",e);else if(e instanceof zg)this.addRef("meshes",e);else if(e instanceof Da)this.addRef("materials",e);else if(e instanceof Xo)this.addRef("textures",e);else if(e instanceof Jw)this.addRef("animations",e);else if(e instanceof Oe)this.addRef("accessors",e);else if(e instanceof Zw)this.addRef("buffers",e);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((e)=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},of=class e{_graph=new Og;_root=new Ps(this._graph);_logger=La.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return e._GRAPH_DOCUMENTS.get(t)||null}constructor(){e._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){let n=t.map((i)=>i.name);for(let i of t)await i(this,{stack:n});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some((n)=>n.extensionName===t)}createExtension(t){let n=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===n)||new t(this)}disposeExtension(t){let n=this.getRoot().listExtensionsUsed().find((i)=>i.extensionName===t);if(n)n.dispose()}createScene(t=""){return new af(this._graph,t)}createNode(t=""){return new sf(this._graph,t)}createCamera(t=""){return new rf(this._graph,t)}createSkin(t=""){return new Yw(this._graph,t)}createMesh(t=""){return new zg(this._graph,t)}createPrimitive(){return new Zn(this._graph)}createPrimitiveTarget(t=""){return new Vg(this._graph,t)}createMaterial(t=""){return new Da(this._graph,t)}createTexture(t=""){return new Xo(this._graph,t)}createAnimation(t=""){return new Jw(this._graph,t)}createAnimationChannel(t=""){return new Fa(this._graph,t)}createAnimationSampler(t=""){return new Sl(this._graph,t)}createAccessor(t="",n=null){if(!n)n=this.getRoot().listBuffers()[0];return new Oe(this._graph,t).setBuffer(n)}createBuffer(t=""){return new Zw(this._graph,t)}},zw={logger:La.DEFAULT_INSTANCE,extensions:[],dependencies:{}},hF=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);Qw=function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e}(Qw||{}),Is=class{_doc;jsonDoc;options;static BufferViewTarget=Qw;static BufferViewUsage=H8;static USAGE_TO_TARGET={["ARRAY_BUFFER"]:34962,["ELEMENT_ARRAY_BUFFER"]:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,n){this._doc=e,this.jsonDoc=t,this.options=n;let i=e.getRoot(),r=i.listBuffers().length,s=i.listTextures().length;this.bufferURIGenerator=new Vw(r>1,()=>n.basename||"buffer"),this.imageURIGenerator=new Vw(s>1,(a)=>bF(e,a)||n.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let n={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},i=JSON.stringify(n);if(!this.samplerDefIndexMap.has(i))this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(n);let r={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(i)},s=JSON.stringify(r);if(!this.textureDefIndexMap.has(s))this.textureDefIndexMap.set(s,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r);let a={index:this.textureDefIndexMap.get(s)};if(t.getTexCoord()!==0)a.texCoord=t.getTexCoord();if(Object.keys(t.getExtras()).length>0)a.extras=t.getExtras();return this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){let t={};if(e.getName())t.name=e.getName();if(Object.keys(e.getExtras()).length>0)t.extras=e.getExtras();return t}createAccessorDef(e){let t=this.createPropertyDef(e);if(t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some((n)=>n.getName()==="attributes"&&n.getAttributes().key==="POSITION"||n.getName()==="input"))t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround);if(e.getNormalized())t.normalized=e.getNormalized();return t}createImageData(e,t,n){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let i=Gi.mimeTypeToExtension(n.getMimeType());e.uri=this.imageURIGenerator.createURI(n,i),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,n){let i=this.jsonDoc.resources;if(!(e in i)){i[e]=t;return}if(t===i[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}let r=`Resource URI "${e}" already assigned to different data.`;if(!n){this.logger.warn(r);return}throw Error(r)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(let n of this._doc.getGraph().listParentEdges(e)){let{usage:i}=n.getAttributes();if(i)return i;if(n.getParent().propertyType!=="Root")this.logger.warn(`Missing attribute ".usage" on edge, "${n.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){let n=this._accessorUsageMap.get(e);if(n&&n!==t)throw Error(`Accessor with usage "${n}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}};({BufferViewUsage:ef}=Is),{UNSIGNED_INT:xF,UNSIGNED_SHORT:yF,UNSIGNED_BYTE:_F}=Oe.ComponentType,vF=new Set(["Accessor","Buffer","Material","Mesh"]);eS=class extends AF{_fetchConfig;constructor(e=Dg.DEFAULT_INIT){super();this._fetchConfig=e}async readURI(e,t){let n=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await n.arrayBuffer());case"text":return n.text()}}resolve(e,t){return Dg.resolve(e,t)}dirname(e){return Dg.dirname(e)}}});function MF(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class Jo{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),n=e+4294967296*t;return this._offset+=8,n}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let n=this._offset,i=0;while(this._dataView.getUint8(this._offset)!==t&&i<e)i++,this._offset++;if(i<e)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}function tS(e){return new TextDecoder().decode(e)}function cf(e){let t=new Uint8Array(e.buffer,e.byteOffset,Kn.length);if(t[0]!==Kn[0]||t[1]!==Kn[1]||t[2]!==Kn[2]||t[3]!==Kn[3]||t[4]!==Kn[4]||t[5]!==Kn[5]||t[6]!==Kn[6]||t[7]!==Kn[7]||t[8]!==Kn[8]||t[9]!==Kn[9]||t[10]!==Kn[10]||t[11]!==Kn[11])throw Error("Missing KTX 2.0 identifier.");let n=MF(),i=17*Uint32Array.BYTES_PER_ELEMENT,r=new Jo(e,Kn.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32(),n.levelCount=r._nextUint32(),n.supercompressionScheme=r._nextUint32();let s=r._nextUint32(),a=r._nextUint32(),o=r._nextUint32(),c=r._nextUint32(),l=r._nextUint64(),u=r._nextUint64(),d=Math.max(n.levelCount,1)*3*8,f=new Jo(e,Kn.length+i,d,!0);for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let h=new Jo(e,s,a,!0);h._skip(4);let b=h._nextUint16(),m=h._nextUint16(),g=h._nextUint16(),p=h._nextUint16(),x=h._nextUint8(),_=h._nextUint8(),y=h._nextUint8(),v=h._nextUint8(),E=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],w=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],A={vendorId:b,descriptorType:m,versionNumber:g,colorModel:x,colorPrimaries:_,transferFunction:y,flags:v,texelBlockDimension:E,bytesPlane:w,samples:[]},P=6,S=4,R=(p/4-P)/S;for(let ie=0;ie<R;ie++){let ce={bitOffset:h._nextUint16(),bitLength:h._nextUint8(),channelType:h._nextUint8(),samplePosition:[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(ce.channelType&64)ce.sampleLower=h._nextInt32(),ce.sampleUpper=h._nextInt32();else ce.sampleLower=h._nextUint32(),ce.sampleUpper=h._nextUint32();A.samples[ie]=ce}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(A);let k=new Jo(e,o,c,!0);while(k._offset<c){let ie=k._nextUint32(),ce=k._scan(ie),_e=tS(ce);if(n.keyValue[_e]=k._nextUint8Array(ie-ce.byteLength-1),_e.match(/^ktx/i)){let ke=tS(n.keyValue[_e]);n.keyValue[_e]=ke.substring(0,ke.lastIndexOf("\x00"))}let Re=ie%4?4-ie%4:0;k._skip(Re)}if(u<=0)return n;let C=new Jo(e,l,u,!0),U=C._nextUint16(),L=C._nextUint16(),O=C._nextUint32(),K=C._nextUint32(),B=C._nextUint32(),X=C._nextUint32(),q=[];for(let ie=0,ce=Math.max(n.levelCount,1);ie<ce;ie++)q.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let le=l+C._offset,de=le+O,Me=de+K,pe=Me+B,J=new Uint8Array(e.buffer,e.byteOffset+le,O),F=new Uint8Array(e.buffer,e.byteOffset+de,K),W=new Uint8Array(e.buffer,e.byteOffset+Me,B),ne=new Uint8Array(e.buffer,e.byteOffset+pe,X);return n.globalData={endpointCount:U,selectorCount:L,imageDescs:q,endpointsData:J,selectorsData:F,tablesData:W,extendedData:ne},n}var nS=0,iS=163,rS=166,jg=0,sS=123,aS=1000066000,k$,Kn;var oS=ut(()=>{k$=new Uint8Array([0]),Kn=[171,75,84,88,32,50,48,187,13,10,26,10]});function kF(e,t,n,i){let r=t.createFeatureID().setFeatureCount(i.featureCount);if(i.nullFeatureId!==void 0)r.setNullFeatureID(i.nullFeatureId);if(i.label!==void 0)r.setLabel(i.label);if(i.attribute!==void 0)r.setAttribute(i.attribute);let s=i.texture;if(s!==void 0){let a=DF(t,n,s);r.setTexture(a)}if(i.propertyTable!==void 0){let a=e.getRoot().getExtension(et).listPropertyTables();r.setPropertyTable(a[i.propertyTable])}return r}function DF(e,t,n){let i=e.createFeatureIDTexture(),{json:r}=t.jsonDoc;if(n.channels)i.setChannels(n.channels);if(n.index!==void 0){let s=r.textures[n.index].source;i.setTexture(t.textures[s]),t.setTextureInfo(i.getTextureInfo(),n)}return i}function LF(e,t,n){let i=e.getRoot(),r={featureCount:n.getFeatureCount()};if(n.getNullFeatureID()!=null)r.nullFeatureId=n.getNullFeatureID();if(n.getLabel())r.label=n.getLabel();if(n.getAttribute()!=null)r.attribute=n.getAttribute();if(n.getTexture()){let s=n.getTexture(),a=s.getTexture(),o=s.getTextureInfo();r.texture=t.createTextureInfoDef(a,o);let c=s.getChannels();if(!mt.eq(c,[0]))r.texture.channels=c}if(n.getPropertyTable()){let s=i.getExtension(et),a=n.getPropertyTable();r.propertyTable=s.listPropertyTables().indexOf(a)}return r}function BF(e){if(!e.extensions||!e.extensions.EXT_meshopt_compression)return!1;return!!e.extensions[Yn].fallback}function jF(e,t,n,i){let{filter:r,bits:s}=i,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(n!=="ATTRIBUTES")return a;if(r!=="NONE"){let o=e.getNormalized()?HF(e):new Float32Array(a.array);switch(r){case"EXPONENTIAL":a.byteStride=e.getElementSize()*4,a.componentType=VF,a.normalized=!1,a.array=t.encodeFilterExp(o,e.getCount(),a.byteStride,s);break;case"OCTAHEDRAL":a.byteStride=s>8?8:4,a.componentType=s>8?uS:zF,a.normalized=!0,o=e.getElementSize()===3?$F(o):o,a.array=t.encodeFilterOct(o,e.getCount(),a.byteStride,s);break;case"QUATERNION":a.byteStride=8,a.componentType=uS,a.normalized=!0,a.array=t.encodeFilterQuat(o,e.getCount(),a.byteStride,s);break;default:throw Error("Invalid filter.")}if(a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized())a.min=a.min.map((c)=>Kg(c,e.getComponentType())),a.max=a.max.map((c)=>Kg(c,e.getComponentType()));if(a.normalized)a.min=a.min.map((c)=>dS(c,a.componentType)),a.max=a.max.map((c)=>dS(c,a.componentType))}else if(a.byteStride%4)a.array=GF(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount();return a}function HF(e){let t=e.getComponentType(),n=e.getArray(),i=new Float32Array(n.length);for(let r=0;r<n.length;r++)i[r]=Kg(n[r],t);return i}function GF(e,t){let n=Ze.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,i=e.length/t,r=new e.constructor(i*n);for(let s=0;s*t<e.length;s++)for(let a=0;a<t;a++)r[s*n+a]=e[s*t+a];return r}function $F(e){let t=new Float32Array(e.length*4/3);for(let n=0,i=e.length/3;n<i;n++)t[n*4]=e[n*3],t[n*4+1]=e[n*3+1],t[n*4+2]=e[n*3+2];return t}function KF(e,t){if(t===Is.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return e.listParents().some((n)=>n instanceof Zn&&n.getMode()===Zn.Mode.TRIANGLES)?"TRIANGLES":"INDICES";return"ATTRIBUTES"}function WF(e,t){let n=t.getGraph().listParentEdges(e).filter((i)=>!(i.getParent()instanceof Ps));for(let i of n){let r=i.getName(),s=i.getAttributes().key||"",a=i.getParent().propertyType===Q.PRIMITIVE_TARGET;if(r==="indices")return{filter:"NONE"};if(r==="attributes"){if(s==="POSITION")return{filter:"NONE"};if(s==="TEXCOORD_0")return{filter:"NONE"};if(s.startsWith("JOINTS_"))return{filter:"NONE"};if(s.startsWith("WEIGHTS_"))return{filter:"NONE"};if(s==="NORMAL"||s==="TANGENT")return a?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(r==="output"){let o=MS(e);if(o==="rotation")return{filter:"QUATERNION",bits:16};if(o==="translation")return{filter:"EXPONENTIAL",bits:12};if(o==="scale")return{filter:"EXPONENTIAL",bits:12};return{filter:"NONE"}}if(r==="input")return{filter:"NONE"};if(r==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function MS(e){for(let t of e.listParents()){if(!(t instanceof Sl))continue;for(let n of t.listParents()){if(!(n instanceof Fa))continue;return n.getTargetPath()}}return null}function l2(e,t,n){let i=e.createStructuralMetadata();if(n.schema!==void 0){let o=u2(e,n.schema);i.setSchema(o)}else if(n.schemaUri){let o=n.schemaUri;i.setSchemaUri(o)}let r=n.propertyTextures||[];for(let o of r){let c=m2(e,t,o);i.addPropertyTexture(c)}let s=n.propertyTables||[];for(let o of s){let c=b2(e,t,o);i.addPropertyTable(c)}let a=n.propertyAttributes||[];for(let o of a){let c=y2(e,o);i.addPropertyAttribute(c)}return i}function u2(e,t){let n=e.createSchema().setId(t.id);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.version!==void 0)n.setVersion(t.version);let i=t.classes||{};for(let s of Object.keys(i)){let a=i[s];n.setClass(s,d2(e,a))}let r=t.enums||{};for(let s of Object.keys(r))n.setEnum(s,h2(e,r[s]));return n}function d2(e,t){let n=e.createClass();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);let i=t.properties||{};for(let r of Object.keys(i)){let s=f2(e,i[r]);n.setProperty(r,s)}return n}function f2(e,t){let n=e.createClassProperty().setType(t.type);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.componentType!==void 0)n.setComponentType(t.componentType);if(t.enumType!==void 0)n.setEnumType(t.enumType);if(t.array!==void 0)n.setArray(t.array);if(t.count!==void 0)n.setCount(t.count);if(t.normalized!==void 0)n.setNormalized(t.normalized);if(t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);if(t.required!==void 0)n.setRequired(t.required);if(t.noData!==void 0)n.setNoData(t.noData);if(t.default!==void 0)n.setDefault(t.default);return n}function h2(e,t){let n=e.createEnum();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.valueType!==void 0)n.setValueType(t.valueType);let i=t.values||{};for(let r of i)n.addEnumValue(p2(e,r));return n}function p2(e,t){let n=e.createEnumValue();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.value!==void 0)n.setValue(t.value);return n}function m2(e,t,n){let i=e.createPropertyTexture();if(i.setClass(n.class),n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=g2(e,t,r[s]);i.setProperty(s,a)}return i}function g2(e,t,n){let i=e.createPropertyTextureProperty(),r=t.jsonDoc.json.textures||[];if(n.channels)i.setChannels(n.channels);let s=r[n.index].source;if(s!==void 0){let a=t.textures[s];i.setTexture(a);let o=i.getTextureInfo();if(o)t.setTextureInfo(o,n)}if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function b2(e,t,n){let i=e.createPropertyTable().setClass(n.class).setCount(n.count);if(n.name!==void 0)i.setName(n.name);let r=n.properties||{};for(let s of Object.keys(r)){let a=x2(e,t,r[s]);i.setProperty(s,a)}return i}function x2(e,t,n){let i=e.createPropertyTableProperty(),r=Hg(t,n.values);if(i.setValues(r),n.arrayOffsets!==void 0){let s=Hg(t,n.arrayOffsets);i.setArrayOffsets(s)}if(n.stringOffsets!==void 0){let s=Hg(t,n.stringOffsets);i.setStringOffsets(s)}if(n.arrayOffsetType!==void 0)i.setArrayOffsetType(n.arrayOffsetType);if(n.stringOffsetType!==void 0)i.setStringOffsetType(n.stringOffsetType);if(n.offset!==void 0)i.setOffset(n.offset);if(n.scale!==void 0)i.setScale(n.scale);if(n.max!==void 0)i.setMax(n.max);if(n.min!==void 0)i.setMin(n.min);return i}function y2(e,t){let n=e.createPropertyAttribute();if(n.setClass(t.class),t.name!==void 0)n.setName(t.name);let i=t.properties||{};for(let r of Object.keys(i)){let s=_2(e,i[r]);n.setProperty(r,s)}return n}function _2(e,t){let n=e.createPropertyAttributeProperty();if(n.setAttribute(t.attribute),t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);return n}function v2(e,t){let n={},i=t.getSchema();if(i)n.schema=E2(i);let r=t.getSchemaUri();if(r)n.schemaUri=r;let s=t.listPropertyTables();if(s.length>0){let c=[];for(let l of s){let u=M2(e,l);c.push(u)}n.propertyTables=c}let a=t.listPropertyTextures();if(a.length>0){let c=[];for(let l of a){let u=N2(e,l);c.push(u)}n.propertyTextures=c}let o=t.listPropertyAttributes();if(o.length>0){let c=[];for(let l of o){let u=I2(l);c.push(u)}n.propertyAttributes=c}return n}function E2(e){let t={id:e.getId()},n=e.listClassKeys();if(n.length>0){t.classes={};for(let r of n){let s=T2(e.getClass(r));t.classes[r]=s}}let i=e.listEnumKeys();if(i.length>0){t.enums={};for(let r of i){let s=w2(e.getEnum(r));t.enums[r]=s}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getVersion())t.version=e.getVersion();return t}function T2(e){let t={},n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=e.getProperty(i);t.properties[i]=A2(r)}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();return t}function A2(e){let t={type:e.getType()};if(e.getArray())t.array=e.getArray();if(e.getNormalized())t.normalized=e.getNormalized();if(e.getRequired())t.required=e.getRequired();if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getComponentType()!=null)t.componentType=e.getComponentType();if(e.getEnumType()!=null)t.enumType=e.getEnumType();if(e.getCount()!=null)t.count=e.getCount();if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();if(e.getNoData()!=null)t.noData=e.getNoData();if(e.getDefault()!=null)t.default=e.getDefault();return t}function w2(e){let t={values:e.listValues().map(S2)};if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getValueType()!=="UINT16")t.valueType=e.getValueType();return t}function S2(e){let t={name:e.getName(),value:e.getValue()};if(e.getDescription())t.description=e.getDescription();return t}function M2(e,t){let n={class:t.getClass(),count:t.getCount()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=R2(e,t.getProperty(r));n.properties[r]=s}}return n}function R2(e,t){let n=t.getValues(),i={values:e.otherBufferViewsIndexMap.get(n)};if(t.getArrayOffsets()){let r=t.getArrayOffsets();i.arrayOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getStringOffsets()){let r=t.getStringOffsets();i.stringOffsets=e.otherBufferViewsIndexMap.get(r)}if(t.getArrayOffsetType()!=null)i.arrayOffsetType=t.getArrayOffsetType();if(t.getStringOffsetType()!=null)i.stringOffsetType=t.getStringOffsetType();if(t.getOffset()!=null)i.offset=t.getOffset();if(t.getScale()!=null)i.scale=t.getScale();if(t.getMax()!=null)i.max=t.getMax();if(t.getMin()!=null)i.min=t.getMin();return i}function I2(e){let t={class:e.getClass()};if(e.getName())t.name=e.getName();let n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let i of n){let r=C2(e.getProperty(i));t.properties[i]=r}}return t}function C2(e){let t={attribute:e.getAttribute()};if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();return t}function N2(e,t){let n={class:t.getClass()};if(t.getName())n.name=t.getName();let i=t.listPropertyKeys();if(i.length>0){n.properties={};for(let r of i){let s=P2(e,t.getProperty(r));n.properties[r]=s}}return n}function P2(e,t){let n=t.getTexture(),i=t.getTextureInfo(),r=t.getChannels(),s=e.createTextureInfoDef(n,i);if(!mt.eq(r,[0]))s.channels=r;if(t.getOffset()!=null)s.offset=t.getOffset();if(t.getScale()!=null)s.scale=t.getScale();if(t.getMax()!=null)s.max=t.getMax();if(t.getMin()!=null)s.min=t.getMin();return s}function Hg(e,t){let n=e.jsonDoc,i=n.json.buffers||[],r=(n.json.bufferViews||[])[t],s=i[r.buffer],a=s.uri?n.resources[s.uri]:n.resources[Cs],o=r.byteOffset||0,c=r.byteLength;return a.slice(o,o+c)}function O2(e,t){let n=e.getRoot().listBuffers()[0],i=t.otherBufferViews.get(n);if(!i)i=[],t.otherBufferViews.set(n,i);return i}function hS(e,t){if(e.byteLength<4+t)return null;let n=e.getUint32(t);if(e.byteLength<n+t||n<8)return null;return{type:Ze.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+n}}function U2(e,t){let n=new yn.DecoderBuffer;try{if(n.Init(t,t.length),e.GetEncodedGeometryType(n)!==yn.TRIANGULAR_MESH)throw Error(`[${tn}] Unknown geometry type.`);let i=new yn.Mesh;if(!e.DecodeBufferToMesh(n,i).ok()||i.ptr===0)throw Error(`[${tn}] Decoding failure.`);return i}finally{yn.destroy(n)}}function B2(e,t){let n=t.num_faces()*3,i,r;if(t.num_points()<=65534){let s=n*Uint16Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt16Array(t,s,i),r=new Uint16Array(yn.HEAPU16.buffer,i,n).slice()}else{let s=n*Uint32Array.BYTES_PER_ELEMENT;i=yn._malloc(s),e.GetTrianglesUInt32Array(t,s,i),r=new Uint32Array(yn.HEAPU32.buffer,i,n).slice()}return yn._free(i),r}function z2(e,t,n,i){let r=NS[i.componentType],s=CS[i.componentType],a=n.num_components(),o=t.num_points()*a,c=o*s.BYTES_PER_ELEMENT,l=yn._malloc(c);e.GetAttributeDataArrayForAllPoints(t,n,r,c,l);let u=new s(yn.HEAPF32.buffer,l,o).slice();return yn._free(l),u}function V2(e){yn=e,CS={[Oe.ComponentType.FLOAT]:Float32Array,[Oe.ComponentType.UNSIGNED_INT]:Uint32Array,[Oe.ComponentType.UNSIGNED_SHORT]:Uint16Array,[Oe.ComponentType.UNSIGNED_BYTE]:Uint8Array,[Oe.ComponentType.SHORT]:Int16Array,[Oe.ComponentType.BYTE]:Int8Array},NS={[Oe.ComponentType.FLOAT]:yn.DT_FLOAT32,[Oe.ComponentType.UNSIGNED_INT]:yn.DT_UINT32,[Oe.ComponentType.UNSIGNED_SHORT]:yn.DT_UINT16,[Oe.ComponentType.UNSIGNED_BYTE]:yn.DT_UINT8,[Oe.ComponentType.SHORT]:yn.DT_INT16,[Oe.ComponentType.BYTE]:yn.DT_INT8}}function H2(e){wi=e}function G2(e,t=gS){let n={...gS,...t};n.quantizationBits={...PS,...t.quantizationBits};let i=new wi.MeshBuilder,r=new wi.Mesh,s=new wi.ExpertEncoder(r),a={},o=new wi.DracoInt8Array,c=e.listTargets().length>0,l=!1;for(let m of e.listSemantics()){let g=e.getAttribute(m);if(g.getSparse()){l=!0;continue}let p=$2(m),x=K2(i,g.getComponentType(),r,wi[p],g.getCount(),g.getElementSize(),g.getArray());if(x===-1)throw Error(`Error compressing "${m}" attribute.`);if(a[m]=x,n.quantizationVolume==="mesh"||m!=="POSITION")s.SetAttributeQuantization(x,n.quantizationBits[p]);else if(typeof n.quantizationVolume==="object"){let{quantizationVolume:_}=n,y=Math.max(_.max[0]-_.min[0],_.max[1]-_.min[1],_.max[2]-_.min[2]);s.SetAttributeExplicitQuantization(x,n.quantizationBits[p],g.getElementSize(),_.min,y)}else throw Error("Invalid quantization volume state.")}let u=e.getIndices();if(!u)throw new Wg("Primitive must have indices.");if(i.AddFacesToMesh(r,u.getCount()/3,u.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),n.method===0||c||l)s.SetEncodingMethod(wi.MESH_SEQUENTIAL_ENCODING);else s.SetEncodingMethod(wi.MESH_EDGEBREAKER_ENCODING);let d=s.EncodeToDracoBuffer(!(c||l),o);if(d<=0)throw new Wg("Error applying Draco compression.");let f=new Uint8Array(d);for(let m=0;m<d;++m)f[m]=o.GetValue(m);let h=s.GetNumberOfEncodedPoints(),b=s.GetNumberOfEncodedFaces()*3;return wi.destroy(o),wi.destroy(r),wi.destroy(i),wi.destroy(s),{numVertices:h,numIndices:b,data:f,attributeIDs:a}}function $2(e){if(e==="POSITION")return"POSITION";else if(e==="NORMAL")return"NORMAL";else if(e.startsWith("COLOR_"))return"COLOR";else if(e.startsWith("TEXCOORD_"))return"TEX_COORD";return"GENERIC"}function K2(e,t,n,i,r,s,a){switch(t){case Oe.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(n,i,r,s,a);case Oe.ComponentType.BYTE:return e.AddInt8Attribute(n,i,r,s,a);case Oe.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(n,i,r,s,a);case Oe.ComponentType.SHORT:return e.AddInt16Attribute(n,i,r,s,a);case Oe.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(n,i,r,s,a);case Oe.ComponentType.FLOAT:return e.AddFloatAttribute(n,i,r,s,a);default:throw Error(`Unexpected component type, "${t}".`)}}function W2(e){let t=e.getLogger(),n=new Set,i=new Set,r=0,s=0;for(let d of e.getRoot().listMeshes())for(let f of d.listPrimitives())if(!f.getIndices())i.add(f),r++;else if(f.getMode()!==Zn.Mode.TRIANGLES)i.add(f),s++;else n.add(f);if(r>0)t.warn(`[${tn}] Skipping Draco compression of ${r} non-indexed primitives.`);if(s>0)t.warn(`[${tn}] Skipping Draco compression of ${s} non-TRIANGLES primitives.`);let a=e.getRoot().listAccessors(),o=new Map;for(let d=0;d<a.length;d++)o.set(a[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(n)){let f=bS(d,o);if(l.has(f)){u.set(d,f);continue}if(c.has(d.getIndices())){let h=d.getIndices(),b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}for(let h of d.listAttributes())if(c.has(h)){let b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}f=bS(d,o),l.add(f),u.set(d,f),c.set(d.getIndices(),f);for(let h of d.listAttributes())c.set(h,f)}for(let d of Array.from(c.keys())){let f=new Set(d.listParents().map((h)=>h.propertyType));if(f.size!==2||!f.has(Q.PRIMITIVE)||!f.has(Q.ROOT))throw Error(`[${tn}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(n)){let f=u.get(d),h=d.getIndices();if(c.get(h)!==f||d.listAttributes().some((b)=>c.get(b)!==f))throw Error(`[${tn}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(i)){let f=d.getIndices();if(c.has(f)||d.listAttributes().some((h)=>c.has(h)))throw Error(`[${tn}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function bS(e,t){let n=[],i=e.getIndices();n.push(t.get(i));for(let r of e.listAttributes())n.push(t.get(r));return n.sort().join("|")}function jU(e){return e.vkFormat>jg&&e.vkFormat<=sS}function SS(e){let t=e.vkFormat===aS&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===jg||t}function Gg(e){return JSON.parse(JSON.stringify(e))}var Os="EXT_mesh_gpu_instancing",Gr="EXT_mesh_features",Yn="EXT_meshopt_compression",et="EXT_structural_metadata",lf="EXT_texture_webp",uf="EXT_texture_avif",RF="KHR_accessor_float16",IF="KHR_accessor_float64",tn="KHR_draco_mesh_compression",Hr="KHR_lights_punctual",ks="KHR_materials_anisotropy",Ds="KHR_materials_clearcoat",Ls="KHR_materials_diffuse_transmission",Fs="KHR_materials_dispersion",Us="KHR_materials_emissive_strength",Bs="KHR_materials_ior",zs="KHR_materials_iridescence",Vs="KHR_materials_pbrSpecularGlossiness",js="KHR_materials_sheen",Hs="KHR_materials_specular",Gs="KHR_materials_transmission",Zo="KHR_materials_unlit",$s="KHR_materials_volume",hi="KHR_materials_variants",cS="KHR_mesh_primitive_restart",lS="KHR_mesh_quantization",Ks="KHR_node_visibility",df="KHR_texture_basisu",Ws="KHR_texture_transform",$i="KHR_xmp_json_ld",CF,NF,PF,Ml,OF,$g="INSTANCE_ATTRIBUTE",FF,ff,UF,zF,uS,VF,dS,Kg,fS,Rl,XF,qF,JF,ZF,YF,QF,e2,t2,n2,i2,r2,s2,a2,o2,c2,k2=class{match(e){return e.length>=12&&Ze.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=hS(t,0);if(!n)return null;let i=n.end;while(n=hS(t,i))if(n.type==="meta")i=n.start+4;else if(n.type==="iprp"||n.type==="ipco")i=n.start;else if(n.type==="ispe")return[t.getUint32(n.start+4),t.getUint32(n.start+8)];else if(n.type==="mdat")break;else i=n.end;return null}getChannels(e){return 4}},RS,D2=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){let t=Ze.decodeText(e.slice(0,4)),n=Ze.decodeText(e.slice(8,12));if(t!=="RIFF"||n!=="WEBP")return null;let i=new DataView(e.buffer,e.byteOffset),r=12;while(r<i.byteLength){let s=Ze.decodeText(new Uint8Array([i.getUint8(r),i.getUint8(r+1),i.getUint8(r+2),i.getUint8(r+3)])),a=i.getUint32(r+4,!0);if(s==="VP8 ")return[i.getInt16(r+14,!0)&16383,i.getInt16(r+16,!0)&16383];else if(s==="VP8L"){let o=i.getUint8(r+9),c=i.getUint8(r+10),l=i.getUint8(r+11),u=i.getUint8(r+12);return[1+((c&63)<<8|o),1+((u&15)<<10|l<<2|(c&192)>>6)]}r+=8+a+a%2}return null}getChannels(e){return 4}},IS,pS,L2,mS,F2,yn,CS,NS,wi,j2,PS,gS,Wg,OS,xS,X2,q2,J2,Z2,Y2,Q2,yS,_S,eU,tU,nU,iU,rU,sU,aU,oU,cU,lU,uU,dU,fU,hU,kS,pU,mU,gU,bU,vS,ES,TS,AS,xU,DS,yU,_U,vU,EU,TU,AU,wU,SU,MU,RU,IU,LS,CU,NU,PU,OU,FS,kU,DU,wS,LU,FU,UU,BU,US,Il,zU,VU,HU=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){let t=cf(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){let t=cf(e),n=t.dataFormatDescriptor[0];if(jU(t))return n.samples.length;if(SS(t))switch(n.colorModel){case iS:return n.samples.length===2&&(n.samples[1].channelType&15)===15?4:3;case rS:return(n.samples[0].channelType&15)===3?4:3;default:throw Error(`Unexpected KTX2 colorModel, "${n.colorModel}".`)}throw Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){let t=cf(e),n=0;if(SS(t)){let i=this.getChannels(e)>3;for(let r=0;r<t.levels.length;r++){let s=t.levels[r];if(s.uncompressedByteLength)n+=s.uncompressedByteLength;else{let a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,r))),o=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,r))),c=i?16:8;n+=a/4*(o/4)*c}}}else for(let i of t.levels)if(t.supercompressionScheme===nS)n+=i.levelData.byteLength;else n+=i.uncompressedByteLength;return n}},Xg,GU,$U,KU,WU,XU,qU,BS;var hf=ut(()=>{qo();oS();CF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},NF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){let e=new wt(this.graph,"textureInfo");return e.setMinFilter(wt.MagFilter.NEAREST),e.setMagFilter(wt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},PF=class extends nt{static EXTENSION_NAME=Gr;init(){this.extensionName=Gr,this.propertyType="Features",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new It([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}},Ml=Gr,OF=class extends _t{extensionName=Gr;static EXTENSION_NAME=Gr;createFeatures(){return new PF(this.document.getGraph())}createFeatureID(){return new CF(this.document.getGraph())}createFeatureIDTexture(){return new NF(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,n)=>{(t.primitives||[]).forEach((i,r)=>{this._readPrimitive(e,n,i,r)})}),this}_readPrimitive(e,t,n,i){if(!n.extensions||!n.extensions[Ml])return;let r=this.createFeatures(),s=n.extensions[Ml];for(let a of s.featureIds){let o=kF(this.document,this,e,a);r.addFeatureID(o)}e.meshes[t].listPrimitives()[i].setExtension(Ml,r)}write(e){let t=e.jsonDoc.json.meshes;if(!t)return this;for(let n of this.document.getRoot().listMeshes()){let i=t[e.meshIndexMap.get(n)];n.listPrimitives().forEach((r,s)=>{let a=i.primitives[s];this._writePrimitive(e,r,a)})}return this}_writePrimitive(e,t,n){let i=t.getExtension(Ml);if(!i)return;let r={featureIds:[]};i.listFeatureIDs().forEach((s)=>{r.featureIds.push(LF(this.document,e,s))}),n.extensions=n.extensions||{},n.extensions[Ml]=r}};FF=class extends nt{static EXTENSION_NAME=Os;init(){this.extensionName=Os,this.propertyType="InstancedMesh",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:$g})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},ff=class extends _t{static EXTENSION_NAME=Os;extensionName=Os;prewriteTypes=[Q.ACCESSOR];createInstancedMesh(){return new FF(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;let i=t.extensions[Os],r=this.createInstancedMesh();for(let s in i.attributes)r.setAttribute(s,e.accessors[i.attributes[s]]);e.nodes[n].setExtension(Os,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add($g);for(let t of this.properties)for(let n of t.listAttributes())e.addAccessorToUsageGroup(n,$g);return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listNodes().forEach((n)=>{let i=n.getExtension(Os);if(i){let r=e.nodeIndexMap.get(n),s=t.json.nodes[r],a={attributes:{}};i.listSemantics().forEach((o)=>{let c=i.getAttribute(o);a.attributes[o]=e.accessorIndexMap.get(c)}),s.extensions=s.extensions||{},s.extensions[Os]=a}}),this}},UF=function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e}({});({BYTE:zF,SHORT:uS,FLOAT:VF}=Oe.ComponentType),{encodeNormalizedInt:dS,decodeNormalizedInt:Kg}=mt;fS={method:"quantize"},Rl=class extends _t{extensionName=Yn;prereadTypes=[Q.BUFFER,Q.PRIMITIVE];prewriteTypes=[Q.BUFFER,Q.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=Yn;static EncoderMethod=UF;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=fS;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){if(e==="meshopt.decoder")this._decoder=t;if(e==="meshopt.encoder")this._encoder=t;return this}setEncoderOptions(e){return this._encoderOptions={...fS,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${Yn}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${Yn}]: Missing WASM support.`)}if(t===Q.BUFFER)this._prereadBuffers(e);else if(t===Q.PRIMITIVE)this._prereadPrimitives(e);return this}_prereadBuffers(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n,i)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let r=n.extensions[Yn],s=r.byteOffset||0,a=r.byteLength||0,{count:o,byteStride:c}=r,l=new Uint8Array(o*c),u=t.json.buffers[r.buffer],d=u.uri?t.resources[u.uri]:t.resources[Cs],f=Ze.toView(d,s,a);this._decoder.decodeGltfBuffer(l,o,c,f,r.mode,r.filter),e.bufferViews[i]=l})}_prereadPrimitives(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let i=n.extensions[Yn],r=e.buffers[i.buffer],s=e.buffers[n.buffer],a=t.json.buffers[n.buffer];if(BF(a))this._decoderFallbackBufferMap.set(s,r)})}read(e){if(!this.isRequired())return this;for(let[t,n]of this._decoderFallbackBufferMap){for(let i of t.listParents())if(i instanceof Oe)i.swap(t,n);t.dispose()}return this}prewrite(e,t){if(t===Q.ACCESSOR)this._prewriteAccessors(e);else if(t===Q.BUFFER)this._prewriteBuffers(e);return this}_prewriteAccessors(e){let t=e.jsonDoc.json,n=this._encoder,i=this._encoderOptions,r=this.document.getGraph(),s=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(s),o=1,c=new Map,l=(u)=>{for(let d of r.listParents(u)){if(d.propertyType===Q.ROOT)continue;let f=c.get(u);if(f===void 0)c.set(u,f=o++);return f}return-1};this._encoderFallbackBuffer=s,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(MS(u)==="weights")continue;if(u.getSparse())continue;let d=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(d)?l(u):null,h=KF(u,d),b=i.method==="filter"?WF(u,this.document):{filter:"NONE"},m=jF(u,n,h,b),{array:g,byteStride:p}=m,x=u.getBuffer();if(!x)throw Error(`${Yn}: Missing buffer for accessor.`);let _=this.document.getRoot().listBuffers().indexOf(x),y=[d,f,h,b.filter,p,_].join(":"),v=this._encoderBufferViews[y],E=this._encoderBufferViewData[y],w=this._encoderBufferViewAccessors[y];if(!v||!E)w=this._encoderBufferViewAccessors[y]=[],E=this._encoderBufferViewData[y]=[],v=this._encoderBufferViews[y]={buffer:a,target:Is.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===Is.BufferViewUsage.ARRAY_BUFFER?p:void 0,extensions:{[Yn]:{buffer:_,byteOffset:0,byteLength:0,mode:h,filter:b.filter!=="NONE"?b.filter:void 0,byteStride:p,count:0}}};let T=e.createAccessorDef(u);if(T.componentType=m.componentType,T.normalized=m.normalized,T.byteOffset=v.byteLength,T.min&&m.min)T.min=m.min;if(T.max&&m.max)T.max=m.max;e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(T),w.push(T),E.push(new Uint8Array(g.buffer,g.byteOffset,g.byteLength)),v.byteLength+=g.byteLength,v.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){let t=this._encoder;for(let n in this._encoderBufferViews){let i=this._encoderBufferViews[n],r=this._encoderBufferViewData[n],s=this.document.getRoot().listBuffers()[i.extensions[Yn].buffer],a=e.otherBufferViews.get(s)||[],{count:o,byteStride:c,mode:l}=i.extensions[Yn],u=Ze.concat(r),d=t.encodeGltfBuffer(u,o,c,l),f=Ze.pad(d);i.extensions[Yn].byteLength=d.byteLength,r.length=0,r.push(f),a.push(f),e.otherBufferViews.set(s,a)}}write(e){let t=0;for(let s in this._encoderBufferViews){let a=this._encoderBufferViews[s],o=this._encoderBufferViewData[s][0],c=e.otherBufferViewsIndexMap.get(o),l=this._encoderBufferViewAccessors[s];for(let h of l)h.bufferView=c;let u=e.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,a),u.byteOffset=t;let f=u.extensions[Yn];f.byteOffset=d,t+=Ze.padNumber(a.byteLength)}let n=this._encoderFallbackBuffer,i=e.bufferIndexMap.get(n),r=e.jsonDoc.json.buffers[i];return r.byteLength=t,r.extensions={[Yn]:{fallback:!0}},n.dispose(),this}},XF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="StructuralMetadata",this.parentTypes=[Q.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new xn,propertyTextures:new xn,propertyAttributes:new xn})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},qF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new dn,enums:new dn})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},JF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new dn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},ZF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},YF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new xn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},QF=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},e2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},t2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},n2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},i2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){let e=new wt(this.graph,"textureInfo");return e.setMinFilter(wt.MagFilter.NEAREST),e.setMagFilter(wt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},r2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},s2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},a2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="NodeStructuralMetadata",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},o2=class extends nt{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new xn,propertyAttributes:new xn})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},c2=class extends _t{extensionName=et;static EXTENSION_NAME=et;prewriteTypes=[Q.BUFFER];prereadTypes=[Q.SCENE];createStructuralMetadata(){return new XF(this.document.getGraph())}createSchema(){return new qF(this.document.getGraph())}createClass(){return new JF(this.document.getGraph())}createClassProperty(){return new ZF(this.document.getGraph())}createEnum(){return new YF(this.document.getGraph())}createEnumValue(){return new QF(this.document.getGraph())}createPropertyTable(){return new e2(this.document.getGraph())}createPropertyTableProperty(){return new t2(this.document.getGraph())}createPropertyTexture(){return new n2(this.document.getGraph())}createPropertyTextureProperty(){return new i2(this.document.getGraph())}createPropertyAttribute(){return new r2(this.document.getGraph())}createPropertyAttributeProperty(){return new s2(this.document.getGraph())}createNodeStructuralMetadata(){return new a2(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new o2(this.document.getGraph())}read(e){return this}preread(e){let t=this.document.getRoot(),{json:n}=e.jsonDoc,i=n.extensions[et],r=l2(this,e,i);return t.setExtension(et,r),(n.meshes||[]).forEach((s,a)=>{let o=e.meshes[a].listPrimitives();(s.primitives||[]).forEach((c,l)=>{let u=o[l];this._readPrimitive(r,u,c)})}),(n.nodes||[]).forEach((s,a)=>{this._readNode(e.nodes[a],s)}),this}_readPrimitive(e,t,n){if(!n.extensions||!n.extensions.EXT_structural_metadata)return;let i=this.createMeshPrimitiveStructuralMetadata(),r=n.extensions[et],s=e.listPropertyTextures(),a=r.propertyTextures||[];for(let l of a){let u=s[l];i.addPropertyTexture(u)}let o=e.listPropertyAttributes(),c=r.propertyAttributes||[];for(let l of c){let u=o[l];i.addPropertyAttribute(u)}t.setExtension(et,i)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let n=t.extensions[et],i=this.createNodeStructuralMetadata().setClass(n.class).setProperties(n.properties);e.setExtension(et,i)}write(e){let t=this.document.getRoot(),n=t.getExtension(et);if(!n)return this;let i=e.jsonDoc.json,r=v2(e,n);i.extensions=i.extensions||{},i.extensions[et]=r;let s=t.listMeshes(),a=i.meshes;if(a)for(let l of s){let u=a[e.meshIndexMap.get(l)];l.listPrimitives().forEach((d,f)=>{let h=u.primitives[f];this._writePrimitive(n,d,h)})}let o=t.listNodes(),c=i.nodes;if(c)for(let l of o){let u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,n){let i=t.getExtension(et);if(!i)return;let r=e.listPropertyTextures(),s=e.listPropertyAttributes(),a,o,c=i.listPropertyTextures();if(c.length>0){a=[];for(let d of c){let f=r.indexOf(d);if(f>=0)a.push(f);else throw Error(`${et}: Invalid property texture in mesh primitive`)}}let l=i.listPropertyAttributes();if(l.length>0){o=[];for(let d of l){let f=s.indexOf(d);if(f>=0)o.push(f);else throw Error(`${et}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:a,propertyAttributes:o};n.extensions=n.extensions||{},n.extensions[et]=u}_writeNode(e,t){let n=e.getExtension("EXT_structural_metadata");if(!n)return;t.extensions=t.extensions||{},t.extensions[et]={class:n.getClass(),properties:n.getProperties()}}prewrite(e,t){if(t===Q.BUFFER)this._prewriteBuffers(e);return this}_prewriteBuffers(e){let t=this.document,n=t.getRoot().getExtension(et);e.jsonDoc.json.bufferViews||=[];for(let i of n.listPropertyTables())for(let r of i.listPropertyValues()){let s=O2(t,e);s.push(r.getValues());let a=r.getArrayOffsets();if(a)s.push(a);let o=r.getStringOffsets();if(o)s.push(o)}}};RS=class extends _t{extensionName=uf;prereadTypes=[Q.TEXTURE];static EXTENSION_NAME=uf;static register(){Gi.registerFormat("image/avif",new k2)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_avif)t.source=t.extensions[uf].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/avif"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[uf]={source:r.source},delete r.source})}}),this}};IS=class extends _t{extensionName=lf;prereadTypes=[Q.TEXTURE];static EXTENSION_NAME=lf;static register(){Gi.registerFormat("image/webp",new D2)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_webp)t.source=t.extensions[lf].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/webp"){let i=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[lf]={source:r.source},delete r.source})}}),this}},pS=RF,L2=class extends _t{extensionName=pS;static EXTENSION_NAME=pS;read(e){return this}write(e){return this}},mS=IF,F2=class extends _t{extensionName=mS;static EXTENSION_NAME=mS;read(e){return this}write(e){return this}};j2=function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e}({}),PS={["POSITION"]:14,["NORMAL"]:10,["COLOR"]:8,["TEX_COORD"]:12,["GENERIC"]:12},gS={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:PS,quantizationVolume:"mesh"};Wg=class extends Error{},OS=class extends _t{extensionName=tn;prereadTypes=[Q.PRIMITIVE];prewriteTypes=[Q.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=tn;static EncoderMethod=j2;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){if(e==="draco3d.decoder")this._decoderModule=t,V2(this._decoderModule);if(e==="draco3d.encoder")this._encoderModule=t,H2(this._encoderModule);return this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.decoder".`);let t=this.document.getLogger(),n=e.jsonDoc,i=new Map;try{let r=n.json.meshes||[];for(let s of r)for(let a of s.primitives){if(!a.extensions||!a.extensions.KHR_draco_mesh_compression)continue;let o=a.extensions[tn],[c,l]=i.get(o.bufferView)||[];if(!l||!c){let u=n.json.bufferViews[o.bufferView],d=n.json.buffers[u.buffer],f=d.uri?n.resources[d.uri]:n.resources[Cs],h=u.byteOffset||0,b=u.byteLength,m=Ze.toView(f,h,b);c=new this._decoderModule.Decoder,l=U2(c,m),i.set(o.bufferView,[c,l]),t.debug(`[${tn}] Decompressed ${m.byteLength} bytes.`)}for(let u in o.attributes){let d=e.jsonDoc.json.accessors[a.attributes[u]],f=c.GetAttributeByUniqueId(l,o.attributes[u]),h=z2(c,l,f,d);e.accessors[a.attributes[u]].setArray(h)}if(a.indices!==void 0)e.accessors[a.indices].setArray(B2(c,l))}}finally{for(let[r,s]of Array.from(i.values()))this._decoderModule.destroy(r),this._decoderModule.destroy(s)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.encoder".`);let n=this.document.getLogger();n.debug(`[${tn}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let i=W2(this.document),r=new Map,s="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)n.warn(`[${tn}]: quantizationVolume=scene requires exactly 1 scene.`);else s=Ug(this.document.getRoot().listScenes().pop());for(let a of Array.from(i.keys())){let o=i.get(a);if(!o)throw Error("Unexpected primitive.");if(r.has(o)){r.set(o,r.get(o));continue}let c=a.getIndices(),l=e.jsonDoc.json.accessors,u;try{u=G2(a,{...this._encoderOptions,quantizationVolume:s})}catch(h){if(h instanceof Wg){n.warn(`[${tn}]: ${h.message} Skipping primitive compression.`);continue}throw h}r.set(o,u);let d=e.createAccessorDef(c);if(d.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&Oe.getComponentSize(d.componentType)<=2)d.componentType=Oe.ComponentType.UNSIGNED_INT;else if(u.numVertices>254&&Oe.getComponentSize(d.componentType)<=1)d.componentType=Oe.ComponentType.UNSIGNED_SHORT;for(let h of a.listSemantics()){let b=a.getAttribute(h);if(u.attributeIDs[h]===void 0)continue;let m=e.createAccessorDef(b);m.count=u.numVertices,e.accessorIndexMap.set(b,l.length),l.push(m)}let f=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!e.otherBufferViews.has(f))e.otherBufferViews.set(f,[]);e.otherBufferViews.get(f).push(u.data)}return n.debug(`[${tn}] Compressed ${i.size} primitives.`),e.extensionData[tn]={primitiveHashMap:i,primitiveEncodingMap:r},this}write(e){let t=e.extensionData[tn];for(let n of this.document.getRoot().listMeshes()){let i=e.jsonDoc.json.meshes[e.meshIndexMap.get(n)];for(let r=0;r<n.listPrimitives().length;r++){let s=n.listPrimitives()[r],a=i.primitives[r],o=t.primitiveHashMap.get(s);if(!o)continue;let c=t.primitiveEncodingMap.get(o);if(!c)continue;a.extensions=a.extensions||{},a.extensions[tn]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){let n=e.jsonDoc.json;n.extensionsUsed=(n.extensionsUsed||[]).filter((i)=>i!==tn),n.extensionsRequired=(n.extensionsRequired||[]).filter((i)=>i!==tn)}return this}};xS=class e extends nt{static EXTENSION_NAME=Hr;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Hr,this.propertyType="Light",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:e.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},X2=class extends _t{extensionName=Hr;static EXTENSION_NAME=Hr;createLight(e=""){return new xS(this.document.getGraph(),e)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;let n=(t.json.extensions.KHR_lights_punctual.lights||[]).map((i)=>{let r=this.createLight().setName(i.name||"").setType(i.type);if(i.extras)r.setExtras(i.extras);if(i.color!==void 0)r.setColor(i.color);if(i.intensity!==void 0)r.setIntensity(i.intensity);if(i.range!==void 0)r.setRange(i.range);if(i.spot?.innerConeAngle!==void 0)r.setInnerConeAngle(i.spot.innerConeAngle);if(i.spot?.outerConeAngle!==void 0)r.setOuterConeAngle(i.spot.outerConeAngle);return r});return t.json.nodes.forEach((i,r)=>{if(!i.extensions||!i.extensions.KHR_lights_punctual)return;let s=i.extensions[Hr];e.nodes[r].setExtension(Hr,n[s.light])}),this}write(e){let t=e.jsonDoc;if(this.properties.size===0)return this;let n=[],i=new Map;for(let r of this.properties){let s=r,a=e.createPropertyDef(r);if(a.type=s.getType(),!mt.eq(s.getColor(),[1,1,1]))a.color=s.getColor();if(s.getIntensity()!==1)a.intensity=s.getIntensity();if(s.getRange()!=null)a.range=s.getRange();if(s.getName())a.name=s.getName();if(s.getType()===xS.Type.SPOT)a.spot={innerConeAngle:s.getInnerConeAngle(),outerConeAngle:s.getOuterConeAngle()};n.push(a),i.set(s,n.length-1)}return this.document.getRoot().listNodes().forEach((r)=>{let s=r.getExtension(Hr);if(s){let a=e.nodeIndexMap.get(r),o=t.json.nodes[a];o.extensions=o.extensions||{},o.extensions[Hr]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[Hr]={lights:n},this}},{R:q2,G:J2,B:Z2}=Ai,Y2=class extends nt{static EXTENSION_NAME=ks;init(){this.extensionName=ks,this.propertyType="Anisotropy",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new wt(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:q2|J2|Z2})}},Q2=class extends _t{static EXTENSION_NAME=ks;extensionName=ks;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createAnisotropy(){return new Y2(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_anisotropy){let a=this.createAnisotropy();e.materials[s].setExtension(ks,a);let o=r.extensions[ks];if(o.extras)a.setExtras(o.extras);if(o.anisotropyStrength!==void 0)a.setAnisotropyStrength(o.anisotropyStrength);if(o.anisotropyRotation!==void 0)a.setAnisotropyRotation(o.anisotropyRotation);if(o.anisotropyTexture!==void 0){let c=o.anisotropyTexture,l=e.textures[i[c.index].source];a.setAnisotropyTexture(l),e.setTextureInfo(a.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(ks);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[ks]=a,i.getAnisotropyStrength()>0)a.anisotropyStrength=i.getAnisotropyStrength();if(i.getAnisotropyRotation()!==0)a.anisotropyRotation=i.getAnisotropyRotation();if(i.getAnisotropyTexture()){let o=i.getAnisotropyTexture(),c=i.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:yS,G:_S,B:eU}=Ai,tU=class extends nt{static EXTENSION_NAME=Ds;init(){this.extensionName=Ds,this.propertyType="Clearcoat",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new wt(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new wt(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new wt(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:yS})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:_S})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:yS|_S|eU})}},nU=class extends _t{static EXTENSION_NAME=Ds;extensionName=Ds;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createClearcoat(){return new tU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_clearcoat){let a=this.createClearcoat();e.materials[s].setExtension(Ds,a);let o=r.extensions[Ds];if(o.extras)a.setExtras(o.extras);if(o.clearcoatFactor!==void 0)a.setClearcoatFactor(o.clearcoatFactor);if(o.clearcoatRoughnessFactor!==void 0)a.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor);if(o.clearcoatTexture!==void 0){let c=o.clearcoatTexture,l=e.textures[i[c.index].source];a.setClearcoatTexture(l),e.setTextureInfo(a.getClearcoatTextureInfo(),c)}if(o.clearcoatRoughnessTexture!==void 0){let c=o.clearcoatRoughnessTexture,l=e.textures[i[c.index].source];a.setClearcoatRoughnessTexture(l),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),c)}if(o.clearcoatNormalTexture!==void 0){let c=o.clearcoatNormalTexture,l=e.textures[i[c.index].source];if(a.setClearcoatNormalTexture(l),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),c),c.scale!==void 0)a.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Ds);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ds]=a,a.clearcoatFactor=i.getClearcoatFactor(),a.clearcoatRoughnessFactor=i.getClearcoatRoughnessFactor(),i.getClearcoatTexture()){let o=i.getClearcoatTexture(),c=i.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatRoughnessTexture()){let o=i.getClearcoatRoughnessTexture(),c=i.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(o,c)}if(i.getClearcoatNormalTexture()){let o=i.getClearcoatNormalTexture(),c=i.getClearcoatNormalTextureInfo();if(a.clearcoatNormalTexture=e.createTextureInfoDef(o,c),i.getClearcoatNormalScale()!==1)a.clearcoatNormalTexture.scale=i.getClearcoatNormalScale()}}}),this}},{R:iU,G:rU,B:sU,A:aU}=Ai,oU=class extends nt{static EXTENSION_NAME=Ls;init(){this.extensionName=Ls,this.propertyType="DiffuseTransmission",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new wt(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new wt(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:aU})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:iU|rU|sU})}},cU=class extends _t{extensionName=Ls;static EXTENSION_NAME=Ls;createDiffuseTransmission(){return new oU(this.document.getGraph())}read(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_diffuse_transmission){let a=this.createDiffuseTransmission();e.materials[s].setExtension(Ls,a);let o=r.extensions[Ls];if(o.extras)a.setExtras(o.extras);if(o.diffuseTransmissionFactor!==void 0)a.setDiffuseTransmissionFactor(o.diffuseTransmissionFactor);if(o.diffuseTransmissionColorFactor!==void 0)a.setDiffuseTransmissionColorFactor(o.diffuseTransmissionColorFactor);if(o.diffuseTransmissionTexture!==void 0){let c=o.diffuseTransmissionTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionTexture(l),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),c)}if(o.diffuseTransmissionColorTexture!==void 0){let c=o.diffuseTransmissionColorTexture,l=e.textures[i[c.index].source];a.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listMaterials()){let i=n.getExtension(Ls);if(!i)continue;let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Ls]=a,a.diffuseTransmissionFactor=i.getDiffuseTransmissionFactor(),a.diffuseTransmissionColorFactor=i.getDiffuseTransmissionColorFactor(),i.getDiffuseTransmissionTexture()){let o=i.getDiffuseTransmissionTexture(),c=i.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(o,c)}if(i.getDiffuseTransmissionColorTexture()){let o=i.getDiffuseTransmissionColorTexture(),c=i.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(o,c)}}return this}},lU=class extends nt{static EXTENSION_NAME=Fs;init(){this.extensionName=Fs,this.propertyType="Dispersion",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},uU=class extends _t{static EXTENSION_NAME=Fs;extensionName=Fs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createDispersion(){return new lU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){let i=this.createDispersion();e.materials[n].setExtension(Fs,i);let r=t.extensions[Fs];if(r.extras)i.setExtras(r.extras);if(r.dispersion!==void 0)i.setDispersion(r.dispersion)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Fs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Fs]=a,a.dispersion=i.getDispersion()}}),this}},dU=class extends nt{static EXTENSION_NAME=Us;init(){this.extensionName=Us,this.propertyType="EmissiveStrength",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},fU=class extends _t{static EXTENSION_NAME=Us;extensionName=Us;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createEmissiveStrength(){return new dU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){let i=this.createEmissiveStrength();e.materials[n].setExtension(Us,i);let r=t.extensions[Us];if(r.extras)i.setExtras(r.extras);if(r.emissiveStrength!==void 0)i.setEmissiveStrength(r.emissiveStrength)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Us);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Us]=a,a.emissiveStrength=i.getEmissiveStrength()}}),this}},hU=class extends nt{static EXTENSION_NAME=Bs;init(){this.extensionName=Bs,this.propertyType="IOR",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},kS=class extends _t{static EXTENSION_NAME=Bs;extensionName=Bs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createIOR(){return new hU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_ior){let i=this.createIOR();e.materials[n].setExtension(Bs,i);let r=t.extensions[Bs];if(r.extras)i.setExtras(r.extras);if(r.ior!==void 0)i.setIOR(r.ior)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Bs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);s.extensions=s.extensions||{},s.extensions[Bs]=a,a.ior=i.getIOR()}}),this}},{R:pU,G:mU}=Ai,gU=class extends nt{static EXTENSION_NAME=zs;init(){this.extensionName=zs,this.propertyType="Iridescence",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new wt(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new wt(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:pU})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:mU})}},bU=class extends _t{static EXTENSION_NAME=zs;extensionName=zs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createIridescence(){return new gU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_iridescence){let a=this.createIridescence();e.materials[s].setExtension(zs,a);let o=r.extensions[zs];if(o.extras)a.setExtras(o.extras);if(o.iridescenceFactor!==void 0)a.setIridescenceFactor(o.iridescenceFactor);if(o.iridescenceIor!==void 0)a.setIridescenceIOR(o.iridescenceIor);if(o.iridescenceThicknessMinimum!==void 0)a.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum);if(o.iridescenceThicknessMaximum!==void 0)a.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum);if(o.iridescenceTexture!==void 0){let c=o.iridescenceTexture,l=e.textures[i[c.index].source];a.setIridescenceTexture(l),e.setTextureInfo(a.getIridescenceTextureInfo(),c)}if(o.iridescenceThicknessTexture!==void 0){let c=o.iridescenceThicknessTexture,l=e.textures[i[c.index].source];a.setIridescenceThicknessTexture(l),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(zs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[zs]=a,i.getIridescenceFactor()>0)a.iridescenceFactor=i.getIridescenceFactor();if(i.getIridescenceIOR()!==1.3)a.iridescenceIor=i.getIridescenceIOR();if(i.getIridescenceThicknessMinimum()!==100)a.iridescenceThicknessMinimum=i.getIridescenceThicknessMinimum();if(i.getIridescenceThicknessMaximum()!==400)a.iridescenceThicknessMaximum=i.getIridescenceThicknessMaximum();if(i.getIridescenceTexture()){let o=i.getIridescenceTexture(),c=i.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(o,c)}if(i.getIridescenceThicknessTexture()){let o=i.getIridescenceThicknessTexture(),c=i.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:vS,G:ES,B:TS,A:AS}=Ai,xU=class extends nt{static EXTENSION_NAME=Vs;init(){this.extensionName=Vs,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new wt(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new wt(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:vS|ES|TS|AS,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:vS|ES|TS|AS})}},DS=class extends _t{static EXTENSION_NAME=Vs;extensionName=Vs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createPBRSpecularGlossiness(){return new xU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_pbrSpecularGlossiness){let a=this.createPBRSpecularGlossiness();e.materials[s].setExtension(Vs,a);let o=r.extensions[Vs];if(o.extras)a.setExtras(o.extras);if(o.diffuseFactor!==void 0)a.setDiffuseFactor(o.diffuseFactor);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.glossinessFactor!==void 0)a.setGlossinessFactor(o.glossinessFactor);if(o.diffuseTexture!==void 0){let c=o.diffuseTexture,l=e.textures[i[c.index].source];a.setDiffuseTexture(l),e.setTextureInfo(a.getDiffuseTextureInfo(),c)}if(o.specularGlossinessTexture!==void 0){let c=o.specularGlossinessTexture,l=e.textures[i[c.index].source];a.setSpecularGlossinessTexture(l),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Vs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Vs]=a,a.diffuseFactor=i.getDiffuseFactor(),a.specularFactor=i.getSpecularFactor(),a.glossinessFactor=i.getGlossinessFactor(),i.getDiffuseTexture()){let o=i.getDiffuseTexture(),c=i.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularGlossinessTexture()){let o=i.getSpecularGlossinessTexture(),c=i.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:yU,G:_U,B:vU,A:EU}=Ai,TU=class extends nt{static EXTENSION_NAME=js;init(){this.extensionName=js,this.propertyType="Sheen",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new wt(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new wt(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:yU|_U|vU,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:EU})}},AU=class extends _t{static EXTENSION_NAME=js;extensionName=js;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createSheen(){return new TU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_sheen){let a=this.createSheen();e.materials[s].setExtension(js,a);let o=r.extensions[js];if(o.extras)a.setExtras(o.extras);if(o.sheenColorFactor!==void 0)a.setSheenColorFactor(o.sheenColorFactor);if(o.sheenRoughnessFactor!==void 0)a.setSheenRoughnessFactor(o.sheenRoughnessFactor);if(o.sheenColorTexture!==void 0){let c=o.sheenColorTexture,l=e.textures[i[c.index].source];a.setSheenColorTexture(l),e.setTextureInfo(a.getSheenColorTextureInfo(),c)}if(o.sheenRoughnessTexture!==void 0){let c=o.sheenRoughnessTexture,l=e.textures[i[c.index].source];a.setSheenRoughnessTexture(l),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(js);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[js]=a,a.sheenColorFactor=i.getSheenColorFactor(),a.sheenRoughnessFactor=i.getSheenRoughnessFactor(),i.getSheenColorTexture()){let o=i.getSheenColorTexture(),c=i.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(o,c)}if(i.getSheenRoughnessTexture()){let o=i.getSheenRoughnessTexture(),c=i.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:wU,G:SU,B:MU,A:RU}=Ai,IU=class extends nt{static EXTENSION_NAME=Hs;init(){this.extensionName=Hs,this.propertyType="Specular",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new wt(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new wt(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:RU})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:wU|SU|MU,isColor:!0})}},LS=class extends _t{static EXTENSION_NAME=Hs;extensionName=Hs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createSpecular(){return new IU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_specular){let a=this.createSpecular();e.materials[s].setExtension(Hs,a);let o=r.extensions[Hs];if(o.extras)a.setExtras(o.extras);if(o.specularFactor!==void 0)a.setSpecularFactor(o.specularFactor);if(o.specularColorFactor!==void 0)a.setSpecularColorFactor(o.specularColorFactor);if(o.specularTexture!==void 0){let c=o.specularTexture,l=e.textures[i[c.index].source];a.setSpecularTexture(l),e.setTextureInfo(a.getSpecularTextureInfo(),c)}if(o.specularColorTexture!==void 0){let c=o.specularColorTexture,l=e.textures[i[c.index].source];a.setSpecularColorTexture(l),e.setTextureInfo(a.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Hs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Hs]=a,i.getSpecularFactor()!==1)a.specularFactor=i.getSpecularFactor();if(!mt.eq(i.getSpecularColorFactor(),[1,1,1]))a.specularColorFactor=i.getSpecularColorFactor();if(i.getSpecularTexture()){let o=i.getSpecularTexture(),c=i.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(o,c)}if(i.getSpecularColorTexture()){let o=i.getSpecularColorTexture(),c=i.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:CU}=Ai,NU=class extends nt{static EXTENSION_NAME=Gs;init(){this.extensionName=Gs,this.propertyType="Transmission",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new wt(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:CU})}},PU=class extends _t{static EXTENSION_NAME=Gs;extensionName=Gs;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createTransmission(){return new NU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_transmission){let a=this.createTransmission();e.materials[s].setExtension(Gs,a);let o=r.extensions[Gs];if(o.extras)a.setExtras(o.extras);if(o.transmissionFactor!==void 0)a.setTransmissionFactor(o.transmissionFactor);if(o.transmissionTexture!==void 0){let c=o.transmissionTexture,l=e.textures[i[c.index].source];a.setTransmissionTexture(l),e.setTextureInfo(a.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension(Gs);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[Gs]=a,a.transmissionFactor=i.getTransmissionFactor(),i.getTransmissionTexture()){let o=i.getTransmissionTexture(),c=i.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(o,c)}}}),this}},OU=class extends nt{static EXTENSION_NAME=Zo;init(){this.extensionName=Zo,this.propertyType="Unlit",this.parentTypes=[Q.MATERIAL]}},FS=class extends _t{static EXTENSION_NAME=Zo;extensionName=Zo;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createUnlit(){return new OU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_unlit)e.materials[n].setExtension(Zo,this.createUnlit())}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{if(n.getExtension("KHR_materials_unlit")){let i=e.materialIndexMap.get(n),r=t.json.materials[i];r.extensions=r.extensions||{},r.extensions[Zo]={}}}),this}},kU=class extends nt{static EXTENSION_NAME=hi;init(){this.extensionName=hi,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new It})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},DU=class extends nt{static EXTENSION_NAME=hi;init(){this.extensionName=hi,this.propertyType="MappingList",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new It})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},wS=class extends nt{static EXTENSION_NAME=hi;init(){this.extensionName=hi,this.propertyType="Variant",this.parentTypes=["MappingList"]}},LU=class extends _t{extensionName=hi;static EXTENSION_NAME=hi;createMappingList(){return new DU(this.document.getGraph())}createVariant(e=""){return new wS(this.document.getGraph(),e)}createMapping(){return new kU(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((e)=>e instanceof wS)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;let n=(t.json.extensions.KHR_materials_variants.variants||[]).map((i)=>this.createVariant().setName(i.name||""));return(t.json.meshes||[]).forEach((i,r)=>{let s=e.meshes[r];(i.primitives||[]).forEach((a,o)=>{if(!a.extensions||!a.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=a.extensions[hi];for(let u of l.mappings){let d=this.createMapping();if(u.material!==void 0)d.setMaterial(e.materials[u.material]);for(let f of u.variants||[])d.addVariant(n[f]);c.addMapping(d)}s.listPrimitives()[o].setExtension(hi,c)})}),this}write(e){let t=e.jsonDoc,n=this.listVariants();if(!n.length)return this;let i=[],r=new Map;for(let s of n)r.set(s,i.length),i.push(e.createPropertyDef(s));for(let s of this.document.getRoot().listMeshes()){let a=e.meshIndexMap.get(s);s.listPrimitives().forEach((o,c)=>{let l=o.getExtension(hi);if(!l)return;let u=e.jsonDoc.json.meshes[a].primitives[c],d=l.listMappings().map((f)=>{let h=e.createPropertyDef(f),b=f.getMaterial();if(b)h.material=e.materialIndexMap.get(b);return h.variants=f.listVariants().map((m)=>r.get(m)),h});u.extensions=u.extensions||{},u.extensions[hi]={mappings:d}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[hi]={variants:i},this}},{G:FU}=Ai,UU=class extends nt{static EXTENSION_NAME=$s;init(){this.extensionName=$s,this.propertyType="Volume",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new wt(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:FU})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},BU=class extends _t{static EXTENSION_NAME=$s;extensionName=$s;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createVolume(){return new UU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],i=t.json.textures||[];return n.forEach((r,s)=>{if(r.extensions&&r.extensions.KHR_materials_volume){let a=this.createVolume();e.materials[s].setExtension($s,a);let o=r.extensions[$s];if(o.extras)a.setExtras(o.extras);if(o.thicknessFactor!==void 0)a.setThicknessFactor(o.thicknessFactor);if(o.attenuationDistance!==void 0)a.setAttenuationDistance(o.attenuationDistance);if(o.attenuationColor!==void 0)a.setAttenuationColor(o.attenuationColor);if(o.thicknessTexture!==void 0){let c=o.thicknessTexture,l=e.textures[i[c.index].source];a.setThicknessTexture(l),e.setTextureInfo(a.getThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let i=n.getExtension($s);if(i){let r=e.materialIndexMap.get(n),s=t.json.materials[r],a=e.createPropertyDef(i);if(s.extensions=s.extensions||{},s.extensions[$s]=a,i.getThicknessFactor()>0)a.thicknessFactor=i.getThicknessFactor();if(Number.isFinite(i.getAttenuationDistance()))a.attenuationDistance=i.getAttenuationDistance();if(!mt.eq(i.getAttenuationColor(),[1,1,1]))a.attenuationColor=i.getAttenuationColor();if(i.getThicknessTexture()){let o=i.getThicknessTexture(),c=i.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},US=class extends _t{extensionName=cS;static EXTENSION_NAME=cS;read(e){return this}write(e){return this}},Il=class extends _t{extensionName=lS;static EXTENSION_NAME=lS;read(e){return this}write(e){return this}},zU=class extends nt{static EXTENSION_NAME=Ks;init(){this.extensionName=Ks,this.propertyType="Visibility",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},VU=class extends _t{static EXTENSION_NAME=Ks;extensionName=Ks;createVisibility(){return new zU(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_node_visibility){let i=this.createVisibility();e.nodes[n].setExtension(Ks,i);let r=t.extensions[Ks];if(r.visible!==void 0)i.setVisible(r.visible)}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listNodes()){let i=n.getExtension(Ks);if(!i)continue;let r=e.nodeIndexMap.get(n),s=t.json.nodes[r];s.extensions=s.extensions||{},s.extensions[Ks]={visible:i.getVisible()}}return this}};Xg=class extends _t{static EXTENSION_NAME=df;extensionName=df;prereadTypes=[Q.TEXTURE];static register(){Gi.registerFormat("image/ktx2",new HU)}preread(e){if(e.jsonDoc.json.textures)e.jsonDoc.json.textures.forEach((t)=>{if(t.extensions&&t.extensions.KHR_texture_basisu)t.source=t.extensions[df].source});return this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/ktx2"){let i=e.imageIndexMap.get(n);t.json.textures.forEach((r)=>{if(r.source===i)r.extensions=r.extensions||{},r.extensions[df]={source:r.source},delete r.source})}}),this}},GU=class extends nt{static EXTENSION_NAME=Ws;init(){this.extensionName=Ws,this.propertyType="Transform",this.parentTypes=[Q.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},$U=class extends _t{extensionName=Ws;static EXTENSION_NAME=Ws;createTransform(){return new GU(this.document.getGraph())}read(e){for(let[t,n]of Array.from(e.textureInfos.entries())){if(!n.extensions||!n.extensions.KHR_texture_transform)continue;let i=this.createTransform(),r=n.extensions[Ws];if(r.offset!==void 0)i.setOffset(r.offset);if(r.rotation!==void 0)i.setRotation(r.rotation);if(r.scale!==void 0)i.setScale(r.scale);if(r.texCoord!==void 0)i.setTexCoord(r.texCoord);t.setExtension(Ws,i)}return this}write(e){let t=Array.from(e.textureInfoDefMap.entries());for(let[n,i]of t){let r=n.getExtension(Ws);if(!r)continue;i.extensions=i.extensions||{};let s={},a=mt.eq;if(!a(r.getOffset(),[0,0]))s.offset=r.getOffset();if(r.getRotation()!==0)s.rotation=r.getRotation();if(!a(r.getScale(),[1,1]))s.scale=r.getScale();if(r.getTexCoord()!=null)s.texCoord=r.getTexCoord();i.extensions[Ws]=s}return this}},KU=[Q.ROOT,Q.SCENE,Q.NODE,Q.MESH,Q.MATERIAL,Q.TEXTURE,Q.ANIMATION],WU=class extends nt{static EXTENSION_NAME=$i;init(){this.extensionName=$i,this.propertyType="Packet",this.parentTypes=KU}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){let t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);let n={...this.get("properties")};if(t)n[e]=t;else delete n[e];return this.set("properties",n)}toJSONLD(){return{"@context":Gg(this.get("context")),...Gg(this.get("properties"))}}fromJSONLD(e){e=Gg(e);let t=e["@context"];if(t)this.set("context",t);return delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw Error(`${$i}: Missing context for term, "${e}".`)}};XU=class extends _t{extensionName=$i;static EXTENSION_NAME=$i;createPacket(){return new WU(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){let t=e.jsonDoc.json.extensions?.[$i];if(!t||!t.packets)return this;let n=e.jsonDoc.json,i=this.document.getRoot(),r=t.packets.map((o)=>this.createPacket().fromJSONLD(o)),s=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[i],i.listScenes(),i.listNodes(),i.listMeshes(),i.listMaterials(),i.listTextures(),i.listAnimations()];for(let o=0;o<s.length;o++){let c=s[o]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[$i];a[o][l].setExtension($i,r[d.packet])}}}return this}write(e){let{json:t}=e.jsonDoc,n=[];for(let i of this.properties){n.push(i.toJSONLD());for(let r of i.listParents()){let s;switch(r.propertyType){case Q.ROOT:s=t.asset;break;case Q.SCENE:s=t.scenes[e.sceneIndexMap.get(r)];break;case Q.NODE:s=t.nodes[e.nodeIndexMap.get(r)];break;case Q.MESH:s=t.meshes[e.meshIndexMap.get(r)];break;case Q.MATERIAL:s=t.materials[e.materialIndexMap.get(r)];break;case Q.TEXTURE:s=t.images[e.imageIndexMap.get(r)];break;case Q.ANIMATION:s=t.animations[e.animationIndexMap.get(r)];break;default:s=null,this.document.getLogger().warn(`[${$i}]: Unsupported parent property, "${r.propertyType}"`)}if(!s)continue;s.extensions=s.extensions||{},s.extensions[$i]={packet:n.length-1}}}if(n.length>0)t.extensions=t.extensions||{},t.extensions[$i]={packets:n};return this}},qU=[L2,F2,OS,X2,Q2,nU,cU,uU,fU,kS,bU,DS,LS,AU,PU,FS,LU,BU,US,Il,VU,Xg,$U,XU],BS=[ff,OF,Rl,c2,RS,IS,...qU]});var VS=Jr(function(nK,zS){function JU(e){var t=Array(e);for(var n=0;n<e;++n)t[n]=n;return t}zS.exports=JU});var GS=Jr(function(iK,HS){/*!
+ `},r=new Ea(5,5,5),i=new Mr({name:"CubemapFromEquirect",uniforms:Os(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ln,blending:fi});i.uniforms.tEquirect.value=t;let a=new Gt(r,i),s=t.minFilter;if(t.minFilter===hi)t.minFilter=An;return new sg(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(i)}};Wk={[Yp]:"LINEAR_TONE_MAPPING",[Qp]:"REINHARD_TONE_MAPPING",[em]:"CINEON_TONE_MAPPING",[al]:"ACES_FILMIC_TONE_MAPPING",[nm]:"AGX_TONE_MAPPING",[rm]:"NEUTRAL_TONE_MAPPING",[tm]:"CUSTOM_TONE_MAPPING"};BT=new en,vg=new Ps(1,1),jT=new Dd,VT=new qm,GT=new Gd,vT=[],ET=[],AT=new Float32Array(16),TT=new Float32Array(9),wT=new Float32Array(4);yg=/(\w+)(\])?(\[|\.)?/g;RT=new nt;jL={[Yp]:"Linear",[Qp]:"Reinhard",[em]:"Cineon",[al]:"ACESFilmic",[nm]:"AgX",[rm]:"Neutral",[tm]:"Custom"};tf=new V;WL=/^[ \t]*#include +<([\w\d./]+)>/gm;XL=new Map;JL=/#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;YL={[rl]:"SHADOWMAP_TYPE_PCF",[Co]:"SHADOWMAP_TYPE_VSM"};eD={[Po]:"ENVMAP_TYPE_CUBE",[Ms]:"ENVMAP_TYPE_CUBE",[sl]:"ENVMAP_TYPE_CUBE_UV"};nD={[Ms]:"ENVMAP_MODE_REFRACTION"};iD={[jA]:"ENVMAP_BLENDING_MULTIPLY",[VA]:"ENVMAP_BLENDING_MIX",[GA]:"ENVMAP_BLENDING_ADD"};ED=[new V(1,0,0),new V(-1,0,0),new V(0,1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1)],AD=[new V(0,-1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1),new V(0,-1,0),new V(0,-1,0)],FT=new Ze,wl=new V,_g=new V;JT=class JT extends Gr{constructor(e,t){super();let n=this,r=null,i=1,a=null,s="local-floor",o=1,c=null,l=null,u=null,d=null,f=null,h=null,b=typeof XRWebGLBinding<"u",m=new qT,g={},p=t.getContextAttributes(),y=null,v=null,x=[],_=[],E=new We,w=null,A=null,T=new hn;T.viewport=new Pt;let N=new hn;N.viewport=new Pt;let M=[T,N],R=new og,k=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let F=x[J];if(F===void 0)F=new dl,x[J]=F;return F.getTargetRaySpace()},this.getControllerGrip=function(J){let F=x[J];if(F===void 0)F=new dl,x[J]=F;return F.getGripSpace()},this.getHand=function(J){let F=x[J];if(F===void 0)F=new dl,x[J]=F;return F.getHandSpace()};function U(J){let F=_.indexOf(J.inputSource);if(F===-1)return;let X=x[F];if(X!==void 0)X.update(J.inputSource,J.frame,c||a),X.dispatchEvent({type:J.type,data:J.inputSource})}function D(){r.removeEventListener("select",U),r.removeEventListener("selectstart",U),r.removeEventListener("selectend",U),r.removeEventListener("squeeze",U),r.removeEventListener("squeezestart",U),r.removeEventListener("squeezeend",U),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",P);for(let J=0;J<x.length;J++){let F=_[J];if(F===null)continue;_[J]=null,x[J].disconnect(F)}k=null,C=null,m.reset();for(let J in g)delete g[J];if(e.setRenderTarget(y),f=null,d=null,u=null,r=null,v=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(E.width,E.height,!1),A!==null){let J=A.camera;J.fov=A.fov,J.zoom=A.zoom,J.updateProjectionMatrix(),A=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){if(i=J,n.isPresenting===!0)Ve("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){if(s=J,n.isPresenting===!0)Ve("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(J){c=J},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){if(u===null&&b)u=new XRWebGLBinding(r,t);return u},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(J){if(r=J,r!==null){if(y=e.getRenderTarget(),r.addEventListener("select",U),r.addEventListener("selectstart",U),r.addEventListener("selectend",U),r.addEventListener("squeeze",U),r.addEventListener("squeezestart",U),r.addEventListener("squeezeend",U),r.addEventListener("end",D),r.addEventListener("inputsourceschange",P),p.xrCompatible!==!0)await t.makeXRCompatible();if(w=e.getPixelRatio(),e.getSize(E),!(b&&("createProjectionLayer"in XRWebGLBinding.prototype))){let X={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,X),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new hr(f.framebufferWidth,f.framebufferHeight,{format:mi,type:Vr,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}else{let X=null,ne=null,re=null;if(p.depth)re=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,X=p.stencil?Is:Rs,ne=p.stencil?Do:xa;let ce={colorFormat:t.RGBA8,depthFormat:re,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(ce),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new hr(d.textureWidth,d.textureHeight,{format:mi,type:Vr,depthTexture:new Ps(d.textureWidth,d.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,X),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(o),c=null,a=await r.requestReferenceSpace(s),pe.setContext(r),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function P(J){for(let F=0;F<J.removed.length;F++){let X=J.removed[F],ne=_.indexOf(X);if(ne>=0)_[ne]=null,x[ne].disconnect(X)}for(let F=0;F<J.added.length;F++){let X=J.added[F],ne=_.indexOf(X);if(ne===-1){for(let ce=0;ce<x.length;ce++)if(ce>=_.length){_.push(X),ne=ce;break}else if(_[ce]===null){_[ce]=X,ne=ce;break}if(ne===-1)break}let re=x[ne];if(re)re.connect(X)}}let K=new V,z=new V;function W(J,F,X){K.setFromMatrixPosition(F.matrixWorld),z.setFromMatrixPosition(X.matrixWorld);let ne=K.distanceTo(z),re=F.projectionMatrix.elements,ce=X.projectionMatrix.elements,ve=re[14]/(re[10]-1),Re=re[14]/(re[10]+1),ke=(re[9]+1)/re[5],Xe=(re[9]-1)/re[5],et=(re[8]-1)/re[0],Wt=(ce[8]+1)/ce[0],dt=ve*et,Ft=ve*Wt,Qt=ne/(-et+Wt),nn=Qt*-et;if(F.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(nn),J.translateZ(Qt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),re[10]===-1)J.projectionMatrix.copy(F.projectionMatrix),J.projectionMatrixInverse.copy(F.projectionMatrixInverse);else{let B=ve+Qt,_n=Re+Qt,St=dt-nn,Xt=Ft+(ne-nn),O=ke*Re/_n*B,S=Xe*Re/_n*B;J.projectionMatrix.makePerspective(St,Xt,O,S,B,_n),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function q(J,F){if(F===null)J.matrixWorld.copy(J.matrix);else J.matrixWorld.multiplyMatrices(F.matrixWorld,J.matrix);J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;let{near:F,far:X}=J;if(m.texture!==null){if(m.depthNear>0)F=m.depthNear;if(m.depthFar>0)X=m.depthFar}if(R.near=N.near=T.near=F,R.far=N.far=T.far=X,k!==R.near||C!==R.far)r.updateRenderState({depthNear:R.near,depthFar:R.far}),k=R.near,C=R.far;R.layers.mask=J.layers.mask|6,T.layers.mask=R.layers.mask&-5,N.layers.mask=R.layers.mask&-3;let ne=J.parent,re=R.cameras;q(R,ne);for(let ce=0;ce<re.length;ce++)q(re[ce],ne);if(re.length===2)W(R,T,N);else R.projectionMatrix.copy(T.projectionMatrix);if(A===null&&J.isPerspectiveCamera)A={camera:J,fov:J.fov,zoom:J.zoom};le(J,R,ne)};function le(J,F,X){if(X===null)J.matrix.copy(F.matrixWorld);else J.matrix.copy(X.matrixWorld),J.matrix.invert(),J.matrix.multiply(F.matrixWorld);if(J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(F.projectionMatrix),J.projectionMatrixInverse.copy(F.projectionMatrixInverse),J.isPerspectiveCamera)J.fov=ws*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1}this.getCamera=function(){return R},this.getFoveation=function(){if(d===null&&f===null)return;return o},this.setFoveation=function(J){if(o=J,d!==null)d.fixedFoveation=J;if(f!==null&&f.fixedFoveation!==void 0)f.fixedFoveation=J},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(R)},this.getCameraTexture=function(J){return g[J]};let he=null;function xe(J,F){if(l=F.getViewerPose(c||a),h=F,l!==null){let X=l.views;if(f!==null)e.setRenderTargetFramebuffer(v,f.framebuffer),e.setRenderTarget(v);let ne=!1;if(X.length!==R.cameras.length)R.cameras.length=0,ne=!0;for(let Re=0;Re<X.length;Re++){let ke=X[Re],Xe=null;if(f!==null)Xe=f.getViewport(ke);else{let Wt=u.getViewSubImage(d,ke);if(Xe=Wt.viewport,Re===0)e.setRenderTargetTextures(v,Wt.colorTexture,Wt.depthStencilTexture),e.setRenderTarget(v)}let et=M[Re];if(et===void 0)et=new hn,et.layers.enable(Re),et.viewport=new Pt,M[Re]=et;if(et.matrix.fromArray(ke.transform.matrix),et.matrix.decompose(et.position,et.quaternion,et.scale),et.projectionMatrix.fromArray(ke.projectionMatrix),et.projectionMatrixInverse.copy(et.projectionMatrix).invert(),et.viewport.set(Xe.x,Xe.y,Xe.width,Xe.height),Re===0)R.matrix.copy(et.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale);if(ne===!0)R.cameras.push(et)}let re=r.enabledFeatures;if(re&&re.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&b){u=n.getBinding();let Re=u.getDepthInformation(X[0]);if(Re&&Re.isValid&&Re.texture)m.init(Re,r.renderState)}if(re&&re.includes("camera-access")&&b){e.state.unbindTexture(),u=n.getBinding();for(let Re=0;Re<X.length;Re++){let ke=X[Re].camera;if(ke){let Xe=g[ke];if(!Xe)Xe=new Hd,g[ke]=Xe;let et=u.getCameraImage(ke);Xe.sourceTexture=et}}}}for(let X=0;X<x.length;X++){let ne=_[X],re=x[X];if(ne!==null&&re!==void 0)re.update(ne,F,c||a)}if(he)he(J,F);if(F.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:F});h=null}let pe=new UT;pe.setAnimationLoop(xe),this.setAnimationLoop=function(J){he=J},this.dispose=function(){}}};CD=new Ze,ZT=new nt;ZT.set(-1,0,0,0,1,0,0,0,1);OD=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])});async function ec(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}function $w(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=()=>{throw Error("Texture manifest cannot read image dimensions")},r=(a,s)=>{if(a+s>e.byteLength)n()};if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return r(16,8),{width:t.getUint32(16),height:t.getUint32(20)};if(Gg(e))return r(20,8),{width:t.getUint32(20,!0),height:t.getUint32(24,!0)};if(e[0]===255&&e[1]===216){let a=2;while(a+4<=e.byteLength){if(e[a]!==255)n();let s=e[a+1];if(s===255){a++;continue}if(s===216||s===1||s>=208&&s<=215){a+=2;continue}let o=t.getUint16(a+2);if(s>=192&&s<=207&&![196,200,204].includes(s))return r(a+5,4),{width:t.getUint16(a+7),height:t.getUint16(a+5)};a+=2+o}n()}let i=(a)=>String.fromCharCode(...e.subarray(a,Math.min(a+4,e.byteLength)));if(i(0)==="RIFF"&&i(8)==="WEBP"){r(12,19);let a=i(12);if(a==="VP8X")return{width:1+(t.getUint32(24,!0)&16777215),height:1+(t.getUint32(27,!0)&16777215)};if(a==="VP8L"){let s=t.getUint32(21,!0);return{width:1+(s&16383),height:1+(s>>14&16383)}}if(a==="VP8 ")return r(26,4),{width:t.getUint16(26,!0)&16383,height:t.getUint16(28,!0)&16383}}return n()}function s9(e){if(!Na(e))return;let t=Na(e.extensions)?e.extensions:{};for(let n of["KHR_texture_basisu","EXT_texture_webp","EXT_texture_avif"]){let r=t[n];if(Na(r)&&Ca(r.source)!==void 0)return Ca(r.source)}return Ca(e.source)}function o9(e){let t=Array.isArray(e.textures)?e.textures:[],n=new Set;for(let r of Array.isArray(e.materials)?e.materials:[]){if(!Na(r))continue;let i=Na(r.pbrMetallicRoughness)?r.pbrMetallicRoughness:{};for(let a of[i.baseColorTexture,r.emissiveTexture]){let s=Na(a)?Ca(a.index):void 0,o=s===void 0?void 0:s9(t[s]);if(o!==void 0)n.add(o)}}return n}function c9(e){let t=atob(e);return Uint8Array.from(t,(n)=>n.charCodeAt(0))}function l9(e,t){let n=Array.isArray(e.bufferViews)?e.bufferViews:[];return(Array.isArray(e.images)?e.images:[]).map((r)=>{if(!Na(r))throw Error("Invalid glTF image");let i=Ca(r.bufferView);if(i!==void 0){let s=n[i];if(!Na(s)||Ca(s.buffer)!==0||!t)throw Error("Texture manifest requires images embedded in the GLB binary chunk");let o=Ca(s.byteOffset)??0,c=Ca(s.byteLength);if(c===void 0||o+c>t.byteLength)throw Error("Invalid glTF image buffer view");if(typeof r.mimeType!=="string")throw Error("Embedded image needs a mimeType");return{bytes:t.subarray(o,o+c),mimeType:r.mimeType}}let a=typeof r.uri==="string"?/^data:([^;,]+);base64,(.*)$/s.exec(r.uri):null;if(!a)throw Error("Texture manifest requires embedded image bytes");return{bytes:c9(a[2]),mimeType:a[1]}})}async function Kw(e,t,n={}){let r=o9(e),i=[];for(let[a,{bytes:s,mimeType:o}]of l9(e,t).entries()){let c=`sha256:${await ec(s)}`,l=n.sources?.get(a),u=l??c,d=n.maps?.find((f)=>f.sha256===u);i.push({image:a,sha256:c,bytes:s.byteLength,mimeType:o,...$w(s),colorSpace:r.has(a)?"srgb":"linear",...l&&l!==c?{sourceSha256:l}:{},...d?{material:{pin:{...d.pin},slot:d.slot}}:{}})}return i}function Ww(e){let t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/ktx2":"ktx2"}[e];if(!t)throw Error(`External textures do not support ${e}`);return t}var Na=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Ca=(e)=>Number.isInteger(e)&&e>=0?e:void 0,a9,Gg=(e)=>e.byteLength>=12&&a9.every((t,n)=>e[n]===t);var cf=ot(()=>{a9=Object.freeze([171,75,84,88,32,50,48,187,13,10,26,10])});var Xw=class{_listeners={};addEventListener(e,t){let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t);return this}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let r=n.indexOf(t);if(r!==-1)n.splice(r,1)}return this}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){let n=t.slice(0);for(let r=0,i=n.length;r<i;r++)n[r].call(this,e)}return this}dispose(){for(let e in this._listeners)delete this._listeners[e]}},Oa=class{_disposed=!1;_name;_parent;_child;_attributes;constructor(e,t,n,r={}){if(this._name=e,this._parent=t,this._child=n,this._attributes=r,!t.isOnGraph(n))throw Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}},Hg,xn=class{list=[];constructor(e){if(e)for(let t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){let t=this.list.indexOf(e);if(t>=0)this.list.splice(t,1)}removeChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);for(let n of t)this.remove(n);return t}listRefsByChild(e){let t=[];for(let n of this.list)if(n.getChild()===e)t.push(n);return t}values(){return this.list}},Ct=class{set=new Set;map=new Map;constructor(e){if(e)for(let t of e)this.add(t)}add(e){let t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){let t=this.map.get(e)||null;if(t)this.remove(t);return t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}},dn=class{map={};constructor(e){if(e)Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},Tt,Pa,qw;var Jw=ot(()=>{Hg=class extends Xw{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){let t=new Set;for(let n of this.listParentEdges(e))t.add(n.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){let t=new Set;for(let n of this.listChildEdges(e))t.add(n.getChild());return Array.from(t)}disconnectParents(e,t){for(let n of this.listParentEdges(e))if(!t||t(n.getParent()))n.dispose();return this}_createEdge(e,t,n,r){let i=new Oa(e,t,n,r);this._edges.add(i);let a=i.getParent();if(!this._parentEdges.has(a))this._parentEdges.set(a,new Set);this._parentEdges.get(a).add(i);let s=i.getChild();if(!this._childEdges.has(s))this._childEdges.set(s,new Set);return this._childEdges.get(s).add(i),i}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}},Tt=Symbol("attributes"),Pa=Symbol("immutableKeys"),qw=class e extends Xw{_disposed=!1;graph;[Tt];[Pa];constructor(t){super();this.graph=t,this[Pa]=new Set,this[Tt]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let t=this.getDefaults(),n={};for(let r in t){let i=t[r];if(i instanceof e){let a=this.graph._createEdge(r,this,i);this[Pa].add(r),n[r]=a}else n[r]=i}return n}isOnGraph(t){return this.graph===t.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((t)=>t.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(t,n){for(let r in this[Tt]){let i=this[Tt][r];if(i instanceof Oa){let a=i;if(a.getChild()===t)this.setRef(r,n,a.getAttributes())}else if(i instanceof xn)for(let a of i.listRefsByChild(t)){let s=a.getAttributes();this.removeRef(r,t),this.addRef(r,n,s)}else if(i instanceof Ct){let a=i.getRefByChild(t);if(a){let s=a.getAttributes();this.removeRef(r,t),this.addRef(r,n,s)}}else if(i instanceof dn)for(let a of i.keys()){let s=i.get(a);if(s.getChild()===t)this.setRefMap(r,a,n,s.getAttributes())}}return this}get(t){return this[Tt][t]}set(t,n){return this[Tt][t]=n,this.dispatchEvent({type:"change",attribute:t})}getRef(t){let n=this[Tt][t];return n?n.getChild():null}setRef(t,n,r){if(this[Pa].has(t))throw Error(`Cannot overwrite immutable attribute, "${t}".`);let i=this[Tt][t];if(i)i.dispose();if(!n)return this;let a=this.graph._createEdge(t,this,n,r);return this[Tt][t]=a,this.dispatchEvent({type:"change",attribute:t})}listRefs(t){return this.assertRefList(t).values().map((n)=>n.getChild())}addRef(t,n,r){let i=this.graph._createEdge(t,this,n,r);return this.assertRefList(t).add(i),this.dispatchEvent({type:"change",attribute:t})}removeRef(t,n){let r=this.assertRefList(t);if(r instanceof xn)for(let i of r.listRefsByChild(n))i.dispose();else{let i=r.getRefByChild(n);if(i)i.dispose()}return this}assertRefList(t){let n=this[Tt][t];if(n instanceof xn||n instanceof Ct)return n;throw Error(`Expected RefList or RefSet for attribute "${t}"`)}listRefMapKeys(t){return this.assertRefMap(t).keys()}listRefMapValues(t){return this.assertRefMap(t).values().map((n)=>n.getChild())}getRefMap(t,n){let r=this.assertRefMap(t).get(n);return r?r.getChild():null}setRefMap(t,n,r,i){let a=this.assertRefMap(t),s=a.get(n);if(s)s.dispose();if(!r)return this;i=Object.assign(i||{},{key:n});let o=this.graph._createEdge(t,this,r,{...i,key:n});return a.set(n,o),this.dispatchEvent({type:"change",attribute:t,key:n})}assertRefMap(t){let n=this[Tt][t];if(n instanceof dn)return n;throw Error(`Expected RefMap for attribute "${t}"`)}dispatchEvent(t){return super.dispatchEvent({...t,target:this}),this.graph.dispatchEvent({...t,target:this,type:`node:${t.type}`}),this}_destroyRef(t){let n=t.getName();if(this[Tt][n]===t){if(this[Tt][n]=null,this[Pa].has(n))t.getChild().dispose()}else if(this[Tt][n]instanceof xn)this[Tt][n].remove(t);else if(this[Tt][n]instanceof Ct)this[Tt][n].remove(t);else if(this[Tt][n]instanceof dn){let r=this[Tt][n];for(let i of r.keys())if(r.get(i)===t)r.delete(i)}else return;this.graph._destroyEdge(t),this.dispatchEvent({type:"change",attribute:n})}}});function p9(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(e.getUint8(t)!==255)throw TypeError("Invalid JPG, marker table corrupted");return e}function m9(){var e=new Wg(3);if(Wg!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function $g(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function g9(e,t,n){var r=t[0],i=t[1],a=t[2],s=n[3]*r+n[7]*i+n[11]*a+n[15];return s=s||1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/s,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/s,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/s,e}function qg(e){let t=sM(),n=e.propertyType==="Node"?[e]:e.listChildren();for(let r of n)r.traverse((i)=>{let a=i.getMesh();if(!a)return;let s=b9(a,i.getWorldMatrix());if(s.min.every(isFinite)&&s.max.every(isFinite))Xg(s.min,t),Xg(s.max,t)});return t}function b9(e,t){let n=sM();for(let r of e.listPrimitives()){let i=r.getAttribute("POSITION"),a=r.getIndices();if(!i)continue;let s=[0,0,0],o=[0,0,0];for(let c=0,l=a?a.getCount():i.getCount();c<l;c++){let u=a?a.getScalar(c):c;s=i.getElement(u,s),o=g9(o,s,t),Xg(o,n)}}return n}function Xg(e,t){for(let n=0;n<3;n++)t.min[n]=Math.min(e[n],t.min[n]),t.max[n]=Math.max(e[n],t.max[n])}function sM(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}function Yw(e){return Object.prototype.toString.call(e)==="[object Object]"}function Us(e){if(Yw(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;if(Yw(n)===!1)return!1;if(Object.hasOwn(n,"isPrototypeOf")===!1)return!1;return!0}function y9(e){var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],s=e[5],o=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],h=e[12],b=e[13],m=e[14],g=e[15],p=t*s-n*a,y=t*o-r*a,v=n*o-r*s,x=l*b-u*h,_=l*m-d*h,E=u*m-d*b,w=t*E-n*_+r*x,A=a*E-s*_+o*x,T=l*v-u*y+d*p,N=h*v-b*y+m*p;return c*w-i*A+g*T-f*N}function _9(e,t,n){var r=t[0],i=t[1],a=t[2],s=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],y=t[15],v=n[0],x=n[1],_=n[2],E=n[3];return e[0]=v*r+x*o+_*d+E*m,e[1]=v*i+x*c+_*f+E*g,e[2]=v*a+x*l+_*h+E*p,e[3]=v*s+x*u+_*b+E*y,v=n[4],x=n[5],_=n[6],E=n[7],e[4]=v*r+x*o+_*d+E*m,e[5]=v*i+x*c+_*f+E*g,e[6]=v*a+x*l+_*h+E*p,e[7]=v*s+x*u+_*b+E*y,v=n[8],x=n[9],_=n[10],E=n[11],e[8]=v*r+x*o+_*d+E*m,e[9]=v*i+x*c+_*f+E*g,e[10]=v*a+x*l+_*h+E*p,e[11]=v*s+x*u+_*b+E*y,v=n[12],x=n[13],_=n[14],E=n[15],e[12]=v*r+x*o+_*d+E*m,e[13]=v*i+x*c+_*f+E*g,e[14]=v*a+x*l+_*h+E*p,e[15]=v*s+x*u+_*b+E*y,e}function v9(e,t){var n=t[0],r=t[1],i=t[2],a=t[4],s=t[5],o=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(n*n+r*r+i*i),e[1]=Math.sqrt(a*a+s*s+o*o),e[2]=Math.sqrt(c*c+l*l+u*u),e}function E9(e,t){var n=new Wg(3);v9(n,t);var r=1/n[0],i=1/n[1],a=1/n[2],s=t[0]*r,o=t[1]*i,c=t[2]*a,l=t[4]*r,u=t[5]*i,d=t[6]*a,f=t[8]*r,h=t[9]*i,b=t[10]*a,m=s+u+b,g=0;if(m>0)g=Math.sqrt(m+1)*2,e[3]=0.25*g,e[0]=(d-h)/g,e[1]=(f-c)/g,e[2]=(o-l)/g;else if(s>u&&s>b)g=Math.sqrt(1+s-u-b)*2,e[3]=(d-h)/g,e[0]=0.25*g,e[1]=(o+l)/g,e[2]=(f+c)/g;else if(u>b)g=Math.sqrt(1+u-s-b)*2,e[3]=(f-c)/g,e[0]=(o+l)/g,e[1]=0.25*g,e[2]=(d+h)/g;else g=Math.sqrt(1+b-s-u)*2,e[3]=(o-l)/g,e[0]=(f+c)/g,e[1]=(d+h)/g,e[2]=0.25*g;return e}function A9(e,t){if(!!e!==!!t)return!1;let n=e.getChild(),r=t.getChild();return n===r||n.equals(r)}function T9(e,t){if(!!e!==!!t)return!1;let n=e.values(),r=t.values();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++){let a=n[i],s=r[i];if(a.getChild()===s.getChild())continue;if(!a.getChild().equals(s.getChild()))return!1}return!0}function w9(e,t){if(!!e!==!!t)return!1;let n=e.keys(),r=t.keys();if(n.length!==r.length)return!1;for(let i of n){let a=e.get(i),s=t.get(i);if(!!a!==!!s)return!1;let o=a.getChild(),c=s.getChild();if(o===c)continue;if(!o.equals(c))return!1}return!0}function oM(e,t){if(e===t)return!0;if(!!e!==!!t||!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function cM(e,t){if(e===t)return!0;if(!!e!==!!t)return!1;if(!Us(e)||!Us(t))return e===t;let n=e,r=t,i=0,a=0,s;for(s in n)i++;for(s in r)a++;if(i!==a)return!1;for(s in n){let o=n[s],c=r[s];if(pf(o)&&pf(c)){if(!oM(o,c))return!1}else if(Us(o)&&Us(c)){if(!cM(o,c))return!1}else if(o!==c)return!1}return!0}function pf(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function N9(e){switch(e.constructor){case Float32Array:return Oe.ComponentType.FLOAT;case Uint32Array:return Oe.ComponentType.UNSIGNED_INT;case Uint16Array:return Oe.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Oe.ComponentType.UNSIGNED_BYTE;case Int16Array:return Oe.ComponentType.SHORT;case Int8Array:return Oe.ComponentType.BYTE;case Float64Array:return Oe.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&e.constructor===Float16Array)return Oe.ComponentType.FLOAT16;throw Error("Unknown accessor componentType.")}function D9(e,t){let n=t.jsonDoc,r=t.bufferViews[e.bufferView],i=n.json.bufferViews[e.bufferView],a=Ol[e.componentType],s=Oe.getElementSize(e.type),o=a.BYTES_PER_ELEMENT,c=e.byteOffset||0,l=new a(e.count*s),u=new DataView(r.buffer,r.byteOffset,r.byteLength),d=i.byteStride;for(let f=0;f<e.count;f++)for(let h=0;h<s;h++){let b=c+f*d+h*o,m;switch(e.componentType){case Oe.ComponentType.FLOAT:m=u.getFloat32(b,!0);break;case Oe.ComponentType.UNSIGNED_INT:m=u.getUint32(b,!0);break;case Oe.ComponentType.UNSIGNED_SHORT:m=u.getUint16(b,!0);break;case Oe.ComponentType.UNSIGNED_BYTE:m=u.getUint8(b);break;case Oe.ComponentType.SHORT:m=u.getInt16(b,!0);break;case Oe.ComponentType.BYTE:m=u.getInt8(b);break;case Oe.ComponentType.FLOAT16:m=u.getFloat16(b,!0);break;case Oe.ComponentType.FLOAT64:m=u.getFloat64(b,!0);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}l[f*s+h]=m}return l}function hf(e,t){let n=t.jsonDoc,r=t.bufferViews[e.bufferView],i=n.json.bufferViews[e.bufferView],a=Ol[e.componentType],s=Oe.getElementSize(e.type),o=a.BYTES_PER_ELEMENT,c=s*o;if(i.byteStride!==void 0&&i.byteStride!==c)return D9(e,t);let l=r.byteOffset+(e.byteOffset||0),u=e.count*s*o;return new a(r.buffer.slice(l,l+u))}function F9(e,t){let n=Ol[e.componentType],r=Oe.getElementSize(e.type),i;if(e.bufferView!==void 0)i=hf(e,t);else i=new n(e.count*r);let a=e.sparse;if(!a)return i;let s=a.count,o={...e,...a.indices,count:s,type:"SCALAR"},c={...e,...a.values,count:s},l=hf(o,t),u=hf(c,t);for(let d=0;d<o.count;d++)for(let f=0;f<r;f++)i[l[d]*r+f]=u[d*r+f];return i}function U9(e,t){let n=e.getGraph().listParentEdges(t).find((r)=>r.getParent()!==e.getRoot());return n?n.getName().replace(/texture$/i,""):""}function H9(e){let t=[];for(let n in e){let r=e[n];if(Array.isArray(r)&&r.length===0)t.push(n);else if(r===null||r==="")t.push(n);else if(r&&typeof r==="object"&&Object.keys(r).length===0)t.push(n)}for(let n of t)delete e[n]}function K9(e,t){return t.uri!==void 0&&!(t.uri in e.resources)}function W9(e,t){return t.uri!==void 0&&!(t.uri in e.resources)&&t.bufferView===void 0}function nM(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return t[0]===1179937895&&t[1]===2}var rM="v4.5.1",La="@glb.bin",Q,u9,Rr,iM,d9,Ol,Ye=class{static createBufferFromDataURI(e){if(typeof Buffer>"u"){let t=atob(e.split(",")[1]),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}else{let t=e.split(",")[1],n=e.indexOf("base64")>=0;return Buffer.from(t,n?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let i of e)t+=i.byteLength;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;return n}static pad(e,t=0){let n=this.padNumber(e.byteLength);if(n===e.byteLength)return e;let r=new Uint8Array(n);if(r.set(e),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let n=e.byteLength;while(n--)if(e[n]!==t[n])return!1;return!0}static toView(e,t=0,n=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,n))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}},aM=class{static hexToFactor(e,t){e=Math.floor(e);let n=t;return n[0]=(e>>16&255)/255,n[1]=(e>>8&255)/255,n[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[n,r,i]=this.convertLinearToSRGB(e,t);return n*255<<16^r*255<<8^i*255<<0}static convertSRGBToLinear(e,t){let n=e,r=t;for(let i=0;i<3;i++)r[i]=n[i]<0.04045?n[i]*0.0773993808:Math.pow(n[i]*0.9478672986+0.0521327014,2.4);return t}static convertLinearToSRGB(e,t){let n=e,r=t;for(let i=0;i<3;i++)r[i]=n[i]<0.0031308?n[i]*12.92:1.055*Math.pow(n[i],0.41666)-0.055;return t}},f9=class{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),n,r;while(t.byteLength){if(n=t.getUint16(0,!1),p9(t,n),r=t.getUint8(n+1),r===192||r===193||r===194)return[t.getUint16(n+7,!1),t.getUint16(n+5,!1)];t=new DataView(e.buffer,t.byteOffset+n+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}},h9=class e{static PNG_FRIED_CHUNK_NAME="CgBI";match(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10}getSize(t){let n=new DataView(t.buffer,t.byteOffset);if(Ye.decodeText(t.slice(12,16))===e.PNG_FRIED_CHUNK_NAME)return[n.getUint32(32,!1),n.getUint32(36,!1)];return[n.getUint32(16,!1),n.getUint32(20,!1)]}getChannels(t){return 4}},Kr,zs=class{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return Kr.mimeTypeToExtension(t)}else if(e.startsWith("data:model/gltf+json"))return"gltf";else if(e.startsWith("data:model/gltf-binary"))return"glb";else if(e.startsWith("data:application/"))return"bin";return e.split(/[\\/]/).pop().split(/[.]/).pop()}},Wg,Zw="https://null.example",Kg,x9,js,gt=class e{static identity(t){return t}static eq(t,n,r=0.00001){if(t.length!==n.length)return!1;for(let i=0;i<t.length;i++)if(Math.abs(t[i]-n[i])>r)return!1;return!0}static clamp(t,n,r){if(t<n)return n;if(t>r)return r;return t}static decodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(t,n){switch(n){case 5126:return t;case 5123:return Math.round(e.clamp(t,0,1)*65535);case 5121:return Math.round(e.clamp(t,0,1)*255);case 5122:return Math.round(e.clamp(t,-1,1)*32767);case 5120:return Math.round(e.clamp(t,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(t,n,r,i){let a=$g([t[0],t[1],t[2]]),s=$g([t[4],t[5],t[6]]),o=$g([t[8],t[9],t[10]]);if(y9(t)<0)a=-a;n[0]=t[12],n[1]=t[13],n[2]=t[14];let c=t.slice(),l=1/a,u=1/s,d=1/o;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,E9(r,c),i[0]=a,i[1]=s,i[2]=o}static compose(t,n,r,i){let a=i,s=n[0],o=n[1],c=n[2],l=n[3],u=s+s,d=o+o,f=c+c,h=s*u,b=s*d,m=s*f,g=o*d,p=o*f,y=c*f,v=l*u,x=l*d,_=l*f,E=r[0],w=r[1],A=r[2];return a[0]=(1-(g+y))*E,a[1]=(b+_)*E,a[2]=(m-x)*E,a[3]=0,a[4]=(b-_)*w,a[5]=(1-(h+y))*w,a[6]=(p+v)*w,a[7]=0,a[8]=(m+x)*A,a[9]=(p-v)*A,a[10]=(1-(h+g))*A,a[11]=0,a[12]=t[0],a[13]=t[1],a[14]=t[2],a[15]=1,a}},M9="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",S9=999,R9=6,Qw,I9=function(){let e="";for(let t=0;t<R9;t++)e+=M9.charAt(Math.floor(Math.random()*42));return e},lM=function(){for(let e=0;e<S9;e++){let t=I9();if(!Qw.has(t))return Qw.add(t),t}return""},Da=(e)=>e,C9,Jg,Kn,Oe,uM,Vs,kl,dM,mf,rt,Mt,lf,uf,df,P9,Bs,Zg,gf,Qn,Yg,bf,fM,tc,Fa,xf,_t=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=!1;properties=new Set;_listener;constructor(e){this.document=e,e.getRoot()._enableExtension(this),this._listener=(n)=>{let r=n,i=r.target;if(i instanceof rt&&i.extensionName===this.extensionName){if(r.type==="node:create")this._addExtensionProperty(i);if(r.type==="node:dispose")this._removeExtensionProperty(i)}};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(let t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}},O9=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(e){this.jsonDoc=e}setTextureInfo(e,t){if(this.textureInfos.set(e,t),t.texCoord!==void 0)e.setTexCoord(t.texCoord);if(t.extras!==void 0)e.setExtras(t.extras);let n=this.jsonDoc.json.textures[t.index];if(n.sampler===void 0)return;let r=this.jsonDoc.json.samplers[n.sampler];if(r.magFilter!==void 0)e.setMagFilter(r.magFilter);if(r.minFilter!==void 0)e.setMinFilter(r.minFilter);if(r.wrapS!==void 0)e.setWrapS(r.wrapS);if(r.wrapT!==void 0)e.setWrapT(r.wrapT)}},eM,k9,L9=class{static read(e,t=eM){let n={...eM,...t},{json:r}=e,i=new xf().setLogger(n.logger);this.validate(e,n);let a=new O9(e),s=r.asset,o=i.getRoot().getAsset();if(s.copyright)o.copyright=s.copyright;if(s.extras)o.extras=s.extras;if(r.extras!==void 0)i.getRoot().setExtras({...r.extras});let c=r.extensionsUsed||[],l=r.extensionsRequired||[];n.extensions.sort((p,y)=>p.EXTENSION_NAME>y.EXTENSION_NAME?1:-1);for(let p of n.extensions)if(c.includes(p.EXTENSION_NAME)){let y=i.createExtension(p).setRequired(l.includes(p.EXTENSION_NAME)),v=y.prereadTypes.filter((x)=>!k9.has(x));if(v.length)n.logger.warn(`Preread hooks for some types (${v.join()}), requested by extension ${y.extensionName}, are unsupported. Please file an issue or a PR.`);for(let x of y.readDependencies)y.install(x,n.dependencies[x])}let u=r.buffers||[];i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Buffer")).forEach((p)=>p.preread(a,"Buffer")),a.buffers=u.map((p)=>{let y=i.createBuffer(p.name);if(p.extras)y.setExtras(p.extras);if(p.uri&&p.uri.indexOf("__")!==0)y.setURI(p.uri);return y}),a.bufferViewBuffers=(r.bufferViews||[]).map((p,y)=>{if(!a.bufferViews[y]){let v=e.json.buffers[p.buffer],x=v.uri?e.resources[v.uri]:e.resources[La],_=p.byteOffset||0;a.bufferViews[y]=Ye.toView(x,_,p.byteLength)}return a.buffers[p.buffer]});let d=r.accessors||[];a.accessors=d.map((p)=>{let y=a.bufferViewBuffers[p.bufferView],v=i.createAccessor(p.name,y).setType(p.type);if(p.extras)v.setExtras(p.extras);if(p.normalized!==void 0)v.setNormalized(p.normalized);if(p.bufferView===void 0)return v;return v.setArray(hf(p,a)),v});let f=r.images||[],h=r.textures||[];i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Texture")).forEach((p)=>p.preread(a,"Texture")),a.textures=f.map((p)=>{let y=i.createTexture(p.name);if(p.extras)y.setExtras(p.extras);if(p.bufferView!==void 0){let v=r.bufferViews[p.bufferView],x=e.json.buffers[v.buffer],_=x.uri?e.resources[x.uri]:e.resources[La],E=v.byteOffset||0,w=v.byteLength,A=_.slice(E,E+w);y.setImage(A)}else if(p.uri!==void 0){if(y.setImage(e.resources[p.uri]),p.uri.indexOf("__")!==0)y.setURI(p.uri)}if(p.mimeType!==void 0)y.setMimeType(p.mimeType);else if(p.uri){let v=zs.extension(p.uri);y.setMimeType(Kr.extensionToMimeType(v))}return y}),i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Material")).forEach((p)=>p.preread(a,"Material")),a.materials=(r.materials||[]).map((p)=>{let y=i.createMaterial(p.name);if(p.extras)y.setExtras(p.extras);if(p.alphaMode!==void 0)y.setAlphaMode(p.alphaMode);if(p.alphaCutoff!==void 0)y.setAlphaCutoff(p.alphaCutoff);if(p.doubleSided!==void 0)y.setDoubleSided(p.doubleSided);let v=p.pbrMetallicRoughness||{};if(v.baseColorFactor!==void 0)y.setBaseColorFactor(v.baseColorFactor);if(p.emissiveFactor!==void 0)y.setEmissiveFactor(p.emissiveFactor);if(v.metallicFactor!==void 0)y.setMetallicFactor(v.metallicFactor);if(v.roughnessFactor!==void 0)y.setRoughnessFactor(v.roughnessFactor);if(v.baseColorTexture!==void 0){let x=v.baseColorTexture,_=a.textures[h[x.index].source];y.setBaseColorTexture(_),a.setTextureInfo(y.getBaseColorTextureInfo(),x)}if(p.emissiveTexture!==void 0){let x=p.emissiveTexture,_=a.textures[h[x.index].source];y.setEmissiveTexture(_),a.setTextureInfo(y.getEmissiveTextureInfo(),x)}if(p.normalTexture!==void 0){let x=p.normalTexture,_=a.textures[h[x.index].source];if(y.setNormalTexture(_),a.setTextureInfo(y.getNormalTextureInfo(),x),p.normalTexture.scale!==void 0)y.setNormalScale(p.normalTexture.scale)}if(p.occlusionTexture!==void 0){let x=p.occlusionTexture,_=a.textures[h[x.index].source];if(y.setOcclusionTexture(_),a.setTextureInfo(y.getOcclusionTextureInfo(),x),p.occlusionTexture.strength!==void 0)y.setOcclusionStrength(p.occlusionTexture.strength)}if(v.metallicRoughnessTexture!==void 0){let x=v.metallicRoughnessTexture,_=a.textures[h[x.index].source];y.setMetallicRoughnessTexture(_),a.setTextureInfo(y.getMetallicRoughnessTextureInfo(),x)}return y}),i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Mesh")).forEach((p)=>p.preread(a,"Mesh"));let b=r.meshes||[];i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Primitive")).forEach((p)=>p.preread(a,"Primitive")),a.meshes=b.map((p)=>{let y=i.createMesh(p.name);if(p.extras)y.setExtras(p.extras);if(p.weights!==void 0)y.setWeights(p.weights);return(p.primitives||[]).forEach((v)=>{let x=i.createPrimitive();if(v.extras)x.setExtras(v.extras);if(v.material!==void 0)x.setMaterial(a.materials[v.material]);if(v.mode!==void 0)x.setMode(v.mode);for(let[E,w]of Object.entries(v.attributes||{}))x.setAttribute(E,a.accessors[w]);if(v.indices!==void 0)x.setIndices(a.accessors[v.indices]);let _=p.extras&&p.extras.targetNames||[];(v.targets||[]).forEach((E,w)=>{let A=_[w]||w.toString(),T=i.createPrimitiveTarget(A);for(let[N,M]of Object.entries(E))T.setAttribute(N,a.accessors[M]);x.addTarget(T)}),y.addPrimitive(x)}),y}),a.cameras=(r.cameras||[]).map((p)=>{let y=i.createCamera(p.name).setType(p.type);if(p.extras)y.setExtras(p.extras);if(p.type===mf.Type.PERSPECTIVE){let v=p.perspective;if(y.setYFov(v.yfov),y.setZNear(v.znear),v.zfar!==void 0)y.setZFar(v.zfar);if(v.aspectRatio!==void 0)y.setAspectRatio(v.aspectRatio)}else{let v=p.orthographic;y.setZNear(v.znear).setZFar(v.zfar).setXMag(v.xmag).setYMag(v.ymag)}return y});let m=r.nodes||[];i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Node")).forEach((p)=>p.preread(a,"Node")),a.nodes=m.map((p)=>{let y=i.createNode(p.name);if(p.extras)y.setExtras(p.extras);if(p.translation!==void 0)y.setTranslation(p.translation);if(p.rotation!==void 0)y.setRotation(p.rotation);if(p.scale!==void 0)y.setScale(p.scale);if(p.matrix!==void 0){let v=[0,0,0],x=[0,0,0,1],_=[1,1,1];gt.decompose(p.matrix,v,x,_),y.setTranslation(v),y.setRotation(x),y.setScale(_)}if(p.weights!==void 0)y.setWeights(p.weights);return y}),a.skins=(r.skins||[]).map((p)=>{let y=i.createSkin(p.name);if(p.extras)y.setExtras(p.extras);if(p.inverseBindMatrices!==void 0)y.setInverseBindMatrices(a.accessors[p.inverseBindMatrices]);if(p.skeleton!==void 0)y.setSkeleton(a.nodes[p.skeleton]);for(let v of p.joints)y.addJoint(a.nodes[v]);return y}),m.map((p,y)=>{let v=a.nodes[y];if((p.children||[]).forEach((x)=>v.addChild(a.nodes[x])),p.mesh!==void 0)v.setMesh(a.meshes[p.mesh]);if(p.camera!==void 0)v.setCamera(a.cameras[p.camera]);if(p.skin!==void 0)v.setSkin(a.skins[p.skin])}),a.animations=(r.animations||[]).map((p)=>{let y=i.createAnimation(p.name);if(p.extras)y.setExtras(p.extras);let v=(p.samplers||[]).map((x)=>{let _=i.createAnimationSampler().setInput(a.accessors[x.input]).setOutput(a.accessors[x.output]).setInterpolation(x.interpolation||kl.Interpolation.LINEAR);if(x.extras)_.setExtras(x.extras);return y.addSampler(_),_});return(p.channels||[]).forEach((x)=>{let _=i.createAnimationChannel().setSampler(v[x.sampler]).setTargetPath(x.target.path);if(x.target.node!==void 0)_.setTargetNode(a.nodes[x.target.node]);if(x.extras)_.setExtras(x.extras);y.addChannel(_)}),y});let g=r.scenes||[];if(i.getRoot().listExtensionsUsed().filter((p)=>p.prereadTypes.includes("Scene")).forEach((p)=>p.preread(a,"Scene")),a.scenes=g.map((p)=>{let y=i.createScene(p.name);if(p.extras)y.setExtras(p.extras);return(p.nodes||[]).map((v)=>a.nodes[v]).forEach((v)=>y.addChild(v)),y}),r.scene!==void 0)i.getRoot().setDefaultScene(a.scenes[r.scene]);return i.getRoot().listExtensionsUsed().forEach((p)=>p.read(a)),d.forEach((p,y)=>{let v=a.accessors[y],x=!!p.sparse,_=!p.bufferView&&!v.getArray();if(x||_)v.setSparse(!0).setArray(F9(p,a))}),i}static validate(e,t){let n=e.json;if(n.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${n.asset.version}".`);if(n.extensionsRequired){for(let r of n.extensionsRequired)if(!t.extensions.find((i)=>i.EXTENSION_NAME===r))throw Error(`Missing required extension, "${r}".`)}if(n.extensionsUsed){for(let r of n.extensionsUsed)if(!t.extensions.find((i)=>i.EXTENSION_NAME===r))t.logger.warn(`Missing optional extension, "${r}".`)}}},hM,ka,tM=class{multiple;basename;counter={};constructor(e,t){this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();else if(!this.multiple)return`${this.basename(e)}.${t}`;else{let n=this.basename(e);return this.counter[n]=this.counter[n]||1,`${n}_${this.counter[n]++}.${t}`}}},ff,z9,B9,j9,V9,G9=class{static write(e,t){let n=e.getGraph(),r=e.getRoot(),i={asset:{generator:`glTF-Transform ${rM}`,...r.getAsset()},extras:{...r.getExtras()}},a={json:i,resources:{}},s=new ka(e,a,t),o=t.logger||js.DEFAULT_INSTANCE,c=new Set(t.extensions.map((m)=>m.EXTENSION_NAME)),l=e.getRoot().listExtensionsUsed().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1),u=e.getRoot().listExtensionsRequired().filter((m)=>c.has(m.extensionName)).sort((m,g)=>m.extensionName>g.extensionName?1:-1);if(l.length<e.getRoot().listExtensionsUsed().length)o.warn("Some extensions were not registered for I/O, and will not be written.");for(let m of l){let g=m.prewriteTypes.filter((p)=>!V9.has(p));if(g.length)o.warn(`Prewrite hooks for some types (${g.join()}), requested by extension ${m.extensionName}, are unsupported. Please file an issue or a PR.`);for(let p of m.writeDependencies)m.install(p,t.dependencies[p])}function d(m,g,p,y){let v=[],x=0;for(let E of m){let w=s.createAccessorDef(E);w.bufferView=i.bufferViews.length;let A=E.getArray(),T=Ye.pad(Ye.toView(A));w.byteOffset=x,x+=T.byteLength,v.push(T),s.accessorIndexMap.set(E,i.accessors.length),i.accessors.push(w)}let _={buffer:g,byteOffset:p,byteLength:Ye.concat(v).byteLength};if(y)_.target=y;return i.bufferViews.push(_),{buffers:v,byteLength:x}}function f(m,g,p){let y=m[0].getCount(),v=0;for(let A of m){let T=s.createAccessorDef(A);T.bufferView=i.bufferViews.length,T.byteOffset=v;let N=A.getElementSize(),M=A.getComponentSize();v+=Ye.padNumber(N*M),s.accessorIndexMap.set(A,i.accessors.length),i.accessors.push(T)}let x=y*v,_=new ArrayBuffer(x),E=new DataView(_);for(let A=0;A<y;A++){let T=0;for(let N of m){let M=N.getElementSize(),R=N.getComponentSize(),k=N.getComponentType(),C=N.getArray();for(let U=0;U<M;U++){let D=A*v+T+U*R,P=C[A*M+U];switch(k){case Oe.ComponentType.FLOAT:E.setFloat32(D,P,!0);break;case Oe.ComponentType.BYTE:E.setInt8(D,P);break;case Oe.ComponentType.SHORT:E.setInt16(D,P,!0);break;case Oe.ComponentType.UNSIGNED_BYTE:E.setUint8(D,P);break;case Oe.ComponentType.UNSIGNED_SHORT:E.setUint16(D,P,!0);break;case Oe.ComponentType.UNSIGNED_INT:E.setUint32(D,P,!0);break;case Oe.ComponentType.FLOAT16:E.setFloat16(D,P,!0);break;case Oe.ComponentType.FLOAT64:E.setFloat64(D,P,!0);break;default:throw Error("Unexpected component type: "+k)}}T+=Ye.padNumber(M*R)}}let w={buffer:g,byteOffset:p,byteLength:x,byteStride:v,target:ka.BufferViewTarget.ARRAY_BUFFER};return i.bufferViews.push(w),{byteLength:x,buffers:[new Uint8Array(_)]}}function h(m,g,p){let y=[],v=0,x=new Map,_=-1/0,E=!1;for(let k of m){let C=s.createAccessorDef(k);i.accessors.push(C),s.accessorIndexMap.set(k,i.accessors.length-1);let U=[],D=[],P=[],K=Array(k.getElementSize()).fill(0);for(let le=0,he=k.getCount();le<he;le++){if(k.getElement(le,P),gt.eq(P,K,0))continue;_=Math.max(le,_),U.push(le);for(let xe=0;xe<P.length;xe++)D.push(P[xe])}let z=U.length,W={accessorDef:C,count:z};if(x.set(k,W),z===0)continue;if(z>k.getCount()/2)E=!0;let q=Ol[k.getComponentType()];W.indices=U,W.values=new q(D)}if(!Number.isFinite(_))return{buffers:y,byteLength:v};if(E)o.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let w=_<255?Uint8Array:_<65535?Uint16Array:Uint32Array,A=_<255?j9:_<65535?B9:z9,T={buffer:g,byteOffset:p+v,byteLength:0};for(let k of m){let C=x.get(k);if(C.count===0)continue;C.indicesByteOffset=T.byteLength;let U=Ye.pad(Ye.toView(new w(C.indices)));y.push(U),v+=U.byteLength,T.byteLength+=U.byteLength}i.bufferViews.push(T);let N=i.bufferViews.length-1,M={buffer:g,byteOffset:p+v,byteLength:0};for(let k of m){let C=x.get(k);if(C.count===0)continue;C.valuesByteOffset=M.byteLength;let U=Ye.pad(Ye.toView(C.values));y.push(U),v+=U.byteLength,M.byteLength+=U.byteLength}i.bufferViews.push(M);let R=i.bufferViews.length-1;for(let k of m){let C=x.get(k);if(C.count===0)continue;C.accessorDef.sparse={count:C.count,indices:{bufferView:N,byteOffset:C.indicesByteOffset,componentType:A},values:{bufferView:R,byteOffset:C.valuesByteOffset}}}return{buffers:y,byteLength:v}}if(i.accessors=[],i.bufferViews=[],i.samplers=[],i.textures=[],i.images=r.listTextures().map((m,g)=>{let p=s.createPropertyDef(m);if(m.getMimeType())p.mimeType=m.getMimeType();let y=m.getImage();if(y)s.createImageData(p,y,m);return s.imageIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Accessor")).forEach((m)=>m.prewrite(s,"Accessor")),r.listAccessors().forEach((m)=>{let{accessorUsageGroupedByParent:g,accessorParents:p}=s;if(s.accessorIndexMap.has(m))return;let y=s.getAccessorUsage(m);if(s.addAccessorToUsageGroup(m,y),g.has(y)){let v=n.listParents(m).find((x)=>x.propertyType!=="Root");p.set(m,v)}}),l.filter((m)=>m.prewriteTypes.includes("Buffer")).forEach((m)=>m.prewrite(s,"Buffer")),(r.listAccessors().length>0||s.otherBufferViews.size>0||r.listTextures().length>0&&t.format==="GLB")&&r.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(i.buffers=[],r.listBuffers().forEach((m,g)=>{let p=s.createPropertyDef(m),y=s.accessorUsageGroupedByParent,v=m.listParents().filter((N)=>N instanceof Oe),x=new Set(v.map((N)=>s.accessorParents.get(N))),_=new Map(Array.from(x).map((N,M)=>[N,M])),E={};for(let N of v){if(s.accessorIndexMap.has(N))continue;let M=s.getAccessorUsage(N),R=M;if(y.has(M)){let k=s.accessorParents.get(N);R+=`:${_.get(k)}`}E[R]||={usage:M,accessors:[]},E[R].accessors.push(N)}let w=[],A=i.buffers.length,T=0;for(let{usage:N,accessors:M}of Object.values(E))if(N===ff.ARRAY_BUFFER&&t.vertexLayout==="interleaved"){let R=f(M,A,T);T+=R.byteLength;for(let k of R.buffers)w.push(k)}else if(N===ff.ARRAY_BUFFER)for(let R of M){let k=f([R],A,T);T+=k.byteLength;for(let C of k.buffers)w.push(C)}else if(N===ff.SPARSE){let R=h(M,A,T);T+=R.byteLength;for(let k of R.buffers)w.push(k)}else if(N===ff.ELEMENT_ARRAY_BUFFER){let R=ka.BufferViewTarget.ELEMENT_ARRAY_BUFFER,k=d(M,A,T,R);T+=k.byteLength;for(let C of k.buffers)w.push(C)}else{let R=d(M,A,T);T+=R.byteLength;for(let k of R.buffers)w.push(k)}if(s.imageBufferViews.length&&g===0){for(let N=0;N<s.imageBufferViews.length;N++)if(i.bufferViews[i.images[N].bufferView].byteOffset=T,T+=s.imageBufferViews[N].byteLength,w.push(s.imageBufferViews[N]),T%8){let M=8-T%8;T+=M,w.push(new Uint8Array(M))}}if(s.otherBufferViews.has(m))for(let N of s.otherBufferViews.get(m))i.bufferViews.push({buffer:A,byteOffset:T,byteLength:N.byteLength}),s.otherBufferViewsIndexMap.set(N,i.bufferViews.length-1),T+=N.byteLength,w.push(N);if(T){let N;if(t.format==="GLB")N=La;else N=s.bufferURIGenerator.createURI(m,"bin"),p.uri=N;p.byteLength=T,s.assignResourceURI(N,Ye.concat(w),!0)}i.buffers.push(p),s.bufferIndexMap.set(m,g)}),r.listAccessors().find((m)=>!m.getBuffer()))o.warn("Skipped writing one or more Accessors: no Buffer assigned.");l.filter((m)=>m.prewriteTypes.includes("Material")).forEach((m)=>m.prewrite(s,"Material")),i.materials=r.listMaterials().map((m,g)=>{let p=s.createPropertyDef(m);if(m.getAlphaMode()!==Bs.AlphaMode.OPAQUE)p.alphaMode=m.getAlphaMode();if(m.getAlphaMode()===Bs.AlphaMode.MASK)p.alphaCutoff=m.getAlphaCutoff();if(m.getDoubleSided())p.doubleSided=!0;if(p.pbrMetallicRoughness={},!gt.eq(m.getBaseColorFactor(),[1,1,1,1]))p.pbrMetallicRoughness.baseColorFactor=m.getBaseColorFactor();if(!gt.eq(m.getEmissiveFactor(),[0,0,0]))p.emissiveFactor=m.getEmissiveFactor();if(m.getRoughnessFactor()!==1)p.pbrMetallicRoughness.roughnessFactor=m.getRoughnessFactor();if(m.getMetallicFactor()!==1)p.pbrMetallicRoughness.metallicFactor=m.getMetallicFactor();if(m.getBaseColorTexture()){let y=m.getBaseColorTexture(),v=m.getBaseColorTextureInfo();p.pbrMetallicRoughness.baseColorTexture=s.createTextureInfoDef(y,v)}if(m.getEmissiveTexture()){let y=m.getEmissiveTexture(),v=m.getEmissiveTextureInfo();p.emissiveTexture=s.createTextureInfoDef(y,v)}if(m.getNormalTexture()){let y=m.getNormalTexture(),v=m.getNormalTextureInfo(),x=s.createTextureInfoDef(y,v);if(m.getNormalScale()!==1)x.scale=m.getNormalScale();p.normalTexture=x}if(m.getOcclusionTexture()){let y=m.getOcclusionTexture(),v=m.getOcclusionTextureInfo(),x=s.createTextureInfoDef(y,v);if(m.getOcclusionStrength()!==1)x.strength=m.getOcclusionStrength();p.occlusionTexture=x}if(m.getMetallicRoughnessTexture()){let y=m.getMetallicRoughnessTexture(),v=m.getMetallicRoughnessTextureInfo();p.pbrMetallicRoughness.metallicRoughnessTexture=s.createTextureInfoDef(y,v)}return s.materialIndexMap.set(m,g),p}),l.filter((m)=>m.prewriteTypes.includes("Mesh")).forEach((m)=>m.prewrite(s,"Mesh")),i.meshes=r.listMeshes().map((m,g)=>{let p=s.createPropertyDef(m),y=null;if(p.primitives=m.listPrimitives().map((v)=>{let x={attributes:{}};x.mode=v.getMode();let _=v.getMaterial();if(_)x.material=s.materialIndexMap.get(_);if(Object.keys(v.getExtras()).length)x.extras=v.getExtras();let E=v.getIndices();if(E)x.indices=s.accessorIndexMap.get(E);for(let w of v.listSemantics())x.attributes[w]=s.accessorIndexMap.get(v.getAttribute(w));for(let w of v.listTargets()){let A={};for(let T of w.listSemantics())A[T]=s.accessorIndexMap.get(w.getAttribute(T));x.targets=x.targets||[],x.targets.push(A)}if(v.listTargets().length&&!y)y=v.listTargets().map((w)=>w.getName());return x}),m.getWeights().length)p.weights=m.getWeights();if(y)p.extras=p.extras||{},p.extras.targetNames=y;return s.meshIndexMap.set(m,g),p}),i.cameras=r.listCameras().map((m,g)=>{let p=s.createPropertyDef(m);if(p.type=m.getType(),p.type===mf.Type.PERSPECTIVE){p.perspective={znear:m.getZNear(),zfar:m.getZFar(),yfov:m.getYFov()};let y=m.getAspectRatio();if(y!==null)p.perspective.aspectRatio=y}else p.orthographic={znear:m.getZNear(),zfar:m.getZFar(),xmag:m.getXMag(),ymag:m.getYMag()};return s.cameraIndexMap.set(m,g),p}),i.nodes=r.listNodes().map((m,g)=>{let p=s.createPropertyDef(m);if(!gt.eq(m.getTranslation(),[0,0,0]))p.translation=m.getTranslation();if(!gt.eq(m.getRotation(),[0,0,0,1]))p.rotation=m.getRotation();if(!gt.eq(m.getScale(),[1,1,1]))p.scale=m.getScale();if(m.getWeights().length)p.weights=m.getWeights();return s.nodeIndexMap.set(m,g),p}),i.skins=r.listSkins().map((m,g)=>{let p=s.createPropertyDef(m),y=m.getInverseBindMatrices();if(y)p.inverseBindMatrices=s.accessorIndexMap.get(y);let v=m.getSkeleton();if(v)p.skeleton=s.nodeIndexMap.get(v);return p.joints=m.listJoints().map((x)=>s.nodeIndexMap.get(x)),s.skinIndexMap.set(m,g),p}),r.listNodes().forEach((m,g)=>{let p=i.nodes[g],y=m.getMesh();if(y)p.mesh=s.meshIndexMap.get(y);let v=m.getCamera();if(v)p.camera=s.cameraIndexMap.get(v);let x=m.getSkin();if(x)p.skin=s.skinIndexMap.get(x);if(m.listChildren().length>0)p.children=m.listChildren().map((_)=>s.nodeIndexMap.get(_))}),i.animations=r.listAnimations().map((m,g)=>{let p=s.createPropertyDef(m),y=new Map;return p.samplers=m.listSamplers().map((v,x)=>{let _=s.createPropertyDef(v);return _.input=s.accessorIndexMap.get(v.getInput()),_.output=s.accessorIndexMap.get(v.getOutput()),_.interpolation=v.getInterpolation(),y.set(v,x),_}),p.channels=m.listChannels().map((v)=>{let x=s.createPropertyDef(v);return x.sampler=y.get(v.getSampler()),x.target={node:s.nodeIndexMap.get(v.getTargetNode()),path:v.getTargetPath()},x}),s.animationIndexMap.set(m,g),p}),i.scenes=r.listScenes().map((m,g)=>{let p=s.createPropertyDef(m);return p.nodes=m.listChildren().map((y)=>s.nodeIndexMap.get(y)),s.sceneIndexMap.set(m,g),p});let b=r.getDefaultScene();if(b)i.scene=r.listScenes().indexOf(b);return i.extensionsUsed=l.map((m)=>m.extensionName),i.extensionsRequired=u.map((m)=>m.extensionName),l.forEach((m)=>m.write(s)),H9(i),a}},$9=class{_logger=js.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=!0;lastReadBytes=0;lastWriteBytes=0;setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let n=nM(t)?this._binaryToJSON(t):{json:JSON.parse(Ye.decodeText(t)),resources:{}};return await this._readResourcesExternal(n,this.dirname(e)),this._readResourcesInternal(n),n}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),L9.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(Ye.assertView(e));this._readResourcesInternal(t);let n=t.json;if(n.buffers&&n.buffers.some((r)=>K9(t,r)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(n.images&&n.images.some((r)=>W9(t,r)))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(Ye.assertView(e)))}async writeJSON(e,t={}){if(t.format==="GLB"&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return G9.write(e,{format:t.format||"GLTF",basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:n}=await this.writeJSON(e,{format:"GLB"}),r=new Uint32Array([1179937895,2,12]),i=JSON.stringify(t),a=Ye.pad(Ye.encodeText(i),32),s=Ye.toView(new Uint32Array([a.byteLength,1313821514])),o=Ye.concat([s,a]);r[r.length-1]+=o.byteLength;let c=Object.values(n)[0];if(!c||!c.byteLength)return Ye.concat([Ye.toView(r),o]);let l=Ye.pad(c,0),u=Ye.toView(new Uint32Array([l.byteLength,5130562])),d=Ye.concat([u,l]);return r[r.length-1]+=d.byteLength,Ye.concat([Ye.toView(r),o,d])}async _readResourcesExternal(e,t){let n=e.json.images||[],r=e.json.buffers||[],i=[...n,...r].map(async(a)=>{let s=a.uri;if(!s||s.match(/data:/))return Promise.resolve();try{e.resources[s]=await this.readURI(this.resolve(t,s),"view"),this.lastReadBytes+=e.resources[s].byteLength}catch(o){if(!this._strictResources&&n.includes(a))this._logger.warn(`Failed to load image URI, "${s}". ${o}`),e.resources[s]=null;else throw o}});await Promise.all(i)}_readResourcesInternal(e){function t(n){if(!n.uri)return;if(n.uri in e.resources){Ye.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){let r=`__${lM()}.${zs.extension(n.uri)}`;e.resources[r]=Ye.createBufferFromDataURI(n.uri),n.uri=r}}(e.json.images||[]).forEach((n)=>{if(n.bufferView===void 0&&n.uri===void 0)throw Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:n}=e.json;if(e={json:{...e.json},resources:{...e.resources}},t)e.json.images=t.map((r)=>({...r}));if(n)e.json.buffers=n.map((r)=>({...r}));return e}_binaryToJSON(e){if(!nM(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==1313821514)throw Error("Missing required GLB JSON chunk.");let n=20,r=t[0],i=Ye.decodeText(Ye.toView(e,n,r)),a=JSON.parse(i),s=n+r;if(e.byteLength<=s)return{json:a,resources:{}};let o=new Uint32Array(e.buffer,e.byteOffset+s,2);if(o[1]!==5130562)return{json:a,resources:{}};let c=o[0],l=Ye.toView(e,s+8,c);return{json:a,resources:{[La]:l}}}},pM;var nc=ot(()=>{Jw();Q=function(e){return e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo",e}({}),u9=function(e){return e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE",e}({}),Rr=function(e){return e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A",e}({}),iM=function(e){return e.GLTF="GLTF",e.GLB="GLB",e}({}),d9=class extends Float32Array{constructor(){super();throw Error("Unsupported typed array instantiation.")}},Ol={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5131":typeof Float16Array<"u"?Float16Array:d9,"5126":Float32Array,"5130":Float64Array},Kr=class{static impls={"image/jpeg":new f9,"image/png":new h9};static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){if(!this.impls[t])return null;return this.impls[t].getSize(e)}static getChannels(e,t){if(!this.impls[t])return null;return this.impls[t].getChannels(e)}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let n=0,r=4,i=this.getSize(e,t);if(!i)return null;while(i[0]>1||i[1]>1)n+=i[0]*i[1]*r,i[0]=Math.max(Math.floor(i[0]/2),1),i[1]=Math.max(Math.floor(i[1]/2),1);return n+=4,n}static mimeTypeToExtension(e){if(e==="image/jpeg")return"jpg";return e.split("/").pop()}static extensionToMimeType(e){if(e==="jpg")return"image/jpeg";if(!e)return"";return`image/${e}`}};Wg=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;(function(){var e=m9();return function(t,n,r,i,a,s){var o,c;if(!n)n=3;if(!r)r=0;if(i)c=Math.min(i*n+r,t.length);else c=t.length;for(o=r;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],a(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();Kg=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.substring(0,t+1)}static basename(e){return zs.basename(new URL(e,Zw).pathname)}static extension(e){return zs.extension(new URL(e,Zw).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let n=e.split("/"),r=t.split("/");n.pop();for(let i=0;i<r.length;i++){if(r[i]===".")continue;if(r[i]==="..")n.pop();else n.push(r[i])}return n.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}};x9=function(e){return e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG",e}({}),js=class e{verbosity;static Verbosity=x9;static DEFAULT_INSTANCE=new e(1);constructor(t){this.verbosity=t}debug(t){if(this.verbosity<=0)console.debug(t)}info(t){if(this.verbosity<=1)console.info(t)}warn(t){if(this.verbosity<=2)console.warn(t)}error(t){if(this.verbosity<=3)console.error(t)}};Qw=new Set,C9=new Set,Jg=class extends qw{constructor(e,t=""){super(e);this[Tt].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){if(Array.isArray(t))t=t.slice();return super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,Da)}copy(e,t=Da){for(let n in this[Tt]){let r=this[Tt][n];if(r instanceof Oa){if(!this[Pa].has(n))r.dispose()}else if(r instanceof xn||r instanceof Ct)for(let i of r.values())i.dispose();else if(r instanceof dn)for(let i of r.values())i.dispose()}for(let n in e[Tt]){let r=this[Tt][n],i=e[Tt][n];if(i instanceof Oa)if(this[Pa].has(n))r.getChild().copy(t(i.getChild()),t);else this.setRef(n,t(i.getChild()),i.getAttributes());else if(i instanceof Ct||i instanceof xn)for(let a of i.values())this.addRef(n,t(a.getChild()),a.getAttributes());else if(i instanceof dn)for(let a of i.keys()){let s=i.get(a);this.setRefMap(n,a,t(s.getChild()),s.getAttributes())}else if(Us(i))this[Tt][n]=JSON.parse(JSON.stringify(i));else if(Array.isArray(i)||i instanceof ArrayBuffer||ArrayBuffer.isView(i))this[Tt][n]=i.slice();else this[Tt][n]=i}return this}equals(e,t=C9){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let n in this[Tt]){if(t.has(n))continue;let r=this[Tt][n],i=e[Tt][n];if(r instanceof Oa||i instanceof Oa){if(!A9(r,i))return!1}else if(r instanceof Ct||i instanceof Ct||r instanceof xn||i instanceof xn){if(!T9(r,i))return!1}else if(r instanceof dn||i instanceof dn){if(!w9(r,i))return!1}else if(Us(r)||Us(i)){if(!cM(r,i))return!1}else if(pf(r)||pf(i)){if(!oM(r,i))return!1}else if(r!==i)return!1}return!0}detach(){return this.graph.disconnectParents(this,(e)=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},Kn=class extends Jg{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new dn})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){if(t)t._validateParent(this);return this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}},Oe=class e extends Kn{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor"}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:e.Type.SCALAR,componentType:e.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(t){switch(t){case e.Type.SCALAR:return 1;case e.Type.VEC2:return 2;case e.Type.VEC3:return 3;case e.Type.VEC4:return 4;case e.Type.MAT2:return 4;case e.Type.MAT3:return 9;case e.Type.MAT4:return 16;default:throw Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case e.ComponentType.BYTE:case e.ComponentType.UNSIGNED_BYTE:return 1;case e.ComponentType.SHORT:case e.ComponentType.UNSIGNED_SHORT:return 2;case e.ComponentType.UNSIGNED_INT:case e.ComponentType.FLOAT:return 4;case e.ComponentType.FLOAT16:return 2;case e.ComponentType.FLOAT64:return 8;default:throw Error("Unexpected component type: "+t)}}getMinNormalized(t){let n=this.getNormalized(),r=this.getElementSize(),i=this.getComponentType();if(this.getMin(t),n)for(let a=0;a<r;a++)t[a]=gt.decodeNormalizedInt(t[a],i);return t}getMin(t){let n=this.getArray(),r=this.getCount(),i=this.getElementSize();for(let a=0;a<i;a++)t[a]=1/0;for(let a=0;a<r*i;a+=i)for(let s=0;s<i;s++){let o=n[a+s];if(Number.isFinite(o))t[s]=Math.min(t[s],o)}return t}getMaxNormalized(t){let n=this.getNormalized(),r=this.getElementSize(),i=this.getComponentType();if(this.getMax(t),n)for(let a=0;a<r;a++)t[a]=gt.decodeNormalizedInt(t[a],i);return t}getMax(t){let n=this.get("array"),r=this.getCount(),i=this.getElementSize();for(let a=0;a<i;a++)t[a]=-1/0;for(let a=0;a<r*i;a+=i)for(let s=0;s<i;s++){let o=n[a+s];if(Number.isFinite(o))t[s]=Math.max(t[s],o)}return t}getCount(){let t=this.get("array");return t?t.length/this.getElementSize():0}getType(){return this.get("type")}setType(t){return this.set("type",t)}getElementSize(){return e.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(t){return this.set("normalized",t)}getScalar(t){let n=this.getElementSize(),r=this.getComponentType(),i=this.getArray();if(this.getNormalized())return gt.decodeNormalizedInt(i[t*n],r);return i[t*n]}setScalar(t,n){let r=this.getElementSize(),i=this.getComponentType(),a=this.getArray();if(this.getNormalized())a[t*r]=gt.encodeNormalizedInt(n,i);else a[t*r]=n;return this}getElement(t,n){let r=this.getNormalized(),i=this.getElementSize(),a=this.getComponentType(),s=this.getArray();for(let o=0;o<i;o++)if(r)n[o]=gt.decodeNormalizedInt(s[t*i+o],a);else n[o]=s[t*i+o];return n}setElement(t,n){let r=this.getNormalized(),i=this.getElementSize(),a=this.getComponentType(),s=this.getArray();for(let o=0;o<i;o++)if(r)s[t*i+o]=gt.encodeNormalizedInt(n[o],a);else s[t*i+o]=n[o];return this}getSparse(){return this.get("sparse")}setSparse(t){return this.set("sparse",t)}getBuffer(){return this.getRef("buffer")}setBuffer(t){return this.setRef("buffer",t)}getArray(){return this.get("array")}setArray(t){return this.set("componentType",t?N9(t):e.ComponentType.FLOAT),this.set("array",t),this}getByteLength(){let t=this.get("array");return t?t.byteLength:0}};uM=class extends Kn{init(){this.propertyType="Animation"}getDefaults(){return Object.assign(super.getDefaults(),{channels:new Ct,samplers:new Ct})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}},Vs=class extends Kn{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel"}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}},kl=class e extends Kn{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler"}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:e.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(t){return this.set("interpolation",t)}getInput(){return this.getRef("input")}setInput(t){return this.setRef("input",t,{usage:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(t){return this.setRef("output",t,{usage:"OTHER"})}},dM=class extends Kn{init(){this.propertyType="Buffer"}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}},mf=class e extends Kn{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera"}getDefaults(){return Object.assign(super.getDefaults(),{type:e.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(t){return this.set("type",t)}getZNear(){return this.get("znear")}setZNear(t){return this.set("znear",t)}getZFar(){return this.get("zfar")}setZFar(t){return this.set("zfar",t)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(t){return this.set("aspectRatio",t)}getYFov(){return this.get("yfov")}setYFov(t){return this.set("yfov",t)}getXMag(){return this.get("xmag")}setXMag(t){return this.set("xmag",t)}getYMag(){return this.get("ymag")}setYMag(t){return this.set("ymag",t)}},rt=class extends Jg{static EXTENSION_NAME;_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}},Mt=class e extends Kn{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo"}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:e.WrapMode.REPEAT,wrapT:e.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(t){return this.set("texCoord",t)}getMagFilter(){return this.get("magFilter")}setMagFilter(t){return this.set("magFilter",t)}getMinFilter(){return this.get("minFilter")}setMinFilter(t){return this.set("minFilter",t)}getWrapS(){return this.get("wrapS")}setWrapS(t){return this.set("wrapS",t)}getWrapT(){return this.get("wrapT")}setWrapT(t){return this.set("wrapT",t)}},{R:lf,G:uf,B:df,A:P9}=Rr,Bs=class e extends Kn{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material"}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:e.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new Mt(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new Mt(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new Mt(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new Mt(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new Mt(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(t){return this.set("doubleSided",t)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(t){let n=this.get("baseColorFactor").slice();return n[3]=t,this.set("baseColorFactor",n)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(t){return this.set("alphaMode",t)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(t){return this.set("alphaCutoff",t)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(t){return this.set("baseColorFactor",t)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(t){return this.setRef("baseColorTexture",t,{channels:lf|uf|df|P9,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(t){return this.set("emissiveFactor",t)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(t){return this.setRef("emissiveTexture",t,{channels:lf|uf|df,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(t){return this.set("normalScale",t)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(t){return this.setRef("normalTexture",t,{channels:lf|uf|df})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(t){return this.set("occlusionStrength",t)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(t){return this.setRef("occlusionTexture",t,{channels:lf})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(t){return this.set("roughnessFactor",t)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(t){return this.set("metallicFactor",t)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(t){return this.setRef("metallicRoughnessTexture",t,{channels:uf|df})}},Zg=class extends Kn{init(){this.propertyType="Mesh"}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new Ct})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}},gf=class extends Kn{init(){this.propertyType="Node"}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new Ct})}copy(e,t=Da){if(t===Da)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return gt.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),n=this.get("rotation").slice(),r=this.get("scale").slice();return gt.decompose(e,t,n,r),this.set("translation",t).set("rotation",n).set("scale",r)}getWorldTranslation(){let e=[0,0,0];return gt.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return gt.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return gt.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e=[];for(let r=this;r!=null;r=r.getParentNode())e.push(r);let t,n=e.pop().getMatrix();while(t=e.pop())_9(n,n,t.getMatrix());return n}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);for(let n of e.listParents())if(n.propertyType==="Scene")n.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType==="Node")return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(let t of this.listChildren())t.traverse(e);return this}},Qn=class e extends Kn{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive"}getDefaults(){return Object.assign(super.getDefaults(),{mode:e.Mode.TRIANGLES,material:null,indices:null,attributes:new dn,targets:new Ct})}getIndices(){return this.getRef("indices")}setIndices(t){return this.setRef("indices",t,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(t){return this.getRefMap("attributes",t)}setAttribute(t,n){return this.setRefMap("attributes",t,n,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(t){return this.setRef("material",t)}getMode(){return this.get("mode")}setMode(t){return this.set("mode",t)}listTargets(){return this.listRefs("targets")}addTarget(t){return this.addRef("targets",t)}removeTarget(t){return this.removeRef("targets",t)}},Yg=class extends Jg{init(){this.propertyType="PrimitiveTarget"}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},bf=class extends Kn{init(){this.propertyType="Scene"}getDefaults(){return Object.assign(super.getDefaults(),{children:new Ct})}copy(e,t=Da){if(t===Da)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();if(t)t.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}},fM=class extends Kn{init(){this.propertyType="Skin"}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new Ct})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:"INVERSE_BIND_MATRICES"})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}},tc=class extends Kn{init(){this.propertyType="Texture"}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||Kr.extensionToMimeType(zs.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=Kr.extensionToMimeType(zs.extension(e));if(t)this.set("mimeType",t);return this}getImage(){return this.get("image")}setImage(e){return this.set("image",Ye.assertView(e))}getSize(){let e=this.get("image");if(!e)return null;return Kr.getSize(e,this.getMimeType())}},Fa=class extends Kn{_extensions=new Set;init(){this.propertyType="Root"}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${rM}`,version:"2.0"},defaultScene:null,accessors:new Ct,animations:new Ct,buffers:new Ct,cameras:new Ct,materials:new Ct,meshes:new Ct,nodes:new Ct,scenes:new Ct,skins:new Ct,textures:new Ct})}constructor(e){super(e);e.addEventListener("node:create",(t)=>{this._addChildOfRoot(t.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=Da){if(t===Da)throw Error("Root cannot be copied.");this.set("asset",{...e.get("asset")}),this.setName(e.getName()),this.setExtras({...e.getExtras()}),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(let n of e.listRefMapKeys("extensions")){let r=e.getExtension(n);this.setExtension(n,t(r))}return this}_addChildOfRoot(e){if(e instanceof bf)this.addRef("scenes",e);else if(e instanceof gf)this.addRef("nodes",e);else if(e instanceof mf)this.addRef("cameras",e);else if(e instanceof fM)this.addRef("skins",e);else if(e instanceof Zg)this.addRef("meshes",e);else if(e instanceof Bs)this.addRef("materials",e);else if(e instanceof tc)this.addRef("textures",e);else if(e instanceof uM)this.addRef("animations",e);else if(e instanceof Oe)this.addRef("accessors",e);else if(e instanceof dM)this.addRef("buffers",e);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((e)=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}},xf=class e{_graph=new Hg;_root=new Fa(this._graph);_logger=js.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(t){return e._GRAPH_DOCUMENTS.get(t)||null}constructor(){e._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(t){return this._logger=t,this}clone(){throw Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(t){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...t){let n=t.map((r)=>r.name);for(let r of t)await r(this,{stack:n});return this}hasExtension(t){return this.getRoot().listExtensionsUsed().some((n)=>n.extensionName===t)}createExtension(t){let n=t.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((r)=>r.extensionName===n)||new t(this)}disposeExtension(t){let n=this.getRoot().listExtensionsUsed().find((r)=>r.extensionName===t);if(n)n.dispose()}createScene(t=""){return new bf(this._graph,t)}createNode(t=""){return new gf(this._graph,t)}createCamera(t=""){return new mf(this._graph,t)}createSkin(t=""){return new fM(this._graph,t)}createMesh(t=""){return new Zg(this._graph,t)}createPrimitive(){return new Qn(this._graph)}createPrimitiveTarget(t=""){return new Yg(this._graph,t)}createMaterial(t=""){return new Bs(this._graph,t)}createTexture(t=""){return new tc(this._graph,t)}createAnimation(t=""){return new uM(this._graph,t)}createAnimationChannel(t=""){return new Vs(this._graph,t)}createAnimationSampler(t=""){return new kl(this._graph,t)}createAccessor(t="",n=null){if(!n)n=this.getRoot().listBuffers()[0];return new Oe(this._graph,t).setBuffer(n)}createBuffer(t=""){return new dM(this._graph,t)}},eM={logger:js.DEFAULT_INSTANCE,extensions:[],dependencies:{}},k9=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]);hM=function(e){return e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e}(hM||{}),ka=class{_doc;jsonDoc;options;static BufferViewTarget=hM;static BufferViewUsage=u9;static USAGE_TO_TARGET={["ARRAY_BUFFER"]:34962,["ELEMENT_ARRAY_BUFFER"]:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(e,t,n){this._doc=e,this.jsonDoc=t,this.options=n;let r=e.getRoot(),i=r.listBuffers().length,a=r.listTextures().length;this.bufferURIGenerator=new tM(i>1,()=>n.basename||"buffer"),this.imageURIGenerator=new tM(a>1,(s)=>U9(e,s)||n.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let n={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},r=JSON.stringify(n);if(!this.samplerDefIndexMap.has(r))this.samplerDefIndexMap.set(r,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(n);let i={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(r)},a=JSON.stringify(i);if(!this.textureDefIndexMap.has(a))this.textureDefIndexMap.set(a,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(i);let s={index:this.textureDefIndexMap.get(a)};if(t.getTexCoord()!==0)s.texCoord=t.getTexCoord();if(Object.keys(t.getExtras()).length>0)s.extras=t.getExtras();return this.textureInfoDefMap.set(t,s),s}createPropertyDef(e){let t={};if(e.getName())t.name=e.getName();if(Object.keys(e.getExtras()).length>0)t.extras=e.getExtras();return t}createAccessorDef(e){let t=this.createPropertyDef(e);if(t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some((n)=>n.getName()==="attributes"&&n.getAttributes().key==="POSITION"||n.getName()==="input"))t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround);if(e.getNormalized())t.normalized=e.getNormalized();return t}createImageData(e,t,n){if(this.options.format==="GLB")this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let r=Kr.mimeTypeToExtension(n.getMimeType());e.uri=this.imageURIGenerator.createURI(n,r),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,n){let r=this.jsonDoc.resources;if(!(e in r)){r[e]=t;return}if(t===r[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}let i=`Resource URI "${e}" already assigned to different data.`;if(!n){this.logger.warn(i);return}throw Error(i)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return"SPARSE";for(let n of this._doc.getGraph().listParentEdges(e)){let{usage:r}=n.getAttributes();if(r)return r;if(n.getParent().propertyType!=="Root")this.logger.warn(`Missing attribute ".usage" on edge, "${n.getName()}".`)}return"OTHER"}addAccessorToUsageGroup(e,t){let n=this._accessorUsageMap.get(e);if(n&&n!==t)throw Error(`Accessor with usage "${n}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}};({BufferViewUsage:ff}=ka),{UNSIGNED_INT:z9,UNSIGNED_SHORT:B9,UNSIGNED_BYTE:j9}=Oe.ComponentType,V9=new Set(["Accessor","Buffer","Material","Mesh"]);pM=class extends $9{_fetchConfig;constructor(e=Kg.DEFAULT_INIT){super();this._fetchConfig=e}async readURI(e,t){let n=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await n.arrayBuffer());case"text":return n.text()}}resolve(e,t){return Kg.resolve(e,t)}dirname(e){return Kg.dirname(e)}}});function X9(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class rc{constructor(e,t,n,r){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=r,this._offset=0}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),n=e+4294967296*t;return this._offset+=8,n}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let n=this._offset,r=0;while(this._dataView.getUint8(this._offset)!==t&&r<e)r++,this._offset++;if(r<e)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)}}function mM(e){return new TextDecoder().decode(e)}function yf(e){let t=new Uint8Array(e.buffer,e.byteOffset,Wn.length);if(t[0]!==Wn[0]||t[1]!==Wn[1]||t[2]!==Wn[2]||t[3]!==Wn[3]||t[4]!==Wn[4]||t[5]!==Wn[5]||t[6]!==Wn[6]||t[7]!==Wn[7]||t[8]!==Wn[8]||t[9]!==Wn[9]||t[10]!==Wn[10]||t[11]!==Wn[11])throw Error("Missing KTX 2.0 identifier.");let n=X9(),r=17*Uint32Array.BYTES_PER_ELEMENT,i=new rc(e,Wn.length,r,!0);n.vkFormat=i._nextUint32(),n.typeSize=i._nextUint32(),n.pixelWidth=i._nextUint32(),n.pixelHeight=i._nextUint32(),n.pixelDepth=i._nextUint32(),n.layerCount=i._nextUint32(),n.faceCount=i._nextUint32(),n.levelCount=i._nextUint32(),n.supercompressionScheme=i._nextUint32();let a=i._nextUint32(),s=i._nextUint32(),o=i._nextUint32(),c=i._nextUint32(),l=i._nextUint64(),u=i._nextUint64(),d=Math.max(n.levelCount,1)*3*8,f=new rc(e,Wn.length+r,d,!0);for(let re=0,ce=Math.max(n.levelCount,1);re<ce;re++)n.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});let h=new rc(e,a,s,!0);h._skip(4);let b=h._nextUint16(),m=h._nextUint16(),g=h._nextUint16(),p=h._nextUint16(),y=h._nextUint8(),v=h._nextUint8(),x=h._nextUint8(),_=h._nextUint8(),E=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],w=[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],T={vendorId:b,descriptorType:m,versionNumber:g,colorModel:y,colorPrimaries:v,transferFunction:x,flags:_,texelBlockDimension:E,bytesPlane:w,samples:[]},N=6,M=4,R=(p/4-N)/M;for(let re=0;re<R;re++){let ce={bitOffset:h._nextUint16(),bitLength:h._nextUint8(),channelType:h._nextUint8(),samplePosition:[h._nextUint8(),h._nextUint8(),h._nextUint8(),h._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(ce.channelType&64)ce.sampleLower=h._nextInt32(),ce.sampleUpper=h._nextInt32();else ce.sampleLower=h._nextUint32(),ce.sampleUpper=h._nextUint32();T.samples[re]=ce}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(T);let k=new rc(e,o,c,!0);while(k._offset<c){let re=k._nextUint32(),ce=k._scan(re),ve=mM(ce);if(n.keyValue[ve]=k._nextUint8Array(re-ce.byteLength-1),ve.match(/^ktx/i)){let ke=mM(n.keyValue[ve]);n.keyValue[ve]=ke.substring(0,ke.lastIndexOf("\x00"))}let Re=re%4?4-re%4:0;k._skip(Re)}if(u<=0)return n;let C=new rc(e,l,u,!0),U=C._nextUint16(),D=C._nextUint16(),P=C._nextUint32(),K=C._nextUint32(),z=C._nextUint32(),W=C._nextUint32(),q=[];for(let re=0,ce=Math.max(n.levelCount,1);re<ce;re++)q.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let le=l+C._offset,he=le+P,xe=he+K,pe=xe+z,J=new Uint8Array(e.buffer,e.byteOffset+le,P),F=new Uint8Array(e.buffer,e.byteOffset+he,K),X=new Uint8Array(e.buffer,e.byteOffset+xe,z),ne=new Uint8Array(e.buffer,e.byteOffset+pe,W);return n.globalData={endpointCount:U,selectorCount:D,imageDescs:q,endpointsData:J,selectorsData:F,tablesData:X,extendedData:ne},n}var gM=0,bM=163,xM=166,Qg=0,yM=123,_M=1000066000,l$,Wn;var vM=ot(()=>{l$=new Uint8Array([0]),Wn=[171,75,84,88,32,50,48,187,13,10,26,10]});function t2(e,t,n,r){let i=t.createFeatureID().setFeatureCount(r.featureCount);if(r.nullFeatureId!==void 0)i.setNullFeatureID(r.nullFeatureId);if(r.label!==void 0)i.setLabel(r.label);if(r.attribute!==void 0)i.setAttribute(r.attribute);let a=r.texture;if(a!==void 0){let s=n2(t,n,a);i.setTexture(s)}if(r.propertyTable!==void 0){let s=e.getRoot().getExtension(tt).listPropertyTables();i.setPropertyTable(s[r.propertyTable])}return i}function n2(e,t,n){let r=e.createFeatureIDTexture(),{json:i}=t.jsonDoc;if(n.channels)r.setChannels(n.channels);if(n.index!==void 0){let a=i.textures[n.index].source;r.setTexture(t.textures[a]),t.setTextureInfo(r.getTextureInfo(),n)}return r}function r2(e,t,n){let r=e.getRoot(),i={featureCount:n.getFeatureCount()};if(n.getNullFeatureID()!=null)i.nullFeatureId=n.getNullFeatureID();if(n.getLabel())i.label=n.getLabel();if(n.getAttribute()!=null)i.attribute=n.getAttribute();if(n.getTexture()){let a=n.getTexture(),s=a.getTexture(),o=a.getTextureInfo();i.texture=t.createTextureInfoDef(s,o);let c=a.getChannels();if(!gt.eq(c,[0]))i.texture.channels=c}if(n.getPropertyTable()){let a=r.getExtension(tt),s=n.getPropertyTable();i.propertyTable=a.listPropertyTables().indexOf(s)}return i}function s2(e){if(!e.extensions||!e.extensions.EXT_meshopt_compression)return!1;return!!e.extensions[er].fallback}function l2(e,t,n,r){let{filter:i,bits:a}=r,s={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(n!=="ATTRIBUTES")return s;if(i!=="NONE"){let o=e.getNormalized()?u2(e):new Float32Array(s.array);switch(i){case"EXPONENTIAL":s.byteStride=e.getElementSize()*4,s.componentType=c2,s.normalized=!1,s.array=t.encodeFilterExp(o,e.getCount(),s.byteStride,a);break;case"OCTAHEDRAL":s.byteStride=a>8?8:4,s.componentType=a>8?TM:o2,s.normalized=!0,o=e.getElementSize()===3?f2(o):o,s.array=t.encodeFilterOct(o,e.getCount(),s.byteStride,a);break;case"QUATERNION":s.byteStride=8,s.componentType=TM,s.normalized=!0,s.array=t.encodeFilterQuat(o,e.getCount(),s.byteStride,a);break;default:throw Error("Invalid filter.")}if(s.min=e.getMin([]),s.max=e.getMax([]),e.getNormalized())s.min=s.min.map((c)=>rb(c,e.getComponentType())),s.max=s.max.map((c)=>rb(c,e.getComponentType()));if(s.normalized)s.min=s.min.map((c)=>wM(c,s.componentType)),s.max=s.max.map((c)=>wM(c,s.componentType))}else if(s.byteStride%4)s.array=d2(s.array,e.getElementSize()),s.byteStride=s.array.byteLength/e.getCount();return s}function u2(e){let t=e.getComponentType(),n=e.getArray(),r=new Float32Array(n.length);for(let i=0;i<n.length;i++)r[i]=rb(n[i],t);return r}function d2(e,t){let n=Ye.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,r=e.length/t,i=new e.constructor(r*n);for(let a=0;a*t<e.length;a++)for(let s=0;s<t;s++)i[a*n+s]=e[a*t+s];return i}function f2(e){let t=new Float32Array(e.length*4/3);for(let n=0,r=e.length/3;n<r;n++)t[n*4]=e[n*3],t[n*4+1]=e[n*3+1],t[n*4+2]=e[n*3+2];return t}function h2(e,t){if(t===ka.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return e.listParents().some((n)=>n instanceof Qn&&n.getMode()===Qn.Mode.TRIANGLES)?"TRIANGLES":"INDICES";return"ATTRIBUTES"}function p2(e,t){let n=t.getGraph().listParentEdges(e).filter((r)=>!(r.getParent()instanceof Fa));for(let r of n){let i=r.getName(),a=r.getAttributes().key||"",s=r.getParent().propertyType===Q.PRIMITIVE_TARGET;if(i==="indices")return{filter:"NONE"};if(i==="attributes"){if(a==="POSITION")return{filter:"NONE"};if(a==="TEXCOORD_0")return{filter:"NONE"};if(a.startsWith("JOINTS_"))return{filter:"NONE"};if(a.startsWith("WEIGHTS_"))return{filter:"NONE"};if(a==="NORMAL"||a==="TANGENT")return s?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(i==="output"){let o=jM(e);if(o==="rotation")return{filter:"QUATERNION",bits:16};if(o==="translation")return{filter:"EXPONENTIAL",bits:12};if(o==="scale")return{filter:"EXPONENTIAL",bits:12};return{filter:"NONE"}}if(i==="input")return{filter:"NONE"};if(i==="inverseBindMatrices")return{filter:"NONE"}}return{filter:"NONE"}}function jM(e){for(let t of e.listParents()){if(!(t instanceof kl))continue;for(let n of t.listParents()){if(!(n instanceof Vs))continue;return n.getTargetPath()}}return null}function C2(e,t,n){let r=e.createStructuralMetadata();if(n.schema!==void 0){let o=N2(e,n.schema);r.setSchema(o)}else if(n.schemaUri){let o=n.schemaUri;r.setSchemaUri(o)}let i=n.propertyTextures||[];for(let o of i){let c=D2(e,t,o);r.addPropertyTexture(c)}let a=n.propertyTables||[];for(let o of a){let c=U2(e,t,o);r.addPropertyTable(c)}let s=n.propertyAttributes||[];for(let o of s){let c=B2(e,o);r.addPropertyAttribute(c)}return r}function N2(e,t){let n=e.createSchema().setId(t.id);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.version!==void 0)n.setVersion(t.version);let r=t.classes||{};for(let a of Object.keys(r)){let s=r[a];n.setClass(a,P2(e,s))}let i=t.enums||{};for(let a of Object.keys(i))n.setEnum(a,k2(e,i[a]));return n}function P2(e,t){let n=e.createClass();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);let r=t.properties||{};for(let i of Object.keys(r)){let a=O2(e,r[i]);n.setProperty(i,a)}return n}function O2(e,t){let n=e.createClassProperty().setType(t.type);if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.componentType!==void 0)n.setComponentType(t.componentType);if(t.enumType!==void 0)n.setEnumType(t.enumType);if(t.array!==void 0)n.setArray(t.array);if(t.count!==void 0)n.setCount(t.count);if(t.normalized!==void 0)n.setNormalized(t.normalized);if(t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);if(t.required!==void 0)n.setRequired(t.required);if(t.noData!==void 0)n.setNoData(t.noData);if(t.default!==void 0)n.setDefault(t.default);return n}function k2(e,t){let n=e.createEnum();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.valueType!==void 0)n.setValueType(t.valueType);let r=t.values||{};for(let i of r)n.addEnumValue(L2(e,i));return n}function L2(e,t){let n=e.createEnumValue();if(t.name!==void 0)n.setName(t.name);if(t.description!==void 0)n.setDescription(t.description);if(t.value!==void 0)n.setValue(t.value);return n}function D2(e,t,n){let r=e.createPropertyTexture();if(r.setClass(n.class),n.name!==void 0)r.setName(n.name);let i=n.properties||{};for(let a of Object.keys(i)){let s=F2(e,t,i[a]);r.setProperty(a,s)}return r}function F2(e,t,n){let r=e.createPropertyTextureProperty(),i=t.jsonDoc.json.textures||[];if(n.channels)r.setChannels(n.channels);let a=i[n.index].source;if(a!==void 0){let s=t.textures[a];r.setTexture(s);let o=r.getTextureInfo();if(o)t.setTextureInfo(o,n)}if(n.offset!==void 0)r.setOffset(n.offset);if(n.scale!==void 0)r.setScale(n.scale);if(n.max!==void 0)r.setMax(n.max);if(n.min!==void 0)r.setMin(n.min);return r}function U2(e,t,n){let r=e.createPropertyTable().setClass(n.class).setCount(n.count);if(n.name!==void 0)r.setName(n.name);let i=n.properties||{};for(let a of Object.keys(i)){let s=z2(e,t,i[a]);r.setProperty(a,s)}return r}function z2(e,t,n){let r=e.createPropertyTableProperty(),i=eb(t,n.values);if(r.setValues(i),n.arrayOffsets!==void 0){let a=eb(t,n.arrayOffsets);r.setArrayOffsets(a)}if(n.stringOffsets!==void 0){let a=eb(t,n.stringOffsets);r.setStringOffsets(a)}if(n.arrayOffsetType!==void 0)r.setArrayOffsetType(n.arrayOffsetType);if(n.stringOffsetType!==void 0)r.setStringOffsetType(n.stringOffsetType);if(n.offset!==void 0)r.setOffset(n.offset);if(n.scale!==void 0)r.setScale(n.scale);if(n.max!==void 0)r.setMax(n.max);if(n.min!==void 0)r.setMin(n.min);return r}function B2(e,t){let n=e.createPropertyAttribute();if(n.setClass(t.class),t.name!==void 0)n.setName(t.name);let r=t.properties||{};for(let i of Object.keys(r)){let a=j2(e,r[i]);n.setProperty(i,a)}return n}function j2(e,t){let n=e.createPropertyAttributeProperty();if(n.setAttribute(t.attribute),t.offset!==void 0)n.setOffset(t.offset);if(t.scale!==void 0)n.setScale(t.scale);if(t.max!==void 0)n.setMax(t.max);if(t.min!==void 0)n.setMin(t.min);return n}function V2(e,t){let n={},r=t.getSchema();if(r)n.schema=G2(r);let i=t.getSchemaUri();if(i)n.schemaUri=i;let a=t.listPropertyTables();if(a.length>0){let c=[];for(let l of a){let u=X2(e,l);c.push(u)}n.propertyTables=c}let s=t.listPropertyTextures();if(s.length>0){let c=[];for(let l of s){let u=Y2(e,l);c.push(u)}n.propertyTextures=c}let o=t.listPropertyAttributes();if(o.length>0){let c=[];for(let l of o){let u=J2(l);c.push(u)}n.propertyAttributes=c}return n}function G2(e){let t={id:e.getId()},n=e.listClassKeys();if(n.length>0){t.classes={};for(let i of n){let a=H2(e.getClass(i));t.classes[i]=a}}let r=e.listEnumKeys();if(r.length>0){t.enums={};for(let i of r){let a=K2(e.getEnum(i));t.enums[i]=a}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getVersion())t.version=e.getVersion();return t}function H2(e){let t={},n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let r of n){let i=e.getProperty(r);t.properties[r]=$2(i)}}if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();return t}function $2(e){let t={type:e.getType()};if(e.getArray())t.array=e.getArray();if(e.getNormalized())t.normalized=e.getNormalized();if(e.getRequired())t.required=e.getRequired();if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getComponentType()!=null)t.componentType=e.getComponentType();if(e.getEnumType()!=null)t.enumType=e.getEnumType();if(e.getCount()!=null)t.count=e.getCount();if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();if(e.getNoData()!=null)t.noData=e.getNoData();if(e.getDefault()!=null)t.default=e.getDefault();return t}function K2(e){let t={values:e.listValues().map(W2)};if(e.getName())t.name=e.getName();if(e.getDescription())t.description=e.getDescription();if(e.getValueType()!=="UINT16")t.valueType=e.getValueType();return t}function W2(e){let t={name:e.getName(),value:e.getValue()};if(e.getDescription())t.description=e.getDescription();return t}function X2(e,t){let n={class:t.getClass(),count:t.getCount()};if(t.getName())n.name=t.getName();let r=t.listPropertyKeys();if(r.length>0){n.properties={};for(let i of r){let a=q2(e,t.getProperty(i));n.properties[i]=a}}return n}function q2(e,t){let n=t.getValues(),r={values:e.otherBufferViewsIndexMap.get(n)};if(t.getArrayOffsets()){let i=t.getArrayOffsets();r.arrayOffsets=e.otherBufferViewsIndexMap.get(i)}if(t.getStringOffsets()){let i=t.getStringOffsets();r.stringOffsets=e.otherBufferViewsIndexMap.get(i)}if(t.getArrayOffsetType()!=null)r.arrayOffsetType=t.getArrayOffsetType();if(t.getStringOffsetType()!=null)r.stringOffsetType=t.getStringOffsetType();if(t.getOffset()!=null)r.offset=t.getOffset();if(t.getScale()!=null)r.scale=t.getScale();if(t.getMax()!=null)r.max=t.getMax();if(t.getMin()!=null)r.min=t.getMin();return r}function J2(e){let t={class:e.getClass()};if(e.getName())t.name=e.getName();let n=e.listPropertyKeys();if(n.length>0){t.properties={};for(let r of n){let i=Z2(e.getProperty(r));t.properties[r]=i}}return t}function Z2(e){let t={attribute:e.getAttribute()};if(e.getOffset()!=null)t.offset=e.getOffset();if(e.getScale()!=null)t.scale=e.getScale();if(e.getMax()!=null)t.max=e.getMax();if(e.getMin()!=null)t.min=e.getMin();return t}function Y2(e,t){let n={class:t.getClass()};if(t.getName())n.name=t.getName();let r=t.listPropertyKeys();if(r.length>0){n.properties={};for(let i of r){let a=Q2(e,t.getProperty(i));n.properties[i]=a}}return n}function Q2(e,t){let n=t.getTexture(),r=t.getTextureInfo(),i=t.getChannels(),a=e.createTextureInfoDef(n,r);if(!gt.eq(i,[0]))a.channels=i;if(t.getOffset()!=null)a.offset=t.getOffset();if(t.getScale()!=null)a.scale=t.getScale();if(t.getMax()!=null)a.max=t.getMax();if(t.getMin()!=null)a.min=t.getMin();return a}function eb(e,t){let n=e.jsonDoc,r=n.json.buffers||[],i=(n.json.bufferViews||[])[t],a=r[i.buffer],s=a.uri?n.resources[a.uri]:n.resources[La],o=i.byteOffset||0,c=i.byteLength;return s.slice(o,o+c)}function eF(e,t){let n=e.getRoot().listBuffers()[0],r=t.otherBufferViews.get(n);if(!r)r=[],t.otherBufferViews.set(n,r);return r}function SM(e,t){if(e.byteLength<4+t)return null;let n=e.getUint32(t);if(e.byteLength<n+t||n<8)return null;return{type:Ye.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+n}}function aF(e,t){let n=new yn.DecoderBuffer;try{if(n.Init(t,t.length),e.GetEncodedGeometryType(n)!==yn.TRIANGULAR_MESH)throw Error(`[${tn}] Unknown geometry type.`);let r=new yn.Mesh;if(!e.DecodeBufferToMesh(n,r).ok()||r.ptr===0)throw Error(`[${tn}] Decoding failure.`);return r}finally{yn.destroy(n)}}function sF(e,t){let n=t.num_faces()*3,r,i;if(t.num_points()<=65534){let a=n*Uint16Array.BYTES_PER_ELEMENT;r=yn._malloc(a),e.GetTrianglesUInt16Array(t,a,r),i=new Uint16Array(yn.HEAPU16.buffer,r,n).slice()}else{let a=n*Uint32Array.BYTES_PER_ELEMENT;r=yn._malloc(a),e.GetTrianglesUInt32Array(t,a,r),i=new Uint32Array(yn.HEAPU32.buffer,r,n).slice()}return yn._free(r),i}function oF(e,t,n,r){let i=$M[r.componentType],a=HM[r.componentType],s=n.num_components(),o=t.num_points()*s,c=o*a.BYTES_PER_ELEMENT,l=yn._malloc(c);e.GetAttributeDataArrayForAllPoints(t,n,i,c,l);let u=new a(yn.HEAPF32.buffer,l,o).slice();return yn._free(l),u}function cF(e){yn=e,HM={[Oe.ComponentType.FLOAT]:Float32Array,[Oe.ComponentType.UNSIGNED_INT]:Uint32Array,[Oe.ComponentType.UNSIGNED_SHORT]:Uint16Array,[Oe.ComponentType.UNSIGNED_BYTE]:Uint8Array,[Oe.ComponentType.SHORT]:Int16Array,[Oe.ComponentType.BYTE]:Int8Array},$M={[Oe.ComponentType.FLOAT]:yn.DT_FLOAT32,[Oe.ComponentType.UNSIGNED_INT]:yn.DT_UINT32,[Oe.ComponentType.UNSIGNED_SHORT]:yn.DT_UINT16,[Oe.ComponentType.UNSIGNED_BYTE]:yn.DT_UINT8,[Oe.ComponentType.SHORT]:yn.DT_INT16,[Oe.ComponentType.BYTE]:yn.DT_INT8}}function uF(e){Ir=e}function dF(e,t=CM){let n={...CM,...t};n.quantizationBits={...KM,...t.quantizationBits};let r=new Ir.MeshBuilder,i=new Ir.Mesh,a=new Ir.ExpertEncoder(i),s={},o=new Ir.DracoInt8Array,c=e.listTargets().length>0,l=!1;for(let m of e.listSemantics()){let g=e.getAttribute(m);if(g.getSparse()){l=!0;continue}let p=fF(m),y=hF(r,g.getComponentType(),i,Ir[p],g.getCount(),g.getElementSize(),g.getArray());if(y===-1)throw Error(`Error compressing "${m}" attribute.`);if(s[m]=y,n.quantizationVolume==="mesh"||m!=="POSITION")a.SetAttributeQuantization(y,n.quantizationBits[p]);else if(typeof n.quantizationVolume==="object"){let{quantizationVolume:v}=n,x=Math.max(v.max[0]-v.min[0],v.max[1]-v.min[1],v.max[2]-v.min[2]);a.SetAttributeExplicitQuantization(y,n.quantizationBits[p],g.getElementSize(),v.min,x)}else throw Error("Invalid quantization volume state.")}let u=e.getIndices();if(!u)throw new ib("Primitive must have indices.");if(r.AddFacesToMesh(i,u.getCount()/3,u.getArray()),a.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),a.SetTrackEncodedProperties(!0),n.method===0||c||l)a.SetEncodingMethod(Ir.MESH_SEQUENTIAL_ENCODING);else a.SetEncodingMethod(Ir.MESH_EDGEBREAKER_ENCODING);let d=a.EncodeToDracoBuffer(!(c||l),o);if(d<=0)throw new ib("Error applying Draco compression.");let f=new Uint8Array(d);for(let m=0;m<d;++m)f[m]=o.GetValue(m);let h=a.GetNumberOfEncodedPoints(),b=a.GetNumberOfEncodedFaces()*3;return Ir.destroy(o),Ir.destroy(i),Ir.destroy(r),Ir.destroy(a),{numVertices:h,numIndices:b,data:f,attributeIDs:s}}function fF(e){if(e==="POSITION")return"POSITION";else if(e==="NORMAL")return"NORMAL";else if(e.startsWith("COLOR_"))return"COLOR";else if(e.startsWith("TEXCOORD_"))return"TEX_COORD";return"GENERIC"}function hF(e,t,n,r,i,a,s){switch(t){case Oe.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(n,r,i,a,s);case Oe.ComponentType.BYTE:return e.AddInt8Attribute(n,r,i,a,s);case Oe.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(n,r,i,a,s);case Oe.ComponentType.SHORT:return e.AddInt16Attribute(n,r,i,a,s);case Oe.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(n,r,i,a,s);case Oe.ComponentType.FLOAT:return e.AddFloatAttribute(n,r,i,a,s);default:throw Error(`Unexpected component type, "${t}".`)}}function pF(e){let t=e.getLogger(),n=new Set,r=new Set,i=0,a=0;for(let d of e.getRoot().listMeshes())for(let f of d.listPrimitives())if(!f.getIndices())r.add(f),i++;else if(f.getMode()!==Qn.Mode.TRIANGLES)r.add(f),a++;else n.add(f);if(i>0)t.warn(`[${tn}] Skipping Draco compression of ${i} non-indexed primitives.`);if(a>0)t.warn(`[${tn}] Skipping Draco compression of ${a} non-TRIANGLES primitives.`);let s=e.getRoot().listAccessors(),o=new Map;for(let d=0;d<s.length;d++)o.set(s[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(n)){let f=NM(d,o);if(l.has(f)){u.set(d,f);continue}if(c.has(d.getIndices())){let h=d.getIndices(),b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}for(let h of d.listAttributes())if(c.has(h)){let b=h.clone();o.set(b,e.getRoot().listAccessors().length-1),d.swap(h,b)}f=NM(d,o),l.add(f),u.set(d,f),c.set(d.getIndices(),f);for(let h of d.listAttributes())c.set(h,f)}for(let d of Array.from(c.keys())){let f=new Set(d.listParents().map((h)=>h.propertyType));if(f.size!==2||!f.has(Q.PRIMITIVE)||!f.has(Q.ROOT))throw Error(`[${tn}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(n)){let f=u.get(d),h=d.getIndices();if(c.get(h)!==f||d.listAttributes().some((b)=>c.get(b)!==f))throw Error(`[${tn}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(r)){let f=d.getIndices();if(c.has(f)||d.listAttributes().some((h)=>c.has(h)))throw Error(`[${tn}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function NM(e,t){let n=[],r=e.getIndices();n.push(t.get(r));for(let i of e.listAttributes())n.push(t.get(i));return n.sort().join("|")}function lU(e){return e.vkFormat>Qg&&e.vkFormat<=yM}function BM(e){let t=e.vkFormat===_M&&e.dataFormatDescriptor[0].colorModel===167;return e.vkFormat===Qg||t}function tb(e){return JSON.parse(JSON.stringify(e))}var Ua="EXT_mesh_gpu_instancing",qi="EXT_mesh_features",er="EXT_meshopt_compression",tt="EXT_structural_metadata",_f="EXT_texture_webp",vf="EXT_texture_avif",q9="KHR_accessor_float16",J9="KHR_accessor_float64",tn="KHR_draco_mesh_compression",Xi="KHR_lights_punctual",za="KHR_materials_anisotropy",Ba="KHR_materials_clearcoat",ja="KHR_materials_diffuse_transmission",Va="KHR_materials_dispersion",Ga="KHR_materials_emissive_strength",Ha="KHR_materials_ior",$a="KHR_materials_iridescence",Ka="KHR_materials_pbrSpecularGlossiness",Wa="KHR_materials_sheen",Xa="KHR_materials_specular",qa="KHR_materials_transmission",ic="KHR_materials_unlit",Ja="KHR_materials_volume",br="KHR_materials_variants",EM="KHR_mesh_primitive_restart",AM="KHR_mesh_quantization",Za="KHR_node_visibility",Ef="KHR_texture_basisu",Ya="KHR_texture_transform",Wr="KHR_xmp_json_ld",Z9,Y9,Q9,Ll,e2,nb="INSTANCE_ATTRIBUTE",i2,Af,a2,o2,TM,c2,wM,rb,MM,Dl,m2,g2,b2,x2,y2,_2,v2,E2,A2,T2,w2,M2,S2,R2,I2,tF=class{match(e){return e.length>=12&&Ye.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=SM(t,0);if(!n)return null;let r=n.end;while(n=SM(t,r))if(n.type==="meta")r=n.start+4;else if(n.type==="iprp"||n.type==="ipco")r=n.start;else if(n.type==="ispe")return[t.getUint32(n.start+4),t.getUint32(n.start+8)];else if(n.type==="mdat")break;else r=n.end;return null}getChannels(e){return 4}},VM,nF=class{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){let t=Ye.decodeText(e.slice(0,4)),n=Ye.decodeText(e.slice(8,12));if(t!=="RIFF"||n!=="WEBP")return null;let r=new DataView(e.buffer,e.byteOffset),i=12;while(i<r.byteLength){let a=Ye.decodeText(new Uint8Array([r.getUint8(i),r.getUint8(i+1),r.getUint8(i+2),r.getUint8(i+3)])),s=r.getUint32(i+4,!0);if(a==="VP8 ")return[r.getInt16(i+14,!0)&16383,r.getInt16(i+16,!0)&16383];else if(a==="VP8L"){let o=r.getUint8(i+9),c=r.getUint8(i+10),l=r.getUint8(i+11),u=r.getUint8(i+12);return[1+((c&63)<<8|o),1+((u&15)<<10|l<<2|(c&192)>>6)]}i+=8+s+s%2}return null}getChannels(e){return 4}},GM,RM,rF,IM,iF,yn,HM,$M,Ir,lF,KM,CM,ib,WM,PM,mF,gF,bF,xF,yF,_F,OM,kM,vF,EF,AF,TF,wF,MF,SF,RF,IF,CF,NF,PF,OF,kF,XM,LF,DF,FF,UF,LM,DM,FM,UM,zF,qM,BF,jF,VF,GF,HF,$F,KF,WF,XF,qF,JF,JM,ZF,YF,QF,eU,ZM,tU,nU,zM,rU,iU,aU,sU,YM,Fl,oU,cU,uU=class{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){let t=yf(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){let t=yf(e),n=t.dataFormatDescriptor[0];if(lU(t))return n.samples.length;if(BM(t))switch(n.colorModel){case bM:return n.samples.length===2&&(n.samples[1].channelType&15)===15?4:3;case xM:return(n.samples[0].channelType&15)===3?4:3;default:throw Error(`Unexpected KTX2 colorModel, "${n.colorModel}".`)}throw Error(`Unexpected KTX2 vkFormat, "${t.vkFormat}".`)}getVRAMByteLength(e){let t=yf(e),n=0;if(BM(t)){let r=this.getChannels(e)>3;for(let i=0;i<t.levels.length;i++){let a=t.levels[i];if(a.uncompressedByteLength)n+=a.uncompressedByteLength;else{let s=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,i))),o=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,i))),c=r?16:8;n+=s/4*(o/4)*c}}}else for(let r of t.levels)if(t.supercompressionScheme===gM)n+=r.levelData.byteLength;else n+=r.uncompressedByteLength;return n}},ab,dU,fU,hU,pU,mU,gU,QM;var Tf=ot(()=>{nc();vM();Z9=class extends rt{static EXTENSION_NAME=qi;init(){this.extensionName=qi,this.propertyType="FeatureID",this.parentTypes=["Features"]}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(e){return this.set("featureCount",e)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(e){return this.set("nullFeatureId",e)}getLabel(){return this.get("label")}setLabel(e){return this.set("label",e)}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(e){return this.setRef("propertyTable",e)}},Y9=class extends rt{static EXTENSION_NAME=qi;init(){this.extensionName=qi,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"]}getDefaults(){let e=new Mt(this.graph,"textureInfo");return e.setMinFilter(Mt.MagFilter.NEAREST),e.setMagFilter(Mt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},Q9=class extends rt{static EXTENSION_NAME=qi;init(){this.extensionName=qi,this.propertyType="Features",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new Ct([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(e){return this.addRef("featureIds",e)}removeFeatureID(e){return this.removeRef("featureIds",e)}},Ll=qi,e2=class extends _t{extensionName=qi;static EXTENSION_NAME=qi;createFeatures(){return new Q9(this.document.getGraph())}createFeatureID(){return new Z9(this.document.getGraph())}createFeatureIDTexture(){return new Y9(this.document.getGraph())}read(e){return(e.jsonDoc.json.meshes||[]).forEach((t,n)=>{(t.primitives||[]).forEach((r,i)=>{this._readPrimitive(e,n,r,i)})}),this}_readPrimitive(e,t,n,r){if(!n.extensions||!n.extensions[Ll])return;let i=this.createFeatures(),a=n.extensions[Ll];for(let s of a.featureIds){let o=t2(this.document,this,e,s);i.addFeatureID(o)}e.meshes[t].listPrimitives()[r].setExtension(Ll,i)}write(e){let t=e.jsonDoc.json.meshes;if(!t)return this;for(let n of this.document.getRoot().listMeshes()){let r=t[e.meshIndexMap.get(n)];n.listPrimitives().forEach((i,a)=>{let s=r.primitives[a];this._writePrimitive(e,i,s)})}return this}_writePrimitive(e,t,n){let r=t.getExtension(Ll);if(!r)return;let i={featureIds:[]};r.listFeatureIDs().forEach((a)=>{i.featureIds.push(r2(this.document,e,a))}),n.extensions=n.extensions||{},n.extensions[Ll]=i}};i2=class extends rt{static EXTENSION_NAME=Ua;init(){this.extensionName=Ua,this.propertyType="InstancedMesh",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new dn})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:nb})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},Af=class extends _t{static EXTENSION_NAME=Ua;extensionName=Ua;prewriteTypes=[Q.ACCESSOR];createInstancedMesh(){return new i2(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions.EXT_mesh_gpu_instancing)return;let r=t.extensions[Ua],i=this.createInstancedMesh();for(let a in r.attributes)i.setAttribute(a,e.accessors[r.attributes[a]]);e.nodes[n].setExtension(Ua,i)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(nb);for(let t of this.properties)for(let n of t.listAttributes())e.addAccessorToUsageGroup(n,nb);return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listNodes().forEach((n)=>{let r=n.getExtension(Ua);if(r){let i=e.nodeIndexMap.get(n),a=t.json.nodes[i],s={attributes:{}};r.listSemantics().forEach((o)=>{let c=r.getAttribute(o);s.attributes[o]=e.accessorIndexMap.get(c)}),a.extensions=a.extensions||{},a.extensions[Ua]=s}}),this}},a2=function(e){return e.QUANTIZE="quantize",e.FILTER="filter",e}({});({BYTE:o2,SHORT:TM,FLOAT:c2}=Oe.ComponentType),{encodeNormalizedInt:wM,decodeNormalizedInt:rb}=gt;MM={method:"quantize"},Dl=class extends _t{extensionName=er;prereadTypes=[Q.BUFFER,Q.PRIMITIVE];prewriteTypes=[Q.BUFFER,Q.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=er;static EncoderMethod=a2;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=MM;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(e,t){if(e==="meshopt.decoder")this._decoder=t;if(e==="meshopt.encoder")this._encoder=t;return this}setEncoderOptions(e){return this._encoderOptions={...MM,...e},this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${er}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${er}]: Missing WASM support.`)}if(t===Q.BUFFER)this._prereadBuffers(e);else if(t===Q.PRIMITIVE)this._prereadPrimitives(e);return this}_prereadBuffers(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n,r)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let i=n.extensions[er],a=i.byteOffset||0,s=i.byteLength||0,{count:o,byteStride:c}=i,l=new Uint8Array(o*c),u=t.json.buffers[i.buffer],d=u.uri?t.resources[u.uri]:t.resources[La],f=Ye.toView(d,a,s);this._decoder.decodeGltfBuffer(l,o,c,f,i.mode,i.filter),e.bufferViews[r]=l})}_prereadPrimitives(e){let t=e.jsonDoc;(t.json.bufferViews||[]).forEach((n)=>{if(!n.extensions||!n.extensions.EXT_meshopt_compression)return;let r=n.extensions[er],i=e.buffers[r.buffer],a=e.buffers[n.buffer],s=t.json.buffers[n.buffer];if(s2(s))this._decoderFallbackBufferMap.set(a,i)})}read(e){if(!this.isRequired())return this;for(let[t,n]of this._decoderFallbackBufferMap){for(let r of t.listParents())if(r instanceof Oe)r.swap(t,n);t.dispose()}return this}prewrite(e,t){if(t===Q.ACCESSOR)this._prewriteAccessors(e);else if(t===Q.BUFFER)this._prewriteBuffers(e);return this}_prewriteAccessors(e){let t=e.jsonDoc.json,n=this._encoder,r=this._encoderOptions,i=this.document.getGraph(),a=this.document.createBuffer(),s=this.document.getRoot().listBuffers().indexOf(a),o=1,c=new Map,l=(u)=>{for(let d of i.listParents(u)){if(d.propertyType===Q.ROOT)continue;let f=c.get(u);if(f===void 0)c.set(u,f=o++);return f}return-1};this._encoderFallbackBuffer=a,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(jM(u)==="weights")continue;if(u.getSparse())continue;let d=e.getAccessorUsage(u),f=e.accessorUsageGroupedByParent.has(d)?l(u):null,h=h2(u,d),b=r.method==="filter"?p2(u,this.document):{filter:"NONE"},m=l2(u,n,h,b),{array:g,byteStride:p}=m,y=u.getBuffer();if(!y)throw Error(`${er}: Missing buffer for accessor.`);let v=this.document.getRoot().listBuffers().indexOf(y),x=[d,f,h,b.filter,p,v].join(":"),_=this._encoderBufferViews[x],E=this._encoderBufferViewData[x],w=this._encoderBufferViewAccessors[x];if(!_||!E)w=this._encoderBufferViewAccessors[x]=[],E=this._encoderBufferViewData[x]=[],_=this._encoderBufferViews[x]={buffer:s,target:ka.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===ka.BufferViewUsage.ARRAY_BUFFER?p:void 0,extensions:{[er]:{buffer:v,byteOffset:0,byteLength:0,mode:h,filter:b.filter!=="NONE"?b.filter:void 0,byteStride:p,count:0}}};let A=e.createAccessorDef(u);if(A.componentType=m.componentType,A.normalized=m.normalized,A.byteOffset=_.byteLength,A.min&&m.min)A.min=m.min;if(A.max&&m.max)A.max=m.max;e.accessorIndexMap.set(u,t.accessors.length),t.accessors.push(A),w.push(A),E.push(new Uint8Array(g.buffer,g.byteOffset,g.byteLength)),_.byteLength+=g.byteLength,_.extensions.EXT_meshopt_compression.count+=u.getCount()}}_prewriteBuffers(e){let t=this._encoder;for(let n in this._encoderBufferViews){let r=this._encoderBufferViews[n],i=this._encoderBufferViewData[n],a=this.document.getRoot().listBuffers()[r.extensions[er].buffer],s=e.otherBufferViews.get(a)||[],{count:o,byteStride:c,mode:l}=r.extensions[er],u=Ye.concat(i),d=t.encodeGltfBuffer(u,o,c,l),f=Ye.pad(d);r.extensions[er].byteLength=d.byteLength,i.length=0,i.push(f),s.push(f),e.otherBufferViews.set(a,s)}}write(e){let t=0;for(let a in this._encoderBufferViews){let s=this._encoderBufferViews[a],o=this._encoderBufferViewData[a][0],c=e.otherBufferViewsIndexMap.get(o),l=this._encoderBufferViewAccessors[a];for(let h of l)h.bufferView=c;let u=e.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,s),u.byteOffset=t;let f=u.extensions[er];f.byteOffset=d,t+=Ye.padNumber(s.byteLength)}let n=this._encoderFallbackBuffer,r=e.bufferIndexMap.get(n),i=e.jsonDoc.json.buffers[r];return i.byteLength=t,i.extensions={[er]:{fallback:!0}},n.dispose(),this}},m2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="StructuralMetadata",this.parentTypes=[Q.ROOT]}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new xn,propertyTextures:new xn,propertyAttributes:new xn})}getSchema(){return this.getRef("schema")}setSchema(e){return this.setRef("schema",e)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(e){return this.set("schemaUri",e)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(e){return this.addRef("propertyTables",e)}removePropertyTable(e){return this.removeRef("propertyTables",e)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},g2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new dn,enums:new dn})}getId(){return this.get("id")}setId(e){return this.set("id",e)}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getVersion(){return this.get("version")}setVersion(e){return this.set("version",e)}setClass(e,t){return this.setRefMap("classes",e,t)}getClass(e){return this.getRefMap("classes",e)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(e,t){return this.setRefMap("enums",e,t)}getEnum(e){return this.getRefMap("enums",e)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},b2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="Class",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new dn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},x2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="ClassProperty",this.parentTypes=["Class"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getComponentType(){return this.get("componentType")}setComponentType(e){return this.set("componentType",e)}getEnumType(){return this.get("enumType")}setEnumType(e){return this.set("enumType",e)}getArray(){return this.get("array")}setArray(e){return this.set("array",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}getRequired(){return this.get("required")}setRequired(e){return this.set("required",e)}getNoData(){return this.get("noData")}setNoData(e){return this.set("noData",e)}getDefault(){return this.get("default")}setDefault(e){return this.set("default",e)}},y2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="Enum",this.parentTypes=["Schema"]}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new xn})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValueType(){return this.get("valueType")}setValueType(e){return this.set("valueType",e)}listValues(){return this.listRefs("values")}addEnumValue(e){return this.addRef("values",e)}removeEnumValue(e){return this.removeRef("values",e)}},_2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="EnumValue",this.parentTypes=["Enum"]}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(e){return this.set("description",e)}getValue(){return this.get("value")}setValue(e){return this.set("value",e)}},v2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getCount(){return this.get("count")}setCount(e){return this.set("count",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},E2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"]}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(e){return this.set("values",e)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(e){return this.set("arrayOffsets",e)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(e){return this.set("stringOffsets",e)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(e){return this.set("arrayOffsetType",e)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(e){return this.set("stringOffsetType",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},A2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},T2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"]}getDefaults(){let e=new Mt(this.graph,"textureInfo");return e.setMinFilter(Mt.MagFilter.NEAREST),e.setMagFilter(Mt.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:e,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(e){return this.set("channels",e)}getTexture(){return this.getRef("texture")}setTexture(e){return this.setRef("texture",e)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},w2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"]}getDefaults(){return Object.assign(super.getDefaults(),{properties:new dn})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}setProperty(e,t){return this.setRefMap("properties",e,t)}getProperty(e){return this.getRefMap("properties",e)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},M2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"]}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(e){return this.set("attribute",e)}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getMax(){return this.get("max")}setMax(e){return this.set("max",e)}getMin(){return this.get("min")}setMin(e){return this.set("min",e)}},S2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="NodeStructuralMetadata",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(e){return this.set("class",e)}getProperties(){return this.get("properties")}setProperties(e){return this.set("properties",e)}},R2=class extends rt{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new xn,propertyAttributes:new xn})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(e){return this.addRef("propertyTextures",e)}removePropertyTexture(e){return this.removeRef("propertyTextures",e)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(e){return this.addRef("propertyAttributes",e)}removePropertyAttribute(e){return this.removeRef("propertyAttributes",e)}},I2=class extends _t{extensionName=tt;static EXTENSION_NAME=tt;prewriteTypes=[Q.BUFFER];prereadTypes=[Q.SCENE];createStructuralMetadata(){return new m2(this.document.getGraph())}createSchema(){return new g2(this.document.getGraph())}createClass(){return new b2(this.document.getGraph())}createClassProperty(){return new x2(this.document.getGraph())}createEnum(){return new y2(this.document.getGraph())}createEnumValue(){return new _2(this.document.getGraph())}createPropertyTable(){return new v2(this.document.getGraph())}createPropertyTableProperty(){return new E2(this.document.getGraph())}createPropertyTexture(){return new A2(this.document.getGraph())}createPropertyTextureProperty(){return new T2(this.document.getGraph())}createPropertyAttribute(){return new w2(this.document.getGraph())}createPropertyAttributeProperty(){return new M2(this.document.getGraph())}createNodeStructuralMetadata(){return new S2(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new R2(this.document.getGraph())}read(e){return this}preread(e){let t=this.document.getRoot(),{json:n}=e.jsonDoc,r=n.extensions[tt],i=C2(this,e,r);return t.setExtension(tt,i),(n.meshes||[]).forEach((a,s)=>{let o=e.meshes[s].listPrimitives();(a.primitives||[]).forEach((c,l)=>{let u=o[l];this._readPrimitive(i,u,c)})}),(n.nodes||[]).forEach((a,s)=>{this._readNode(e.nodes[s],a)}),this}_readPrimitive(e,t,n){if(!n.extensions||!n.extensions.EXT_structural_metadata)return;let r=this.createMeshPrimitiveStructuralMetadata(),i=n.extensions[tt],a=e.listPropertyTextures(),s=i.propertyTextures||[];for(let l of s){let u=a[l];r.addPropertyTexture(u)}let o=e.listPropertyAttributes(),c=i.propertyAttributes||[];for(let l of c){let u=o[l];r.addPropertyAttribute(u)}t.setExtension(tt,r)}_readNode(e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let n=t.extensions[tt],r=this.createNodeStructuralMetadata().setClass(n.class).setProperties(n.properties);e.setExtension(tt,r)}write(e){let t=this.document.getRoot(),n=t.getExtension(tt);if(!n)return this;let r=e.jsonDoc.json,i=V2(e,n);r.extensions=r.extensions||{},r.extensions[tt]=i;let a=t.listMeshes(),s=r.meshes;if(s)for(let l of a){let u=s[e.meshIndexMap.get(l)];l.listPrimitives().forEach((d,f)=>{let h=u.primitives[f];this._writePrimitive(n,d,h)})}let o=t.listNodes(),c=r.nodes;if(c)for(let l of o){let u=e.nodeIndexMap.get(l);this._writeNode(l,c[u])}return this}_writePrimitive(e,t,n){let r=t.getExtension(tt);if(!r)return;let i=e.listPropertyTextures(),a=e.listPropertyAttributes(),s,o,c=r.listPropertyTextures();if(c.length>0){s=[];for(let d of c){let f=i.indexOf(d);if(f>=0)s.push(f);else throw Error(`${tt}: Invalid property texture in mesh primitive`)}}let l=r.listPropertyAttributes();if(l.length>0){o=[];for(let d of l){let f=a.indexOf(d);if(f>=0)o.push(f);else throw Error(`${tt}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:s,propertyAttributes:o};n.extensions=n.extensions||{},n.extensions[tt]=u}_writeNode(e,t){let n=e.getExtension("EXT_structural_metadata");if(!n)return;t.extensions=t.extensions||{},t.extensions[tt]={class:n.getClass(),properties:n.getProperties()}}prewrite(e,t){if(t===Q.BUFFER)this._prewriteBuffers(e);return this}_prewriteBuffers(e){let t=this.document,n=t.getRoot().getExtension(tt);e.jsonDoc.json.bufferViews||=[];for(let r of n.listPropertyTables())for(let i of r.listPropertyValues()){let a=eF(t,e);a.push(i.getValues());let s=i.getArrayOffsets();if(s)a.push(s);let o=i.getStringOffsets();if(o)a.push(o)}}};VM=class extends _t{extensionName=vf;prereadTypes=[Q.TEXTURE];static EXTENSION_NAME=vf;static register(){Kr.registerFormat("image/avif",new tF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_avif)t.source=t.extensions[vf].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/avif"){let r=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((i)=>{if(i.source===r)i.extensions=i.extensions||{},i.extensions[vf]={source:i.source},delete i.source})}}),this}};GM=class extends _t{extensionName=_f;prereadTypes=[Q.TEXTURE];static EXTENSION_NAME=_f;static register(){Kr.registerFormat("image/webp",new nF)}preread(e){return(e.jsonDoc.json.textures||[]).forEach((t)=>{if(t.extensions&&t.extensions.EXT_texture_webp)t.source=t.extensions[_f].source}),this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/webp"){let r=e.imageIndexMap.get(n);(t.json.textures||[]).forEach((i)=>{if(i.source===r)i.extensions=i.extensions||{},i.extensions[_f]={source:i.source},delete i.source})}}),this}},RM=q9,rF=class extends _t{extensionName=RM;static EXTENSION_NAME=RM;read(e){return this}write(e){return this}},IM=J9,iF=class extends _t{extensionName=IM;static EXTENSION_NAME=IM;read(e){return this}write(e){return this}};lF=function(e){return e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL",e}({}),KM={["POSITION"]:14,["NORMAL"]:10,["COLOR"]:8,["TEX_COORD"]:12,["GENERIC"]:12},CM={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:KM,quantizationVolume:"mesh"};ib=class extends Error{},WM=class extends _t{extensionName=tn;prereadTypes=[Q.PRIMITIVE];prewriteTypes=[Q.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=tn;static EncoderMethod=lF;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(e,t){if(e==="draco3d.decoder")this._decoderModule=t,cF(this._decoderModule);if(e==="draco3d.encoder")this._encoderModule=t,uF(this._encoderModule);return this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.decoder".`);let t=this.document.getLogger(),n=e.jsonDoc,r=new Map;try{let i=n.json.meshes||[];for(let a of i)for(let s of a.primitives){if(!s.extensions||!s.extensions.KHR_draco_mesh_compression)continue;let o=s.extensions[tn],[c,l]=r.get(o.bufferView)||[];if(!l||!c){let u=n.json.bufferViews[o.bufferView],d=n.json.buffers[u.buffer],f=d.uri?n.resources[d.uri]:n.resources[La],h=u.byteOffset||0,b=u.byteLength,m=Ye.toView(f,h,b);c=new this._decoderModule.Decoder,l=aF(c,m),r.set(o.bufferView,[c,l]),t.debug(`[${tn}] Decompressed ${m.byteLength} bytes.`)}for(let u in o.attributes){let d=e.jsonDoc.json.accessors[s.attributes[u]],f=c.GetAttributeByUniqueId(l,o.attributes[u]),h=oF(c,l,f,d);e.accessors[s.attributes[u]].setArray(h)}if(s.indices!==void 0)e.accessors[s.indices].setArray(sF(c,l))}}finally{for(let[i,a]of Array.from(r.values()))this._decoderModule.destroy(i),this._decoderModule.destroy(a)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw Error(`[${tn}] Please install extension dependency, "draco3d.encoder".`);let n=this.document.getLogger();n.debug(`[${tn}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let r=pF(this.document),i=new Map,a="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)n.warn(`[${tn}]: quantizationVolume=scene requires exactly 1 scene.`);else a=qg(this.document.getRoot().listScenes().pop());for(let s of Array.from(r.keys())){let o=r.get(s);if(!o)throw Error("Unexpected primitive.");if(i.has(o)){i.set(o,i.get(o));continue}let c=s.getIndices(),l=e.jsonDoc.json.accessors,u;try{u=dF(s,{...this._encoderOptions,quantizationVolume:a})}catch(h){if(h instanceof ib){n.warn(`[${tn}]: ${h.message} Skipping primitive compression.`);continue}throw h}i.set(o,u);let d=e.createAccessorDef(c);if(d.count=u.numIndices,e.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&Oe.getComponentSize(d.componentType)<=2)d.componentType=Oe.ComponentType.UNSIGNED_INT;else if(u.numVertices>254&&Oe.getComponentSize(d.componentType)<=1)d.componentType=Oe.ComponentType.UNSIGNED_SHORT;for(let h of s.listSemantics()){let b=s.getAttribute(h);if(u.attributeIDs[h]===void 0)continue;let m=e.createAccessorDef(b);m.count=u.numVertices,e.accessorIndexMap.set(b,l.length),l.push(m)}let f=s.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!e.otherBufferViews.has(f))e.otherBufferViews.set(f,[]);e.otherBufferViews.get(f).push(u.data)}return n.debug(`[${tn}] Compressed ${r.size} primitives.`),e.extensionData[tn]={primitiveHashMap:r,primitiveEncodingMap:i},this}write(e){let t=e.extensionData[tn];for(let n of this.document.getRoot().listMeshes()){let r=e.jsonDoc.json.meshes[e.meshIndexMap.get(n)];for(let i=0;i<n.listPrimitives().length;i++){let a=n.listPrimitives()[i],s=r.primitives[i],o=t.primitiveHashMap.get(a);if(!o)continue;let c=t.primitiveEncodingMap.get(o);if(!c)continue;s.extensions=s.extensions||{},s.extensions[tn]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){let n=e.jsonDoc.json;n.extensionsUsed=(n.extensionsUsed||[]).filter((r)=>r!==tn),n.extensionsRequired=(n.extensionsRequired||[]).filter((r)=>r!==tn)}return this}};PM=class e extends rt{static EXTENSION_NAME=Xi;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Xi,this.propertyType="Light",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:e.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(t){return this.set("color",t)}getIntensity(){return this.get("intensity")}setIntensity(t){return this.set("intensity",t)}getType(){return this.get("type")}setType(t){return this.set("type",t)}getRange(){return this.get("range")}setRange(t){return this.set("range",t)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(t){return this.set("innerConeAngle",t)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(t){return this.set("outerConeAngle",t)}},mF=class extends _t{extensionName=Xi;static EXTENSION_NAME=Xi;createLight(e=""){return new PM(this.document.getGraph(),e)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_lights_punctual)return this;let n=(t.json.extensions.KHR_lights_punctual.lights||[]).map((r)=>{let i=this.createLight().setName(r.name||"").setType(r.type);if(r.extras)i.setExtras(r.extras);if(r.color!==void 0)i.setColor(r.color);if(r.intensity!==void 0)i.setIntensity(r.intensity);if(r.range!==void 0)i.setRange(r.range);if(r.spot?.innerConeAngle!==void 0)i.setInnerConeAngle(r.spot.innerConeAngle);if(r.spot?.outerConeAngle!==void 0)i.setOuterConeAngle(r.spot.outerConeAngle);return i});return t.json.nodes.forEach((r,i)=>{if(!r.extensions||!r.extensions.KHR_lights_punctual)return;let a=r.extensions[Xi];e.nodes[i].setExtension(Xi,n[a.light])}),this}write(e){let t=e.jsonDoc;if(this.properties.size===0)return this;let n=[],r=new Map;for(let i of this.properties){let a=i,s=e.createPropertyDef(i);if(s.type=a.getType(),!gt.eq(a.getColor(),[1,1,1]))s.color=a.getColor();if(a.getIntensity()!==1)s.intensity=a.getIntensity();if(a.getRange()!=null)s.range=a.getRange();if(a.getName())s.name=a.getName();if(a.getType()===PM.Type.SPOT)s.spot={innerConeAngle:a.getInnerConeAngle(),outerConeAngle:a.getOuterConeAngle()};n.push(s),r.set(a,n.length-1)}return this.document.getRoot().listNodes().forEach((i)=>{let a=i.getExtension(Xi);if(a){let s=e.nodeIndexMap.get(i),o=t.json.nodes[s];o.extensions=o.extensions||{},o.extensions[Xi]={light:r.get(a)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[Xi]={lights:n},this}},{R:gF,G:bF,B:xF}=Rr,yF=class extends rt{static EXTENSION_NAME=za;init(){this.extensionName=za,this.propertyType="Anisotropy",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new Mt(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:gF|bF|xF})}},_F=class extends _t{static EXTENSION_NAME=za;extensionName=za;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createAnisotropy(){return new yF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_anisotropy){let s=this.createAnisotropy();e.materials[a].setExtension(za,s);let o=i.extensions[za];if(o.extras)s.setExtras(o.extras);if(o.anisotropyStrength!==void 0)s.setAnisotropyStrength(o.anisotropyStrength);if(o.anisotropyRotation!==void 0)s.setAnisotropyRotation(o.anisotropyRotation);if(o.anisotropyTexture!==void 0){let c=o.anisotropyTexture,l=e.textures[r[c.index].source];s.setAnisotropyTexture(l),e.setTextureInfo(s.getAnisotropyTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(za);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[za]=s,r.getAnisotropyStrength()>0)s.anisotropyStrength=r.getAnisotropyStrength();if(r.getAnisotropyRotation()!==0)s.anisotropyRotation=r.getAnisotropyRotation();if(r.getAnisotropyTexture()){let o=r.getAnisotropyTexture(),c=r.getAnisotropyTextureInfo();s.anisotropyTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:OM,G:kM,B:vF}=Rr,EF=class extends rt{static EXTENSION_NAME=Ba;init(){this.extensionName=Ba,this.propertyType="Clearcoat",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new Mt(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new Mt(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new Mt(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:OM})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:kM})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:OM|kM|vF})}},AF=class extends _t{static EXTENSION_NAME=Ba;extensionName=Ba;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createClearcoat(){return new EF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_clearcoat){let s=this.createClearcoat();e.materials[a].setExtension(Ba,s);let o=i.extensions[Ba];if(o.extras)s.setExtras(o.extras);if(o.clearcoatFactor!==void 0)s.setClearcoatFactor(o.clearcoatFactor);if(o.clearcoatRoughnessFactor!==void 0)s.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor);if(o.clearcoatTexture!==void 0){let c=o.clearcoatTexture,l=e.textures[r[c.index].source];s.setClearcoatTexture(l),e.setTextureInfo(s.getClearcoatTextureInfo(),c)}if(o.clearcoatRoughnessTexture!==void 0){let c=o.clearcoatRoughnessTexture,l=e.textures[r[c.index].source];s.setClearcoatRoughnessTexture(l),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),c)}if(o.clearcoatNormalTexture!==void 0){let c=o.clearcoatNormalTexture,l=e.textures[r[c.index].source];if(s.setClearcoatNormalTexture(l),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),c),c.scale!==void 0)s.setClearcoatNormalScale(c.scale)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Ba);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[Ba]=s,s.clearcoatFactor=r.getClearcoatFactor(),s.clearcoatRoughnessFactor=r.getClearcoatRoughnessFactor(),r.getClearcoatTexture()){let o=r.getClearcoatTexture(),c=r.getClearcoatTextureInfo();s.clearcoatTexture=e.createTextureInfoDef(o,c)}if(r.getClearcoatRoughnessTexture()){let o=r.getClearcoatRoughnessTexture(),c=r.getClearcoatRoughnessTextureInfo();s.clearcoatRoughnessTexture=e.createTextureInfoDef(o,c)}if(r.getClearcoatNormalTexture()){let o=r.getClearcoatNormalTexture(),c=r.getClearcoatNormalTextureInfo();if(s.clearcoatNormalTexture=e.createTextureInfoDef(o,c),r.getClearcoatNormalScale()!==1)s.clearcoatNormalTexture.scale=r.getClearcoatNormalScale()}}}),this}},{R:TF,G:wF,B:MF,A:SF}=Rr,RF=class extends rt{static EXTENSION_NAME=ja;init(){this.extensionName=ja,this.propertyType="DiffuseTransmission",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new Mt(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new Mt(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:SF})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:TF|wF|MF})}},IF=class extends _t{extensionName=ja;static EXTENSION_NAME=ja;createDiffuseTransmission(){return new RF(this.document.getGraph())}read(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_diffuse_transmission){let s=this.createDiffuseTransmission();e.materials[a].setExtension(ja,s);let o=i.extensions[ja];if(o.extras)s.setExtras(o.extras);if(o.diffuseTransmissionFactor!==void 0)s.setDiffuseTransmissionFactor(o.diffuseTransmissionFactor);if(o.diffuseTransmissionColorFactor!==void 0)s.setDiffuseTransmissionColorFactor(o.diffuseTransmissionColorFactor);if(o.diffuseTransmissionTexture!==void 0){let c=o.diffuseTransmissionTexture,l=e.textures[r[c.index].source];s.setDiffuseTransmissionTexture(l),e.setTextureInfo(s.getDiffuseTransmissionTextureInfo(),c)}if(o.diffuseTransmissionColorTexture!==void 0){let c=o.diffuseTransmissionColorTexture,l=e.textures[r[c.index].source];s.setDiffuseTransmissionColorTexture(l),e.setTextureInfo(s.getDiffuseTransmissionColorTextureInfo(),c)}}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listMaterials()){let r=n.getExtension(ja);if(!r)continue;let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[ja]=s,s.diffuseTransmissionFactor=r.getDiffuseTransmissionFactor(),s.diffuseTransmissionColorFactor=r.getDiffuseTransmissionColorFactor(),r.getDiffuseTransmissionTexture()){let o=r.getDiffuseTransmissionTexture(),c=r.getDiffuseTransmissionTextureInfo();s.diffuseTransmissionTexture=e.createTextureInfoDef(o,c)}if(r.getDiffuseTransmissionColorTexture()){let o=r.getDiffuseTransmissionColorTexture(),c=r.getDiffuseTransmissionColorTextureInfo();s.diffuseTransmissionColorTexture=e.createTextureInfoDef(o,c)}}return this}},CF=class extends rt{static EXTENSION_NAME=Va;init(){this.extensionName=Va,this.propertyType="Dispersion",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}},NF=class extends _t{static EXTENSION_NAME=Va;extensionName=Va;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createDispersion(){return new CF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_dispersion){let r=this.createDispersion();e.materials[n].setExtension(Va,r);let i=t.extensions[Va];if(i.extras)r.setExtras(i.extras);if(i.dispersion!==void 0)r.setDispersion(i.dispersion)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Va);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);a.extensions=a.extensions||{},a.extensions[Va]=s,s.dispersion=r.getDispersion()}}),this}},PF=class extends rt{static EXTENSION_NAME=Ga;init(){this.extensionName=Ga,this.propertyType="EmissiveStrength",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}},OF=class extends _t{static EXTENSION_NAME=Ga;extensionName=Ga;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createEmissiveStrength(){return new PF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_emissive_strength){let r=this.createEmissiveStrength();e.materials[n].setExtension(Ga,r);let i=t.extensions[Ga];if(i.extras)r.setExtras(i.extras);if(i.emissiveStrength!==void 0)r.setEmissiveStrength(i.emissiveStrength)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Ga);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);a.extensions=a.extensions||{},a.extensions[Ga]=s,s.emissiveStrength=r.getEmissiveStrength()}}),this}},kF=class extends rt{static EXTENSION_NAME=Ha;init(){this.extensionName=Ha,this.propertyType="IOR",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}},XM=class extends _t{static EXTENSION_NAME=Ha;extensionName=Ha;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createIOR(){return new kF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_ior){let r=this.createIOR();e.materials[n].setExtension(Ha,r);let i=t.extensions[Ha];if(i.extras)r.setExtras(i.extras);if(i.ior!==void 0)r.setIOR(i.ior)}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Ha);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);a.extensions=a.extensions||{},a.extensions[Ha]=s,s.ior=r.getIOR()}}),this}},{R:LF,G:DF}=Rr,FF=class extends rt{static EXTENSION_NAME=$a;init(){this.extensionName=$a,this.propertyType="Iridescence",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new Mt(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new Mt(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:LF})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:DF})}},UF=class extends _t{static EXTENSION_NAME=$a;extensionName=$a;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createIridescence(){return new FF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_iridescence){let s=this.createIridescence();e.materials[a].setExtension($a,s);let o=i.extensions[$a];if(o.extras)s.setExtras(o.extras);if(o.iridescenceFactor!==void 0)s.setIridescenceFactor(o.iridescenceFactor);if(o.iridescenceIor!==void 0)s.setIridescenceIOR(o.iridescenceIor);if(o.iridescenceThicknessMinimum!==void 0)s.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum);if(o.iridescenceThicknessMaximum!==void 0)s.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum);if(o.iridescenceTexture!==void 0){let c=o.iridescenceTexture,l=e.textures[r[c.index].source];s.setIridescenceTexture(l),e.setTextureInfo(s.getIridescenceTextureInfo(),c)}if(o.iridescenceThicknessTexture!==void 0){let c=o.iridescenceThicknessTexture,l=e.textures[r[c.index].source];s.setIridescenceThicknessTexture(l),e.setTextureInfo(s.getIridescenceThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension($a);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[$a]=s,r.getIridescenceFactor()>0)s.iridescenceFactor=r.getIridescenceFactor();if(r.getIridescenceIOR()!==1.3)s.iridescenceIor=r.getIridescenceIOR();if(r.getIridescenceThicknessMinimum()!==100)s.iridescenceThicknessMinimum=r.getIridescenceThicknessMinimum();if(r.getIridescenceThicknessMaximum()!==400)s.iridescenceThicknessMaximum=r.getIridescenceThicknessMaximum();if(r.getIridescenceTexture()){let o=r.getIridescenceTexture(),c=r.getIridescenceTextureInfo();s.iridescenceTexture=e.createTextureInfoDef(o,c)}if(r.getIridescenceThicknessTexture()){let o=r.getIridescenceThicknessTexture(),c=r.getIridescenceThicknessTextureInfo();s.iridescenceThicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:LM,G:DM,B:FM,A:UM}=Rr,zF=class extends rt{static EXTENSION_NAME=Ka;init(){this.extensionName=Ka,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new Mt(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new Mt(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:LM|DM|FM|UM,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:LM|DM|FM|UM})}},qM=class extends _t{static EXTENSION_NAME=Ka;extensionName=Ka;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createPBRSpecularGlossiness(){return new zF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_pbrSpecularGlossiness){let s=this.createPBRSpecularGlossiness();e.materials[a].setExtension(Ka,s);let o=i.extensions[Ka];if(o.extras)s.setExtras(o.extras);if(o.diffuseFactor!==void 0)s.setDiffuseFactor(o.diffuseFactor);if(o.specularFactor!==void 0)s.setSpecularFactor(o.specularFactor);if(o.glossinessFactor!==void 0)s.setGlossinessFactor(o.glossinessFactor);if(o.diffuseTexture!==void 0){let c=o.diffuseTexture,l=e.textures[r[c.index].source];s.setDiffuseTexture(l),e.setTextureInfo(s.getDiffuseTextureInfo(),c)}if(o.specularGlossinessTexture!==void 0){let c=o.specularGlossinessTexture,l=e.textures[r[c.index].source];s.setSpecularGlossinessTexture(l),e.setTextureInfo(s.getSpecularGlossinessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Ka);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[Ka]=s,s.diffuseFactor=r.getDiffuseFactor(),s.specularFactor=r.getSpecularFactor(),s.glossinessFactor=r.getGlossinessFactor(),r.getDiffuseTexture()){let o=r.getDiffuseTexture(),c=r.getDiffuseTextureInfo();s.diffuseTexture=e.createTextureInfoDef(o,c)}if(r.getSpecularGlossinessTexture()){let o=r.getSpecularGlossinessTexture(),c=r.getSpecularGlossinessTextureInfo();s.specularGlossinessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:BF,G:jF,B:VF,A:GF}=Rr,HF=class extends rt{static EXTENSION_NAME=Wa;init(){this.extensionName=Wa,this.propertyType="Sheen",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new Mt(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new Mt(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:BF|jF|VF,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:GF})}},$F=class extends _t{static EXTENSION_NAME=Wa;extensionName=Wa;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createSheen(){return new HF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_sheen){let s=this.createSheen();e.materials[a].setExtension(Wa,s);let o=i.extensions[Wa];if(o.extras)s.setExtras(o.extras);if(o.sheenColorFactor!==void 0)s.setSheenColorFactor(o.sheenColorFactor);if(o.sheenRoughnessFactor!==void 0)s.setSheenRoughnessFactor(o.sheenRoughnessFactor);if(o.sheenColorTexture!==void 0){let c=o.sheenColorTexture,l=e.textures[r[c.index].source];s.setSheenColorTexture(l),e.setTextureInfo(s.getSheenColorTextureInfo(),c)}if(o.sheenRoughnessTexture!==void 0){let c=o.sheenRoughnessTexture,l=e.textures[r[c.index].source];s.setSheenRoughnessTexture(l),e.setTextureInfo(s.getSheenRoughnessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Wa);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[Wa]=s,s.sheenColorFactor=r.getSheenColorFactor(),s.sheenRoughnessFactor=r.getSheenRoughnessFactor(),r.getSheenColorTexture()){let o=r.getSheenColorTexture(),c=r.getSheenColorTextureInfo();s.sheenColorTexture=e.createTextureInfoDef(o,c)}if(r.getSheenRoughnessTexture()){let o=r.getSheenRoughnessTexture(),c=r.getSheenRoughnessTextureInfo();s.sheenRoughnessTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:KF,G:WF,B:XF,A:qF}=Rr,JF=class extends rt{static EXTENSION_NAME=Xa;init(){this.extensionName=Xa,this.propertyType="Specular",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new Mt(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new Mt(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:qF})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:KF|WF|XF,isColor:!0})}},JM=class extends _t{static EXTENSION_NAME=Xa;extensionName=Xa;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createSpecular(){return new JF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_specular){let s=this.createSpecular();e.materials[a].setExtension(Xa,s);let o=i.extensions[Xa];if(o.extras)s.setExtras(o.extras);if(o.specularFactor!==void 0)s.setSpecularFactor(o.specularFactor);if(o.specularColorFactor!==void 0)s.setSpecularColorFactor(o.specularColorFactor);if(o.specularTexture!==void 0){let c=o.specularTexture,l=e.textures[r[c.index].source];s.setSpecularTexture(l),e.setTextureInfo(s.getSpecularTextureInfo(),c)}if(o.specularColorTexture!==void 0){let c=o.specularColorTexture,l=e.textures[r[c.index].source];s.setSpecularColorTexture(l),e.setTextureInfo(s.getSpecularColorTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Xa);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[Xa]=s,r.getSpecularFactor()!==1)s.specularFactor=r.getSpecularFactor();if(!gt.eq(r.getSpecularColorFactor(),[1,1,1]))s.specularColorFactor=r.getSpecularColorFactor();if(r.getSpecularTexture()){let o=r.getSpecularTexture(),c=r.getSpecularTextureInfo();s.specularTexture=e.createTextureInfoDef(o,c)}if(r.getSpecularColorTexture()){let o=r.getSpecularColorTexture(),c=r.getSpecularColorTextureInfo();s.specularColorTexture=e.createTextureInfoDef(o,c)}}}),this}},{R:ZF}=Rr,YF=class extends rt{static EXTENSION_NAME=qa;init(){this.extensionName=qa,this.propertyType="Transmission",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new Mt(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:ZF})}},QF=class extends _t{static EXTENSION_NAME=qa;extensionName=qa;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createTransmission(){return new YF(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_transmission){let s=this.createTransmission();e.materials[a].setExtension(qa,s);let o=i.extensions[qa];if(o.extras)s.setExtras(o.extras);if(o.transmissionFactor!==void 0)s.setTransmissionFactor(o.transmissionFactor);if(o.transmissionTexture!==void 0){let c=o.transmissionTexture,l=e.textures[r[c.index].source];s.setTransmissionTexture(l),e.setTextureInfo(s.getTransmissionTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(qa);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[qa]=s,s.transmissionFactor=r.getTransmissionFactor(),r.getTransmissionTexture()){let o=r.getTransmissionTexture(),c=r.getTransmissionTextureInfo();s.transmissionTexture=e.createTextureInfoDef(o,c)}}}),this}},eU=class extends rt{static EXTENSION_NAME=ic;init(){this.extensionName=ic,this.propertyType="Unlit",this.parentTypes=[Q.MATERIAL]}},ZM=class extends _t{static EXTENSION_NAME=ic;extensionName=ic;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createUnlit(){return new eU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_materials_unlit)e.materials[n].setExtension(ic,this.createUnlit())}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{if(n.getExtension("KHR_materials_unlit")){let r=e.materialIndexMap.get(n),i=t.json.materials[r];i.extensions=i.extensions||{},i.extensions[ic]={}}}),this}},tU=class extends rt{static EXTENSION_NAME=br;init(){this.extensionName=br,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new Ct})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}},nU=class extends rt{static EXTENSION_NAME=br;init(){this.extensionName=br,this.propertyType="MappingList",this.parentTypes=[Q.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new Ct})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}},zM=class extends rt{static EXTENSION_NAME=br;init(){this.extensionName=br,this.propertyType="Variant",this.parentTypes=["MappingList"]}},rU=class extends _t{extensionName=br;static EXTENSION_NAME=br;createMappingList(){return new nU(this.document.getGraph())}createVariant(e=""){return new zM(this.document.getGraph(),e)}createMapping(){return new tU(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((e)=>e instanceof zM)}read(e){let t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions.KHR_materials_variants)return this;let n=(t.json.extensions.KHR_materials_variants.variants||[]).map((r)=>this.createVariant().setName(r.name||""));return(t.json.meshes||[]).forEach((r,i)=>{let a=e.meshes[i];(r.primitives||[]).forEach((s,o)=>{if(!s.extensions||!s.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=s.extensions[br];for(let u of l.mappings){let d=this.createMapping();if(u.material!==void 0)d.setMaterial(e.materials[u.material]);for(let f of u.variants||[])d.addVariant(n[f]);c.addMapping(d)}a.listPrimitives()[o].setExtension(br,c)})}),this}write(e){let t=e.jsonDoc,n=this.listVariants();if(!n.length)return this;let r=[],i=new Map;for(let a of n)i.set(a,r.length),r.push(e.createPropertyDef(a));for(let a of this.document.getRoot().listMeshes()){let s=e.meshIndexMap.get(a);a.listPrimitives().forEach((o,c)=>{let l=o.getExtension(br);if(!l)return;let u=e.jsonDoc.json.meshes[s].primitives[c],d=l.listMappings().map((f)=>{let h=e.createPropertyDef(f),b=f.getMaterial();if(b)h.material=e.materialIndexMap.get(b);return h.variants=f.listVariants().map((m)=>i.get(m)),h});u.extensions=u.extensions||{},u.extensions[br]={mappings:d}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[br]={variants:r},this}},{G:iU}=Rr,aU=class extends rt{static EXTENSION_NAME=Ja;init(){this.extensionName=Ja,this.propertyType="Volume",this.parentTypes=[Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new Mt(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:iU})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}},sU=class extends _t{static EXTENSION_NAME=Ja;extensionName=Ja;prereadTypes=[Q.MESH];prewriteTypes=[Q.MESH];createVolume(){return new aU(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){let t=e.jsonDoc,n=t.json.materials||[],r=t.json.textures||[];return n.forEach((i,a)=>{if(i.extensions&&i.extensions.KHR_materials_volume){let s=this.createVolume();e.materials[a].setExtension(Ja,s);let o=i.extensions[Ja];if(o.extras)s.setExtras(o.extras);if(o.thicknessFactor!==void 0)s.setThicknessFactor(o.thicknessFactor);if(o.attenuationDistance!==void 0)s.setAttenuationDistance(o.attenuationDistance);if(o.attenuationColor!==void 0)s.setAttenuationColor(o.attenuationColor);if(o.thicknessTexture!==void 0){let c=o.thicknessTexture,l=e.textures[r[c.index].source];s.setThicknessTexture(l),e.setTextureInfo(s.getThicknessTextureInfo(),c)}}}),this}prewrite(e){let t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach((n)=>{let r=n.getExtension(Ja);if(r){let i=e.materialIndexMap.get(n),a=t.json.materials[i],s=e.createPropertyDef(r);if(a.extensions=a.extensions||{},a.extensions[Ja]=s,r.getThicknessFactor()>0)s.thicknessFactor=r.getThicknessFactor();if(Number.isFinite(r.getAttenuationDistance()))s.attenuationDistance=r.getAttenuationDistance();if(!gt.eq(r.getAttenuationColor(),[1,1,1]))s.attenuationColor=r.getAttenuationColor();if(r.getThicknessTexture()){let o=r.getThicknessTexture(),c=r.getThicknessTextureInfo();s.thicknessTexture=e.createTextureInfoDef(o,c)}}}),this}},YM=class extends _t{extensionName=EM;static EXTENSION_NAME=EM;read(e){return this}write(e){return this}},Fl=class extends _t{extensionName=AM;static EXTENSION_NAME=AM;read(e){return this}write(e){return this}},oU=class extends rt{static EXTENSION_NAME=Za;init(){this.extensionName=Za,this.propertyType="Visibility",this.parentTypes=[Q.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{visible:!0})}getVisible(){return this.get("visible")}setVisible(e){return this.set("visible",e)}},cU=class extends _t{static EXTENSION_NAME=Za;extensionName=Za;createVisibility(){return new oU(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,n)=>{if(t.extensions&&t.extensions.KHR_node_visibility){let r=this.createVisibility();e.nodes[n].setExtension(Za,r);let i=t.extensions[Za];if(i.visible!==void 0)r.setVisible(i.visible)}}),this}write(e){let t=e.jsonDoc;for(let n of this.document.getRoot().listNodes()){let r=n.getExtension(Za);if(!r)continue;let i=e.nodeIndexMap.get(n),a=t.json.nodes[i];a.extensions=a.extensions||{},a.extensions[Za]={visible:r.getVisible()}}return this}};ab=class extends _t{static EXTENSION_NAME=Ef;extensionName=Ef;prereadTypes=[Q.TEXTURE];static register(){Kr.registerFormat("image/ktx2",new uU)}preread(e){if(e.jsonDoc.json.textures)e.jsonDoc.json.textures.forEach((t)=>{if(t.extensions&&t.extensions.KHR_texture_basisu)t.source=t.extensions[Ef].source});return this}read(e){return this}write(e){let t=e.jsonDoc;return this.document.getRoot().listTextures().forEach((n)=>{if(n.getMimeType()==="image/ktx2"){let r=e.imageIndexMap.get(n);t.json.textures.forEach((i)=>{if(i.source===r)i.extensions=i.extensions||{},i.extensions[Ef]={source:i.source},delete i.source})}}),this}},dU=class extends rt{static EXTENSION_NAME=Ya;init(){this.extensionName=Ya,this.propertyType="Transform",this.parentTypes=[Q.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}},fU=class extends _t{extensionName=Ya;static EXTENSION_NAME=Ya;createTransform(){return new dU(this.document.getGraph())}read(e){for(let[t,n]of Array.from(e.textureInfos.entries())){if(!n.extensions||!n.extensions.KHR_texture_transform)continue;let r=this.createTransform(),i=n.extensions[Ya];if(i.offset!==void 0)r.setOffset(i.offset);if(i.rotation!==void 0)r.setRotation(i.rotation);if(i.scale!==void 0)r.setScale(i.scale);if(i.texCoord!==void 0)r.setTexCoord(i.texCoord);t.setExtension(Ya,r)}return this}write(e){let t=Array.from(e.textureInfoDefMap.entries());for(let[n,r]of t){let i=n.getExtension(Ya);if(!i)continue;r.extensions=r.extensions||{};let a={},s=gt.eq;if(!s(i.getOffset(),[0,0]))a.offset=i.getOffset();if(i.getRotation()!==0)a.rotation=i.getRotation();if(!s(i.getScale(),[1,1]))a.scale=i.getScale();if(i.getTexCoord()!=null)a.texCoord=i.getTexCoord();r.extensions[Ya]=a}return this}},hU=[Q.ROOT,Q.SCENE,Q.NODE,Q.MESH,Q.MATERIAL,Q.TEXTURE,Q.ANIMATION],pU=class extends rt{static EXTENSION_NAME=Wr;init(){this.extensionName=Wr,this.propertyType="Packet",this.parentTypes=hU}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",{...e})}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){let t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);let n={...this.get("properties")};if(t)n[e]=t;else delete n[e];return this.set("properties",n)}toJSONLD(){return{"@context":tb(this.get("context")),...tb(this.get("properties"))}}fromJSONLD(e){e=tb(e);let t=e["@context"];if(t)this.set("context",t);return delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw Error(`${Wr}: Missing context for term, "${e}".`)}};mU=class extends _t{extensionName=Wr;static EXTENSION_NAME=Wr;createPacket(){return new pU(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){let t=e.jsonDoc.json.extensions?.[Wr];if(!t||!t.packets)return this;let n=e.jsonDoc.json,r=this.document.getRoot(),i=t.packets.map((o)=>this.createPacket().fromJSONLD(o)),a=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],s=[[r],r.listScenes(),r.listNodes(),r.listMeshes(),r.listMaterials(),r.listTextures(),r.listAnimations()];for(let o=0;o<a.length;o++){let c=a[o]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[Wr];s[o][l].setExtension(Wr,i[d.packet])}}}return this}write(e){let{json:t}=e.jsonDoc,n=[];for(let r of this.properties){n.push(r.toJSONLD());for(let i of r.listParents()){let a;switch(i.propertyType){case Q.ROOT:a=t.asset;break;case Q.SCENE:a=t.scenes[e.sceneIndexMap.get(i)];break;case Q.NODE:a=t.nodes[e.nodeIndexMap.get(i)];break;case Q.MESH:a=t.meshes[e.meshIndexMap.get(i)];break;case Q.MATERIAL:a=t.materials[e.materialIndexMap.get(i)];break;case Q.TEXTURE:a=t.images[e.imageIndexMap.get(i)];break;case Q.ANIMATION:a=t.animations[e.animationIndexMap.get(i)];break;default:a=null,this.document.getLogger().warn(`[${Wr}]: Unsupported parent property, "${i.propertyType}"`)}if(!a)continue;a.extensions=a.extensions||{},a.extensions[Wr]={packet:n.length-1}}}if(n.length>0)t.extensions=t.extensions||{},t.extensions[Wr]={packets:n};return this}},gU=[rF,iF,WM,mF,_F,AF,IF,NF,OF,XM,UF,qM,JM,$F,QF,ZM,rU,sU,YM,Fl,cU,ab,fU,mU],QM=[Af,e2,Dl,I2,VM,GM,...gU]});var tS=ta(function(NK,eS){function bU(e){var t=Array(e);for(var n=0;n<e;++n)t[n]=n;return t}eS.exports=bU});var iS=ta(function(PK,rS){/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
- */HS.exports=function(e){return e!=null&&(jS(e)||ZU(e)||!!e._isBuffer)};function jS(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function ZU(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&jS(e.slice(0,0))}});var qg=Jr(function(rK,$S){var YU=VS(),QU=GS(),e3=typeof Float64Array<"u";function t3(e,t){return e[0]-t[0]}function n3(){var e=this.stride,t=Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(t3);var i=Array(t.length);for(n=0;n<i.length;++n)i[n]=t[n][1];return i}function i3(e,t){var n=["View",t,"d",e].join("");if(t<0)n="View_Nil"+e;var i=e==="generic";if(t===-1){var r="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",m=Function(r);return m()}else if(t===0){var r="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",m=Function("TrivialArray",r);return m(pf[e][0])}var r=["'use strict'"],s=YU(t),a=s.map(function(g){return"i"+g}),o="this.offset+"+s.map(function(g){return"this.stride["+g+"]*i"+g}).join("+"),c=s.map(function(g){return"b"+g}).join(","),l=s.map(function(g){return"c"+g}).join(",");if(r.push("function "+n+"(a,"+c+","+l+",d){this.data=a","this.shape=["+c+"]","this.stride=["+l+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+s.map(function(g){return"this.shape["+g+"]"}).join("*"),"}})"),t===1)r.push("proto.order=[0]");else if(r.push("Object.defineProperty(proto,'order',{get:"),t<4){if(r.push("function "+n+"_order(){"),t===2)r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})");else if(t===3)r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}else r.push("ORDER})");if(r.push("proto.set=function "+n+"_set("+a.join(",")+",v){"),i)r.push("return this.data.set("+o+",v)}");else r.push("return this.data["+o+"]=v}");if(r.push("proto.get=function "+n+"_get("+a.join(",")+"){"),i)r.push("return this.data.get("+o+")}");else r.push("return this.data["+o+"]}");r.push("proto.index=function "+n+"_index(",a.join(),"){return "+o+"}"),r.push("proto.hi=function "+n+"_hi("+a.join(",")+"){return new "+n+"(this.data,"+s.map(function(g){return["(typeof i",g,"!=='number'||i",g,"<0)?this.shape[",g,"]:i",g,"|0"].join("")}).join(",")+","+s.map(function(g){return"this.stride["+g+"]"}).join(",")+",this.offset)}");var u=s.map(function(g){return"a"+g+"=this.shape["+g+"]"}),d=s.map(function(g){return"c"+g+"=this.stride["+g+"]"});r.push("proto.lo=function "+n+"_lo("+a.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+d.join(","));for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");r.push("return new "+n+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"c"+g}).join(",")+",b)}"),r.push("proto.step=function "+n+"_step("+a.join(",")+"){var "+s.map(function(g){return"a"+g+"=this.shape["+g+"]"}).join(",")+","+s.map(function(g){return"b"+g+"=this.stride["+g+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");r.push("return new "+n+"(this.data,"+s.map(function(g){return"a"+g}).join(",")+","+s.map(function(g){return"b"+g}).join(",")+",c)}");var h=Array(t),b=Array(t);for(var f=0;f<t;++f)h[f]="a[i"+f+"]",b[f]="b[i"+f+"]";r.push("proto.transpose=function "+n+"_transpose("+a+"){"+a.map(function(g,p){return g+"=("+g+"===undefined?"+p+":"+g+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+h.join(",")+","+b.join(",")+",this.offset)}"),r.push("proto.pick=function "+n+"_pick("+a+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)r.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+s.map(function(g){return"shape["+g+"]"}).join(",")+","+s.map(function(g){return"stride["+g+"]"}).join(",")+",offset)}");var m=Function("CTOR_LIST","ORDER",r.join(`
-`));return m(pf[e],n3)}function r3(e){if(QU(e))return"buffer";if(e3)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}if(Array.isArray(e))return"array";return"generic"}var pf={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function s3(e,t,n,i){if(e===void 0){var l=pf.array[0];return l([])}else if(typeof e==="number")e=[e];if(t===void 0)t=[e.length];var r=t.length;if(n===void 0){n=Array(r);for(var s=r-1,a=1;s>=0;--s)n[s]=a,a*=t[s]}if(i===void 0){i=0;for(var s=0;s<r;++s)if(n[s]<0)i-=(t[s]-1)*n[s]}var o=r3(e),c=pf[o];while(c.length<=r+1)c.push(i3(o,c.length-1));var l=c[r+1];return l(e,t,n,i)}$S.exports=s3});var WS=Jr(function(sK,KS){function a3(e,t){var n=1,i=e.length,r=e[0],s=e[0];for(var a=1;a<i;++a)if(s=r,r=e[a],t(r,s)){if(a===n){n++;continue}e[n++]=r}return e.length=n,e}function o3(e){var t=1,n=e.length,i=e[0],r=e[0];for(var s=1;s<n;++s,r=i)if(r=i,i=e[s],i!==r){if(s===t){t++;continue}e[t++]=i}return e.length=t,e}function c3(e,t,n){if(e.length===0)return e;if(t){if(!n)e.sort(t);return a3(e,t)}if(!n)e.sort();return o3(e)}KS.exports=c3});var JS=Jr(function(aK,qS){var l3=WS();function XS(e,t,n){var i=e.length,r=t.arrayArgs.length,s=t.indexArgs.length>0,a=[],o=[],c=0,l=0,u,d;for(u=0;u<i;++u)o.push(["i",u,"=0"].join(""));for(d=0;d<r;++d)for(u=0;u<i;++u)if(l=c,c=e[u],u===0)o.push(["d",d,"s",u,"=t",d,"p",c].join(""));else o.push(["d",d,"s",u,"=(t",d,"p",c,"-s",l,"*t",d,"p",l,")"].join(""));if(o.length>0)a.push("var "+o.join(","));for(u=i-1;u>=0;--u)c=e[u],a.push(["for(i",u,"=0;i",u,"<s",c,";++i",u,"){"].join(""));a.push(n);for(u=0;u<i;++u){l=c,c=e[u];for(d=0;d<r;++d)a.push(["p",d,"+=d",d,"s",u].join(""));if(s){if(u>0)a.push(["index[",l,"]-=s",l].join(""));a.push(["++index[",c,"]"].join(""))}a.push("}")}return a.join(`
-`)}function u3(e,t,n,i){var r=t.length,s=n.arrayArgs.length,a=n.blockSize,o=n.indexArgs.length>0,c=[];for(var l=0;l<s;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<r;++l)if(c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",a,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",a].join("")),c.push(["j",l,"-=",a,"}"].join("")),o)c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;l<s;++l){var u=["offset"+l];for(var d=e;d<r;++d)u.push(["j",d,"*t",l,"p",t[d]].join(""));c.push(["p",l,"=(",u.join("+"),")"].join(""))}c.push(XS(t,n,i));for(var l=e;l<r;++l)c.push("}");return c.join(`
-`)}function d3(e){var t=0,n=e[0].length;while(t<n){for(var i=1;i<e.length;++i)if(e[i][t]!==e[0][t])return t;++t}return t}function Jg(e,t,n){var i=e.body,r=[],s=[];for(var a=0;a<e.args.length;++a){var o=e.args[a];if(o.count<=0)continue;var c=new RegExp(o.name,"g"),l="",u=t.arrayArgs.indexOf(a);switch(t.argTypes[a]){case"offset":var d=t.offsetArgIndex.indexOf(a),f=t.offsetArgs[d];u=f.array,l="+q"+d;case"array":l="p"+u+l;var h="l"+a,b="a"+u;if(t.arrayBlockIndices[u]===0){if(o.count===1)if(n[u]==="generic")if(o.lvalue)r.push(["var ",h,"=",b,".get(",l,")"].join("")),i=i.replace(c,h),s.push([b,".set(",l,",",h,")"].join(""));else i=i.replace(c,[b,".get(",l,")"].join(""));else i=i.replace(c,[b,"[",l,"]"].join(""));else if(n[u]==="generic"){if(r.push(["var ",h,"=",b,".get(",l,")"].join("")),i=i.replace(c,h),o.lvalue)s.push([b,".set(",l,",",h,")"].join(""))}else if(r.push(["var ",h,"=",b,"[",l,"]"].join("")),i=i.replace(c,h),o.lvalue)s.push([b,"[",l,"]=",h].join(""))}else{var m=[o.name],g=[l];for(var p=0;p<Math.abs(t.arrayBlockIndices[u]);p++)m.push("\\s*\\[([^\\]]+)\\]"),g.push("$"+(p+1)+"*t"+u+"b"+p);if(c=new RegExp(m.join(""),"g"),l=g.join("+"),n[u]==="generic")throw Error("cwise: Generic arrays not supported in combination with blocks!");else i=i.replace(c,[b,"[",l,"]"].join(""))}break;case"scalar":i=i.replace(c,"Y"+t.scalarArgs.indexOf(a));break;case"index":i=i.replace(c,"index");break;case"shape":i=i.replace(c,"shape");break}}return[r.join(`
-`),i,s.join(`
+ */rS.exports=function(e){return e!=null&&(nS(e)||xU(e)||!!e._isBuffer)};function nS(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function xU(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&nS(e.slice(0,0))}});var sb=ta(function(OK,aS){var yU=tS(),_U=iS(),vU=typeof Float64Array<"u";function EU(e,t){return e[0]-t[0]}function AU(){var e=this.stride,t=Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(EU);var r=Array(t.length);for(n=0;n<r.length;++n)r[n]=t[n][1];return r}function TU(e,t){var n=["View",t,"d",e].join("");if(t<0)n="View_Nil"+e;var r=e==="generic";if(t===-1){var i="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",m=Function(i);return m()}else if(t===0){var i="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(r?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(r?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",m=Function("TrivialArray",i);return m(wf[e][0])}var i=["'use strict'"],a=yU(t),s=a.map(function(g){return"i"+g}),o="this.offset+"+a.map(function(g){return"this.stride["+g+"]*i"+g}).join("+"),c=a.map(function(g){return"b"+g}).join(","),l=a.map(function(g){return"c"+g}).join(",");if(i.push("function "+n+"(a,"+c+","+l+",d){this.data=a","this.shape=["+c+"]","this.stride=["+l+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),i.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+a.map(function(g){return"this.shape["+g+"]"}).join("*"),"}})"),t===1)i.push("proto.order=[0]");else if(i.push("Object.defineProperty(proto,'order',{get:"),t<4){if(i.push("function "+n+"_order(){"),t===2)i.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})");else if(t===3)i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}else i.push("ORDER})");if(i.push("proto.set=function "+n+"_set("+s.join(",")+",v){"),r)i.push("return this.data.set("+o+",v)}");else i.push("return this.data["+o+"]=v}");if(i.push("proto.get=function "+n+"_get("+s.join(",")+"){"),r)i.push("return this.data.get("+o+")}");else i.push("return this.data["+o+"]}");i.push("proto.index=function "+n+"_index(",s.join(),"){return "+o+"}"),i.push("proto.hi=function "+n+"_hi("+s.join(",")+"){return new "+n+"(this.data,"+a.map(function(g){return["(typeof i",g,"!=='number'||i",g,"<0)?this.shape[",g,"]:i",g,"|0"].join("")}).join(",")+","+a.map(function(g){return"this.stride["+g+"]"}).join(",")+",this.offset)}");var u=a.map(function(g){return"a"+g+"=this.shape["+g+"]"}),d=a.map(function(g){return"c"+g+"=this.stride["+g+"]"});i.push("proto.lo=function "+n+"_lo("+s.join(",")+"){var b=this.offset,d=0,"+u.join(",")+","+d.join(","));for(var f=0;f<t;++f)i.push("if(typeof i"+f+"==='number'&&i"+f+">=0){d=i"+f+"|0;b+=c"+f+"*d;a"+f+"-=d}");i.push("return new "+n+"(this.data,"+a.map(function(g){return"a"+g}).join(",")+","+a.map(function(g){return"c"+g}).join(",")+",b)}"),i.push("proto.step=function "+n+"_step("+s.join(",")+"){var "+a.map(function(g){return"a"+g+"=this.shape["+g+"]"}).join(",")+","+a.map(function(g){return"b"+g+"=this.stride["+g+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var f=0;f<t;++f)i.push("if(typeof i"+f+"==='number'){d=i"+f+"|0;if(d<0){c+=b"+f+"*(a"+f+"-1);a"+f+"=ceil(-a"+f+"/d)}else{a"+f+"=ceil(a"+f+"/d)}b"+f+"*=d}");i.push("return new "+n+"(this.data,"+a.map(function(g){return"a"+g}).join(",")+","+a.map(function(g){return"b"+g}).join(",")+",c)}");var h=Array(t),b=Array(t);for(var f=0;f<t;++f)h[f]="a[i"+f+"]",b[f]="b[i"+f+"]";i.push("proto.transpose=function "+n+"_transpose("+s+"){"+s.map(function(g,p){return g+"=("+g+"===undefined?"+p+":"+g+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+h.join(",")+","+b.join(",")+",this.offset)}"),i.push("proto.pick=function "+n+"_pick("+s+"){var a=[],b=[],c=this.offset");for(var f=0;f<t;++f)i.push("if(typeof i"+f+"==='number'&&i"+f+">=0){c=(c+this.stride["+f+"]*i"+f+")|0}else{a.push(this.shape["+f+"]);b.push(this.stride["+f+"])}");i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+a.map(function(g){return"shape["+g+"]"}).join(",")+","+a.map(function(g){return"stride["+g+"]"}).join(",")+",offset)}");var m=Function("CTOR_LIST","ORDER",i.join(`
+`));return m(wf[e],AU)}function wU(e){if(_U(e))return"buffer";if(vU)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}if(Array.isArray(e))return"array";return"generic"}var wf={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function MU(e,t,n,r){if(e===void 0){var l=wf.array[0];return l([])}else if(typeof e==="number")e=[e];if(t===void 0)t=[e.length];var i=t.length;if(n===void 0){n=Array(i);for(var a=i-1,s=1;a>=0;--a)n[a]=s,s*=t[a]}if(r===void 0){r=0;for(var a=0;a<i;++a)if(n[a]<0)r-=(t[a]-1)*n[a]}var o=wU(e),c=wf[o];while(c.length<=i+1)c.push(TU(o,c.length-1));var l=c[i+1];return l(e,t,n,r)}aS.exports=MU});var oS=ta(function(kK,sS){function SU(e,t){var n=1,r=e.length,i=e[0],a=e[0];for(var s=1;s<r;++s)if(a=i,i=e[s],t(i,a)){if(s===n){n++;continue}e[n++]=i}return e.length=n,e}function RU(e){var t=1,n=e.length,r=e[0],i=e[0];for(var a=1;a<n;++a,i=r)if(i=r,r=e[a],r!==i){if(a===t){t++;continue}e[t++]=r}return e.length=t,e}function IU(e,t,n){if(e.length===0)return e;if(t){if(!n)e.sort(t);return SU(e,t)}if(!n)e.sort();return RU(e)}sS.exports=IU});var uS=ta(function(LK,lS){var CU=oS();function cS(e,t,n){var r=e.length,i=t.arrayArgs.length,a=t.indexArgs.length>0,s=[],o=[],c=0,l=0,u,d;for(u=0;u<r;++u)o.push(["i",u,"=0"].join(""));for(d=0;d<i;++d)for(u=0;u<r;++u)if(l=c,c=e[u],u===0)o.push(["d",d,"s",u,"=t",d,"p",c].join(""));else o.push(["d",d,"s",u,"=(t",d,"p",c,"-s",l,"*t",d,"p",l,")"].join(""));if(o.length>0)s.push("var "+o.join(","));for(u=r-1;u>=0;--u)c=e[u],s.push(["for(i",u,"=0;i",u,"<s",c,";++i",u,"){"].join(""));s.push(n);for(u=0;u<r;++u){l=c,c=e[u];for(d=0;d<i;++d)s.push(["p",d,"+=d",d,"s",u].join(""));if(a){if(u>0)s.push(["index[",l,"]-=s",l].join(""));s.push(["++index[",c,"]"].join(""))}s.push("}")}return s.join(`
+`)}function NU(e,t,n,r){var i=t.length,a=n.arrayArgs.length,s=n.blockSize,o=n.indexArgs.length>0,c=[];for(var l=0;l<a;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<i;++l)if(c.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",s,"){"].join("")),c.push(["s",t[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",t[l],"=",s].join("")),c.push(["j",l,"-=",s,"}"].join("")),o)c.push(["index[",t[l],"]=j",l].join(""));for(var l=0;l<a;++l){var u=["offset"+l];for(var d=e;d<i;++d)u.push(["j",d,"*t",l,"p",t[d]].join(""));c.push(["p",l,"=(",u.join("+"),")"].join(""))}c.push(cS(t,n,r));for(var l=e;l<i;++l)c.push("}");return c.join(`
+`)}function PU(e){var t=0,n=e[0].length;while(t<n){for(var r=1;r<e.length;++r)if(e[r][t]!==e[0][t])return t;++t}return t}function ob(e,t,n){var r=e.body,i=[],a=[];for(var s=0;s<e.args.length;++s){var o=e.args[s];if(o.count<=0)continue;var c=new RegExp(o.name,"g"),l="",u=t.arrayArgs.indexOf(s);switch(t.argTypes[s]){case"offset":var d=t.offsetArgIndex.indexOf(s),f=t.offsetArgs[d];u=f.array,l="+q"+d;case"array":l="p"+u+l;var h="l"+s,b="a"+u;if(t.arrayBlockIndices[u]===0){if(o.count===1)if(n[u]==="generic")if(o.lvalue)i.push(["var ",h,"=",b,".get(",l,")"].join("")),r=r.replace(c,h),a.push([b,".set(",l,",",h,")"].join(""));else r=r.replace(c,[b,".get(",l,")"].join(""));else r=r.replace(c,[b,"[",l,"]"].join(""));else if(n[u]==="generic"){if(i.push(["var ",h,"=",b,".get(",l,")"].join("")),r=r.replace(c,h),o.lvalue)a.push([b,".set(",l,",",h,")"].join(""))}else if(i.push(["var ",h,"=",b,"[",l,"]"].join("")),r=r.replace(c,h),o.lvalue)a.push([b,"[",l,"]=",h].join(""))}else{var m=[o.name],g=[l];for(var p=0;p<Math.abs(t.arrayBlockIndices[u]);p++)m.push("\\s*\\[([^\\]]+)\\]"),g.push("$"+(p+1)+"*t"+u+"b"+p);if(c=new RegExp(m.join(""),"g"),l=g.join("+"),n[u]==="generic")throw Error("cwise: Generic arrays not supported in combination with blocks!");else r=r.replace(c,[b,"[",l,"]"].join(""))}break;case"scalar":r=r.replace(c,"Y"+t.scalarArgs.indexOf(s));break;case"index":r=r.replace(c,"index");break;case"shape":r=r.replace(c,"shape");break}}return[i.join(`
+`),r,a.join(`
`)].join(`
-`).trim()}function f3(e){var t=Array(e.length),n=!0;for(var i=0;i<e.length;++i){var r=e[i],s=r.match(/\d+/);if(!s)s="";else s=s[0];if(r.charAt(0)===0)t[i]="u"+r.charAt(1)+s;else t[i]=r.charAt(0)+s;if(i>0)n=n&&t[i]===t[i-1]}if(n)return t[0];return t.join("")}function h3(e,t){var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,i=Array(e.arrayArgs.length),r=Array(e.arrayArgs.length);for(var s=0;s<e.arrayArgs.length;++s)r[s]=t[2*s],i[s]=t[2*s+1];var a=[],o=[],c=[],l=[],u=[];for(var s=0;s<e.arrayArgs.length;++s){if(e.arrayBlockIndices[s]<0)c.push(0),l.push(n),a.push(n),o.push(n+e.arrayBlockIndices[s]);else c.push(e.arrayBlockIndices[s]),l.push(e.arrayBlockIndices[s]+n),a.push(0),o.push(e.arrayBlockIndices[s]);var d=[];for(var f=0;f<i[s].length;f++)if(c[s]<=i[s][f]&&i[s][f]<l[s])d.push(i[s][f]-c[s]);u.push(d)}var h=["SS"],b=["'use strict'"],m=[];for(var f=0;f<n;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var s=0;s<e.arrayArgs.length;++s){h.push("a"+s),h.push("t"+s),h.push("p"+s);for(var f=0;f<n;++f)m.push(["t",s,"p",f,"=t",s,"[",c[s]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[s]);++f)m.push(["t",s,"b",f,"=t",s,"[",a[s]+f,"]"].join(""))}for(var s=0;s<e.scalarArgs.length;++s)h.push("Y"+s);if(e.shapeArgs.length>0)m.push("shape=SS.slice(0)");if(e.indexArgs.length>0){var g=Array(n);for(var s=0;s<n;++s)g[s]="0";m.push(["index=[",g.join(","),"]"].join(""))}for(var s=0;s<e.offsetArgs.length;++s){var p=e.offsetArgs[s],x=[];for(var f=0;f<p.offset.length;++f)if(p.offset[f]===0)continue;else if(p.offset[f]===1)x.push(["t",p.array,"p",f].join(""));else x.push([p.offset[f],"*t",p.array,"p",f].join(""));if(x.length===0)m.push("q"+s+"=0");else m.push(["q",s,"=",x.join("+")].join(""))}var _=l3([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));if(m=m.concat(_),m.length>0)b.push("var "+m.join(","));for(var s=0;s<e.arrayArgs.length;++s)b.push("p"+s+"|=0");if(e.pre.body.length>3)b.push(Jg(e.pre,e,r));var y=Jg(e.body,e,r),v=d3(u);if(v<n)b.push(u3(v,u[0],e,y));else b.push(XS(u[0],e,y));if(e.post.body.length>3)b.push(Jg(e.post,e,r));if(e.debug)console.log("-----Generated cwise routine for ",t,`:
+`).trim()}function OU(e){var t=Array(e.length),n=!0;for(var r=0;r<e.length;++r){var i=e[r],a=i.match(/\d+/);if(!a)a="";else a=a[0];if(i.charAt(0)===0)t[r]="u"+i.charAt(1)+a;else t[r]=i.charAt(0)+a;if(r>0)n=n&&t[r]===t[r-1]}if(n)return t[0];return t.join("")}function kU(e,t){var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,r=Array(e.arrayArgs.length),i=Array(e.arrayArgs.length);for(var a=0;a<e.arrayArgs.length;++a)i[a]=t[2*a],r[a]=t[2*a+1];var s=[],o=[],c=[],l=[],u=[];for(var a=0;a<e.arrayArgs.length;++a){if(e.arrayBlockIndices[a]<0)c.push(0),l.push(n),s.push(n),o.push(n+e.arrayBlockIndices[a]);else c.push(e.arrayBlockIndices[a]),l.push(e.arrayBlockIndices[a]+n),s.push(0),o.push(e.arrayBlockIndices[a]);var d=[];for(var f=0;f<r[a].length;f++)if(c[a]<=r[a][f]&&r[a][f]<l[a])d.push(r[a][f]-c[a]);u.push(d)}var h=["SS"],b=["'use strict'"],m=[];for(var f=0;f<n;++f)m.push(["s",f,"=SS[",f,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){h.push("a"+a),h.push("t"+a),h.push("p"+a);for(var f=0;f<n;++f)m.push(["t",a,"p",f,"=t",a,"[",c[a]+f,"]"].join(""));for(var f=0;f<Math.abs(e.arrayBlockIndices[a]);++f)m.push(["t",a,"b",f,"=t",a,"[",s[a]+f,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)h.push("Y"+a);if(e.shapeArgs.length>0)m.push("shape=SS.slice(0)");if(e.indexArgs.length>0){var g=Array(n);for(var a=0;a<n;++a)g[a]="0";m.push(["index=[",g.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){var p=e.offsetArgs[a],y=[];for(var f=0;f<p.offset.length;++f)if(p.offset[f]===0)continue;else if(p.offset[f]===1)y.push(["t",p.array,"p",f].join(""));else y.push([p.offset[f],"*t",p.array,"p",f].join(""));if(y.length===0)m.push("q"+a+"=0");else m.push(["q",a,"=",y.join("+")].join(""))}var v=CU([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));if(m=m.concat(v),m.length>0)b.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)b.push("p"+a+"|=0");if(e.pre.body.length>3)b.push(ob(e.pre,e,i));var x=ob(e.body,e,i),_=PU(u);if(_<n)b.push(NU(_,u[0],e,x));else b.push(cS(u[0],e,x));if(e.post.body.length>3)b.push(ob(e.post,e,i));if(e.debug)console.log("-----Generated cwise routine for ",t,`:
`+b.join(`
`)+`
-----------`);var E=[e.funcName||"unnamed","_cwise_loop_",i[0].join("s"),"m",v,f3(r)].join(""),w=Function(["function ",E,"(",h.join(","),"){",b.join(`
-`),"} return ",E].join(""));return w()}qS.exports=h3});var YS=Jr(function(oK,ZS){var p3=JS();function m3(e){var t=["'use strict'","var CACHED={}"],n=[],i=e.funcName+"_cwise_thunk";t.push(["return function ",i,"(",e.shimArgs.join(","),"){"].join(""));var r=[],s=[],a=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],o=[],c=[];for(var l=0;l<e.arrayArgs.length;++l){var u=e.arrayArgs[l];if(n.push(["t",u,"=array",u,".dtype,","r",u,"=array",u,".order"].join("")),r.push("t"+u),r.push("r"+u),s.push("t"+u),s.push("r"+u+".join()"),a.push("array"+u+".data"),a.push("array"+u+".stride"),a.push("array"+u+".offset|0"),l>0)o.push("array"+e.arrayArgs[0]+".shape.length===array"+u+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+u+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]")}if(e.arrayArgs.length>1)t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}");for(var l=0;l<e.scalarArgs.length;++l)a.push("scalar"+e.scalarArgs[l]);if(n.push(["type=[",s.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),t.push("var "+n.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",r.join(","),"])}","return proc(",a.join(","),")}"].join("")),e.debug)console.log(`-----Generated thunk:
+----------`);var E=[e.funcName||"unnamed","_cwise_loop_",r[0].join("s"),"m",_,OU(i)].join(""),w=Function(["function ",E,"(",h.join(","),"){",b.join(`
+`),"} return ",E].join(""));return w()}lS.exports=kU});var fS=ta(function(DK,dS){var LU=uS();function DU(e){var t=["'use strict'","var CACHED={}"],n=[],r=e.funcName+"_cwise_thunk";t.push(["return function ",r,"(",e.shimArgs.join(","),"){"].join(""));var i=[],a=[],s=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],o=[],c=[];for(var l=0;l<e.arrayArgs.length;++l){var u=e.arrayArgs[l];if(n.push(["t",u,"=array",u,".dtype,","r",u,"=array",u,".order"].join("")),i.push("t"+u),i.push("r"+u),a.push("t"+u),a.push("r"+u+".join()"),s.push("array"+u+".data"),s.push("array"+u+".stride"),s.push("array"+u+".offset|0"),l>0)o.push("array"+e.arrayArgs[0]+".shape.length===array"+u+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+u+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]")}if(e.arrayArgs.length>1)t.push("if (!("+o.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}");for(var l=0;l<e.scalarArgs.length;++l)s.push("scalar"+e.scalarArgs[l]);if(n.push(["type=[",a.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),t.push("var "+n.join(",")),t.push(["if(!proc){","CACHED[type]=proc=compile([",i.join(","),"])}","return proc(",s.join(","),")}"].join("")),e.debug)console.log(`-----Generated thunk:
`+t.join(`
`)+`
----------`);var d=Function("compile",t.join(`
-`));return d(p3.bind(void 0,e))}ZS.exports=m3});var eM=Jr(function(cK,QS){var g3=YS();function b3(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function x3(e){var t=new b3;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var i=0;i<n.length;++i){var r=n[i];if(r==="array"||typeof r==="object"&&r.blockIndices){if(t.argTypes[i]="array",t.arrayArgs.push(i),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array args");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if(r==="index"){if(t.indexArgs.push(i),i<t.pre.args.length&&t.pre.args[i].count>0)throw Error("cwise: pre() block may not reference array index");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array index");if(i<t.post.args.length&&t.post.args[i].count>0)throw Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(i),i<t.pre.args.length&&t.pre.args[i].lvalue)throw Error("cwise: pre() block may not write to array shape");if(i<t.body.args.length&&t.body.args[i].lvalue)throw Error("cwise: body() block may not write to array shape");if(i<t.post.args.length&&t.post.args[i].lvalue)throw Error("cwise: post() block may not write to array shape")}else if(typeof r==="object"&&r.offset)t.argTypes[i]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(i);else throw Error("cwise: Unknown argument type "+n[i])}if(t.arrayArgs.length<=0)throw Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,g3(t)}QS.exports=x3});var oM=Jr(function(an){var Qn=eM(),mf={body:"",args:[],thisVars:[],localVars:[]};function Zg(e){if(!e)return mf;for(var t=0;t<e.args.length;++t){var n=e.args[t];if(t===0)e.args[t]={name:n,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1};else e.args[t]={name:n,lvalue:!1,rvalue:!0,count:1}}if(!e.thisVars)e.thisVars=[];if(!e.localVars)e.localVars=[];return e}function y3(e){return Qn({args:e.args,pre:Zg(e.pre),body:Zg(e.body),post:Zg(e.proc),funcName:e.funcName})}function Yt(e){var t=[];for(var n=0;n<e.args.length;++n)t.push("a"+n);var i=Function("P",["return function ",e.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return i(y3(e))}var tM={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var e in tM){var t=tM[e];an[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),an[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),an[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),an[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}})();var nM={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var e in nM){var t=nM[e];an[e]=Yt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),an[e+"eq"]=Yt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}})();var iM={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var e in iM){var t=iM[e];an[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),an[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),an[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),an[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}})();var rM=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var e=0;e<rM.length;++e){var t=rM[e];an[t]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),an[t+"eq"]=Yt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var sM=["max","min","atan2","pow"];(function(){for(var e=0;e<sM.length;++e){var t=sM[e];an[t]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),an[t+"s"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),an[t+"eq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),an[t+"seq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var aM=["atan2","pow"];(function(){for(var e=0;e<aM.length;++e){var t=aM[e];an[t+"op"]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),an[t+"ops"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),an[t+"opeq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),an[t+"opseq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();an.any=Qn({args:["array"],pre:mf,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});an.all=Qn({args:["array"],pre:mf,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});an.sum=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});an.prod=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});an.norm2squared=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});an.norm2=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});an.norminf=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});an.norm1=Qn({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});an.sup=Qn({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});an.inf=Qn({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});an.argmin=Qn({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});an.argmax=Qn({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});an.random=Yt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});an.assign=Yt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});an.assigns=Yt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});an.equals=Qn({args:["array","array"],pre:mf,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});function F3(e,t){if(!(e instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let n=new Blob([e],{type:t});return createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((i)=>{let r=new OffscreenCanvas(i.width,i.height).getContext("2d");r.drawImage(i,0,0);let s=r.getImageData(0,0,i.width,i.height);return cM.default(new Uint8Array(s.data),[i.width,i.height,4],[4,4*i.width,1],0)})}async function lM(e,t){return F3(e,t)}var cM,L3;var uM=ut(()=>{cM=Bf(qg(),1),L3=Bf(oM(),1)});function Af(e,t){return Object.defineProperty(t,"name",{value:e}),t}function wf(e,t){let n={...e};for(let i in t)if(t[i]!==void 0)n[i]=t[i];return n}function SM(e){let t=[];for(let n of e.listAttributes())t.push(n);for(let n of e.listTargets())for(let i of n.listAttributes())t.push(i);return Array.from(new Set(t))}function B3(e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function yf(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function z3(e,t=e){let n=MM(e,t);for(let i=0;i<n.length;i++)n[i]=i;return n}function MM(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function RM(e){for(let t in e)return!1;return!0}function V3(e,t){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],h=t[11],b=t[12],m=t[13],g=t[14],p=t[15],x=n*o-i*a,_=n*c-r*a,y=n*l-s*a,v=i*c-r*o,E=i*l-s*o,w=r*l-s*c,T=u*m-d*b,A=u*g-f*b,P=u*p-h*b,S=d*g-f*m,R=d*p-h*m,k=f*p-h*g,C=x*k-_*R+y*S+v*P-E*A+w*T;if(!C)return null;return C=1/C,e[0]=(o*k-c*R+l*S)*C,e[1]=(r*R-i*k-s*S)*C,e[2]=(m*w-g*E+p*v)*C,e[3]=(f*E-d*w-h*v)*C,e[4]=(c*P-a*k-l*A)*C,e[5]=(n*k-r*P+s*A)*C,e[6]=(g*y-b*w-p*_)*C,e[7]=(u*w-f*y+h*_)*C,e[8]=(a*R-o*P+l*T)*C,e[9]=(i*P-n*R-s*T)*C,e[10]=(b*E-m*y+p*x)*C,e[11]=(d*y-u*E-h*x)*C,e[12]=(o*A-a*S-c*T)*C,e[13]=(n*S-i*A+r*T)*C,e[14]=(m*_-b*v-g*x)*C,e[15]=(u*v-d*_+f*x)*C,e}function rb(e,t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],x=t[15],_=n[0],y=n[1],v=n[2],E=n[3];return e[0]=_*i+y*o+v*d+E*m,e[1]=_*r+y*c+v*f+E*g,e[2]=_*s+y*l+v*h+E*p,e[3]=_*a+y*u+v*b+E*x,_=n[4],y=n[5],v=n[6],E=n[7],e[4]=_*i+y*o+v*d+E*m,e[5]=_*r+y*c+v*f+E*g,e[6]=_*s+y*l+v*h+E*p,e[7]=_*a+y*u+v*b+E*x,_=n[8],y=n[9],v=n[10],E=n[11],e[8]=_*i+y*o+v*d+E*m,e[9]=_*r+y*c+v*f+E*g,e[10]=_*s+y*l+v*h+E*p,e[11]=_*a+y*u+v*b+E*x,_=n[12],y=n[13],v=n[14],E=n[15],e[12]=_*i+y*o+v*d+E*m,e[13]=_*r+y*c+v*f+E*g,e[14]=_*s+y*l+v*h+E*p,e[15]=_*a+y*u+v*b+E*x,e}function j3(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function H3(e,t,n,i){var r=t[0],s=t[1],a=t[2],o=t[3],c=r+r,l=s+s,u=a+a,d=r*c,f=r*l,h=r*u,b=s*l,m=s*u,g=a*u,p=o*c,x=o*l,_=o*u,y=i[0],v=i[1],E=i[2];return e[0]=(1-(b+g))*y,e[1]=(f+_)*y,e[2]=(h-x)*y,e[3]=0,e[4]=(f-_)*v,e[5]=(1-(d+g))*v,e[6]=(m+p)*v,e[7]=0,e[8]=(h+x)*E,e[9]=(m-p)*E,e[10]=(1-(d+b))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function vf(e,t){let n=e.getAttribute("POSITION"),i=e.getIndices();if(!n)return 0;switch(t){case"render":return i?i.getCount():n.getCount();case"render-cached":return i?new Set(i.getArray()).size:n.getCount();case"upload-naive":case"upload":return n.getCount();case"distinct":case"distinct-position":return G3(t);case"unused":return i?n.getCount()-new Set(i.getArray()).size:0;default:return $3(t)}}function G3(e){throw Error(`Not implemented: ${e}`)}function $3(e){throw Error(`Unexpected value: ${e}`)}function K3(e,t,n){let i=of.fromGraph(e.getGraph());if(!t||!n)[t,n]=W3(e);let r=e.getIndices(),s=r?r.getArray():null,a=vf(e,"render"),o=i.createAccessor(),c=a,l=MM(c,n);for(let d=0;d<c;d++)l[d]=t[s?s[d]:d];e.setIndices(o.setArray(l));let u=SM(e);for(let d of e.listAttributes()){let f=yf(i,d);eb(d,r,t,f,n),e.swap(d,f)}for(let d of e.listTargets())for(let f of d.listAttributes()){let h=yf(i,f);eb(f,r,t,h,n),d.swap(f,h)}if(r&&r.listParents().length===1)r.dispose();for(let d of u)if(d.listParents().length===1)d.dispose();return e}function eb(e,t,n,i,r){let s=e.getElementSize(),a=e.getArray(),o=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new a.constructor(r*s),u=new Uint8Array(r);for(let d=0;d<c;d++){let f=o?o[d]:d,h=n[f];if(u[h])continue;for(let b=0;b<s;b++)l[h*s+b]=a[f*s+b];u[h]=1}return i.setArray(l)}function W3(e){let t=vf(e,"upload"),n=e.getIndices(),i=n?n.getArray():null;if(!n||!i)return[z3(t,1e6),t];let r=new Uint32Array(t).fill(dM),s=0;for(let a=0;a<i.length;a++){let o=i[a];if(r[o]===dM)r[o]=s++}return[r,s]}function X3(){var e=new _f(3);if(_f!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function q3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function tb(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function nb(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function fM(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function J3(e,t,n){var i=t[0],r=t[1],s=t[2],a=n[3]*i+n[7]*r+n[11]*s+n[15];return a=a||1,e[0]=(n[0]*i+n[4]*r+n[8]*s+n[12])/a,e[1]=(n[1]*i+n[5]*r+n[9]*s+n[13])/a,e[2]=(n[2]*i+n[6]*r+n[10]*s+n[14])/a,e}function sb(e=Qg){let t=wf(Qg,e),n=new Set(t.propertyTypes);for(let i of t.propertyTypes)if(!Qg.propertyTypes.includes(i))throw Error(`${qs}: Unsupported deduplication on type "${i}".`);return Af(qs,(i)=>{let r=i.getLogger();if(n.has(Q.ACCESSOR))Y3(i);if(n.has(Q.TEXTURE))e9(i,t);if(n.has(Q.MATERIAL))t9(i,t);if(n.has(Q.MESH))Q3(i,t);if(n.has(Q.SKIN))n9(i,t);r.debug(`${qs}: Complete.`)})}function Y3(e){let t=e.getLogger(),n=new Map,i=new Map,r=new Map,s=new Map,a=e.getRoot().listMeshes();a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((h)=>o(h,i)),o(f.getIndices(),n)})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers())o(f.getInput(),r),o(f.getOutput(),s);function o(d,f){if(!d)return;let h=[d.getCount(),d.getType(),d.getComponentType(),d.getNormalized(),d.getSparse()].join(":"),b=f.get(h);if(!b)f.set(h,b=new Set);b.add(d)}function c(d,f){for(let h=0;h<d.length;h++){let b=d[h],m=Ze.toView(b.getArray());if(f.has(b))continue;for(let g=h+1;g<d.length;g++){let p=d[g];if(f.has(p))continue;if(Ze.equals(m,Ze.toView(p.getArray())))f.set(p,b)}}}let l=0,u=new Map;for(let d of[i,n,r,s])for(let f of d.values())l+=f.size,c(Array.from(f),u);t.debug(`${qs}: Merged ${u.size} of ${l} accessors.`),a.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((b)=>{if(u.has(b))f.swap(b,u.get(b))});let h=f.getIndices();if(h&&u.has(h))f.swap(h,u.get(h))})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers()){let h=f.getInput(),b=f.getOutput();if(h&&u.has(h))f.swap(h,u.get(h));if(b&&u.has(b))f.swap(b,u.get(b))}Array.from(u.keys()).forEach((d)=>d.dispose())}function Q3(e,t){let n=e.getLogger(),i=e.getRoot(),r=new Map;i.listAccessors().forEach((o,c)=>r.set(o,c)),i.listMaterials().forEach((o,c)=>r.set(o,c));let s=i.listMeshes().length,a=new Map;for(let o of i.listMeshes()){let c=[];for(let u of o.listPrimitives())c.push(IM(u,r));let l="";if(t.keepUniqueNames)l+=o.getName()+";";if(l+=c.join(";"),a.has(l)){let u=a.get(l);o.listParents().forEach((d)=>{if(d.propertyType!==Q.ROOT)d.swap(o,u)}),o.dispose()}else a.set(l,o)}n.debug(`${qs}: Merged ${s-a.size} of ${s} meshes.`)}function e9(e,t){let n=e.getLogger(),i=e.getRoot(),r=i.listTextures(),s=new Map;for(let a=0;a<r.length;a++){let o=r[a],c=o.getImage();if(s.has(o))continue;for(let l=a+1;l<r.length;l++){let u=r[l],d=u.getImage();if(s.has(u))continue;if(o.getMimeType()!==u.getMimeType())continue;if(t.keepUniqueNames&&o.getName()!==u.getName())continue;let f=o.getSize(),h=u.getSize();if(!f||!h)continue;if(f[0]!==h[0])continue;if(f[1]!==h[1])continue;if(!c||!d)continue;if(Ze.equals(c,d))s.set(u,o)}}n.debug(`${qs}: Merged ${s.size} of ${i.listTextures().length} textures.`),Array.from(s.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Ps))c.swap(a,o)}),a.dispose()})}function t9(e,t){let n=e.getLogger(),i=e.getRoot().listMaterials(),r=new Map,s=new Map,a=new Set;if(!t.keepUniqueNames)a.add("name");for(let o=0;o<i.length;o++){let c=i[o];if(r.has(c))continue;if(hM(c,s))continue;for(let l=o+1;l<i.length;l++){let u=i[l];if(r.has(u))continue;if(hM(u,s))continue;if(c.equals(u,a))r.set(u,c)}}n.debug(`${qs}: Merged ${r.size} of ${i.length} materials.`),Array.from(r.entries()).forEach(([o,c])=>{o.listParents().forEach((l)=>{if(!(l instanceof Ps))l.swap(o,c)}),o.dispose()})}function n9(e,t){let n=e.getLogger(),i=e.getRoot().listSkins(),r=new Map,s=new Set(["joints"]);if(!t.keepUniqueNames)s.add("name");for(let a=0;a<i.length;a++){let o=i[a];if(r.has(o))continue;for(let c=a+1;c<i.length;c++){let l=i[c];if(r.has(l))continue;if(o.equals(l,s)&&B3(o.listJoints(),l.listJoints()))r.set(l,o)}}n.debug(`${qs}: Merged ${r.size} of ${i.length} skins.`),Array.from(r.entries()).forEach(([a,o])=>{a.listParents().forEach((c)=>{if(!(c instanceof Ps))c.swap(a,o)}),a.dispose()})}function IM(e,t){let n=[];for(let i of e.listSemantics()){let r=e.getAttribute(i);n.push(i+":"+t.get(r))}if(e instanceof Zn){let i=e.getIndices();if(i)n.push("indices:"+t.get(i));let r=e.getMaterial();if(r)n.push("material:"+t.get(r));n.push("mode:"+e.getMode());for(let s of e.listTargets())n.push("target:"+IM(s,t))}return n.join(",")}function hM(e,t){if(t.has(e))return t.get(e);let n=e.getGraph(),i=new Set,r=n.listParentEdges(e);while(r.length>0){let s=r.pop();if(s.getAttributes().modifyChild===!0)return t.set(e,!0),!0;let a=s.getChild();if(i.has(a))continue;for(let o of n.listChildEdges(a))r.push(o)}return t.set(e,!1),!1}function CM(){var e=new _f(4);if(_f!=Float32Array)e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e}function i9(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function r9(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function s9(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function a9(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function o9(e){var t=e[0],n=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+n*n+i*i+r*r)}function u9(e){return e.getGraph().listParentEdges(e).some((t)=>t.getAttributes().isColor||l9.test(t.getName()))?"srgb":null}function d9(e){let t=e.getGraph(),n=new Set,i=new Set;function r(s){let a=new Set;for(let o of t.listChildEdges(s))if(o.getChild()instanceof Xo)a.add(o.getName()+"Info");for(let o of t.listChildEdges(s)){let c=o.getChild();if(n.has(c))continue;if(n.add(c),c instanceof wt&&a.has(o.getName()))i.add(c);else if(c instanceof nt)r(c)}}return r(e),Array.from(i)}function f9(e){let t=of.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter((i)=>i.getParent()!==t).map((i)=>i.getName());return Array.from(new Set(n))}function Sf(e=pM){let t=wf(pM,e),n=new Set(t.propertyTypes),i=t.keepExtras;return Af(Yo,async(r)=>{let s=r.getLogger(),a=r.getRoot(),o=r.getGraph(),c=new h9,l=(u)=>c.dispose(u.target);if(o.addEventListener("node:dispose",l),n.has(Q.MESH))for(let u of a.listMeshes()){if(u.listPrimitives().length>0)continue;u.dispose()}if(n.has(Q.NODE)){if(!t.keepLeaves)for(let u of a.listScenes())OM(o,u,i);for(let u of a.listNodes())Si(u,i)}if(n.has(Q.SKIN))for(let u of a.listSkins())Si(u,i);if(n.has(Q.MESH))for(let u of a.listMeshes())Si(u,i);if(n.has(Q.CAMERA))for(let u of a.listCameras())Si(u,i);if(n.has(Q.PRIMITIVE))mM(o,Q.PRIMITIVE,i);if(n.has(Q.PRIMITIVE_TARGET))mM(o,Q.PRIMITIVE_TARGET,i);if(!t.keepAttributes&&n.has(Q.ACCESSOR)){let u=new Map;for(let d of a.listMeshes())for(let f of d.listPrimitives()){let h=f.getMaterial();if(!h)continue;let b=p9(f,kM(r,f,h));gM(f,b),f.listTargets().forEach((m)=>gM(m,b)),u.has(h)?u.get(h).add(f):u.set(h,new Set([f]))}for(let[d,f]of u)m9(d,Array.from(f))}if(n.has(Q.ANIMATION))for(let u of a.listAnimations()){for(let d of u.listChannels())if(!d.getTargetNode())d.dispose();if(!u.listChannels().length){let d=u.listSamplers();Si(u,i),d.forEach((f)=>Si(f,i))}else u.listSamplers().forEach((d)=>Si(d,i))}if(n.has(Q.MATERIAL))a.listMaterials().forEach((u)=>Si(u,i));if(n.has(Q.TEXTURE)){if(a.listTextures().forEach((u)=>Si(u,i)),!t.keepSolidTextures)await g9(r)}if(n.has(Q.ACCESSOR))a.listAccessors().forEach((u)=>Si(u,i));if(n.has(Q.BUFFER))a.listBuffers().forEach((u)=>Si(u,i));if(o.removeEventListener("node:dispose",l),!c.empty()){let u=c.entries().map(([d,f])=>`${d} (${f})`).join(", ");s.info(`${Yo}: Removed types... ${u}`)}else s.debug(`${Yo}: No unused properties found.`);s.debug(`${Yo}: Complete.`)})}function Si(e,t){let n=e.listParents().filter((r)=>!(r instanceof Ps||r instanceof Fa)),i=t&&!RM(e.getExtras());if(!n.length&&!i)e.dispose()}function mM(e,t,n){for(let i of e.listEdges()){let r=i.getParent();if(r.propertyType===t)Si(r,n)}}function OM(e,t,n){if(t.listChildren().forEach((a)=>OM(e,a,n)),t instanceof af)return;let i=e.listParentEdges(t).some((a)=>{let o=a.getParent().propertyType;return o!==Q.ROOT&&o!==Q.SCENE&&o!==Q.NODE}),r=e.listChildren(t).length===0,s=n&&!RM(t.getExtras());if(r&&!i&&!s)t.dispose()}function gM(e,t){for(let n of t)e.setAttribute(n,null)}function p9(e,t){let n=[];for(let i of e.listSemantics())if(i==="NORMAL"&&!t.has(i))n.push(i);else if(i==="TANGENT"&&!t.has(i))n.push(i);else if(i.startsWith("TEXCOORD_")&&!t.has(i))n.push(i);else if(i.startsWith("COLOR_")&&i!=="COLOR_0")n.push(i);return n}function kM(e,t,n,i=new Set){let r=e.getGraph().listChildEdges(n),s=new Set;for(let c of r)if(c.getChild()instanceof Xo)s.add(c.getName());for(let c of r){let l=c.getName(),u=c.getChild();if(u instanceof wt){if(s.has(l.replace(/Info$/,"")))i.add(`TEXCOORD_${u.getTexCoord()}`)}if(u instanceof Xo&&l.match(/normalTexture/i))i.add("TANGENT");if(u instanceof nt)kM(e,t,u,i)}let a=n instanceof Da&&!n.getExtension("KHR_materials_unlit"),o=t.getMode()===Zn.Mode.POINTS;if(a&&!o)i.add("NORMAL");return i}function m9(e,t){let n=d9(e),i=new Set(n.map((c)=>c.getTexCoord())),r=Array.from(i).sort(),s=new Map(r.map((c,l)=>[c,l])),a=new Map(r.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(let c of n){let l=c.getTexCoord();c.setTexCoord(s.get(l))}for(let c of t){let l=c.listSemantics().filter((u)=>u.startsWith("TEXCOORD_")).sort();o(c,l),c.listTargets().forEach((u)=>o(u,l))}function o(c,l){for(let u of l){let d=c.getAttribute(u);if(!d)continue;let f=a.get(u);if(f===u)continue;c.setAttribute(f,d),c.setAttribute(u,null)}}}async function g9(e){let t=e.getRoot(),n=e.getGraph(),i=e.getLogger(),r=t.listTextures().map(async(s)=>{let a=await x9(s);if(!a)return;if(u9(s)==="srgb")$w.convertSRGBToLinear(a,a);let o=s.getName()||s.getURI(),c=s.getSize()?.join("x"),l=f9(s);for(let u of n.listParentEdges(s)){let d=u.getParent();if(d!==t&&b9(d,a,u.getName(),i))u.dispose()}if(s.listParents().length===1)s.dispose(),i.debug(`${Yo}: Removed solid-color texture "${o}" (${c}px ${l.join(", ")})`)});await Promise.all(r)}function b9(e,t,n,i){if(e instanceof Da)switch(n){case"baseColorTexture":return e.setBaseColorFactor(c9(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(Z3([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=ib;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return PM(NM(CM(),t,[0.5,0.5,1,1]))<=ib}return i.warn(`${Yo}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function x9(e){let t=await y9(e);if(!t)return null;let n=[1/0,1/0,1/0,1/0],i=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[s,a]=t.shape;for(let o=0;o<s;o++){for(let c=0;c<a;c++)for(let l=0;l<4;l++)n[l]=Math.min(n[l],t.get(o,c,l)),i[l]=Math.max(i[l],t.get(o,c,l));if(PM(NM(r,i,n))/255>ib)return null}return a9(r,i9(r,i,n),0.00196078431372549)}async function y9(e){try{return await lM(e.getImage(),e.getMimeType())}catch{return null}}function _9(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw Error("Limit must be positive multiple of four.");let n=e.getAttribute("POSITION").getCount(),i=e.listSemantics().filter((l)=>l.startsWith("WEIGHTS_")).length,r=new Uint16Array(i*4),s=new Float32Array(i*4),a=new Float32Array(i*4),o=new Uint32Array(i*4),c=new Uint32Array(i*4);for(let l=0;l<n;l++){Ef(e,l,"WEIGHTS",s),Ef(e,l,"JOINTS",o);for(let u=0;u<i*4;u++)r[u]=u;r.sort((u,d)=>s[u]>s[d]?-1:1);for(let u=0;u<r.length;u++)a[u]=s[r[u]],c[u]=o[r[u]];Tf(e,l,"WEIGHTS",a),Tf(e,l,"JOINTS",c)}for(let l=i;l*4>t;l--){let u=e.getAttribute(`WEIGHTS_${l-1}`),d=e.getAttribute(`JOINTS_${l-1}`);if(e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1)u.dispose();if(d.listParents().length===1)d.dispose()}v9(e)}function v9(e){if(!E9(e))return;let t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter((d)=>d.startsWith("WEIGHTS_")).length,i=e.getAttribute("WEIGHTS_0"),r=i.getArray(),s=i.getComponentType(),a=i.getNormalized(),o=a?s:void 0,c=a?mt.decodeNormalizedInt(1,s):Number.EPSILON,l=new Uint32Array(n*4).fill(0),u=r.slice(0,n*4).fill(0);for(let d=0;d<t;d++){Ef(e,d,"JOINTS",l),Ef(e,d,"WEIGHTS",u,o);let f=bM(u,o);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let h=0;h<u.length;h++)if(a){let b=mt.decodeNormalizedInt(u[h],s);u[h]=mt.encodeNormalizedInt(b/f,s)}else u[h]/=f;if(f=bM(u,o),a&&f!==1){for(let h=u.length-1;h>=0;h--)if(u[h]>0){let b=1-f;u[h]+=Math.sign(b)*mt.encodeNormalizedInt(Math.abs(b),s);break}}}for(let h=u.length-1;h>=0;h--)if(u[h]===0)l[h]=0;Tf(e,d,"JOINTS",l),Tf(e,d,"WEIGHTS",u,o)}}function Ef(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){s.getElement(t,a);for(let c=0;c<4;c++)if(r)i[o*4+c]=mt.encodeNormalizedInt(a[c],r);else i[o*4+c]=a[c]}return i}function Tf(e,t,n,i,r){let s,a=[0,0,0,0];for(let o=0;s=e.getAttribute(`${n}_${o}`);o++){for(let c=0;c<4;c++)if(r)a[c]=mt.decodeNormalizedInt(i[o*4+c],r);else a[c]=i[o*4+c];s.setElement(t,a)}}function bM(e,t){let n=0;for(let i=0;i<e.length;i++)if(t)n+=mt.decodeNormalizedInt(e[i],t);else n+=e[i];return n}function E9(e){let t=e.listSemantics().filter((r)=>r.startsWith("WEIGHTS_")).map((r)=>e.getAttribute(r)),n=t.map((r)=>r.getNormalized()),i=t.map((r)=>r.getComponentType());return new Set(n).size===1&&new Set(i).size===1}function DM(e=xf){let t=wf(xf,{patternTargets:e.pattern||xf.pattern,...e});return Af(Xs,async(n)=>{let i=n.getLogger(),r=n.getRoot();if(n.hasExtension("KHR_mesh_primitive_restart"))throw Error("quantize: Missing support for KHR_mesh_primitive_restart.");let s;if(t.quantizationVolume==="scene")s=yM(L9(r.listMeshes().map(_M)));for(let a of n.getRoot().listMeshes()){if(t.quantizationVolume==="mesh")s=yM(_M(a));if(s&&t.pattern.test("POSITION"))I9(n,a,s),P9(a,1/s.scale);for(let o of a.listPrimitives()){if(vf(o,"render")<vf(o,"upload")/2)K3(o);xM(n,o,s,t);for(let c of o.listTargets())xM(n,c,s,t)}}if(r.listMeshes().flatMap((a)=>a.listPrimitives()).some(LM))n.createExtension(Il).setRequired(!0);if(t.cleanup)await n.transform(Sf({propertyTypes:[Q.ACCESSOR,Q.SKIN,Q.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),sb({propertyTypes:[Q.ACCESSOR,Q.MATERIAL,Q.SKIN],keepUniqueNames:!0}));i.debug(`${Xs}: Complete.`)})}function xM(e,t,n,i){let r=t instanceof Vg,s=e.getLogger();for(let a of t.listSemantics()){if(!r&&!i.pattern.test(a))continue;if(r&&!i.patternTargets.test(a))continue;let o=t.getAttribute(a),{bits:c,ctor:l}=k9(a,o,s,i);if(!l)continue;if(c<8||c>16)throw Error(`${Xs}: Requires bits = 8–16.`);if(o.getComponentSize()<=c/8)continue;let u=o.clone();if(a==="POSITION"){let d=n.scale,f=[];t instanceof Zn?V3(f,Mf(n)):j3(f,[1/d,1/d,1/d]);for(let h=0,b=[0,0,0],m=u.getCount();h<m;h++)u.getElement(h,b),u.setElement(h,J3(b,b,f))}O9(u,l,c),t.setAttribute(a,u)}if(i.normalizeWeights&&t.getAttribute("WEIGHTS_0"))_9(t,1/0);if(t instanceof Zn&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){let a=t.getIndices();a.setArray(new Uint16Array(a.getArray()))}}function yM(e){let{min:t,max:n}=e,i=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:i}}function I9(e,t,n){let i=Mf(n);for(let r of t.listParents()){if(!(r instanceof sf))continue;let s=r.listParents().filter((f)=>f instanceof Fa),a=s.some((f)=>R9.includes(f.getTargetPath())),o=r.listChildren().length>0,c=r.getSkin();if(c){r.setSkin(C9(c,n));continue}let l=r.getExtension("EXT_mesh_gpu_instancing");if(l){r.setExtension("EXT_mesh_gpu_instancing",N9(e,l,n));continue}let u;if(o||a)u=e.createNode("").setMesh(t),r.addChild(u).setMesh(null),s.filter((f)=>f.getTargetPath()===M9).forEach((f)=>f.setTargetNode(u));else u=r;let d=u.getMatrix();rb(d,d,i),u.setMatrix(d)}}function C9(e,t){e=e.clone();let n=Mf(t),i=e.getInverseBindMatrices().clone(),r=[];for(let s=0,a=i.getCount();s<a;s++)i.getElement(s,r),rb(r,r,n),i.setElement(s,r);return e.setInverseBindMatrices(i)}function N9(e,t,n){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let i=t.getAttribute("TRANSLATION")?.clone(),r=t.getAttribute("ROTATION")?.clone(),s=t.getAttribute("SCALE")?.clone(),a=i||r||s,o=[0,0,0],c=[0,0,0,1],l=[1,1,1];if(!i&&n.offset)i=e.createAccessor().setType("VEC3").setArray(EM(a.getCount(),o));if(!s&&n.scale)s=e.createAccessor().setType("VEC3").setArray(EM(a.getCount(),l));let u=[0,0,0],d=[0,0,0,1],f=[1,1,1],h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],b=Mf(n);for(let m=0,g=a.getCount();m<g;m++){if(mt.compose(i?i.getElement(m,u):o,r?r.getElement(m,d):c,s?s.getElement(m,f):l,h),rb(h,h,b),mt.decompose(h,u,d,f),i)i.setElement(m,u);if(r)r.setElement(m,d);if(s)s.setElement(m,f)}if(i)t.setAttribute("TRANSLATION",i);if(r)t.setAttribute("ROTATION",r);if(s)t.setAttribute("SCALE",s);return t}function P9(e,t){for(let n of e.listPrimitives()){let i=n.getMaterial();if(!i)continue;let r=i.getExtension("KHR_materials_volume");if(!r||r.getThicknessFactor()<=0)continue;r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),i=i.clone().setExtension("KHR_materials_volume",r),n.setMaterial(i)}}function O9(e,t,n){let i=new t(e.getArray().length),r=T9.includes(t)?1:0,s=n-r,a=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,s)-1,c=a-s,l=2*s-a,u=[r>0?-1:0,1];for(let d=0,f=0,h=[];d<e.getCount();d++){e.getElement(d,h);for(let b=0;b<h.length;b++){let m=F9(h[b],u);m=Math.round(Math.abs(m)*o),m=m<<c|m>>l,i[f++]=m*Math.sign(h[b])}}e.setArray(i).setNormalized(!0).setSparse(!1)}function k9(e,t,n,i){let r=t.getMinNormalized([]),s=t.getMaxNormalized([]),a,o;if(e==="POSITION")a=i.quantizePosition,o=a<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")a=i.quantizeNormal,o=a<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))a=i.quantizeColor,o=a<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeTexcoord,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("JOINTS_")){if(a=Math.max(...t.getMax([]))<=255?8:16,o=a<=8?Uint8Array:Uint16Array,t.getComponentSize()>a/8)t.setArray(new o(t.getArray()));return{bits:-1}}else if(e.startsWith("WEIGHTS_")){if(r.some((c)=>c<0)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [0,1] range.`),{bits:-1};a=i.quantizeWeight,o=a<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some((c)=>c<-1)||s.some((c)=>c>1))return n.warn(`${Xs}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};a=i.quantizeGeneric,o=r.some((c)=>c<0)?o=a<=8?Int8Array:Int16Array:o=a<=8?Uint8Array:Uint16Array}else throw Error(`${Xs}: Unexpected semantic, "${e}".`);return{bits:a,ctor:o}}function _M(e){let t=[],n=[];for(let r of e.listPrimitives()){let s=r.getAttribute("POSITION");if(s)t.push(s);for(let a of r.listTargets()){let o=a.getAttribute("POSITION");if(o)n.push(o)}}if(t.length===0)throw Error(`${Xs}: Missing "POSITION" attribute.`);let i=vM(t,3);if(n.length>0){let{min:r,max:s}=vM(n,3);tb(i.min,i.min,tb(r,fM(r,r,2),[0,0,0])),nb(i.max,i.max,nb(s,fM(s,s,2),[0,0,0]))}return i}function D9(e,t){let n=t.getComponentSize();if(e==="POSITION")return n<4;if(e==="NORMAL")return n<4;if(e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){let i=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&i===Oe.ComponentType.UNSIGNED_BYTE)&&!(r&&i===Oe.ComponentType.UNSIGNED_SHORT)}return!1}function LM(e){for(let t of e.listSemantics())if(D9(t,e.getAttribute("POSITION")))return!0;if(e.propertyType===Q.PRIMITIVE)return e.listTargets().some(LM);return!1}function vM(e,t){let n=Array(t).fill(1/0),i=Array(t).fill(-1/0),r=[],s=[];for(let a of e){a.getMinNormalized(r),a.getMaxNormalized(s);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),i[o]=Math.max(i[o],s[o])}return{min:n,max:i}}function L9(e){let t=e[0];for(let n of e)tb(t.min,t.min,n.min),nb(t.max,t.max,n.max);return t}function Mf(e){return H3([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function F9(e,t){return Math.min(Math.max(e,t[0]),t[1])}function EM(e,t){let n=t.length,i=new Float32Array(e*n);for(let r=0;r<e;r++)i.set(t,r*n);return i}function FM(e){let t=wf(U9,e),n=t.encoder;if(!n)throw Error(`${gf}: encoder dependency required — install "meshoptimizer".`);return Af(gf,async(i)=>{let r=i.getLogger();if(i.hasExtension("KHR_mesh_primitive_restart"))throw Error("reorder: Missing support for KHR_mesh_primitive_restart.");await n.ready;let s=B9(i);for(let a of s.indicesToAttributes.keys()){let o=a.getArray();if(!(o instanceof Uint32Array))o=new Uint32Array(o);else o=o.slice();let[c,l]=n.reorderMesh(o,s.indicesToMode.get(a)===Zn.Mode.TRIANGLES,t.target==="size"),u=yf(i,a);u.setArray(l<=65534?new Uint16Array(o):o);for(let d of s.indicesToAttributes.get(a)){let f=yf(i,d);eb(d,a,c,f,l);for(let h of s.indicesToPrimitives.get(a)){if(h.getIndices()===a)h.swap(a,u);h.swap(d,f);for(let b of h.listTargets())b.swap(d,f)}}}if(t.cleanup)await i.transform(Sf({propertyTypes:[Q.ACCESSOR],keepAttributes:!0,keepIndices:!0}));if(!s.indicesToAttributes.size)r.warn(`${gf}: No qualifying primitives found; may need to weld first.`);else r.debug(`${gf}: Complete.`)})}function B9(e){let t=new Map,n=new Yg,i=new Yg,r=new Yg;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=a.getIndices();if(!o)continue;t.set(o,a.getMode()),n.add(o,a);for(let c of SM(a))i.add(o,c),r.add(c,a)}return{indicesToPrimitives:n,indicesToAttributes:i,indicesToMode:t,attributesToPrimitives:r}}function V9(e,t,n,i=0.0001){let r=t.length/e.length,s=Array(r).fill(0),a=Array(r).fill(0),o=Array(r).fill(0),c=Array(r).fill(0),l=e.length-1,u=1;for(let d=1;d<l;++d){let f=e[u-1],h=e[d],b=e[d+1],m=(h-f)/(b-f),g=!1;if(h!==b&&(d!==1||h!==e[0])){if(Cl(t,u-1,c),Cl(t,d,a),Cl(t,d+1,o),n==="slerp"){let p=G9(s,c,o,m),x=wM(c,a)+wM(a,o);g=!bf(a,p,i)||x+Number.EPSILON>=Math.PI}else if(n==="lerp")g=!bf(a,H9(s,c,o,m),i);else if(n==="step")g=!bf(a,c)||!bf(a,o)}if(g){if(d!==u)e[u]=e[d],AM(t,u,Cl(t,d,s));u++}}if(l>0)e[u]=e[l],AM(t,u,Cl(t,l,s)),u++;return u}function Cl(e,t,n){for(let i=0,r=n.length;i<r;i++)n[i]=e[t*r+i];return n}function AM(e,t,n){for(let i=0,r=n.length;i<r;i++)e[t*r+i]=n[i]}function bf(e,t,n=0){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(Math.abs(e[i]-t[i])>n)return!1;return!0}function j9(e,t,n){return e*(1-n)+t*n}function H9(e,t,n,i){for(let r=0;r<t.length;r++)e[r]=j9(t[r],n[r],i);return e}function G9(e,t,n,i){let r=t[0],s=t[1],a=t[2],o=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,b,m,g;if(h=r*c+s*l+a*u+o*d,h<0)h=-h,c=-c,l=-l,u=-u,d=-d;if(1-h>z9)f=Math.acos(h),b=Math.sin(f),m=Math.sin((1-i)*f)/b,g=Math.sin(i*f)/b;else m=1-i,g=i;return e[0]=m*r+g*c,e[1]=m*s+g*l,e[2]=m*a+g*u,e[3]=m*o+g*d,e}function wM(e,t){let n=$9(e,t);return Math.acos(2*n*n-1)}function $9(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}var U3,mK,gK,bK,xK,yK,_K,vK,Yg=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let n=this._map.get(e);if(!n)n=new Set,this._map.set(e,n);return n.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}},EK,_f,dM=4294967295,Z3,TK,AK,wK,SK,MK,RK,IK,qs="dedup",Qg,CK,NK,NM,c9,PM,l9,Yo="prune",ib=0.011764705882352941,pM,h9=class{disposed={};empty(){for(let e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}},PK,OK,kK,DK,LK,Xs="quantize",T9,A9,w9,S9,M9,R9,xf,gf="reorder",U9,FK,TM,z9=0.000001,UK,BK,zK,VK,jK,HK,GK,$K;var UM=ut(()=>{qo();uM();hf();U3=Bf(qg(),1),{POINTS:mK,LINES:gK,LINE_STRIP:bK,LINE_LOOP:xK,TRIANGLES:yK,TRIANGLE_STRIP:_K,TRIANGLE_FAN:vK}=Zn.Mode;EK=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});_f=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;Z3=q3;(function(){var e=X3();return function(t,n,i,r,s,a){var o,c;if(!n)n=3;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();({FLOAT:TK}=Oe.ComponentType),{LINES:AK,LINE_STRIP:wK,LINE_LOOP:SK,TRIANGLES:MK,TRIANGLE_STRIP:RK,TRIANGLE_FAN:IK}=Zn.Mode,Qg={keepUniqueNames:!1,propertyTypes:[Q.ACCESSOR,Q.MESH,Q.TEXTURE,Q.MATERIAL,Q.SKIN]};({TEXTURE_INFO:CK,ROOT:NK}=Q);NM=r9,c9=s9,PM=o9;(function(){var e=CM();return function(t,n,i,r,s,a){var o,c;if(!n)n=4;if(!i)i=0;if(r)c=Math.min(r*n+i,t.length);else c=t.length;for(o=i;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],s(e,e,a),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();l9=/color|emissive|diffuse/i;pM={propertyTypes:[Q.NODE,Q.SKIN,Q.MESH,Q.CAMERA,Q.PRIMITIVE,Q.PRIMITIVE_TARGET,Q.ANIMATION,Q.MATERIAL,Q.TEXTURE,Q.ACCESSOR,Q.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};({ROOT:PK,NODE:OK,MESH:kK,PRIMITIVE:DK,ACCESSOR:LK}=Q);T9=[Int8Array,Int16Array,Int32Array],{TRANSLATION:A9,ROTATION:w9,SCALE:S9,WEIGHTS:M9}=Fa.TargetPath,R9=[A9,w9,S9],xf={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};U9={target:"size",cleanup:!0};FK={level:"high",...xf};(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(TM||(TM={}));UK={ready:Promise.resolve(),resample:V9,tolerance:0.0001,cleanup:!0},{POINTS:BK,LINES:zK,LINE_STRIP:VK,LINE_LOOP:jK,TRIANGLES:HK,TRIANGLE_STRIP:GK,TRIANGLE_FAN:$K}=Zn.Mode});function zM(e,t,n,i={}){if(!Array.isArray(t))return e.push({code:"EXPECTED_ARRAY",path:n,message:`${n} must be an array.`}),!1;if(!i.allowEmpty&&t.length===0)e.push({code:"EXPECTED_NONEMPTY_ARRAY",path:n,message:`${n} must not be empty.`});let r=new Set;for(let s=0;s<t.length;s++){let a=t[s];if(!$r(a)){e.push({code:"EXPECTED_NONEMPTY_STRING",path:`${n}[${s}]`,message:`${n}[${s}] must be a trimmed non-empty string.`});continue}if(r.has(a))e.push({code:"DUPLICATE_VALUE",path:`${n}[${s}]`,message:`${n} contains duplicate value ${JSON.stringify(a)}.`});r.add(a)}return!0}function X9(e,t,n){let i=`frames[${t}]`;if(!Js(e))return n.push({code:"INVALID_FRAME",path:i,message:`${i} must be an object.`}),!1;if(!$r(e.id))n.push({code:"INVALID_FRAME_ID",path:`${i}.id`,message:"Frame ID is required."});if(!BM(e.translation,3))n.push({code:"INVALID_FRAME_TRANSLATION",path:`${i}.translation`,message:"Frame translation must be three finite meters."});if(!BM(e.rotation,4))n.push({code:"INVALID_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation must be a finite quaternion."});else{let r=Math.hypot(...e.rotation);if(Math.abs(r-1)>0.000001)n.push({code:"NON_UNIT_FRAME_ROTATION",path:`${i}.rotation`,message:"Frame rotation quaternion must be normalized within 1e-6."})}return!0}function q9(e,t,n){let i=`relationships[${t}]`;if(!Js(e))return n.push({code:"INVALID_RELATIONSHIP",path:i,message:`${i} must be an object.`}),!1;for(let r of["kind","target"])if(!$r(e[r]))n.push({code:"INVALID_RELATIONSHIP_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(e.targetType!=="node"&&e.targetType!=="role"&&e.targetType!=="socket")n.push({code:"INVALID_RELATIONSHIP_TARGET_TYPE",path:`${i}.targetType`,message:"Relationship targetType must be node, role, or socket."});for(let r of["sourceFrame","targetFrame"])if(e[r]!==void 0&&!$r(e[r]))n.push({code:"INVALID_RELATIONSHIP_FRAME",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});return!0}function J9(e,t,n){let i=`sockets[${t}]`;if(!Js(e))return n.push({code:"INVALID_SOCKET",path:i,message:`${i} must be an object.`}),!1;for(let r of["id","type","frame"])if(!$r(e[r]))n.push({code:"INVALID_SOCKET_FIELD",path:`${i}.${r}`,message:`${i}.${r} must be a trimmed non-empty string.`});if(zM(n,e.compatibleTypes,`${i}.compatibleTypes`,{allowEmpty:!0}),e.allowedRotationsDegrees!==void 0){if(!Array.isArray(e.allowedRotationsDegrees)||e.allowedRotationsDegrees.some((r)=>typeof r!=="number"||!Number.isFinite(r)))n.push({code:"INVALID_ALLOWED_ROTATIONS",path:`${i}.allowedRotationsDegrees`,message:"Allowed rotations must be finite degree values."})}return!0}function Z9(e){let t=[];if(!Js(e))return{valid:!1,issues:[{code:"EXPECTED_OBJECT",path:"",message:"SemanticMetadataV1 must be an object."}]};if(e.schemaVersion!==1)t.push({code:"UNSUPPORTED_SCHEMA_VERSION",path:"schemaVersion",message:"schemaVersion must be 1."});zM(t,e.roles,"roles");let n=Array.isArray(e.frames)?e.frames:[];if(!Array.isArray(e.frames))t.push({code:"EXPECTED_ARRAY",path:"frames",message:"frames must be an array."});let i=new Set;n.forEach((o,c)=>{if(X9(o,c,t),Js(o)&&$r(o.id)){if(i.has(o.id))t.push({code:"DUPLICATE_FRAME_ID",path:`frames[${c}].id`,message:`Duplicate frame ID ${JSON.stringify(o.id)}.`});i.add(o.id)}});let r=Array.isArray(e.relationships)?e.relationships:[];if(!Array.isArray(e.relationships))t.push({code:"EXPECTED_ARRAY",path:"relationships",message:"relationships must be an array."});r.forEach((o,c)=>{if(q9(o,c,t),Js(o))for(let l of["sourceFrame","targetFrame"]){let u=o[l];if($r(u)&&!i.has(u))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`relationships[${c}].${l}`,message:`Unknown frame ${JSON.stringify(u)}.`})}});let s=Array.isArray(e.sockets)?e.sockets:[];if(!Array.isArray(e.sockets))t.push({code:"EXPECTED_ARRAY",path:"sockets",message:"sockets must be an array."});let a=new Set;if(s.forEach((o,c)=>{if(J9(o,c,t),Js(o)&&$r(o.id)){if(a.has(o.id))t.push({code:"DUPLICATE_SOCKET_ID",path:`sockets[${c}].id`,message:`Duplicate socket ID ${JSON.stringify(o.id)}.`});a.add(o.id)}if(Js(o)&&$r(o.frame)&&!i.has(o.frame))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`sockets[${c}].frame`,message:`Unknown frame ${JSON.stringify(o.frame)}.`})}),t.length>0)return{valid:!1,issues:t};return{valid:!0,value:Y9(e),issues:t}}function Y9(e){return{schemaVersion:1,roles:[...e.roles],relationships:e.relationships.map((t)=>({kind:t.kind,target:t.target,targetType:t.targetType,...t.sourceFrame?{sourceFrame:t.sourceFrame}:{},...t.targetFrame?{targetFrame:t.targetFrame}:{}})),frames:e.frames.map((t)=>({id:t.id,translation:K9(t.translation),rotation:W9(t.rotation)})),sockets:e.sockets.map((t)=>({id:t.id,type:t.type,frame:t.frame,compatibleTypes:[...t.compatibleTypes],...t.allowedRotationsDegrees?{allowedRotationsDegrees:[...t.allowedRotationsDegrees]}:{}}))}}function Rf(e){let t=e.kilnSemantic;if(t===void 0)return;let n=Z9(t);return n.valid?n.value:void 0}var Zs,Js=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),$r=(e)=>typeof e==="string"&&e.trim().length>0&&e===e.trim(),BM=(e,t)=>Array.isArray(e)&&e.length===t&&e.every((n)=>typeof n==="number"&&Number.isFinite(n)),K9=(e)=>[e[0],e[1],e[2]],W9=(e)=>[e[0],e[1],e[2],e[3]];var Nl=ut(()=>{Zs=Object.freeze({vehicleFrame:"vehicle.frame",vehicleForward:"vehicle.front.+x",socket:"socket",chassis:"chassis",chassisMain:"chassis.main",axle:"axle",seat:"seat",contact:"contact",steering:"steering",propulsion:"propulsion",wheelAssembly:"wheel.assembly",wheelPivot:"wheel.pivot",wheelLoadBearing:"wheel.load-bearing",wheelTire:"wheel.tire",wheelRim:"wheel.rim",wheelHub:"wheel.hub",wheelContact:"wheel.contact",steeringPivot:"steering.pivot",roof:"roof",architectureRoof:"architecture.roof",collider:"collider",colliderBox:"collider.box",colliderCapsule:"collider.capsule",colliderHull:"collider.hull",anchor:"anchor",kitModule:"kit.module",kitPort:"kit.port",lodImpostor:"lod.impostor"})});function jM(){return new eS().registerExtensions([...BS,ab])}var fn="MSFT_lod",VM,ab;var If=ut(()=>{qo();hf();VM=class VM extends nt{static EXTENSION_NAME=fn;init(){this.extensionName=fn,this.propertyType="Lod",this.parentTypes=[Q.NODE,Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{levels:new xn})}addLevel(e){return this.addRef("levels",e)}listLevels(){return this.listRefs("levels")}removeLevel(e){return this.removeRef("levels",e)}};ab=class ab extends _t{extensionName=fn;static EXTENSION_NAME=fn;createLod(e=""){return new VM(this.document.getGraph(),e)}read(e){let t=e.jsonDoc.json;return this.readLevels(t.nodes,e.nodes),this.readLevels(t.materials,e.materials),this}readLevels(e,t){(e??[]).forEach((n,i)=>{let r=n.extensions?.[fn]?.ids,s=t[i];if(!s||!Array.isArray(r))return;let a=this.createLod();for(let o of r){let c=typeof o==="number"?t[o]:void 0;if(c&&c!==s)a.addLevel(c)}s.setExtension(fn,a)})}write(e){let t=e.jsonDoc.json,n=this.document.getRoot();for(let i of n.listNodes()){let r=e.nodeIndexMap.get(i),s=i.getExtension(fn)?.listLevels().filter((o)=>o.propertyType===Q.NODE).map((o)=>e.nodeIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.nodes?.[r];if(a&&s?.length)a.extensions={...a.extensions,[fn]:{ids:s}}}for(let i of n.listMaterials()){let r=e.materialIndexMap.get(i),s=i.getExtension(fn)?.listLevels().filter((o)=>o.propertyType===Q.MATERIAL).map((o)=>e.materialIndexMap.get(o)).filter((o)=>o!==void 0),a=r===void 0?void 0:t.materials?.[r];if(a&&s?.length)a.extensions={...a.extensions,[fn]:{ids:s}}}return this}}});var Q9;var ob=ut(()=>{Q9=Object.freeze([1,1,1])});var rW,sW;var HM=ut(()=>{ob();rW=Object.freeze({units:"m",forward:"+X",up:"+Y",right:"+Z",groundY:0}),sW=Math.PI/180});var GM=()=>{};var $M=()=>{};var KM=ut(()=>{HM();ob();GM();$M();Nl()});var eB;var WM=ut(()=>{eB=Object.freeze({parametricSamples:262144,subdivisionTriangles:1e6,subdivisionAttributeBytes:134217728,subdivisionIterations:10,repeatedMeshes:1e4,curveRepeatVertices:262144,simplifyTriangles:1e6,primitiveSegments:4096,primitiveGridVertices:262144,unwrapVertices:65536,unwrapTriangles:1e6,unwrapAttributeBytes:134217728,unwrapResolution:4096,skinBones:1024,skinVertices:262144,skinAttributeBytes:134217728,colliderHullVertices:65536,surfaceBakeVertices:262144,surfaceBakeTriangles:1e6,surfaceBakeRays:8388608,surfaceBakeRayDirections:256})});var cb="kilnRepeatInstances";var lb=ut(()=>{KM();Ac();WM()});function Pl(e){return e.getExtension("KHR_node_visibility")?.getVisible?.()===!1}var TW;var Ol=ut(()=>{TW=[{grade:"A",max:1,range:"0-1"},{grade:"B",max:3,range:"2-3"},{grade:"C",max:6,range:"4-6"},{grade:"D",max:12,range:"7-12"},{grade:"F",max:Number.POSITIVE_INFINITY,range:"13+"}]});var XM=ut(()=>{Ol()});function JM(e){let t=new Map,n=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!n)return t;let i=(r,s)=>{let a=new Map;for(let o of r){let c=o.getName(),l=a.get(c)??0;a.set(c,l+1);let u=`${s}${qM(c,l)}`;t.set(o,u),i(o.listChildren(),u)}};return i(n.listChildren(),qM(n.getName()||"Scene",0)),t}var qM=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var ZM=ut(()=>{If();Nl();lb();Ol();XM()});function iB(e,t,n){let i=0;for(let r=0;r<t;r++)if(e[r].getName()===n)i++;return i}function rB(e){let t=e.getExtras()[ub];return Array.isArray(t)&&t.every((n)=>typeof n==="number")?[...t]:void 0}function sB(e){let t=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!t)return[];let n=[],i=(r,s)=>{r.forEach((a,o)=>{let c=(d)=>`${s}${YM(d,iB(r,o,d))}`,l=c(a.getName()),u=(a.getExtension(fn)?.listLevels()??[]).filter((d)=>d.propertyType===Q.NODE);if(u.length>0)n.push({levels:[a,...u],paths:[l,...u.map((d)=>c(d.getName()))]});i(a.listChildren(),l)})};return i(t.listChildren(),YM(t.getName()||"Scene",0)),n}function QM(e,t){let n=sB(e),i=new Set;for(let{levels:a}of n)for(let o of a.slice(t+1))o.traverse((c)=>{i.add(c)});for(let a of e.getRoot().listAnimations())for(let o of a.listChannels()){let c=o.getTargetNode();if(c&&i.has(c))throw Error(`maxLod ${t} would drop ${c.getName()||"a node"}, which animation ${JSON.stringify(a.getName())} targets; keep that level.`)}let r=n.map(({levels:a,paths:o})=>{let[c,...l]=a,u=l.slice(t);if(u.length>0){let d=c.getExtension(fn);for(let b of u)d.removeLevel(b);let f={...c.getExtras()},h=rB(c);if(t===0)c.setExtension(fn,null),d.dispose(),delete f[ub];else if(h)f[ub]=h.slice(0,t+1);c.setExtras(f);for(let b of u){let m=[];b.traverse((g)=>{m.push(g)});for(let g of m.reverse())g.dispose()}}return{path:o[0],levels:a.length-u.length,dropped:u.map((d)=>d.getName())}}),s=e.getRoot();if(!s.listNodes().some((a)=>a.getExtension(fn)))s.listExtensionsUsed().find((a)=>a.extensionName===fn)?.dispose();return r}var ub="MSFT_screencoverage",YM=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var eR=ut(()=>{qo();Nl();If();Ol()});var KW,aB;var tR=ut(()=>{KW=Object.freeze({profile:"web.portable.v1",tier:"standard"}),aB=Object.freeze({"web.portable.v1":Object.freeze({hero:Object.freeze({maxImageDimension:4096,maxImageCount:8,maxDecodedBytesRgba8:134217728,maxBlendedSurfaceAreaRatio:0.35}),standard:Object.freeze({maxImageDimension:2048,maxImageCount:4,maxDecodedBytesRgba8:33554432,maxBlendedSurfaceAreaRatio:0.15}),background:Object.freeze({maxImageDimension:1024,maxImageCount:2,maxDecodedBytesRgba8:8388608,maxBlendedSurfaceAreaRatio:0.05})}),"mobile.portable.v1":Object.freeze({hero:Object.freeze({maxImageDimension:2048,maxImageCount:6,maxDecodedBytesRgba8:50331648,maxBlendedSurfaceAreaRatio:0.2}),standard:Object.freeze({maxImageDimension:1024,maxImageCount:3,maxDecodedBytesRgba8:16777216,maxBlendedSurfaceAreaRatio:0.1}),background:Object.freeze({maxImageDimension:512,maxImageCount:1,maxDecodedBytesRgba8:4194304,maxBlendedSurfaceAreaRatio:0.03})})})});var Cf="kilnBudgetV1";var nR=ut(()=>{Ac();tR()});var iR=()=>{};function Ht(e){throw TypeError(`atlas provenance: ${e}`)}function Ki(e,t){if(!e||typeof e!=="object"||Array.isArray(e))Ht("plain metadata object required.");let n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype)Ht("plain metadata prototype required.");let i=Object.getOwnPropertyDescriptor(e,t);if(!i)return;if(!i.enumerable||!("value"in i))Ht("metadata accessors/hidden fields are unsupported.");return i.value}function kl(e,t){for(let n of Reflect.ownKeys(e))if(typeof n!=="string"||!t.includes(n))Ht("unsupported metadata field.");for(let n of t)Ki(e,n);return e}function cB(e){Rn(e);let t=kl(e,["spec","manifest"]),n=pa(t.spec);return{spec:n,manifest:Cc(t.manifest,n)}}function lB(e){let t=kl(e,["version","atlases"]);if(t.version!==Qo)Ht("unsupported version.");let n=t.atlases;if(!Array.isArray(n)||Object.getPrototypeOf(n)!==Array.prototype)Ht("dense atlas array required.");let i=Object.getOwnPropertyDescriptor(n,"length").value;if(i>Ua.atlases||Reflect.ownKeys(n).length!==i+1)Ht("atlas count/density budget exceeded.");let r=oB,s=[];for(let a=0;a<i;a++){let o=Object.getOwnPropertyDescriptor(n,String(a));if(!o?.enumerable||!("value"in o))Ht("atlas array accessors are unsupported.");let c=Rn(o.value);if(r+=new TextEncoder().encode(c).length+(a>0?1:0),r>Ua.bytes)Ht("aggregate metadata byte budget exceeded.");s.push(kl(o.value,["id","spec","manifest"]))}return s}function uB(e){let t=lB(e),n=new Set,i=[];for(let r of t){let s=cB({spec:r.spec,manifest:r.manifest});if(r.id!==s.manifest.manifestHash||n.has(r.id))Ht("duplicate or mismatched atlas identity.");n.add(r.id),i.push({id:r.id,...s})}return{version:Qo,atlases:i}}function rR(e,t){let n=e.atlases.find((i)=>i.id===t);if(!n)Ht("unknown atlas reference.");return n}function dB(e,t,n,i){if(!["top-left","bottom-left"].includes(n)||!["content-boundary","texel-center"].includes(i))Ht("explicit binding origin/mode required.");let r=e.manifest.regions.find((d)=>d.name===t);if(!r)Ht("unknown named region.");let{x:s,y:a,width:o,height:c}=r.content,l=i==="texel-center",u=n==="bottom-left";return{manifestHash:e.manifest.manifestHash,specHash:e.manifest.specHash,layoutHash:e.manifest.layoutHash,region:r.name,content:structuredClone(r.content),allocation:structuredClone(r.allocation),inputOrigin:n,mode:i,scale:[(o-(l?1:0))/e.manifest.width,(u?-1:1)*(c-(l?1:0))/e.manifest.height],offset:[(s+(l?0.5:0))/e.manifest.width,(a+(u?c-(l?0.5:0):l?0.5:0))/e.manifest.height]}}function fB(e,t){Rn(e);let n=kl(e,["version","atlasId","region","inputOrigin","mode"]);if(n.version!==Qo)Ht("unsupported binding version.");return dB(rR(t,n.atlasId),n.region,n.inputOrigin,n.mode)}function hB(e){let t=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];return t?Ki(t.getExtras(),"kilnAtlasProvenance"):void 0}function sR(e){let t=hB(e);return t===void 0?void 0:uB(t)}function aR(e){let t=[];for(let n of e.getRoot().listMaterials())for(let[i,r]of[[n.getBaseColorTexture(),n.getBaseColorTextureInfo()],[n.getNormalTexture(),n.getNormalTextureInfo()],[n.getMetallicRoughnessTexture(),n.getMetallicRoughnessTextureInfo()],[n.getEmissiveTexture(),n.getEmissiveTextureInfo()],[n.getOcclusionTexture(),n.getOcclusionTextureInfo()]])if(i&&r&&Ki(r.getExtras(),"kilnAtlasReference")!==void 0){if(t.length>=Ua.bindings)Ht("document binding budget exceeded.");t.push({texture:i,info:r})}return t}async function oR(e){let t=e.getImage();if(!t||t.byteLength>Ua.encodedBytes)Ht("encoded image missing or over budget.");let n=await crypto.subtle.digest("SHA-256",t);return`sha256:${[...new Uint8Array(n)].map((i)=>i.toString(16).padStart(2,"0")).join("")}`}function cR(e){let t={minFilter:e.getMinFilter(),magFilter:e.getMagFilter(),wrapS:e.getWrapS(),wrapT:e.getWrapT()};if(![null,9728,9729,9984,9985,9986,9987].includes(t.minFilter)||![null,9728,9729].includes(t.magFilter)||![33071,33648,10497].includes(t.wrapS)||![33071,33648,10497].includes(t.wrapT))Ht("unsupported effective sampler.");return t}function lR(e,t){Rn(e);let n=kl(e,["version","id","effectiveSampler","finalMime","finalImageSha256"]);if(n.version!==Qo)Ht("unsupported texture reference version.");return rR(t,n.id),n}function uR(e){let t=new Set,n=0;for(let{texture:i}of e){if(t.has(i))continue;t.add(i);let r=i.getImage();if(!r||r.byteLength>Ua.encodedBytes)Ht("encoded image missing or over budget.");if(n+=r.byteLength,n>Ua.aggregateEncodedBytes)Ht("aggregate encoded image hash budget exceeded.")}}async function dR(e){let t=sR(e),n=aR(e);if(!n.length)return;if(!t)Ht("atlas table missing.");uR(n);let i=new Map;for(let{texture:r,info:s}of n){let a=lR(Ki(s.getExtras(),"kilnAtlasReference"),t),o=i.get(r);if(!o)o=await oR(r),i.set(r,o);s.setExtras({...s.getExtras(),kilnAtlasReference:{version:Qo,id:a.id,effectiveSampler:cR(s),finalMime:r.getMimeType(),finalImageSha256:o}})}}async function fR(e){let t=sR(e),n=aR(e);if(n.length&&!t)Ht("atlas table missing.");if(!t){for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives())if(Ki(a.getExtras(),"kilnAtlasBinding")!==void 0)Ht("atlas table missing.");return}uR(n);let i=new Map;for(let{texture:s,info:a}of n){let o=lR(Ki(a.getExtras(),"kilnAtlasReference"),t),c=i.get(s);if(!c)c=await oR(s),i.set(s,c);if(o.finalImageSha256!==c||o.finalMime!==s.getMimeType()||Rn(o.effectiveSampler)!==Rn(cR(a)))Ht("final image or effective sampler identity mismatch.")}let r=0;for(let s of e.getRoot().listMeshes())for(let a of s.listPrimitives()){let o=Ki(a.getExtras(),"kilnAtlasBinding");if(o!==void 0){if(++r>Ua.bindings)Ht("primitive budget exceeded.");fB(o,t);let c=a.getMaterial(),l=Ki(o,"atlasId");if(!(c?[c.getBaseColorTextureInfo(),c.getNormalTextureInfo(),c.getMetallicRoughnessTextureInfo(),c.getEmissiveTextureInfo(),c.getOcclusionTextureInfo()]:[]).some((d)=>d&&Ki(d.getExtras(),"kilnAtlasReference")!==void 0&&Ki(Ki(d.getExtras(),"kilnAtlasReference"),"id")===l))Ht("named binding has no matching material atlas reference.")}}}var Qo="kiln.atlas-provenance.v1",oB,Ua;var hR=ut(()=>{iR();Fu();oB=new TextEncoder().encode(JSON.stringify({version:Qo,atlases:[]})).length,Ua=Object.freeze({atlases:128,bytes:4194304,bindings:1024,entryBytes:262144,encodedBytes:16777216,aggregateEncodedBytes:67108864,bakeDecodedBytes:67108864})});var bR={};Lb(bR,{deliverRuntimeThreeGlb:()=>AB});function gB(e,t){let n=(i)=>{if(!i)return-1;if(!t.has(i))t.set(i,t.size);return t.get(i)};return e.listPrimitives().map((i)=>`${i.getMode()}:${n(i.getMaterial())}:${n(i.getIndices())}:${i.listSemantics().sort().map((r)=>`${r}=${n(i.getAttribute(r))}`).join(",")}:${i.listTargets().length}`).join("|")}function bB(e){let t=[],n=new Map,i=e.getRoot().listNodes().filter((s)=>s.getExtras()[cb]!==void 0),r;for(let s of i){let a=new Map;for(let l of s.listChildren()){let u=l.getMesh();if(!u||l.listChildren().length||l.getSkin()||l.listExtensions().length||Pl(l)||Dl(l).length||Object.keys(l.getExtras()).length||l.getWeights().length)continue;let d=gB(u,n);a.set(d,[...a.get(d)??[],l])}let o=0;for(let l of a.values()){if(l.length<2)continue;let u=l[0].getMesh();r??=e.createExtension(ff).setRequired(!0);let d=e.getRoot().listBuffers()[0],f=(_,y)=>e.createAccessor().setType(_).setArray(new Float32Array(y)).setBuffer(d??null),h=[],b=[],m=[];for(let _ of l)h.push(..._.getTranslation()),b.push(..._.getRotation()),m.push(..._.getScale());let g=r.createInstancedMesh().setAttribute("TRANSLATION",f("VEC3",h)).setAttribute("ROTATION",f("VEC4",b)).setAttribute("SCALE",f("VEC3",m)),p=`${s.getName()||"Node"}_Instances${o?`_${o}`:""}`;o++;let x=e.createNode(p).setMesh(u).setExtension("EXT_mesh_gpu_instancing",g);s.addChild(x),t.push({node:x,mesh:u.getName(),count:l.length,instances:l.map((_)=>_.getName())});for(let _ of l){let y=_.getMesh();if(_.dispose(),y&&y!==u&&!y.listParents().some((v)=>v.propertyType===Q.NODE))y.dispose()}}let c={...s.getExtras()};delete c[cb],s.setExtras(c)}return t}function xB(e){let t=[];for(let n of e.getRoot().listNodes()){let i=n.getMesh();if(!i||!gR(n))continue;let r=e.createNode(`${n.getName()}_Proxy`).setMesh(i);n.setMesh(null).addChild(r),t.push({collider:n,proxy:r})}return t}async function yB(e,t,n){let i=e.getRoot().listTextures().filter((o)=>o.getMimeType()!=="image/ktx2"&&o.getImage());if(!t)return{status:"skipped",textures:i.length,reason:"No KTX2 encoder was supplied; textures stay PNG or JPEG."};let r=new Map,s=(o,c)=>{if(o)r.set(o,(r.get(o)??new Set).add(c))};for(let o of e.getRoot().listMaterials())s(o.getBaseColorTexture(),"baseColor"),s(o.getEmissiveTexture(),"emissive"),s(o.getNormalTexture(),"normal"),s(o.getMetallicRoughnessTexture(),"metallicRoughness"),s(o.getOcclusionTexture(),"occlusion");let a=["baseColor","emissive","normal","metallicRoughness","occlusion"];for(let o of i){let c=r.get(o)??new Set,l=c.has("baseColor")||c.has("emissive"),u=o.listParents().some((m)=>m.propertyType!==Q.ROOT&&!_B(m)),d=[...c].some((m)=>m!=="baseColor"&&m!=="emissive")||u;if(l&&d)throw Error(`Texture ${JSON.stringify(o.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);let f=o.getImage(),h=await t({image:f,mimeType:o.getMimeType(),name:o.getName(),colorSpace:l?"srgb":"linear",slot:a.find((m)=>c.has(m))??"other"});if(!(h instanceof Uint8Array)||!Ng(h))throw Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");n.set(o,`sha256:${await Al(f)}`),o.setImage(h).setMimeType("image/ktx2");let b=o.getURI();if(b)o.setURI(b.replace(/\.(png|jpe?g)$/i,".ktx2"))}if(i.length){e.createExtension(Xg).setRequired(!0);await Promise.resolve().then(() => hR());await dR(e),await fR(e)}return{status:"encoded",textures:i.length,...t.identity?{encoder:structuredClone(t.identity)}:{}}}function _B(e){return e.propertyType===Q.MATERIAL}function mR(e,t){let n=new Je().fromArray(e).invert().multiply(new Je().fromArray(t)),i=new j,r=new ln,s=new j;return n.decompose(i,r,s),{scale:s.x,offset:[i.x,i.y,i.z]}}function vB(e){let t=(n,i)=>{if(i.getComponentSize()>=4)return!1;if(n==="POSITION"||n==="NORMAL"||n==="TANGENT")return!0;if(!n.startsWith("TEXCOORD_"))return!1;let r=i.getComponentType();return!(i.getNormalized()&&(r===Oe.ComponentType.UNSIGNED_BYTE||r===Oe.ComponentType.UNSIGNED_SHORT))};return e.getRoot().listMeshes().flatMap((n)=>n.listPrimitives()).flatMap((n)=>[n,...n.listTargets()]).some((n)=>n.listSemantics().some((i)=>t(i,n.getAttribute(i))))}function EB(e,t){let n=2**(t-1)-1,i=new Map;for(let c of e.getRoot().listNodes())for(let l of c.getExtension(fn)?.listLevels()??[])if(l.propertyType===Q.NODE)i.set(l,c);let r=(c)=>{let l=new Je().fromArray(c.getWorldMatrix()),u=c;while(u.getParentNode())u=u.getParentNode();let d=i.get(u)?.getParentNode();return d?new Je().fromArray(d.getWorldMatrix()).multiply(l):l},s=(c)=>{let l=[1/0,1/0,1/0],u=[-1/0,-1/0,-1/0],d=(f,h)=>{for(let b=0;b<3;b++){let m=f[b],g=h?[m,m*2,0]:[m];l[b]=Math.min(l[b],...g),u[b]=Math.max(u[b],...g)}};for(let f of c.listPrimitives()){let h=f.getAttribute("POSITION");if(h)d(h.getMin([]),!1),d(h.getMax([]),!1);for(let b of f.listTargets()){let m=b.getAttribute("POSITION");if(m)d(m.getMin([]),!0),d(m.getMax([]),!0)}}return Math.max(...[0,1,2].map((f)=>(u[f]-l[f])/2))},a=(c)=>{let l=c.getExtension("EXT_mesh_gpu_instancing")?.getAttribute("SCALE");if(!l)return 1;let u=0;for(let d=0;d<l.getCount();d++)u=Math.max(u,...l.getElement(d,[]).map(Math.abs));return u},o=[];for(let c of e.getRoot().listNodes()){let l=c.getMesh();if(!l?.listPrimitives().some((d)=>d.getAttribute("POSITION")))continue;let u=c.getSkin()?1:r(c).getMaxScaleOnAxis()*a(c);o.push({node:c,mesh:l.getName(),step:s(l)*u/n})}return o}async function TB(e,t){let n=QM(e,t),i=[];if(n.some((r)=>r.dropped.length>0)){await e.transform(Sf({propertyTypes:[Q.MESH,Q.PRIMITIVE,Q.PRIMITIVE_TARGET,Q.ACCESSOR,Q.MATERIAL,Q.TEXTURE],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepExtras:!0,keepSolidTextures:!0}));let r=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0],s={...r?.getExtras()??{}},a=s[Cf];if(r&&a?.triangles){let o={...a.triangles};for(let c of Object.keys(o))if(Number(c.slice(3))>t)i.push(c),delete o[c];if(Object.keys(o).length>0)s[Cf]={...a,triangles:o};else delete s[Cf];r.setExtras(s)}}return{maxLod:t,chains:n,budgetTiersOmitted:i}}async function AB(e,t,n={},i={}){let r=n.compression??"meshopt";if(r!=="meshopt"&&r!=="none")throw Error("Runtime three compression must be meshopt or none");let{maxLod:s}=n;if(s!==void 0&&!(Number.isSafeInteger(s)&&s>=0))throw Error("Runtime three maxLod must be a non-negative integer");let a=n.positionBits??_r.position;if(a!=="float"&&!(Number.isSafeInteger(a)&&a>=8&&a<=16))throw Error("Runtime three positionBits must be an integer from 8 to 16, or float");let o=jM().registerDependencies({"meshopt.encoder":t}),c=await o.readBinary(e);c.setLogger(new La(La.Verbosity.SILENT));let l=s===void 0?void 0:await TB(c,s);await c.transform(sb({propertyTypes:[Q.ACCESSOR],keepUniqueNames:!0}));let u=bB(c),d=xB(c),f=new Map;for(let R of c.getRoot().listNodes())if(R.getMesh())f.set(R,[...R.getMatrix()]);let h=a==="float"?[]:EB(c,a),b=a==="float"?mB:pB;if(await c.transform(FM({encoder:t,target:"size"}),DM({pattern:b,patternTargets:b,quantizationVolume:"mesh",quantizePosition:a==="float"?_r.position:a,quantizeNormal:_r.normal,quantizeTexcoord:_r.texcoord,quantizeColor:_r.color,quantizeWeight:_r.weight})),a==="float"&&vB(c))c.createExtension(Il).setRequired(!0);if(r==="meshopt")c.createExtension(Rl).setRequired(!0).setEncoderOptions({method:Rl.EncoderMethod.QUANTIZE});let m=new Map,g=await yB(c,n.ktx2Encoder,m);for(let R of c.getRoot().listNodes()){if(!R.getMesh()||f.has(R)||R.getName())continue;let C=R.getParentNode();R.setName(`${C?.getName()||"Node"}_Mesh`)}let p=JM(c),x=(R)=>p.get(R)??`#${encodeURIComponent(R.getName())}`,_=new Set(d.map((R)=>R.proxy)),y=[];for(let R of c.getRoot().listNodes()){let k=R.getMesh();if(!k||R.getExtension("EXT_mesh_gpu_instancing"))continue;let C=p.get(R);if(C===void 0)continue;let U=f.get(R),L=U===void 0,O=L||_.has(R),K=L?new Je().identity().toArray():U,B=[...R.getMatrix()],{scale:X,offset:q}=mR(K,B);if(!L&&Math.abs(X-1)<0.000000000001&&q.every((de)=>de===0))continue;let le=R.getParentNode();y.push({node:C,mesh:k.getName(),meshMovedToChild:O,...O&&le?{authoredNode:x(le)}:{},dequantization:{scale:X,offset:q},localScale:[...R.getScale()]})}for(let R of c.getRoot().listNodes()){let k=R.getMesh();if(!k||p.has(R)||!f.has(R))continue;let{scale:C,offset:U}=mR(f.get(R),[...R.getMatrix()]);y.push({node:`#lod/${encodeURIComponent(R.getName())}`,mesh:k.getName(),meshMovedToChild:!1,dequantization:{scale:C,offset:U},localScale:[...R.getScale()]})}let v=new Map;for(let R of c.getRoot().listMeshes())for(let k of R.listPrimitives())for(let C of k.listSemantics())if(C.startsWith("_"))v.set(C,(v.get(C)??new Set).add(R));let E=c.getRoot().listNodes(),w=await o.writeBinary(c),T=(await o.binaryToJSON(w)).json,A=new Map;c.getRoot().listTextures().forEach((R,k)=>{let C=m.get(R);if(C)A.set(k,C)});let P=i.gltfBasename?await o.writeJSON(c,{format:Gw.GLTF,basename:i.gltfBasename}):void 0,S={target:"three",extensionsUsed:[...T.extensionsUsed??[]].sort(),extensionsRequired:[...T.extensionsRequired??[]].sort(),compression:r==="meshopt"?{extension:"EXT_meshopt_compression",method:"quantize"}:{extension:"none"},quantization:{extension:"KHR_mesh_quantization",volume:"mesh",bits:{position:a==="float"?"float32":a,normal:_r.normal,texcoord:_r.texcoord,color:_r.color,weight:_r.weight},customAttributes:"float32",positionSteps:h.map(({node:R,mesh:k,step:C})=>({node:p.get(R)??`#lod/${encodeURIComponent(R.getName())}`,mesh:k,step:C})),maxPositionStep:Math.max(0,...h.map(({step:R})=>R))},nodeScale:y,colliderProxies:d.map(({collider:R,proxy:k})=>({collider:x(R),proxy:x(k)})),customAttributes:[...v].sort(([R],[k])=>pR(R)-pR(k)||(R<k?-1:R>k?1:0)).map(([R,k])=>({name:R,meshes:k.size,componentType:"FLOAT",normalized:!1})),instancing:u.map(({node:R,...k})=>({node:x(R),...k})),ktx2:g,...l?{lod:l}:{},preserved:{lodChains:E.filter((R)=>R.getExtension(fn)).length,hiddenNodes:E.filter((R)=>Pl(R)).length,colliders:E.filter(gR).length,anchors:E.filter((R)=>Dl(R).some((k)=>k.startsWith(`${Zs.anchor}.`))).length,ports:E.filter((R)=>Dl(R).some((k)=>k.startsWith(`${Zs.kitPort}.`))).length,kitModules:E.filter((R)=>Dl(R).includes(Zs.kitModule)).length}};return{glb:w,delivery:S,imageSources:A,...P?{gltf:{json:P.json,resources:P.resources}}:{}}}var _r,pB,mB,pR=(e)=>e==="_EDGE"?0:e==="_CAVITY"?1:2,Dl=(e)=>Rf(e.getExtras())?.roles??[],gR=(e)=>Dl(e).some((t)=>t.startsWith(`${Zs.collider}.`));var xR=ut(()=>{qo();hf();UM();ji();Nl();If();ZM();lb();Ol();Pg();eR();nR();_r=Object.freeze({volume:"mesh",position:14,normal:10,texcoord:12,color:8,weight:8}),pB=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/,mB=/^(NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/});var wB;var yR=ut(()=>{wB=function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:8f8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Eabcj;abae9Uc;WFbGcjdaeca0Egifcufai9Uae2aiadfaicl4cifcd4f2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;Pviwue99eu8Jjjjjbcjd9Rgo8Kjjjjbadcd4hrdndndnavcd9hmbarTmbaohdarhwinadc:CuBdbadclfhdawcufgwmbkaeTmdarcdthDalhqcbhkinaohdaqhwarhxinadadydbgmcbawIdbgP:8cL4cFeGc:cufaPJbbbb9BEgsamas9kEBdbawclfhwadclfhdaxcufgxmbkaqaDfhqakcefgkae9hmbxdkkaeTmekarcdthqavce9hhDcbhkindndndnaDmbarTmdc:CuhwalhdarhxinawcbadIdbgP:8cL4cFeGc:cufaPJbbbb9BEgmawam9kEhwadclfhdaxcufgxmbxdkkdndndndnavPleddbdkarTmlaohdalhwarhxinadcbcbawIdbgP:8cL4cFeGgmc:cufgsasam0EaPJbbbb9BEBdbadclfhdawclfhwaxcufgxmbxikkarTmicbhdarhwinaoadfcbaladfIdbgP:8cL4cFeGgxc8Aaxc8A0Ec:cufaPJbbbb9BEBdbadclfhdawcufgwmbxdkkarTmdkc:CuhwkcbhdarhminawhxdnavceSmbaoadfydbhxkdndnaladfIdbgPcjjj;8iaxai9RcefgxcLt9R::NJbbbZJbbb:;aPJbbbb9GEMgP:lJbbb9p9DTmbaP:Ohsxekcjjjj94hskabadfascFFFrGaxcKtVBdbadclfhdamcufgmmbkkabaqfhbalaqfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(h){n=h.instance,n.exports.__wasm_call_ctors(),n.exports.meshopt_encodeVertexVersion(1),n.exports.meshopt_encodeIndexVersion(1)});function r(h){var b=new Uint8Array(h.length);for(var m=0;m<h.length;++m){var g=h.charCodeAt(m);b[m]=g>96?g-97:g>64?g-39:g+4}var p=0;for(var m=0;m<h.length;++m)b[p++]=b[m]<60?t[b[m]]:(b[m]-60)*64+b[++m];return b.buffer.slice(0,p)}function s(h){if(!h)throw Error("Assertion failed")}function a(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,b,m,g){var p=n.exports.sbrk,x=p(b.length*4),_=p(m*4),y=new Uint8Array(n.exports.memory.buffer),v=a(b);if(y.set(v,x),g)g(x,x,b.length,m);var E=h(_,x,b.length,m);y=new Uint8Array(n.exports.memory.buffer);var w=new Uint32Array(m);new Uint8Array(w.buffer).set(y.subarray(_,_+m*4)),v.set(y.subarray(x,x+b.length*4)),p(x-p(0));for(var T=0;T<b.length;++T)b[T]=w[b[T]];return[w,E]}function c(h,b,m,g){var p=n.exports.sbrk,x=p(m*4),_=p(m*g),y=new Uint8Array(n.exports.memory.buffer);y.set(a(b),_),h(x,_,m,g),y=new Uint8Array(n.exports.memory.buffer);var v=new Uint32Array(m);return new Uint8Array(v.buffer).set(y.subarray(x,x+m*4)),p(x-p(0)),v}function l(h,b,m,g,p,x,_){var y=n.exports.sbrk,v=y(b),E=y(g*p),w=new Uint8Array(n.exports.memory.buffer);w.set(a(m),E);var T=h(v,b,E,g,p,x,_),A=new Uint8Array(T);return A.set(w.subarray(v,v+T)),y(v-y(0)),A}function u(h){var b=0;for(var m=0;m<h.length;++m){var g=h[m];b=b<g?g:b}return b}function d(h,b){if(s(b==2||b==4),b==4)return new Uint32Array(h.buffer,h.byteOffset,h.byteLength/4);else{var m=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2);return new Uint32Array(m)}}function f(h,b,m,g,p,x,_){var y=n.exports.sbrk,v=y(m*g),E=y(m*x),w=new Uint8Array(n.exports.memory.buffer);w.set(a(b),E),h(v,m,g,p,E,_);var T=new Uint8Array(m*g);return T.set(w.subarray(v,v+m*g)),y(v-y(0)),T}return{ready:i,supported:!0,reorderMesh:function(h,b,m){s(h instanceof Uint32Array||h instanceof Int32Array),s(!b||h.length%3==0);var g=b?m?n.exports.meshopt_optimizeVertexCacheStrip:n.exports.meshopt_optimizeVertexCache:void 0;return o(n.exports.meshopt_optimizeVertexFetchRemap,h,u(h)+1,g)},reorderPoints:function(h,b){return s(h instanceof Float32Array),s(h.length%b==0),s(b>=3),c(n.exports.meshopt_spatialSortRemap,h,h.length/b,b*4)},encodeVertexBuffer:function(h,b,m){s(m>0&&m<=256),s(m%4==0);var g=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBuffer,g,h,b,m)},encodeVertexBufferLevel:function(h,b,m,g,p){s(m>0&&m<=256),s(m%4==0),s(g>=0&&g<=3),s(p===void 0||p==0||p==1);var x=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBufferLevel,x,h,b,m,g,p===void 0?-1:p)},encodeIndexBuffer:function(h,b,m){s(m==2||m==4),s(b%3==0);var g=d(h,m),p=n.exports.meshopt_encodeIndexBufferBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexBuffer,p,g,b,4)},encodeIndexSequence:function(h,b,m){s(m==2||m==4);var g=d(h,m),p=n.exports.meshopt_encodeIndexSequenceBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexSequence,p,g,b,4)},encodeGltfBuffer:function(h,b,m,g,p){var x={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return s(x[g]),x[g](h,b,m,2,p===void 0?0:p)},encodeFilterOct:function(h,b,m,g){return s(m==4||m==8),s(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterOct,h,b,m,g,16)},encodeFilterQuat:function(h,b,m,g){return s(m==8),s(g>=4&&g<=16),f(n.exports.meshopt_encodeFilterQuat,h,b,m,g,16)},encodeFilterExp:function(h,b,m,g,p){s(m>0&&m%4==0),s(g>=1&&g<=24);var x={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return s(!p||p in x),f(n.exports.meshopt_encodeFilterExp,h,b,m,g,m,p?x[p]:1)},encodeFilterColor:function(h,b,m,g){return s(m==4||m==8),s(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterColor,h,b,m,g,16)}}}()});var gX;var _R=ut(()=>{gX=function(){var e="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",t="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var r=WebAssembly.validate(n)?o(t):o(e),s,a=WebAssembly.instantiate(r,{}).then(function(p){s=p.instance,s.exports.__wasm_call_ctors()});function o(p){var x=new Uint8Array(p.length);for(var _=0;_<p.length;++_){var y=p.charCodeAt(_);x[_]=y>96?y-97:y>64?y-39:y+4}var v=0;for(var _=0;_<p.length;++_)x[v++]=x[_]<60?i[x[_]]:(x[_]-60)*64+x[++_];return x.buffer.slice(0,v)}function c(p,x,_,y,v,E,w){var T=p.exports.sbrk,A=y+3&-4,P=T(A*v),S=T(E.length),R=new Uint8Array(p.exports.memory.buffer);R.set(E,S);var k=x(P,y,v,S,E.length);if(k==0&&w)w(P,A,v);if(_.set(R.subarray(P,P+y*v)),T(P-T(0)),k!=0)throw Error("Malformed buffer data: "+k)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function h(p){var x={object:new Worker(p),pending:0,requests:{}};return x.object.onmessage=function(_){var y=_.data;x.pending-=y.count,x.requests[y.id][y.action](y.value),delete x.requests[y.id]},x}function b(p){var x="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+g.name+";"+c.toString()+g.toString(),_=new Blob([x],{type:"text/javascript"}),y=URL.createObjectURL(_);for(var v=d.length;v<p;++v)d[v]=h(y);for(var v=p;v<d.length;++v)d[v].object.postMessage({});d.length=p,URL.revokeObjectURL(y)}function m(p,x,_,y,v){var E=d[0];for(var w=1;w<d.length;++w)if(d[w].pending<E.pending)E=d[w];return new Promise(function(T,A){var P=new Uint8Array(_),S=++f;E.pending+=p,E.requests[S]={resolve:T,reject:A},E.object.postMessage({id:S,count:p,size:x,source:P,mode:y,filter:v},[P.buffer])})}function g(p){var x=p.data;self.ready.then(function(_){if(!x.id)return self.close();try{var y=new Uint8Array(x.count*x.size);c(_,_.exports[x.mode],y,x.count,x.size,x.source,_.exports[x.filter]),self.postMessage({id:x.id,count:x.count,action:"resolve",value:y},[y.buffer])}catch(v){self.postMessage({id:x.id,count:x.count,action:"reject",value:v})}})}return{ready:a,supported:!0,useWorkers:function(p){b(p)},decodeVertexBuffer:function(p,x,_,y,v){c(s,s.exports.meshopt_decodeVertexBuffer,p,x,_,y,s.exports[l[v]])},decodeIndexBuffer:function(p,x,_,y){c(s,s.exports.meshopt_decodeIndexBuffer,p,x,_,y)},decodeIndexSequence:function(p,x,_,y){c(s,s.exports.meshopt_decodeIndexSequence,p,x,_,y)},decodeGltfBuffer:function(p,x,_,y,v,E){c(s,s.exports[u[v]],p,x,_,y,s.exports[l[E]])},decodeGltfBufferAsync:function(p,x,_,y,v){if(d.length>0)return m(p,x,_,u[y],l[v]);return a.then(function(){var E=new Uint8Array(p*x);return c(s,s.exports[u[y]],E,p,x,_,s.exports[l[v]]),E})}}}()});var xX;var vR=ut(()=>{xX=function(){var e="b9H79Tebbbe:6eO9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999Gluuuueu9Gluuuub9GiuuueuiLQdilvorlwDiqkxmPszbHHbelve9Weiiviebeoweuecj:Gdkr:Bdxo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbxQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bmX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbPa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9Wbs59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9Wbzl79IV9RbHDwebcekdCXq;y;WeQdbk;r:herYue99iuY99Xue9:D998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkdnamcdGTmbalcrfci4cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd1:H:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:tjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd:m:H:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbhLasc:Cefasyd;8egecdtfaLBdbasaLBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd1:H:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd1:H:cjbHjjjjbbhOasc:Cefasyd;8egHcdtfaOBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhQasc:Cefasyd;8egHcdtfaQBdbasaHcefBd;8eaOaQaialavazasc:Cefz:djjjbalcbyd1:H:cjbHjjjjbbhYasc:Cefasyd;8egHcdtfaYBdbasaHcefBd;8ea3cbyd1:H:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8ea3cbyd1:H:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaHcFeaez:tjjjbh5aAcFeaez:tjjjbh8EdnalTmbindnaLa8AgAcefg8AcdtfydbgCaLaAcdtgefydbgHSmbaCaH9Rh8FaEaHcitfhaa8Eaefhha5aefhKcbhCindndnaaaCcitfydbgXaA9hmbaKaABdbahaABdbxekdnaLaXcdtggfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheinaeydbaASmdaecwfheaHcufgHmbkka8EagfgeaAaXaeydbcuSEBdbaKaXaAaKydbcuSEBdbkaCcefgCa8F9hmbkka8Aal9hmbkaOhHaQhAa5hXa8EhCcbheindndnaeaHydbgK9hmbdnaeaAydbgK9hmbaXydbhKdnaCydbg8Fcu9hmbaKcu9hmbaYaefcb86bbxikdna8FcuSmbaKcuSmbaea8FSmbaOa8FcdtfydbaOaKcdtfydb9hmbaYaefcd86bbxikaYaefhadnaea8FSmbaeaKSmbaace86bbxikaacl86bbxdkdnaeaQaKcdtg8Ffydb9hmbdnaCydbgacuSmbaeaaSmbaXydbggcuSmbaeagSmba8Ea8FfydbghcuSmbahaKSmba5a8Ffydbg8FcuSmba8FaKSmbdnaOaacdtfydbgKaOa8Fcdtfydb9hmbaKaOagcdtfydbg8FSmba8FaOahcdtfydb9hmbaYaefcd86bbxlkaYaefcl86bbxikaYaefcl86bbxdkaYaefcl86bbxekaYaefaYaKfRbb86bbkaHclfhHaAclfhAaXclfhXaCclfhCalaecefge9hmbkdnamcaGTmbcbh8JindndnaYa8Jfg8KRbbg8Lc9:fPibebekdndndnaOa8Jcdtfydbgea8J9hmbdnaqmbcbh8FxdkdnazTmbcbh8Fa8JheinaqazaecdtgefydbfRbbce4a8FVceGh8FaQaefydbgea8J9hmbxikkcbh8Fa8JheinaqaefRbbce4a8FVceGh8FaQaecdtfydbgea8J9hmbxdkkaYaefRbbhexeka8JheindnaLaecdtg8AfgeclfydbgHaeydbgeSmbaHae9RhgaEaecitfhhaOa8AfhacbhKinahaKcitfydbgXhednindnaLaecdtgCfgeclfydbgHaeydbgeSmbaHae9RhHaEaecitfheaaydbhAdninaOaeydbcdtfydbaASmeaecwfheaHcufgHTmdxbkkcbhexdkaQaCfydbgeaX9hmbkceheka8FaeVh8FaKcefgKag9hmbkkaQa8Afydbgea8J9hmbka8Lcia8FceGEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaOhHalhAindnaqaeydbfRbbceGTmbaYaHydbfcl86bbkaeclfheaHclfhHaAcufgAmbxdkkaqheaOhHalhAindnaeRbbceGTmbaYaHydbfcl86bbkaecefheaHclfhHaAcufgAmbkkaOhealhAaYhHindnaYaeydbfRbbcl9hmbaHcl86bbkaeclfheaHcefhHaAcufgAmbkkamceGTmbaYhealhHindnaeRbbce9hmbaecl86bbkaecefheaHcufgHmbkkcbh8Mcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh8Nasc:Cefasyd;8egecdtfa8NBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Naialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhCxekcbhCawhecbhHindnaeIdbJbbbb9ETmbasaCcdtfaHBdbaCcefhCkaeclfheaDaHcefgH9hmbkcuaCal2gecdtaecFFFFi0Ecbyd1:H:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaCmbcbhCxekarcd4hgdnazTmbaCcdthhcbh8Fa8Phainaoaza8Fcdtfydbag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbxdkkaCcdthhcbh8Fa8Phainaoa8Fag2cdtfhKasheaahHaChAinaHaKaeydbcdtgXfIdbawaXfIdbNUdbaeclfheaHclfhHaAcufgAmbkaaahfhaa8Fcefg8Fal9hmbkkcualc8S2gHalc;D;O;f8U0EgXcbyd1:H:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaHz:tjjjbhIcbh8RcbhgdnaCTmbcbh8MaXcbyd1:H:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaHz:tjjjb8AcuaCal2gecltgHaecFFFFb0Ecbyd1:H:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaHz:tjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd1:H:cjbHjjjjbbh8Masc:Cefasyd;8egHcdtfa8MBdbasaHcefBd;8ea8Mcbaez:tjjjb8AkdnadTmbcbhKabhHina8NaHclfydbg8Fcx2fgeIdba8NaHydbgacx2fgAIdbg8S:tgRa8NaHcwfydbghcx2fgXIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaXIdba8S:tg8XN:tg8Ya8YNa8WaXIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaOaacdtfydbgXc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaOa8Fcdtfydbg8Fc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaOahcdtfydbgac8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8MTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8MaXcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8Ma8Fcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8Maacltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaHcxfhHaKcifgKad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhHaOhXazhKaIhea8NhAindnaHaXydb9hmbaHh8FdnazTmbaKydbh8Fka80hRdnaqTmbJbbjZa80aqa8FfRbbclGEhRkaecxfg8Fa8FIdbJbbbbMUdbaeczfg8Fa8FIdbJbbbbMUdbaecCfg8Fa8FIdbJbbbbMUdbaeaRaecyfg8FIdbg8YNgRaeIdbMUdbaeclfgaaRaaIdbMUdbaecwfgaaRaaIdbMUdbaecKfgaaaIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgaaaIdbaRaAclfIdbg8XN:tUdbaecafgaaaIdbaRa8VN:tUdbaec8KfgaIdbh81a8Fa8YaRMUdbaaa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaXclfhXaKclfhKaec8SfheaAcxfhAalaHcefgH9hmbkkdnadTmbcbh8Aabhainaba8Acdtfh8FcbhHinaYa8FaHc:G:G:cjbfydbcdtfydbgAfRbbhedndnaYaaaHfydbgXfRbbgKc99fcFeGcpe0mbaec99fcFeGc;:e6mekdnaKcufcFeGce0mba5aXcdtfydbaA9hmekdnaecufcFeGce0mba8EaAcdtfydbaX9hmekJbbacJbbacJbbbZaecFeGceSEaKcFeGceSEhUdna8Na8FaHc:K:G:cjbfydbcdtfydbcx2fgeIdwa8NaXcx2fgKIdwg86:tg8Sa8NaAcx2fghIdwa86:tg8Xa8XNahIdbaKIdbg8U:tg80a80NahIdlaKIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaeIdba8U:tg83a80Na8VaeIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaOaXcdtfydbc8S2fgeaeIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaea8Wa8XaRa8XNg8SNMg83aeIdlMUdlaea8Ya81aRa81Ng8WNMg8YaeIdwMUdwaeaca8Va8SNMg8SaeIdxMUdxaeaZa8Wa8VNMgUaeIdzMUdzaea8:a8Xa8WNMg8WaeIdCMUdCaea87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaeIdKMUdKaea89a8XaRNMg8XaeId3MUd3aea85a81aRNMg81aeIdaMUdaaea88a86aRN:tgRaeId8KMUd8KaeaBaeIdyMUdyaIaOaAcdtfydbc8S2fgea80aeIdbMUdbaea83aeIdlMUdlaea8YaeIdwMUdwaea8SaeIdxMUdxaeaUaeIdzMUdzaea8WaeIdCMUdCaea8VaeIdKMUdKaea8XaeId3MUd3aea81aeIdaMUdaaeaRaeId8KMUd8KaeaBaeIdyMUdykaHclfgHcx9hmbkaacxfhaa8Acifg8Aad6mbkaCTmbcbhainJbbbbh80a8Nabaacdtfgeclfydbg8Fcx2fgHIdwa8Naeydbghcx2fgAIdwg8Z:tg8Va8VNaHIdbaAIdbg83:tg8Wa8WNaHIdlaAIdlg85:tg8Xa8XNMMg8Sa8Naecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8PahaC2g8JcdtfhHa8Pa8AaC2gDcdtfhAa8Pa8FaC2g8KcdtfhXa8Z:mh9ca85:mhJa83:mh9eascjdfheaChKJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aXIdbaHIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRa9ca8VNaJa8WNa8Ya9ea8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aHclfhHaXclfhXaAclfhAaeczfheaKcufgKmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Fc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8Jcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8Ra8Kcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8RaDcltfh8FcbhHaChXina8FaHfgeascjdfaHfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbkaacifgaad6mbkkcbhAdndnamcwGgTmbJbbbbh8ScbhScbh9hcbh9ixekcbhSa3cbyd1:H:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ecua9ialabadaOz:fjjjbgXcltaXcjjjjiGEcbyd1:H:cjbHjjjjbbh9hasc:Cefasyd;8egecdtfa9hBdbasaecefBd;8ea9haXa9ia8Nalz:gjjjbJFFuuh8SaXTmba9hheaXhHinaeIdbgRa8Sa8SaR9EEh8SaeclfheaHcufgHmbkaXhSkdnalTmbaLclfheaLydbhXaYhHalhKcbhAincbaeydbg8FaX9RaHRbbcpeGEaAfhAaHcefhHaeclfhea8FhXaKcufgKmbkaAce4hAkcuadaA9Rcifg6cx2a6c;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbh9kasc:Cefasyd;8egecdtfa9kBdbasaecefBd;8ecua6cdta6cFFFFi0Ecbyd1:H:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ea3cbyd1:H:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ealcbyd1:H:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8eaxaxNayJbbjZamclGEgZaZN:vh87JbbbbhUdnadak9nmbdna6ci6mbaCclth9oa9kcwfh9pJbbbbh85JbbbbhUinascNefabadalaOz:cjjjbabh8Acbh9qcbh9rinaba9rcdtfhDcbheindnaOa8AaefydbgAcdtghfydbgXaOaDaec:W:G:cjbfydbcdtfydbgHcdtg8JfydbgKSmbaYaHfRbbgacv2aYaAfRbbg8FfRb;a:G:cjbg8La8Fcv2aafg8KRb;a:G:cjbg3VcFeGTmbdnaKaX9nmba8KRb;G:G:cjbcFeGmekdna8FcufcFeGce0mbaaTmba5ahfydbaH9hmekdna8FTmbaacufcFeGce0mba8Ea8JfydbaA9hmeka9ka9qcx2fgXaHaAa3cFeGgKEBdlaXaAaHaKEBdbaXaKa8LGcb9hBdwa9qcefh9qkaeclfgecx9hmbkdna9rcifg9rad9pmba8Acxfh8Aa9qcifa69nmekka9qTmdcbh8KinaIaOa9ka8Kcx2fghydbgKcdtgXfydbg8Ac8S2fgeIdwa8Nahydlg8Fcx2fgHIdwg8WNaeIdzaHIdbg8XNaeIdaMgRaRMMa8WNaeIdlaHIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8VdndnahydwgDmbJFFuuh86xekJbbbbJbbjZaIaOa8Fcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8NaKcx2fgHIdwg81NaeIdzaHIdbg80NaeIdaMgBaBMMa81NaeIdlaHIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNh86ka8VaRNhBdnaCTmbagaKc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8FaC2gacdtfhHa8RaKaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8Vxekaga8Fc8S2fgAIdwa8NaKcx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8RaacltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86dndndnaYaKfRbbc9:fPddbekaQaXfydbgXaKSmbaOa8Fcdtfydbh8Jindndna5aXcdtgafydbgecuSmbaOaecdtfydba8JSmekdna8EaafydbgecuSmbaOaecdtfydba8JSmeka8FhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkaBaR:lMhBaQaafydbgXaK9hmbkkaYa8FfRbbci9hmeaDTmeaQa8FcdtfydbgXa8FSmeindndna5aXcdtgafydbgecuSmbaOaecdtfydba8ASmekdna8EaafydbgecuSmbaOaecdtfydba8ASmekaKhekagaXc8S2fgAIdwa8Naecx2fgHIdwg8WNaAIdzaHIdbg8XNaAIdaMgRaRMMa8WNaAIdlaHIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaeaC2cdtfhHa8RaXaC2cltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbka86aR:lMh86aQaafydbgXa8F9hmbxdkkdna8Ea5a5aXfydba8FSEaQaXfydbgacdtfydbgXcu9hmbaQa8FcdtfydbhXkagaac8S2fgAIdwa8NaXcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaXaC2g8AcdtfhHa8RaaaC2g8JcltfheaAIdyh81aChAinaHIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaHclfhHaeczfheaAcufgAmbkdndnaDmbJbbbbh8VxekagaXc8S2fgAIdwa8Naacx2fgeIdwg8XNaAIdzaeIdbg8YNaAIdaMg8Va8VMMa8XNaAIdlaeIdlg81NaAIdCa8XNaAId3Mg8Va8VMMa81NaAIdba8YNaAIdxa81NaAIdKMg8Va8VMMa8YNaAId8KMMMh8Va8Pa8JcdtfhHa8Ra8AcltfheaAIdyh80aChAinaHIdbg8Wa8Wa80NaecxfIdba8XaecwfIdbNa8YaeIdbNa81aeclfIdbNMMMg8Wa8WM:tNa8VMh8VaHclfhHaeczfheaAcufgAmbka8V:lh8VkaBaR:lMhBa86a8VMh86kaha86aBa86aB9DgeEUdwahaKa8FaeaDcb9hGgeEBdlaha8FaKaeEBdba8Kcefg8Ka9q9hmbkascjdfcbcj;qbz:tjjjb8Aa9phea9qhHinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaHcufgHmbkcbhecbhHinascjdfaefgAydbhXaAaHBdbaXaHfhHaeclfgecj;qb9hmbkcbhea9phHinascjdfaHydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba0aAcdtfaeBdbaHcxfhHa9qaecefge9hmbkadak9RgAci9Uh9sdnalTmbcbhea9mhHinaHaeBdbaHclfhHalaecefge9hmbkkcbh9ta9ncbalz:tjjjbh3aAcO9Uh9ua9sce4h9rcbh8Lcbh8Kdnina9ka0a8Kcdtfydbcx2fg8JIdwgRa879Emea8La9s9pmeJFFuuh8Vdna9ra9q9pmba9ka0a9rcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9u0mdkdna3aOa8JydlgDcdtg9vfg8AydbgAfg9wRbba3aOa8Jydbghcdtg9xfydbgefg9yRbbVmbaYahfRbbh9zdndnaLaecdtfgHclfydbgXaHydbgHSmbaXaH9RhXa8NaAcx2fh8Fa8Naecx2fhaaEaHcitfheindna9maeydbcdtfydbgHaASmba9maeclfydbcdtfydbgKaASmbaHaKSmba8NaKcx2fgKIdba8NaHcx2fgHIdbg8W:tgRaaIdlaHIdlg8X:tg80NaKIdla8X:tg8VaaIdba8W:tgBN:tg8YaRa8FIdla8X:tg86Na8Va8FIdba8W:tg8UN:tg8XNa8VaaIdwaHIdwg81:tg8ZNaKIdwa81:tg8Wa80N:tg80a8Va8FIdwa81:tg83Na8Wa86N:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaXcufgXmbkkdndndndna9zc9:fPdebdkahheina8AydbhAdndna5aecdtgHfydbgecuSmbaOaecdtfydbaASmekdna8EaHfydbgecuSmbaOaecdtfydbaASmekaDheka9maHfaeBdbaQaHfydbgeah9hmbxikkdna8Ea5a5a9xfydbaDSEaQa9xfydbghcdtfydbgecu9hmbaQa9vfydbheka9ma9xfaDBdbaehDka9mahcdtfaDBdbka9yce86bba9wce86bba8JIdwgRaUaUaR9DEhUa9tcefh9tcecda9zceSEa8Lfh8Lxeka9rcefh9rka8Kcefg8Ka9q9hmbkka9tTmddnalTmbcbh8Fcbhhindna9mahcdtgefydbgAahSmbaOaAcdtfydbh8AdnahaOaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya8MTmba8Ma8Acltfgea8MahcltfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxkaCTmbagaAc8S2fgeagahc8S2gDfgHIdbaeIdbMUdbaeaHIdlaeIdlMUdlaeaHIdwaeIdwMUdwaeaHIdxaeIdxMUdxaeaHIdzaeIdzMUdzaeaHIdCaeIdCMUdCaeaHIdKaeIdKMUdKaeaHId3aeId3MUd3aeaHIdaaeIdaMUdaaeaHId8KaeId8KMUd8KaeaHIdyaeIdyMUdya9oaA2haa8RhHaChXinaHaafgeaHa8FfgAIdbaeIdbMUdbaeclfgKaAclfIdbaKIdbMUdbaecwfgKaAcwfIdbaKIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaHczfhHaXcufgXmbka8JmbJbbbbJbbjZaIaDfgeIdygR:vaRJbbbb9BEaeIdwa8Na8Acx2fgHIdwgRNaeIdzaHIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaHIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85ka8Fa9ofh8Fahcefghal9hmbkcbhHa5heindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa5aXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkcbhHa8EheindnaeydbgAcuSmbdnaHa9maAcdtgXfydbgA9hmbcuhAa8EaXfydbgXcuSmba9maXcdtfydbhAkaeaABdbkaeclfhealaHcefgH9hmbkka85aUaCEh85cbhHabhecbhAindnaOa9maeydbcdtfydbg8FcdtfydbgXaOa9maeclfydbcdtfydbgacdtfydbgKSmbaXaOa9maecwfydbcdtfydbg8AcdtfydbghSmbaKahSmbabaHcdtfgXa8FBdbaXcwfa8ABdbaXclfaaBdbaHcifhHkaecxfheaAcifgAad6mbkdndnaTmbaHhdxekdnaHak0mbaHhdxekdna8Sa859FmbaHhdxekJFFuuh8ScbhdabhecbhAindna9ha9iaeydbgXcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9AabadcdtfgKaXBdbaKclfa9A83dbaRa8Sa8SaR9EEh8SadcifhdkaecxfheaAcifgAaH6mbkkadak0mbxdkkascNefabadalaOz:cjjjbkdndnadak0mbadhaxekdnaTmbadhaxekdna8Sa879FmbadhaxekcehKina8SJbb;aZNgRa87aRa879DEh8WJbbbbhRdnaSTmba9hheaShHinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaHcufgHmbkkJFFuuh8ScbhaabhecbhHindna9ha9iaeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9AabaacdtfgXaABdbaXclfa9A83dba8Va8Sa8Sa8V9EEh8SaacifhakaecxfheaHcifgHad6mbkdnaKaaad9hVceGmbadhaxdkaRaUaUaR9DEhUaaak9nmecbhKaahda8Sa879FmbkkdnamcjjjjdGTmba9ncbalz:tjjjbh8AdnaaTmbabheaahHina8AaeydbgAfce86bba8AaOaAcdtfydbfce86bbaeclfheaHcufgHmbkkascNefabaaalaOz:cjjjbdndnalTmbcbhXindna8AaXfRbbTmbdnaYaXfRbbgecl0mbceaetcQGmekdnaOaXcdtg8FfydbgeaXSmba8NaXcx2fgHa8Naecx2fgeydwBdwaHae8Pdb83dbxekaIaXc8S2fgKIdygcacJL:3;rUNgRMh87aKIdwg9BaRMh8SaKIdlg9CaRMh8UaKIdbg9DaRMh81aKIdag9EaRa8NaXcx2fg8JIdwg88N:th8ZaKId3g9FaRa8JIdlg89N:th83aKIdKg9Ga8JIdbg8:aRN:th80JbbbbhnaKIdCg9HJbbbbMh85aKIdzg9IJbbbbMhBaKIdxg9JJbbbbMh86dndnaCTmbaXhAinJbbbba87agaAc8S2fgHIdygR:vaRJbbbb9BEhRa8RaAaC2cltfheaHIdaa87Na8ZMh8ZaHId3a87Na83Mh83aHIdKa87Na80Mh80aHIdCa87Na85Mh85aHIdza87NaBMhBaHIdxa87Na86Mh86aHIdwa87Na8SMh8SaHIdla87Na8UMh8UaHIdba87Na81Mh81aChHina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaHcufgHmbkaQaAcdtfydbgAaX9hmbka8MTmba8MaXcltfgeIdxhxaeIdwh9caeIdlhJaeIdbhRxekJbbbbhxJbbbbh9cJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83a9caRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vg9c:mhJdnJbbbbaRaRa81:vg9eN:ta86a9cN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80Nax:tMMa86:vhnka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:manNa8W:ma8ZanNa83aB:vMgBNa8V:maJanNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aLa8FfgeclfydbgHaeydbge9RhhaEaecitfh8FJbbbbhRdnaHaeSgDmbJbbbbhRa8FheahhAina8Naeclfydbcx2fgHIdwa88:tg8Va8VNaHIdba8::tg8Va8VNaHIdla89:tg8Va8VNMMg8Va8Naeydbcx2fgHIdwa88:tg8Wa8WNaHIdba8::tg8Wa8WNaHIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaKId8KhndnaDmbina8Na8Fclfydbcx2fgeIdba8Na8Fydbcx2fgHIdbg8W:tgRa89aHIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aHIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9Fmda8Fcwfh8FahcufghmbkkJbbbbJbbjZac:vacJbbbb9BEgRa9BaBNa9Ia87Na9EMg8Va8VMMaBNa9Ca85Na9HaBNa9FMg8Va8VMMa85Na9Da87Na9Ja85Na9GMg8Va8VMMa87NanMMM:lNaRa9Ba88Na9Ia8:Na9EMg8Va8VMMa88Na9Ca89Na9Ha88Na9FMg8Va8VMMa89Na9Da8:Na9Ja89Na9GMg8Va8VMMa8:NanMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaXcefgXal9hmbkdnaCmbcbhCxdkcbhXindna8AaXfRbbTmbaOaXcdtgefydbaX9hmbaYaXfhhaQaefh8Ja8NaXcx2fhAa8PaXaC2cdtfhDcbhEincuhLdnahRbbci9hmbaXhLa8JydbgeaXSmba8PaEcdtgHfhKaDaHfIdbhRaXhLinaLhHcuhLdnaKaeaC2cdtfIdbaR9CmbaHcuSmbaHhLagaec8S2fIdyagaHc8S2fIdy9ETmbaehLkaQaecdtfydbgeaX9hmbkka8PaEcdtfhKa8RaEcltfh8FaXheinaKaeaC2cdtfJbbbbJbbjZagaeaLaLcuSEgHc8S2fIdygR:vaRJbbbb9BEa8FaHaC2cltfgHIdwaAIdwNaHIdbaAIdbNaHIdlaAIdlNMMaHIdxMNUdbaQaecdtfydbgeaX9hmbkaEcefgEaC9hmbkkaXcefgXal9hmbxdkkaCmbcbhCkaiavaoarawaCala8Na8Pazasayasc1efaYa8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaaTmbabhecbhLinaYaeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna5aAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8EaOcdtfydbaASEhCkaeaQaCVaAVBdbaYaOfRbbc3th8Fcjjjj94hCcjjjj94hQdna5aOcdtfydbaHSmbcjjjj94cba8EaHcdtfydbaOSEhQkaKa8FaQVaOVBdbaYaHfRbbc3thOdna5aHcdtfydbaASmbcjjjj94cba8EaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaa6mbkkdnazTmbaaTmbaaheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPaZaU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd:m:H:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8Kjjjjbaak;Yieouabydlhvabydbclfcbaicdtz:tjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd1:H:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:tjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd:m:H:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:tjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbclSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbclSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbclSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbclSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:g8Koque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:tjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd1:H:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkcbhOaqcuavcdtgYavcFFFFi0Ecbyd1:H:cjbHjjjjbbgKBdCaqciBd2aqamcbyd1:H:cjbHjjjjbbgzBdKaqclBd2dndndndnalTmbaPcuf:YhwaoTmecbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxikkaKcFeaYz:tjjjb8AcbhPcbhvxdkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaKcFeaYz:tjjjbhravcufhocbhPcbhYindndndnaraiaYcdtgKfydbgAcm4aA7c:v;t;h;Ev2gvcs4av7aoGgHcdtfgXydbgOcuSmbcehvinaiaOcdtgOfydbaASmdaHavfhOavcefhvaraOaoGgHcdtfgXydbgOcu9hmbkkaXaYBdbaPhvaPcefhPxekazaOfydbhvkazaKfavBdbaYcefgYal9hmbkcuaPc8S2gOaPc;D;O;f8U0EhvkcbhXaqavcbyd1:H:cjbHjjjjbbgvBd3aqcvBd2avcbaOz:tjjjbhOdnadTmbaehiinaxaiclfydbgrcx2fgvIdbaxaiydbgocx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaocdtfydbgvazarcdtfydbgASavazaYcdtfydbgrSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOarc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiaXcifgXad6mbkkcbhAaqcuaPcdtgvaPcFFFFi0Egicbyd1:H:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd1:H:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:tjjjbhYdnalTmbazhHinJbbbbJbbjZaOaHydbgXc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaYaXcdtgvfgXydbcuSmbaiavfIdbaw9ETmekaXaABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaPmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaPcufgPmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd1:H:cjbHjjjjbbgHBdyaHcFeaiz:tjjjbhXdnadTmbavcufhrcbhPcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaYavcdtfydbhAdndnaYaOcdtfydbgvaYaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabaPcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavaPBdbaPcefhPkaxcifgxad6mbkaPci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd:m:H:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:tjjjb8AdnabaeSmbabaeadcdtzMjjjb8AkarcualcdtalcFFFFi0EgDcbyd1:H:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd1:H:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd1:H:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd:m:H:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk:WCoDud99vue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:tjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd1:H:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd1:H:cjbHjjjjbbgxBdzawcdBd2adcd4adfhmceheinaegicetheaiam6mbkcbhPawcuaicdtgsaicFFFFi0Ecbyd1:H:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohexekcjjjj94hekaicufhAc:bwhCcbhXadhQcbhLinaeaCcufgiaeai9iEaPcefaeaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhmindndnaiIdbaONJbbbZMgK:lJbbb9p9DTmbaK:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaONJbbbZMgK:lJbbb9p9DTmbaK:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbh3cbh5indnaEaxa5cdtfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbaeaYSmbcehiinaEamaifaAGgmcdtfg8AydbgecuSmeaicefhiaeaY9hmbkka8AaYBdba3aecuSfh3a5cefg5ad9hmbxdkkazcFeasz:tjjjb8Acbh3kdnaQ:ZgKaH:taD:YgOaC:Y:tg8ENaX:Zg8Fa3:Zga:tNa8FaH:taOaP:Y:tghNaaaK:tNMggJbbbb9BmbaKa8F:taha8EaaaH:tNNNag:vaOMhOkaPaDa3ar0giEhPaXa3aiEhXdna3arSmbaDaCaiEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohexdkcjjjj94hexekaPaCfcd9Theka3aQaiEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekcbhiawakcbyd1:H:cjbHjjjjbbg5BdKawclBd2aPcuf:YhKdndnadTmbaqhiaxheadhmindndnaiIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:OhYxekcjjjj94hYkaYcCthYdndnaiclfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8Aka8AcqtaYVhYdndnaicwfIdbaKNJbbbZMgO:lJbbb9p9DTmbaO:Oh8Axekcjjjj94h8AkaeaYa8AVBdbaicxfhiaeclfheamcufgmmbkazcFeasz:tjjjbhEcbhDcbh3indndndnaEaxa3cdtgCfydbgYcm4aY7c:v;t;h;Ev2gics4ai7aAGgmcdtfg8AydbgecuSmbcehiinaxaecdtgefydbaYSmdamaifheaicefhiaEaeaAGgmcdtfg8Aydbgecu9hmbkka8Aa3BdbaDhiaDcefhDxeka5aefydbhika5aCfaiBdba3cefg3ad9hmbkcuaDc32giaDc;j:KM;jb0EhexekazcFeasz:tjjjb8AcbhDcbhekawaecbyd1:H:cjbHjjjjbbgeBd3awcvBd2aecbaiz:tjjjbh8Aavcd4hxdnadTmbdnalTmbaxcdthEa5hYaqhealhmadhAina8AaYydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiamIdbaiIdxMUdxaiamclfIdbaiIdzMUdzaiamcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaYclfhYaecxfheamaEfhmaAcufgAmbxdkka5hmaqheadhYina8Aamydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKamclfhmaecxfheaYcufgYmbkkdnaDTmba8AhiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgmaOamIdbNUdbaicwfgmaOamIdbNUdbaicxfgmaOamIdbNUdbaiczfgmaOamIdbNUdbaicCfgmaOamIdbNUdbaic3fhiaecufgembkkcbhYawcuaDcdtgCaDcFFFFi0Egicbyd1:H:cjbHjjjjbbgeBdaawcoBd2awaicbyd1:H:cjbHjjjjbbgEBd8KaecFeaCz:tjjjbh3dnadTmbaoJbbjZJbbjZaK:vaPceSENgOaONhKaxcdthxalheinaKaec;8:G:cjbalEgmIdwa8Aa5ydbgAc32fgiIdC:tgOaONamIdbaiIdx:tgOaONamIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna3aAcdtgifgmydbcuSmbaEaifIdbaO9ETmekamaYBdbaEaifaOUdbka5clfh5aqcxfhqaeaxfheadaYcefgY9hmbkkaba3aCzMjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd:m:H:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk9DeeuabcFeaicdtz:tjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:tjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd1:H:cjbHjjjjbbgvBdxavcFeaoz:tjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd:m:H:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd:q:H:cjbgeabcifc98GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:q:H:cjbgeabcrfc94GfgbBd:q:H:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:q:H:cjbge9Rcifc98GaefgbBd:q:H:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk:Kedbcj:Gdk1eFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeebebbebbebebbbeebbbbbbbbbbbbeeeeeebebbeeebeebbbbebebbbbbbbbbbbbbbbbbbc1:Hdkxebbbdbbb:G:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(x){n=x.instance,n.exports.__wasm_call_ctors()});function r(x){var _=new Uint8Array(x.length);for(var y=0;y<x.length;++y){var v=x.charCodeAt(y);_[y]=v>96?v-97:v>64?v-39:v+4}var E=0;for(var y=0;y<x.length;++y)_[E++]=_[y]<60?t[_[y]]:(_[y]-60)*64+_[++y];return _.buffer.slice(0,E)}function s(x){if(!x)throw Error("Assertion failed")}function a(x){return new Uint8Array(x.buffer,x.byteOffset,x.byteLength)}function o(x,_,y,v){var E=n.exports.sbrk,w=E(y*4),T=E(y*v*4),A=new Uint8Array(n.exports.memory.buffer);A.set(a(_),T),x(w,T,y,v*4),A=new Uint8Array(n.exports.memory.buffer);var P=new Uint32Array(y);return new Uint8Array(P.buffer).set(A.subarray(w,w+y*4)),E(w-E(0)),P}function c(x,_,y){var v=n.exports.sbrk,E=v(_.length*4),w=v(y*4),T=new Uint8Array(n.exports.memory.buffer),A=a(_);T.set(A,E);var P=x(w,E,_.length,y);T=new Uint8Array(n.exports.memory.buffer);var S=new Uint32Array(y);new Uint8Array(S.buffer).set(T.subarray(w,w+y*4)),v(E-v(0));for(var R=0;R<_.length;++R)_[R]=S[_[R]];return[S,P]}function l(x){var _=0;for(var y=0;y<x.length;++y){var v=x[y];_=_<v?v:_}return _}function u(x,_,y,v,E,w,T,A,P){var S=n.exports.sbrk,R=S(4),k=S(y*4),C=S(E*w),U=S(y*4),L=new Uint8Array(n.exports.memory.buffer);L.set(a(v),C),L.set(a(_),U);var O=x(k,U,y,C,E,w,T,A,P,R);L=new Uint8Array(n.exports.memory.buffer);var K=new Uint32Array(O);a(K).set(L.subarray(k,k+O*4));var B=new Float32Array(1);return a(B).set(L.subarray(R,R+4)),S(R-S(0)),[K,B[0]]}function d(x,_,y,v,E,w,T,A,P,S,R,k,C){var U=n.exports.sbrk,L=U(4),O=U(y*4),K=U(E*w),B=U(E*A),X=U(P.length*4),q=U(y*4),le=S?U(E):0,de=new Uint8Array(n.exports.memory.buffer);if(de.set(a(v),K),de.set(a(T),B),de.set(a(P),X),de.set(a(_),q),S)de.set(a(S),le);var Me=x(O,q,y,K,E,w,B,A,X,P.length,le,R,k,C,L);de=new Uint8Array(n.exports.memory.buffer);var pe=new Uint32Array(Me);a(pe).set(de.subarray(O,O+Me*4));var J=new Float32Array(1);return a(J).set(de.subarray(L,L+4)),U(L-U(0)),[pe,J[0]]}function f(x,_,y,v,E,w,T,A,P,S,R,k,C){var U=n.exports.sbrk,L=U(4),O=U(E*w),K=U(E*A),B=U(P.length*4),X=U(y*4),q=S?U(E):0,le=new Uint8Array(n.exports.memory.buffer);if(le.set(a(v),O),le.set(a(T),K),le.set(a(P),B),le.set(a(_),X),S)le.set(a(S),q);var de=x(X,y,O,E,w,K,A,B,P.length,q,R,k,C,L);le=new Uint8Array(n.exports.memory.buffer),a(_).set(le.subarray(X,X+de*4)),a(v).set(le.subarray(O,O+E*w)),a(T).set(le.subarray(K,K+E*A));var Me=new Float32Array(1);return a(Me).set(le.subarray(L,L+4)),U(L-U(0)),[de,Me[0]]}function h(x,_,y,v){var E=n.exports.sbrk,w=E(y*v),T=new Uint8Array(n.exports.memory.buffer);T.set(a(_),w);var A=x(w,y,v);return E(w-E(0)),A}function b(x,_,y,v,E,w,T,A){var P=n.exports.sbrk,S=P(A*4),R=P(y*v),k=E?P(y*w):0,C=new Uint8Array(n.exports.memory.buffer);if(C.set(a(_),R),E)C.set(a(E),k);var U=x(S,R,y,v,k,w,T,A);C=new Uint8Array(n.exports.memory.buffer);var L=new Uint32Array(U);return a(L).set(C.subarray(S,S+U*4)),P(S-P(0)),L}function m(x,_,y,v,E,w,T,A,P){var S=n.exports.sbrk,R=S(4),k=S(y*4),C=S(E*w),U=S(y*4),L=T?S(E):0,O=new Uint8Array(n.exports.memory.buffer);if(O.set(a(v),C),O.set(a(_),U),T)O.set(a(T),L);var K=x(k,U,y,C,E,w,L,A,P,R);O=new Uint8Array(n.exports.memory.buffer);var B=new Uint32Array(K);a(B).set(O.subarray(k,k+K*4));var X=new Float32Array(1);return a(X).set(O.subarray(R,R+4)),S(R-S(0)),[B,X[0]]}function g(x,_,y,v,E,w,T){var A=n.exports.sbrk,P=A(y*4),S=A(E*w),R=A(y*4),k=new Uint8Array(n.exports.memory.buffer);k.set(a(v),S),k.set(a(_),R);var C=x(P,R,y,S,E,w,T);k=new Uint8Array(n.exports.memory.buffer);var U=new Uint32Array(C);return a(U).set(k.subarray(P,P+C*4)),A(P-A(0)),U}var p={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,_InternalDebug:1073741824};return{ready:i,supported:!0,compactMesh:function(x){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0);var _=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),y=c(n.exports.meshopt_optimizeVertexFetchRemap,_,l(x)+1);if(x!==_)for(var v=0;v<_.length;++v)x[v]=_[v];return y},generatePositionRemap:function(x,_){return s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),o(n.exports.meshopt_generatePositionRemap,x,x.length/_,_)},simplify:function(x,_,y,v,E,w){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v>=0&&v<=x.length),s(v%3==0),s(E>=0);var T=0;for(var A=0;A<(w?w.length:0);++A)s(w[A]in p),T|=p[w[A]];var P=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),S=u(n.exports.meshopt_simplify,P,x.length,_,_.length/y,y*4,v,E,T);return S[0]=x instanceof Uint32Array?S[0]:new x.constructor(S[0]),S},simplifyWithAttributes:function(x,_,y,v,E,w,T,A,P,S){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/y)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/y),s(A>=0&&A<=x.length),s(A%3==0),s(P>=0),s(Array.isArray(w)),s(E>=w.length),s(w.length<=32);for(var R=0;R<w.length;++R)s(w[R]>=0);var k=0;for(var R=0;R<(S?S.length:0);++R)s(S[R]in p),k|=p[S[R]];var C=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),U=d(n.exports.meshopt_simplifyWithAttributes,C,x.length,_,_.length/y,y*4,v,E*4,new Float32Array(w),T,A,P,k);return U[0]=x instanceof Uint32Array?U[0]:new x.constructor(U[0]),U},simplifyWithUpdate:function(x,_,y,v,E,w,T,A,P,S){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v instanceof Float32Array),s(v.length==E*(_.length/y)),s(E>=0),s(T==null||T instanceof Uint8Array),s(T==null||T.length==_.length/y),s(A>=0&&A<=x.length),s(A%3==0),s(P>=0),s(Array.isArray(w)),s(E>=w.length),s(w.length<=32);for(var R=0;R<w.length;++R)s(w[R]>=0);var k=0;for(var R=0;R<(S?S.length:0);++R)s(S[R]in p),k|=p[S[R]];var C=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),U=f(n.exports.meshopt_simplifyWithUpdate,C,x.length,_,_.length/y,y*4,v,E*4,new Float32Array(w),T,A,P,k);if(x!==C)for(var R=0;R<U[0];++R)x[R]=C[R];return U},getScale:function(x,_){return s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),h(n.exports.meshopt_simplifyScale,x,x.length/_,_*4)},simplifyPoints:function(x,_,y,v,E,w){if(s(x instanceof Float32Array),s(x.length%_==0),s(_>=3),s(y>=0&&y<=x.length/_),v)return s(v instanceof Float32Array),s(v.length%E==0),s(E>=3),s(x.length/_==v.length/E),b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,v,E*4,w||0,y);else return b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,void 0,0,0,y)},simplifySloppy:function(x,_,y,v,E,w){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v==null||v instanceof Uint8Array),s(v==null||v.length==_.length/y),s(E>=0&&E<=x.length),s(E%3==0),s(w>=0);var T=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),A=m(n.exports.meshopt_simplifySloppy,T,x.length,_,_.length/y,y*4,v,E,w);return A[0]=x instanceof Uint32Array?A[0]:new x.constructor(A[0]),A},simplifyPrune:function(x,_,y,v){s(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),s(x.length%3==0),s(_ instanceof Float32Array),s(_.length%y==0),s(y>=3),s(v>=0);var E=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),w=g(n.exports.meshopt_simplifyPrune,E,x.length,_,_.length/y,y*4,v);return w=x instanceof Uint32Array?w:new x.constructor(w),w}}}()});var _X;var ER=ut(()=>{_X=function(){var e="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgzaBa81:tg8Xa80a8Z:tg8YNaUa83:tg8Za8XNa8Za8YNMMUdbazaYfaPId8KaPIdC:tg8XaPIdyaPIdK:tg8YNaPIdaaPIdz:tg8Za8XNa8Za8YNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,i=WebAssembly.instantiate(r(e),{}).then(function(m){n=m.instance,n.exports.__wasm_call_ctors()});function r(m){var g=new Uint8Array(m.length);for(var p=0;p<m.length;++p){var x=m.charCodeAt(p);g[p]=x>96?x-97:x>64?x-39:x+4}var _=0;for(var p=0;p<m.length;++p)g[_++]=g[p]<60?t[g[p]]:(g[p]-60)*64+g[++p];return g.buffer.slice(0,_)}function s(m){if(!m)throw Error("Assertion failed")}function a(m){return new Uint8Array(m.buffer,m.byteOffset,m.byteLength)}var o=48,c=16;function l(m,g){var p=m.meshlets[g*4+0],x=m.meshlets[g*4+1],_=m.meshlets[g*4+2],y=m.meshlets[g*4+3];return{vertices:m.vertices.subarray(p,p+_),triangles:m.triangles.subarray(x,x+y*3)}}function u(m,g,p,x,_,y,v,E,w,T){var A=n.exports.sbrk,P=n.exports.meshopt_buildMeshletsBound(g.length,y,v),S=A(P*c),R=A(g.length*4),k=A(g.length),C=A(g.byteLength),U=A(p.byteLength),L=new Uint8Array(n.exports.memory.buffer);L.set(a(g),C),L.set(a(p),U);var O=m(S,R,k,C,g.length,U,x,_,y,v,E,w,T);L=new Uint8Array(n.exports.memory.buffer);var K=L.subarray(S,S+O*c),B=new Uint32Array(K.buffer,K.byteOffset,K.byteLength/4).slice();for(var X=0;X<O;++X){var q=B[X*4+0],le=B[X*4+1],x=B[X*4+2],de=B[X*4+3];n.exports.meshopt_optimizeMeshlet(R+q*4,k+le,de,x)}var Me=O?B[(O-1)*4+0]+B[(O-1)*4+2]:0,pe=O?B[(O-1)*4+1]+B[(O-1)*4+3]*3:0,J={meshlets:B,vertices:new Uint32Array(L.buffer,R,Me).slice(),triangles:new Uint8Array(L.buffer,k,pe).slice(),meshletCount:O};return A(S-A(0)),J}function d(m){var g=new Float32Array(n.exports.memory.buffer,m,o/4);return{centerX:g[0],centerY:g[1],centerZ:g[2],radius:g[3],coneApexX:g[4],coneApexY:g[5],coneApexZ:g[6],coneAxisX:g[7],coneAxisY:g[8],coneAxisZ:g[9],coneCutoff:g[10]}}function f(m,g,p,x){var _=n.exports.sbrk,y=[],v=_(g.byteLength),E=_(m.vertices.byteLength),w=_(m.triangles.byteLength),T=_(o),A=new Uint8Array(n.exports.memory.buffer);A.set(a(g),v),A.set(a(m.vertices),E),A.set(a(m.triangles),w);for(var P=0;P<m.meshletCount;++P){var S=m.meshlets[P*4+0],R=m.meshlets[P*4+1],k=m.meshlets[P*4+3];n.exports.meshopt_computeMeshletBounds(T,E+S*4,w+R,k,v,p,x),y.push(d(T))}return _(v-_(0)),y}function h(m,g,p,x){var _=n.exports.sbrk,y=_(o),v=_(m.byteLength),E=_(g.byteLength),w=new Uint8Array(n.exports.memory.buffer);w.set(a(m),v),w.set(a(g),E),n.exports.meshopt_computeClusterBounds(y,v,m.length,E,p,x);var T=d(y);return _(y-_(0)),T}function b(m,g,p,x,_){var y=n.exports.sbrk,v=y(o),E=y(m.byteLength),w=x?y(x.byteLength):0,T=new Uint8Array(n.exports.memory.buffer);if(T.set(a(m),E),x)T.set(a(x),w);n.exports.meshopt_computeSphereBounds(v,E,g,p,w,x?_:0);var A=d(v);return y(v-y(0)),A}return{ready:i,supported:!0,buildMeshlets:function(m,g,p,x,_,y){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&_<=512),y=y||0;var v=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,v,g,g.length/p,p*4,x,_,_,y,0)},buildMeshletsFlex:function(m,g,p,x,_,y,v,E){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&y<=512),s(_<=y),v=v||0,E=E||0;var w=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,w,g,g.length/p,p*4,x,_,y,v,E)},buildMeshletsSpatial:function(m,g,p,x,_,y,v){s(m.length%3==0),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),s(x>=3&&x<=256),s(_>=1&&y<=512),s(_<=y),v=v||0;var E=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsSpatial,E,g,g.length/p,p*4,x,_,y,v)},extractMeshlet:function(m,g){return s(g>=0&&g<m.meshletCount),l(m,g)},computeClusterBounds:function(m,g,p){s(m.length%3==0),s(m.length/3<=512),s(g instanceof Float32Array),s(g.length%p==0),s(p>=3);var x=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(x,g,g.length/p,p*4)},computeMeshletBounds:function(m,g,p){return s(g instanceof Float32Array),s(g.length%p==0),s(p>=3),f(m,g,g.length/p,p*4)},computeSphereBounds:function(m,g,p,x){return s(m instanceof Float32Array),s(m.length%g==0),s(g>=3),s(!p||p instanceof Float32Array),s(!p||p.length%x==0),s(!p||x>=1),s(!p||m.length/g==p.length/x),x=x||0,b(m,m.length/g,g*4,p,x*4)}}}()});var TR={};Lb(TR,{MeshoptEncoder:()=>wB});var AR=ut(()=>{yR();_R();vR();ER()});function rc(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 Vf(e,t="|"){return e.map((n)=>Gf(n)).join(t)}function sc(e,t){if(typeof t==="bigint")return t.toString();return t}class Fb{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 ac(e){return new Fb(e)}function Ub(e){return e===null||e===void 0}function Yr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Bb(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function mi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function oc(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Sr(e){return oc(e._zod.def)??e._zod.def.shape}function zb(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return mi(this,t,i),i},enumerable:!0,configurable:!0})}function Vb(e,t,n){if(t in e)mi(e,t,n);else e[t]=n}function ra(e,t,n,i){let r=Sr(t);for(let s of n){let a=Object.getOwnPropertyDescriptor(r,s);if(!a.enumerable)continue;if(a.get)zb(e,s,()=>{let o=t._zod.def.shape[s];return i?i(o,s):o});else Vb(e,s,i?i(a.value,s):a.value)}}function hI(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)zb(e,n,()=>t[n]);else Vb(e,n,i.value)}}function ei(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function jb(e){return JSON.stringify(e)}function Hb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var jf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ha(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Gb=ac(()=>{if(Bn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function sa(e){if(Ha(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(Ha(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Hf(e){if(sa(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 $b=new Set(["string","number","symbol"]),Kb=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Rr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ji(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ue(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 Gf(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Wb(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Kl=(()=>({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]}))(),$f={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function pI(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 ra(s,e,Wl(e,t)),Ji(e,ei(n,{shape:s,checks:[]}))}function Wl(e,t){let n=Sr(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 mI(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(Wl(e,t)),a={};return ra(a,e,Reflect.ownKeys(Sr(e)).filter((o)=>!s.has(o))),Ji(e,ei(n,{shape:a,checks:[]}))}function gI(e,t){if(!sa(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Sr(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 Ji(e,ei(e._zod.def,{shape:Xb(e,t)}))}function Xb(e,t){let n={};return ra(n,e,Reflect.ownKeys(Sr(e))),hI(n,t),n}function bI(e,t){if(!sa(t))throw Error("Invalid input to safeExtend: expected a plain object");return Ji(e,ei(e._zod.def,{shape:Xb(e,t)}))}function xI(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={};ra(n,e,Reflect.ownKeys(Sr(e))),ra(n,t,Reflect.ownKeys(Sr(t)));let i=ei(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ji(e,i)}function qb(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let o=n?new Set(Wl(t,n)):void 0,c={};return ra(c,t,Reflect.ownKeys(Sr(t)),e&&((l,u)=>o&&!o.has(u)?l:new e({type:"optional",innerType:l}))),Ji(t,ei(t._zod.def,{shape:c,checks:[]}))}function yI(e,t,n){let i=n?new Set(Wl(t,n)):void 0,r={};return ra(r,t,Reflect.ownKeys(Sr(t)),(s,a)=>i&&!i.has(a)?s:new e({type:"nonoptional",innerType:s})),Ji(t,ei(t._zod.def,{shape:r}))}function gi(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 Jb(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 Zi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function ic(e){return typeof e==="string"?e:e?.message}function Kf(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Yi(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:ic(e.inst?._zod.def?.error?.(e))??ic(s?.(e))??ic(t?.error?.(e))??ic(n.customError?.(e))??ic(n.localeError?.(e))??"Invalid input",o={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;o[c]=e[c]}if(o.path??(o.path=[]),o.message=a,t?.reportInput)o.input=e.input;return o}var _I=/[\uD800-\uDBFF]/;function Xl(e){let t=e.length;if(!_I.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 ql(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Zb(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 aa(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function Yb(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else vI(e,n,i.value)}}function Mr(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Jl(e,t,n){return Mr(e,t,n,!1)}function Qb(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Mr(this,n,i(this))},set(r){Mr(this,n,r)}})}return t}function vI(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Mr(this,t,n.bind(this))},set(i){Mr(this,t,i)}})}function EI(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var zf,Zr=!1,TI={configurable:!0,get(){Zr=!0;return}};function Et(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&zf!==e._zod){zf=void 0;return}zf=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,TI);let r=Zr;Zr=!1;try{let s=n(this);if(Zr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Zr=Zr||r,s}catch(s){throw delete this[t],Zr=Zr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function AI(e,t,n,i){let r=EI(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 wI="~constantCatch";function ex(e){let t=()=>e;return t[wI]=!0,t}var tx;var Wf={value:void 0,enumerable:!1},nx="captureStackTrace"in Error?Error:null;function SI(e){let t=nx;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return nx=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function se(e,t,n,i){let r={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=r;let a=n,o=a&&new WeakSet;function c(f,h){if(!f._zod){Wf.value=new s(h);try{Object.defineProperty(f,"_zod",Wf)}finally{Wf.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),o){let m=Object.getPrototypeOf(f),g=f._zod.constr.prototype,p=m;while(p&&p!==g)p=Object.getPrototypeOf(p);let x=p??m;if(!o.has(x))o.add(x),Yb(x,a)}let b=d.prototype;for(let m in b){if(!Object.prototype.hasOwnProperty.call(b,m))continue;if(!(m in f))f[m]=b[m].bind(f)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(f){let h=i?.Parent?SI(u):this;c(h,f);let b=h._zod.deferred;if(b){for(let g of b)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(f)=>{if(i?.Parent&&f instanceof i.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Qi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class cc extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(tx=globalThis).__zod_globalConfig??(tx.__zod_globalConfig={});var Bn=globalThis.__zod_globalConfig;function ti(e){if(e)Object.assign(Bn,e);return Bn}function MI(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,sc,2)),e.message}function RI(e){this._zod.message=e}var II={get:MI,set:RI,enumerable:!0,configurable:!0},qf={value:void 0,enumerable:!1},ix=new WeakSet([Object.prototype,Error.prototype]),rx=(e,t)=>{e.name="$ZodError",qf.value=t,Object.defineProperty(e,"issues",qf),qf.value=void 0,Object.defineProperty(e,"message",II);let n=Object.getPrototypeOf(e);if(!ix.has(n))ix.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})}})},sx=se("$ZodError",rx),$B=se("$ZodError",rx,void 0,{Parent:Error});function CI(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 ax(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)CI(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function ox(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((o)=>i({issues:o},[...s,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...s,...a.path]);else{let o=[...s,...a.path];if(o.length===0)n._errors.push(t(a));else{let c=n,l=0;while(l<o.length){let u=o[l],d=l===o.length-1;if(u==="_errors"){if(d)c._errors.push(t(a));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];if(d)f._errors.push(t(a));c=f,l++}}}};return i(e),n}function Zl(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Yl=(e)=>{let t=(n,i,r,s)=>{let a=r?{...r,async:!1}:{async:!1},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)throw new Qi;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>Yi(l,a,ti())));throw jf(c,s?.callee??t),c}return o.value};return t};var Ql=(e)=>{let t=async(n,i,r,s)=>{let a=r?{...r,async:!0}:{async:!0},o=n._zod.run({value:i,issues:[]},a);if(o instanceof Promise)o=await o;if(o.issues.length){let c=new(s?.Err??e)(o.issues.map((l)=>Yi(l,a,ti())));throw jf(c,s?.callee??t),c}return o.value};return t};var eu=(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 Qi;return s.issues.length?cx(e,s.issues,r):{success:!0,data:s.value}};function cx(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Yi(r,n,ti()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var tu=(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?cx(e,s.issues,r):{success:!0,data:s.value}};var NI=Symbol.for("zod.compile.invalid"),PI=Symbol.for("zod.compile.fallback"),Jf=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==NI)return!0;if(i.definite===!0&&n===void 0)return!1}return OI(e,t,n)};function OI(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[PI]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Qi;return s.issues.length===0}var Zf=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},lx=(e)=>{let t=Yl(e),n=(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,o,Zl(n,a))};return n};var ux=(e)=>{let t=Yl(e),n=(i,r,s,a)=>t(i,r,s,Zl(n,a));return n};var dx=(e)=>{let t=Ql(e),n=async(i,r,s,a)=>{let o=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,o,Zl(n,a))};return n};var fx=(e)=>{let t=Ql(e),n=async(i,r,s,a)=>await t(i,r,s,Zl(n,a));return n};var hx=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return eu(e)(t,n,r)};var px=(e)=>(t,n,i)=>eu(e)(t,n,i);var mx=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return tu(e)(t,n,r)};var gx=(e)=>async(t,n,i)=>tu(e)(t,n,i);var bx=/^[cC][0-9a-z]{6,}$/,xx=/^[0-9a-z]+$/,yx=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_x=/^[0-9a-vA-V]{20}$/,vx=/^[A-Za-z0-9]{27}$/,Ex=/^[a-zA-Z0-9_-]{21}$/;function Tx(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ax=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var wx=/^([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})$/,Qf=(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 Sx=/^(?:[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 kI="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Mx(){return new RegExp(kI,"u")}var Rx=/^(?:(?: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])$/,Ix=/^(([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 Cx=/^((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])$/,Nx=/^(([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])$/,Px=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ox=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var kx=/^https?$/,Dx=/^\+[1-9]\d{6,14}$/;var Lx="(?:(?:\\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 DI(e){return new RegExp(`^${e}$`)}var Fx=DI(Lx);function Yf(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 Ux(e){return new RegExp(`^${Yf(e)}$`)}function Bx(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Yf({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Yf({precision:e.precision})}`:n;return new RegExp(`^${Lx}T(?:${i})$`)}var zx=/^[\s\S]{0,}$/,Vx=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var nu=/^-?\d+$/,Ga=/^-?\d+(?:\.\d+)?$/,jx=/^(?:true|false)$/i;var Hx=/^[^A-Z]*$/,Gx=/^[^a-z]*$/;var Sn=se("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var eh=(e)=>{let t=e.value;return!Ub(t)&&t.length!==void 0},iu={number:"number",bigint:"bigint",object:"date"},th=se("$ZodCheckLessThan",(e,t)=>{Sn.init(e,t);let n=iu[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:iu[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})}}),nh=se("$ZodCheckGreaterThan",(e,t)=>{Sn.init(e,t);let n=iu[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:iu[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})}}),$x=se("$ZodCheckMultipleOf",(e,t)=>{Sn.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Bb(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Kx=se("$ZodCheckNumberFormat",(e,t)=>{Sn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Kl[t.format];e._zod.check=(a)=>{let o=a.value;if(n){if(!Number.isInteger(o)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){if(o>0)a.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else a.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(o<r)a.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(o>s)a.issues.push({origin:"number",input:o,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Wx=se("$ZodCheckMaxLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=eh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Xl(r):s)<=t.maximum)return;let o=ql(r);i.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Xx=se("$ZodCheckMinLength",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=eh),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Xl(r):s)>=t.minimum)return;let o=ql(r);i.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qx=se("$ZodCheckLengthEquals",(e,t)=>{var n;Sn.init(e,t),(n=e._zod.def).when??(n.when=eh),e._zod.check=(i)=>{let r=i.value,s=r.length,a=typeof r==="string"&&s>=t.length&&s<=t.length*2?Xl(r):s;if(a===t.length)return;let o=ql(r),c=a>t.length;i.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),uc=se("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Sn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Jx=se("$ZodCheckRegex",(e,t)=>{uc.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})}}),Zx=se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Hx),uc.init(e,t)}),Yx=se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Gx),uc.init(e,t)}),Qx=se("$ZodCheckIncludes",(e,t)=>{Sn.init(e,t);let n=Rr(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})}}),ey=se("$ZodCheckStartsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`^${Rr(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})}}),ty=se("$ZodCheckEndsWith",(e,t)=>{Sn.init(e,t);let n=new RegExp(`.*${Rr(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 ny=se("$ZodCheckOverwrite",(e,t)=>{Sn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class ih{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(", ")}) {
+`));return d(LU.bind(void 0,e))}dS.exports=DU});var pS=ta(function(FK,hS){var FU=fS();function UU(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function zU(e){var t=new UU;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var r=0;r<n.length;++r){var i=n[r];if(i==="array"||typeof i==="object"&&i.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(i.blockIndices?i.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw Error("cwise: post() block may not reference array args")}else if(i==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(i==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw Error("cwise: post() block may not reference array index")}else if(i==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw Error("cwise: post() block may not write to array shape")}else if(typeof i==="object"&&i.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:i.array,offset:i.offset}),t.offsetArgIndex.push(r);else throw Error("cwise: Unknown argument type "+n[r])}if(t.arrayArgs.length<=0)throw Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,FU(t)}hS.exports=zU});var vS=ta(function(sn){var tr=pS(),Mf={body:"",args:[],thisVars:[],localVars:[]};function cb(e){if(!e)return Mf;for(var t=0;t<e.args.length;++t){var n=e.args[t];if(t===0)e.args[t]={name:n,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1};else e.args[t]={name:n,lvalue:!1,rvalue:!0,count:1}}if(!e.thisVars)e.thisVars=[];if(!e.localVars)e.localVars=[];return e}function BU(e){return tr({args:e.args,pre:cb(e.pre),body:cb(e.body),post:cb(e.proc),funcName:e.funcName})}function Yt(e){var t=[];for(var n=0;n<e.args.length;++n)t.push("a"+n);var r=Function("P",["return function ",e.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(BU(e))}var mS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var e in mS){var t=mS[e];sn[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),sn[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}})();var gS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var e in gS){var t=gS[e];sn[e]=Yt({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),sn[e+"eq"]=Yt({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}})();var bS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var e in bS){var t=bS[e];sn[e]=Yt({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),sn[e+"s"]=Yt({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),sn[e+"eq"]=Yt({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),sn[e+"seq"]=Yt({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}})();var xS=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var e=0;e<xS.length;++e){var t=xS[e];sn[t]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),sn[t+"eq"]=Yt({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var yS=["max","min","atan2","pow"];(function(){for(var e=0;e<yS.length;++e){var t=yS[e];sn[t]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),sn[t+"s"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),sn[t+"eq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),sn[t+"seq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var _S=["atan2","pow"];(function(){for(var e=0;e<_S.length;++e){var t=_S[e];sn[t+"op"]=Yt({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),sn[t+"ops"]=Yt({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),sn[t+"opeq"]=Yt({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),sn[t+"opseq"]=Yt({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();sn.any=tr({args:["array"],pre:Mf,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});sn.all=tr({args:["array"],pre:Mf,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});sn.sum=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});sn.prod=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});sn.norm2squared=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});sn.norm2=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});sn.norminf=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});sn.norm1=tr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});sn.sup=tr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.inf=tr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});sn.argmin=tr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.argmax=tr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});sn.random=Yt({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});sn.assign=Yt({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});sn.assigns=Yt({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});sn.equals=tr({args:["array","array"],pre:Mf,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});function i3(e,t){if(!(e instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let n=new Blob([e],{type:t});return createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((r)=>{let i=new OffscreenCanvas(r.width,r.height).getContext("2d");i.drawImage(r,0,0);let a=i.getImageData(0,0,r.width,r.height);return ES.default(new Uint8Array(a.data),[r.width,r.height,4],[4,4*r.width,1],0)})}async function AS(e,t){return i3(e,t)}var ES,r3;var TS=ot(()=>{ES=Zf(sb(),1),r3=Zf(vS(),1)});function Lf(e,t){return Object.defineProperty(t,"name",{value:e}),t}function Df(e,t){let n={...e};for(let r in t)if(t[r]!==void 0)n[r]=t[r];return n}function BS(e){let t=[];for(let n of e.listAttributes())t.push(n);for(let n of e.listTargets())for(let r of n.listAttributes())t.push(r);return Array.from(new Set(t))}function s3(e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Cf(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function o3(e,t=e){let n=jS(e,t);for(let r=0;r<n.length;r++)n[r]=r;return n}function jS(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function VS(e){for(let t in e)return!1;return!0}function c3(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],h=t[11],b=t[12],m=t[13],g=t[14],p=t[15],y=n*o-r*s,v=n*c-i*s,x=n*l-a*s,_=r*c-i*o,E=r*l-a*o,w=i*l-a*c,A=u*m-d*b,T=u*g-f*b,N=u*p-h*b,M=d*g-f*m,R=d*p-h*m,k=f*p-h*g,C=y*k-v*R+x*M+_*N-E*T+w*A;if(!C)return null;return C=1/C,e[0]=(o*k-c*R+l*M)*C,e[1]=(i*R-r*k-a*M)*C,e[2]=(m*w-g*E+p*_)*C,e[3]=(f*E-d*w-h*_)*C,e[4]=(c*N-s*k-l*T)*C,e[5]=(n*k-i*N+a*T)*C,e[6]=(g*x-b*w-p*v)*C,e[7]=(u*w-f*x+h*v)*C,e[8]=(s*R-o*N+l*A)*C,e[9]=(r*N-n*R-a*A)*C,e[10]=(b*E-m*x+p*y)*C,e[11]=(d*x-u*E-h*y)*C,e[12]=(o*T-s*M-c*A)*C,e[13]=(n*M-r*T+i*A)*C,e[14]=(m*v-b*_-g*y)*C,e[15]=(u*_-d*v+f*y)*C,e}function mb(e,t,n){var r=t[0],i=t[1],a=t[2],s=t[3],o=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],h=t[10],b=t[11],m=t[12],g=t[13],p=t[14],y=t[15],v=n[0],x=n[1],_=n[2],E=n[3];return e[0]=v*r+x*o+_*d+E*m,e[1]=v*i+x*c+_*f+E*g,e[2]=v*a+x*l+_*h+E*p,e[3]=v*s+x*u+_*b+E*y,v=n[4],x=n[5],_=n[6],E=n[7],e[4]=v*r+x*o+_*d+E*m,e[5]=v*i+x*c+_*f+E*g,e[6]=v*a+x*l+_*h+E*p,e[7]=v*s+x*u+_*b+E*y,v=n[8],x=n[9],_=n[10],E=n[11],e[8]=v*r+x*o+_*d+E*m,e[9]=v*i+x*c+_*f+E*g,e[10]=v*a+x*l+_*h+E*p,e[11]=v*s+x*u+_*b+E*y,v=n[12],x=n[13],_=n[14],E=n[15],e[12]=v*r+x*o+_*d+E*m,e[13]=v*i+x*c+_*f+E*g,e[14]=v*a+x*l+_*h+E*p,e[15]=v*s+x*u+_*b+E*y,e}function l3(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function u3(e,t,n,r){var i=t[0],a=t[1],s=t[2],o=t[3],c=i+i,l=a+a,u=s+s,d=i*c,f=i*l,h=i*u,b=a*l,m=a*u,g=s*u,p=o*c,y=o*l,v=o*u,x=r[0],_=r[1],E=r[2];return e[0]=(1-(b+g))*x,e[1]=(f+v)*x,e[2]=(h-y)*x,e[3]=0,e[4]=(f-v)*_,e[5]=(1-(d+g))*_,e[6]=(m+p)*_,e[7]=0,e[8]=(h+y)*E,e[9]=(m-p)*E,e[10]=(1-(d+b))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Pf(e,t){let n=e.getAttribute("POSITION"),r=e.getIndices();if(!n)return 0;switch(t){case"render":return r?r.getCount():n.getCount();case"render-cached":return r?new Set(r.getArray()).size:n.getCount();case"upload-naive":case"upload":return n.getCount();case"distinct":case"distinct-position":return d3(t);case"unused":return r?n.getCount()-new Set(r.getArray()).size:0;default:return f3(t)}}function d3(e){throw Error(`Not implemented: ${e}`)}function f3(e){throw Error(`Unexpected value: ${e}`)}function h3(e,t,n){let r=xf.fromGraph(e.getGraph());if(!t||!n)[t,n]=p3(e);let i=e.getIndices(),a=i?i.getArray():null,s=Pf(e,"render"),o=r.createAccessor(),c=s,l=jS(c,n);for(let d=0;d<c;d++)l[d]=t[a?a[d]:d];e.setIndices(o.setArray(l));let u=BS(e);for(let d of e.listAttributes()){let f=Cf(r,d);db(d,i,t,f,n),e.swap(d,f)}for(let d of e.listTargets())for(let f of d.listAttributes()){let h=Cf(r,f);db(f,i,t,h,n),d.swap(f,h)}if(i&&i.listParents().length===1)i.dispose();for(let d of u)if(d.listParents().length===1)d.dispose();return e}function db(e,t,n,r,i){let a=e.getElementSize(),s=e.getArray(),o=t?t.getArray():null,c=t?t.getCount():e.getCount(),l=new s.constructor(i*a),u=new Uint8Array(i);for(let d=0;d<c;d++){let f=o?o[d]:d,h=n[f];if(u[h])continue;for(let b=0;b<a;b++)l[h*a+b]=s[f*a+b];u[h]=1}return r.setArray(l)}function p3(e){let t=Pf(e,"upload"),n=e.getIndices(),r=n?n.getArray():null;if(!n||!r)return[o3(t,1e6),t];let i=new Uint32Array(t).fill(wS),a=0;for(let s=0;s<r.length;s++){let o=r[s];if(i[o]===wS)i[o]=a++}return[i,a]}function m3(){var e=new Nf(3);if(Nf!=Float32Array)e[0]=0,e[1]=0,e[2]=0;return e}function g3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function fb(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function hb(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function MS(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function b3(e,t,n){var r=t[0],i=t[1],a=t[2],s=n[3]*r+n[7]*i+n[11]*a+n[15];return s=s||1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/s,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/s,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/s,e}function gb(e=ub){let t=Df(ub,e),n=new Set(t.propertyTypes);for(let r of t.propertyTypes)if(!ub.propertyTypes.includes(r))throw Error(`${es}: Unsupported deduplication on type "${r}".`);return Lf(es,(r)=>{let i=r.getLogger();if(n.has(Q.ACCESSOR))y3(r);if(n.has(Q.TEXTURE))v3(r,t);if(n.has(Q.MATERIAL))E3(r,t);if(n.has(Q.MESH))_3(r,t);if(n.has(Q.SKIN))A3(r,t);i.debug(`${es}: Complete.`)})}function y3(e){let t=e.getLogger(),n=new Map,r=new Map,i=new Map,a=new Map,s=e.getRoot().listMeshes();s.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((h)=>o(h,r)),o(f.getIndices(),n)})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers())o(f.getInput(),i),o(f.getOutput(),a);function o(d,f){if(!d)return;let h=[d.getCount(),d.getType(),d.getComponentType(),d.getNormalized(),d.getSparse()].join(":"),b=f.get(h);if(!b)f.set(h,b=new Set);b.add(d)}function c(d,f){for(let h=0;h<d.length;h++){let b=d[h],m=Ye.toView(b.getArray());if(f.has(b))continue;for(let g=h+1;g<d.length;g++){let p=d[g];if(f.has(p))continue;if(Ye.equals(m,Ye.toView(p.getArray())))f.set(p,b)}}}let l=0,u=new Map;for(let d of[r,n,i,a])for(let f of d.values())l+=f.size,c(Array.from(f),u);t.debug(`${es}: Merged ${u.size} of ${l} accessors.`),s.forEach((d)=>{d.listPrimitives().forEach((f)=>{f.listAttributes().forEach((b)=>{if(u.has(b))f.swap(b,u.get(b))});let h=f.getIndices();if(h&&u.has(h))f.swap(h,u.get(h))})});for(let d of e.getRoot().listAnimations())for(let f of d.listSamplers()){let h=f.getInput(),b=f.getOutput();if(h&&u.has(h))f.swap(h,u.get(h));if(b&&u.has(b))f.swap(b,u.get(b))}Array.from(u.keys()).forEach((d)=>d.dispose())}function _3(e,t){let n=e.getLogger(),r=e.getRoot(),i=new Map;r.listAccessors().forEach((o,c)=>i.set(o,c)),r.listMaterials().forEach((o,c)=>i.set(o,c));let a=r.listMeshes().length,s=new Map;for(let o of r.listMeshes()){let c=[];for(let u of o.listPrimitives())c.push(GS(u,i));let l="";if(t.keepUniqueNames)l+=o.getName()+";";if(l+=c.join(";"),s.has(l)){let u=s.get(l);o.listParents().forEach((d)=>{if(d.propertyType!==Q.ROOT)d.swap(o,u)}),o.dispose()}else s.set(l,o)}n.debug(`${es}: Merged ${a-s.size} of ${a} meshes.`)}function v3(e,t){let n=e.getLogger(),r=e.getRoot(),i=r.listTextures(),a=new Map;for(let s=0;s<i.length;s++){let o=i[s],c=o.getImage();if(a.has(o))continue;for(let l=s+1;l<i.length;l++){let u=i[l],d=u.getImage();if(a.has(u))continue;if(o.getMimeType()!==u.getMimeType())continue;if(t.keepUniqueNames&&o.getName()!==u.getName())continue;let f=o.getSize(),h=u.getSize();if(!f||!h)continue;if(f[0]!==h[0])continue;if(f[1]!==h[1])continue;if(!c||!d)continue;if(Ye.equals(c,d))a.set(u,o)}}n.debug(`${es}: Merged ${a.size} of ${r.listTextures().length} textures.`),Array.from(a.entries()).forEach(([s,o])=>{s.listParents().forEach((c)=>{if(!(c instanceof Fa))c.swap(s,o)}),s.dispose()})}function E3(e,t){let n=e.getLogger(),r=e.getRoot().listMaterials(),i=new Map,a=new Map,s=new Set;if(!t.keepUniqueNames)s.add("name");for(let o=0;o<r.length;o++){let c=r[o];if(i.has(c))continue;if(SS(c,a))continue;for(let l=o+1;l<r.length;l++){let u=r[l];if(i.has(u))continue;if(SS(u,a))continue;if(c.equals(u,s))i.set(u,c)}}n.debug(`${es}: Merged ${i.size} of ${r.length} materials.`),Array.from(i.entries()).forEach(([o,c])=>{o.listParents().forEach((l)=>{if(!(l instanceof Fa))l.swap(o,c)}),o.dispose()})}function A3(e,t){let n=e.getLogger(),r=e.getRoot().listSkins(),i=new Map,a=new Set(["joints"]);if(!t.keepUniqueNames)a.add("name");for(let s=0;s<r.length;s++){let o=r[s];if(i.has(o))continue;for(let c=s+1;c<r.length;c++){let l=r[c];if(i.has(l))continue;if(o.equals(l,a)&&s3(o.listJoints(),l.listJoints()))i.set(l,o)}}n.debug(`${es}: Merged ${i.size} of ${r.length} skins.`),Array.from(i.entries()).forEach(([s,o])=>{s.listParents().forEach((c)=>{if(!(c instanceof Fa))c.swap(s,o)}),s.dispose()})}function GS(e,t){let n=[];for(let r of e.listSemantics()){let i=e.getAttribute(r);n.push(r+":"+t.get(i))}if(e instanceof Qn){let r=e.getIndices();if(r)n.push("indices:"+t.get(r));let i=e.getMaterial();if(i)n.push("material:"+t.get(i));n.push("mode:"+e.getMode());for(let a of e.listTargets())n.push("target:"+GS(a,t))}return n.join(",")}function SS(e,t){if(t.has(e))return t.get(e);let n=e.getGraph(),r=new Set,i=n.listParentEdges(e);while(i.length>0){let a=i.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;let s=a.getChild();if(r.has(s))continue;for(let o of n.listChildEdges(s))i.push(o)}return t.set(e,!1),!1}function HS(){var e=new Nf(4);if(Nf!=Float32Array)e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e}function T3(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function w3(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function M3(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function S3(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function R3(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)}function N3(e){return e.getGraph().listParentEdges(e).some((t)=>t.getAttributes().isColor||C3.test(t.getName()))?"srgb":null}function P3(e){let t=e.getGraph(),n=new Set,r=new Set;function i(a){let s=new Set;for(let o of t.listChildEdges(a))if(o.getChild()instanceof tc)s.add(o.getName()+"Info");for(let o of t.listChildEdges(a)){let c=o.getChild();if(n.has(c))continue;if(n.add(c),c instanceof Mt&&s.has(o.getName()))r.add(c);else if(c instanceof rt)i(c)}}return i(e),Array.from(r)}function O3(e){let t=xf.fromGraph(e.getGraph()).getRoot(),n=e.getGraph().listParentEdges(e).filter((r)=>r.getParent()!==t).map((r)=>r.getName());return Array.from(new Set(n))}function Ff(e=RS){let t=Df(RS,e),n=new Set(t.propertyTypes),r=t.keepExtras;return Lf(ac,async(i)=>{let a=i.getLogger(),s=i.getRoot(),o=i.getGraph(),c=new k3,l=(u)=>c.dispose(u.target);if(o.addEventListener("node:dispose",l),n.has(Q.MESH))for(let u of s.listMeshes()){if(u.listPrimitives().length>0)continue;u.dispose()}if(n.has(Q.NODE)){if(!t.keepLeaves)for(let u of s.listScenes())WS(o,u,r);for(let u of s.listNodes())Cr(u,r)}if(n.has(Q.SKIN))for(let u of s.listSkins())Cr(u,r);if(n.has(Q.MESH))for(let u of s.listMeshes())Cr(u,r);if(n.has(Q.CAMERA))for(let u of s.listCameras())Cr(u,r);if(n.has(Q.PRIMITIVE))IS(o,Q.PRIMITIVE,r);if(n.has(Q.PRIMITIVE_TARGET))IS(o,Q.PRIMITIVE_TARGET,r);if(!t.keepAttributes&&n.has(Q.ACCESSOR)){let u=new Map;for(let d of s.listMeshes())for(let f of d.listPrimitives()){let h=f.getMaterial();if(!h)continue;let b=L3(f,XS(i,f,h));CS(f,b),f.listTargets().forEach((m)=>CS(m,b)),u.has(h)?u.get(h).add(f):u.set(h,new Set([f]))}for(let[d,f]of u)D3(d,Array.from(f))}if(n.has(Q.ANIMATION))for(let u of s.listAnimations()){for(let d of u.listChannels())if(!d.getTargetNode())d.dispose();if(!u.listChannels().length){let d=u.listSamplers();Cr(u,r),d.forEach((f)=>Cr(f,r))}else u.listSamplers().forEach((d)=>Cr(d,r))}if(n.has(Q.MATERIAL))s.listMaterials().forEach((u)=>Cr(u,r));if(n.has(Q.TEXTURE)){if(s.listTextures().forEach((u)=>Cr(u,r)),!t.keepSolidTextures)await F3(i)}if(n.has(Q.ACCESSOR))s.listAccessors().forEach((u)=>Cr(u,r));if(n.has(Q.BUFFER))s.listBuffers().forEach((u)=>Cr(u,r));if(o.removeEventListener("node:dispose",l),!c.empty()){let u=c.entries().map(([d,f])=>`${d} (${f})`).join(", ");a.info(`${ac}: Removed types... ${u}`)}else a.debug(`${ac}: No unused properties found.`);a.debug(`${ac}: Complete.`)})}function Cr(e,t){let n=e.listParents().filter((i)=>!(i instanceof Fa||i instanceof Vs)),r=t&&!VS(e.getExtras());if(!n.length&&!r)e.dispose()}function IS(e,t,n){for(let r of e.listEdges()){let i=r.getParent();if(i.propertyType===t)Cr(i,n)}}function WS(e,t,n){if(t.listChildren().forEach((s)=>WS(e,s,n)),t instanceof bf)return;let r=e.listParentEdges(t).some((s)=>{let o=s.getParent().propertyType;return o!==Q.ROOT&&o!==Q.SCENE&&o!==Q.NODE}),i=e.listChildren(t).length===0,a=n&&!VS(t.getExtras());if(i&&!r&&!a)t.dispose()}function CS(e,t){for(let n of t)e.setAttribute(n,null)}function L3(e,t){let n=[];for(let r of e.listSemantics())if(r==="NORMAL"&&!t.has(r))n.push(r);else if(r==="TANGENT"&&!t.has(r))n.push(r);else if(r.startsWith("TEXCOORD_")&&!t.has(r))n.push(r);else if(r.startsWith("COLOR_")&&r!=="COLOR_0")n.push(r);return n}function XS(e,t,n,r=new Set){let i=e.getGraph().listChildEdges(n),a=new Set;for(let c of i)if(c.getChild()instanceof tc)a.add(c.getName());for(let c of i){let l=c.getName(),u=c.getChild();if(u instanceof Mt){if(a.has(l.replace(/Info$/,"")))r.add(`TEXCOORD_${u.getTexCoord()}`)}if(u instanceof tc&&l.match(/normalTexture/i))r.add("TANGENT");if(u instanceof rt)XS(e,t,u,r)}let s=n instanceof Bs&&!n.getExtension("KHR_materials_unlit"),o=t.getMode()===Qn.Mode.POINTS;if(s&&!o)r.add("NORMAL");return r}function D3(e,t){let n=P3(e),r=new Set(n.map((c)=>c.getTexCoord())),i=Array.from(r).sort(),a=new Map(i.map((c,l)=>[c,l])),s=new Map(i.map((c,l)=>[`TEXCOORD_${c}`,`TEXCOORD_${l}`]));for(let c of n){let l=c.getTexCoord();c.setTexCoord(a.get(l))}for(let c of t){let l=c.listSemantics().filter((u)=>u.startsWith("TEXCOORD_")).sort();o(c,l),c.listTargets().forEach((u)=>o(u,l))}function o(c,l){for(let u of l){let d=c.getAttribute(u);if(!d)continue;let f=s.get(u);if(f===u)continue;c.setAttribute(f,d),c.setAttribute(u,null)}}}async function F3(e){let t=e.getRoot(),n=e.getGraph(),r=e.getLogger(),i=t.listTextures().map(async(a)=>{let s=await z3(a);if(!s)return;if(N3(a)==="srgb")aM.convertSRGBToLinear(s,s);let o=a.getName()||a.getURI(),c=a.getSize()?.join("x"),l=O3(a);for(let u of n.listParentEdges(a)){let d=u.getParent();if(d!==t&&U3(d,s,u.getName(),r))u.dispose()}if(a.listParents().length===1)a.dispose(),r.debug(`${ac}: Removed solid-color texture "${o}" (${c}px ${l.join(", ")})`)});await Promise.all(i)}function U3(e,t,n,r){if(e instanceof Bs)switch(n){case"baseColorTexture":return e.setBaseColorFactor(I3(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(x3([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=pb;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return KS($S(HS(),t,[0.5,0.5,1,1]))<=pb}return r.warn(`${ac}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function z3(e){let t=await B3(e);if(!t)return null;let n=[1/0,1/0,1/0,1/0],r=[-1/0,-1/0,-1/0,-1/0],i=[0,0,0,0],[a,s]=t.shape;for(let o=0;o<a;o++){for(let c=0;c<s;c++)for(let l=0;l<4;l++)n[l]=Math.min(n[l],t.get(o,c,l)),r[l]=Math.max(r[l],t.get(o,c,l));if(KS($S(i,r,n))/255>pb)return null}return S3(i,T3(i,r,n),0.00196078431372549)}async function B3(e){try{return await AS(e.getImage(),e.getMimeType())}catch{return null}}function j3(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw Error("Limit must be positive multiple of four.");let n=e.getAttribute("POSITION").getCount(),r=e.listSemantics().filter((l)=>l.startsWith("WEIGHTS_")).length,i=new Uint16Array(r*4),a=new Float32Array(r*4),s=new Float32Array(r*4),o=new Uint32Array(r*4),c=new Uint32Array(r*4);for(let l=0;l<n;l++){Of(e,l,"WEIGHTS",a),Of(e,l,"JOINTS",o);for(let u=0;u<r*4;u++)i[u]=u;i.sort((u,d)=>a[u]>a[d]?-1:1);for(let u=0;u<i.length;u++)s[u]=a[i[u]],c[u]=o[i[u]];kf(e,l,"WEIGHTS",s),kf(e,l,"JOINTS",c)}for(let l=r;l*4>t;l--){let u=e.getAttribute(`WEIGHTS_${l-1}`),d=e.getAttribute(`JOINTS_${l-1}`);if(e.setAttribute(`WEIGHTS_${l-1}`,null),e.setAttribute(`JOINTS_${l-1}`,null),u.listParents().length===1)u.dispose();if(d.listParents().length===1)d.dispose()}V3(e)}function V3(e){if(!G3(e))return;let t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter((d)=>d.startsWith("WEIGHTS_")).length,r=e.getAttribute("WEIGHTS_0"),i=r.getArray(),a=r.getComponentType(),s=r.getNormalized(),o=s?a:void 0,c=s?gt.decodeNormalizedInt(1,a):Number.EPSILON,l=new Uint32Array(n*4).fill(0),u=i.slice(0,n*4).fill(0);for(let d=0;d<t;d++){Of(e,d,"JOINTS",l),Of(e,d,"WEIGHTS",u,o);let f=NS(u,o);if(f!==0&&f!==1){if(Math.abs(1-f)>c)for(let h=0;h<u.length;h++)if(s){let b=gt.decodeNormalizedInt(u[h],a);u[h]=gt.encodeNormalizedInt(b/f,a)}else u[h]/=f;if(f=NS(u,o),s&&f!==1){for(let h=u.length-1;h>=0;h--)if(u[h]>0){let b=1-f;u[h]+=Math.sign(b)*gt.encodeNormalizedInt(Math.abs(b),a);break}}}for(let h=u.length-1;h>=0;h--)if(u[h]===0)l[h]=0;kf(e,d,"JOINTS",l),kf(e,d,"WEIGHTS",u,o)}}function Of(e,t,n,r,i){let a,s=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){a.getElement(t,s);for(let c=0;c<4;c++)if(i)r[o*4+c]=gt.encodeNormalizedInt(s[c],i);else r[o*4+c]=s[c]}return r}function kf(e,t,n,r,i){let a,s=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){for(let c=0;c<4;c++)if(i)s[c]=gt.decodeNormalizedInt(r[o*4+c],i);else s[c]=r[o*4+c];a.setElement(t,s)}}function NS(e,t){let n=0;for(let r=0;r<e.length;r++)if(t)n+=gt.decodeNormalizedInt(e[r],t);else n+=e[r];return n}function G3(e){let t=e.listSemantics().filter((i)=>i.startsWith("WEIGHTS_")).map((i)=>e.getAttribute(i)),n=t.map((i)=>i.getNormalized()),r=t.map((i)=>i.getComponentType());return new Set(n).size===1&&new Set(r).size===1}function qS(e=If){let t=Df(If,{patternTargets:e.pattern||If.pattern,...e});return Lf(Qa,async(n)=>{let r=n.getLogger(),i=n.getRoot();if(n.hasExtension("KHR_mesh_primitive_restart"))throw Error("quantize: Missing support for KHR_mesh_primitive_restart.");let a;if(t.quantizationVolume==="scene")a=OS(rz(i.listMeshes().map(kS)));for(let s of n.getRoot().listMeshes()){if(t.quantizationVolume==="mesh")a=OS(kS(s));if(a&&t.pattern.test("POSITION"))J3(n,s,a),Q3(s,1/a.scale);for(let o of s.listPrimitives()){if(Pf(o,"render")<Pf(o,"upload")/2)h3(o);PS(n,o,a,t);for(let c of o.listTargets())PS(n,c,a,t)}}if(i.listMeshes().flatMap((s)=>s.listPrimitives()).some(JS))n.createExtension(Fl).setRequired(!0);if(t.cleanup)await n.transform(Ff({propertyTypes:[Q.ACCESSOR,Q.SKIN,Q.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),gb({propertyTypes:[Q.ACCESSOR,Q.MATERIAL,Q.SKIN],keepUniqueNames:!0}));r.debug(`${Qa}: Complete.`)})}function PS(e,t,n,r){let i=t instanceof Yg,a=e.getLogger();for(let s of t.listSemantics()){if(!i&&!r.pattern.test(s))continue;if(i&&!r.patternTargets.test(s))continue;let o=t.getAttribute(s),{bits:c,ctor:l}=tz(s,o,a,r);if(!l)continue;if(c<8||c>16)throw Error(`${Qa}: Requires bits = 8–16.`);if(o.getComponentSize()<=c/8)continue;let u=o.clone();if(s==="POSITION"){let d=n.scale,f=[];t instanceof Qn?c3(f,Uf(n)):l3(f,[1/d,1/d,1/d]);for(let h=0,b=[0,0,0],m=u.getCount();h<m;h++)u.getElement(h,b),u.setElement(h,b3(b,b,f))}ez(u,l,c),t.setAttribute(s,u)}if(r.normalizeWeights&&t.getAttribute("WEIGHTS_0"))j3(t,1/0);if(t instanceof Qn&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){let s=t.getIndices();s.setArray(new Uint16Array(s.getArray()))}}function OS(e){let{min:t,max:n}=e,r=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:r}}function J3(e,t,n){let r=Uf(n);for(let i of t.listParents()){if(!(i instanceof gf))continue;let a=i.listParents().filter((f)=>f instanceof Vs),s=a.some((f)=>q3.includes(f.getTargetPath())),o=i.listChildren().length>0,c=i.getSkin();if(c){i.setSkin(Z3(c,n));continue}let l=i.getExtension("EXT_mesh_gpu_instancing");if(l){i.setExtension("EXT_mesh_gpu_instancing",Y3(e,l,n));continue}let u;if(o||s)u=e.createNode("").setMesh(t),i.addChild(u).setMesh(null),a.filter((f)=>f.getTargetPath()===X3).forEach((f)=>f.setTargetNode(u));else u=i;let d=u.getMatrix();mb(d,d,r),u.setMatrix(d)}}function Z3(e,t){e=e.clone();let n=Uf(t),r=e.getInverseBindMatrices().clone(),i=[];for(let a=0,s=r.getCount();a<s;a++)r.getElement(a,i),mb(i,i,n),r.setElement(a,i);return e.setInverseBindMatrices(r)}function Y3(e,t,n){if(!t.getAttribute("TRANSLATION")&&!t.getAttribute("ROTATION")&&!t.getAttribute("SCALE"))return t;t=t.clone();let r=t.getAttribute("TRANSLATION")?.clone(),i=t.getAttribute("ROTATION")?.clone(),a=t.getAttribute("SCALE")?.clone(),s=r||i||a,o=[0,0,0],c=[0,0,0,1],l=[1,1,1];if(!r&&n.offset)r=e.createAccessor().setType("VEC3").setArray(DS(s.getCount(),o));if(!a&&n.scale)a=e.createAccessor().setType("VEC3").setArray(DS(s.getCount(),l));let u=[0,0,0],d=[0,0,0,1],f=[1,1,1],h=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],b=Uf(n);for(let m=0,g=s.getCount();m<g;m++){if(gt.compose(r?r.getElement(m,u):o,i?i.getElement(m,d):c,a?a.getElement(m,f):l,h),mb(h,h,b),gt.decompose(h,u,d,f),r)r.setElement(m,u);if(i)i.setElement(m,d);if(a)a.setElement(m,f)}if(r)t.setAttribute("TRANSLATION",r);if(i)t.setAttribute("ROTATION",i);if(a)t.setAttribute("SCALE",a);return t}function Q3(e,t){for(let n of e.listPrimitives()){let r=n.getMaterial();if(!r)continue;let i=r.getExtension("KHR_materials_volume");if(!i||i.getThicknessFactor()<=0)continue;i=i.clone().setThicknessFactor(i.getThicknessFactor()*t),r=r.clone().setExtension("KHR_materials_volume",i),n.setMaterial(r)}}function ez(e,t,n){let r=new t(e.getArray().length),i=H3.includes(t)?1:0,a=n-i,s=t.BYTES_PER_ELEMENT*8-i,o=Math.pow(2,a)-1,c=s-a,l=2*a-s,u=[i>0?-1:0,1];for(let d=0,f=0,h=[];d<e.getCount();d++){e.getElement(d,h);for(let b=0;b<h.length;b++){let m=iz(h[b],u);m=Math.round(Math.abs(m)*o),m=m<<c|m>>l,r[f++]=m*Math.sign(h[b])}}e.setArray(r).setNormalized(!0).setSparse(!1)}function tz(e,t,n,r){let i=t.getMinNormalized([]),a=t.getMaxNormalized([]),s,o;if(e==="POSITION")s=r.quantizePosition,o=s<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")s=r.quantizeNormal,o=s<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))s=r.quantizeColor,o=s<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(i.some((c)=>c<0)||a.some((c)=>c>1))return n.warn(`${Qa}: Skipping ${e}; out of [0,1] range.`),{bits:-1};s=r.quantizeTexcoord,o=s<=8?Uint8Array:Uint16Array}else if(e.startsWith("JOINTS_")){if(s=Math.max(...t.getMax([]))<=255?8:16,o=s<=8?Uint8Array:Uint16Array,t.getComponentSize()>s/8)t.setArray(new o(t.getArray()));return{bits:-1}}else if(e.startsWith("WEIGHTS_")){if(i.some((c)=>c<0)||a.some((c)=>c>1))return n.warn(`${Qa}: Skipping ${e}; out of [0,1] range.`),{bits:-1};s=r.quantizeWeight,o=s<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(i.some((c)=>c<-1)||a.some((c)=>c>1))return n.warn(`${Qa}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};s=r.quantizeGeneric,o=i.some((c)=>c<0)?o=s<=8?Int8Array:Int16Array:o=s<=8?Uint8Array:Uint16Array}else throw Error(`${Qa}: Unexpected semantic, "${e}".`);return{bits:s,ctor:o}}function kS(e){let t=[],n=[];for(let i of e.listPrimitives()){let a=i.getAttribute("POSITION");if(a)t.push(a);for(let s of i.listTargets()){let o=s.getAttribute("POSITION");if(o)n.push(o)}}if(t.length===0)throw Error(`${Qa}: Missing "POSITION" attribute.`);let r=LS(t,3);if(n.length>0){let{min:i,max:a}=LS(n,3);fb(r.min,r.min,fb(i,MS(i,i,2),[0,0,0])),hb(r.max,r.max,hb(a,MS(a,a,2),[0,0,0]))}return r}function nz(e,t){let n=t.getComponentSize();if(e==="POSITION")return n<4;if(e==="NORMAL")return n<4;if(e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){let r=t.getComponentType(),i=t.getNormalized();return n<4&&!(i&&r===Oe.ComponentType.UNSIGNED_BYTE)&&!(i&&r===Oe.ComponentType.UNSIGNED_SHORT)}return!1}function JS(e){for(let t of e.listSemantics())if(nz(t,e.getAttribute("POSITION")))return!0;if(e.propertyType===Q.PRIMITIVE)return e.listTargets().some(JS);return!1}function LS(e,t){let n=Array(t).fill(1/0),r=Array(t).fill(-1/0),i=[],a=[];for(let s of e){s.getMinNormalized(i),s.getMaxNormalized(a);for(let o=0;o<t;o++)n[o]=Math.min(n[o],i[o]),r[o]=Math.max(r[o],a[o])}return{min:n,max:r}}function rz(e){let t=e[0];for(let n of e)fb(t.min,t.min,n.min),hb(t.max,t.max,n.max);return t}function Uf(e){return u3([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function iz(e,t){return Math.min(Math.max(e,t[0]),t[1])}function DS(e,t){let n=t.length,r=new Float32Array(e*n);for(let i=0;i<e;i++)r.set(t,i*n);return r}function ZS(e){let t=Df(az,e),n=t.encoder;if(!n)throw Error(`${Sf}: encoder dependency required — install "meshoptimizer".`);return Lf(Sf,async(r)=>{let i=r.getLogger();if(r.hasExtension("KHR_mesh_primitive_restart"))throw Error("reorder: Missing support for KHR_mesh_primitive_restart.");await n.ready;let a=sz(r);for(let s of a.indicesToAttributes.keys()){let o=s.getArray();if(!(o instanceof Uint32Array))o=new Uint32Array(o);else o=o.slice();let[c,l]=n.reorderMesh(o,a.indicesToMode.get(s)===Qn.Mode.TRIANGLES,t.target==="size"),u=Cf(r,s);u.setArray(l<=65534?new Uint16Array(o):o);for(let d of a.indicesToAttributes.get(s)){let f=Cf(r,d);db(d,s,c,f,l);for(let h of a.indicesToPrimitives.get(s)){if(h.getIndices()===s)h.swap(s,u);h.swap(d,f);for(let b of h.listTargets())b.swap(d,f)}}}if(t.cleanup)await r.transform(Ff({propertyTypes:[Q.ACCESSOR],keepAttributes:!0,keepIndices:!0}));if(!a.indicesToAttributes.size)i.warn(`${Sf}: No qualifying primitives found; may need to weld first.`);else i.debug(`${Sf}: Complete.`)})}function sz(e){let t=new Map,n=new lb,r=new lb,i=new lb;for(let a of e.getRoot().listMeshes())for(let s of a.listPrimitives()){let o=s.getIndices();if(!o)continue;t.set(o,s.getMode()),n.add(o,s);for(let c of BS(s))r.add(o,c),i.add(c,s)}return{indicesToPrimitives:n,indicesToAttributes:r,indicesToMode:t,attributesToPrimitives:i}}function cz(e,t,n,r=0.0001){let i=t.length/e.length,a=Array(i).fill(0),s=Array(i).fill(0),o=Array(i).fill(0),c=Array(i).fill(0),l=e.length-1,u=1;for(let d=1;d<l;++d){let f=e[u-1],h=e[d],b=e[d+1],m=(h-f)/(b-f),g=!1;if(h!==b&&(d!==1||h!==e[0])){if(Ul(t,u-1,c),Ul(t,d,s),Ul(t,d+1,o),n==="slerp"){let p=dz(a,c,o,m),y=zS(c,s)+zS(s,o);g=!Rf(s,p,r)||y+Number.EPSILON>=Math.PI}else if(n==="lerp")g=!Rf(s,uz(a,c,o,m),r);else if(n==="step")g=!Rf(s,c)||!Rf(s,o)}if(g){if(d!==u)e[u]=e[d],US(t,u,Ul(t,d,a));u++}}if(l>0)e[u]=e[l],US(t,u,Ul(t,l,a)),u++;return u}function Ul(e,t,n){for(let r=0,i=n.length;r<i;r++)n[r]=e[t*i+r];return n}function US(e,t,n){for(let r=0,i=n.length;r<i;r++)e[t*i+r]=n[r]}function Rf(e,t,n=0){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Math.abs(e[r]-t[r])>n)return!1;return!0}function lz(e,t,n){return e*(1-n)+t*n}function uz(e,t,n,r){for(let i=0;i<t.length;i++)e[i]=lz(t[i],n[i],r);return e}function dz(e,t,n,r){let i=t[0],a=t[1],s=t[2],o=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,b,m,g;if(h=i*c+a*l+s*u+o*d,h<0)h=-h,c=-c,l=-l,u=-u,d=-d;if(1-h>oz)f=Math.acos(h),b=Math.sin(f),m=Math.sin((1-r)*f)/b,g=Math.sin(r*f)/b;else m=1-r,g=r;return e[0]=m*i+g*c,e[1]=m*a+g*l,e[2]=m*s+g*u,e[3]=m*o+g*d,e}function zS(e,t){let n=fz(e,t);return Math.acos(2*n*n-1)}function fz(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}var a3,HK,$K,KK,WK,XK,qK,JK,lb=class{_map=new Map;get size(){return this._map.size}has(e){return this._map.has(e)}add(e,t){let n=this._map.get(e);if(!n)n=new Set,this._map.set(e,n);return n.add(t),this}get(e){return this._map.get(e)||new Set}keys(){return this._map.keys()}},ZK,Nf,wS=4294967295,x3,YK,QK,eW,tW,nW,rW,iW,es="dedup",ub,aW,sW,$S,I3,KS,C3,ac="prune",pb=0.011764705882352941,RS,k3=class{disposed={};empty(){for(let e in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(e){this.disposed[e.propertyType]=this.disposed[e.propertyType]||0,this.disposed[e.propertyType]++}},oW,cW,lW,uW,dW,Qa="quantize",H3,$3,K3,W3,X3,q3,If,Sf="reorder",az,fW,FS,oz=0.000001,hW,pW,mW,gW,bW,xW,yW,_W;var YS=ot(()=>{nc();TS();Tf();a3=Zf(sb(),1),{POINTS:HK,LINES:$K,LINE_STRIP:KK,LINE_LOOP:WK,TRIANGLES:XK,TRIANGLE_STRIP:qK,TRIANGLE_FAN:JK}=Qn.Mode;ZK=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});Nf=typeof Float32Array<"u"?Float32Array:Array;Math.PI/180;180/Math.PI;x3=g3;(function(){var e=m3();return function(t,n,r,i,a,s){var o,c;if(!n)n=3;if(!r)r=0;if(i)c=Math.min(i*n+r,t.length);else c=t.length;for(o=r;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],a(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();({FLOAT:YK}=Oe.ComponentType),{LINES:QK,LINE_STRIP:eW,LINE_LOOP:tW,TRIANGLES:nW,TRIANGLE_STRIP:rW,TRIANGLE_FAN:iW}=Qn.Mode,ub={keepUniqueNames:!1,propertyTypes:[Q.ACCESSOR,Q.MESH,Q.TEXTURE,Q.MATERIAL,Q.SKIN]};({TEXTURE_INFO:aW,ROOT:sW}=Q);$S=w3,I3=M3,KS=R3;(function(){var e=HS();return function(t,n,r,i,a,s){var o,c;if(!n)n=4;if(!r)r=0;if(i)c=Math.min(i*n+r,t.length);else c=t.length;for(o=r;o<c;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],a(e,e,s),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();C3=/color|emissive|diffuse/i;RS={propertyTypes:[Q.NODE,Q.SKIN,Q.MESH,Q.CAMERA,Q.PRIMITIVE,Q.PRIMITIVE_TARGET,Q.ANIMATION,Q.MATERIAL,Q.TEXTURE,Q.ACCESSOR,Q.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};({ROOT:oW,NODE:cW,MESH:lW,PRIMITIVE:uW,ACCESSOR:dW}=Q);H3=[Int8Array,Int16Array,Int32Array],{TRANSLATION:$3,ROTATION:K3,SCALE:W3,WEIGHTS:X3}=Vs.TargetPath,q3=[$3,K3,W3],If={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};az={target:"size",cleanup:!0};fW={level:"high",...If};(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(FS||(FS={}));hW={ready:Promise.resolve(),resample:cz,tolerance:0.0001,cleanup:!0},{POINTS:pW,LINES:mW,LINE_STRIP:gW,LINE_LOOP:bW,TRIANGLES:xW,TRIANGLE_STRIP:yW,TRIANGLE_FAN:_W}=Qn.Mode});function eR(e,t,n,r={}){if(!Array.isArray(t))return e.push({code:"EXPECTED_ARRAY",path:n,message:`${n} must be an array.`}),!1;if(!r.allowEmpty&&t.length===0)e.push({code:"EXPECTED_NONEMPTY_ARRAY",path:n,message:`${n} must not be empty.`});let i=new Set;for(let a=0;a<t.length;a++){let s=t[a];if(!Ji(s)){e.push({code:"EXPECTED_NONEMPTY_STRING",path:`${n}[${a}]`,message:`${n}[${a}] must be a trimmed non-empty string.`});continue}if(i.has(s))e.push({code:"DUPLICATE_VALUE",path:`${n}[${a}]`,message:`${n} contains duplicate value ${JSON.stringify(s)}.`});i.add(s)}return!0}function mz(e,t,n){let r=`frames[${t}]`;if(!ts(e))return n.push({code:"INVALID_FRAME",path:r,message:`${r} must be an object.`}),!1;if(!Ji(e.id))n.push({code:"INVALID_FRAME_ID",path:`${r}.id`,message:"Frame ID is required."});if(!QS(e.translation,3))n.push({code:"INVALID_FRAME_TRANSLATION",path:`${r}.translation`,message:"Frame translation must be three finite meters."});if(!QS(e.rotation,4))n.push({code:"INVALID_FRAME_ROTATION",path:`${r}.rotation`,message:"Frame rotation must be a finite quaternion."});else{let i=Math.hypot(...e.rotation);if(Math.abs(i-1)>0.000001)n.push({code:"NON_UNIT_FRAME_ROTATION",path:`${r}.rotation`,message:"Frame rotation quaternion must be normalized within 1e-6."})}return!0}function gz(e,t,n){let r=`relationships[${t}]`;if(!ts(e))return n.push({code:"INVALID_RELATIONSHIP",path:r,message:`${r} must be an object.`}),!1;for(let i of["kind","target"])if(!Ji(e[i]))n.push({code:"INVALID_RELATIONSHIP_FIELD",path:`${r}.${i}`,message:`${r}.${i} must be a trimmed non-empty string.`});if(e.targetType!=="node"&&e.targetType!=="role"&&e.targetType!=="socket")n.push({code:"INVALID_RELATIONSHIP_TARGET_TYPE",path:`${r}.targetType`,message:"Relationship targetType must be node, role, or socket."});for(let i of["sourceFrame","targetFrame"])if(e[i]!==void 0&&!Ji(e[i]))n.push({code:"INVALID_RELATIONSHIP_FRAME",path:`${r}.${i}`,message:`${r}.${i} must be a trimmed non-empty string.`});return!0}function bz(e,t,n){let r=`sockets[${t}]`;if(!ts(e))return n.push({code:"INVALID_SOCKET",path:r,message:`${r} must be an object.`}),!1;for(let i of["id","type","frame"])if(!Ji(e[i]))n.push({code:"INVALID_SOCKET_FIELD",path:`${r}.${i}`,message:`${r}.${i} must be a trimmed non-empty string.`});if(eR(n,e.compatibleTypes,`${r}.compatibleTypes`,{allowEmpty:!0}),e.allowedRotationsDegrees!==void 0){if(!Array.isArray(e.allowedRotationsDegrees)||e.allowedRotationsDegrees.some((i)=>typeof i!=="number"||!Number.isFinite(i)))n.push({code:"INVALID_ALLOWED_ROTATIONS",path:`${r}.allowedRotationsDegrees`,message:"Allowed rotations must be finite degree values."})}return!0}function xz(e){let t=[];if(!ts(e))return{valid:!1,issues:[{code:"EXPECTED_OBJECT",path:"",message:"SemanticMetadataV1 must be an object."}]};if(e.schemaVersion!==1)t.push({code:"UNSUPPORTED_SCHEMA_VERSION",path:"schemaVersion",message:"schemaVersion must be 1."});eR(t,e.roles,"roles");let n=Array.isArray(e.frames)?e.frames:[];if(!Array.isArray(e.frames))t.push({code:"EXPECTED_ARRAY",path:"frames",message:"frames must be an array."});let r=new Set;n.forEach((o,c)=>{if(mz(o,c,t),ts(o)&&Ji(o.id)){if(r.has(o.id))t.push({code:"DUPLICATE_FRAME_ID",path:`frames[${c}].id`,message:`Duplicate frame ID ${JSON.stringify(o.id)}.`});r.add(o.id)}});let i=Array.isArray(e.relationships)?e.relationships:[];if(!Array.isArray(e.relationships))t.push({code:"EXPECTED_ARRAY",path:"relationships",message:"relationships must be an array."});i.forEach((o,c)=>{if(gz(o,c,t),ts(o))for(let l of["sourceFrame","targetFrame"]){let u=o[l];if(Ji(u)&&!r.has(u))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`relationships[${c}].${l}`,message:`Unknown frame ${JSON.stringify(u)}.`})}});let a=Array.isArray(e.sockets)?e.sockets:[];if(!Array.isArray(e.sockets))t.push({code:"EXPECTED_ARRAY",path:"sockets",message:"sockets must be an array."});let s=new Set;if(a.forEach((o,c)=>{if(bz(o,c,t),ts(o)&&Ji(o.id)){if(s.has(o.id))t.push({code:"DUPLICATE_SOCKET_ID",path:`sockets[${c}].id`,message:`Duplicate socket ID ${JSON.stringify(o.id)}.`});s.add(o.id)}if(ts(o)&&Ji(o.frame)&&!r.has(o.frame))t.push({code:"UNKNOWN_FRAME_REFERENCE",path:`sockets[${c}].frame`,message:`Unknown frame ${JSON.stringify(o.frame)}.`})}),t.length>0)return{valid:!1,issues:t};return{valid:!0,value:yz(e),issues:t}}function yz(e){return{schemaVersion:1,roles:[...e.roles],relationships:e.relationships.map((t)=>({kind:t.kind,target:t.target,targetType:t.targetType,...t.sourceFrame?{sourceFrame:t.sourceFrame}:{},...t.targetFrame?{targetFrame:t.targetFrame}:{}})),frames:e.frames.map((t)=>({id:t.id,translation:hz(t.translation),rotation:pz(t.rotation)})),sockets:e.sockets.map((t)=>({id:t.id,type:t.type,frame:t.frame,compatibleTypes:[...t.compatibleTypes],...t.allowedRotationsDegrees?{allowedRotationsDegrees:[...t.allowedRotationsDegrees]}:{}}))}}function zf(e){let t=e.kilnSemantic;if(t===void 0)return;let n=xz(t);return n.valid?n.value:void 0}var ns,ts=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Ji=(e)=>typeof e==="string"&&e.trim().length>0&&e===e.trim(),QS=(e,t)=>Array.isArray(e)&&e.length===t&&e.every((n)=>typeof n==="number"&&Number.isFinite(n)),hz=(e)=>[e[0],e[1],e[2]],pz=(e)=>[e[0],e[1],e[2],e[3]];var zl=ot(()=>{ns=Object.freeze({vehicleFrame:"vehicle.frame",vehicleForward:"vehicle.front.+x",socket:"socket",chassis:"chassis",chassisMain:"chassis.main",axle:"axle",seat:"seat",contact:"contact",steering:"steering",propulsion:"propulsion",wheelAssembly:"wheel.assembly",wheelPivot:"wheel.pivot",wheelLoadBearing:"wheel.load-bearing",wheelTire:"wheel.tire",wheelRim:"wheel.rim",wheelHub:"wheel.hub",wheelContact:"wheel.contact",steeringPivot:"steering.pivot",roof:"roof",architectureRoof:"architecture.roof",collider:"collider",colliderBox:"collider.box",colliderCapsule:"collider.capsule",colliderHull:"collider.hull",anchor:"anchor",kitModule:"kit.module",kitPort:"kit.port",lodImpostor:"lod.impostor"})});function nR(){return new pM().registerExtensions([...QM,bb])}var fn="MSFT_lod",tR,bb;var Bf=ot(()=>{nc();Tf();tR=class tR extends rt{static EXTENSION_NAME=fn;init(){this.extensionName=fn,this.propertyType="Lod",this.parentTypes=[Q.NODE,Q.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{levels:new xn})}addLevel(e){return this.addRef("levels",e)}listLevels(){return this.listRefs("levels")}removeLevel(e){return this.removeRef("levels",e)}};bb=class bb extends _t{extensionName=fn;static EXTENSION_NAME=fn;createLod(e=""){return new tR(this.document.getGraph(),e)}read(e){let t=e.jsonDoc.json;return this.readLevels(t.nodes,e.nodes),this.readLevels(t.materials,e.materials),this}readLevels(e,t){(e??[]).forEach((n,r)=>{let i=n.extensions?.[fn]?.ids,a=t[r];if(!a||!Array.isArray(i))return;let s=this.createLod();for(let o of i){let c=typeof o==="number"?t[o]:void 0;if(c&&c!==a)s.addLevel(c)}a.setExtension(fn,s)})}write(e){let t=e.jsonDoc.json,n=this.document.getRoot();for(let r of n.listNodes()){let i=e.nodeIndexMap.get(r),a=r.getExtension(fn)?.listLevels().filter((o)=>o.propertyType===Q.NODE).map((o)=>e.nodeIndexMap.get(o)).filter((o)=>o!==void 0),s=i===void 0?void 0:t.nodes?.[i];if(s&&a?.length)s.extensions={...s.extensions,[fn]:{ids:a}}}for(let r of n.listMaterials()){let i=e.materialIndexMap.get(r),a=r.getExtension(fn)?.listLevels().filter((o)=>o.propertyType===Q.MATERIAL).map((o)=>e.materialIndexMap.get(o)).filter((o)=>o!==void 0),s=i===void 0?void 0:t.materials?.[i];if(s&&a?.length)s.extensions={...s.extensions,[fn]:{ids:a}}}return this}}});var _z;var xb=ot(()=>{_z=Object.freeze([1,1,1])});var OW,kW;var rR=ot(()=>{xb();OW=Object.freeze({units:"m",forward:"+X",up:"+Y",right:"+Z",groundY:0}),kW=Math.PI/180});var iR=()=>{};var aR=()=>{};var sR=ot(()=>{rR();xb();iR();aR();zl()});var vz;var oR=ot(()=>{vz=Object.freeze({parametricSamples:262144,subdivisionTriangles:1e6,subdivisionAttributeBytes:134217728,subdivisionIterations:10,repeatedMeshes:1e4,curveRepeatVertices:262144,simplifyTriangles:1e6,primitiveSegments:4096,primitiveGridVertices:262144,unwrapVertices:65536,unwrapTriangles:1e6,unwrapAttributeBytes:134217728,unwrapResolution:4096,skinBones:1024,skinVertices:262144,skinAttributeBytes:134217728,colliderHullVertices:65536,surfaceBakeVertices:262144,surfaceBakeTriangles:1e6,surfaceBakeRays:8388608,surfaceBakeRayDirections:256})});var yb="kilnRepeatInstances";var _b=ot(()=>{sR();Pc();oR()});function Bl(e){return e.getExtension("KHR_node_visibility")?.getVisible?.()===!1}var YW;var jl=ot(()=>{YW=[{grade:"A",max:1,range:"0-1"},{grade:"B",max:3,range:"2-3"},{grade:"C",max:6,range:"4-6"},{grade:"D",max:12,range:"7-12"},{grade:"F",max:Number.POSITIVE_INFINITY,range:"13+"}]});var cR=ot(()=>{jl()});function uR(e){let t=new Map,n=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!n)return t;let r=(i,a)=>{let s=new Map;for(let o of i){let c=o.getName(),l=s.get(c)??0;s.set(c,l+1);let u=`${a}${lR(c,l)}`;t.set(o,u),r(o.listChildren(),u)}};return r(n.listChildren(),lR(n.getName()||"Scene",0)),t}var lR=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var dR=ot(()=>{Bf();zl();_b();jl();cR()});function Tz(e,t,n){let r=0;for(let i=0;i<t;i++)if(e[i].getName()===n)r++;return r}function wz(e){let t=e.getExtras()[vb];return Array.isArray(t)&&t.every((n)=>typeof n==="number")?[...t]:void 0}function Mz(e){let t=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];if(!t)return[];let n=[],r=(i,a)=>{i.forEach((s,o)=>{let c=(d)=>`${a}${fR(d,Tz(i,o,d))}`,l=c(s.getName()),u=(s.getExtension(fn)?.listLevels()??[]).filter((d)=>d.propertyType===Q.NODE);if(u.length>0)n.push({levels:[s,...u],paths:[l,...u.map((d)=>c(d.getName()))]});r(s.listChildren(),l)})};return r(t.listChildren(),fR(t.getName()||"Scene",0)),n}function hR(e,t){let n=Mz(e),r=new Set;for(let{levels:s}of n)for(let o of s.slice(t+1))o.traverse((c)=>{r.add(c)});for(let s of e.getRoot().listAnimations())for(let o of s.listChannels()){let c=o.getTargetNode();if(c&&r.has(c))throw Error(`maxLod ${t} would drop ${c.getName()||"a node"}, which animation ${JSON.stringify(s.getName())} targets; keep that level.`)}let i=n.map(({levels:s,paths:o})=>{let[c,...l]=s,u=l.slice(t);if(u.length>0){let d=c.getExtension(fn);for(let b of u)d.removeLevel(b);let f={...c.getExtras()},h=wz(c);if(t===0)c.setExtension(fn,null),d.dispose(),delete f[vb];else if(h)f[vb]=h.slice(0,t+1);c.setExtras(f);for(let b of u){let m=[];b.traverse((g)=>{m.push(g)});for(let g of m.reverse())g.dispose()}}return{path:o[0],levels:s.length-u.length,dropped:u.map((d)=>d.getName())}}),a=e.getRoot();if(!a.listNodes().some((s)=>s.getExtension(fn)))a.listExtensionsUsed().find((s)=>s.extensionName===fn)?.dispose();return i}var vb="MSFT_screencoverage",fR=(e,t)=>`/${encodeURIComponent(e)}[${t}]`;var pR=ot(()=>{nc();zl();Bf();jl()});var vX,Sz;var mR=ot(()=>{vX=Object.freeze({profile:"web.portable.v1",tier:"standard"}),Sz=Object.freeze({"web.portable.v1":Object.freeze({hero:Object.freeze({maxImageDimension:4096,maxImageCount:8,maxDecodedBytesRgba8:134217728,maxBlendedSurfaceAreaRatio:0.35}),standard:Object.freeze({maxImageDimension:2048,maxImageCount:4,maxDecodedBytesRgba8:33554432,maxBlendedSurfaceAreaRatio:0.15}),background:Object.freeze({maxImageDimension:1024,maxImageCount:2,maxDecodedBytesRgba8:8388608,maxBlendedSurfaceAreaRatio:0.05})}),"mobile.portable.v1":Object.freeze({hero:Object.freeze({maxImageDimension:2048,maxImageCount:6,maxDecodedBytesRgba8:50331648,maxBlendedSurfaceAreaRatio:0.2}),standard:Object.freeze({maxImageDimension:1024,maxImageCount:3,maxDecodedBytesRgba8:16777216,maxBlendedSurfaceAreaRatio:0.1}),background:Object.freeze({maxImageDimension:512,maxImageCount:1,maxDecodedBytesRgba8:4194304,maxBlendedSurfaceAreaRatio:0.03})})})});var jf="kilnBudgetV1";var gR=ot(()=>{Pc();mR()});var bR=()=>{};function Dt(e){throw TypeError(`atlas provenance: ${e}`)}function Xr(e,t){if(!e||typeof e!=="object"||Array.isArray(e))Dt("plain metadata object required.");let n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype)Dt("plain metadata prototype required.");let r=Object.getOwnPropertyDescriptor(e,t);if(!r)return;if(!r.enumerable||!("value"in r))Dt("metadata accessors/hidden fields are unsupported.");return r.value}function Vl(e,t){for(let n of Reflect.ownKeys(e))if(typeof n!=="string"||!t.includes(n))Dt("unsupported metadata field.");for(let n of t)Xr(e,n);return e}function Iz(e){Rn(e);let t=Vl(e,["spec","manifest"]),n=bs(t.spec);return{spec:n,manifest:Bc(t.manifest,n)}}function Cz(e){let t=Vl(e,["version","atlases"]);if(t.version!==sc)Dt("unsupported version.");let n=t.atlases;if(!Array.isArray(n)||Object.getPrototypeOf(n)!==Array.prototype)Dt("dense atlas array required.");let r=Object.getOwnPropertyDescriptor(n,"length").value;if(r>Gs.atlases||Reflect.ownKeys(n).length!==r+1)Dt("atlas count/density budget exceeded.");let i=Rz,a=[];for(let s=0;s<r;s++){let o=Object.getOwnPropertyDescriptor(n,String(s));if(!o?.enumerable||!("value"in o))Dt("atlas array accessors are unsupported.");let c=Rn(o.value);if(i+=new TextEncoder().encode(c).length+(s>0?1:0),i>Gs.bytes)Dt("aggregate metadata byte budget exceeded.");a.push(Vl(o.value,["id","spec","manifest"]))}return a}function Nz(e){let t=Cz(e),n=new Set,r=[];for(let i of t){let a=Iz({spec:i.spec,manifest:i.manifest});if(i.id!==a.manifest.manifestHash||n.has(i.id))Dt("duplicate or mismatched atlas identity.");n.add(i.id),r.push({id:i.id,...a})}return{version:sc,atlases:r}}function xR(e,t){let n=e.atlases.find((r)=>r.id===t);if(!n)Dt("unknown atlas reference.");return n}function Pz(e,t,n,r,i){if(!["top-left","bottom-left"].includes(n)||!["content-boundary","texel-center"].includes(r))Dt("explicit binding origin/mode required.");if(i!==void 0&&i!=="u-only")Dt("unsupported binding axes.");let a=i==="u-only",s=e.manifest.regions.find((h)=>h.name===t);if(!s)Dt("unknown named region.");let{x:o,y:c,width:l,height:u}=s.content,d=r==="texel-center",f=n==="bottom-left";if(a&&(n!=="top-left"||c!==0||u!==e.manifest.height))Dt("u-only binding requires a top-left origin over a full-height region.");return{manifestHash:e.manifest.manifestHash,specHash:e.manifest.specHash,layoutHash:e.manifest.layoutHash,region:s.name,content:structuredClone(s.content),allocation:structuredClone(s.allocation),inputOrigin:n,mode:r,...a?{axes:"u-only"}:{},scale:[(l-(d?1:0))/e.manifest.width,a?1:(f?-1:1)*(u-(d?1:0))/e.manifest.height],offset:[(o+(d?0.5:0))/e.manifest.width,a?0:(c+(f?u-(d?0.5:0):d?0.5:0))/e.manifest.height]}}function Oz(e,t){Rn(e);let n=Vl(e,["version","atlasId","region","inputOrigin","mode","axes"]);if(n.version!==sc)Dt("unsupported binding version.");return Pz(xR(t,n.atlasId),n.region,n.inputOrigin,n.mode,n.axes)}function kz(e){let t=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0];return t?Xr(t.getExtras(),"kilnAtlasProvenance"):void 0}function yR(e){let t=kz(e);return t===void 0?void 0:Nz(t)}function _R(e){let t=[];for(let n of e.getRoot().listMaterials())for(let[r,i]of[[n.getBaseColorTexture(),n.getBaseColorTextureInfo()],[n.getNormalTexture(),n.getNormalTextureInfo()],[n.getMetallicRoughnessTexture(),n.getMetallicRoughnessTextureInfo()],[n.getEmissiveTexture(),n.getEmissiveTextureInfo()],[n.getOcclusionTexture(),n.getOcclusionTextureInfo()]])if(r&&i&&Xr(i.getExtras(),"kilnAtlasReference")!==void 0){if(t.length>=Gs.bindings)Dt("document binding budget exceeded.");t.push({texture:r,info:i})}return t}async function vR(e){let t=e.getImage();if(!t||t.byteLength>Gs.encodedBytes)Dt("encoded image missing or over budget.");let n=await crypto.subtle.digest("SHA-256",t);return`sha256:${[...new Uint8Array(n)].map((r)=>r.toString(16).padStart(2,"0")).join("")}`}function ER(e){let t={minFilter:e.getMinFilter(),magFilter:e.getMagFilter(),wrapS:e.getWrapS(),wrapT:e.getWrapT()};if(![null,9728,9729,9984,9985,9986,9987].includes(t.minFilter)||![null,9728,9729].includes(t.magFilter)||![33071,33648,10497].includes(t.wrapS)||![33071,33648,10497].includes(t.wrapT))Dt("unsupported effective sampler.");return t}function AR(e,t){Rn(e);let n=Vl(e,["version","id","effectiveSampler","finalMime","finalImageSha256"]);if(n.version!==sc)Dt("unsupported texture reference version.");return xR(t,n.id),n}function TR(e){let t=new Set,n=0;for(let{texture:r}of e){if(t.has(r))continue;t.add(r);let i=r.getImage();if(!i||i.byteLength>Gs.encodedBytes)Dt("encoded image missing or over budget.");if(n+=i.byteLength,n>Gs.aggregateEncodedBytes)Dt("aggregate encoded image hash budget exceeded.")}}async function wR(e){let t=yR(e),n=_R(e);if(!n.length)return;if(!t)Dt("atlas table missing.");TR(n);let r=new Map;for(let{texture:i,info:a}of n){let s=AR(Xr(a.getExtras(),"kilnAtlasReference"),t),o=r.get(i);if(!o)o=await vR(i),r.set(i,o);a.setExtras({...a.getExtras(),kilnAtlasReference:{version:sc,id:s.id,effectiveSampler:ER(a),finalMime:i.getMimeType(),finalImageSha256:o}})}}async function MR(e){let t=yR(e),n=_R(e);if(n.length&&!t)Dt("atlas table missing.");if(!t){for(let a of e.getRoot().listMeshes())for(let s of a.listPrimitives())if(Xr(s.getExtras(),"kilnAtlasBinding")!==void 0)Dt("atlas table missing.");return}TR(n);let r=new Map;for(let{texture:a,info:s}of n){let o=AR(Xr(s.getExtras(),"kilnAtlasReference"),t),c=r.get(a);if(!c)c=await vR(a),r.set(a,c);if(o.finalImageSha256!==c||o.finalMime!==a.getMimeType()||Rn(o.effectiveSampler)!==Rn(ER(s)))Dt("final image or effective sampler identity mismatch.")}let i=0;for(let a of e.getRoot().listMeshes())for(let s of a.listPrimitives()){let o=Xr(s.getExtras(),"kilnAtlasBinding");if(o!==void 0){if(++i>Gs.bindings)Dt("primitive budget exceeded.");Oz(o,t);let c=s.getMaterial(),l=Xr(o,"atlasId");if(!(c?[c.getBaseColorTextureInfo(),c.getNormalTextureInfo(),c.getMetallicRoughnessTextureInfo(),c.getEmissiveTextureInfo(),c.getOcclusionTextureInfo()]:[]).some((d)=>d&&Xr(d.getExtras(),"kilnAtlasReference")!==void 0&&Xr(Xr(d.getExtras(),"kilnAtlasReference"),"id")===l))Dt("named binding has no matching material atlas reference.")}}}var sc="kiln.atlas-provenance.v1",Rz,Gs;var SR=ot(()=>{bR();Wu();Rz=new TextEncoder().encode(JSON.stringify({version:sc,atlases:[]})).length,Gs=Object.freeze({atlases:128,bytes:4194304,bindings:1024,entryBytes:262144,encodedBytes:16777216,aggregateEncodedBytes:67108864,bakeDecodedBytes:67108864})});var NR={};Xb(NR,{deliverRuntimeThreeGlb:()=>$z});function Fz(e,t){let n=(r)=>{if(!r)return-1;if(!t.has(r))t.set(r,t.size);return t.get(r)};return e.listPrimitives().map((r)=>`${r.getMode()}:${n(r.getMaterial())}:${n(r.getIndices())}:${r.listSemantics().sort().map((i)=>`${i}=${n(r.getAttribute(i))}`).join(",")}:${r.listTargets().length}`).join("|")}function Uz(e){let t=[],n=new Map,r=e.getRoot().listNodes().filter((a)=>a.getExtras()[yb]!==void 0),i;for(let a of r){let s=new Map;for(let l of a.listChildren()){let u=l.getMesh();if(!u||l.listChildren().length||l.getSkin()||l.listExtensions().length||Bl(l)||Gl(l).length||Object.keys(l.getExtras()).length||l.getWeights().length)continue;let d=Fz(u,n);s.set(d,[...s.get(d)??[],l])}let o=0;for(let l of s.values()){if(l.length<2)continue;let u=l[0].getMesh();i??=e.createExtension(Af).setRequired(!0);let d=e.getRoot().listBuffers()[0],f=(v,x)=>e.createAccessor().setType(v).setArray(new Float32Array(x)).setBuffer(d??null),h=[],b=[],m=[];for(let v of l)h.push(...v.getTranslation()),b.push(...v.getRotation()),m.push(...v.getScale());let g=i.createInstancedMesh().setAttribute("TRANSLATION",f("VEC3",h)).setAttribute("ROTATION",f("VEC4",b)).setAttribute("SCALE",f("VEC3",m)),p=`${a.getName()||"Node"}_Instances${o?`_${o}`:""}`;o++;let y=e.createNode(p).setMesh(u).setExtension("EXT_mesh_gpu_instancing",g);a.addChild(y),t.push({node:y,mesh:u.getName(),count:l.length,instances:l.map((v)=>v.getName())});for(let v of l){let x=v.getMesh();if(v.dispose(),x&&x!==u&&!x.listParents().some((_)=>_.propertyType===Q.NODE))x.dispose()}}let c={...a.getExtras()};delete c[yb],a.setExtras(c)}return t}function zz(e){let t=[];for(let n of e.getRoot().listNodes()){let r=n.getMesh();if(!r||!CR(n))continue;let i=e.createNode(`${n.getName()}_Proxy`).setMesh(r);n.setMesh(null).addChild(i),t.push({collider:n,proxy:i})}return t}async function Bz(e,t,n){let r=e.getRoot().listTextures().filter((o)=>o.getMimeType()!=="image/ktx2"&&o.getImage());if(!t)return{status:"skipped",textures:r.length,reason:"No KTX2 encoder was supplied; textures stay PNG or JPEG."};let i=new Map,a=(o,c)=>{if(o)i.set(o,(i.get(o)??new Set).add(c))};for(let o of e.getRoot().listMaterials())a(o.getBaseColorTexture(),"baseColor"),a(o.getEmissiveTexture(),"emissive"),a(o.getNormalTexture(),"normal"),a(o.getMetallicRoughnessTexture(),"metallicRoughness"),a(o.getOcclusionTexture(),"occlusion");let s=["baseColor","emissive","normal","metallicRoughness","occlusion"];for(let o of r){let c=i.get(o)??new Set,l=c.has("baseColor")||c.has("emissive"),u=o.listParents().some((m)=>m.propertyType!==Q.ROOT&&!jz(m)),d=[...c].some((m)=>m!=="baseColor"&&m!=="emissive")||u;if(l&&d)throw Error(`Texture ${JSON.stringify(o.getName())} is used by both sRGB and linear material slots; one KTX2 encoding cannot serve both. Use separate images.`);let f=o.getImage(),h=await t({image:f,mimeType:o.getMimeType(),name:o.getName(),colorSpace:l?"srgb":"linear",slot:s.find((m)=>c.has(m))??"other"});if(!(h instanceof Uint8Array)||!Gg(h))throw Error("ktx2Encoder must return KTX2 bytes starting with the KTX2 identifier");n.set(o,`sha256:${await ec(f)}`),o.setImage(h).setMimeType("image/ktx2");let b=o.getURI();if(b)o.setURI(b.replace(/\.(png|jpe?g)$/i,".ktx2"))}if(r.length){e.createExtension(ab).setRequired(!0);await Promise.resolve().then(() => SR());await wR(e),await MR(e)}return{status:"encoded",textures:r.length,...t.identity?{encoder:structuredClone(t.identity)}:{}}}function jz(e){return e.propertyType===Q.MATERIAL}function IR(e,t){let n=new Ze().fromArray(e).invert().multiply(new Ze().fromArray(t)),r=new V,i=new ln,a=new V;return n.decompose(r,i,a),{scale:a.x,offset:[r.x,r.y,r.z]}}function Vz(e){let t=(n,r)=>{if(r.getComponentSize()>=4)return!1;if(n==="POSITION"||n==="NORMAL"||n==="TANGENT")return!0;if(!n.startsWith("TEXCOORD_"))return!1;let i=r.getComponentType();return!(r.getNormalized()&&(i===Oe.ComponentType.UNSIGNED_BYTE||i===Oe.ComponentType.UNSIGNED_SHORT))};return e.getRoot().listMeshes().flatMap((n)=>n.listPrimitives()).flatMap((n)=>[n,...n.listTargets()]).some((n)=>n.listSemantics().some((r)=>t(r,n.getAttribute(r))))}function Gz(e,t){let n=2**(t-1)-1,r=new Map;for(let c of e.getRoot().listNodes())for(let l of c.getExtension(fn)?.listLevels()??[])if(l.propertyType===Q.NODE)r.set(l,c);let i=(c)=>{let l=new Ze().fromArray(c.getWorldMatrix()),u=c;while(u.getParentNode())u=u.getParentNode();let d=r.get(u)?.getParentNode();return d?new Ze().fromArray(d.getWorldMatrix()).multiply(l):l},a=(c)=>{let l=[1/0,1/0,1/0],u=[-1/0,-1/0,-1/0],d=(f,h)=>{for(let b=0;b<3;b++){let m=f[b],g=h?[m,m*2,0]:[m];l[b]=Math.min(l[b],...g),u[b]=Math.max(u[b],...g)}};for(let f of c.listPrimitives()){let h=f.getAttribute("POSITION");if(h)d(h.getMin([]),!1),d(h.getMax([]),!1);for(let b of f.listTargets()){let m=b.getAttribute("POSITION");if(m)d(m.getMin([]),!0),d(m.getMax([]),!0)}}return Math.max(...[0,1,2].map((f)=>(u[f]-l[f])/2))},s=(c)=>{let l=c.getExtension("EXT_mesh_gpu_instancing")?.getAttribute("SCALE");if(!l)return 1;let u=0;for(let d=0;d<l.getCount();d++)u=Math.max(u,...l.getElement(d,[]).map(Math.abs));return u},o=[];for(let c of e.getRoot().listNodes()){let l=c.getMesh();if(!l?.listPrimitives().some((d)=>d.getAttribute("POSITION")))continue;let u=c.getSkin()?1:i(c).getMaxScaleOnAxis()*s(c);o.push({node:c,mesh:l.getName(),step:a(l)*u/n})}return o}async function Hz(e,t){let n=hR(e,t),r=[];if(n.some((i)=>i.dropped.length>0)){await e.transform(Ff({propertyTypes:[Q.MESH,Q.PRIMITIVE,Q.PRIMITIVE_TARGET,Q.ACCESSOR,Q.MATERIAL,Q.TEXTURE],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepExtras:!0,keepSolidTextures:!0}));let i=e.getRoot().getDefaultScene()??e.getRoot().listScenes()[0],a={...i?.getExtras()??{}},s=a[jf];if(i&&s?.triangles){let o={...s.triangles};for(let c of Object.keys(o))if(Number(c.slice(3))>t)r.push(c),delete o[c];if(Object.keys(o).length>0)a[jf]={...s,triangles:o};else delete a[jf];i.setExtras(a)}}return{maxLod:t,chains:n,budgetTiersOmitted:r}}async function $z(e,t,n={},r={}){let i=n.compression??"meshopt";if(i!=="meshopt"&&i!=="none")throw Error("Runtime three compression must be meshopt or none");let{maxLod:a}=n;if(a!==void 0&&!(Number.isSafeInteger(a)&&a>=0))throw Error("Runtime three maxLod must be a non-negative integer");let s=n.positionBits??vi.position;if(s!=="float"&&!(Number.isSafeInteger(s)&&s>=8&&s<=16))throw Error("Runtime three positionBits must be an integer from 8 to 16, or float");let o=nR().registerDependencies({"meshopt.encoder":t}),c=await o.readBinary(e);c.setLogger(new js(js.Verbosity.SILENT));let l=a===void 0?void 0:await Hz(c,a);await c.transform(gb({propertyTypes:[Q.ACCESSOR],keepUniqueNames:!0}));let u=Uz(c),d=zz(c),f=new Map;for(let R of c.getRoot().listNodes())if(R.getMesh())f.set(R,[...R.getMatrix()]);let h=s==="float"?[]:Gz(c,s),b=s==="float"?Dz:Lz;if(await c.transform(ZS({encoder:t,target:"size"}),qS({pattern:b,patternTargets:b,quantizationVolume:"mesh",quantizePosition:s==="float"?vi.position:s,quantizeNormal:vi.normal,quantizeTexcoord:vi.texcoord,quantizeColor:vi.color,quantizeWeight:vi.weight})),s==="float"&&Vz(c))c.createExtension(Fl).setRequired(!0);if(i==="meshopt")c.createExtension(Dl).setRequired(!0).setEncoderOptions({method:Dl.EncoderMethod.QUANTIZE});let m=new Map,g=await Bz(c,n.ktx2Encoder,m);for(let R of c.getRoot().listNodes()){if(!R.getMesh()||f.has(R)||R.getName())continue;let C=R.getParentNode();R.setName(`${C?.getName()||"Node"}_Mesh`)}let p=uR(c),y=(R)=>p.get(R)??`#${encodeURIComponent(R.getName())}`,v=new Set(d.map((R)=>R.proxy)),x=[];for(let R of c.getRoot().listNodes()){let k=R.getMesh();if(!k||R.getExtension("EXT_mesh_gpu_instancing"))continue;let C=p.get(R);if(C===void 0)continue;let U=f.get(R),D=U===void 0,P=D||v.has(R),K=D?new Ze().identity().toArray():U,z=[...R.getMatrix()],{scale:W,offset:q}=IR(K,z);if(!D&&Math.abs(W-1)<0.000000000001&&q.every((he)=>he===0))continue;let le=R.getParentNode();x.push({node:C,mesh:k.getName(),meshMovedToChild:P,...P&&le?{authoredNode:y(le)}:{},dequantization:{scale:W,offset:q},localScale:[...R.getScale()]})}for(let R of c.getRoot().listNodes()){let k=R.getMesh();if(!k||p.has(R)||!f.has(R))continue;let{scale:C,offset:U}=IR(f.get(R),[...R.getMatrix()]);x.push({node:`#lod/${encodeURIComponent(R.getName())}`,mesh:k.getName(),meshMovedToChild:!1,dequantization:{scale:C,offset:U},localScale:[...R.getScale()]})}let _=new Map;for(let R of c.getRoot().listMeshes())for(let k of R.listPrimitives())for(let C of k.listSemantics())if(C.startsWith("_"))_.set(C,(_.get(C)??new Set).add(R));let E=c.getRoot().listNodes(),w=await o.writeBinary(c),A=(await o.binaryToJSON(w)).json,T=new Map;c.getRoot().listTextures().forEach((R,k)=>{let C=m.get(R);if(C)T.set(k,C)});let N=r.gltfBasename?await o.writeJSON(c,{format:iM.GLTF,basename:r.gltfBasename}):void 0,M={target:"three",extensionsUsed:[...A.extensionsUsed??[]].sort(),extensionsRequired:[...A.extensionsRequired??[]].sort(),compression:i==="meshopt"?{extension:"EXT_meshopt_compression",method:"quantize"}:{extension:"none"},quantization:{extension:"KHR_mesh_quantization",volume:"mesh",bits:{position:s==="float"?"float32":s,normal:vi.normal,texcoord:vi.texcoord,color:vi.color,weight:vi.weight},customAttributes:"float32",positionSteps:h.map(({node:R,mesh:k,step:C})=>({node:p.get(R)??`#lod/${encodeURIComponent(R.getName())}`,mesh:k,step:C})),maxPositionStep:Math.max(0,...h.map(({step:R})=>R))},nodeScale:x,colliderProxies:d.map(({collider:R,proxy:k})=>({collider:y(R),proxy:y(k)})),customAttributes:[..._].sort(([R],[k])=>RR(R)-RR(k)||(R<k?-1:R>k?1:0)).map(([R,k])=>({name:R,meshes:k.size,componentType:"FLOAT",normalized:!1})),instancing:u.map(({node:R,...k})=>({node:y(R),...k})),ktx2:g,...l?{lod:l}:{},preserved:{lodChains:E.filter((R)=>R.getExtension(fn)).length,hiddenNodes:E.filter((R)=>Bl(R)).length,colliders:E.filter(CR).length,anchors:E.filter((R)=>Gl(R).some((k)=>k.startsWith(`${ns.anchor}.`))).length,ports:E.filter((R)=>Gl(R).some((k)=>k.startsWith(`${ns.kitPort}.`))).length,kitModules:E.filter((R)=>Gl(R).includes(ns.kitModule)).length}};return{glb:w,delivery:M,imageSources:T,...N?{gltf:{json:N.json,resources:N.resources}}:{}}}var vi,Lz,Dz,RR=(e)=>e==="_EDGE"?0:e==="_CAVITY"?1:2,Gl=(e)=>zf(e.getExtras())?.roles??[],CR=(e)=>Gl(e).some((t)=>t.startsWith(`${ns.collider}.`));var PR=ot(()=>{nc();Tf();YS();Hr();zl();Bf();dR();_b();jl();cf();pR();gR();vi=Object.freeze({volume:"mesh",position:14,normal:10,texcoord:12,color:8,weight:8}),Lz=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/,Dz=/^(NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/});var Kz;var OR=ot(()=>{Kz=function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:Nf8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkaraHcd4faAcdVaoaocdSE86bbaHclfgHal6mbkkabaefhgabcefhoalcd4g8McbaDEhkadcefh8Narc;abfceVhecbhmdndninaiam9nmearc;qofcbcjdz:xjjjb8Aagao9Rak6mdadamal2gwfhxcbhHa8Nawfhzaocbakz:xjjjbg8Fakfh3aqaiam9Ramaqfai6Egscsfgocl4cifcd4hOaoc9WGg8JThPindndndndndndndndndndnaDTmbaraHcd4fRbbgQciGPlbedlbkasTmdaxaHfhoarc;abfaHfRbbhQarc;qofhwashCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaCcufgCmbxikkasTmiaHcitcwGh8Aarc;abfaHceVfRbbcwtarc;abfaHc9:GgofRbbVhQaxaofhoarc;qofhwashCinawao8VbbgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbawcefhwaoalfhoaYhQaCcufgCmbxikkaeaHc98Gg8Afhoaza8AfhYarc;abfa8AfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbkasTmdaQcl4hKaHcitcKGhEaxa8Afh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aK93aE486bbaYalfhYa8Aalfh8AaQhCaLcefgLas9hmbkkaDmbcbhoxlka8JTmbcbhodninarc;qofaofgwcwf8Pibaw8Pib:e9qTmeaoczfgoa8J9pmdxbkkdnavmbcehoxikcbh8AaOhLaOhKinarc;qofa8Afgocwf8Pibhyao8Pibh8PcdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgoaYaoaY6Egoczaocz6EaKfhKaocucbaya8P:e9cb9sEgwaoaw6EaLfhLa8Aczfg8Aa8J9pmdxbkka8FaHcd4fgoaoRbbcdaHcetcoGtV86bbxikdnaLas6mbaKas6mba8FaHcd4fgoaoRbbciaHcetcoGtV86bbaga39Ras6mra3arc;qofasz:wjjjbasfh3xikaLaK9phoka8FaHcd4fgwawRbbaoaHcetcoGtV86bbkaga39RaO6mla3cbaOz:xjjjbgaaOfhKdndna8JmbaPhoxekdnagaK9RcK9pmbaPhoxekaocdtc:q:G:cjbfcj:G:cjbaDEg3ydxghcetc;:FFFeGhAcuhEcuahtcu7cFeGh8Ecbh8Karc;qofhQinarc;qofa8KfhXczh8AdndndnahPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEh8AxekcbhoaAh8Aina8Aa8EaQaofRbb9nfh8Aaocefgocz9hmbkkcih5cbhYinczhwdndndna3aYcdtfydbgLPDbeeeeeeedekcucbaXcwf8PibaX8Pib:e9cb9sEhwxekaLcetc;:FFFeGhwcuaLtcu7cFeGhCcbhoinawaCaQaofRbb9nfhwaocefgocz9hmbkkdndnawa8A6mbaLaE9hmeawa8A9hmea3a5cdtfydbcwSmekaYh5awh8AkaYcefgYci9hmbkaaa8Kco4fgoaoRbba5a8Kci4coGtV86bbdndndna3a5cdtfydbgEPDdbbbbbbbebkdncwaE9Tg5TmbcuaEtcu7hwdndnaEceSmbcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCaEtVhCaocefhoaYcufgYmbkaKaC86bbaXa5fhXaKcefhKa8La5fg8Lcz6mbxdkkcbh8LaQhXinaXhoa5hYcbhCinaoRbbg8AawcFeGgLa8AaL6EaCcetVhCaocefhoaYcufgYmbkaKaC:T9cFe:d9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:9ca188bbaXa5fhXaKcefhKa8La5fg8Lcz6mbkkcbhoinaKaQaofRbbgC86bbaKaCawcFeG9pfhKaocefgocz9hmbxikkdnaEceSmbinaKcb86bbaKcefhKxbkkinaKcb86bbaKcefhKxbkkaKaX8Pbw83bwaKaX8Pbb83bbaKczfhKka8Kczfg8Ka8J9pgomeaQczfhQagaK9RcK9pmbkkaoTmlaKh3aKTmlkaHcefgHal9hmbkarc;abfaxascufal2falz:wjjjb8Aasamfhma3hoa3mbkcbhwxdkdnagao9RakalfgwcKcaaDEgQawaQ0EgC9pmbcbhwxdkdnawaQ9pmbaocbaCaw9Rgwz:xjjjbawfhokaoarc;adfalz:wjjjbalfhodnaDTmbaoara8Mz:wjjjba8Mfhokaoab9Rhwxekcbhwkarc;qwf8Kjjjjbawk5babaeadaialcdcbyd;i:I:cjbz:bjjjbk9reduaecd4gdaefgicaaica0Ecj;abae9Uc;WFbGcjdaeca0Egicl4cifcd4aifae2adfabaifcufai9U2fcefkmbcbabBd;i:I:cjbk;HPeLu8Jjjjjbc;ae9Rgl8Kjjjjbcbhvdnaeaici9UgocHf6mbabcbyd;m:I:cjbgrc;GeV86bbalc;abfcFecjez:xjjjb8Aal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibabaefc9WfhwabcefgDaofhednaiTmbcmcsarcb9kgqEhkcbhxcbhmcbhPcbhscbhzindnaeaw9nmbcbhvxikazcufhvadaPcdtfgHydbhOaHcwfydbhAaHclfydbhCcbhXdndndninalc;abfavcsGcitfgoydlhQdndndnaoydbgoaO9hmbaQaCSmekdnaoaC9hmbaQaA9hmbaXcefhXxekaoaA9hmeaQaO9hmeaXcdfhXkaXc870mdascufhvaHaXcdtgAcxGgoyd:4:G:cjbcdtfydbhQaHaoyd:0:G:cjbcdtfydbhCaHaoyd:W:G:cjbcdtfydbhOcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaQaxSgvaXce9iaXak9oVgoGfhxdndndncbcsavEaXaoEgvcs9hmbarce9imbaQaQamaQcefamSgvEgmcefSmecmcsavEhvkaDavaAc;WeGV86bbavcs9hmeaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmxvkcPhvaDaAcPV86bbaQhmkavTmiavak9omicdhocehXazhAxlkavcufhvaXclfgXc;ab9hmbkkdnaHcecdcbaAaxSEaCaxSEcdtgvyd:W:G:cjbcdtfydbgOTaHavyd:0:G:cjbcdtfydbgCceSGaHavyd:4:G:cjbcdtfydbgQcdSGaxcb9hGaqGgLce9hmbal9cu83iUal9cu83i8Wal9cu83iyal9cu83iaal9cu83iKal9cu83izal9cu83iwal9cu83ibcbhxkcbhXascufgvhodnindnalaocsGcdtfydbaC9hmbaXhAxdkcuhAaocufhoaXcefgXcz9hmbkkcbhodnindnalavcsGcdtfydbaQ9hmbaohXxdkcuhXavcufhvaocefgocz9hmbkkaxaOaxSgKfhHdndnaAcm0mbaAcefhAxekcbcsaCaHSgvEhAaHavfhHkdndnaXcm0mbaXcefhXxekcbcsaQaHSgvEhXaHavfhHkc9:cuaKEhYcbhvaXaAcltVg8AcFeGhodndndninavc;q:G:cjbfRbbaoSmeavcefgvcz9hmbxdkkaLaOax9havcm0VVmbaDavc;WeV86bbxekaDaY86bbaea8A86bbaecefhekdnaKmbaOam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaOhmkdnaAcs9hmbaCam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaChmkdnaXcs9hmbaQam9Rgvcetavc8F917hvinaecbcjeavcje6EavcFbGV86bbaecefheavcr4gvmbkaQhmkalascdtfaOBdbascefcsGhvdndnaAPzbeeeeeeeeeeeeeebekalavcdtfaCBdbascdfcsGhvkdndnaXPzbeeeeeeeeeeeeeebekalavcdtfaQBdbavcefcsGhvkcihoalc;abfazcitfgXaOBdlaXaCBdbazcefcsGhAcdhXavhsaHhxxekcdhoalascdtfaQBdbcehXascefcsGhsazhAkalc;abfaAcitfgvaCBdlavaQBdbalc;abfazaXfcsGcitfgvaQBdlavaOBdbaDcefhDazaofcsGhzaPcifgPai6mbkkdnaeaw9nmbcbhvxekcbhvinaeavfavc;q:G:cjbfRbb86bbavcefgvcz9hmbkaeab9Ravfhvkalc;aef8KjjjjbavkZeeucbhddninadcefgdc8F0meaeceadt0mbkkadcrfcFeGcr9Uci2cdfabci9U2cHfkmbcbabBd;m:I:cjbk:zderu8Jjjjjbcz9Rhlcbhvdnaeaicvf6mbabcbRb;m:I:cjbc;qeV86bbal9cb83iwabcefhvabaefc98fhodnaiTmbcbhecbhrcbhwindnavao6mbcbskadawcdtfydbgDalcwfaraDae9Rgeaec8F91ge7ae9Rc507grcdtfgqydb9Rgec8E91c9:Gaecdt7arVheinavcbcjeaecje6EaecFbGV86bbavcefhvaecr4gembkaqaDBdbaDheawcefgwai9hmbkkdnavao9nmbcbskavcbBbbavab9RclfhvkavkBeeucbhddninadcefgdc8F0meaeceadt0mbkkabadcwfcFeGcr9U2cvfk:dvli99dui99ludnaeTmbcuadcetcuftcu7:Zhvdndncuaicuftcu7:ZgoJbbbZMgr:lJbbb9p9DTmbar:Ohwxekcjjjj94hwkcbhicbhDinalclfIdbgrJbbbbJbbjZalIdbgq:lar:lMalcwfIdbgk:lMgr:varJbbbb9BEgrNhxaqarNhralcxfIdbhqdndnakJbbbb9GTmbaxhkxekJbbjZar:l:tgkak:maxJbbbb9GEhkJbbjZax:l:tgxax:marJbbbb9GEhrkdndnaqJbbj:;aqJbbj:;9GEgxJbbjZaxJbbjZ9FEavNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohmxekcjjjj94hmkdndnakJbbj:;akJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;akJbbbb9GEMgq:lJbbb9p9DTmbaq:OhPxekcjjjj94hPkdndnarJbbj:;arJbbj:;9GEgqJbbjZaqJbbjZ9FEaoNJbbbZJbbb:;arJbbbb9GEMgr:lJbbb9p9DTmbar:Ohsxekcjjjj94hskdndnadcl9hmbabaDfgzas86bbazcifam86bbazcdfaw86bbazcefaP86bbxekabaifgzas87ebazcofam87ebazclfaw87ebazcdfaP87ebkaicwfhiaDclfhDalczfhlaecufgembkkk;hlld99eud99eudnaeTmbdndncuaicuftcu7:ZgvJbbbZMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikaic;8FiGhrinabcofcicdalclfIdb:lalIdb:l9EgialcwfIdb:lalaicdtfIdb:l9EEgialcxfIdb:lalaicdtfIdb:l9EEgiarV87ebdndnJbbj:;JbbjZalaicdtfIdbJbbbb9DEgoalaicd7cdtfIdbJ;Zl:1ZNNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabcdfaq87ebdndnalaicefciGcdtfIdbJ;Zl:1ZNaoNgwJbbj:;awJbbj:;9GEgDJbbjZaDJbbjZ9FEavNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohqxekcjjjj94hqkabaq87ebdndnaoalaicufciGcdtfIdbJ;Zl:1ZNNgoJbbj:;aoJbbj:;9GEgwJbbjZawJbbjZ9FEavNJbbbZJbbb:;aoJbbbb9GEMgo:lJbbb9p9DTmbao:Ohixekcjjjj94hikabclfai87ebabcwfhbalczfhlaecufgembkkk;uvdDue998Jjjjjbcjd9Rgo8Kjjjjbdndndnadcd4grTmbc:CucbavEhwaohdarhDinadawBdbadclfhdaDcufgDmbkavcd9hmbaeTmbarcdthqcbhkalhxinaohdaxhDarhwinadadydbgmaDydbcL4cFeGc:cufgPamaP9kEBdbaDclfhDadclfhdawcufgwmbkaxaqfhxakcefgkae9hmbxdkkaeTmekarcdthxavce9hhqcbhkindndndnaqmbarTmdc:CuhwalhdarhDinawadydbcL4cFeGc:cufgmawam9kEhwadclfhdaDcufgDmbxdkkdndndndnavPleddbdkarTmlaohdalhDarhwinadcbaDydbcL4cFeGgmc:cufgPaPam0EBdbadclfhdaDclfhDawcufgwmbxikkarTmicbhdarhDindnaladfIdbgsJbbbb9Bmbaoadfas:8cL4cFeGgwc8Aawc8A0Ec:cufBdbkadclfhdaDcufgDmbxdkkarTmdkc:CuhwkcbhdarhminawhDdnavceSmbaoadfydbhDkdndnaladfIdbgscjjj;8iaDai9RcefgPcLt9R::NJbbbZJbbb:;asJbbbb9GEMgs:lJbbb9p9DTmbas:OhDxekcjjjj94hDkabadfaDcFFFiaDcFFFi9iEcFFFrGaPcKtVBdbadclfhdamcufgmmbkkabaxfhbalaxfhlakcefgkae9hmbkkaocjdf8Kjjjjbk:Olveue99iue99iudnaeTmbceaicufthvcuaitcu7:Zhocbhradcl9hhwcbhDindndnalcwfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohixekcjjjj94hikdndnalIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9TgkaifhidndnalclfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkadai9Rcd9ThddndnalcxfIdbgqJbbbbaqJbbbb9GEgqJbbjZaqJbbjZ9FEaoNJbbbZMgq:lJbbb9p9DTmbaq:Ohxxekcjjjj94hxkadaifhiaxce91avVhxdndnawmbabaDfgmai86bbamcifax86bbamcdfad86bbamcefak86bbxekabarfgmai87ebamcofax87ebamclfad87ebamcdfak87ebkarcwfhraDclfhDalczfhlaecufgembkkk;mqdQui998Jjjjjbc:qd9Rgv8Kjjjjbavc:Sefcbc;Kbz:xjjjb8AdnadTmbaiTmbdndnabaeSmbaehoxekavcuadcdtgradcFFFFi0Ecbyd;q:I:cjbHjjjjbbgoBd:SeavceBd:mdaoaearz:wjjjb8AkavcbBd:Oeav9cb83i:Geavc:Gefaoadaiavc:Sefz:pjjjbavyd:Gehwadci9UgDcbyd;q:I:cjbHjjjjbbheavc:Sefavyd:mdgqcdtfaeBdbavaqcefgrBd:mdaecbaDz:xjjjbhkavc:SefarcdtfcuaicdtaicFFFFi0Ecbyd;q:I:cjbHjjjjbbgxBdbavaqcdfgmBd:mdalc;ebfhPawheaxhrinaralIdbaPaeydbgscwascw6EcdtfIdbMUdbaeclfhearclfhraicufgimbkavc:SefamcdtfcuaDcdtadcFFFF970Ecbyd;q:I:cjbHjjjjbbgmBdbdnadci6mbaoheamhraDhiinaraxaeydbcdtfIdbaxaeclfydbcdtfIdbMaxaecwfydbcdtfIdbMUdbaecxfhearclfhraicufgimbkkaqcifhzalc;ebfhHavc;qbfhOavheavyd:KehAavyd:OehCcbhscbhrcbhXcehQinaehLaoarcx2fgKydbhPaKclfydbhdabaXcx2fgecwfaKcwfydbgYBdbaeclfadBdbaeaPBdbakarfce86bbaOaYBdwaOadBdlaOaPBdbamarcdtfcbBdbcih8AdnasTmbaLhiinaOa8AcdtfaiydbgeBdba8AaeaY9haeaP9haead9hGGfh8AaiclfhiascufgsmbkkaXcefhXcbhsinaCaAaKascdtfydbcdtgifydbcdtfgYheawaifgdydbgPhidnaPTmbdninaeydbarSmeaeclfheaicufgiTmdxbkkaeaYaPcdtfc98fydbBdbadadydbcufBdbkascefgsci9hmbkdndndna8ATmbcuhrJbbbbhEcbhdavyd:KehYavyd:OehKindnawaOadcdtfydbcdtgsfydbgeTmbaxasfgiIdbh3aialcuadadcs0EcdtfclfIdbaHaecwaecw6EcdtfIdbMg5Udba5a3:th5aecdthiaKaYasfydbcdtfheinamaeydbgscdtfgPa5aPIdbMg3Udba3aEaEa39DgPEhEasaraPEhraeclfheaic98fgimbkkadcefgda8A9hmbkarcu9hmekaQaD9pmeindnakaQfRbbmbaQhrxdkaDaQcefgQ9hmbxdkka8Acza8Acz6EhsaOheaLhOarcu9hmekkazTmbaqcdtavc:Seffcwfheinaeydbcbyd;u:I:cjbH:bjjjbbaec98fheazcufgzmbkkavc:qdf8Kjjjjbk:0leoucuaicdtgvaicFFFFi0Egocbyd;q:I:cjbHjjjjbbhralalyd9GgwcdtfarBdbalawcefBd9GabarBdbaocbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdlcuadcdtadcFFFFi0Ecbyd;q:I:cjbHjjjjbbhralalyd9GgocdtfarBdbalaocefBd9GabarBdwabydbcbavz:xjjjb8AabydbhraehladhvinaralydbcdtfgoaoydbcefBdbalclfhlavcufgvmbkcbhvabydlglhoarhwaihDinaoavBdbaoclfhoawydbavfhvawclfhwaDcufgDmbkadci9Uhqdnadcd9nmbabydwhocbhvinaecwfydbhwaeclfydbhDalaeydbcdtfgbabydbgbcefBdbaoabcdtfavBdbalaDcdtfgDaDydbgDcefBdbaoaDcdtfavBdbalawcdtfgwawydbgwcefBdbaoawcdtfavBdbaecxfheaqavcefgv9hmbkkinalalydbarydb9RBdbarclfhralclfhlaicufgimbkkQbabaeadaic;G:G:cjbz:ojjjbkQbabaeadaic;i:H:cjbz:ojjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk:3vioud9:du8Jjjjjbc;Wa9Rgl8Kjjjjbcbhvalcxfcbc;Kbz:xjjjb8AalcuadcitgoadcFFFFe0Ecbyd;q:I:cjbHjjjjbbgrBdxalceBd2araeadaicezNjjjbalcuaoadcjjjjoGEcbyd;q:I:cjbHjjjjbbgwBdzadcdthednadTmbabhiinaiavBdbaiclfhiadavcefgv9hmbkkawaefhDalabBdwalawBdl9cbhqindnadTmbaq9cq9:hkarhvaDhiadheinaiav8Pibak1:NcFrG87ebavcwfhvaicdfhiaecufgembkkalclfaq:NceGcdtfydbhxalclfaq9ce98gq:NceGcdtfydbhmalc;Wbfcbcjaz:xjjjb8AaDhvadhidnadTmbinalc;Wbfav8VebcdtfgeaeydbcefBdbavcdfhvaicufgimbkkcbhvcbhiinalc;WbfavfgeydbhoaeaiBdbaoaifhiavclfgvcja9hmbkadhvdndnadTmbinalc;WbfaDamydbgicetf8VebcdtfgeaeydbgecefBdbaxaecdtfaiBdbamclfhmavcufgvmbkaq9cv9smdcbhvinabawydbcdtfavBdbawclfhwadavcefgv9hmbxdkkaq9cv9smekkcwhvcbhiinalcxfavfc98fydbcbyd;u:I:cjbH:bjjjbbaiceGheclhvcehiaeTmbkalc;Waf8Kjjjjbk:Awliuo99iud9:cbhv8Jjjjjbca9Rgocbyd:4:I:cjbBdKaocb8Pd:W:I:cjb83izaocbyd;e:I:cjbBdwaocb8Pd:8:I:cjb83ibaicd4hrdndnadmbJFFuFhwJFFuuhDJFFuuhqJFFuFhkJFFuuhxJFFuFhmxekarcdthPaehsincbhiinaoczfaifgzasaifIdbgwazIdbgDaDaw9EEUdbaoaifgzawazIdbgDaDaw9DEUdbaiclfgicx9hmbkasaPfhsavcefgvad9hmbkaoIdKhDaoIdwhwaoIdChqaoIdlhkaoIdzhxaoIdbhmkdnadTmbJbbbbJbFu9hJbbbbamax:tgmamJbbbb9DEgmakaq:tgkakam9DEgkawaD:tgwawak9DEgw:vawJbbbb9BEhwdnalmbarcdthoindndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:S9cC:ghHdndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikaHai:S:ehHdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaHai:T9cy:g:e83ibaeaofheabcwfhbadcufgdmbxdkkarcdthoindndnaeIdbax:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cv9:9c;j:KM;j:KM;j:Kd:dhOdndnaeclfIdbaq:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cq9:9cM;j:KM;j:KM;jl:daO:ehOdndnaecwfIdbaD:tawNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabaOai:SgH9ca:gaH9cz:g9cjjj;4s:d:eaH9cFe:d:e9cF:bj;4:pj;ar:d9c:bd9:9c:p;G:d;4j:E;ar:d9cH9:9c;d;H:W:y:m:g;d;Hb:d9cC9:9c:KM;j:KM;j:KMD:d:e83ibaeaofheabcwfhbadcufgdmbkkk9teiucbcbyd;y:I:cjbgeabcifc98GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;y:I:cjbgeabcrfc94GfgbBd;y:I:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;y:I:cjbge9Rcifc98GaefgbBd;y:I:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akkk;Sddbcj:Gdk;idbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbbbbbbbbbbbbbbbbebbbdbbbbbbbebbbbbbbbbbbbbbbb4:h9w9N94:P:gW:j9O:ye9Pbbbbbb:l29hZ;69:9kZ;N;76Z;rg97Z;z;o9xZ8J;B85Z;:;u9yZ;b;k9HZ:2;Z9DZ9e:l9mZ59A8KZ:r;T3Z:A:zYZ79OHZ;j4::8::Y:D9V8:bbbb9s:49:Z8R:hBZ9M9M;M8:L;z;o8:;8:PG89q;x:J878R:hQ8::M:B;e87bbbbbbjZbbjZbbjZ:E;V;N8::Y:DsZ9i;H;68:xd;R8:;h0838:;W:NoZbbbb:WV9O8:uf888:9i;H;68:9c9G;L89;n;m9m89;D8Ko8:bbbbf:8tZ9m836ZS:2AZL;zPZZ818EZ9e:lxZ;U98F8:819E;68:FFuuFFuuFFuuFFuFFFuFFFuFbc;i:IdkCebbbebbbebbbdbbb9G:rbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,r=WebAssembly.instantiate(i(e),{}).then(function(h){n=h.instance,n.exports.__wasm_call_ctors(),n.exports.meshopt_encodeVertexVersion(1),n.exports.meshopt_encodeIndexVersion(1)});function i(h){var b=new Uint8Array(h.length);for(var m=0;m<h.length;++m){var g=h.charCodeAt(m);b[m]=g>96?g-97:g>64?g-39:g+4}var p=0;for(var m=0;m<h.length;++m)b[p++]=b[m]<60?t[b[m]]:(b[m]-60)*64+b[++m];return b.buffer.slice(0,p)}function a(h){if(!h)throw Error("Assertion failed")}function s(h){return new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}function o(h,b,m,g){var p=n.exports.sbrk,y=p(b.length*4),v=p(m*4),x=new Uint8Array(n.exports.memory.buffer),_=s(b);if(x.set(_,y),g)g(y,y,b.length,m);var E=h(v,y,b.length,m);x=new Uint8Array(n.exports.memory.buffer);var w=new Uint32Array(m);new Uint8Array(w.buffer).set(x.subarray(v,v+m*4)),_.set(x.subarray(y,y+b.length*4)),p(y-p(0));for(var A=0;A<b.length;++A)b[A]=w[b[A]];return[w,E]}function c(h,b,m,g){var p=n.exports.sbrk,y=p(m*4),v=p(m*g),x=new Uint8Array(n.exports.memory.buffer);x.set(s(b),v),h(y,v,m,g),x=new Uint8Array(n.exports.memory.buffer);var _=new Uint32Array(m);return new Uint8Array(_.buffer).set(x.subarray(y,y+m*4)),p(y-p(0)),_}function l(h,b,m,g,p,y,v){var x=n.exports.sbrk,_=x(b),E=x(g*p),w=new Uint8Array(n.exports.memory.buffer);w.set(s(m),E);var A=h(_,b,E,g,p,y,v),T=new Uint8Array(A);return T.set(w.subarray(_,_+A)),x(_-x(0)),T}function u(h){var b=0;for(var m=0;m<h.length;++m){var g=h[m];b=b<g?g:b}return b}function d(h,b){if(a(b==2||b==4),b==4)return new Uint32Array(h.buffer,h.byteOffset,h.byteLength/4);else{var m=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/2);return new Uint32Array(m)}}function f(h,b,m,g,p,y,v){var x=n.exports.sbrk,_=x(m*g),E=x(m*y),w=new Uint8Array(n.exports.memory.buffer);w.set(s(b),E),h(_,m,g,p,E,v);var A=new Uint8Array(m*g);return A.set(w.subarray(_,_+m*g)),x(_-x(0)),A}return{ready:r,supported:!0,reorderMesh:function(h,b,m){a(h instanceof Uint32Array||h instanceof Int32Array),a(!b||h.length%3==0);var g=b?m?n.exports.meshopt_optimizeVertexCacheStrip:n.exports.meshopt_optimizeVertexCache:void 0;return o(n.exports.meshopt_optimizeVertexFetchRemap,h,u(h)+1,g)},reorderPoints:function(h,b){return a(h instanceof Float32Array),a(h.length%b==0),a(b>=3),c(n.exports.meshopt_spatialSortRemap,h,h.length/b,b*4)},encodeVertexBuffer:function(h,b,m){a(m>0&&m<=256),a(m%4==0);var g=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBuffer,g,h,b,m)},encodeVertexBufferLevel:function(h,b,m,g,p){a(m>0&&m<=256),a(m%4==0),a(g>=0&&g<=3),a(p===void 0||p==0||p==1);var y=n.exports.meshopt_encodeVertexBufferBound(b,m);return l(n.exports.meshopt_encodeVertexBufferLevel,y,h,b,m,g,p===void 0?-1:p)},encodeIndexBuffer:function(h,b,m){a(m==2||m==4),a(b%3==0);var g=d(h,m),p=n.exports.meshopt_encodeIndexBufferBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexBuffer,p,g,b,4)},encodeIndexSequence:function(h,b,m){a(m==2||m==4);var g=d(h,m),p=n.exports.meshopt_encodeIndexSequenceBound(b,u(g)+1);return l(n.exports.meshopt_encodeIndexSequence,p,g,b,4)},encodeGltfBuffer:function(h,b,m,g,p){var y={ATTRIBUTES:this.encodeVertexBufferLevel,TRIANGLES:this.encodeIndexBuffer,INDICES:this.encodeIndexSequence};return a(y[g]),y[g](h,b,m,2,p===void 0?0:p)},encodeFilterOct:function(h,b,m,g){return a(m==4||m==8),a(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterOct,h,b,m,g,16)},encodeFilterQuat:function(h,b,m,g){return a(m==8),a(g>=4&&g<=16),f(n.exports.meshopt_encodeFilterQuat,h,b,m,g,16)},encodeFilterExp:function(h,b,m,g,p){a(m>0&&m%4==0),a(g>=1&&g<=24);var y={Separate:0,SharedVector:1,SharedComponent:2,Clamped:3};return a(!p||p in y),f(n.exports.meshopt_encodeFilterExp,h,b,m,g,m,p?y[p]:1)},encodeFilterColor:function(h,b,m,g){return a(m==4||m==8),a(g>=2&&g<=16),f(n.exports.meshopt_encodeFilterColor,h,b,m,g,16)}}}()});var $X;var kR=ot(()=>{$X=function(){var e="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;X8:kdbk:kYi5ud9:du8Jjjjjbcjq9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCaAcethXaxaDfhiaOaeaoaeao6E9RhQalcl4cifcd4hLazcjdfaAfhKcbhYabaOad2fg8AhEaHh3incbh5dnawTmbaxaYcd4fRbbh5kcbh8Eazcjdfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcjdfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcjdfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaL6mva8FaLfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasaYcd4fRbbgociGPlbedrbkaATmdazaYfh8Fazcjdfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeazaYfhaazcjdfhhcbhoceh8EaKh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaQaocefgofmbka8FaXfh8FcdhoaacdfhaahaXfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8EazaYfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaKhainazcjdfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3aYclfgYad6mbkaza8AaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcjqf8Kjjjjbaok:bsesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb",t="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:I9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:SBlEud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fgOavcjdfasaeaH9RaHasfae6EgAaAcsfgoc9WGgCSEhXaPaDfhQaocl4cifcd4hLavcj;cbfaCcetfhKavcj;cbfaCci2fhYavcj;cbfaCfh8AcbhEaoc;ab6h3incbh5dnawTmbaPaEcd4fRbbh5kcbh8Eavcj;cbfh8Findndndndna5a8Ecet4ciGgoc9:fPdebdkaxaQ9RaC6mwdnaCTmbavcj;cbfa8EaC2faQaC;8qbbkaQaAfhQxdkaCTmeavcj;cbfa8EaC2fcbaC;8kbxekaxaQ9RaL6moaoclVcbawEhraQaLfhocbhidna3mbaxao9Rc;Gb6mbcbhlina8FalfhidndndndndndnaQalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaiczfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaoclffa8JRb:q:W:cjbfhoxikaicafaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbagaocwffa8JRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbagaocdffa8JRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsaap5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaC0meaihlaxao9Rc;Fb0mbkkdnaiaC9pmbaici4hlinaxao9RcK6mwa8FaifhqdndndndndndnaQaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLgacdp:meaapmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9oghpxiiiiiiiiiiiiiiiip8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaoclffa8JRb:q:W:cjbfhoxikaqaopbbwaopbbbgaclp:meaapmbzeHdOiAlCvXoQrLpxssssssssssssssssp9oghpxssssssssssssssssp8Jgap5b9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbagRb:q:W:cjbggpsaap5e9cjF;8;4;W;G;ab9:9cU1:Ng8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPahaap9spkbbagaocwffa8JRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbggcitpbi:q:G:cjbagRb:q:W:cjbggpsaoRbeg8Jcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbagaocdffa8JRb:q:W:cjbfhokalcdfhlaiczfgiaC6mbkkaohQaoTmoka8FaCfh8Fa8Ecefg8Ecl9hmbkdndndndnawTmbazaEcd4fRbbglciGPlbedwbkaCTmdaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep9Taapxeeeeeeeeeeeeeeeeghp9op9Hp9rgaa8Kp9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep9Taaahp9op9Hp9rgap9Ug8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp9Ug8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp9Ug8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep9Taaahp9op9Hp9rgap9Ughp9Abbbaladfglahaaaapmlvorlvorlvorlvorp9Ughp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp9Ughp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp9Ug8Kp9AbbbaladfhlaoczfgoaC6mbxikkaCTmeaXaEfhlavaEfpbdbh8Kcbhoinalavcj;cbfaofpblbg8La8Aaofpblbg8MpmbzeHdOiAlCvXoQrLg8NaKaofpblbgyaYaofpblbg8PpmbzeHdOiAlCvXoQrLgIpmbezHdiOAlvCXorQLgacep:neaapxebebebebebebebebghp9op:bep9rgaa8Kp:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8NaIpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwKDYq8AkEx3m5P8Es8Fg8Laya8PpmwKDYq8AkEx3m5P8Es8Fg8MpmbezHdiOAlvCXorQLgacep:neaaahp9op:bep9rgap:oeg8Kp9Abbbaladfgla8Kaaaapmlvorlvorlvorlvorp:oeg8Kp9Abbbaladfgla8KaaaapmwDqkwDqkwDqkwDqkp:oeg8Kp9Abbbaladfgla8KaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9Abbbaladfgla8Ka8La8MpmwDKYqk8AExm35Ps8E8Fgacep:neaaahp9op:bep9rgap:oeghp9Abbbaladfglahaaaapmlvorlvorlvorlvorp:oeghp9AbbbaladfglahaaaapmwDqkwDqkwDqkwDqkp:oeghp9AbbbaladfglahaaaapmxmPsxmPsxmPsxmPsp:oeg8Kp9AbbbaladfhlaoczfgoaC6mbxdkkaCTmbaXaEfhrcbhocbalcl4gl9Rc8FGhiavaEfpbdbhhinaravcj;cbfaofpblbg8Ka8Aaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaKaofpblbg8NaYaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgaahp9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ma8PpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9Abbbaradfgraha8Ka8LpmwDKYqk8AExm35Ps8E8Fgaaip:Reaaalp:Tep9qgap9rghp9Abbbaradfgrahaaaapmlvorlvorlvorlvorp9rghp9AbbbaradfgrahaaaapmwDqkwDqkwDqkwDqkp9rghp9AbbbaradfgrahaaaapmxmPsxmPsxmPsxmPsp9rghp9AbbbaradfhraoczfgoaC6mbkkaEclfgEad6mbkdnaXavcjdf9hmbaAad2goTmbaOavcjdfao;8qbbkdnammbavaXaAcufad2fad;8qbbkaAaHfhHc9:hoaQhPaQmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkpPesu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhDaicefgiarfhqdndnaeci9pmbaqhexekcmcsawceSEhkcbhxcbhmaqhecbhlcbhoindndnaiRbbgrc;Ve0mbavc;abfaoarcu7gPcl4fcsGcitfgwydlhsawydbhzdndnarcsGgwak9pmbavalaPfcsGcdtfydbaxawEhraxawTgHfhxxekdnaeaD9nmbc9:hoxokdndnawcsSmbcehHamawcetfcWfhrxekaecefhrae8SbbgwcFeGhPdndnawcu9mmbarhexekaecvfheaPcFbGhPcrhwdninar8SbbgHcFbGawtaPVhPaHcu9kmearcefhrawcrfgwc8J9hmbxdkkarcefhekcehHaPce4cbaPceG9R7amfhrkarhmkavc;abfaocitfgwarBdbawasBdlavalcdtfarBdbavc;abfaocefcsGcitfgwazBdbawarBdlaocdfhoaHalfhldnadcd9hmbabar87elabas87edabaz87ebabcofhbxdkabarBdwabasBdlabazBdbabcxfhbxekdnarcpe0mbavalaDarcsGfRbbgwcl4gP9RcsGcdtfydbaxcefgsaPEhravalaw9RcsGcdtfydbasaPTgzfgsawcsGgPEhwaPThPdndnadcd9hmbabaw87elabar87edabax87ebcohHxekabawBdwabarBdlabaxBdbcxhHkavalcdtfaxBdbavc;abfaocitfgOarBdbaOaxBdlavalcefglcsGcdtfarBdbavc;abfaocefcsGcitfgOawBdbaOarBdlavalazfglcsGcdtfawBdbavc;abfaocdfcsGcitfgraxBdbarawBdlaocifhoabaHfhbalaPfhlasaPfhxxekdnaeaD9nmbc9:hoxlkaxcbaeRbbgwEgHarc;:eSgrfhsawcsGhOdndnawcl4gAmbascefhzxekashzavalaA9RcsGcdtfydbhskdndnaOmbazcefhxxekazhxavalaw9RcsGcdtfydbhzkdndnarTmbaecefhrxekaecdfhrae8SbegPcFeGhwdnaPcu9kmbaecofhHawcFbGhwcrhedninar8SbbgPcFbGaetawVhwaPcu9kmearcefhraecrfgec8J9hmbkaHhrxekarcefhrkawce4cbawceG9R7amfgmhHkdndnaAcsSmbarhwxekarcefhwar8SbbgecFeGhPdnaecu9kmbarcvfhsaPcFbGhPcrhedninaw8SbbgrcFbGaetaPVhParcu9kmeawcefhwaecrfgec8J9hmbkashwxekawcefhwkaPce4cbaPceG9R7amfgmhskdndnaOcsSmbawhexekawcefheaw8SbbgrcFeGhPdnarcu9kmbawcvfhzaPcFbGhPcrhrdninae8SbbgwcFbGartaPVhPawcu9kmeaecefhearcrfgrc8J9hmbkazhexekaecefhekaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabaz87elabas87edabaH87ebcohrxekabazBdwabasBdlabaHBdbcxhrkavc;abfaocitfgwasBdbawaHBdlavalcdtfaHBdbavc;abfaocefcsGcitfgwazBdbawasBdlavalcefglcsGcdtfasBdbavc;abfaocdfcsGcitfgwaHBdbawazBdlavalaATaAcsSVfglcsGcdtfazBdbalaOTaOcsSVfhlaocifhoabarfhbkaocsGhoalcsGhlaicefgiaq6mbkkcbc99aeaDSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb",n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var i=WebAssembly.validate(n)?o(t):o(e),a,s=WebAssembly.instantiate(i,{}).then(function(p){a=p.instance,a.exports.__wasm_call_ctors()});function o(p){var y=new Uint8Array(p.length);for(var v=0;v<p.length;++v){var x=p.charCodeAt(v);y[v]=x>96?x-97:x>64?x-39:x+4}var _=0;for(var v=0;v<p.length;++v)y[_++]=y[v]<60?r[y[v]]:(y[v]-60)*64+y[++v];return y.buffer.slice(0,_)}function c(p,y,v,x,_,E,w){var A=p.exports.sbrk,T=x+3&-4,N=A(T*_),M=A(E.length),R=new Uint8Array(p.exports.memory.buffer);R.set(E,M);var k=y(N,x,_,M,E.length);if(k==0&&w)w(N,T,_);if(v.set(R.subarray(N,N+x*_)),A(N-A(0)),k!=0)throw Error("Malformed buffer data: "+k)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function h(p){var y={object:new Worker(p),pending:0,requests:{}};return y.object.onmessage=function(v){var x=v.data;y.pending-=x.count,y.requests[x.id][x.action](x.value),delete y.requests[x.id]},y}function b(p){var y="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+g.name+";"+c.toString()+g.toString(),v=new Blob([y],{type:"text/javascript"}),x=URL.createObjectURL(v);for(var _=d.length;_<p;++_)d[_]=h(x);for(var _=p;_<d.length;++_)d[_].object.postMessage({});d.length=p,URL.revokeObjectURL(x)}function m(p,y,v,x,_){var E=d[0];for(var w=1;w<d.length;++w)if(d[w].pending<E.pending)E=d[w];return new Promise(function(A,T){var N=new Uint8Array(v),M=++f;E.pending+=p,E.requests[M]={resolve:A,reject:T},E.object.postMessage({id:M,count:p,size:y,source:N,mode:x,filter:_},[N.buffer])})}function g(p){var y=p.data;self.ready.then(function(v){if(!y.id)return self.close();try{var x=new Uint8Array(y.count*y.size);c(v,v.exports[y.mode],x,y.count,y.size,y.source,v.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:x},[x.buffer])}catch(_){self.postMessage({id:y.id,count:y.count,action:"reject",value:_})}})}return{ready:s,supported:!0,useWorkers:function(p){b(p)},decodeVertexBuffer:function(p,y,v,x,_){c(a,a.exports.meshopt_decodeVertexBuffer,p,y,v,x,a.exports[l[_]])},decodeIndexBuffer:function(p,y,v,x){c(a,a.exports.meshopt_decodeIndexBuffer,p,y,v,x)},decodeIndexSequence:function(p,y,v,x){c(a,a.exports.meshopt_decodeIndexSequence,p,y,v,x)},decodeGltfBuffer:function(p,y,v,x,_,E){c(a,a.exports[u[_]],p,y,v,x,a.exports[l[E]])},decodeGltfBufferAsync:function(p,y,v,x,_){if(d.length>0)return m(p,y,v,u[x],l[_]);return s.then(function(){var E=new Uint8Array(p*y);return c(a,a.exports[u[x]],E,p,y,v,a.exports[l[_]]),E})}}}()});var WX;var LR=ot(()=>{WX=function(){var e="b9H79Tebbbe;veC9Geueu9Geub9Gbb9Gsuuuuuuuuuuuu99uueu9Gvuuuuub9Gruuuuuuub9Gouuuuuue999Gvuuuuueu9Gzuuuuuuuuuuu99uuuub9Gquuuuuuu99uueu9GPuuuuuuuuuuu99uueu9Gquuuuuuuu99ueu9Gruuuuuu99eu9Gwuuuuuu99ueu9Giuuue999GDuuuuuuuuueu9Gkuuuuuuuu99uub9Gluuuueu9Gluuuub9Giuuueui3EdilvorlwDiqkrxmPszdHObAAbeAlve9Weiiviebeoweuecj:Gdkr:Sdmo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbz9TW79O9V9Wt9F79P9T9W29P9M95bw8E9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9OcttV9P9I91tW7bD8A9TW79O9V9Wt9F79P9T9W29P9M959x9Pt9O9v9W9K9HtWbqQ9TW79O9V9Wt9F79P9T9W29P9M959t29V9W9W95bkX9TW79O9V9Wt9F79P9T9W29P9M959qV919UWbmQ9TW79O9V9Wt9F79P9T9W29P9M959q9V9P9Ut7bPX9TW79O9V9Wt9F79P9T9W29P9M959t9J9H2WbsP9TW79O9V9Wt9FVW9TW79Obza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbA59TW79O9V9Wt9F9NW9UWV9HtW9q9V79Pt9P9V9U9sW9T9H9WbCl79IV9RbXDwebcekdKYq:p:1dElbzOk:Q:tekYue99iuQ99eui99Due99xue9:w998Jjjjjbcj;sb9Rgs8Kjjjjbcbhzasc:Cefcbc;Kbz:xjjjb8AdnabaeSmbabaeadcdtz:wjjjb8AkdnamcdGTmbalcrfci4cbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egecdtfaHBdbasaecefBd;8ecbhlcbhednadTmbabheadhOinaHaeydbci4fcb86bbaeclfheaOcufgOmbkcbhlabheadhOinaHaeydbgAci4fgCaCRbbgCceaAcrGgAtV86bbaCcu7aA4ceGalfhlaeclfheaOcufgOmbkcualcdtalcFFFFi0Ehekaecbyd;y:L:cjbHjjjjbbhzasc:Cefasyd;8egecdtfazBdbasaecefBd;8ealcd4alfhOcehHinaHgecethHaeaO6mbkcbhXcuaecdtgOaecFFFFi0Ecbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egAcdtfaHBdbasaAcefBd;8eaHcFeaOz:xjjjbhQdnadTmbaecufhLcbhKindndnaQabaKcdtfgYydbgAc:v;t;h;Ev2aLGgOcdtfgCydbgHcuSmbceheinazaHcdtfydbaASmdaOaefhHaecefheaQaHaLGgOcdtfgCydbgHcu9hmbkkazaXcdtfaABdbaCaXBdbaXhHaXcefhXkaYaHBdbaKcefgKad9hmbkkaQcbyd;C:L:cjbH:bjjjbbasasyd;8ecufBd;8ekcbh8AcualcefgecdtaecFFFFi0Ecbyd;y:L:cjbHjjjjbbhKasc:Cefasyd;8egecdtfaKBdbasaKBdNeasaecefBd;8ecuadcitadcFFFFe0Ecbyd;y:L:cjbHjjjjbbhEasc:Cefasyd;8egecdtfaEBdbasaEBd:yeasaecefBd;8eascNefabadalcbz:cjjjbcualcdtgealcFFFFi0Eg3cbyd;y:L:cjbHjjjjbbhHasc:Cefasyd;8egOcdtfaHBdbasaOcefBd;8ea3cbyd;y:L:cjbHjjjjbbhXasc:Cefasyd;8egOcdtfaXBdbasaOcefBd;8eaHaXaialavazasc:Cefz:djjjbalcbyd;y:L:cjbHjjjjbbh5asc:Cefasyd;8egOcdtfa5BdbasaOcefBd;8ea3cbyd;y:L:cjbHjjjjbbhOasc:Cefasyd;8egAcdtfaOBdbasaAcefBd;8ea3cbyd;y:L:cjbHjjjjbbhAasc:Cefasyd;8egCcdtfaABdbasaCcefBd;8eaOcFeaez:xjjjbh8EaAcFeaez:xjjjbh8FdnalTmbindnaKa8AgAcefg8AcdtfydbgCaKaAcdtgefydbgOSmbaCaO9RhYaEaOcitfhaa8Faefhha8EaefhLcbhCindndnaaaCcitfydbgQaA9hmbaLaABdbahaABdbxekdnaKaQcdtggfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheinaeydbaASmdaecwfheaOcufgOmbkka8FagfgeaAaQaeydbcuSEBdbaLaQaAaLydbcuSEBdbkaCcefgCaY9hmbkka8Aal9hmbkaHhOaXhAa8EhQa8FhCcbheindndnaeaOydbgL9hmbdnaeaAydbgL9hmbaQydbhLdnaCydbgYcu9hmbaLcu9hmba5aefcb86bbxikdnaYcuSmbaLcuSmbaeaYSmbaHaYcdtfydbaHaLcdtfydb9hmba5aefcd86bbxika5aefhadnaeaYSmbaeaLSmbaace86bbxikaacv86bbxdkdnaeaXaLcdtgYfydb9hmbdnaCydbgacuSmbaeaaSmbaQydbggcuSmbaeagSmba8FaYfydbghcuSmbahaLSmba8EaYfydbgYcuSmbaYaLSmbaHaacdtfydbgLaHaYcdtfydb9hmbaLaHagcdtfydbgYSmbaYaHahcdtfydb9hmba5aefcd86bbxika5aefcv86bbxdka5aefcv86bbxeka5aefa5aLfRbb86bbkaOclfhOaAclfhAaQclfhQaCclfhCalaecefge9hmbkdnamcaGTmbcbh8Jindndna5a8Jfg8KRbbg8Lc9:fPlbeebekdndndnaHa8Jcdtfydbgea8J9hmbcbhYcbh8MaqTmednazTmbcbh8Ma8JheinaqazaecdtgefydbfRbbce4a8MVceGh8MaXaefydbgea8J9hmbxikkcbh8Ma8JheinaqaefRbbce4a8MVceGh8MaXaecdtfydbgea8J9hmbxdkka5aefRbbhexeka8JheindnaKaecdtg8AfgeclfydbgOaeydbgeSmbaOae9RhgaEaecitfhhaHa8AfhacbhLinahaLcitfydbgQhednindnaKaecdtgCfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheaaydbhAdninaHaeydbcdtfydbaASmeaecwfheaOcufgOTmdxbkkcbhexdkaXaCfydbgeaQ9hmbkcehekaYaeVhYaLcefgLag9hmbkkaXa8Afydbgea8J9hmbka8LclciaYceGEa8MEheka8Kae86bbka8Jcefg8Jal9hmbkkdnaqTmbdndnazTmbazheaHhOalhAindnaqaeydbfRbbceGTmba5aOydbfcv86bbkaeclfheaOclfhOaAcufgAmbxdkkaqheaHhOalhAindnaeRbbceGTmba5aOydbfcv86bbkaecefheaOclfhOaAcufgAmbkkaHhealhAa5hOindna5aeydbfRbbcv9hmbaOcv86bbkaeclfheaOcefhOaAcufgAmbkkamceGTmba5healhOindndnaeRbbcufPlbeebekaecv86bbkaecefheaOcufgOmbkkcbh8Ncualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbh8Kasc:Cefasyd;8egecdtfa8KBdbasaecefBd;8eascbBd:qeas9cb83i1ea8Kaialavazasc1efz:ejjjbhydndnaDmbcbh8PcbhaxekcbhaawhecbhOindnaeIdbJbbbb9ETmbasaacdtfaOBdbaacefhakaeclfheaDaOcefgO9hmbkcuaaal2gecdtaecFFFFi0Ecbyd;y:L:cjbHjjjjbbh8Pasc:Cefasyd;8egecdtfa8PBdbasaecefBd;8ealTmbdnaambcbhaxekarcd4hgdnazTmbaacdthhcbhLa8PhYinaoazaLcdtfydbag2cdtfhQasheaYhOaahAinaOaQaeydbcdtgCfIdbawaCfIdbNUdbaeclfheaOclfhOaAcufgAmbkaYahfhYaLcefgLal9hmbxdkkaacdthhcbhLa8PhYinaoaLag2cdtfhQasheaYhOaahAinaOaQaeydbcdtgCfIdbawaCfIdbNUdbaeclfheaOclfhOaAcufgAmbkaYahfhYaLcefgLal9hmbkkcualc8S2gOalc;D;O;f8U0EgCcbyd;y:L:cjbHjjjjbbheasc:Cefasyd;8egAcdtfaeBdbasaAcefBd;8eaecbaOz:xjjjbhIcbh8RcbhgdnaaTmbcbh8NaCcbyd;y:L:cjbHjjjjbbhgasc:Cefasyd;8egecdtfagBdbasaecefBd;8eagcbaOz:xjjjb8Acuaaal2gecltgOaecFFFFb0Ecbyd;y:L:cjbHjjjjbbh8Rasc:Cefasyd;8egecdtfa8RBdbasaecefBd;8ea8RcbaOz:xjjjb8AamcjjjjdGTmbcualcltgealcFFFFb0Ecbyd;y:L:cjbHjjjjbbh8Nasc:Cefasyd;8egOcdtfa8NBdbasaOcefBd;8ea8Ncbaez:xjjjb8AkdnadTmbcbhQabhOina8KaOclfydbgLcx2fgeIdba8KaOydbgYcx2fgAIdbg8S:tgRa8KaOcwfydbghcx2fgCIdlaAIdlg8U:tg8VNaeIdla8U:tg8WaCIdba8S:tg8XN:tg8Ya8YNa8WaCIdwaAIdwg8Z:tg80NaeIdwa8Z:tg8Wa8VN:tg81a81Na8Wa8XNaRa80N:tg80a80NMMg8V:rhBa8Yh8Xa80h8Wa81hRdna8VJbbbb9EgATmba8YaB:vh8Xa80aB:vh8Wa81aB:vhRkaIaHaYcdtfydbgCc8S2fgeaRaB:rg8VaRNNg83aeIdbMUdbaea8Wa8Va8WNgUNg85aeIdlMUdlaea8Xa8Va8XNg86Ng87aeIdwMUdwaeaRaUNgUaeIdxMUdxaea86aRNg88aeIdzMUdzaea8Wa86Ng89aeIdCMUdCaeaRa8Va8Xa8ZNaRa8SNa8Ua8WNMM:mg8:Ng86NgRaeIdKMUdKaea8Wa86Ng8WaeId3MUd3aea8Xa86Ng8XaeIdaMUdaaea86a8:Ng86aeId8KMUd8Kaea8VaeIdyMUdyaIaHaLcdtfydbgLc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdyaIaHahcdtfydbgYc8S2fgea83aeIdbMUdbaea85aeIdlMUdlaea87aeIdwMUdwaeaUaeIdxMUdxaea88aeIdzMUdzaea89aeIdCMUdCaeaRaeIdKMUdKaea8WaeId3MUd3aea8XaeIdaMUdaaea86aeId8KMUd8Kaea8VaeIdyMUdydna8NTmbdnaATmba8YaB:vh8Ya80aB:vh80a81aB:vh81ka8NaCcltfgeaBJbbbZNgRa80Ng8VaeIdlMUdlaeaRa8YNg8WaeIdwMUdwaeaRa81Ng8XaeIdbMUdbaeaRa8S:ma81Na8Ua80N:ta8Za8YN:tNgRaeIdxMUdxa8NaLcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxa8NaYcltfgea8VaeIdlMUdlaea8WaeIdwMUdwaea8XaeIdbMUdbaeaRaeIdxMUdxkaOcxfhOaQcifgQad6mbkkdnalTmbJq;x8J88J;n;m;m89J:v:;;w8ZamczGEamc;abGEh80cbhOaHhCazhQaIhea8KhAindnaOaCydb9hmbaOhLdnazTmbaQydbhLka80hRdnaqTmbJbbjZa80aqaLfRbbclGEhRkaecxfgLaLIdbJbbbbMUdbaeczfgLaLIdbJbbbbMUdbaecCfgLaLIdbJbbbbMUdbaeaRaecyfgLIdbg8YNgRaeIdbMUdbaeclfgYaRaYIdbMUdbaecwfgYaRaYIdbMUdbaecKfgYaYIdbaAIdbg8WaRN:tUdbaAcwfIdbh8Vaec3fgYaYIdbaRaAclfIdbg8XN:tUdbaecafgYaYIdbaRa8VN:tUdbaec8KfgYIdbh81aLa8YaRMUdbaYa81aRa8Va8VNa8Wa8WNa8Xa8XNMMNMUdbkaCclfhCaQclfhQaec8SfheaAcxfhAalaOcefgO9hmbkkdnadTmbcbh8AabhLinaba8AcdtfhYcbheindna5aLaefydbgCfRbbgOTmba5aYaec:G:G:cjbfydbcdtfydbgQfRbbcFeGgATmbdnaOclSghmbaOci6mbaAclSmbaAcd0mekdnaOcd0mba8EaCcdtfydbaQ9hmekdnaAcd0mba8FaQcdtfydbaC9hmekdndnahmbaAcl9hmekaOciSmeaAciSmekJbbbZJbbbZJbbacaAcdSEaOcdSEhUdna8KaYaec:K:G:cjbfydbcdtfydbcx2fgOIdwa8KaCcx2fgAIdwg86:tg8Sa8KaQcx2fghIdwa86:tg8Xa8XNahIdbaAIdbg8U:tg80a80NahIdlaAIdlg8Z:tg8Va8VNMMg81Na8Xa8Sa8XNaOIdba8U:tg83a80Na8VaOIdla8Z:tg85NMMg8WN:tg8Ya8YNa83a81Na80a8WN:tgRaRNa85a81Na8Va8WN:tg8Wa8WNMMgBJbbbb9ETmba8YaB:rgB:vh8Ya8WaB:vh8WaRaB:vhRkaUa81:rNgBa8Ya86NaRa8UNa8Za8WNMM:mg81Ng87a81Nh88a80a85Na8Va83N:tg81a81Na8Va8SNa8Xa85N:tg8Va8VNa8Xa83Na80a8SN:tg8Xa8XNMMg83:rh80a8Ya87Nh85a8Wa87Nh89aRa87Nh87a8WaBa8YNg8SNh8:a8SaRNhZaRaBa8WNgnNhca8Ya8SNh8Ya8WanNh8WaRaBaRNNh8Sdna83Jbbbb9ETmba81a80:vh81a8Xa80:vh8Xa8Va80:vh8VkaIaHaCcdtfydbc8S2fgOaOIdba8Sa8VaUa80:rNgRa8VNNMg80MUdbaOa8Wa8XaRa8XNg8SNMg83aOIdlMUdlaOa8Ya81aRa81Ng8WNMg8YaOIdwMUdwaOaca8Va8SNMg8SaOIdxMUdxaOaZa8Wa8VNMgUaOIdzMUdzaOa8:a8Xa8WNMg8WaOIdCMUdCaOa87a8VaRa81a86Na8Va8UNa8Za8XNMMg86:mNgRNMg8VaOIdKMUdKaOa89a8XaRNMg8XaOId3MUd3aOa85a81aRNMg81aOIdaMUdaaOa88a86aRN:tgRaOId8KMUd8KaOaBaOIdyMUdyaIaHaQcdtfydbc8S2fgOa80aOIdbMUdbaOa83aOIdlMUdlaOa8YaOIdwMUdwaOa8SaOIdxMUdxaOaUaOIdzMUdzaOa8WaOIdCMUdCaOa8VaOIdKMUdKaOa8XaOId3MUd3aOa81aOIdaMUdaaOaRaOId8KMUd8KaOaBaOIdyMUdykaeclfgecx9hmbkaLcxfhLa8Acifg8Aad6mbkkdnamcjeGTmbalTmbcbh9cindnaKa9cgecdtgOfydbghaKaecefg9ccdtfydbg8M9pmba8Kaecx2fhDaIaHaOfydbgCc8S2fh8AindnaHaEahcitfgeydbgLcdtfydbg8JaC0mbaeydlh8LcuhAaLheindnaKaecdtgYfgeclfydbgOaeydbgeSmbaOae9RhOaEaecitfheindnaHaeydbcdtfydbaC9hmbaAcu9hhQaLhAaQmbaeclfydbhAkaecwfheaOcufgOmbkkaXaYfydbgeaL9hmbkaAaLSmbaAcuSmba8KaLcx2fgeIdbaDIdbg81:tgRa8Ka8Lcx2fgOIdlaDIdlg80:tg8XNaeIdla80:tg8VaOIdba81:tg8YN:tg86a8KaAcx2fgAIdba81:tg8Za8VNaAIdla80:tg83aRN:tg8SNa8VaOIdwaDIdwgB:tg8UNaeIdwaB:tg8Wa8XN:tg85a83a8WNaAIdwaB:tg87a8VN:tgUNa8Wa8YNaRa8UN:tg88a87aRNa8Za8WN:tg89NMMa86a86Na85a85Na88a88NMM:rJ:A:z9z:;Na8Sa8SNaUaUNa89a89NMM:rN9Gmbdna8Ua8Wa8WNaRaRNa8Va8VNMMg8SNa8Wa8Ua8WNa8YaRNa8Va8XNMMg86N:tg8Ua8UNa8Ya8SNaRa86N:tg8Ya8YNa8Xa8SNa8Va86N:tg86a86NMMg8XJbbbb9ETmba8Ua8X:rg8X:vh8Ua86a8X:vh86a8Ya8X:vh8Yka8S:rg8Xa8UaBNa8Ya81Na80a86NMM:mgUNg85aUNhUa8Ua85Nh88a86a85Nh89a8Ya85Nh8:a86a8Xa8UNg85NhZa85a8YNhna8Ya8Xa86NgcNhJa8Ua85Nh8Ua86acNh86a8Ya8Xa8YNNh85dna87a8SNa8Wa87a8WNa8ZaRNa8Va83NMMg8YN:tg8Wa8WNa8Za8SNaRa8YN:tgRaRNa83a8SNa8Va8YN:tg8Va8VNMMg8YJbbbb9ETmba8Wa8Y:rg8Y:vh8Wa8Va8Y:vh8VaRa8Y:vhRka8Aa8AIdba85aRa8XaRNNMg8SMUdba8Aa86a8Va8Xa8VNg8ZNMg86a8AIdlMUdla8Aa8Ua8Wa8Xa8WNg8YNMg8Ua8AIdwMUdwa8AaJaRa8ZNMg8Za8AIdxMUdxa8Aana8YaRNMg83a8AIdzMUdza8AaZa8Va8YNMg85a8AIdCMUdCa8Aa8:aRa8Xa8WaBNaRa81Na80a8VNMMg81:mNg8YNMgRa8AIdKMUdKa8Aa89a8Va8YNMg8Va8AId3MUd3a8Aa88a8Wa8YNMg8Wa8AIdaMUdaa8AaUa81a8YN:tg8Ya8AId8KMUd8Ka8Aa8Xa8XMg8Xa8AIdyMUdyaIa8Jc8S2fgea8SaeIdbMUdbaea86aeIdlMUdlaea8UaeIdwMUdwaea8ZaeIdxMUdxaea83aeIdzMUdzaea85aeIdCMUdCaeaRaeIdKMUdKaea8VaeId3MUd3aea8WaeIdaMUdaaea8YaeId8KMUd8Kaea8XaeIdyMUdykahcefgha8M9hmbkka9cal9hmbkkdnadTmbaaTmbcbhYinJbbbbh80a8KabaYcdtfgeclfydbgLcx2fgOIdwa8Kaeydbghcx2fgAIdwg8Z:tg8Va8VNaOIdbaAIdbg83:tg8Wa8WNaOIdlaAIdlg85:tg8Xa8XNMMg8Sa8Kaecwfydbg8Acx2fgeIdwa8Z:tg8YNa8Va8YNa8WaeIdba83:tg81Na8XaeIdla85:tgBNMMgRa8VN:tJbbbbJbbjZa8Sa8Ya8YNa81a81NaBaBNMMg8UNaRaRN:tg86:va86Jbbbb9BEg86Nh88a8Ua8VNaRa8YN:ta86Nh89a8SaBNaRa8XN:ta86Nh8:a8Ua8XNaRaBN:ta86NhZa8Sa81NaRa8WN:ta86Nhna8Ua8WNaRa81N:ta86Nhca8WaBNa8Xa81N:tgRaRNa8Xa8YNa8VaBN:tgRaRNa8Va81Na8Wa8YN:tgRaRNMM:rJbbbZNhRa8Pahaa2g8JcdtfhOa8Pa8Aaa2g8McdtfhAa8PaLaa2gDcdtfhCa8Z:mhJa85:mh9ea83:mhTascjdfheaahQJbbbbhBJbbbbh86Jbbbbh8SJbbbbh8UJbbbbh8ZJbbbbh83Jbbbbh85Jbbbbh87JbbbbhUinaecwfaRa89aCIdbaOIdbg8Y:tg8XNa88aAIdba8Y:tg81NMg8VNUdbaeclfaRaZa8XNa8:a81NMg8WNUdbaeaRaca8XNana81NMg8XNUdbaecxfaRaJa8VNa9ea8WNa8YaTa8XNMMMg8YNUdbaRa8Va8WNNa8ZMh8ZaRa8Va8XNNa8UMh8UaRa8Wa8XNNa8SMh8SaRa8Ya8YNNaUMhUaRa8Va8YNNa87Mh87aRa8Wa8YNNa85Mh85aRa8Xa8YNNa83Mh83aRa8Va8VNNa86Mh86aRa8Wa8WNNaBMhBaRa8Xa8XNNa80Mh80aOclfhOaCclfhCaAclfhAaeczfheaQcufgQmbkagahc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyagaLc8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdyaga8Ac8S2fgea80aeIdbMUdbaeaBaeIdlMUdlaea86aeIdwMUdwaea8SaeIdxMUdxaea8UaeIdzMUdzaea8ZaeIdCMUdCaea83aeIdKMUdKaea85aeId3MUd3aea87aeIdaMUdaaeaUaeId8KMUd8KaeaRaeIdyMUdya8Ra8JcltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8RaDcltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8Ra8McltfhLcbhOaahCinaLaOfgeascjdfaOfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbkaYcifgYad6mbkkcbhAdndnamcwGgSmbJbbbbh86cbh9hcbh9icbh6xekcbh9ha3cbyd;y:L:cjbHjjjjbbh6asc:Cefasyd;8egecdtfa6BdbasaecefBd;8ecua6alabadaHz:fjjjbgCcltaCcjjjjiGEcbyd;y:L:cjbHjjjjbbh9iasc:Cefasyd;8egecdtfa9iBdbasaecefBd;8ea9iaCa6a8Kalz:gjjjbJFFuuh86aCTmba9iheaChOinaeIdbgRa86a86aR9EEh86aeclfheaOcufgOmbkaCh9hkdnalTmbaKclfheaKydbhCa5hOalhQcbhAincbaeydbgLaC9RaORbbcpeGEaAfhAaOcefhOaeclfheaLhCaQcufgQmbkaAce4hAkcuadaA9Rcifg9kcx2a9kc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbh0asc:Cefasyd;8egecdtfa0BdbasaecefBd;8ecua9kcdta9kcFFFFi0Ecbyd;y:L:cjbHjjjjbbh9masc:Cefasyd;8egecdtfa9mBdbasaecefBd;8ea3cbyd;y:L:cjbHjjjjbbh9nasc:Cefasyd;8egecdtfa9nBdbasaecefBd;8ealcbyd;y:L:cjbHjjjjbbh9oasc:Cefasyd;8egecdtfa9oBdbasaecefBd;8eaxaxNayJbbjZamclGEg9pa9pN:vh87JbbbbhUdnadak9nmbdna9kci6mbamcjdGh9qaaclth9ra0cwfh9sJbbbbh85JbbbbhUinascNefabadalaHz:cjjjbabh8Acbh3cbh9tinaba9tcdtfh8McbheindnaHa8AaefydbgAcdtghfydbgCaHa8Maec:W:G:cjbfydbcdtfydbgOcdtg8JfydbgQSmba5aOfRbbgYco2a5aAfRbbgLfRb;a:G:cjbg8LaLco2aYfgDRb;a:G:cjbg9cVcFeGTmbdnaQaC9nmbaDRb;W:G:cjbcFeGmekdnaLcufcFeGce0mbaYTmba8EahfydbaO9hmekdnaLTmbaYcufcFeGce0mba8Fa8JfydbaA9hmeka0a3cx2fgCaOaAa9ccFeGgQEBdlaCaAaOaQEBdbaCaQa8LGcb9hBdwa3cefh3kaeclfgecx9hmbkdna9tcifg9tad9pmba8Acxfh8Aa3cifa9k9nmekka3TmdcbhDinaIaHa0aDcx2fghydbgLcdtgCfydbg8Jc8S2fgeIdwa8KahydlgYcx2fgOIdwg8WNaeIdzaOIdbg8XNaeIdaMgRaRMMa8WNaeIdlaOIdlg8YNaeIdCa8WNaeId3MgRaRMMa8YNaeIdba8XNaeIdxa8YNaeIdKMgRaRMMa8XNaeId8KMMM:lhRJbbbbJbbjZaeIdyg8V:va8VJbbbb9BEh8Vdndnahydwg8MmbJFFuuhBxekJbbbbJbbjZaIaHaYcdtfydbc8S2fgeIdyg81:va81Jbbbb9BEaeIdwa8KaLcx2fgOIdwg81NaeIdzaOIdbg80NaeIdaMgBaBMMa81NaeIdlaOIdlgBNaeIdCa81NaeId3Mg81a81MMaBNaeIdba80NaeIdxaBNaeIdKMg81a81MMa80NaeId8KMMM:lNhBka8VaRNh80dnaaTmbagaLc8S2fgAIdwa8WNaAIdza8XNaAIdaMgRaRMMa8WNaAIdla8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaYaa2gQcdtfhOa8RaLaa2g8AcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEh8Sdndna8MmbJbbbbhRxekagaYc8S2fgAIdwa8KaLcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8AcdtfhOa8RaQcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEhRka80a8SMh80aBaRMhBdndndna5aLfRbbc9:fPibeedkdna8Fa8Ea8EaCfydbaYSEaXaCfydbgQcdtfydbgCcu9hmbaXaYcdtfydbhCkagaQc8S2fgAIdwa8KaCcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8PaCaa2g8AcdtfhOa8RaQaa2g8JcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEh8Sdndna8MmbJbbbbhRxekagaCc8S2fgAIdwa8KaQcx2fgeIdwg8WNaAIdzaeIdbg8XNaAIdaMgRaRMMa8WNaAIdlaeIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Pa8JcdtfhOa8Ra8AcltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaR:lgRa81aRa819DEaRa9qEhRka80a8SMh80aBaRMhBxdkaXaCfydbgCaLSmbaHaYcdtfydbh8Aindndna8EaCcdtgQfydbgecuSmbaHaecdtfydba8ASmekdna8FaQfydbgecuSmbaHaecdtfydba8ASmekaYhekagaCc8S2fgAIdwa8Kaecx2fgOIdwg8WNaAIdzaOIdbg8XNaAIdaMgRaRMMa8WNaAIdlaOIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Paeaa2cdtfhOa8RaCaa2cltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbka80aR:lgRa81aRa819DEaRa9qEMh80aXaQfydbgCaL9hmbkkdna5aYfRbbgeciSmbaecl9hmeka8MTmbaXaYcdtfydbgCaYSmbindndna8EaCcdtgQfydbgecuSmbaHaecdtfydba8JSmekdna8FaQfydbgecuSmbaHaecdtfydba8JSmekaLhekagaCc8S2fgAIdwa8Kaecx2fgOIdwg8WNaAIdzaOIdbg8XNaAIdaMgRaRMMa8WNaAIdlaOIdlg8YNaAIdCa8WNaAId3MgRaRMMa8YNaAIdba8XNaAIdxa8YNaAIdKMgRaRMMa8XNaAId8KMMMhRa8Paeaa2cdtfhOa8RaCaa2cltfheaAIdyh81aahAinaOIdbg8Va8Va81NaecxfIdba8WaecwfIdbNa8XaeIdbNa8YaeclfIdbNMMMg8Va8VM:tNaRMhRaOclfhOaeczfheaAcufgAmbkaBaR:lgRa81aRa819DEaRa9qEMhBaXaQfydbgCaY9hmbkkahaBa80aBa809DgeEUdwahaLaYaea8Mcb9hGgeEBdlahaYaLaeEBdbaDcefgDa39hmbkascjdfcbcj;qbz:xjjjb8Aa9shea3hOinascjdfaeydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbcefBdbaecxfheaOcufgOmbkcbhecbhOinascjdfaefgAydbhCaAaOBdbaCaOfhOaeclfgecj;qb9hmbkcbhea9shOinascjdfaOydbcA4cF8FGgAcFAaAcFA6EcdtfgAaAydbgAcefBdba9maAcdtfaeBdbaOcxfhOa3aecefge9hmbkadak9RgAci9Uh9udnalTmbcbhea9nhOinaOaeBdbaOclfhOalaecefge9hmbkkcbh9va9ocbalz:xjjjbh9caAcO9Uh9wa9uce4h9tcbh8Lcbh8Mdnina0a9ma8Mcdtfydbcx2fg8JIdwgRa879Emea8La9u9pmeJFFuuh8Vdna9ta39pmba0a9ma9tcdtfydbcx2fIdwJbb;aZNh8VkdnaRa8V9ETmbaRaU9ETmba8La9w0mdkdna9caHa8JydlgDcdtg9xfg8AydbgAfg9yRbba9caHa8Jydbghcdtg9zfydbgefg9ARbbVmba5ahfRbbh9BdndnaKaecdtfgOclfydbgCaOydbgOSmbaCaO9RhCa8KaAcx2fhLa8Kaecx2fhYaEaOcitfheindna9naeydbcdtfydbgOaASmba9naeclfydbcdtfydbgQaASmbaOaQSmba8KaQcx2fgQIdba8KaOcx2fgOIdbg8W:tgRaYIdlaOIdlg8X:tg80NaQIdla8X:tg8VaYIdba8W:tgBN:tg8YaRaLIdla8X:tg8SNa8VaLIdba8W:tg8UN:tg8XNa8VaYIdwaOIdwg81:tg8ZNaQIdwa81:tg8Wa80N:tg80a8VaLIdwa81:tg83Na8Wa8SN:tg8VNa8WaBNaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmikaecwfheaCcufgCmbkkdndna9Bc99fcFeGce0mba9na9zfaDBdbaXa9zfydbgeahSmeina8AydbhAdndna8EaecdtgOfydbgecuSmbaHaecdtfydbaASmekdna8FaOfydbgecuSmbaHaecdtfydbaASmekaDheka9naOfaeBdbaXaOfydbgeah9hmbxdkkdndna9BcFeGcdSmbaDhexekdna8Fa8Ea8Ea9zfydbaDSEaXa9zfydbghcdtfydbgecu9hmbaXa9xfydbheka9na9zfaDBdbka9nahcdtfaeBdbka9Ace86bba9yce86bba8JIdwgRaUaUaR9DEhUa9vcefh9vcecda9BcFeGceSEa8Lfh8Lxeka9tcefh9tka8Mcefg8Ma39hmbkka9vTmddnalTmbcbhLcbhhindna9nahcdtgefydbgAahSmbaHaAcdtfydbh8AdnahaHaefydb9hg8JmbaIa8Ac8S2fgeaIahc8S2fgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxaeaOIdzaeIdzMUdzaeaOIdCaeIdCMUdCaeaOIdKaeIdKMUdKaeaOId3aeId3MUd3aeaOIdaaeIdaMUdaaeaOId8KaeId8KMUd8KaeaOIdyaeIdyMUdya8NTmba8Na8Acltfgea8NahcltfgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxkaaTmbagaAc8S2fgeagahc8S2g8MfgOIdbaeIdbMUdbaeaOIdlaeIdlMUdlaeaOIdwaeIdwMUdwaeaOIdxaeIdxMUdxaeaOIdzaeIdzMUdzaeaOIdCaeIdCMUdCaeaOIdKaeIdKMUdKaeaOId3aeId3MUd3aeaOIdaaeIdaMUdaaeaOId8KaeId8KMUd8KaeaOIdyaeIdyMUdya9raA2hYa8RhOaahCinaOaYfgeaOaLfgAIdbaeIdbMUdbaeclfgQaAclfIdbaQIdbMUdbaecwfgQaAcwfIdbaQIdbMUdbaecxfgeaAcxfIdbaeIdbMUdbaOczfhOaCcufgCmbka8JmbJbbbbJbbjZaIa8MfgeIdygR:vaRJbbbb9BEaeIdwa8Ka8Acx2fgOIdwgRNaeIdzaOIdbg8VNaeIdaMg8Wa8WMMaRNaeIdlaOIdlg8WNaeIdCaRNaeId3MgRaRMMa8WNaeIdba8VNaeIdxa8WNaeIdKMgRaRMMa8VNaeId8KMMM:lNgRa85a85aR9DEh85kaLa9rfhLahcefghal9hmbkcbhOa8EheindnaeydbgAcuSmbdnaOa9naAcdtgCfydbgA9hmbcuhAa8EaCfydbgCcuSmba9naCcdtfydbhAkaeaABdbkaeclfhealaOcefgO9hmbkcbhOa8FheindnaeydbgAcuSmbdnaOa9naAcdtgCfydbgA9hmbcuhAa8FaCfydbgCcuSmba9naCcdtfydbhAkaeaABdbkaeclfhealaOcefgO9hmbkka85aUaaEh85cbhOabhecbhAindnaHa9naeydbcdtfydbgLcdtfydbgCaHa9naeclfydbcdtfydbgYcdtfydbgQSmbaCaHa9naecwfydbcdtfydbg8AcdtfydbghSmbaQahSmbabaOcdtfgCaLBdbaCcwfa8ABdbaCclfaYBdbaOcifhOkaecxfheaAcifgAad6mbkdndnaSmbaOhdxekdnaOak0mbaOhdxekdna86a859FmbaOhdxekJFFuuh86cbhdabhecbhAindna9ia6aeydbgCcdtfydbcdtfIdbgRa859ETmbaeclf8Pdbh9CabadcdtfgQaCBdbaQclfa9C83dbaRa86a86aR9EEh86adcifhdkaecxfheaAcifgAaO6mbkkadak0mbxdkkascNefabadalaHz:cjjjbkdndnadak0mbadhYxekdnaSmbadhYxekdna86a879FmbadhYxekcehQina86Jbb;aZNgRa87aRa879DEh8WJbbbbhRdna9hTmba9ihea9hhOinaeIdbg8VaRa8Va8W9FEaRa8VaR9EEhRaeclfheaOcufgOmbkkJFFuuh86cbhYabhecbhOindna9ia6aeydbgAcdtfydbcdtfIdbg8Va8W9ETmbaeclf8Pdbh9CabaYcdtfgCaABdbaCclfa9C83dba8Va86a86a8V9EEh86aYcifhYkaecxfheaOcifgOad6mbkdnaQaYad9hVceGmbadhYxdkaRaUaUaR9DEhUaYak9nmecbhQaYhda86a879FmbkkdnamcjjjjdGTmba9ocbalz:xjjjbh8AdnaYTmbabheaYhOina8AaeydbgAfce86bba8AaHaAcdtfydbfce86bbaeclfheaOcufgOmbkkascNefabaYalaHz:cjjjbdndnalTmbcbhCindna8AaCfRbbTmbdna5aCfRbbPlbeebekdnaHaCcdtgLfydbgeaCSmba8KaCcx2fgOa8Kaecx2fgeydwBdwaOae8Pdb83dbxekaIaCc8S2fgQIdygnanJL:3;rUNgRMh87aQIdwgxaRMh8SaQIdlg9DaRMh8UaQIdbg9EaRMh81aQIdag9FaRa8KaCcx2fg8JIdwg88N:th8ZaQId3g9GaRa8JIdlg89N:th83aQIdKg9Ha8JIdbg8:aRN:th80JbbbbhZaQIdCg9IJbbbbMh85aQIdzg9JJbbbbMhBaQIdxg9KJbbbbMh86dndnaaTmbaChAinJbbbba87agaAc8S2fgOIdygR:vaRJbbbb9BEhRa8RaAaa2cltfheaOIdaa87Na8ZMh8ZaOId3a87Na83Mh83aOIdKa87Na80Mh80aOIdCa87Na85Mh85aOIdza87NaBMhBaOIdxa87Na86Mh86aOIdwa87Na8SMh8SaOIdla87Na8UMh8UaOIdba87Na81Mh81aahOina8ZaecwfIdbg8VaecxfIdbg8YNaRN:th8Za83aeclfIdbg8Wa8YNaRN:th83a85a8Wa8VNaRN:th85a81aeIdbg8Xa8XNaRN:th81a80a8Xa8YNaRN:th80aBa8Xa8VNaRN:thBa86a8Xa8WNaRN:th86a8Sa8Va8VNaRN:th8Sa8Ua8Wa8WNaRN:th8UaeczfheaOcufgOmbkaXaAcdtfydbgAaC9hmbka8NTmba8NaCcltfgeIdxhTaeIdwhcaeIdlhJaeIdbhRxekJbbbbhTJbbbbhcJbbbbhJJbbbbhRkaBa81:vg8Wa80Na8Z:ta85aBa86a81:vg8VN:tg8Za8Ua86a8VN:tg8Y:vg8Xa8Va80Na83:tg8UN:th83acaRa8WN:taJaRa8VN:tg86a8XN:tg85a8SaBa8WN:ta8Za8XN:tgB:vg8S:mh8Za86a8Y:vgc:mhJdnJbbbbaRaRa81:vg9eN:ta86acN:ta85a8SN:tg86:la87J:983:g81NgR9ETmba8Za83NaJa8UNa9ea80NaT:tMMa86:vhZka81:laR9ETmba8Y:laR9ETmbaB:laR9ETmba9e:maZNa8W:ma8ZaZNa83aB:vMgBNa8V:maJaZNa8X:maBNa8Ua8Y:vMMg85Na80:ma81:vMMMh87aKaLfgeclfydbgOaeydbge9RhhaEaecitfhLJbbbbhRdnaOaeSg8MmbJbbbbhRaLheahhAina8Kaeclfydbcx2fgOIdwa88:tg8Va8VNaOIdba8::tg8Va8VNaOIdla89:tg8Va8VNMMg8Va8Kaeydbcx2fgOIdwa88:tg8Wa8WNaOIdba8::tg8Wa8WNaOIdla89:tg8Wa8WNMMg8WaRaRa8W9DEgRaRa8V9DEhRaecwfheaAcufgAmbkaR:rgRaRNhRkaBa88:tg8Va8VNa87a8::tg8Va8VNa85a89:tg8Va8VNMMaR9EmbaQId8KhZdna8Mmbina8KaLclfydbcx2fgeIdba8KaLydbcx2fgOIdbg8W:tgRa89aOIdlg8X:tg80NaeIdla8X:tg8Va8:a8W:tg86N:tg8YaRa85a8X:tg8SNa8Va87a8W:tg8UN:tg8XNa8Va88aOIdwg81:tg8ZNaeIdwa81:tg8Wa80N:tg80a8VaBa81:tg83Na8Wa8SN:tg8VNa8Wa86NaRa8ZN:tg81a8Wa8UNaRa83N:tgRNMMa8Ya8YNa80a80Na81a81NMMa8Xa8XNa8Va8VNaRaRNMMN:rJbbj8:N9FmdaLcwfhLahcufghmbkkJbbbbJbbjZan:vanJbbbb9BEgRaxaBNa9Ja87Na9FMg8Va8VMMaBNa9Da85Na9IaBNa9GMg8Va8VMMa85Na9Ea87Na9Ka85Na9HMg8Va8VMMa87NaZMMM:lNaRaxa88Na9Ja8:Na9FMg8Va8VMMa88Na9Da89Na9Ia88Na9GMg8Va8VMMa89Na9Ea8:Na9Ka89Na9HMg8Va8VMMa8:NaZMMM:lNJbb;aZNJ:983:g81M9Emba8JaBUdwa8Ja85Udla8Ja87UdbkaCcefgCal9hmbkdnaambcbhaxdkcbhQindna8AaQfRbbTmbaHaQcdtgefydbaQ9hmba5aQfhhaXaefh8Ja8KaQcx2fhAa8PaQaa2cdtfh8McbhEincuhCdnahRbbc99fcFeGce0mbaQhCa8JydbgeaQSmba8PaEcdtgOfhLa8MaOfIdbhRaQhCinaChOcuhCdnaLaeaa2cdtfIdbaR9CmbaOcuSmbaOhCagaec8S2fIdyagaOc8S2fIdy9ETmbaehCkaXaecdtfydbgeaQ9hmbkka8PaEcdtfhLa8RaEcltfhKaQheinaLaeaa2cdtfJbbbbJbbjZagaeaCaCcuSEgOc8S2fIdygR:vaRJbbbb9BEaKaOaa2cltfgOIdwaAIdwNaOIdbaAIdbNaOIdlaAIdlNMMaOIdxMNUdbaXaecdtfydbgeaQ9hmbkaEcefgEaa9hmbkkaQcefgQal9hmbxdkkaambcbhakaiavaoarawaaala8Ka8Pazasayasc1efa5a8Aaqz:hjjjbkdnamcjjjjlGTmbazmbaYTmbabhecbhLina5aeydbgAfRbbc3thQaecwfgXydbhHcjjjj94hCdna8EaAcdtgEfydbaeclfgKydbgOSmbcjjjj94cba8FaOcdtfydbaASEhCkaeaQaCVaAVBdba5aOfRbbc3thacjjjj94hCcjjjj94hQdna8EaOcdtfydbaHSmbcjjjj94cba8FaHcdtfydbaOSEhQkaKaaaQVaOVBdba5aHfRbbc3thOdna8EaHcdtfydbaASmbcjjjj94cba8FaEfydbaHSEhCkaXaOaCVaHVBdbaecxfheaLcifgLaY6mbkkdnazTmbaYTmbaYheinabazabydbcdtfydbBdbabclfhbaecufgembkkdnaPTmbaPa9paU:rNUdbkdnasyd;8egHTmbaHcdtasc:Ceffc98fheinaeydbcbyd;C:L:cjbH:bjjjbbaec98fheaHcufgHmbkkascj;sbf8KjjjjbaYk;Yieouabydlhvabydbclfcbaicdtz:xjjjbhoadci9UhrdnadTmbdnalTmbaehwadhDinaoalawydbcdtfydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbxdkkaehwadhDinaoawydbcdtfgqaqydbcefBdbawclfhwaDcufgDmbkkdnaiTmbcbhDaohwinawydbhqawaDBdbawclfhwaqaDfhDaicufgimbkkdnadci6mbinaecwfydbhwaeclfydbhDaeydbhidnalTmbalawcdtfydbhwalaDcdtfydbhDalaicdtfydbhikavaoaicdtfgqydbcitfaDBdbavaqydbcitfawBdlaqaqydbcefBdbavaoaDcdtfgqydbcitfawBdbavaqydbcitfaiBdlaqaqydbcefBdbavaoawcdtfgwydbcitfaiBdbavawydbcitfaDBdlawawydbcefBdbaecxfhearcufgrmbkkabydbcbBdbk:todDue99aicd4aifhrcehwinawgDcethwaDar6mbkcuaDcdtgraDcFFFFi0Ecbyd;y:L:cjbHjjjjbbhwaoaoyd9GgqcefBd9GaoaqcdtfawBdbawcFearz:xjjjbhkdnaiTmbalcd4hlaDcufhxcbhminamhDdnavTmbavamcdtfydbhDkcbadaDal2cdtfgDydlgwawcjjjj94SEgwcH4aw7c:F:b:DD2cbaDydbgwawcjjjj94SEgwcH4aw7c;D;O:B8J27cbaDydwgDaDcjjjj94SEgDcH4aD7c:3F;N8N27axGhwamcdthPdndndnavTmbakawcdtfgrydbgDcuSmeadavaPfydbal2cdtfgsIdbhzcehqinaqhrdnadavaDcdtfydbal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmlkarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbxdkkakawcdtfgrydbgDcuSmbadamal2cdtfgsIdbhzcehqinaqhrdnadaDal2cdtfgqIdbaz9CmbaqIdlasIdl9CmbaqIdwasIdw9BmikarcefhqakawarfaxGgwcdtfgrydbgDcu9hmbkkaramBdbamhDkabaPfaDBdbamcefgmai9hmbkkakcbyd;C:L:cjbH:bjjjbbaoaoyd9GcufBd9GdnaeTmbaiTmbcbhDaehwinawaDBdbawclfhwaiaDcefgD9hmbkcbhDaehwindnaDabydbgrSmbawaearcdtfgrydbBdbaraDBdbkabclfhbawclfhwaiaDcefgD9hmbkkk;:odvuv998Jjjjjbca9Rgocbyd1:G:cjbBdKaocb8Pdj:G:cjb83izaocbydN:G:cjbBdwaocb8Pd:m:G:cjb83ibdnadTmbaicd4hrdnabmbdnalTmbcbhwinaealawcdtfydbar2cdtfhDcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxikkarcdthwcbhDincbhiinaoczfaifgqaeaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaeawfheaDcefgDad9hmbxdkkdnalTmbcbhwinabawcx2fgiaealawcdtfydbar2cdtfgDIdbUdbaiaDIdlUdlaiaDIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkawcefgwad9hmbxdkkarcdthlcbhwaehDinabawcx2fgiaeawar2cdtfgqIdbUdbaiaqIdlUdlaiaqIdwUdwcbhiinaoczfaifgqaDaifIdbgkaqIdbgxaxak9EEUdbaoaifgqakaqIdbgxaxak9DEUdbaiclfgicx9hmbkaDalfhDawcefgwad9hmbkkJbbbbaoIdbaoIdzgx:tgkakJbbbb9DEgkaoIdlaoIdCgm:tgPaPak9DEgkaoIdwaoIdKgP:tgsasak9DEhsdnabTmbadTmbJbbbbJbbjZas:vasJbbbb9BEhkinabakabIdbax:tNUdbabclfgoakaoIdbam:tNUdbabcwfgoakaoIdbaP:tNUdbabcxfhbadcufgdmbkkdnavTmbavaPUdwavamUdlavaxUdbkask:WlewudnaeTmbcbhvabhoinaoavBdbaoclfhoaeavcefgv9hmbkkdnaiTmbcbhrinadarcdtfhwcbhDinalawaDcdtgvyd:G:G:cjbcdtfydbcdtfydbhodnalawavfydbcdtfydbgqabaqcdtfgkydbgvSmbinakabavgqcdtfgxydbgvBdbaxhkaqav9hmbkkdnaoabaocdtfgkydbgvSmbinakabavgocdtfgxydbgvBdbaxhkaoav9hmbkkdnaqaoSmbabaqaoaqao0Ecdtfaqaoaqao6EBdbkaDcefgDci9hmbkarcifgrai6mbkkdnaembcbskcbhxindnalaxcdtgvfydbax9hmbaxhodnaxabavfgDydbgvSmbaDhqinaqabavgocdtfgkydbgvBdbakhqaoav9hmbkkaDaoBdbkaxcefgxae9hmbkcbhkabhvcbhoindndnaoalydbgq9hmbdnaoavydbgq9hmbavakBdbakcefhkxdkavabaqcdtfydbBdbxekavabaqcdtfydbBdbkalclfhlavclfhvaeaocefgo9hmbkakk;jiilud99euabcbaecltz:xjjjbhvdnalTmbadhoaihralhwinarcwfIdbhDarclfIdbhqavaoydbcltfgkarIdbakIdbMUdbakaqakIdlMUdlakaDakIdwMUdwakakIdxJbbjZMUdxaoclfhoarcxfhrawcufgwmbkkdnaeTmbavhkaehrinakcxfgoIdbhDaocbBdbakakIdbJbbbbJbbjZaD:vaDJbbbb9BEgDNUdbakclfgoaDaoIdbNUdbakcwfgoaDaoIdbNUdbakczfhkarcufgrmbkkdnalTmbinavadydbcltfgkaicwfIdbakIdw:tgDaDNaiIdbakIdb:tgDaDNaiclfIdbakIdl:tgDaDNMMgDakIdxgqaqaD9DEUdxadclfhdaicxfhialcufglmbkkdnaeTmbavcxfhkinabakIdbUdbakczfhkabclfhbaecufgembkkk:moerudnaoTmbaecd4hzdnavTmbaicd4hHavcdthOcbhAindnaPaAfRbbTmbaAhednaDTmbaDaAcdtfydbhekdnasTmbasaefRbbceGmekdnamaAfRbbcvSmbabaeaz2cdtfgiaraAcx2fgCIdbakNaxIdbMUdbaiaCIdlakNaxIdlMUdlaiaCIdwakNaxIdwMUdwkadaeaH2cdtfhXaqheawhiavhCinaXaeydbcdtgQfaiIdbalaQfIdb:vUdbaeclfheaiclfhiaCcufgCmbkkawaOfhwaAcefgAao9hmbxdkkdnasmbcbheaDhiindnaPaefRbbTmbaehCdnaDTmbaiydbhCkamaefRbbcvSmbabaCaz2cdtfgCarIdbakNaxIdbMUdbaCarclfIdbakNaxIdlMUdlaCarcwfIdbakNaxIdwMUdwkaiclfhiarcxfhraoaecefge9hmbxdkkdnaDTmbindnaPRbbTmbasaDydbgefRbbceGmbamRbbcvSmbabaeaz2cdtfgearIdbakNaxIdbMUdbaearclfIdbakNaxIdlMUdlaearcwfIdbakNaxIdwMUdwkaPcefhPaDclfhDamcefhmarcxfhraocufgombxdkkazcdthicbheindnaPaefRbbTmbasaefRbbceGmbamaefRbbcvSmbabarIdbakNaxIdbMUdbabclfarclfIdbakNaxIdlMUdbabcwfarcwfIdbakNaxIdwMUdbkarcxfhrabaifhbaoaecefge9hmbkkk8MbabaeadaialavcbcbcbcbcbaoarawaDz:bjjjbk8MbabaeadaialavaoarawaDaqakaxamaPz:bjjjbkRbababaeadaialavaoarawaDaqakaxcjjjjdVamz:bjjjbk:vgoque99due99duq998Jjjjjbc;Wb9Rgq8Kjjjjbcbhkaqcxfcbc;Kbz:xjjjb8Aaqcualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbgxBdxaqceBd2axaialavcbcbz:ejjjb8AaqcualcdtalcFFFFi0Egmcbyd;y:L:cjbHjjjjbbgiBdzaqcdBd2dndnJFF959eJbbjZawJbbjZawJbbjZ9DE:vawJ9VO:d869DEgw:lJbbb9p9DTmbaw:OhPxekcjjjj94hPkadci9Uhsarco9UhzdndnaombaPcd9imekdnalTmbaPcuf:YhwdnaoTmbcbhvaihHaxhOindndnaoavfRbbceGTmbavcjjjjlVhAxekdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHaOcxfhOalavcefgv9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkadTmbcbhkaehvcbhOinakaiavclfydbcdtfydbgHaiavcwfydbcdtfydbgA9haiavydbcdtfydbgXaH9haXaA9hGGfhkavcxfhvaOcifgOad6mbkkarci9UhQdndnaz:Z:rJbbbZMgw:lJbbb9p9DTmbaw:Ohvxekcjjjj94hvkaQ:ZhLcbhKc:bwhzdninakaQ9pmeazaP9Rcd9imeavazcufgOavaO9iEaPcefavaP9kEhYdnalTmbaYcuf:YhwdnaoTmbcbhOaihHaxhvindndnaoaOfRbbceGTmbaOcjjjjlVhAxekdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcqthAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXVhAdndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaAaXcCtVhAkaHaABdbaHclfhHavcxfhvalaOcefgO9hmbxdkkaxhvaihOalhHindndnavIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhAxekcjjjj94hAkaAcCthAdndnavclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqtaAVhAdndnavcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaOaAaXVBdbavcxfhvaOclfhOaHcufgHmbkkcbhOdnadTmbaehvcbhHinaOaiavclfydbcdtfydbgAaiavcwfydbcdtfydbgX9haiavydbcdtfydbgraA9haraX9hGGfhOavcxfhvaHcifgHad6mbkkdnas:ZgCaL:taY:Ygwaz:Y:tg8ANak:ZgEaO:Zg3:tNaEaL:tawaP:Y:tg5Na3aC:tNMg8EJbbbb9BmbaCaE:ta5a8Aa3aL:tNNNa8E:vawMhwkdndnaOaQ0mbaOhkaYhPxekaOhsaYhzkdndnaKcl0mbdnawJbbbZMgw:lJbbb9p9DTmbaw:Ohvxdkcjjjj94hvxekaPazfcd9ThvkaKcefgKcs9hmbkkdndndnakmbJbbjZhwcbhOcdhvaDmexdkalcd4alfhHcehOinaOgvcethOavaH6mbkaqcuavcdtavcFFFFi0Ecbyd;y:L:cjbHjjjjbbgYBdCaqciBd2aqamcbyd;y:L:cjbHjjjjbbgzBdKaqclBd2dnalTmbaPcuf:YhwdnaoTmbcbhOaihAaxhHindndnaoaOfRbbceGTmbaOcjjjjlVhXxekdndnaHclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcqthXdndnaHcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarVhXdndnaHIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaXarcCtVhXkaAaXBdbaAclfhAaHcxfhHalaOcefgO9hmbxdkkaxhOaihHalhAindndnaOIdbawNJbbbZMgC:lJbbb9p9DTmbaC:OhXxekcjjjj94hXkaXcCthXdndnaOclfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkarcqtaXVhXdndnaOcwfIdbawNJbbbZMgC:lJbbb9p9DTmbaC:Ohrxekcjjjj94hrkaHaXarVBdbaOcxfhOaHclfhHaAcufgAmbkkaqcuaYavazaialz:mjjjbgXc8S2gvaXc;D;O;f8U0Ecbyd;y:L:cjbHjjjjbbgiBd3aqcvBd2aicbavz:xjjjbhOdnadTmbcbhraehiinaxaiclfydbgocx2fgvIdbaxaiydbgPcx2fgHIdbg3:tgCaxaicwfydbgYcx2fgAIdlaHIdlg8A:tgwNavIdla8A:tgEaAIdba3:tg8EN:tgLaLNaEaAIdwaHIdwg5:tg8FNavIdwa5:tgEawN:tgwawNaEa8ENaCa8FN:tgCaCNMMg8E:rhEJbbnnJbbjZazaPcdtfydbgvazaocdtfydbgASavazaYcdtfydbgoSGgHEh8Fdna8EJbbbb9ETmbaLaE:vhLaCaE:vhCawaE:vhwkaOavc8S2fgvavIdbawa8FaE:rNgEawNNg8FMUdbavaCaEaCNgaNghavIdlMUdlavaLaEaLNg8ENggavIdwMUdwavawaaNgaavIdxMUdxava8EawNg8JavIdzMUdzavaCa8ENg8EavIdCMUdCavawaEaLa5Nawa3Na8AaCNMM:mg8ANg3NgwavIdKMUdKavaCa3NgCavId3MUd3avaLa3NgLavIdaMUdaava3a8ANg3avId8KMUd8KavaEavIdyMUdydnaHmbaOaAc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdyaOaoc8S2fgva8FavIdbMUdbavahavIdlMUdlavagavIdwMUdwavaaavIdxMUdxava8JavIdzMUdzava8EavIdCMUdCavawavIdKMUdKavaCavId3MUd3avaLavIdaMUdaava3avId8KMUd8KavaEavIdyMUdykaicxfhiarcifgrad6mbkkcbhAaqcuaXcdtgvaXcFFFFi0Egicbyd;y:L:cjbHjjjjbbgHBdaaqcoBd2aqaicbyd;y:L:cjbHjjjjbbgiBd8KaqcrBd2aHcFeavz:xjjjbhPdnalTmbazhHinJbbbbJbbjZaOaHydbgrc8S2fgvIdygw:vawJbbbb9BEavIdwaxcwfIdbgwNavIdzaxIdbgCNavIdaMgLaLMMawNavIdlaxclfIdbgLNavIdCawNavId3MgwawMMaLNavIdbaCNavIdxaLNavIdKMgwawMMaCNavId8KMMM:lNhwdndnaParcdtgvfgrydbcuSmbaiavfIdbaw9ETmekaraABdbaiavfawUdbkaHclfhHaxcxfhxalaAcefgA9hmbkkdndnaXmbJbbbbhwxekJbbbbhwinaiIdbgCawawaC9DEhwaiclfhiaXcufgXmbkaw:rhwkakcd4akfhOcehiinaigvcethiavaO6mbkcbhOaqcuavcdtgiavcFFFFi0Ecbyd;y:L:cjbHjjjjbbgHBdyaHcFeaiz:xjjjbhXdnadTmbavcufhrcbhkcbhxindnazaeaxcdtfgvydbcdtfydbgiazavclfydbcdtfydbgOSmbaiazavcwfydbcdtfydbgvSmbaOavSmbaPavcdtfydbhAdndnaPaOcdtfydbgvaPaicdtfydbgi9pmbavaA9pmbaAhlaihoavhAxekdnaAai9pmbaAav9pmbaihlavhoxekavhlaAhoaihAkabakcx2fgvaABdbavcwfaoBdbavclfalBdbdnaXaoc:3F;N8N2alc:F:b:DD27aAc;D;O:B8J27arGgOcdtfgvydbgicuSmbcehHinaHhvdnabaicx2fgiydbaA9hmbaiydlal9hmbaiydwaoSmikavcefhHaXaOavfarGgOcdtfgvydbgicu9hmbkkavakBdbakcefhkkaxcifgxad6mbkakci2hOkcwhvaDTmekaDawUdbkavcdthvaqcxfc98fhiinaiavfydbcbyd;C:L:cjbH:bjjjbbavc98fgvmbkaqc;Wbf8KjjjjbaOk:0iewuabcFeaecdtz:xjjjbhbdnalmbcbskaecufhvdndnaiTmbcbhocbhrindndndnabaiarcdtgwfydbgDcm4aD7c:v;t;h;Ev2gecs4ae7avGgqcdtfgkydbgxcuSmbceheinaiaxcdtgxfydbaDSmdaqaefhxaecefheabaxavGgqcdtfgkydbgxcu9hmbkkakarBdbaoheaocefhoxekadaxfydbhekadawfaeBdbarcefgral9hmbxdkkcbhocbhDindnabaDcm4aD7c:v;t;h;Ev2gecs4ae7avGgqcdtfgkydbgxcuSmbaxaDSmbceheinabaqaefavGgqcdtfgkydbgxcuSmeaecefheaxaD9hmbkkdndnaxcu9hmbakaDBdbaoheaocefhoxekadaxcdtfydbhekadaDcdtfaeBdbaDcefgDal9hmbkkaok:3ldrue9:8Jjjjjbc;Wb9Rgr8Kjjjjbcbhwarcxfcbc;Kbz:xjjjb8AdnabaeSmbabaeadcdtz:wjjjb8AkarcualcdtalcFFFFi0EgDcbyd;y:L:cjbHjjjjbbgqBdxarceBd2aqcbaialavcbarcxfz:djjjbcualcx2alc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbhkarcxfaryd2gxcdtfakBdbaraxcefgmBd2akaialavcbcbz:ejjjb8AarcxfamcdtfaDcbyd;y:L:cjbHjjjjbbgiBdbaraxcdfgvBd2arcxfavcdtfcuaialaeadaqz:fjjjbgecltaecjjjjiGEcbyd;y:L:cjbHjjjjbbgqBdbaqaeaiakalz:gjjjbaxcifhkdnadTmbaoaoNhocbhwabhlcbheindnaqaialydbgvcdtfydbcdtfIdbao9ETmbalclf8PdbhPabawcdtfgDavBdbaDclfaP83dbawcifhwkalcxfhlaecifgead6mbkkdnakTmbaxcdtarcxffcwfhlinalydbcbyd;C:L:cjbH:bjjjbbalc98fhlakcufgkmbkkarc;Wbf8Kjjjjbawk;lOoDud99oue99vuv998Jjjjjbc;Wb9Rgw8KjjjjbdndnarmbcbhDxekawcxfcbc;Kbz:xjjjb8Aawcuadcx2adc;v:Q;v:Qe0Ecbyd;y:L:cjbHjjjjbbgqBdxawceBd2aqaeadaicbcbz:ejjjb8AawcuadcdtadcFFFFi0Egkcbyd;y:L:cjbHjjjjbbgxBdzawcdBd2adcd4adfhecehiinaigmcethiamae6mbkcbhPawcuamcdtgsamcFFFFi0Ecbyd;y:L:cjbHjjjjbbgzBdCawciBd2dndnar:ZgH:rJbbbZMgO:lJbbb9p9DTmbaO:Ohixekcjjjj94hikamcufhAc:bwhCcbhXadhQcbhLinaiaCcufgeaiae9iEaPcefaiaP9kEhDdndnadTmbaDcuf:YhOaqhiaxheadhKindndnaiIdbaONJbbbZMgY:lJbbb9p9DTmbaY:Oh8Axekcjjjj94h8Aka8AcCth8AdndnaiclfIdbaONJbbbZMgY:lJbbb9p9DTmbaY:OhExekcjjjj94hEkaEcqta8AVh8AdndnaicwfIdbaONJbbbZMgY:lJbbb9p9DTmbaY:OhExekcjjjj94hEkaea8AaEVBdbaicxfhiaeclfheaKcufgKmbkazcFeasz:xjjjbh3cbh5cbh8Eindna3axa8Ecdtfydbg8Acm4a8A7c:v;t;h;Ev2gics4ai7aAGgKcdtfgEydbgecuSmbaea8ASmbcehiina3aKaifaAGgKcdtfgEydbgecuSmeaicefhiaea8A9hmbkkaEa8ABdba5aecuSfh5a8Ecefg8Ead9hmbxdkkazcFeasz:xjjjb8Acbh5kdnaQ:ZgYaH:taD:YgOaC:Y:tg8FNaX:Zgaa5:Zgh:tNaaaH:taOaP:Y:tggNahaY:tNMg8JJbbbb9BmbaYaa:taga8FahaH:tNNNa8J:vaOMhOkaPaDa5ar0geEhPaXa5aeEhXdna5arSmbaDaCaeEgCaP9Rcd9imbdndnaLcl0mbdnaOJbbbZMgO:lJbbb9p9DTmbaO:Ohixdkcjjjj94hixekaPaCfcd9Thika5aQaeEhQaLcefgLcs9hmekkdndnaXmbcihicbhDxekawakcbyd;y:L:cjbHjjjjbbg8ABdKawclBd2aPcuf:YhYdnadTmbaqhiaxheadhKindndnaiIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:OhExekcjjjj94hEkaEcCthEdndnaiclfIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:Oh3xekcjjjj94h3ka3cqtaEVhEdndnaicwfIdbaYNJbbbZMgO:lJbbb9p9DTmbaO:Oh3xekcjjjj94h3kaeaEa3VBdbaicxfhiaeclfheaKcufgKmbkkawcuazama8Aaxadz:mjjjbgDc32giaDc;j:KM;jb0Ecbyd;y:L:cjbHjjjjbbgeBd3awcvBd2aecbaiz:xjjjbh3avcd4hxdnadTmbdnalTmbaxcdth8Ea8AhEaqhealhKadhAina3aEydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaKIdbaiIdxMUdxaiaKclfIdbaiIdzMUdzaiaKcwfIdbaiIdCMUdCaiaiIdKJbbjZMUdKaEclfhEaecxfheaKa8EfhKaAcufgAmbxdkka8AhKaqheadhEina3aKydbc32fgiaeIdbaiIdbMUdbaiaeclfIdbaiIdlMUdlaiaecwfIdbaiIdwMUdwaiaiIdxJbbbbMUdxaiaiIdzJbbbbMUdzaiaiIdCJbbbbMUdCaiaiIdKJbbjZMUdKaKclfhKaecxfheaEcufgEmbkkdnaDTmba3hiaDheinaiaiIdbJbbbbJbbjZaicKfIdbgO:vaOJbbbb9BEgONUdbaiclfgKaOaKIdbNUdbaicwfgKaOaKIdbNUdbaicxfgKaOaKIdbNUdbaiczfgKaOaKIdbNUdbaicCfgKaOaKIdbNUdbaic3fhiaecufgembkkcbhEawcuaDcdtgCaDcFFFFi0Egicbyd;y:L:cjbHjjjjbbgeBdaawcoBd2awaicbyd;y:L:cjbHjjjjbbg8EBd8KaecFeaCz:xjjjbh5dnadTmbaoJbbjZJbbjZaY:vaPceSENgOaONhYaxcdthxalheinaYaecN:H:cjbalEgKIdwa3a8AydbgAc32fgiIdC:tgOaONaKIdbaiIdx:tgOaONaKIdlaiIdz:tgOaONMMNaqcwfIdbaiIdw:tgOaONaqIdbaiIdb:tgOaONaqclfIdbaiIdl:tgOaONMMMhOdndna5aAcdtgifgKydbcuSmba8EaifIdbaO9ETmekaKaEBdba8EaifaOUdbka8Aclfh8AaqcxfhqaeaxfheadaEcefgE9hmbkkaba5aCz:wjjjb8Acrhikaicdthiawcxfc98fheinaeaifydbcbyd;C:L:cjbH:bjjjbbaic98fgimbkkawc;Wbf8KjjjjbaDk:Pdidui99ducbhi8Jjjjjbca9Rglcbyd1:G:cjbBdKalcb8Pdj:G:cjb83izalcbydN:G:cjbBdwalcb8Pd:m:G:cjb83ibdndnaembJbbjFhvJbbjFhoJbbjFhrxekadcd4cdthwincbhdinalczfadfgDabadfIdbgvaDIdbgoaoav9EEUdbaladfgDavaDIdbgoaoav9DEUdbadclfgdcx9hmbkabawfhbaicefgiae9hmbkalIdwalIdK:thralIdlalIdC:thoalIdbalIdz:thvkJbbbbavavJbbbb9DEgvaoaoav9DEgvararav9DEk:H8Modui99lud99Aus998Jjjjjbcji9RgD8KjjjjbcbhqaDcxfcbc;Kbz:xjjjb8AaDcbBdwaD9cb83ibaDcbyd;i:L:cjbBd1eaDcb8Pd;a:L:cjb83ijeaDcbyd;u:L:cjbBd94aDcb8Pd;m:L:cjb83i9WdndnavmbJbbjFhkJbbjFhxJbbjFhmxekaocd4cdthPalhsincbhzinaDcjefazfgHasazfIdbgkaHIdbgxaxak9EEUdbaDc;WbfazfgHakaHIdbgxaxak9DEUdbazclfgzcx9hmbkasaPfhsaqcefgqav9hmbkaDId94aDId1e:thmaDIdtaDId:ee:thxaDId9WaDIdje:thkkJbbbbhOdnar:YgAJq;x8J88MaA:vJbbbbakakJbbbb9DEgkaxaxak9DEgkamamak9DENgxJbbbb9Bmbarc9:f:Yax:vhOkaDcCfhCaDcxfcxfhXcbhzinaDazfaDcjefazfIdbgkaxaDc;WbfazfIdbak:t:tJbbb:;NMUdbazclfgzcx9hmbkcbhQaDarar2gLar2gzcbyd;y:L:cjbHjjjjbbgHBdxaDceBd2aHcbazz:xjjjbgKcbcbadaialaoaraOaDawz:rjjjbcdhYaDcuaLcdtaLcFFFFi0Eg8Acbyd;y:L:cjbHjjjjbbgEBdzaDcdBd2aDcjefcbarz:xjjjb8Acbh3dnaLTmbdnarcb9kmbaKhzaEhHaLhsincbh3aHcbcuazaDcjefarz:AjjjbEBdbazarfhzaHclfhHascufgsmbxdkkaKhPcbh3cbhvindndnaKavar2faDcjefarz:AjjjbTmbcbhHaPhzarhsinazaHazRbbgqfgHcbaqE86bbazcefhzascufgsmbkaEavcdtfa3BdbaHa3fh3xekaEavcdtfcuBdbkaParfhPavcefgvaL9hmbkkdnabTmbaDcua3cotgza3cFFF8F0Ecbyd;y:L:cjbHjjjjbbgQBdCcihYaDciBd2aQcbazz:xjjjb8AaXhCkdnawceGmbaCa8Acbyd;y:L:cjbHjjjjbbg5BdbaDaYcefgzBd2aDcxfazcdtfaLcbyd;y:L:cjbHjjjjbbgzBdbaDaYcdfgYBd2azcbaLz:xjjjbh8EarcufhXdnarci9imbarc9:fhCararcef2aKfcefh8Aceh8Fina8Far2hPa8AhvcehqindnaEaqaPfcdtfydbcuSmbavhzaChHinazazRbbgscuasE86bbazcefhzaHcufgHmbkkavarfhvaqcefgqaX9hmbka8AaLfh8Aa8Fcefg8FaX9hmbkkarce9imbcbh8Acbhqcbhvina8EaqfhscbhzindnasazfgHRbbmbaHce86bba5a8AcdtfaqazfBdba8Acefh8Akarazcefgz9hmbkaqarfhqavcefgvar9hmbka8ATmbaKcefhaaKc9:fhharc9:fhgarci9ih8Jina8Ea5a8Acufg8Acdtfydbgvfcb86bbavar2hPdna8JmbaEavcdtfydbcuSmbaKaPfhHaghqindnaHcefgzRbbgscFe9hmbaHRbbmbcbhskazas86bbazhHaqcufgqmbkaharavcef2fhzaXhsindnazRbbgHcFe9hmbazcefRbbmbcbhHkazaH86bbazcufhzascufgsce9kmbkkaaaPfh8Kavavar9Ug8Lar29Rh8FcbhCindnaCceScuaCEa8Ffgzce9imbazaX9ombcuaCciSaCcdSEa8LfgHce9imbaHaX9ombaEaHar2azfg8McdtfydbcuSmba8Jmbaaa8Mar2fhzcbhqa8KhsaghvinazazRbbgHcbaHaHcFeSEasRbbEgP86bbascefhsazcefhzaPaH7aqVhqavcufgvmbkaqcFeGTmba8Ea8MfgzRbbmbazce86bba5a8Acdtfa8MBdba8Acefh8AkaCcefgCcl9hmbka8AmbkkdnaQTmbaKaEaQadaialaoaraOaDawz:rjjjba3TmbJbbjZaO:vhkawcjjjjlGhPdnawcdGTmbJbbnnaOaON:vh8NakJbbbZNhyaQhzinazczfgsIdbg8PazcCfIdbgx:vhmazcxfgqIdbgIax:vhAazcwfgvIdbg8Rax:vh8SakazydbgHcFrG:ZNhRakaHcq4cFrG:ZNh8UakaHcC4cFrG:ZNh8VdnaxJ:p;c;188Ng8WazcKfIdbMg8X:laxJ:983:g81Ngx9ETmba8Wazc3fIdbMazc8KfIdbg8Ya8Ya8X:vg8YN:tg8Z:lax9ETmba8WazcafIdbMazcyfIdbg8Wa8Wa8X:vg80N:tazc8SfIdba8Wa8YN:tg8Wa8Wa8Z:vg8WN:tg81:lax9ETmba8PJ:p;c;188NazcUfIdb:ta80a8RJ:p;c;188Nazc8WfIdb:tg8PN:ta8WaIJ:p;c;188Nazc80fIdb:ta8Ya8PN:tgIN:ta81:vgxam:tg8Ra8RNa8Pa8X:va8YaIa8Z:va8WaxN:tg8XN:ta80axN:tg8Wa8S:tg8Ya8YNa8XaA:tg8Ya8YNMMa8N9DTmbaxaRaxaR9EEgxakaRMgmaxam9DEhma8Xa8Ua8Xa8U9EEgxaka8UMgAaxaA9DEhAa8Wa8Va8Wa8V9EEgxaka8VMg8Saxa8S9DEh8SkdnaPTmbayaRMhmaya8UMhAaya8VMh8SkasamUdbaqaAUdbava8SUdbazc;abfhza3cufg3mbxdkkdnaPTmbakJbbbZNhxaQhzinazczfaxakazydbgHcFrG:ZNMUdbazcxfaxakaHcq4cFrG:ZNMUdbazcwfaxakaHcC4cFrG:ZNMUdbazc;abfhza3cufg3mbxdkkaQcCfhzinazc98fgHaHIdbazIdbgk:vUdbazc94fgHaHIdbak:vUdbazctfgHaHIdbak:vUdbazc;abfhza3cufg3mbkkcbhsdndnarcd9imbarcufh3aEarcdtfhadnabmbaKcefg8Mararcefgz2fh8JaKazfhba8MaLfh8Ecbhscbh8Kina8Kar2h8La8Mheabh8Aa8Eh8Fa8Jh5cbhXindnaEaXa8LfgqcdtgzfgHclfydbaHydbGaaazfgzydbGazclfydbGcuSmbclcbaKaqar2fgzarfRbbEazRbbcb9hVczcbazaLfgzRbbEVc;abcbazarfRbbEVhPaehza8AhHa8Fhqa5hva3hQindnaPclcbaHRbbEazRbbcb9hVczcbaqRbbEVc;abcbavRbbEVgPcetVgCTmbaCcFeSmbasaCRb;W;p:cjbfhskazcefhzaHcefhHaqcefhqavcefhvaQcufgQmbkkaearfhea8Aarfh8Aa8Farfh8Fa5arfh5aXcefgXa39hmbka8MaLfh8MabaLfhba8EaLfh8Ea8JaLfh8Ja8Kcefg8Ka39hmbxdkkJbbjZaO:vgkakJk;x8J88NNh8RawcdGh8EaDIdwhkaDIdlhxaDIdbhmcbhscbhPinaPar2h8KcbhvindnaEava8KfgqcdtgzfgHclfydbaHydbGaaazfgzydbGazclfydbGcuSmbcbh8AclcbaKaqar2fgYarfRbbEaYRbbcb9hVczcbaYaLfg8JRbbEVc;abcba8JarfRbbEVh8Lindna8LclcbaYa8Ag8Mcefg8AfgzarfRbbEazRbbcb9hVczcba8Ja8AfgzRbbEVc;abcbazarfRbbEVg8LcetVgCTmbaCcFeSmbcbhqdndndnaCRb;W;n:cjbcufPdebdka8ETmeaCcC2gz8Ve;W:L:cjbcltaz8Ve;Y:L:cjbcsGVh8FaKa8Mfh5cxhzaDcjefhHinaHaQaEa8Faz4gqce4ceGavfaqcd4ceGaPfar2fgXcdtfydbcotfa5aqceGfaXar2fRbbcotfcnfBdbaHclfhHazc98fgzc989hmbkaDydjegzIdyaDyd:megHIdyMaDyd:eegqIdyaDyd1egXIdyMMg8XaqIdwaXIdwMJbbbZNgANazIdUaHIdUMaqIdUaXIdUMMg8WMg8Sa8SMazIdaaHIdaMaqIdaaXIdaMMg8YaqIdzaXIdzMJbbbZNg8SNMa8SNazId8SaHId8SMaqId8SaXId8SMMgRa8SNazId80aHId80MaqId80aXId80MMg8UMg8Sa8SMazId3aHId3MaqId3aXId3MMg8VaqIdxaXIdxMJbbbZNg8SNMa8SNazId8KaHId8KMaqId8KaXId8KMMg8Za8SNazId8WaHId8WMaqId8WaXId8WMMg80Mg8Sa8SMazIdKaHIdKMaqIdKaXIdKMMgyaANMaANazId88aHId88MaqId88aXId88MMg8PMMM:lgIa8RazIdCaHIdCMaqIdCaXIdCMMN9Ea8XazIdwaHIdwMJbbbZNgANa8WMg8Sa8SMa8YazIdzaHIdzMJbbbZNg8SNMa8SNaRa8SNa8UMg8Sa8SMa8VazIdxaHIdxMJbbbZNg8SNMa8SNa8Za8SNa80Mg8Sa8SMayaANMaANa8PMMM:laIJ;d;1UZN9DGhqxekaKa8Mfh8FcbhzcrhHindnaCaz4ceGTmba8FazceGfazce4ceGavfazcd4aPfar2fgqar2fRbbgXcFeSmbaQaEaqcdtfydbcotfaXcotfc9efRbbaH4ceGTmbcbhqxdkaHcufhHcehqazcefgzcw9hmbkkaCcC2aqcq2fgH8Ve;W:L:cjbgzTmbaHc;Y:L:cjbfhqaKa8MfhCabasc8K2fhHindnasae9pmbaHaQaEazcD4ceGavfazcq4ceGaPfar2fgXcdtfydbcotfaCazcw4ceGfaXar2fRbbcotfgXc9ifIdbamMUdbaHclfaXc9mfIdbaxMUdbaHcwfaXc9qfIdbakMUdbaHcxfamaQaEazcv4ceGavfazco4ceGaPfar2fgXcdtfydbcotfaCazcl4ceGfaXar2fRbbcotfgXc9ifIdbMUdbaHczfaxaXc9mfIdbMUdbaHcCfakaXc9qfIdbMUdbaHcKfamaQaEazce4ceGavfazcd4ceGaPfar2fgXcdtfydbcotfaCazceGfaXar2fRbbcotfgzc9ifIdbMUdbaHc3faxazc9mfIdbMUdbaHcafakazc9qfIdbMUdbkaHc8KfhHascefhsaq8Vebhzaqcdfhqazmbkka8Aa39hmbkkavcefgva39hmbkaPcefgPa39hmbkaDyd2gYTmekaYcdtaDcxffc98fhzinazydbcbyd;C:L:cjbH:bjjjbbazc98fhzaYcufgYmbkkaDcjif8Kjjjjbask;Kxmiue99due99euz99eui99eud99dud99oudnalTmbaocd4hkaqcdGhxarc99fhqarcethmawawMhPcbhsindndnawavaiascdtfgoclfydbak2cdtfgzIdwgHavaoydbak2cdtfgOIdwgA:tgCaCNazIdbgXaOIdbgQ:tgLaLNazIdlgKaOIdlgY:tg8Aa8ANMMgEavaocwfydbak2cdtfgoIdwg3aA:tg5a5NaoIdbg8EaQ:tg8Fa8FNaoIdlgaaY:tghahNMMggaEag9EEgEa3aH:tgHaHNa8EaX:tgHaHNaaaK:tgHaHNMMgHaEaH9EE:rNgHaHMgH:lJbbb9p9DTmbaH:Ohoxekcjjjj94hokdnaLahNa8Aa8FN:tgHaHNa8Aa5NaCahN:tgXaXNaCa8FNaLa5N:tgKaKNMMg3Jbbbb9BmbJbbjZhEdnaoceaoce9kEgoamaoam9iEg8Jcd9imbJbbjZa8J:Z:vhEkarcb9imbaAaDIdw:th8KaYaDIdl:th8LaQaDIdb:th8Ma8Jcba8Jcb9kEh8NdnadTmbaHJbbjZa3:rgA:vgQNg3aAa8Jcefa8Jcdf2:Y:vgANh8EaKaQNgKaANhyaXaQNgXaXaANNh8PcbhIina8Jcba8Jcb9kEcefh8RaEaI:ZNgQaCNa8KMhgaQa8ANa8LMh8SaQaLNa8MMhRcbhzindndnaPaEaz:ZNgQahNa8SMgYNgH:lJbbb9p9DTmbaH:OhOxekcjjjj94hOkaOce91goaqaoaq6Eh8UdndnaPaQa5NagMgHNga:lJbbb9p9DTmbaa:Oh8Vxekcjjjj94h8Vka8Ua8Vce91goaqaoaq6Eg8Wcefar2fcefgoar2h8XdndnaPaQa8FNaRMgQNga:lJbbb9p9DTmbaa:Oh8Yxekcjjjj94h8Ykadaeaocdtfydbcotfaba8Yce91goaqaoaq6Eg8Zfa8XfcefRbbcotfgocnfa8Ucqta8ZcCtVa8WVBdbaoc9efg8Ua8URbbcea8YceGaOcetcdGVa8VcdtclGVtV86bbaoc9ifgOaQaANaOIdbMUdbaoc9mfgOaYaANaOIdbMUdbaoc9qfgOaHaANaOIdbMUdbaoc9ufgOaAaOIdbMUdbdnaxTmbaoc9yfgOa8PaOIdbMUdbaoc9CfgOaKayNaOIdbMUdbaoc9GfgOa3a8ENaOIdbMUdbaoc9KfgOaXayNaOIdbMUdbaoc9OfgOaXa8ENaOIdbMUdbaoc2fgOaKa8ENaOIdbMUdbaoc9WfgOaXaAa3aHNaXaQNaKaYNMMgY:mNgQNaOIdbMUdbaoctfgOaKaQNaOIdbMUdbaoc94fgOa3aQNaOIdbMUdbaoc98fgoaoIdbaYaQN:tUdbka8Razcefgz9hmbka8Jcufh8JaIa8NShoaIcefhIaoTmbxdkkcbh8Vina8Jcba8Jcb9kEcefh8UaEa8V:ZNgAaCNa8KMhYaAa8ANa8LMhHaAaLNa8MMhXcbhoindndnaPaEao:ZNgAahNaHMNgQ:lJbbb9p9DTmbaQ:Ohzxekcjjjj94hzkazce91gzaqazaq6EhzdndnaPaAa5NaYMNgQ:lJbbb9p9DTmbaQ:OhOxekcjjjj94hOkazaOce91gOaqaOaq6Ecefar2fcefar2hzdndnaPaAa8FNaXMNgA:lJbbb9p9DTmbaA:OhOxekcjjjj94hOkabaOce91gOaqaOaq6Efazfcefce86bba8Uaocefgo9hmbka8Jcufh8Ja8Va8NShoa8Vcefh8VaoTmbkkascifgsal6mbkkk:Nvezu8Jjjjjbcjd9Rgb8Kjjjjbcbheabcbcjdz:xjjjbhdc:W:H:cjbhbinabRbbgicC2glabcqf8Veb87e;4:L:cjbalabcdfgv8Peb83e;W:L:cjbaiabcefRbb86b;W;n:cjbadaifce86bbalavabcxfceaetc:F:d;avGEgi8Peb83e;6:L:cjbalai8Vew87e:c:M:cjbabcQfhbaecefgecK9hmbkcbhoinc;Y:L:cjbhrcbhvindnadavfgwRbbce9hmbavcC2c;W:L:cjbfhDcbhbcehqavc;W;n:cjbfhkinabcitc:G:H:cjbfhlcbhbcbheinaeavab4ceGalabfRbbtVheabcefgbcw9hmbkdnadaecFeGgxfgmRbbmbaxcC2c;W:L:cjbfhPcbhbcehsindnaDabcq2gif8VebgbTmbaraifheaPaifhiinaialabcl4csGfRbbcltalabcw4csGfRbbcwtValabcsGfRbbV87ebaicdfhiae8VebhbaecdfheabmbkkcehbasceGhecbhsaembkamce86bbaxakRbb86b;W;n:cjbkcehbaqceGhlcbhqalmbkawcd86bbkarcCfhravcefgvcjd9hmbkaocefgoci9hmbkcbhic;W:L:cjbhvincuhlavhbinalcefhlab8Vebheabcdfhbaembkaial86b;W;p:cjbavcCfhvaicefgicjd9hmbkadcjdf8Kjjjjbk9DeeuabcFeaicdtz:xjjjbhlcbhbdnadTmbindnalaeydbcdtfgiydbcu9hmbaiabBdbabcefhbkaeclfheadcufgdmbkkabk;Bidqui998Jjjjjbc;Wb9Rgl8Kjjjjbalcxfcbc;Kbz:xjjjb8Aadcd4adfhvcehoinaogrcethoarav6mbkalcuarcdtgoarcFFFFi0Ecbyd;y:L:cjbHjjjjbbgvBdxavcFeaoz:xjjjbhwdnadTmbaicd4hDarcufhqcbhkindndnawcbaeakaD2cdtfgrydlgiaicjjjj94SEgocH4ao7c:F:b:DD2cbarydbgxaxcjjjj94SEgocH4ao7c;D;O:B8J27cbarydwgmamcjjjj94SEgrcH4ar7c:3F;N8N27aqGgvcdtfgrydbgocuSmbam::hPai::hsax::hzcehiinaihrdnaeaoaD2cdtfgiIdbaz9CmbaiIdlas9CmbaiIdwaP9BmikarcefhiawavarfaqGgvcdtfgrydbgocu9hmbkkarakBdbakhokabakcdtfaoBdbakcefgkad9hmbkkalydxcbyd;C:L:cjbH:bjjjbbalc;Wbf8Kjjjjbk9teiucbcbyd;G:L:cjbgeabcifc98GfgbBd;G:L:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;G:L:cjbgeabcrfc94GfgbBd;G:L:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;G:L:cjbge9Rcifc98GaefgbBd;G:L:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk6eiucbhidnadTmbdninabRbbglaeRbbgv9hmeaecefheabcefhbadcufgdmbxdkkalav9Rhikaikk;0vdbcj:Gdk;yvFFuuFFuuFFuuFFuFFFuFFFuFbbbbbbbbebbbdbbbbbbbebbbebbbdbbbbbbbbbbbeeeeeebebbeebbebbebbbeeebbbbebbbbbbbbbbbbbbbbbbbeeeeeeebebbbeeebbeebbbbbebbbbbebebbbbbbbbbbbbbbbdiorbelvlbodveribbbbbbbbbbbbbbbbbbbbbbebbbbbbbbbbbbbbbbbbbbbibbbbbbbbbbbbbbbbbbbbbobbbbbbbbbbbbbbbbbbbbbrbaebbbbbbbbbbbbbbbbbbsd8We8YbbbbbbbhiaebbbbbbQe8Ke9cebbbbbbbbbbbbbbbbLb8KebbbbbbbbbbbbbbbbbbKbbbbbbbbbbbbbbbbbbbbbYeJbilbbbbbbbbbbbbbbbbEe80e8WlbbbbbbzlAbbbbbbb5eJdnibbbbbbai8Kbbbbbbb8Ee9ce8Ylcibbbb8Yebbbbbbbb8FdOlAdbbbbbb80e8Ylbbbbbb88eTi8KiJv8Jlbbbbbbbbbbbb89e9td8Kv9qibbbbndlvaibbbbZd8Li8KvbbbbbbJdTibbbbbb9Pe81b9GvoiBvbbbbbbbbbbbb9Re9JbvoWibbbbvibbbbbbbb9VeWi9Gvbbbbbb8WvBbbbbbbb9:b9ceBvbbbbbbbbbbbbbbbbubWibbbbbbbbbbbbbbbbbb;Wd9hvSrbbbbbbWl9NvbbbbbbFbbbbbbbbbbbbbbbbbbbbbFFuuFFuuFFuuFFuFFFuFFFuFbc;y:Ldkxebbbdbbb;W:Obb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,r=WebAssembly.instantiate(i(e),{}).then(function(x){n=x.instance,n.exports.__wasm_call_ctors()});function i(x){var _=new Uint8Array(x.length);for(var E=0;E<x.length;++E){var w=x.charCodeAt(E);_[E]=w>96?w-97:w>64?w-39:w+4}var A=0;for(var E=0;E<x.length;++E)_[A++]=_[E]<60?t[_[E]]:(_[E]-60)*64+_[++E];return _.buffer.slice(0,A)}function a(x){if(!x)throw Error("Assertion failed")}function s(x){return new Uint8Array(x.buffer,x.byteOffset,x.byteLength)}function o(x,_,E,w){var A=n.exports.sbrk,T=A(E*4),N=A(E*w*4),M=new Uint8Array(n.exports.memory.buffer);M.set(s(_),N),x(T,N,E,w*4),M=new Uint8Array(n.exports.memory.buffer);var R=new Uint32Array(E);return new Uint8Array(R.buffer).set(M.subarray(T,T+E*4)),A(T-A(0)),R}function c(x,_,E){var w=n.exports.sbrk,A=w(_.length*4),T=w(E*4),N=new Uint8Array(n.exports.memory.buffer),M=s(_);N.set(M,A);var R=x(T,A,_.length,E);N=new Uint8Array(n.exports.memory.buffer);var k=new Uint32Array(E);new Uint8Array(k.buffer).set(N.subarray(T,T+E*4)),w(A-w(0));for(var C=0;C<_.length;++C)_[C]=k[_[C]];return[k,R]}function l(x){var _=0;for(var E=0;E<x.length;++E){var w=x[E];_=_<w?w:_}return _}function u(x,_,E,w,A,T,N,M,R){var k=n.exports.sbrk,C=k(4),U=k(E*4),D=k(A*T),P=k(E*4),K=new Uint8Array(n.exports.memory.buffer);K.set(s(w),D),K.set(s(_),P);var z=x(U,P,E,D,A,T,N,M,R,C);K=new Uint8Array(n.exports.memory.buffer);var W=new Uint32Array(z);s(W).set(K.subarray(U,U+z*4));var q=new Float32Array(1);return s(q).set(K.subarray(C,C+4)),k(C-k(0)),[W,q[0]]}function d(x,_,E,w,A,T,N,M,R,k,C,U,D){var P=n.exports.sbrk,K=P(4),z=P(E*4),W=P(A*T),q=P(A*M),le=P(R.length*4),he=P(E*4),xe=k?P(A):0,pe=new Uint8Array(n.exports.memory.buffer);if(pe.set(s(w),W),pe.set(s(N),q),pe.set(s(R),le),pe.set(s(_),he),k)pe.set(s(k),xe);var J=x(z,he,E,W,A,T,q,M,le,R.length,xe,C,U,D,K);pe=new Uint8Array(n.exports.memory.buffer);var F=new Uint32Array(J);s(F).set(pe.subarray(z,z+J*4));var X=new Float32Array(1);return s(X).set(pe.subarray(K,K+4)),P(K-P(0)),[F,X[0]]}function f(x,_,E,w,A,T,N,M,R,k,C,U,D){var P=n.exports.sbrk,K=P(4),z=P(A*T),W=P(A*M),q=P(R.length*4),le=P(E*4),he=k?P(A):0,xe=new Uint8Array(n.exports.memory.buffer);if(xe.set(s(w),z),xe.set(s(N),W),xe.set(s(R),q),xe.set(s(_),le),k)xe.set(s(k),he);var pe=x(le,E,z,A,T,W,M,q,R.length,he,C,U,D,K);xe=new Uint8Array(n.exports.memory.buffer),s(_).set(xe.subarray(le,le+pe*4)),s(w).set(xe.subarray(z,z+A*T)),s(N).set(xe.subarray(W,W+A*M));var J=new Float32Array(1);return s(J).set(xe.subarray(K,K+4)),P(K-P(0)),[pe,J[0]]}function h(x,_,E,w){var A=n.exports.sbrk,T=A(E*w),N=new Uint8Array(n.exports.memory.buffer);N.set(s(_),T);var M=x(T,E,w);return A(T-A(0)),M}function b(x,_,E,w,A,T,N,M){var R=n.exports.sbrk,k=R(M*4),C=R(E*w),U=A?R(E*T):0,D=new Uint8Array(n.exports.memory.buffer);if(D.set(s(_),C),A)D.set(s(A),U);var P=x(k,C,E,w,U,T,N,M);D=new Uint8Array(n.exports.memory.buffer);var K=new Uint32Array(P);return s(K).set(D.subarray(k,k+P*4)),R(k-R(0)),K}function m(x,_,E,w,A,T,N,M,R){var k=n.exports.sbrk,C=k(4),U=k(E*4),D=k(A*T),P=k(E*4),K=N?k(A):0,z=new Uint8Array(n.exports.memory.buffer);if(z.set(s(w),D),z.set(s(_),P),N)z.set(s(N),K);var W=x(U,P,E,D,A,T,K,M,R,C);z=new Uint8Array(n.exports.memory.buffer);var q=new Uint32Array(W);s(q).set(z.subarray(U,U+W*4));var le=new Float32Array(1);return s(le).set(z.subarray(C,C+4)),k(C-k(0)),[q,le[0]]}function g(x,_,E,w,A,T,N){var M=n.exports.sbrk,R=M(E*4),k=M(A*T),C=M(E*4),U=new Uint8Array(n.exports.memory.buffer);U.set(s(w),k),U.set(s(_),C);var D=x(R,C,E,k,A,T,N);U=new Uint8Array(n.exports.memory.buffer);var P=new Uint32Array(D);return s(P).set(U.subarray(R,R+D*4)),M(R-M(0)),P}function p(x,_,E,w,A,T){var N=n.exports.sbrk,M=N(E.byteLength),R=N(_.byteLength),k=new Uint8Array(n.exports.memory.buffer);k.set(s(E),M),k.set(s(_),R);var C=E.byteLength/w,U=x(0,0,R,_.length,M,C,w,A,T),D=N(U*9*4),P=x(D,U,R,_.length,M,C,w,A,T);a(P<=U),k=new Uint8Array(n.exports.memory.buffer);var K=new Float32Array(P*9);return s(K).set(k.subarray(D,D+K.byteLength)),N(M-N(0)),K}var y={LockBorder:1,Sparse:2,ErrorAbsolute:4,Prune:8,Regularize:16,Permissive:32,RegularizeLight:64,PreserveFolds:128,ErrorClamped:256,_InternalDebug:1073741824},v={Shell:1,Solve:2,Thicken:0,_InternalDebug:1073741824};return{ready:r,supported:!0,compactMesh:function(x){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0);var _=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),E=c(n.exports.meshopt_optimizeVertexFetchRemap,_,l(x)+1);if(x!==_)for(var w=0;w<_.length;++w)x[w]=_[w];return E},generatePositionRemap:function(x,_){return a(x instanceof Float32Array),a(x.length%_==0),a(_>=3),o(n.exports.meshopt_generatePositionRemap,x,x.length/_,_)},simplify:function(x,_,E,w,A,T){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w>=0&&w<=x.length),a(w%3==0),a(A>=0);var N=0;for(var M=0;M<(T?T.length:0);++M)a(T[M]in y),N|=y[T[M]];var R=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),k=u(n.exports.meshopt_simplify,R,x.length,_,_.length/E,E*4,w,A,N);return k[0]=x instanceof Uint32Array?k[0]:new x.constructor(k[0]),k},simplifyWithAttributes:function(x,_,E,w,A,T,N,M,R,k){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w instanceof Float32Array),a(w.length==A*(_.length/E)),a(A>=0),a(N==null||N instanceof Uint8Array),a(N==null||N.length==_.length/E),a(M>=0&&M<=x.length),a(M%3==0),a(R>=0),a(Array.isArray(T)),a(A>=T.length),a(T.length<=32);for(var C=0;C<T.length;++C)a(T[C]>=0);var U=0;for(var C=0;C<(k?k.length:0);++C)a(k[C]in y),U|=y[k[C]];var D=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),P=d(n.exports.meshopt_simplifyWithAttributes,D,x.length,_,_.length/E,E*4,w,A*4,new Float32Array(T),N,M,R,U);return P[0]=x instanceof Uint32Array?P[0]:new x.constructor(P[0]),P},simplifyWithUpdate:function(x,_,E,w,A,T,N,M,R,k){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w instanceof Float32Array),a(w.length==A*(_.length/E)),a(A>=0),a(N==null||N instanceof Uint8Array),a(N==null||N.length==_.length/E),a(M>=0&&M<=x.length),a(M%3==0),a(R>=0),a(Array.isArray(T)),a(A>=T.length),a(T.length<=32);for(var C=0;C<T.length;++C)a(T[C]>=0);var U=0;for(var C=0;C<(k?k.length:0);++C)a(k[C]in y),U|=y[k[C]];var D=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),P=f(n.exports.meshopt_simplifyWithUpdate,D,x.length,_,_.length/E,E*4,w,A*4,new Float32Array(T),N,M,R,U);if(x!==D)for(var C=0;C<P[0];++C)x[C]=D[C];return P},getScale:function(x,_){return a(x instanceof Float32Array),a(x.length%_==0),a(_>=3),h(n.exports.meshopt_simplifyScale,x,x.length/_,_*4)},simplifyPoints:function(x,_,E,w,A,T){if(a(x instanceof Float32Array),a(x.length%_==0),a(_>=3),a(E>=0&&E<=x.length/_),w)return a(w instanceof Float32Array),a(w.length%A==0),a(A>=3),a(x.length/_==w.length/A),b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,w,A*4,T||0,E);else return b(n.exports.meshopt_simplifyPoints,x,x.length/_,_*4,void 0,0,0,E)},simplifySloppy:function(x,_,E,w,A,T){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w==null||w instanceof Uint8Array),a(w==null||w.length==_.length/E),a(A>=0&&A<=x.length),a(A%3==0),a(T>=0);var N=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),M=m(n.exports.meshopt_simplifySloppy,N,x.length,_,_.length/E,E*4,w,A,T);return M[0]=x instanceof Uint32Array?M[0]:new x.constructor(M[0]),M},simplifyPrune:function(x,_,E,w){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w>=0);var A=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x),T=g(n.exports.meshopt_simplifyPrune,A,x.length,_,_.length/E,E*4,w);return T=x instanceof Uint32Array?T:new x.constructor(T),T},remesh:function(x,_,E,w,A){a(x instanceof Uint32Array||x instanceof Int32Array||x instanceof Uint16Array||x instanceof Int16Array),a(x.length%3==0),a(_ instanceof Float32Array),a(_.length%E==0),a(E>=3),a(w>=4&&w<=256);var T=0;for(var N=0;N<(A?A.length:0);++N)a(A[N]in v),T|=v[A[N]];var M=x.BYTES_PER_ELEMENT==4?x:new Uint32Array(x);return p(n.exports.meshopt_remesh,M,_,E*4,w,T)}}}()});var qX;var DR=ot(()=>{qX=function(){var e="b9H79Tebbbe:neP9Geueu9Geub9Gbb9Giuuueu9Gmuuuuuuuuuuu9999eu9Gouuuuuueu9Gruuuuuuub9Gxuuuuuuuuuuuueu9Gxuuuuuuuuuuu99eu9GPuuuuuuuuuuuuu99b9Gouuuuuub9Gwuuuuuuuub9Gvuuuuub9GluuuubiQXdilvorwDqokoqxmbiibeilve9Weiiviebeoweuecj:Gdkr;Zeqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9I919P29K9nW79O2Wt79c9V919U9KbeY9TW79O9V9Wt9F9I919P29K9nW79O2Wt7S2W94bd39TW79O9V9Wt9F9I919P29K9nW79O2Wt79t9W9Ht9P9H2bo39TW79O9V9Wt9F9J9V9T9W91tWJ2917tWV9c9V919U9K7bw39TW79O9V9Wt9F9J9V9T9W91tW9nW79O2Wt9c9V919U9K7bkE9TW79O9V9Wt9F9J9V9T9W91tW9t9W9OWVW9c9V919U9K7bxL9TW79O9V9Wt9F9V9Wt9P9T9P96W9nW79O2WtbPl79IV9RbsDwebcekdOAq;W:leXdbkIbabaec9:fgefcufae9Ugeabci9Uadfcufad9Ugbaeab0Ek:88JDPue99eux99due99euo99iu8Jjjjjbc:WD9Rgm8KjjjjbdndnalmbcbhPxekamc:Cwfcbc;Kbz:rjjjb8AcuaocdtgsaocFFFFi0Ehzcbyd;0:G:cjbhHdndnalcb9imbaoal9nmbamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waihzalhsinaHazydbcdtfcbBdbazclfhzascufgsmbkaihzalhsinaHazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkaihzalhCcbhXindnaHazydbcdtgQfgsydbcb9imbaOaQfaXBdbasasydbgQcjjjj94VBdbaQaXfhXkazclfhzaCcufgCmbkalci9UhLdnalci6mbcbhzaihsinascwfydbhCasclfydbhXaOasydbcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaXcdtfgXaXydbgXcefBdbaAaXcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaihzalhsindnaHazydbcdtgCfgXydbgQcu9kmbaXaQcFFFFrGgQBdbaOaCfgCaCydbaQ9RBdbkazclfhzascufgsmbxdkkamazaHHjjjjbbgHBd:CwamceBd;8wamazcbyd;0:G:cjbHjjjjbbgOBd:GwamcdBd;8wamcualcdtalcFFFFi0Ecbyd;0:G:cjbHjjjjbbgABd:KwamciBd;8waHcbasz:rjjjbhXaihzalhsinaXazydbcdtfgCaCydbcefBdbazclfhzascufgsmbkalci9UhLdnaoTmbcbhzaOhsaXhCaohQinasazBdbasclfhsaCydbazfhzaCclfhCaQcufgQmbkkdnalci6mbcbhzaihsinascwfydbhCasclfydbhQaOasydbcdtfgKaKydbgKcefBdbaAaKcdtfazBdbaOaQcdtfgQaQydbgQcefBdbaAaQcdtfazBdbaOaCcdtfgCaCydbgCcefBdbaAaCcdtfazBdbascxfhsaLazcefgz9hmbkkaoTmbcbhzaohsinaOazfgCaCydbaXazfydb9RBdbazclfhzascufgsmbkkamaLcbyd;0:G:cjbHjjjjbbgzBd:OwamclBd;8wazcbaLz:rjjjbhYamcuaLcK2alcjjjjd0Ecbyd;0:G:cjbHjjjjbbg8ABd:SwamcvBd;8wJbbbbhEdnalci6g3mbarcd4hKaihsa8AhzaLhrJbbbbh5inavasclfydbaK2cdtfgCIdlh8EavasydbaK2cdtfgXIdlhEavascwfydbaK2cdtfgQIdlh8FaCIdwhaaXIdwhhaQIdwhgazaCIdbg8JaXIdbg8KMaQIdbg8LMJbbnn:vUdbazclfaXIdlaCIdlMaQIdlMJbbnn:vUdbaQIdwh8MaCIdwh8NaXIdwhyazcxfa8EaE:tg8Eagah:tggNaaah:tgaa8FaE:tghN:tgEJbbbbJbbjZa8Ja8K:tg8FahNa8Ea8La8K:tg8KN:tghahNaEaENaaa8KNa8FagN:tgEaENMMg8K:rg8E:va8KJbbbb9BEg8KNUdbazczfaEa8KNUdbazcCfaha8KNUdbazcwfa8Maya8NMMJbbnn:vUdba5a8EMh5ascxfhsazcKfhzarcufgrmbka5aL:Z:vJbbbZNhEkamcuaLcdtalcFFFF970Ecbyd;0:G:cjbHjjjjbbgCBd:WwamcoBd;8waq:Zhhdna3mbcbhzaChsinasazBdbasclfhsaLazcefgz9hmbkkaEahNhhamcuaLcltalcFFFFd0Ecbyd;0:G:cjbHjjjjbbg8PBd:0wamcrBd;8wcba8Pa8AaCaLcbz:djjjb8AJFFuuh8MJFFuuh8NJFFuuhydnalci6mbJFFuuhya8AhzaLhsJFFuuh8NJFFuuh8MinazcwfIdbgEa8Ma8MaE9EEh8MazclfIdbgEa8Na8NaE9EEh8NazIdbgEayayaE9EEhyazcKfhzascufgsmbkkah:rhEamaocetgzcuaocu9kEcbyd;0:G:cjbHjjjjbbgCBd:4wdndnaoal9nmbaihzalhsinaCazydbcetfcFFi87ebazclfhzascufgsmbxdkkaCcFeazz:rjjjb8AkaEJbbbZNh8JcuhIdnalci6mbcbhsJFFuuhEa8AhzcuhIinazcwfIdba8M:tghahNazIdbay:tghahNazclfIdba8N:tghahNMM:rghaEaIcuSahaE9DVgXEhEasaIaXEhIazcKfhzaLascefgs9hmbkkamczfcbcjwz:rjjjb8Aam9cb83iwam9cb83ibaxa8JNh8RJbbjZak:th8Lcbh8SJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8Ycbh8ZcbhPinJbbbbhEdna8STmbJbbjZa8S:Z:vhEkJbbbbhhdna8Ya8YNa8Wa8WNa8Xa8XNMMg8KJbbbb9BmbJbbjZa8K:r:vhhka8VaENh8Ka8UaENh5aRaENh8EaIhLdndndndndna8SaPVTmbamydwg80Tmea8YahNh8Fa8XahNhaa8WahNhgaeamydbcdtfh81cbh3JFFuuhEcvhQcuhLindnaHa81a3cdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhsindndnaCaiasydbgKcx2fgzclfydbgrcetf8Vebcs4aCazydbgXcetf8Vebcs4faCazcwfydbglcetf8Vebcs4fgombcbhzxekcehzaHaXcdtfydbgXceSmbcehzaHarcdtfydbgrceSmbcehzaHalcdtfydbglceSmbdnarcdSaXcdSfalcdSfcd6mbaocefhzxekaocdfhzkdnazaQ9kmba8AaKcK2fgXIdwa8K:tghahNaXIdba8E:tghahNaXIdla5:tghahNMM:ra8J:va8LNJbbjZMJ9VO:d86JbbjZaXIdCa8FNaXIdxagNaaaXIdzNMMakN:tghahJ9VO:d869DENghaEazaQ6ahaE9DVgXEhEaKaLaXEhLazaQaXEhQkasclfhsavcufgvmbkka3cefg3a809hmbkkaLcu9hmekama8KUd:ODama5Ud:KDama8EUd:GDamcuBd:qDamcFFF;7rBdjDa8Pcba8AaYamc:GDfamc:qDfamcjDfz:ejjjbamyd:qDhLdndnaxJbbbb9ETmba8SaD6mbaLcuSmeceh3amIdjDa8R9EmixdkaLcu9hmekdna8STmbabaPcltfgHam8Piw83dwaHam8Pib83dbaPcefhPkc3hHinamc:CwfaHfydbcbyd;4:G:cjbH:bjjjbbaHc98fgHc989hmbxvkkcbh3a8Saq9pmbamydwaCaiaLcx2fgzydbcetf8Vebcs4aCazcwfydbcetf8Vebcs4faCazclfydbcetf8Vebcs4ffaw9nmekcbhzcbhsdna8ZTmbcbhsamczfhXinamczfascdtfaXydbgQBdbaXclfhXasaYaQfRbbTfhsa8Zcufg8ZmbkkamydwhlamydbhXam9cu83i:GDam9cu83i:ODam9cu83i:qDam9cu83i:yDinamcjDfazfcFFF;7rBdbazclfgzcz9hmbkasc;8easclfc:bd6Eg8Zcdth80dnalTmbaeaXcdtfhocbhrindnaHaoarcdtfydbcdtgzfydbgvTmbaAaOazfydbcdtfhscuhQcuhzinaHaiasydbgKcx2fgXclfydbcdtfydbaHaXydbcdtfydbfaHaXcwfydbcdtfydbfgXazaXaz6gXEhzaKaQaXEhQasclfhsavcufgvmbkaQcuSmba8AaQcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEcbhsindndnazamc:qDfasfgvydbgX6mbazaX9hmeaEamcjDfasfIdb9FTmekavazBdbamc:GDfasfaQBdbamcjDfasfaEUdbxdkasclfgscz9hmbkkarcefgral9hmbkkamczfa80fhQcbhzcbhsindnamc:GDfazfydbgXcuSmbaQascdtfaXBdbascefhskazclfgzcz9hmbkasa8Zfg8ZTmbJFFuuhhcuhKamczfhza8ZhvcuhQina8AazydbgXcK2fgsIdwa8M:tgEaENasIdbay:tgEaENasIdla8N:tgEaENMM:rhEdndnaHaiaXcx2fgsclfydbcdtfydbaHasydbcdtfydbfaHascwfydbcdtfydbfgsaQ6mbasaQ9hmeaEah9DTmekaEhhashQaXhKkazclfhzavcufgvmbkaKcuSmbaKhLkdnamaiaLcx2fgrydbarclfydbarcwfydbaCabaeadaPawaqa3z:fjjjbTmbaPcefhPJbbbbhRJbbbbh8UJbbbbh8VJbbbbh8WJbbbbh8XJbbbbh8YkcbhXinaAaOaraXcdtfydbcdtgsfydbcdtfgKhzaHasfgvydbgQhsdnaQTmbdninazydbaLSmeazclfhzascufgsTmdxbkkazaKaQcdtfc98fydbBdbavavydbcufBdbkaXcefgXci9hmbka8AaLcK2fgzIdbhEazIdlhhazIdwh8KazIdxh5azIdzh8EazIdCh8FaYaLfce86bba8Ya8FMh8Ya8Xa8EMh8Xa8Wa5Mh8Wa8Va8KMh8Va8UahMh8UaRaEMhRamydxh8Sxbkkamc:WDf8KjjjjbaPkjoivuv99lu8Jjjjjbca9Rgo8Kjjjjbdndnalcw0mbaiydbhraeabcitfgwalcdtciVBdlawarBdbdnalcd6mbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkkalabfhwxekcbhqaocbBdKao9cb83izaocbBdwao9cb83ibJbbjZhkJbbjZhxinadaiaqcdtfydbcK2fhDcbhwinaoczfawfgraDawfIdbgmarIdbgP:tgsaxNaPMgPUdbaoawfgrasamaP:tNarIdbMUdbawclfgwcx9hmbkJbbjZakJbbjZMgk:vhxaqcefgqal9hmbkcbhradcbcecdaoIdlgmaoIdwgP9GEgwaoIdbgsaP9GEawasam9GEgzcdtgwfhHaoczfawfIdbhmaihwalhDinaiarcdtfgqydbhOaqawydbgABdbawaOBdbawclfhwaraHaAcK2fIdbam9DfhraDcufgDmbkdndnarcv6mbavc8X9kmbaralc98f6mekaiydbhraeabcitfgwalcdtciVBdlawarBdbaiclfhralcufhDawcxfhwinarydbhqawcuBdbawc98faqBdbawcwfhwarclfhraDcufgDmbkalabfhwxekaeabcitfgwamUdbawawydlc98GazVBdlabcefaeadaiaravcefgqz:djjjbhDawawydlciGaDabcu7fcdtVBdlaDaeadaiarcdtfalar9Raqz:djjjbhwkaocaf8Kjjjjbawk;Oddvue99dninabaecitfgrydlgwcd4gDTmednawciGgqci9hmbcihqdnawcl6mbabaecitfhbcbheawhqcehkindnaiabydbgDfRbbmbcbhkadaDcK2fgwIdwalIdw:tgxaxNawIdbalIdb:tgxaxNawIdlalIdl:tgxaxNMM:rgxaoIdb9DTmbaoaxUdbavaDBdbarydlhqkabcwfhbaecefgeaqcd46mbkakceGTmikaraqciGBdlskdnabcbaDalaqcdtfIdbarIdb:tgxJbbbb9FEgwaD7aecefgDfgecitfydlabawaDfgDcitfydlVci0mbaraqBdlkabaDadaialavaoz:ejjjbax:laoIdb9Fmbkkkjlevudndnabydwgxaladcetfgm8Vebcs4alaecetfgP8Vebgscs4falaicetfgz8Vebcs4ffaD0mbakmbcbhDabydxaq6mekavawcltfgxab8Pdw83dwaxab8Pdb83dbabydbhDdnabydwgwTmbaoaDcdtfhxawhsinalaxydbcetfcFFi87ebaxclfhxascufgsmbkkabaDawfBdbabydxhxab9cb83dwababydlaxci2fBdlaP8VebhscehDcbhxkdnascztcz91cu9kmbabaxcefBdwaPax87ebaoabydbcdtfaxcdtfaeBdbkdnam8Uebcu9kmbababydwgxcefBdwamax87ebaoabydbcdtfaxcdtfadBdbkdnaz8Uebcu9kmbababydwgxcefBdwazax87ebaoabydbcdtfaxcdtfaiBdbkarabydlfabydxci2faPRbb86bbarabydlfabydxci2fcefamRbb86bbarabydlfabydxci2fcdfazRbb86bbababydxcefBdxaDk:mPrHue99eue99eue99iu8Jjjjjbc;W;Gb9Rgx8KjjjjbdndnalmbcbhmxekcbhPaxc:m;Gbfcbc;Kbz:rjjjb8Aaxcualci9UgscltascjjjjiGEcbyd;0:G:cjbHjjjjbbgzBd:m9GaxceBd;S9GaxcuascK2gHcKfalcpFFFe0Ecbyd;0:G:cjbHjjjjbbgOBd:q9GaxcdBd;S9Gdnalci6gAmbarcd4hCascdthXaOhQazhLinavaiaPcx2fgrydwaC2cdtfhKavarydlaC2cdtfhYavarydbaC2cdtfh8AcbhraLhEinaQarfgma8Aarfg3Idbg5aYarfg8EIdbg8Fa5a8F9DEg5UdbamaKarfgaIdbg8Fa5a8Fa59DEg8FUdbamcxfgma3Idbg5a8EIdbgha5ah9EEg5UdbamaaIdbgha5aha59EEg5UdbaEa8Fa5MJbbbZNUdbaEaXfhEarclfgrcx9hmbkaQcKfhQaLclfhLaPcefgPas9hmbkkaOaHfgr9cb83dbar9cb83dzar9cb83dwaxcuascx2gralc:bjjjl0Ecbyd;0:G:cjbHjjjjbbgHBdN9GaxciBd;S9GascdthgazarfhvaxcwVhPaxclVhCaHh8Jazh8KcbhLinaxcbcj;Gbz:rjjjbhEaLas2cdthadnaAmba8Khrash3inaEarydbgmc8F91cjjjj94Vam7gmcQ4cx2fg8Ea8EydwcefBdwaEamcd4cFrGcx2fg8Ea8EydbcefBdbaEamcx4cFrGcx2fgmamydlcefBdlarclfhra3cufg3mbkkazaafh8AaHaafhXcbhmcbh3cbh8EcbhainaEamfgrydbhQara3BdbarcwfgKydbhYaKaaBdbarclfgrydbhKara8EBdbaQa3fh3aYaafhaaKa8Efh8Eamcxfgmcj;Gb9hmbkdnaAmbcbhravhminamarBdbamclfhmasarcefgr9hmbkavhrashminaEa8Aarydbg3cdtfydbg8Ec8F91a8E7cd4cFrGcx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbka8JhrashminaCa8Aarydbg3cdtfydbg8Ec8F91a8E7cx4cFrGcx2fg8Ea8Eydbg8EcefBdbava8Ecdtfa3BdbarclfhramcufgmmbkavhrashminaPa8Aarydbg3cdtfydbg8Ec8F91cjjjj94Va8E7cQ4cx2fg8Ea8Eydbg8EcefBdbaXa8Ecdtfa3Bdbarclfhramcufgmmbkka8Jagfh8Ja8Kagfh8KaLcefgLci9hmbkaEaocetgrcuaocu9kEcbyd;0:G:cjbHjjjjbbgKBd:y9GaEclBd;S9Gdndnaoal9nmbaihralhminaKarydbcetfcFFi87ebarclfhramcufgmmbxdkkaKcFearz:rjjjb8Akcbh8EaEascbyd;0:G:cjbHjjjjbbg8ABd:C9GaOaHaHascdtfaHascitfa8AascbazaKaiawaDaqakz:hjjjbdndnalci6mba8Ahrashmina8EarRbbfh8EarcefhramcufgmmbkaE9cb83iwaE9cb83ibalawc9:fgrfcufar9UgrasaDfcufaD9Ugmaram0EhYcbhmcbhra8Ehaincbh3dnarTmba8AarfRbbceSh3kamaEaiaHydbcx2fgQydbaQclfydbaQcwfydbaKabaeadamawaqa3a3ce7a8EaY9nVaaamfaY6VGz:fjjjbfhmaHclfhHaaa8AarfRbb9Rhaasarcefgr9hmbkaEydxTmeabamcltfgraE8Piw83dwaraE8Pib83dbamcefhmxekaE9cb83iwaE9cb83ibcbhmkczhrinaEc:m;Gbfarfydbcbyd;4:G:cjbH:bjjjbbarc98fgrc989hmbkkaxc;W;Gbf8Kjjjjbamk:wKDQue99iue99iul9:euw99iu8Jjjjjbc;qb9RgP8Kjjjjbaxhsaxhzdndnavax0gHmbdnavTmbcbhOaehzavhAinawaDazydbcx2fgCcwfydbcetfgX8VebhQawaCclfydbcetfgL8VebhKawaCydbcetfgC8VebhYaXce87ebaLce87ebaCce87ebaOaKcs4aYcs4faQcs4ffhOazclfhzaAcufgAmbkaehzavhAinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaAcufgAmbkcehzaqhsaOaq0mekalce86bbalcefcbavcufz:rjjjb8AxekaPaiBdxaPadBdwaPaeBdlavakaqci9Ug8Aaka8Aak6EaHEgK9RhEaxaK9Rh3aKcufh5aKceth8EaKcdtgCc98fh8FavcitgOaC9Rarfc98fhaascufhhavcufhgaraOfh8JJbbjZas:Y:vh8KcbazceakaxSEg8Lcdtg8M9Rh8NJFFuuhycuh8PcbhIcbh8RinaPclfa8RcdtfydbhQaPcb8Pd:y:G:cjbg8S83i9iaPcb8Pd:q:G:cjbgR83inaPcb8Pd1:G:cjbg8U83iUaPcb8Pdj:G:cjbg8V83i8WaPa8S83iyaPaR83iaaPa8U83iKaPa8V83izaQavcdtgYfh8WcbhXinabaQaXcdtgLfydbcK2fhAcbhzinaPc8WfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaba8WaXcu7cdtfydbcK2fhAcbhzaPIdUh8ZaPId9ih80aPId80h81aPId9ehBaPId8Wh83aPIdnhUinaPczfazfgCaAazfgOIdbg8XaCIdbg8Ya8Xa8Y9DEUdbaCczfgCaOcxfIdbg8XaCIdbg8Ya8Xa8Y9EEUdbazclfgzcx9hmbkaraLfgza80a8Z:tg8XaUa83:tg8YNa8YaBa81:tg8ZNa8Za8XNMMUdbazaYfaPIdyaPIdK:tg8XaPIdaaPIdz:tg8YNa8YaPId8KaPIdC:tg8ZNa8Za8XNMMUdbaXcefgXav9hmbkcbh85dnaHmbcbhAaQhza8JhCavhXinawaDazydbcx2fgOcwfydbcetfgL8Vebh8WawaOclfydbcetfg858Vebh86awaOydbcetfgO8Vebh87aLce87eba85ce87ebaOce87ebaCaAa86cs4a87cs4fa8Wcs4ffgABdbazclfhzaCclfhCaXcufgXmbkavhCinawaDaQydbcx2fgzcwfydbcetfcFFi87ebawazclfydbcetfcFFi87ebawazydbcetfcFFi87ebaQclfhQaCcufgCmbka8Jh85kdndndndndndndndndndndnava8E6mba8Eax9nmeavavaK9UgzaK29Raza320mda5aE9pmqa85Th87ceh8WaEhQxwka5ag9pmDa8Eax9nmixokavaK6mea5aE9pmwcehQaEhXa85Tmixlka5ag6mlxrka5ag9pmokcbhQaghXa85mekJFFuuh8XcbhLa5hzindnazcefgCaK6mbaQavaC9RgOaK6GmbarazcdtfIdbg8YaC:YNaravaz9RcdtfaYfc94fIdbg8ZaO:YNMg80a8X9Embdndna8KaOahf:YNg81:lJbbb9p9DTmba81:OhAxekcjjjj94hAka8ZasaA2aO9R:YNh8Zdndna8Kazasf:YNg81:lJbbb9p9DTmba81:OhOxekcjjjj94hOkamasaO2aC9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgOEh8XaCaLaOEhLkaza8LfgzaX6mbxlkkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazaK6mbaQaCaK6GmbaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9Embdndna8Ka85aOfydbgYahf:YNg81:lJbbb9p9DTmba81:Oh8Wxekcjjjj94h8Wkamasa8W2aY9R:Yg81a8YNa8Za81NMNa80Mg8Ya8Xa8Ya8X9DgYEh8XazaLaYEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaX6mbxikka85Th87cbh8WaghQkJFFuuh8XcbhLaEhCaahAa8FhOaKhzindnazazaK9UgXaK29RaXa320mbdna8WTmbaCaCaK9UgXaK29RaXa320mekaraOfIdbg8Yaz:YNaAIdbg8ZaC:YNMg80a8X9EmbazhXaChYdna87mba85aOfydbgXhYkdndna8KaYahf:YNg81:lJbbb9p9DTmba81:Oh86xekcjjjj94h86ka8Zasa862aY9R:YNh8Zdndna8KaXahf:YNg81:lJbbb9p9DTmba81:OhYxekcjjjj94hYkamasaY2aX9R:Ya8YNa8ZMNa80Mg8Ya8Xa8Ya8X9DgXEh8XazaLaXEhLkaCa8L9RhCaAa8NfhAaOa8MfhOaza8LfgzcufaQ6mbkkaLTmba8Xay9DTmba8XhyaLhIa8Rh8Pka8Rcefg8Rci9hmbkdndnaoc8X9kmba8Pcb9omeka8Acufh85cbhYindndndnavaY9RaxaYaxfav0Eg8WTmbcbhAaeaYcdtfgzhCa8WhXinawaDaCydbcx2fgOcwfydbcetfgQ8VebhbawaOclfydbcetfgL8VebhrawaOydbcetfgO8VebhKaQce87ebaLce87ebaOce87ebaAarcs4aKcs4fabcs4ffhAaCclfhCaXcufgXmbka8WhOinawaDazydbcx2fgCcwfydbcetfcFFi87ebawaCclfydbcetfcFFi87ebawaCydbcetfcFFi87ebazclfhzaOcufgOmbkaAaq0mekalaYfgzce86bbazcefcba8Wcufz:rjjjb8AxekalaYfgzce86bbazcefcba85z:rjjjb8Aa8Ah8Wka8WaYfgYav9pmdxbkkaravcdtg8WfhLdnaITmbaPclfa8PcdtfydbhzaIhCinaLazydbfcb86bbazclfhzaCcufgCmbkkdnavaI9nmbaPclfa8PcdtfydbaIcdtfhzavaI9RhCinaLazydbfce86bbazclfhzaCcufgCmbkkcbhYindnaYa8PSmbcbhzaraPclfaYcdtfydbgKa8Wz:qjjjbhCavhXaIhOinaKaOazaLaCydbgQfRbbgAEcdtfaQBdbaCclfhCaOaAfhOazaA9RcefhzaXcufgXmbkkaYcefgYci9hmbkabaeadaialaIaocefgCarawaDaqakaxamz:hjjjbabaeaIcdtgzfadazfaiazfalaIfavaI9RaCarawaDaqakaxamz:hjjjbkaPc;qbf8Kjjjjbk:Seeru8Jjjjjbc:q;ab9Rgo8Kjjjjbaoc:q8WfcFecjzz:rjjjb8AcbhrdnadTmbaehwadhDinaoarcdtfawydbgqBdbaoc:q8WfaqcFiGcdtfgkydbhxakaqBdbawclfhwaraxaq9hfhraDcufgDmbkkabaeadaoaraiavz:jjjjbaoc:q;abf8Kjjjjbk;Sqloud99euD998Jjjjjbc:W;ab9Rgr8KjjjjbdndnadTmbaocd4hwcbhDcbhqindnavaeclfydbaw2cdtfgkIdbavaeydbaw2cdtfgxIdbgm:tgPavaecwfydbaw2cdtfgsIdlaxIdlgz:tgHNakIdlaz:tgOasIdbam:tgAN:tgCaCNaOasIdwaxIdwgX:tgQNakIdwaX:tgOaHN:tgHaHNaOaANaPaQN:tgPaPNMMgOJbbbb9Bmbarc8WfaDcltfgkaCaO:rgO:vgCUdwakaPaO:vgPUdlakaHaO:vgHUdbakaCaXNaHamNazaPNMM:mUdxaDcefhDkaecxfheaqcifgqad6mbkab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbaDTmearcbBd8Sar9cb83iKar9cb83izarczfavalaoarc8Sfcbcraiz:kjjjbarIdKhQarIdChLarIdzhKar9cb83iwar9cb83ibararc8WfaDczarc8Sfcbcicbz:kjjjbJbbbbhmdnarIdwgzazNarIdbgHaHNarIdlgXaXNMMgCJbbbb9BmbJbbjZaC:r:vhmkazamNhCaXamNhXaHamNhHJbbjZhmarc8WfheaDhvinaecwfIdbaCNaeIdbaHNaXaeclfIdbNMMgzamazam9DEhmaeczfheavcufgvmbkabaQUdwabaLUdlabaKUdbabarId3UdxdndnamJ;n;m;m899FmbJbbbbhzarc8WfheinaecxfIdbaQaecwfIdbgPNaKaeIdbgONaLaeclfIdbgANMMMaCaPNaHaONaXaANMM:vgPazaPaz9EEhzaeczfheaDcufgDmbkabaCUd8KabaXUdaabaHUd3abaQaCazN:tUdKabaLaXazN:tUdCabaKaHazN:tUdzabJbbjZamamN:t:rgmUdydndnaCJbbj:;aCJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aCJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohexekcjjjj94hekabae86b8UdndnaXJbbj:;aXJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aXJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohvxekcjjjj94hvkabav86bRdndnaHJbbj:;aHJbbj:;9GEgzJbbjZazJbbjZ9FEJbb;:9cNJbbbZJbbb:;aHJbbbb9GEMgz:lJbbb9p9DTmbaz:Ohwxekcjjjj94hwkabaw86b8SdndnaecKtcK91:YJbb;:9c:vaC:t:lavcKtcK91:YJbb;:9c:vaX:t:lawcKtcK91:YJbb;:9c:vaH:t:lamMMMJbb;:9cNJbbjZMgm:lJbbb9p9DTmbam:Ohexekcjjjj94hekaecFbaecFb9iEhexekabcjjj;8iBdycFbhekabae86b8Vxekab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbkarc:W;abf8Kjjjjbk;7woDuo99eue99euv998Jjjjjbcje9Rgw8Kjjjjbawc;abfcbaocdtgDz:rjjjb8Aawc;GbfcbaDz:rjjjb8AawcafhDawhqaohkinaqcFFF97BdbaDcFFF;7rBdbaqclfhqaDclfhDakcufgkmbkavcd4hxaicd4hmdnadTmbaocx2hPcbhsinashzdnarTmbarascdtfydbhzkaeazam2cdtfgDIdwhHaDIdlhOaDIdbhAalazax2cdtfIdbhCcbhDawcafhqawc;Gbfhvawhkawc;abfhiinaCaDc:O:G:cjbfIdbaHNaDc:G:G:cjbfIdbaANaDc:K:G:cjbfIdbaONMMgXMhQazhLdnaXaC:tgXaqIdbgK9DgYmbavydbhLkavaLBdbazhLdnaQakIdbg8A9EmbaiydbhLa8AhQkaiaLBdbakaQUdbaqaXaKaYEUdbaiclfhiakclfhkavclfhvaqclfhqaPaDcxfgD9hmbkascefgsad9hmbkkJbbbbhQcbhLawc;GbfhDawc;abfhqcbhkinalaqydbgvax2cdtfIdbalaDydbgiax2cdtfIdbaeavam2cdtfgvIdwaeaiam2cdtfgiIdw:tgCaCNavIdbaiIdb:tgCaCNavIdlaiIdl:tgCaCNMM:rMMgCaQaCaQ9EgvEhQakaLavEhLaqclfhqaDclfhDaoakcefgk9hmbkJbbbbhCdnaeawc;abfaLcdtgqfydbgkam2cdtfgDIdwaeawc;Gbfaqfydbgvam2cdtfgqIdwgH:tgXaXNaDIdbaqIdbgA:tg8Aa8ANaDIdlaqIdlgE:tgOaONMMgKJbbbb9ETmbaK:rgCalakax2cdtfIdbMalavax2cdtfIdb:taCaCM:vhCkaQJbbbZNhKaXaCNaHMhHaOaCNaEMhOa8AaCNaAMhAdnadTmbcbhqarhkinaqhDdnarTmbakydbhDkdnalaDax2cdtfIdbg3aeaDam2cdtfgDIdwaH:tgQaQNaDIdbaA:tgCaCNaDIdlaO:tgXaXNMMg5:rgEMg8EaK9ETmbJbbbbh8Adna5Jbbbb9ETmba8EaK:taEaEM:vh8Aka8AaQNaHMhHa8AaXNaOMhOa8AaCNaAMhAa3aKaEMMJbbbZNhKkakclfhkadaqcefgq9hmbkkabaKUdxabaHUdwabaOUdlabaAUdbawcjef8Kjjjjbk:reevu8Jjjjjbcj8W9Rgr8Kjjjjbaici2hwcbhDdnaiTmbarhiawhqinaiaeadRbbgkcdtfydbBdbaDakcefgkaDak0EhDaiclfhiadcefhdaqcufgqmbkkabarawaeaDalaoz:jjjjbarcj8Wf8Kjjjjbk:Eeeeu8Jjjjjbca9Rgo8Kjjjjbab9cb83dyab9cb83daab9cb83dKab9cb83dzab9cb83dwab9cb83dbdnadTmbaocbBd3ao9cb83iwao9cb83ibaoaeadaialaoc3falEavcbalEcrcbz:kjjjbabao8Pib83dbabao8Piw83dwkaocaf8Kjjjjbk::meQu8Jjjjjbcjz9Rgv8KjjjjbcbhoavcjPfcbaez:rjjjb8Aavcjxfcbaez:rjjjb8AdnaiTmbadhoaihrinavcjxfaoRbbfgwawRbbcef86bbavcjxfaocefRbbfgwawRbbcef86bbavcjxfaocdfRbbfgwawRbbcef86bbaocifhoarcufgrmbkcbhDcjehoadhqcehkindndnalTmbcbhxcuhmaqhrakhwcuhPinawcufamaoavcjPfarcefRbbgsfRbb9RcFeGgzci6aoavcjPfarRbbgHfRbb9RcFeGgOci6faoavcjPfarcdfRbbgAfRbb9RcFeGgCci6fgXcOtaOcFr7azaCf9RcwtVavcjxfaAfRbbgzavcjxfaHfRbbgHavcjxfasfRbbgsaHas6Egsazas6EcFe7VgsaP9kgzEhmaXcd6gHaxcefgOal9iVce9hmdasaPazEhPaxaOaHEhxarcifhrawai6hsawcefhwasmbxdkkcuhmaqhrakhwcuhxinawcufamaoavcjPfarcefRbbfRbb9RcFeGci6aoavcjPfarRbbfRbb9RcFeGci6faoavcjPfarcdfRbbfRbb9RcFeGci6fgPax9kgsEhmaPce0meaPaxasEhxarcifhrawai6hPawcefhwaPmbkkadamci2fgrcdfRbbhwarcefRbbhxarRbbhPadaDci2fgrcifaramaD9Rci2zNjjjb8AaPavcjPffaocefgo86bbaPavcjxffgmamRbbcuf86bbaxavcjPffao86bbaxavcjxffgmamRbbcuf86bbarcdfaw86bbarcefax86bbaraP86bbawavcjPffao86bbawavcjxffgrarRbbcuf86bbaqcifhqakcefhkaDcefgDai9hmbkcbhzdnalcb9mmbcbhsavcjPfcbaez:rjjjb8Aadcvfhlinadasci2fgxcefgDRbbhoaxcdfgqRbbhrdndnavcjPfaxRbbgmfRbbmbavcjPfarfRbbhwdndndnavcjPfaofRbbTmbawcFeGTmexikawcFeGmdascefgAai9pmdasc980mdascifhQcbhLarcFeGhCamcFeGhXalhwcbhKcbhYinawcufRbbhPawRbbhOcehkdndnawc9:fRbbgHao9hmbaPcFeGamSmekdnaPcFeGao9hmbaOcFeGamSmekaHamSaOcFeGaoSGhkkceh8AaYceGhYdndnaHar9hmbaPcFeGaoSmekdnaPcFeGar9hmbaOcFeGaoSmekaHaoSaOcFeGarSGh8AkakaYVhYaLaHcFeGgHaXSaPcFeGgPaCSGaPaXSaOcFeGgPaCSGVaHaCSaPaXSGVVhLa8AaKceGVhKdnaAcefgPai9pmbawcifhwaAaQ6hHaPhAaHmekkaYTmeaKmekarhwaohPaohHarhOamhrxdkdnaYTaLVceGTmbaYaKTVaLVceGmekamhwarhParhHamhOaohrxekaohwamhPamhHaohOkavcjPfarfce86bbavcjPfawfce86bbaxaH86bbaqar86bbaDaO86bbavcjPfaPfce86bbalcifhlascefgsai9hmbkkavcFeaecetz:rjjjbhwaici2hrindnawadRbbgmcetfgx8Uebgocu9kmbaxaz87ebawcjlfazcdtfabamcdtfydbBdbazhoazcefhzkadao86bbadcefhdarcufgrmbkazcdthokabavcjlfaoz:qjjjb8Aavcjzf8KjjjjbkObabaiaeadcbz:njjjbk9teiucbcbyd;8:G:cjbgeabcifc98GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd;8:G:cjbgeabcrfc94GfgbBd;8:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd;8:G:cjbge9Rcifc98GaefgbBd;8:G:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk:3qeludndnadch6mbadTmeabaead;8qbbabskabaeSmbdnaeadabfgi9Rcbadcet9R0mbadTmeabaead;8qbbabskaeab7ciGhldndndnabae9pmbdnalTmbadhvabhixikdnabciGmbadhvabhixdkadTmiabaeRbb86bbadcufhvdnabcefgiciGmbaecefhexdkavTmiabaeRbe86beadc9:fhvdnabcdfgiciGmbaecdfhexdkavTmiabaeRbd86bdadc99fhvdnabcifgiciGmbaecifhexdkavTmiabaeRbi86biabclfhiaeclfheadc98fhvxekdnalmbdnaiciGTmbadTmlabadcufgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc9:fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc99fgifglaeaifRbb86bbdnalciGmbaihdxekaiTmlabadc98fgdfaeadfRbb86bbkadcl6mbdnadc98fgocxGcxSmbaocd4cefciGhiaec98fhlabc98fhvinavadfaladfydbBdbadc98fhdaicufgimbkkaocx6mbaec9Wfhvabc9WfhoinaoadfgicxfavadfglcxfydbBdbaicwfalcwfydbBdbaiclfalclfydbBdbaialydbBdbadc9Wfgdci0mbkkadTmdadhidnadciGglTmbaecufhvabcufhoadhiinaoaifavaifRbb86bbaicufhialcufglmbkkadcl6mdaec98fhlabc98fhvinavaifgecifalaifgdcifRbb86bbaecdfadcdfRbb86bbaecefadcefRbb86bbaeadRbb86bbaic98fgimbxikkavcl6mbdnavc98fglc3Gc3Smbavalcd4cefcrGgdcdt9RhvinaiaeydbBdbaeclfheaiclfhiadcufgdmbkkalc36mbinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfaeczfydbBdbaicCfaecCfydbBdbaicKfaecKfydbBdbaic3faec3fydbBdbaecafheaicafhiavc9Gfgvci0mbkkavTmbdndnavcrGgdmbavhlxekavc94GhlinaiaeRbb86bbaicefhiaecefheadcufgdmbkkavcw6mbinaiaeRbb86bbaicefaecefRbb86bbaicdfaecdfRbb86bbaicifaecifRbb86bbaiclfaeclfRbb86bbaicvfaecvfRbb86bbaicofaecofRbb86bbaicrfaecrfRbb86bbaicwfhiaecwfhealc94fglmbkkabkk:pedbcj:GdktFFuuFFuuFFuubbbbFFuFFFuFFFuFbbbbbbjZbbbbbbbbbbbbbbjZbbbbbbbbbbbbbbjZ86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;86;nAZ86;nAZ86;nAZ86;nA:;bc;0:Gdkxebbbdbbbj:qbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,r=WebAssembly.instantiate(i(e),{}).then(function(m){n=m.instance,n.exports.__wasm_call_ctors()});function i(m){var g=new Uint8Array(m.length);for(var p=0;p<m.length;++p){var y=m.charCodeAt(p);g[p]=y>96?y-97:y>64?y-39:y+4}var v=0;for(var p=0;p<m.length;++p)g[v++]=g[p]<60?t[g[p]]:(g[p]-60)*64+g[++p];return g.buffer.slice(0,v)}function a(m){if(!m)throw Error("Assertion failed")}function s(m){return new Uint8Array(m.buffer,m.byteOffset,m.byteLength)}var o=48,c=16;function l(m,g){var p=m.meshlets[g*4+0],y=m.meshlets[g*4+1],v=m.meshlets[g*4+2],x=m.meshlets[g*4+3];return{vertices:m.vertices.subarray(p,p+v),triangles:m.triangles.subarray(y,y+x*3)}}function u(m,g,p,y,v,x,_,E,w,A){var T=n.exports.sbrk,N=n.exports.meshopt_buildMeshletsBound(g.length,x,_),M=T(N*c),R=T(g.length*4),k=T(g.length),C=T(g.byteLength),U=T(p.byteLength),D=new Uint8Array(n.exports.memory.buffer);D.set(s(g),C),D.set(s(p),U);var P=m(M,R,k,C,g.length,U,y,v,x,_,E,w,A);D=new Uint8Array(n.exports.memory.buffer);var K=D.subarray(M,M+P*c),z=new Uint32Array(K.buffer,K.byteOffset,K.byteLength/4).slice();for(var W=0;W<P;++W){var q=z[W*4+0],le=z[W*4+1],y=z[W*4+2],he=z[W*4+3];n.exports.meshopt_optimizeMeshlet(R+q*4,k+le,he,y)}var xe=P?z[(P-1)*4+0]+z[(P-1)*4+2]:0,pe=P?z[(P-1)*4+1]+z[(P-1)*4+3]*3:0,J={meshlets:z,vertices:new Uint32Array(D.buffer,R,xe).slice(),triangles:new Uint8Array(D.buffer,k,pe).slice(),meshletCount:P};return T(M-T(0)),J}function d(m){var g=new Float32Array(n.exports.memory.buffer,m,o/4);return{centerX:g[0],centerY:g[1],centerZ:g[2],radius:g[3],coneApexX:g[4],coneApexY:g[5],coneApexZ:g[6],coneAxisX:g[7],coneAxisY:g[8],coneAxisZ:g[9],coneCutoff:g[10]}}function f(m,g,p,y){var v=n.exports.sbrk,x=[],_=v(g.byteLength),E=v(m.vertices.byteLength),w=v(m.triangles.byteLength),A=v(o),T=new Uint8Array(n.exports.memory.buffer);T.set(s(g),_),T.set(s(m.vertices),E),T.set(s(m.triangles),w);for(var N=0;N<m.meshletCount;++N){var M=m.meshlets[N*4+0],R=m.meshlets[N*4+1],k=m.meshlets[N*4+3];n.exports.meshopt_computeMeshletBounds(A,E+M*4,w+R,k,_,p,y),x.push(d(A))}return v(_-v(0)),x}function h(m,g,p,y){var v=n.exports.sbrk,x=v(o),_=v(m.byteLength),E=v(g.byteLength),w=new Uint8Array(n.exports.memory.buffer);w.set(s(m),_),w.set(s(g),E),n.exports.meshopt_computeClusterBounds(x,_,m.length,E,p,y);var A=d(x);return v(x-v(0)),A}function b(m,g,p,y,v){var x=n.exports.sbrk,_=x(o),E=x(m.byteLength),w=y?x(y.byteLength):0,A=new Uint8Array(n.exports.memory.buffer);if(A.set(s(m),E),y)A.set(s(y),w);n.exports.meshopt_computeSphereBounds(_,E,g,p,w,y?v:0);var T=d(_);return x(_-x(0)),T}return{ready:r,supported:!0,buildMeshlets:function(m,g,p,y,v,x){a(m.length%3==0),a(g instanceof Float32Array),a(g.length%p==0),a(p>=3),a(y>=3&&y<=256),a(v>=1&&v<=512),x=x||0;var _=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,_,g,g.length/p,p*4,y,v,v,x,0)},buildMeshletsFlex:function(m,g,p,y,v,x,_,E){a(m.length%3==0),a(g instanceof Float32Array),a(g.length%p==0),a(p>=3),a(y>=3&&y<=256),a(v>=1&&x<=512),a(v<=x),_=_||0,E=E||0;var w=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsFlex,w,g,g.length/p,p*4,y,v,x,_,E)},buildMeshletsSpatial:function(m,g,p,y,v,x,_){a(m.length%3==0),a(g instanceof Float32Array),a(g.length%p==0),a(p>=3),a(y>=3&&y<=256),a(v>=1&&x<=512),a(v<=x),_=_||0;var E=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return u(n.exports.meshopt_buildMeshletsSpatial,E,g,g.length/p,p*4,y,v,x,_)},extractMeshlet:function(m,g){return a(g>=0&&g<m.meshletCount),l(m,g)},computeClusterBounds:function(m,g,p){a(m.length%3==0),a(m.length/3<=512),a(g instanceof Float32Array),a(g.length%p==0),a(p>=3);var y=m.BYTES_PER_ELEMENT==4?m:new Uint32Array(m);return h(y,g,g.length/p,p*4)},computeMeshletBounds:function(m,g,p){return a(g instanceof Float32Array),a(g.length%p==0),a(p>=3),f(m,g,g.length/p,p*4)},computeSphereBounds:function(m,g,p,y){return a(m instanceof Float32Array),a(m.length%g==0),a(g>=3),a(!p||p instanceof Float32Array),a(!p||p.length%y==0),a(!p||y>=1),a(!p||m.length/g==p.length/y),y=y||0,b(m,m.length/g,g*4,p,y*4)}}}()});var ZX;var FR=ot(()=>{ZX=function(){var e="b9H79Tebbbe9vx9Geueu9Geub9Gbb9Gkuuuuuuuuuuub9Gouuuuuub9Gwuuuuuu9999b9Giuuueu9Ge98e999Gvuuuuueu9Gd99ueu9Ge99e999Gd98ue98isPdilvboberrwDqklve9Weiiviebeoweuecj:Gdkr9Avo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bbK9TW79O9V9Wt9F9NW9UWV9HtW9u9H9U9NW9Ut7beL9TW79O9V9Wt9F9NW9UWV9HtW9o9VV9T9H27bil79IV9RblDwebcekdorq;X9PPdbk;e8EvHuw99euv99wu8Jjjjjbc;Wb9Rgk8Kjjjjbakcxfcbc;Kbz:fjjjb8AakcualcdtalcFFFFi0Ecbyd:W:2:cjbHjjjjbbgxBdxakceBd2adci9Uhmalcd4alfhPcehsinasgzcethsazaP6mbkakcuazcdtgsazcFFFFi0Ecbyd:W:2:cjbHjjjjbbgPBdzakcdBd2aPcFeasz:fjjjbhHaDcd4hOarcd4hAavcd4hCdnalTmbazcufhrcbhvindndnaHcbaiavaC2cdtfgzydlgDaDcjjjj94SEgPcH4cbaoavaA2cdtfgsydlgXcs4aXcjjjj94SE7aP7c:F:b:DD2cbazydbgQaQcjjjj94SEgPcH4cbasydbgLcs4aLcjjjj94SE7aP7c;D;O:B8J27cbazydwgKaKcjjjj94SEgzcH4cbasydwgYcs4aYcjjjj94SE7az7c:3F;N8N27awavaO2cdtfgzydlg8AazydbgE7cFFFFrGgzcm4az7c:fjjK27arGgPcdtfgzydbgscuSmba8A::h3aE::h5aY::h8EaX::h8FaL::haaK::hhaD::hgaQ::h8JcehDinaDhzdnaiasaC2cdtfgDIdba8J9CmbaDIdlag9CmbaDIdwah9CmbaoasaA2cdtfgDIdbaa9CmbaDIdla8F9CmbaDIdwa8E9CmbawasaO2cdtfgDIdba59CmbaDIdla39BmikazcefhDaHaPazfarGgPcdtfgzydbgscu9hmbkkazavBdbavhskaxavcdtfasBdbavcefgval9hmbkkcbhPaHcbyd:0:2:cjbH:bjjjbbakceBd2ak9cb83ibakaeadaxalakcxfz:cjjjbcuamcltadcFFFFd0Ecbyd:W:2:cjbHjjjjbbh8Kakcxfakyd2gKcdtfa8KBdbakaKcefgYBd2dnadci6mbaehsa8KhzamhvindndnaeTmbascwfydbhDasclfydbhHasydbhrxekaPcdfhDaPcefhHaPhrkJbbbbh8JJbbbbJbbbbJbbbbJbbbbJbbjZJbbj:;awaHaO2cdtfgXIdbawaraO2cdtfgQIdbga:tawaDaO2cdtfgLIdlaQIdlgh:tggNaXIdlah:tghaLIdbaa:tN:tgaJbbbb9EEaaJbbbb9BEg5aiaraC2cdtfgrIdwgaaiaHaC2cdtfgHIdwg39BEa5arIdlg8FaHIdlg8L9BEa5arIdbg8EaHIdbg8M9BEg5aaaiaDaC2cdtfgDIdwg8N9BEa5a8FaDIdlgy9BEa5a8EaDIdbg8P9BEg5a3a8N9BEa5a8Lay9BEa5a8Ma8P9BEh5dnaga3aa:tNaha8Naa:tN:tgaaaNaga8Ma8E:tNaha8Pa8E:tN:tg8Ea8ENaga8La8F:tNahaya8F:tN:tggagNMMghJbbbb9Bmba5ah:r:vh8Jkazcxfa5Udbazcwfaaa8JNUdbazclfaga8JNUdbaza8Ea8JNUdbascxfhsazczfhzaPcifhPavcufgvmbkkcbhzakcxfaYcdtfcuadcdtadcFFFFi0Ecbyd:W:2:cjbHjjjjbbgDBdbakaKcdfgPBd2dnadTmbaDhsinasazBdbasclfhsadazcefgz9hmbkkakcxfaPcdtfcuamcdtadcFFFF970Ecbyd:W:2:cjbHjjjjbbgvBdbakaKcifgzBd2akcxfazcdtfamcbyd:W:2:cjbHjjjjbbgYBdbakaKclfBd2dnadci6mba8KcxfhsavhPcbhzinaPazBdbaYazfcdcbasIdbg8JJbbbb9DEa8JJbbbb9EV86bbaPclfhPasczfhsamazcefgz9hmbkkdnalTmbcbhIakydlh8Rakydbh8SinaIcdthzdna8SaIcefgIcdtfydbgsa8SazfydbgzSmbasaz9RhQa8RazcdtfhLcbhRinaLaRcdtfg8Uydbgzcd4g8Vci2g8WazciGcdtgsyd:e:G:cjbfhza8Wasydj:G:cjbfhsdnaeTmbaeazcdtfydbhzaeascdtfydbhskdnaRcefgRaQ9pmbaxazcdtfydbhKaxascdtfydbhEaYa8Vfh8Aava8Vcdtfh8XaRhwinaLawcdtfgXydbgzcd4gsci2gOazciGcdtgzyd:e:G:cjbfhPaOazydj:G:cjbfhzdnaeTmbaeaPcdtfydbhPaeazcdtfydbhzkdndnaxazcdtfydbaKSmbaxaPcdtfydbaE9hmekaYasfRbbgza8ARbbgPVciSmbdnazaPGmba8VhPdna8Va8XydbgzSmba8XhHinaHavazgPcdtfgrydbgzBdbarhHaPaz9hmbkkdnasavascdtfgHydbgzSmbinaHavazgscdtfgrydbgzBdbarhHasaz9hmbkkaPasSmbaYasfgHRbbaYaPfgzRbbVciSmeavascdtfaPBdbazazRbbaHRbbV86bbkdna8UydbciGa8WfgsaDascdtfgPydbgzSmbinaPaDazgscdtfgHydbgzBdbaHhPasaz9hmbkkdnaXydbciGaOfgPaDaPcdtfgHydbgzSmbinaHaDazgPcdtfgrydbgzBdbarhHaPaz9hmbkkasaPSmbaDaPcdtfasBdbkawcefgwaQ9hmbkkaRaQ9hmbkkaIal9hmbkkdnadTmbcbhrinarhsdnaraDarcdtfgwydbgzSmbawhPinaPaDazgscdtfgHydbgzBdbaHhPasaz9hmbkkawasBdbarcefgrad9hmbkcbh8Vabcbadcltz:fjjjbhQdnadci6mbaqceGhKaDhLaeh8Acbh8Windna8Ka8WcltfgPIdxJbbbb9Bmbaea8Wci2gEcdtfhXcbhsa8VhwinaQaLasfydbcltfhzdndnaeTmba8AasfydbhHaXasc:e:G:cjbfydbcdtfydbhOaXascj:G:cjbfydbcdtfydbhxxekasc:e:G:cjbfydbaEfhOascj:G:cjbfydbaEfhxawhHkazaPIdbghaoaHaA2cdtfgrIdbg8JaPIdwg8EarIdwggNaha8JNaPIdlg5arIdlghNMMgaN:tg8FJbbbbJbbjZa8EagaaN:tg8Ea8ENa8Fa8FNa5ahaaN:tgaaaNMMg8F:r:va8FJbbbb9BEJ;As6nJbbjZaiaxaC2cdtfgrIdwaiaHaC2cdtfgHIdwg3:tg8Faga8FagNarIdbaHIdbg8L:tg8Ma8JNaharIdlaHIdlg8N:tgyNMMg8FN:tg5aiaOaC2cdtfgHIdwa3:tg3aga3agNaHIdba8L:tg8Pa8JNahaHIdla8N:tg8NNMMg3N:tggNa8Ma8Ja8FN:tg8La8Pa8Ja3N:tg8JNayaha8FN:tg8Fa8Naha3N:tghNMMJbbbbJbbjZa5a5Na8La8LNa8Fa8FNMMagagNa8Ja8JNahahNMMNg8J:rgg:va8JJbbbb9BENgh:lg8Ja8JJbbjZ9EEg8Ja8JJ7;A9s89NJ:L9t9s::MNJ;ob;jZMJbbjZa8J:t:rNg8J:ta8JahJbbbb9DENg8Jaga8JNaKEg8JNazIdbMUdbazaaa8JNazIdlMUdlaza8Ea8JNazIdwMUdwawcefhwasclfgscx9hmbkkaLcxfhLa8Acxfh8Aa8Vcifh8Va8Wcefg8Wam9hmbkcbhrinarhsdnaravarcdtfgPydbgzSmbinaPavazgscdtfgHydbgzBdbaHhPasaz9hmbkkaQarc8W2fgzc3fJbbjZJbbj:;aYasfRbbceGEg8JUdbazc8Sfa8JUdbaza8JUdxarcefgram9hmbkkaqcdGhvcbhsaDhPaQhzindnasaPydb9hmbdndnazcwfgHIdbg8Ja8JNazIdbggagNazclfgrIdbghahNMMgaJbbbb9BmbaHa8JJbbjZaa:r:vgaNUdbarahaaNUdbazagaaNg8JUdbxekaHa8JJbbbbNUdbarahJbbbbNUdbazagJbbbbNg8JUdba8JJbbjZavEh8Jkaza8JUdbkaPclfhPazczfhzadascefgs9hmbkcbhzaQhsindnazaDydbgPSmbasaQaPcltfgPydwBdwasaP8Pdb83dbkaDclfhDasczfhsadazcefgz9hmbkkdnakyd2gsTmbascdtakcxffc98fhzinazydbcbyd:0:2:cjbH:bjjjbbazc98fhzascufgsmbkkakc;Wbf8Kjjjjbk;:levucualcefgocdtaocFFFFi0Ecbyd:W:2:cjbHjjjjbbhoavavyd9GgrcdtfaoBdbavarcefBd9GabaoBdbcuadcdtadcFFFFi0Ecbyd:W:2:cjbHjjjjbbhoavavyd9GgrcdtfaoBdbavarcefBd9GabaoBdlabydbclfcbalcdtz:fjjjbhoadci9UhwdnadTmbdnaeTmbaehvadhrinaoaiavydbcdtfydbcdtfgDaDydbcefBdbavclfhvarcufgrmbxdkkadhraihvinaoavydbcdtfgDaDydbcefBdbavclfhvarcufgrmbkkdnalTmbcbhraohvinavydbhDavarBdbavclfhvaDarfhralcufglmbkkdnadci6mbabydlhrcbhlcdhvindndnaeTmbaiaealfgqydbcdtfhDaiaqcwfydbcdtfhdaiaqclfydbcdtfhqxekaialfgDcwfhdaDclfhqkadydbhdaqydbhqaoaDydbcdtfgDaDydbgDcefBdbaraDcdtfavc9:fBdbaoaqcdtfgDaDydbgDcefBdbaraDcdtfavcufBdbaoadcdtfgDaDydbgDcefBdbaraDcdtfavBdbalcxfhlavclfhvawcufgwmbkkabydbcbBdbk:SEvxui99duv99xu8Jjjjjbc;Wb9Rgw8Kjjjjbawcxfcbc;Kbz:fjjjb8AawcualcdtalcFFFFi0Ecbyd:W:2:cjbHjjjjbbgDBdxawceBd2adci9Uhqalcd4alfhkaoz:mjjjbhocehxinaxgmcethxamak6mbkawcuamcdtgxamcFFFFi0Ecbyd:W:2:cjbHjjjjbbgkBdzawcdBd2akcFeaxz:fjjjbhPavcd4hsdnalTmbamcufhzcbhHindndnaPcbaiaHas2cdtfgmydlgvavcjjjj94SEgxcH4ax7c:F:b:DD2cbamydbgOaOcjjjj94SEgxcH4ax7c;D;O:B8J27cbamydwgAaAcjjjj94SEgmcH4am7c:3F;N8N27azGgkcdtfgmydbgxcuSmbaA::hCav::hXaO::hQcehvinavhmdnaiaxas2cdtfgvIdbaQ9CmbavIdlaX9CmbavIdwaC9BmikamcefhvaPakamfazGgkcdtfgmydbgxcu9hmbkkamaHBdbaHhxkaDaHcdtfaxBdbaHcefgHal9hmbkkcbhkaPcbyd:0:2:cjbH:bjjjbbawceBd2aw9cb83ibawaeadaDalawcxfz:cjjjbcuaqcltadcFFFFd0Ecbyd:W:2:cjbHjjjjbbhLawcxfawyd2gKcdtfaLBdbawaKcefgOBd2dnadci6mbaehxaLhmaqhHindndnaeTmbaxcwfydbhzaxclfydbhvaxydbhPxekakcdfhzakcefhvakhPkJbbbbhQdnaiavas2cdtfgvIdbaiaPas2cdtfgPIdbgX:tgYaiazas2cdtfgzIdlaPIdlgC:tg8ANavIdlaC:tgCazIdbaX:tgEN:tgXaXNaCazIdwaPIdwg3:tg5NavIdwa3:tg3a8AN:tgCaCNa3aENaYa5N:tgYaYNMMg8AJbbbb9BmbJbbjZa8A:r:vhQkamcxfa8AJbbbb9CBdbamcwfaXaQNUdbamclfaYaQNUdbamaCaQNUdbaxcxfhxamczfhmakcifhkaHcufgHmbkkcbhmawcxfaOcdtfcuadcdtg8EadcFFFFi0Ecbyd:W:2:cjbHjjjjbbgvBdbawaKcdfg8FBd2dnadTmbavhxinaxamBdbaxclfhxadamcefgm9hmbkkdnalTmbcbhaawydlhhawydbhginaacdthmdnagaacefgacdtfydbgxagamfydbgmSmbaxam9RhAahamcdtfh8Jcbh8Kina8Ja8Kcdtfg8Lydbgmcd4gkci2g8MamciGcdtgxyd:e:G:cjbfhma8Maxydj:G:cjbfhxdnaeTmbaeamcdtfydbhmaeaxcdtfydbhxkdna8Kcefg8KaA9pmbaLakcltfhOaDamcdtfydbh8NaDaxcdtfydbhya8KhHina8JaHcdtfg8Pydbgmcd4gkci2gzamciGgPcdtgmyd:e:G:cjbfhxazamydj:G:cjbfhmdnaeTmbaeaxcdtfydbhxaeamcdtfydbhmkdndnaDamcdtfydba8NSmbaDaxcdtfydbay9hmekaOIdwaLakcltfgmIdwNaOIdbamIdbNaOIdlamIdlNMMao9ETmbaOydxamydx9hmbdna8LydbciGa8MfgxavaxcdtfgkydbgmSmbinakavamgxcdtfgPydbgmBdbaPhkaxam9hmbka8PydbciGhPkdnaPazfgkavakcdtfgPydbgmSmbinaPavamgkcdtfgzydbgmBdbazhPakam9hmbkkaxakSmbavakcdtfaxBdbkaHcefgHaA9hmbkka8KaA9hmbkkaaal9hmbkkdndndnadTmbcbhzinazhxdnazavazcdtfgHydbgmSmbaHhkinakavamgxcdtfgPydbgmBdbaPhkaxam9hmbkkaHaxBdbazcefgzad9hmbkcbh8Mabcbadcx2z:fjjjbh8Padcd9nmeavhAaeh8NcbhyinaLaycltfhkaeayci2g8JcdtfhDcbhxa8MhHina8PaAaxfydbcx2fhmdndnaeTmba8NaxfydbhzaDaxc:e:G:cjbfydbcdtfydbhOaDaxcj:G:cjbfydbcdtfydbhPxekaxc:e:G:cjbfydba8JfhOaxcj:G:cjbfydba8JfhPaHhzkamakIdbaiaPas2cdtfgPIdwaiazas2cdtfgzIdwgC:tgoaoNaPIdbazIdbgY:tgQaQNaPIdlazIdlg8A:tgXaXNMMaiaOas2cdtfgPIdwaC:tgCaCNaPIdbaY:tgYaYNaPIdla8A:tg8Aa8ANMMNgE:rg3J;As6nJbbjZaoaCNaQaYNaXa8ANMMJbbbbJbbjZa3:vaEJbbbb9BENgQ:lgoaoJbbjZ9EEgoaoJ7;A9s89NJ:L9t9s::MNJ;ob;jZMJbbjZao:t:rNgo:taoaQJbbbb9DENgoNamIdbMUdbamakIdlaoNamIdlMUdlamakIdwaoNamIdwMUdwaHcefhHaxclfgxcx9hmbkaAcxfhAa8Ncxfh8Na8Mcifh8MaycefgyaqSmdxbkkabcbadcx2z:fjjjb8Axekcbhxavhka8Phmindnaxakydb9hmbJbbbbhodnamcwfgPIdbgQaQNamIdbgXaXNamclfgzIdbgCaCNMMgYJbbbb9BmbJbbjZaY:r:vhokaPaQaoNUdbazaCaoNUdbamaXaoNUdbkakclfhkamcxfhmadaxcefgx9hmbkkdnarJbbbb9ETmbawcxfa8Fcdtfcuadcltg8Pa8EcFFFFi0Ecbyd:W:2:cjbHjjjjbbg8JBdbdndnar:ngo:lJbbb9p9DTmbao:Ohmxekcjjjj94hmkaKcifh8Famce9imbamcqamcq9iEh8Nadci6hLcbhAina8Jcba8Pz:fjjjbhPdnaLmbcbhDavhOinavaDcx2fhecbhxinabaOaxfydbgzcx2fgmIdwhoabaeaxcj:G:cjbfydbcdtfydbgHcx2fgkIdwhQamIdbhXakIdbhCamIdlhYakIdlh8AaPazcltfgmamIdxJbbjZMUdxamamIdbaCaX:taoaQNaXaCNaYa8ANMMgXaXNJbbbbaXJbbbb9EEgXNgCMUdbamamIdla8AaY:taXNgYMUdlamaQao:taXNgoamIdwMUdwaPaHcltfgmamIdxJbbjZMUdxamamIdbaC:tUdbamamIdlaY:tUdlamamIdwao:tUdwaxclfgxcx9hmbkaOcxfhOaDcefgDaq9hmbkkdnadTmbaraA:Z:tgoJbbjZaoJbbjZ9DEJbbbZNh8AcbhxavhkabhzaPhmindnaxakydb9hmbamcxfIdbgQJbbbb9ETmbJbbbbhodnamcwfIdba8AaQ:vgQNazcwfgPIdbMgXaXNamIdbaQNazIdbMgCaCNamclfIdbaQNazclfgHIdbMgQaQNMMgYJbbbb9BmbJbbjZaY:r:vhokaPaXaoNUdbaHaQaoNUdbazaCaoNUdbkakclfhkazcxfhzamczfhmadaxcefgx9hmbkkaAcefgAa8N9hmbkkdnadTmbcbhmabhxindnamavydbgkSmbaxabakcx2fgkydwBdwaxak8Pdb83dbkavclfhvaxcxfhxadamcefgm9hmbkkdna8FTmba8Fcdtawcxffc98fhminamydbcbyd:0:2:cjbH:bjjjbbamc98fhma8Fcufg8Fmbkkawc;Wbf8Kjjjjbk9teiucbcbyd:4:2:cjbgeabcifc98GfgbBd:4:2:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabk9teiucbcbyd:4:2:cjbgeabcrfc94GfgbBd:4:2:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikTeeucbabcbyd:4:2:cjbge9Rcifc98GaefgbBd:4:2:cjbdnabZbcztge9nmbabae9RcFFifcz4nb8Akk9pee98abab:Igbabab:Ige:Iab9e9P9q;U;G9c:t;58::I9e8N8Es;O:h;a9w:;:G:Iae9e9c86v;H9t9v:LZ:Iab9e:b9ExpFF;F:;:I9ebbbbbb;WZ:G:G:G:2k0ed98ababab:Ige:Igdaeae:I:Iae9e:NS87:m:h;n;g8::I9et;N;k;I;5bI:;:G:Iadae9e:Y;79U:jzH:bZ:I9e93:S;l9u9v9v;f:;:G:Iab:G:G:2k:K8Flqud98zul988Jjjjjbc:Wl9Rgv8Kjjjjbcbhoadc99fcK9Tgrcbarcb9kEgwc9O2adfhDdnalcdtc:q:G:cjbfydbgqaicufgkfgdcb9imbawak9RhxdnadTmbaqaifgdceGhmawcdtaicdt9Rc:O:G:cjbfhradc9:GhPavc;adfhdcbhoin9ebbbbbbbbhs9ebbbbbbbbhzdnaxaofgHcb9imbarc98fydb:3hzkadaz85ibdnaHcu9imbarydb:3hskadcwfas85ibadczfhdarcwfhraPaocdfgo9hmbkamTmeaxaofhxkdndnaxcb9omb9ebbbbbbbbhzxekaxcdtyd:G:G:cjb:3hzkavc;adfaocitfaz85ibkaDc9OfhOcbhdaqcbaqcb9kEhmaic;:FFFrGhHaiceGhAaicitavc;adffc9WfhPinadhxdndnaice9omb9ebbbbbbbbhzxekcbhr9ebbbbbbbbhzdnakTmbaPhdabhoinaocwf8Ribad8Rib:Iao8Ribadcwf8Rib:Iaz:G:Ghzadc9WfhdaoczfhoaHarcdfgr9hmbkaATmekabarcitf8Ribavc;adfaxakfar9Rcitf8Rib:Iaz:Ghzkavaxcitfaz85ibaPcwfhPaxcefhdaxam9hmbkaic;:FFFrGhHaiceGhCc8VaD9RhXc8WaD9RhQavc;Gifc98fgLaqcdtfhKawcdtc:G:G:cjbfhwavc;adfc94fhYavc;Gifc9Wfh8Aavc9WfhEaDc9Nfh3aqhxdninavaxcitgdf8Ribhzdnaxce9imbcbhrdndnaxce9hmbaxhdxekaxceGhmaxc;:FFFrGhPaEadfhdcbhravc;Gifhoinaoaz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbaoclfadcwf8Ribas:Ggz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbad8Ribas:Ghzaocwfhoadc9WfhdaParcdfgr9hmbkamTmeaxar9Rhdkavc;Gifarcdtfaz9ebbbbbb9W8::I;8d:3gs9ebbbbbb9W;b:Iaz:G;8dBdbavadcitfc94f8Ribas:GhzkazaOz:njjjbgz9ebbbbbb;aZ:I:C9ebbbbbba;a:Iaz:Ggzaz;8dg5:3:HhzdndndndndnaOce9ig8Embavc;Gifaxcdtfc98fgdadydbgdadaQ91gdaQt9RgoBdbaoaX91h8Fada5fh5xekaOmeavc;Gifaxcdtfc98fydbcL91h8Fka8Fce9imdxekcdh8Faz9ebbbbbb;GZ9Mmbcbh8Fxekcehodnaxce9imbcbhrcbhPdnaxceSmbaxceGhaaxc;:FFFrGhAcbhravc;GifhdcbhPinadydbhodndndndnaPTmbcFFFrhPxekaoTmecjjjwhPkadaPao9RBdbcbhPxekcehPkadclfgmydbhodndndndnaPmbcFFFrhPxekaoTmecjjjwhPkamaPao9RBdbcehPcbhoxekcbhPcehokadcwfhdaAarcdfgr9hmbkaaTmekavc;GifarcdtfgrydbhddndnaPTmbcFFFrhoxekcehoadTmecjjjwhokaraoad9RBdbcbhokdna8EmbcFFFihddndna3PdebdkcFFFehdkavc;Gifaxcdtfc98fgrarydbadGBdbka5cefh5a8Fcd9hmb9ebbbbbb;WZaz:Hhzcdh8Faombaz9ebbbbbb;WZaOz:njjjb:Hhzkdnaz9ebbbbbbbb9Imbdnaxaq9mmbaxaq9RgdciGhrcbhoaxhPdndnaqax9Rc980mbadc98Ghma8AaxcdtfhdcbhoaxhPinadydbadclfydbadcwfydbadcxfydbaoVVVVhoadc9WfhdaPc98fhPamc98fgmmbkarTmekaLaPcdtfhdinadydbaoVhoadc98fhdarcufgrmbkkaoTmbavc;Gifaxcdtfc98fhdinaxcufhxaOc9OfhOadydbhoadc98fhdaoTmbxlkkaKhdaxhPinaPcefhPadydbhoadc98fhdaoTmbkaYaiaxfcitfhminavc;adfaxaifgAcitfawaxcefgxcdtfydb:385ibdndnaice9omb9ebbbbbbbbhzxekcbhr9ebbbbbbbbhzdnakTmbamhdabhoinaocwf8Ribad8Rib:Iao8Ribadcwf8Rib:Iaz:G:Ghzadc9WfhdaoczfhoaHarcdfgr9hmbkaCTmekabarcitf8Ribavc;adfaAar9Rcitf8Rib:Iaz:Ghzkavaxcitfaz85ibamcwfhmaxaP9imbkaPhxxekkdndnazcKaD9Rz:njjjbgz9ebbbbbb9Wc9MTmbavc;Gifaxcdtfaz9ebbbbbb9W8::I;8dgd:39ebbbbbb9W;b:Iaz:G;8dBdbaxcefhxaDhOxekaz;8dhdkavc;GifaxcdtfadBdbkdnaxcb9imb9ebbbbbb;WZaOz:njjjbhzdndnaxceGTmbaxhoxekavaxcitfazavc;Gifaxcdtfydb:3:I85ibaxcufhoaz9ebbbbbb9W8::IhzkdnaxTmbaocefhraocdtavc;Giffc98fhdaocitavfc94fhoinaoaz9ebbbbbb9W8::Igsadydb:3:I85ibaocwfazadclfydb:3:I85ibadc94fhdaoc9Wfhoas9ebbbbbb9W8::Ihzarc9:fgrmbkkavaxcitfhHaxhdindndnaqaxadgi9RgAaqaA9iEgdcb9omb9ebbbbbbbbhzxekadcefgociGhrdndnadci9pmbcbhd9ebbbbbbbbhzxekcbhPcbaoc98G9Rhm9ebbbbbbbbhzcbhdinadc1:2:cjbf8RibaHadfgocKf8Rib:Iadcj:2:cjbf8Ribaoczf8Rib:Iadc;4:1:cjbf8Ribaocwf8Rib:Iadc;W:1:cjbf8Ribao8Rib:Iaz:G:G:G:GhzadcafhdamaPc98fgP9hmbkarTmecbaP9Rhdkadcithdinadc;W:1:cjbf8RibaHadf8Rib:Iaz:Ghzadcwfhdarcufgrmbkkavc:GefaAcitfaz85ibaHc94fhHaicufhdaicb9kmbkkdndndndndnalPleddblk9ebbbbbbbbhhdnaxce9imbaxhddnaxceGTmbavc:Gefaxcitfgdc94fgoao8Ribgzad8Ribgs:Ggg85ibadasazag:H:G85ibaxcufhdkaxceSmbadcdfhoadcitavc:Geffc9Wfhdinadad8Ribgsadcwfgr8RibggadczfgH8Ribg8J:Ggz:Gg8K85ibaHa8Jagaz:H:G85ibarazasa8K:H:G85ibadc9Wfhdaoc9:fgocd9kmbkaxceSmbaxcefhoaxcitavc:Geffc94fhdinadad8Ribgzadcwfgr8Ribgs:Ggg85ibarasazag:H:G85ibadc94fhdaocufgocd0mbkaxcefhoavc:Gefaxcitfhd9ebbbbbbbbhhinahad8Rib:Ghhadc94fhdaocufgocd0mbkkav8Ri:Gehza8Fmdaeaz85ibaeah85izaeav8Ri:Oe85iwxikdndnaxcb9omb9ebbbbbbbbhzxekdndnaxciGci9hmb9ebbbbbbbbhzaxhoxekaxcefciGhravc:Gefaxcitfhd9ebbbbbbbbhzaxhoinaocufhoazad8Rib:Ghzadc94fhdarcufgrmbkkaxci6mbaocefhraocitavc:Geffc9OfhdinazadcKf8Rib:Gadczf8Rib:Gadcwf8Rib:Gad8Rib:Ghzadc9Gfhdarc98fgrmbkkaeaz:Aaza8FE85ibxdkdndnaxcb9omb9ebbbbbbbbhzxekdndnaxciGci9hmb9ebbbbbbbbhzaxhoxekaxcefciGhravc:Gefaxcitfhd9ebbbbbbbbhzaxhoinaocufhoazad8Rib:Ghzadc94fhdarcufgrmbkkaxci6mbaocefhraocitavc:Geffc9OfhdinazadcKf8Rib:Gadczf8Rib:Gadcwf8Rib:Gad8Rib:Ghzadc9Gfhdarc98fgrmbkkaeaz:Aaza8FE85ibav8Ri:Geaz:Hhzcehddnaxce9imbaxciGhodnaxcufci6mbaxc;8FFFrGhHavc:Gefcafhdcbhrinazadc9Of8Rib:Gadc9Wf8Rib:Gadc94f8Rib:Gad8Rib:GhzadcafhdaHarclfgr9hmbkaoTmearcefhdkavc:Gefadcitfhdinazad8Rib:Ghzadcwfhdaocufgombkkaeaz:Aaza8FE85iwxekaeaz:A85ibaeah:A85izaeav8Ri:Oe:A85iwkavc:Wlf8Kjjjjba5crGk:ediiue98eu8Jjjjjbcz9Rgd8Kjjjjbdndnab:8gicFFFFrGglc;A:F:K;Ul0mbaeab:7gvav9e:d;i;j9T8W9F;KZ:I9ebbbbbbUJ:G9ebbbbbbU;d:Ggv9ebbb9q;7h;5:;:I:Gav9e9J9I8A9H:0z9r:::I:G85ibav;8dhlxekdnalcjjj;8r6mbaeabab:t:785ibcbhlxekadalalcL4c;Q9:fgocLt9R:::785iwadcwfadaocecbz:kjjjbhlad8Ribhvdnaicu9kmbaeav:A85ibcbal9Rhlxekaeav85ibkadczf8Kjjjjbalk;piiiue99e988Jjjjjbcz9Rge8Kjjjjbdndnab:8gdcFFFFrGgic;A:F:K;6i0mbJbbjZhlaicjjj;mi6meab:7z1jjjbhlxekdnaic;r:N;T:dl0mbdnaic;K:x;Bjl6mb9eKR9e9u;7hDn9eKR9e9u;7hD;aadcb9iEab:7:Gz1jjjb:mhlxdkab:7hvdnadcu9kmbav9eKR9e9u;7h;5Z:Gz:jjjjbhlxdk9eKR9e9u;7h;5Zav:Hz:jjjjbhlxekdnaic;v;J1:hl0mbdnaic;G;B:;:fl6mb9eKR9e9u;7hYn9eKR9e9u;7hY;aadcb9iEab:7:Gz1jjjbhlxdkdnadcu9kmb9e;sh8Zu98;zO;aab:7:Hz:jjjjbhlxdkab:79e;sh8Zu98;zO;a:Gz:jjjjbhlxekdnaicjjj;8r6mbabab:thlxekabaecwfz:ljjjbhiae8RiwhvdndndndnaiciGPlbedibkavz1jjjbhlxikav:Az:jjjjbhlxdkavz1jjjb:mhlxekavz:jjjjbhlkaeczf8Kjjjjbalk:Uebdndnaecjw9imbab9ebbbbbb;Gu:IhbdnaecFs9pmbaec:b94fhexdkab9ebbbbbb;Gu:IhbaecpLaecpL6Ec:c9Wfhexekaec:b949kmbab9ebbbbbb9Gi:Ihbdnaec:49W9nmbaec;jrfhexekab9ebbbbbb9Gi:Ihbaec;W9Oaec;W9O0EcMsfhekabaecFrf:T9c80:g:;:Ikk;mQdbcj:Gdk:WQebbbdbbbbbbbebbbibbblbbblbbbobbb:d;5:Ib9e9o9Ub;88PXb;r9x8Nb;D80;1b9I;B;ab88:z:vbc:qJb9J9r;:b:7;E:Rb:39H;fb869U8Kb;s9n9cb6o;GbD;Q8Ub3M;rb;R5;:b8P:X3b;O8::Nb;181:cb9e:78Ub:C;P:eb:08M9Wbc9:9Fb;w:r85b9t:d85b:C;085b:l9F:eby;5:9b;48F87b;EF:xbs:yvbH8V;Vbq9A:lb9T8F9Tb;p9:BbD;l8NbS9p:3b:E9MZbR;Q9Fb:68N91b;L;R;hb8997;Xb;385rbM9s:kb;79R;Qb8F:X9Fbw9D:nb8Wi9wb97;8Sb;W:R9Rba:8;pbB;0:Ab;J:P5b9E9H:rbwE;Mb:f:zWb:GC9Fb:nn9Obj;yFb8N79nboo8Xb;k9wXb;j:O7b97;I9Gb9R:m;abY;e9hb;n9N;dbD;O;Cb9z:dIb:l4;eb:M3:wb9e:V;DbY9x;rb:L8:vbvrFb8Z9:Zb;c8Y;Ob:y9p;Eb:7998Yb8M89;db8E9R;Vb:F;49Eb818F86bu;Y;kb;X:h5b98:qhbf8K98b;v9U;6b8WR93bX87Jb:1C;gb;dY:Db:T;e;cb8S9ncbxb9Db:g99Sb;JGRb:B;g:Ab8Z9Ibb:0;s98b:0:N:xb839v;vb;x8:;2b:JzKb9n4;8b9K:DIb9W;x:Rb9J98;4b96:W9xbLX;Nb;a69wb87;w;zb:N:eUb8K8J;lb;w:k93b9A9u8Jbb8F:5b;XqEbY;o;Fb:F8XFb9M8Efb:z9x9Hb:S;79hb9:u;ybgW:3b8Y;O:jb;M:;9Gb;V;e;nb2BDb9DZ;ubQ;E;xb9y87;Eb;E:BMb;sgyby:g;Ob;I9y9nb;g;k8Ybw;JQb;G99;lbL;a9qb;Z5:NbK;G9Bb8UA80b:dO9Ib:d9ieb;1:o9Bb:T:Wub8E;P;Yb9i9kJbz9N;tb:Q;D;yb:U9F9cbf9H;obqy:Kb;t:z:0bo:M;Yb9C93ub:J;c:db9H881b:k794b:V:m9Ab9V;x:9bR:M9Jb;0:;;lb:n:b;Vb8M;b9Nb9v;kTb;k;zBby:O;sb;c9H:nbO;j93bl8MCbOS:Bb;e9z;eb;i;f9eb9n:Y:rbbL;Zb;uJ:Tb8P6;Lbp;vzbb::;8b8EN;mb9W;o;UbA8:;1b;S;Xjb:Z;N;db;h;4yb:tvNb;bG8:b8UD:ZbkT;Zb1O:Cb:Ra97b8U:1:Fb9hM;cb978Y8Vbx9v9TbV:N:qb9R;N8Fb8X;l:wb95Q9kbc95;Ib;0;F:jb;ON:xb;I;M:eb:z8X:xb1;T9Rb9F9FBb:7pPb9i:A:0b9N:K2bGV9cb:n9D8Yb:FX:4b:8;LDb:n8X8Lb;3t85b8Wv3bmxeb0w9Ob8S;U9yb9h:Q:qbt;Ndb:9;w8Kb;399:Mb9U9iVb:FQ;Vb:oN:Mb:0:r;2b;r9t9rb;pq;Yba:y8Zb;109:b:Y9J9Ob;D8:9Fbn9Dib:f:jub9v9s8Pb839K;ab9T;yzb8Y9i8Yb9B9m91b9oG;ubT9u9UbkD;bbI;19PbC9M;vb8Nr:Db9Dl9qb:087;Bb;Q4;fb:h;5Lb69R99b58N:6b:w9P8Pb;g;m:Sb:TC9ub:q;Ifb1;z:jb8SV9qbl:K::b93rNb;Z8W9Wbb;88Nb;QG:Ob9M;c6b9K;G89b:x;D:db:JZ:xbJNpbm:g:mb8Xc;EbM85:Db;D9W:mbL:3;Nbw;F87bX838Rb9Cj:Gb9Aj:tbzHMbs;O;yb2j:Vb;BF0bU:qsb9zK4b9I:LXb9H;l:7b;h:j:5bzn:9b;s;Ylb6918Nb;R:2;2b;Bg:7bqC:Qb:j8M8Vb9K:d4bD878ZbPN8Ab9r86:Qb5:J;cb:V;T:Ub9C8MOb9T;c9nbR96:Cb;a9w:xbiZ:dbD;W;2b8Rn:mb9T8X:zb85:0rbxaXb;y;d9Bb;1M;eb;g:T0b9o;k:Lb:N83;nb;M:PBb:RMNb;D9c9ObY9J;Eb4:m;Vb9O:l9sb;8;B83b:U:H:Rb;FX8Xbb:U:Hbx;7;Ab9K9n9Mb;Tv:3b8PW8Wb9x9w:;b9hF86bf;5:5b91::;Zby:t;Fb:Rj8Wb9M:m;2bl;lXb;6gob;z;K5b89:Z:Kb9xE:pbB;nDb9o9c;PbA:::Kb8Z8J:1b;W:Q8Ab9pW:Ob;s;b:LbkZsb9B94;nb8J;54b97:llb:jLVb;g:M9tb9V9U;Ib;V;Rbb:B9k9yb;e;A:3b:Q9M:6b4;p;pb;rd5b:X;XRb:m:z;bb;d:T93b:g9i;Ab;39D:Gb;gj;0b:S;W8Vb;D;S:AbZ9C:8b;q;E9Tb:q;h8FbI;B:2b:J8L86bb:V:Ab:T9t:tb:29xlb8PR:0b0j9:b;Ar:Nb4:QPb979z:HbQOIb;C:3Rb;6;Lpb:j;B;:b:j::pb;K42bo:P;8b8:j9Wb:f9UXbp:hFby8:rb9H9N8ZbIK:gb9n:9;Qb:Z;N:Vb:p9T9Ub:v9N85b8X:;9Bb:e;x9ib8W;FQb;hRJb8L9H81b;j9W;ob8W;l:4b:;2pb:Kb:Ibv2;Kb9A;D:Gbh9V9hb9IO;sb:59C:eb9W9H6b9R9w;Gb:z9seb9q9v83b8E;v:3b8Z;X;ebA9U9Fb9D8W;Kb:f8U:Pb5:Y;db:H8YBbw:3:Kb;Q:X;ubQ;3hb:p9P;Kb8NF93bxijb:nnRb9p;n:Gba:L:zb:Z:I;tb8V9Dqb:0;59cbH;A;lb99::;qb:B;B;bb:RL:9b;k:I:bbwf9Cb8U9vLb8Nb9vbuC;Wb;Hr:gbCk9Kb:wc:nb:h::;Eb;ApIb9R8L:2b97:j80bv;Z;:b:5:;:Eb9Of9pb9kI:Ob9p;e9AbR;4:8b;x9A:yb;0;h:vbm9n:nba86:Mb:K9x9FbCZ:XbjU:vb;maebG;D:gb;j;E:2b:;9G;1b9nWHber9Rb:m:W:Sb:Y;a;qb9r9v9ib8E;7Pb:vV;db:Jo87b;an81bo;C97b;GT;mb9o8P;6b;w;k;ib;O;Zcb989K;Eb:B9K;yb;z::8Xb:K:x;db939y;ub9P;J;fb;W;AAb:68688bSKSb9v919Fb;s:9;1b9UM;gb:S8U9DbP9e;Tb38:9cb9H;e:hb8Pp;Pb;N;w;Zbg98;kb9V:r81bw;G;fbF;x:nb9Uf;Ib:Wp;gb:tw;bb989Dtb9R:T:Yb;n9U:Db8:V97b;gHfb;3;p:Pb8P7;Fb:1;j:6b:3b9rb;I:Ymbt:68Kb;L999Gbt;y:kbmX8Sb:bKxb9:9MNbe8PQb:F964bpp::b9wT;Vb;z9:Bb;S;zAb:l:6:5b;e:x;8b8X:O8Nb;X9U;dbN;fBb;y:O9wb:0:O:1b;p;mPbO:jRb9V9x80b8S9w:jb:z;o;Jb;wa:5b9R9E:Qb8:I:CbH9F;mbpk9kb;H;0;7b:o879Tb;I:g8Sb;P;u:eb;8:0:Pb;V;U;rb8U81;jb8V859HbUh9ebE;z;ib:b;8qb;79kfb8V3;yb9t:0:eb9o:z:mb9ug;mbI9v;Cb;a;g;wbkY:wb8A9W:4b9P:v9Kb8M9A9GbZ9s;UbuHsb;0:1Hb;8;l;1b80:8Rb80:8;Ub;O9D;mb;D9E9Gb9N:o:BbM8Z;Vb;jL:4b9H9y:Bb;H9x:8b9r:d;gb;y8:zb;DG9ibR3;Db:VK:Hbh8SSb9z;Z;xb;z96:yb:E9u;ab9p:g;6b9wo;8b;L95:Ub:jgBbU:Tgb9N:t;Cb9v;O:Qb:c8MUb;k;N:Bb9rm:Kb:z8Z:Xb:P;xPb9Pv9ibW:Y;Wbu1:Nb19m:xb;5;rBbhM:Zb97:c9kb:y;phbn:F;Cb;C9h9vb;Ht86b9N;R9cb;::D;Fb9E;u9Fb979N:Kb:6:S96b9v;2:Ib8R18Jbc:69vb9z9UwbhI:gb859h:db:j;J;Mb;L:E;ub6;7nbF9w;Pb3s;kb;f9z:kbN;68Rb;t;b;fbs;f;pb;B9A:Ub9h;f:gb:fJ9Ibh:g87b8S95Nbz9H:hbI9m97bj8S8AbJ:;Ob18M:qb9488:jb:O;e;Kb;L;B97b;e86;cb8M;0;Qb;39N:kbmM:;bW:J8Rb89:t:Xb:998kb:K9r;Cb8N;D9Jb9P;H;Db:ANYb:O8P:vb9O;oybD;T:0b9e:Fab9o:y;kb9W:c9Jb9:988Jbs:58Yb:N;1:obC9w;Nbh;Xwb:1:DIb9V9:9nb:LY9rb:1;5:Rb:c;F;wb:w;D9HbQBdb;e86:Fb:d:I:HbV;T9Tb85:n96b:c:4:Pb9R8Y9CbS8N9Bbb80;Tb;sb93b;8;09vbe9z9nb;GGjbbbbbbbbbbbbn;7h;5ZbbbbR9et8:bbbj:yS;488bbb9G9r;m9487bbbj:dE;W85bbbna8L96Ubbbjg:c;JBbbbb5;Z9P81bc:W:2dkxebbbdbbbn:Bbb",t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=="object")return{supported:!1};var n,r=WebAssembly.instantiate(i(e),{}).then(function(u){n=u.instance,n.exports.__wasm_call_ctors()});function i(u){var d=new Uint8Array(u.length);for(var f=0;f<u.length;++f){var h=u.charCodeAt(f);d[f]=h>96?h-97:h>64?h-39:h+4}var b=0;for(var f=0;f<u.length;++f)d[b++]=d[f]<60?t[d[f]]:(d[f]-60)*64+d[++f];return d.buffer.slice(0,b)}function a(u){if(!u)throw Error("Assertion failed")}function s(u){return new Uint8Array(u.buffer,u.byteOffset,u.byteLength)}function o(u,d,f,h,b,m,g,p,y,v){var x=n.exports.sbrk,_=x(d*16),E=u?x(u.byteLength):0,w=x(f.byteLength),A=x(m.byteLength),T=x(p.byteLength),N=new Uint8Array(n.exports.memory.buffer);if(u)N.set(s(u),E);N.set(s(f),w),N.set(s(m),A),N.set(s(p),T),n.exports.meshopt_generateTangents(_,E,d,w,h,b*4,A,g*4,T,y*4,v),N=new Uint8Array(n.exports.memory.buffer);var M=new Float32Array(N.buffer,_,d*4).slice();return x(_-x(0)),M}function c(u,d,f,h,b,m,g){var p=n.exports.sbrk,y=p(d*12),v=u?p(u.byteLength):0,x=p(f.byteLength),_=new Uint8Array(n.exports.memory.buffer);if(u)_.set(s(u),v);_.set(s(f),x),n.exports.meshopt_generateNormals(y,v,d,x,h,b*4,m,g),_=new Uint8Array(n.exports.memory.buffer);var E=new Float32Array(_.buffer,y,d*3).slice();return p(y-p(0)),E}var l={Compatible:1,ZeroFallback:2};return{ready:r,supported:!0,generateTangents:function(u,d,f,h,b,m,g,p){a(u===null||u instanceof Uint32Array||u instanceof Int32Array||u instanceof Uint16Array||u instanceof Int16Array),a(u===null||u.length%3==0),a(d instanceof Float32Array),a(d.length%f==0),a(f>=3),a(h instanceof Float32Array),a(h.length%b==0),a(b>=3),a(m instanceof Float32Array),a(m.length%g==0),a(g>=2),a(d.length/f==h.length/b),a(d.length/f==m.length/g),a(u!==null||d.length/f%3==0);var y=0;for(var v=0;v<(p?p.length:0);++v)a(p[v]in l),y|=l[p[v]];var x=d.length/f,_=u?u.length:x,E=u===null||u.BYTES_PER_ELEMENT==4?u:new Uint32Array(u);return o(E,_,d,x,f,h,b,m,g,y)},generateNormals:function(u,d,f,h,b){a(u===null||u instanceof Uint32Array||u instanceof Int32Array||u instanceof Uint16Array||u instanceof Int16Array),a(u===null||u.length%3==0),a(d instanceof Float32Array),a(d.length%f==0),a(f>=3),a(u!==null||d.length/f%3==0),a(h>=0&&h<=Math.PI),b=b||0;var m=d.length/f,g=u?u.length:m,p=u===null||u.BYTES_PER_ELEMENT==4?u:new Uint32Array(u);return c(p,g,d,m,f,h,b)}}}()});var UR={};Xb(UR,{MeshoptEncoder:()=>Kz});var zR=ot(()=>{OR();kR();LR();DR();FR()});function dc(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Qf(e,t="|"){return e.map((n)=>nh(n)).join(t)}function fc(e,t){if(typeof t==="bigint")return t.toString();return t}class qb{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 hc(e){return new qb(e)}function Jb(e){return e===null||e===void 0}function ra(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Zb(e,t){let n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<i)return 0;return n-r}function yr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pc(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Si(e){return pc(e._zod.def)??e._zod.def.shape}function Yb(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return yr(this,t,r),r},enumerable:!0,configurable:!0})}function Qb(e,t,n){if(t in e)yr(e,t,n);else e[t]=n}function ls(e,t,n,r){let i=Si(t);for(let a of n){let s=Object.getOwnPropertyDescriptor(i,a);if(!s.enumerable)continue;if(s.get)Yb(e,a,()=>{let o=t._zod.def.shape[a];return r?r(o,a):o});else Qb(e,a,r?r(s.value,a):s.value)}}function CI(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)Yb(e,n,()=>t[n]);else Qb(e,n,r.value)}}function nr(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ex(e){return JSON.stringify(e)}function tx(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var eh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var nx=hc(()=>{if(zn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function us(e){if(Xs(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(Xs(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function th(e){if(us(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 rx=new Set(["string","number","symbol"]),ix=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ii(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yr(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function Ue(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 nh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function ax(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var eu=(()=>({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]}))(),rh={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function NI(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let a={};return ls(a,e,tu(e,t)),Yr(e,nr(n,{shape:a,checks:[]}))}function tu(e,t){let n=Si(e),r=[];for(let i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw Error(`Unrecognized key: "${String(i)}"`);if(t[i])r.push(i)}return r}function PI(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let a=new Set(tu(e,t)),s={};return ls(s,e,Reflect.ownKeys(Si(e)).filter((o)=>!a.has(o))),Yr(e,nr(n,{shape:s,checks:[]}))}function OI(e,t){if(!us(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=Si(e);for(let a of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Yr(e,nr(e._zod.def,{shape:sx(e,t)}))}function sx(e,t){let n={};return ls(n,e,Reflect.ownKeys(Si(e))),CI(n,t),n}function kI(e,t){if(!us(t))throw Error("Invalid input to safeExtend: expected a plain object");return Yr(e,nr(e._zod.def,{shape:sx(e,t)}))}function LI(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={};ls(n,e,Reflect.ownKeys(Si(e))),ls(n,t,Reflect.ownKeys(Si(t)));let r=nr(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Yr(e,r)}function ox(e,t,n,r="partial"){let a=t._zod.def.checks;if(a&&a.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let o=n?new Set(tu(t,n)):void 0,c={};return ls(c,t,Reflect.ownKeys(Si(t)),e&&((l,u)=>o&&!o.has(u)?l:new e({type:"optional",innerType:l}))),Yr(t,nr(t._zod.def,{shape:c,checks:[]}))}function DI(e,t,n){let r=n?new Set(tu(t,n)):void 0,i={};return ls(i,t,Reflect.ownKeys(Si(t)),(a,s)=>r&&!r.has(s)?a:new e({type:"nonoptional",innerType:a})),Yr(t,nr(t._zod.def,{shape:i}))}function _r(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 cx(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 Qr(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function uc(e){return typeof e==="string"?e:e?.message}function ih(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let i=r.maximum??r.length??r.size;if(i>=0)t.push([i,n])}return t}function nu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function ei(e,t,n){var r;let i=e.inst?._zod?.traits;if(i?.has("$ZodType"))if(i.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let a=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:uc(e.inst?._zod.def?.error?.(e))??uc(a?.(e))??uc(t?.error?.(e))??uc(n.customError?.(e))??uc(n.localeError?.(e))??"Invalid input",o={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;o[c]=e[c]}if(o.path??(o.path=[]),o.message=s,t?.reportInput)o.input=e.input;return o}var FI=/[\uD800-\uDBFF]/;function ru(e){let t=e.length;if(!FI.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function iu(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function lx(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 ds(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function ux(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else UI(e,n,r.value)}}function Ri(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function au(e,t,n){return Ri(e,t,n,!1)}function dx(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ri(this,n,r(this))},set(i){Ri(this,n,i)}})}return t}function UI(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ri(this,t,n.bind(this))},set(r){Ri(this,t,r)}})}function zI(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Yf,na=!1,BI={configurable:!0,get(){na=!0;return}};function Et(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Yf!==e._zod){Yf=void 0;return}Yf=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,BI);let i=na;na=!1;try{let a=n(this);if(na)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:a});return na=na||i,a}catch(a){throw delete this[t],na=na||i,a}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function jI(e,t,n,r){let i=zI(e,t);if(!i)return;Object.defineProperty(i,t,{configurable:!0,get(){let a={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,a),a.value=n(this),Object.defineProperty(this,t,a),a.value},set(a){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:a})}})}var VI="~constantCatch";function fx(e){let t=()=>e;return t[VI]=!0,t}var hx;var ah={value:void 0,enumerable:!1},px="captureStackTrace"in Error?Error:null;function GI(e){let t=px;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return px=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ae(e,t,n,r){let i={};function a(f){this.def=f,this.constr=d,this.traits=new Set}a.prototype=i;let s=n,o=s&&new WeakSet;function c(f,h){if(!f._zod){ah.value=new a(h);try{Object.defineProperty(f,"_zod",ah)}finally{ah.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,h),o){let m=Object.getPrototypeOf(f),g=f._zod.constr.prototype,p=m;while(p&&p!==g)p=Object.getPrototypeOf(p);let y=p??m;if(!o.has(y))o.add(y),ux(y,s)}let b=d.prototype;for(let m in b){if(!Object.prototype.hasOwnProperty.call(b,m))continue;if(!(m in f))f[m]=b[m].bind(f)}}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(f){let h=r?.Parent?GI(u):this;c(h,f);let b=h._zod.deferred;if(b){for(let g of b)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(f)=>{if(r?.Parent&&f instanceof r.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class ti extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class mc extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(hx=globalThis).__zod_globalConfig??(hx.__zod_globalConfig={});var zn=globalThis.__zod_globalConfig;function rr(e){if(e)Object.assign(zn,e);return zn}function HI(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,fc,2)),e.message}function $I(e){this._zod.message=e}var KI={get:HI,set:$I,enumerable:!0,configurable:!0},oh={value:void 0,enumerable:!1},mx=new WeakSet([Object.prototype,Error.prototype]),gx=(e,t)=>{e.name="$ZodError",oh.value=t,Object.defineProperty(e,"issues",oh),oh.value=void 0,Object.defineProperty(e,"message",KI);let n=Object.getPrototypeOf(e);if(!mx.has(n))mx.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},bx=ae("$ZodError",gx),hB=ae("$ZodError",gx,void 0,{Parent:Error});function WI(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 xx(e,t=(n)=>n.message){let n={},r=[];for(let i of e.issues)if(i.path.length>0)WI(n,i.path[0],()=>[]).push(t(i));else r.push(t(i));return{formErrors:r,fieldErrors:n}}function yx(e,t=(n)=>n.message){let n={_errors:[]},r=(i,a=[])=>{for(let s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((o)=>r({issues:o},[...a,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...a,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...a,...s.path]);else{let o=[...a,...s.path];if(o.length===0)n._errors.push(t(s));else{let c=n,l=0;while(l<o.length){let u=o[l],d=l===o.length-1;if(u==="_errors"){if(d)c._errors.push(t(s));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];if(d)f._errors.push(t(s));c=f,l++}}}};return r(e),n}function su(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ou=(e)=>{let t=(n,r,i,a)=>{let s=i?{...i,async:!1}:{async:!1},o=n._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new ti;if(o.issues.length){let c=new(a?.Err??e)(o.issues.map((l)=>ei(l,s,rr())));throw eh(c,a?.callee??t),c}return o.value};return t};var cu=(e)=>{let t=async(n,r,i,a)=>{let s=i?{...i,async:!0}:{async:!0},o=n._zod.run({value:r,issues:[]},s);if(o instanceof Promise)o=await o;if(o.issues.length){let c=new(a?.Err??e)(o.issues.map((l)=>ei(l,s,rr())));throw eh(c,a?.callee??t),c}return o.value};return t};var lu=(e)=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ti;return a.issues.length?_x(e,a.issues,i):{success:!0,data:a.value}};function _x(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((i)=>ei(i,n,rr()))),t=void 0,n=void 0;return r},set error(i){r=i,t=void 0,n=void 0}}}var uu=(e)=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)a=await a;return a.issues.length?_x(e,a.issues,i):{success:!0,data:a.value}};var XI=Symbol.for("zod.compile.invalid"),qI=Symbol.for("zod.compile.fallback"),ch=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==XI)return!0;if(r.definite===!0&&n===void 0)return!1}return JI(e,t,n)};function JI(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i)r[qI]=!0,a=i({value:t,issues:[]},r);else a=e._zod.run({value:t,issues:[]},r);if(a instanceof Promise)throw new ti;return a.issues.length===0}var lh=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)i=await i;return i.issues.length===0},vx=(e)=>{let t=ou(e),n=(r,i,a,s)=>{let o=a?{...a,direction:"backward"}:{direction:"backward"};return t(r,i,o,su(n,s))};return n};var Ex=(e)=>{let t=ou(e),n=(r,i,a,s)=>t(r,i,a,su(n,s));return n};var Ax=(e)=>{let t=cu(e),n=async(r,i,a,s)=>{let o=a?{...a,direction:"backward"}:{direction:"backward"};return await t(r,i,o,su(n,s))};return n};var Tx=(e)=>{let t=cu(e),n=async(r,i,a,s)=>await t(r,i,a,su(n,s));return n};var wx=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return lu(e)(t,n,i)};var Mx=(e)=>(t,n,r)=>lu(e)(t,n,r);var Sx=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return uu(e)(t,n,i)};var Rx=(e)=>async(t,n,r)=>uu(e)(t,n,r);var Ix=/^[cC][0-9a-z]{6,}$/,Cx=/^[0-9a-z]+$/,Nx=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Px=/^[0-9a-vA-V]{20}$/,Ox=/^[A-Za-z0-9]{27}$/,kx=/^[a-zA-Z0-9_-]{21}$/;function Lx(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Dx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Fx=/^([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})$/,dh=(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 Ux=/^(?:[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 ZI="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function zx(){return new RegExp(ZI,"u")}var Bx=/^(?:(?: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])$/,jx=/^(([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 Vx=/^((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])$/,Gx=/^(([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])$/,Hx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$x=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Kx=/^https?$/,Wx=/^\+[1-9]\d{6,14}$/;var Xx="(?:(?:\\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 YI(e){return new RegExp(`^${e}$`)}var qx=YI(Xx);function uh(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 Jx(e){return new RegExp(`^${uh(e)}$`)}function Zx(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${uh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${uh({precision:e.precision})}`:n;return new RegExp(`^${Xx}T(?:${r})$`)}var Yx=/^[\s\S]{0,}$/,Qx=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var du=/^-?\d+$/,qs=/^-?\d+(?:\.\d+)?$/,ey=/^(?:true|false)$/i;var ty=/^[^A-Z]*$/,ny=/^[^a-z]*$/;var Mn=ae("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var fh=(e)=>{let t=e.value;return!Jb(t)&&t.length!==void 0},fu={number:"number",bigint:"bigint",object:"date"},hh=ae("$ZodCheckLessThan",(e,t)=>{Mn.init(e,t);let n=fu[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:fu[typeof r.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ph=ae("$ZodCheckGreaterThan",(e,t)=>{Mn.init(e,t);let n=fu[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:fu[typeof r.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ry=ae("$ZodCheckMultipleOf",(e,t)=>{Mn.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):Zb(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})}}),iy=ae("$ZodCheckNumberFormat",(e,t)=>{Mn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,a]=eu[t.format];e._zod.check=(s)=>{let o=s.value;if(n){if(!Number.isInteger(o)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){if(o>0)s.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(o<i)s.issues.push({origin:"number",input:o,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort});if(o>a)s.issues.push({origin:"number",input:o,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}});var ay=ae("$ZodCheckMaxLength",(e,t)=>{var n;Mn.init(e,t),(n=e._zod.def).when??(n.when=fh),e._zod.check=(r)=>{let i=r.value,a=i.length;if((typeof i==="string"&&a>t.maximum?ru(i):a)<=t.maximum)return;let o=iu(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),sy=ae("$ZodCheckMinLength",(e,t)=>{var n;Mn.init(e,t),(n=e._zod.def).when??(n.when=fh),e._zod.check=(r)=>{let i=r.value,a=i.length;if((typeof i==="string"&&a>=t.minimum&&a<t.minimum*2?ru(i):a)>=t.minimum)return;let o=iu(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),oy=ae("$ZodCheckLengthEquals",(e,t)=>{var n;Mn.init(e,t),(n=e._zod.def).when??(n.when=fh),e._zod.check=(r)=>{let i=r.value,a=i.length,s=typeof i==="string"&&a>=t.length&&a<=t.length*2?ru(i):a;if(s===t.length)return;let o=iu(i),c=s>t.length;r.issues.push({origin:o,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),bc=ae("$ZodCheckStringFormat",(e,t)=>{var n,r;if(Mn.init(e,t),t.pattern)(n=e._zod).check??(n.check=(i)=>{if(t.pattern.lastIndex=0,t.pattern.test(i.value))return;i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),cy=ae("$ZodCheckRegex",(e,t)=>{bc.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})}}),ly=ae("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ty),bc.init(e,t)}),uy=ae("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ny),bc.init(e,t)}),dy=ae("$ZodCheckIncludes",(e,t)=>{Mn.init(e,t);let n=Ii(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=(i)=>{if(i.value.includes(t.includes,t.position))return;i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),fy=ae("$ZodCheckStartsWith",(e,t)=>{Mn.init(e,t);let n=new RegExp(`^${Ii(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),hy=ae("$ZodCheckEndsWith",(e,t)=>{Mn.init(e,t);let n=new RegExp(`.*${Ii(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var py=ae("$ZodCheckOverwrite",(e,t)=>{Mn.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class mh{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((a)=>a),r=Math.min(...n.map((a)=>a.length-a.trimStart().length)),i=n.map((a)=>a.slice(r)).map((a)=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}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 ry={major:4,minor:6,patch:5};var Ut=se("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ry;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let a of s._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,c,l)=>{if(o.memo)return o;let u=gi(o),d;for(let f of c){if(f._zod.def.when){if(Jb(o))continue;if(!f._zod.def.when(o))continue}else if(u)continue;let h=o.issues.length,b=f._zod.check(o);if(b instanceof Promise&&l?.async===!1)throw new Qi;if(d||b instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await b,o.issues.length===h)return;if(Kf(o.issues,h,e),!u)u=gi(o,h)});else{if(o.issues.length===h)continue;if(Kf(o.issues,h,e),!u)u=gi(o,h)}}if(d)return d.then(()=>o);return o},a=(o,c,l)=>{if(gi(o))return o.aborted=!0,o;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Qi;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>a(d,o,c));return a(u,o,c)}let l=e._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Qi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Jl(this,"~standard",ah(this))},set "~standard"(e){Mr(this,"~standard",e)}}),xy=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Yi(n,t,ti()))}:{value:e.value};async function LI(e,t){let n={async:!0};return xy(await e._zod.run({value:t,issues:[]},n),n)}function ah(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return xy(i,n)}catch(i){}return LI(e,t)},vendor:"zod",version:1}}var ou=se("$ZodString",(e,t)=>{Ut.init(e,t),e._zod.pattern=t.pattern??zx,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}}),$t=se("$ZodStringFormat",(e,t)=>{uc.init(e,t),ou.init(e,t)}),yy=se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wx),$t.init(e,t)}),_y=se("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Qf(i))}else t.pattern??(t.pattern=Qf());$t.init(e,t)}),vy=se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Sx),$t.init(e,t)}),Ey=1,su=2;function Ty(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function FI(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Ty(e)||su;return UI(e,t)}function UI(e,t){if(!t.normalize&&t.protocol?.source===kx.source&&!/^https?:\/\//i.test(e))return Ey;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??su}return new URL(e)}catch{return su}}var BI=/[\t\n\r]/g;function sy(e){return e.replace(BI,"")}function zI(e,t){return t.lastIndex=0,t.test(e.hostname)}function VI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Ay=se("$ZodURL",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=FI(i,t);if(r===Ey){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===su){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=sy(i);return}if(t.hostname&&!zI(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&&!VI(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:sy(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wy=se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Mx()),$t.init(e,t)}),Sy=se("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Ex:Tx(t.length)),$t.init(e,t)}),My=se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bx),$t.init(e,t)}),Ry=se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=xx),$t.init(e,t)}),Iy=se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=yx),$t.init(e,t)}),Cy=se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_x),$t.init(e,t)}),Ny=se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=vx),$t.init(e,t)}),Py=se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Bx(t)),$t.init(e,t)}),Oy=se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Fx),$t.init(e,t)}),ky=se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ux(t)),$t.init(e,t)}),Dy=se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ax),$t.init(e,t)}),Ly=se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Rx),$t.init(e,t)}),jI=/^[0-9a-fA-F:.]+$/;function Fy(e){if(!jI.test(e))return!1;return Ty(`http://[${e}]`)}var Uy=se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ix),$t.init(e,t),e._zod.check=(n)=>{if(!Fy(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var By=se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Cx),$t.init(e,t)});function HI(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 Fy(n)}var zy=se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Nx),$t.init(e,t),e._zod.check=(n)=>{if(!HI(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Vy(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 oh=/^[0-9a-zA-Z+/]*={0,2}$/,jy=se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=oh),$t.init(e,t),e._zod.check=(n)=>{if(Vy(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),cu=/^[A-Za-z0-9_-]*$/;function GI(e){if(!cu.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Vy(n)}var Hy=se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cu),$t.init(e,t),e._zod.check=(n)=>{if(GI(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Gy=se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dx),$t.init(e,t)});function $I(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 $y=se("$ZodJWT",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{if($I(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ch=se("$ZodNumber",(e,t)=>{Ut.init(e,t),e._zod.pattern=Ga,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),Ky=se("$ZodNumberFormat",(e,t)=>{Kx.init(e,t),ch.init(e,t)}),Wy=se("$ZodBoolean",(e,t)=>{Ut.init(e,t),e._zod.pattern=jx,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 Xy=se("$ZodUnknown",(e,t)=>{Ut.init(e,t),e._zod.parse=(n)=>n}),qy=se("$ZodNever",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ay(e,t,n){if(e.issues.length)t.issues.push(...Zi(n,e.issues));t.value[n]=e.value}var Jy=se("$ZodArray",(e,t)=>{Ut.init(e,t);let n=Bn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let a=[],o=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)a.push(u.then((d)=>ay(d,i,c)));else if(ay(u,i,c),o&&u.issues.length!==0&&gi(u))break}if(a.length)return Promise.all(a).then(()=>i);return i}});function au(e,t,n,i,r,s){let a=n in i,o=s==="optional";if(!a&&o&&r==="optional")return;if(e.issues.length){if(r!==void 0&&o&&!a)return;t.issues.push(...Zi(n,e.issues))}if(!a&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(a||r==="defaulted"&&!o)t.value[n]=void 0}else t.value[n]=e.value}var KI=[];function Zy(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:KI,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let s=Wb(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Yy(e,t,n,i,r,s,a){let o=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:f}=l,h=0;for(let b in t){if(a&&n.issues.length!==h){if(gi(n,h))break;h=n.issues.length}if(c.has(b))continue;if(b==="__proto__"){if(u==="never")o.push(b);continue}if(u==="never"){o.push(b);continue}let m=l.run({value:t[b],issues:[]},i);if(m instanceof Promise)e.push(m.then((g)=>au(g,n,b,t,d,f)));else au(m,n,b,t,d,f)}if(o.length)n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var WI=se("$ZodObject",(e,t)=>{Ut.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=ac(()=>Zy(t));Et(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let f in u){let h=u[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,f))mi(d,f,new Set);for(let b of h.values)d[f].add(b);if(h.optin!==void 0)d[f].add(void 0)}}return d});let s=Ha,a=t.catchall,o,c=Bn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{o??(o=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let f=[],h=o.shape,b=u?.abortEarly,m=l.issues.length;for(let g of o.allKeys){if(b&&l.issues.length!==m){if(gi(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let p=h[g],x=p._zod.optin,_=p._zod.optout,y=p._zod.run({value:d[g],issues:[]},u);if(y instanceof Promise)f.push(y.then((v)=>au(v,l,g,d,x,_)));else au(y,l,g,d,x,_)}if(!a)return f.length?Promise.all(f).then(()=>l):l;return Yy(f,d,l,u,r.value,e,b===!0)}}),Qy=se("$ZodObjectJIT",(e,t)=>{WI.init(e,t);let n=e._zod.parse,i=ac(()=>Zy(t)),r=Bn.memoizer,s=(h)=>{let b=i.value,m=b.symbolKeys,g=new ih(["payload","ctx"],{shape:h,inst:e,memo:r,syms:m}),p=(v)=>`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`,x=(v,E)=>`
- let ${v}_ab = false;
- for (let i = 0; i < ${v}.issues.length; i++) {
- const iss = ${v}.issues[i];
+};`)(...Object.values(this.closed))}}var gy={major:4,minor:6,patch:7};var zt=ae("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gy;let r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let a of i)for(let s of a._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let a=(o,c,l)=>{if(o.memo)return o;let u=_r(o),d;for(let f of c){if(f._zod.def.when){if(cx(o))continue;if(!f._zod.def.when(o))continue}else if(u)continue;let h=o.issues.length,b=f._zod.check(o);if(b instanceof Promise&&l?.async===!1)throw new ti;if(d||b instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await b,o.issues.length===h)return;if(nu(o.issues,h,e),!u)u=_r(o,h)});else{if(o.issues.length===h)continue;if(nu(o.issues,h,e),!u)u=_r(o,h)}}if(d)return d.then(()=>o);return o},s=(o,c,l)=>{if(_r(o))return o.aborted=!0,o;let u=a(c,i,l);if(u instanceof Promise){if(l.async===!1)throw new ti;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(o,c)=>{if(c.skipChecks)return e._zod.parse(o,c);if(c.direction==="backward"){let u=e._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>s(d,o,c));return s(u,o,c)}let l=e._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new ti;return l.then((u)=>a(u,i,c))}return a(l,i,c)}}},{get "~standard"(){return au(this,"~standard",xh(this))},set "~standard"(e){Ri(this,"~standard",e)}}),Cy=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>ei(n,t,rr()))}:{value:e.value};async function QI(e,t){let n={async:!0};return Cy(await e._zod.run({value:t,issues:[]},n),n)}function xh(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Cy(r,n)}catch(r){}return QI(e,t)},vendor:"zod",version:1}}var gu=ae("$ZodString",(e,t)=>{zt.init(e,t),e._zod.pattern=t.pattern??Yx,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$t=ae("$ZodStringFormat",(e,t)=>{bc.init(e,t),gu.init(e,t)}),Ny=ae("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fx),$t.init(e,t)}),Py=ae("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=dh(r))}else t.pattern??(t.pattern=dh());$t.init(e,t)}),Oy=ae("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ux),$t.init(e,t)}),ky=1,pu=2;function Ly(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function e1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Ly(e)||pu;return t1(e,t)}function t1(e,t){if(!t.normalize&&t.protocol?.source===Kx.source&&!/^https?:\/\//i.test(e))return ky;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??pu}return new URL(e)}catch{return pu}}var n1=/[\t\n\r]/g;function by(e){return e.replace(n1,"")}function r1(e,t){return t.lastIndex=0,t.test(e.hostname)}function i1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Dy=ae("$ZodURL",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),i=e1(r,t);if(i===ky){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===pu){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=by(r);return}if(t.hostname&&!r1(i,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&&!i1(i,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?i.href:by(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Fy=ae("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zx()),$t.init(e,t)}),Uy=ae("$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?kx:Lx(t.length)),$t.init(e,t)}),zy=ae("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ix),$t.init(e,t)}),By=ae("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Cx),$t.init(e,t)}),jy=ae("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Nx),$t.init(e,t)}),Vy=ae("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Px),$t.init(e,t)}),Gy=ae("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ox),$t.init(e,t)}),Hy=ae("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Zx(t)),$t.init(e,t)}),$y=ae("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=qx),$t.init(e,t)}),Ky=ae("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Jx(t)),$t.init(e,t)}),Wy=ae("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Dx),$t.init(e,t)}),Xy=ae("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Bx),$t.init(e,t)}),a1=/^[0-9a-fA-F:.]+$/;function qy(e){if(!a1.test(e))return!1;return Ly(`http://[${e}]`)}var Jy=ae("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jx),$t.init(e,t),e._zod.check=(n)=>{if(!qy(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Zy=ae("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Vx),$t.init(e,t)});function s1(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);if(`${i}`!==r)return!1;if(i<0||i>128)return!1;return qy(n)}var Yy=ae("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gx),$t.init(e,t),e._zod.check=(n)=>{if(!s1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Qy(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 yh=/^[0-9a-zA-Z+/]*={0,2}$/,e_=ae("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yh),$t.init(e,t),e._zod.check=(n)=>{if(Qy(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),bu=/^[A-Za-z0-9_-]*$/;function o1(e){if(!bu.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Qy(n)}var t_=ae("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bu),$t.init(e,t),e._zod.check=(n)=>{if(o1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),n_=ae("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Wx),$t.init(e,t)});function c1(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));if("typ"in i&&i?.typ!=="JWT")return!1;if(!i.alg)return!1;if(t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}var r_=ae("$ZodJWT",(e,t)=>{$t.init(e,t),e._zod.check=(n)=>{if(c1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var _h=ae("$ZodNumber",(e,t)=>{zt.init(e,t),e._zod.pattern=qs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}let i=n.value;if(typeof i==="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==="number"?Number.isNaN(i)?"NaN":!Number.isFinite(i)?String(i):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),n}}),i_=ae("$ZodNumberFormat",(e,t)=>{iy.init(e,t),_h.init(e,t)}),a_=ae("$ZodBoolean",(e,t)=>{zt.init(e,t),e._zod.pattern=ey,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(a){}let i=n.value;if(typeof i==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}});var s_=ae("$ZodUnknown",(e,t)=>{zt.init(e,t),e._zod.parse=(n)=>n}),o_=ae("$ZodNever",(e,t)=>{zt.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function l1(e,t){let n=ih(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((a)=>a[0])),i=e._zod.parse;e._zod.parse=(a,s)=>{let o=t(a.value);if(o>r&&!s?.skipChecks&&s?.direction!=="backward"){for(let[c,l]of ih(e._zod.def.checks))if(o>c&&l._zod.def.when(a)){let u=a.issues.length;return l._zod.check(a),a.issues[u].continue=!1,nu(a.issues,u,e),a}}return i(a,s)}}var u1=(e)=>Array.isArray(e)?e.length:-1;function xy(e,t,n){if(e.issues.length)t.issues.push(...Qr(n,e.issues));t.value[n]=e.value}var c_=ae("$ZodArray",(e,t)=>{zt.init(e,t);let n=zn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let s=[],o=i?.abortEarly;for(let c=0;c<a.length;c++){let l=a[c],u=t.element._zod.run({value:l,issues:[]},i);if(u instanceof Promise)s.push(u.then((d)=>xy(d,r,c)));else if(xy(u,r,c),o&&u.issues.length!==0&&_r(u))break}if(s.length)return Promise.all(s).then(()=>r);return r},l1(e,u1)});function mu(e,t,n,r,i,a){let s=n in r,o=a==="optional";if(!s&&o&&i==="optional")return;if(e.issues.length){if(i!==void 0&&o&&!s)return;t.issues.push(...Qr(n,e.issues))}if(!s&&i===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(s||i==="defaulted"&&!o)t.value[n]=void 0}else t.value[n]=e.value}var d1=[];function l_(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:d1,i=r.length?[...t,...r]:t;for(let s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let a=ax(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function u_(e,t,n,r,i,a,s){let o=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,{optin:d,optout:f}=l,h=0;for(let b in t){if(s&&n.issues.length!==h){if(_r(n,h))break;h=n.issues.length}if(c.has(b))continue;if(b==="__proto__"){if(u==="never")o.push(b);continue}if(u==="never"){o.push(b);continue}let m=l.run({value:t[b],issues:[]},r);if(m instanceof Promise)e.push(m.then((g)=>mu(g,n,b,t,d,f)));else mu(m,n,b,t,d,f)}if(o.length)n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var f1=ae("$ZodObject",(e,t)=>{zt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let l=()=>{let u={...r};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=r,Object.defineProperty(t,"shape",{get:l})}let i=hc(()=>l_(t));Et(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let f in u){let h=u[f]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(d,f))yr(d,f,new Set);for(let b of h.values)d[f].add(b);if(h.optin!==void 0)d[f].add(void 0)}}return d});let a=Xs,s=t.catchall,o,c=zn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{o??(o=i.value);let d=l.value;if(!a(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let f=[],h=o.shape,b=u?.abortEarly,m=l.issues.length;for(let g of o.allKeys){if(b&&l.issues.length!==m){if(_r(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let p=h[g],y=p._zod.optin,v=p._zod.optout,x=p._zod.run({value:d[g],issues:[]},u);if(x instanceof Promise)f.push(x.then((_)=>mu(_,l,g,d,y,v)));else mu(x,l,g,d,y,v)}if(!s)return f.length?Promise.all(f).then(()=>l):l;return u_(f,d,l,u,i.value,e,b===!0)}}),d_=ae("$ZodObjectJIT",(e,t)=>{f1.init(e,t);let n=e._zod.parse,r=hc(()=>l_(t)),i=zn.memoizer,a=(h)=>{let b=r.value,m=b.symbolKeys,g=new mh(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),p=(_)=>`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`,y=(_,E)=>`
+ let ${_}_ab = false;
+ for (let i = 0; i < ${_}.issues.length; i++) {
+ const iss = ${_}.issues[i];
iss.path = iss.path ? [${E}, ...iss.path] : [${E}];
payload.issues.push(iss);
- if (iss.continue !== true) ${v}_ab = true;
+ if (iss.continue !== true) ${_}_ab = true;
}
- if (${v}_ab && ctx && ctx.abortEarly) {
+ if (${_}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;g.write("const input = payload.value;");let _=Object.create(null),y=0;for(let v of b.allKeys)_[v]=`key_${y++}`;g.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let v of b.allKeys){if(v==="__proto__")continue;let E=_[v],w=typeof v==="symbol"?`syms[${m.indexOf(v)}]`:jb(v),T=`${w} in input`,A=h[v],P=A?._zod?.optin,S=P!==void 0,R=A?._zod?.optout==="optional";if(g.write(`const ${E} = ${p(w)};`),S&&R){let k=P==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;g.write(`
- const ${E}_present = ${T};
+ }`;g.write("const input = payload.value;");let v=Object.create(null),x=0;for(let _ of b.allKeys)v[_]=`key_${x++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let _ of b.allKeys){if(_==="__proto__")continue;let E=v[_],w=typeof _==="symbol"?`syms[${m.indexOf(_)}]`:ex(_),A=`${w} in input`,T=h[_],N=T?._zod?.optin,M=N!==void 0,R=T?._zod?.optout==="optional";if(g.write(`const ${E} = ${p(w)};`),M&&R){let k=N==="optional"?`${E}_present`:`${E}.value !== undefined || ${E}_present`;g.write(`
+ const ${E}_present = ${A};
if (!${E}.issues.length || ${E}_present) {
- if (${E}.issues.length) {${x(E,w)}
+ if (${E}.issues.length) {${y(E,w)}
}
if (${k}) {
@@ -4266,9 +4266,9 @@ ${t.join(`
}
}
- `)}else if(!S)g.write(`
- const ${E}_present = ${T};
- if (${E}.issues.length) {${x(E,w)}
+ `)}else if(!M)g.write(`
+ const ${E}_present = ${A};
+ if (${E}.issues.length) {${y(E,w)}
}
if (!${E}_present && !${E}.issues.length) {
payload.issues.push({
@@ -4288,17 +4288,17 @@ ${t.join(`
}
`);else if(g.write(`
- if (${E}.issues.length) {${x(E,w)}
+ if (${E}.issues.length) {${y(E,w)}
}
- `),P==="defaulted")g.write(`newResult[${w}] = ${E}.value;`);else g.write(`
- if (${E}.value !== undefined || ${T}) {
+ `),N==="defaulted")g.write(`newResult[${w}] = ${E}.value;`);else g.write(`
+ if (${E}.value !== undefined || ${A}) {
newResult[${w}] = ${E}.value;
}
- `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},a,o=Ha,c=!Bn.jitless,u=c&&Gb.value,d=t.catchall,f;e._zod.parse=(h,b)=>{f??(f=i.value);let m=h.value;if(!o(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&b?.async===!1&&b.jitless!==!0){if(!a)a=s(t.shape);if(h=a(h,b),!d)return h;return Yy([],m,h,b,f,e,b?.abortEarly===!0)}return n(h,b)}});function oy(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)=>!gi(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((a)=>Yi(a,i,ti())))}),t}var lh=se("$ZodUnion",(e,t)=>{Ut.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)=>Yr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,a=[];for(let o of t.options){let c=o._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}if(!s)return oy(a,i,e,r);return Promise.all(a).then((o)=>oy(o,i,e,r))}});function XI(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var e_=se("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,lh.init(e,t);let n=e._zod.parse;Et(e,"propValues",(r)=>{let s={},a=0;for(let o of r.def.options){let c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(o)}"`);if(c[r.def.discriminator]?.has(void 0))a++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))mi(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&a>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let a=oc(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=ac(()=>XI(t));e._zod.parse=(r,s)=>{let a=r.value;if(!Ha(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let o=a?.[t.discriminator],c=i.value.get(o);if(c&&(o!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:a,path:[t.discriminator],inst:e}),r}}),t_=se("$ZodIntersection",(e,t)=>{Ut.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);if(s instanceof Promise||a instanceof Promise)return Promise.all([s,a]).then(([c,l])=>cy(n,c,l));return cy(n,s,a)}});function rh(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(sa(e)&&sa(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let a=rh(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};r[s]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],s=t[i],a=rh(r,s);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cy(e,t,n){let i=new Map,r,s=new Map,a=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!s.has(f))s.set(f,l);d=[f]}else return!1;for(let f of d){if(!i.has(f))i.set(f,{});i.get(f)[u]=!0}return!0};for(let l of t.issues)if(!a(l,"l"))e.issues.push(l);for(let l of n.issues)if(!a(l,"r"))e.issues.push(l);let o=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=r?o.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of o)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=rh(t.value,n.value);if(!c.valid){if(gi(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var n_=se("$ZodTuple",(e,t)=>{Ut.init(e,t);let n=t.items,i=Bn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let o=[],c=ly(n,"optin"),l=ly(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;if(a.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let b=n[h]._zod.run({value:a[h],issues:[]},s);if(b instanceof Promise)o.push(b.then((m)=>{u[h]=m}));else if(u[h]=b,d&&!f&&b.issues.length)f=gi(b)}if(t.rest&&!f){let h=n.length-1,b=a.slice(n.length),m=r.issues.length;for(let g of b){if(d&&r.issues.length!==m){if(gi(r,m))break;m=r.issues.length}h++;let p=t.rest._zod.run({value:g,issues:[]},s);if(p instanceof Promise)o.push(p.then((x)=>uy(x,r,h)));else uy(p,r,h)}}if(o.length)return Promise.all(o).then(()=>dy(u,r,n,a,l));return dy(u,r,n,a,l)}});function ly(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function uy(e,t,n){if(e.issues.length)t.issues.push(...Zi(n,e.issues));t.value[n]=e.value}function dy(e,t,n,i,r){for(let s=0;s<n.length;s++){let a=e[s],o=s<i.length;if(!o&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!o&&s>=r){t.value.length=s;break}t.issues.push(...Zi(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var i_=se("$ZodRecord",(e,t)=>{Ut.init(e,t);let n=Bn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!sa(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let a=[],o=t.keyType._zod.values;if(o&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of o)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((b)=>Yi(b,r,ti())),input:u,path:[u],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},r);if(h instanceof Promise)a.push(h.then((b)=>{if(b.issues.length)i.issues.push(...Zi(u,b.issues));i.value[f]=b.value}));else{if(h.issues.length)i.issues.push(...Zi(u,h.issues));i.value[f]=h.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ga.test(l)&&u.issues.length){let b=t.keyType._zod.run({value:Number(l),issues:[]},r);if(b instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(b.issues.length===0)u=b}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(o)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((b)=>Yi(b,r,ti())),input:l,path:[l],inst:e});continue}let f=u.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},r);if(h instanceof Promise)a.push(h.then((b)=>{if(b.issues.length)i.issues.push(...Zi(l,b.issues));i.value[f]=b.value}));else{if(h.issues.length)i.issues.push(...Zi(l,h.issues));i.value[f]=h.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(a.length)return Promise.all(a).then(()=>i);return i}});var r_=se("$ZodEnum",(e,t)=>{Ut.init(e,t);let n=rc(t.entries),i=new Set(n);e._zod.values=i,Et(e,"pattern",(r)=>{let s=rc(r.def.entries).filter((a)=>$b.has(typeof a));return new RegExp(s.length?`^(${s.map((a)=>Rr(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let a=r.value;if(i.has(a))return r;return r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),s_=se("$ZodLiteral",(e,t)=>{Ut.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"?Rr(s):s?Rr(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 a_=se("$ZodTransform",(e,t)=>{Ut.init(e,t),e._zod.optin="optional",Bn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new cc(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((a)=>(n.value=a,n));if(r instanceof Promise)throw new Qi;return n.value=r,n}});function fy(e,t){return e.value=t.issues.length?void 0:t.value,e}var uh=se("$ZodOptional",(e,t)=>{Ut.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(`^(${Yr(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)=>fy(n,s));return fy(n,r)}return t.innerType._zod.run(n,i)}}),o_=se("$ZodExactOptional",(e,t)=>{uh.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)}),c_=se("$ZodNullable",(e,t)=>{Ut.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(`^(${Yr(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)}}),l_=se("$ZodDefault",(e,t)=>{Ut.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)=>hy(s,t));return hy(r,t)}});function hy(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var u_=se("$ZodPrefault",(e,t)=>{Ut.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)}}),d_=se("$ZodNonOptional",(e,t)=>{Ut.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)=>py(s,e));return py(r,e)}});function py(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 my(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Yi(r,i,ti()))},input:e.value}),e}var f_=se("$ZodCatch",(e,t)=>{Ut.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)=>my(n,s,t,i));return my(n,r,t,i)}});var h_=se("$ZodPipe",(e,t)=>{Ut.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((a)=>ru(a,t.in,i));return ru(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>ru(s,t.out,i));return ru(r,t.out,i)}});function ru(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 p_=se("$ZodReadonly",(e,t)=>{Ut.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(gy);return gy(r)}});function gy(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function qI(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let o of t.checks??[]){let c=o._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return Vx({minimum:r,maximum:s}).source;let a=e._zod.pattern;return(i&&a===Ga?nu:a)?.source}function sh(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=sh(i);if(n&&r&&s&&s!==r)return n.replace(Yr(r),()=>Yr(s));return n}if(t.options){let r=t.options.map(sh);if(r.every(Boolean))return`^(${r.map((s)=>Yr(s)).join("|")})$`}return qI(e)}var m_=se("$ZodTemplateLiteral",(e,t)=>{Ut.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=sh(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Yr(r))}else if(i===null||Kb.has(typeof i))n.push(Rr(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var g_=se("$ZodCustom",(e,t)=>{Sn.init(e,t),Ut.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>by(s,n,i,e));by(r,n,i,e);return}});function by(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(aa(r))}}class x_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var fh="~memo",b_=[];function y_(e){return e!==null&&typeof e==="object"}function dh(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var __=new WeakMap,dc=0,du=1,fc=2;function fu(e,t,n){let i=__.get(e);if(i!==void 0)return i?fc:dc;if(t.has(e))return fc;t.add(e);let r=dc,s=(u)=>{if(r!==fc&&u?._zod){let d=fu(u,t,n);if(d>r)r=d}},a=(u,d)=>{let f=dc;for(let h of Reflect.ownKeys(u)){let b=Object.getOwnPropertyDescriptor(u,h);if(d&&!b.enumerable)continue;let m=b.get?du:b.value?._zod?fu(b.value,t,n):dc;if(m>f)f=m}return f},o=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=oc(c);o(u?a(u,!0):du),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);o(u?fu(u,t,!1):du);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let h of f)s(h)}}return t.delete(e),JI(e,r)}function JI(e,t){if(t!==du)__.set(e,t===fc);return t}function ZI(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var lu,uu=[],YI={alloc(e,t,n){let i=lu;if(!i)return n;lu=void 0;let r={value:n,issues:null};return i.set(t.value,r),uu.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"&&QI(s,r.value))throw new x_;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,o=(c,l)=>{if(n===void 0){let p=fu(e,new Set,!1);if(p===dc){if(e._zod.parse=a,e._zod.run===o)e._zod.run=a;return a(c,l)}if(p===fc||i)n=!0;else i=!0}let u=c.value;if(!y_(u))return a(c,l);let d=l[fh];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[fh]=d;let f;if(r===l)f=s;else f=ZI(d,e),r=l,s=f;let h=f.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...dh(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}lu=f;let b=uu.length,m=a(c,l);lu=void 0;let g=uu.length>b?uu.pop():void 0;if(m instanceof Promise)return m.then((p)=>{if(g)g.issues=p.issues.length?dh(p.issues):b_;return p});if(g)g.issues=m.issues.length?dh(m.issues):b_;return m};if(e._zod.parse=o,e._zod.run===a)e._zod.run=o})}};function v_(){return YI}function QI(e,t){let n=e[fh]?.backEdges;return n!==void 0&&y_(t)&&n.has(t)}var e1=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(s,a){if(s==="number"&&typeof a==="number"&&!Number.isFinite(a))return String(a);return i[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let a=r(s.expected),o=Zb(s.input),c=r(o,s.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Gf(s.values[0])}`;return`Invalid option: expected one of ${Vf(s.values,"|")}`;case"too_big":{let a=s.exact?"exactly ":s.inclusive?"<=":"<",o=t(s.origin);if(o)return`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{let a=s.exact?"exactly ":s.inclusive?">=":">",o=t(s.origin);if(o)return`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${o.unit}`;return`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{let a=s;if(a.format==="starts_with")return`Invalid string: must start with "${a.prefix}"`;if(a.format==="ends_with")return`Invalid string: must end with "${a.suffix}"`;if(a.format==="includes")return`Invalid string: must include "${a.includes}"`;if(a.format==="regex")return`Invalid string: must match pattern ${a.pattern}`;return`Invalid ${n[a.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Vf(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((o)=>`'${o}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function hh(){return{localeError:e1()}}var E_;class T_{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function t1(){return new T_}(E_=globalThis).__zod_globalRegistry??(E_.__zod_globalRegistry=t1());var oa=globalThis.__zod_globalRegistry;function A_(e){if(e.checks)e.checks=[...e.checks];return e}function w_(e,t){return new e(A_({type:"string",...Ue(t)}))}function S_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ue(t)})}function M_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ue(t)})}function R_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ue(t)})}function I_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ue(t)})}function C_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ue(t)})}function N_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ue(t)})}function P_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ue(t)})}function O_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ue(t)})}function k_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ue(t)})}function D_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ue(t)})}function L_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ue(t)})}function F_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ue(t)})}function U_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ue(t)})}function B_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ue(t)})}function z_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ue(t)})}function V_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ue(t)})}function j_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ue(t)})}function H_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ue(t)})}function G_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ue(t)})}function $_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ue(t)})}function K_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ue(t)})}function W_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ue(t)})}function X_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ue(t)})}function q_(e,t){return new e({type:"string",format:"date",check:"string_format",...Ue(t)})}function J_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ue(t)})}function Z_(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ue(t)})}function Y_(e,t){return new e(A_({type:"number",checks:[],...Ue(t)}))}function Q_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ue(t)})}function e0(e,t){return new e({type:"boolean",...Ue(t)})}function t0(e){return new e({type:"unknown"})}function n0(e,t){return new e({type:"never",...Ue(t)})}function hu(e,t){return new th({check:"less_than",...Ue(t),value:e,inclusive:!1})}function hc(e,t){return new th({check:"less_than",...Ue(t),value:e,inclusive:!0})}function pu(e,t){return new nh({check:"greater_than",...Ue(t),value:e,inclusive:!1})}function pc(e,t){return new nh({check:"greater_than",...Ue(t),value:e,inclusive:!0})}function mu(e,t){return new $x({check:"multiple_of",...Ue(t),value:e})}function gu(e,t){return new Wx({check:"max_length",...Ue(t),maximum:e})}function $a(e,t){return new Xx({check:"min_length",...Ue(t),minimum:e})}function bu(e,t){return new qx({check:"length_equals",...Ue(t),length:e})}function ph(e,t){return new Jx({check:"string_format",format:"regex",...Ue(t),pattern:e})}function mh(e){return new Zx({check:"string_format",format:"lowercase",...Ue(e)})}function gh(e){return new Yx({check:"string_format",format:"uppercase",...Ue(e)})}function bh(e,t){return new Qx({check:"string_format",format:"includes",...Ue(t),includes:e})}function xh(e,t){return new ey({check:"string_format",format:"starts_with",...Ue(t),prefix:e})}function yh(e,t){return new ty({check:"string_format",format:"ends_with",...Ue(t),suffix:e})}function Qr(e){return new ny({check:"overwrite",tx:e})}function _h(e){return Qr((t)=>t.normalize(e))}function vh(){return Qr((e)=>e.trim())}function Eh(){return Qr((e)=>e.toLowerCase())}function Th(){return Qr((e)=>e.toUpperCase())}function Ah(){return Qr((e)=>Hb(e))}function i0(e,t,n){return new e({type:"array",element:t,...Ue(n)})}function r0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ue(n)})}function s0(e,t){let n=n1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(aa(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(aa(s))}},e(i.value,i)),t);return n}function n1(e,t){let n=new Sn({check:"custom",...Ue(t)});return n._zod.check=e,n}function mc(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))mi(e,i,n[i]);return e}function Sh(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??oa,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 Ir(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 qt(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let f=a.schema,h=t.processors[r.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,f,u)}let d=e._zod.parent;if(d){if(!a.ref)a.ref=d;qt(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)mc(a.schema,c);if(t.io==="input"&&zn(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(i=a.schema).default??(i.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function a0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Mh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let o=e.metadataRegistry.get(a[0])?.id;if(o){let c=i.get(o);if(c&&c!==a[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(o,a[0])}}let r=(a)=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??((b)=>b);if(d)return{ref:f(d)};let h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${f("__shared")}#/${o}/${a0(h)}`}}let c="#",l=`${c}/${o}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+a0(u)}},s=(a)=>{if(a[1].schema.$ref)return;let o=a[1],{ref:c,defId:l}=r(a);if(o.def={...o.schema},l)o.defId=l;let u=o.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let o=a[1];if(o.cycle)throw Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},s,o=Xs,c=!zn.jitless,u=c&&nx.value,d=t.catchall,f;e._zod.parse=(h,b)=>{f??(f=r.value);let m=h.value;if(!o(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&b?.async===!1&&b.jitless!==!0){if(!s)s=a(t.shape);if(h=s(h,b),!d)return h;return u_([],m,h,b,f,e,b?.abortEarly===!0)}return n(h,b)}});function yy(e,t,n,r){for(let a of e)if(a.issues.length===0)return t.value=a.value,t;let i=e.filter((a)=>!_r(a));if(i.length===1)return t.value=i[0].value,i[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((a)=>a.issues.map((s)=>ei(s,r,rr())))}),t}var vh=ae("$ZodUnion",(e,t)=>{zt.init(e,t),Et(e,"optin",(r)=>r.def.options.some((i)=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some((i)=>i._zod.optin!==void 0)?"optional":void 0),Et(e,"optout",(r)=>r.def.options.some((i)=>i._zod.optout==="optional")?"optional":void 0),Et(e,"values",(r)=>{if(r.def.options.every((i)=>i._zod.values))return new Set(r.def.options.flatMap((i)=>Array.from(i._zod.values)));return}),Et(e,"pattern",(r)=>{if(r.def.options.every((i)=>i._zod.pattern)){let i=r.def.options.map((a)=>a._zod.pattern);return new RegExp(`^(${i.map((a)=>ra(a.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,s=[];for(let o of t.options){let c=o._zod.run({value:r.value,issues:[]},i);if(c instanceof Promise)s.push(c),a=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!a)return yy(s,r,e,i);return Promise.all(s).then((o)=>yy(o,r,e,i))}});function h1(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let i of r)if(t.has(i)){if(i!==void 0)throw Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}var f_=ae("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,vh.init(e,t);let n=e._zod.parse;Et(e,"propValues",(i)=>{let a={},s=0;for(let o of i.def.options){let c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${i.def.options.indexOf(o)}"`);if(c[i.def.discriminator]?.has(void 0))s++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(a,l))yr(a,l,new Set);for(let d of u)a[l].add(d)}}if(!i.def.unionFallback&&s>1)a[i.def.discriminator]?.delete(void 0);return a}),t.options.forEach((i,a)=>{let s=pc(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${a}"`)});let r=hc(()=>h1(t));e._zod.parse=(i,a)=>{let s=i.value;if(!Xs(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let o=s?.[t.discriminator],c=r.value.get(o);if(c&&(o!==void 0||a.direction!=="backward"))return c._zod.run(i,a);if(t.unionFallback||a.direction==="backward")return n(i,a);return i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((l)=>r.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),i}}),h_=ae("$ZodIntersection",(e,t)=>{zt.init(e,t),e._zod.parse=(n,r)=>{let i=n.value,a=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);if(a instanceof Promise||s instanceof Promise)return Promise.all([a,s]).then(([c,l])=>_y(n,c,l));return _y(n,a,s)}});function gh(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(us(e)&&us(t)){let n=Object.keys(t),r=Object.keys(e).filter((a)=>n.indexOf(a)!==-1),i={...e,...t};if(Object.prototype.hasOwnProperty.call(i,"__proto__"))delete i.__proto__;for(let a of r){if(a==="__proto__")continue;let s=gh(e[a],t[a]);if(!s.valid)return{valid:!1,mergeErrorPath:[a,...s.mergeErrorPath]};i[a]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],s=gh(i,a);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _y(e,t,n){let r=new Map,i,a=new Map,s=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)i??(i=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!a.has(f))a.set(f,l);d=[f]}else return!1;for(let f of d){if(!r.has(f))r.set(f,{});r.get(f)[u]=!0}return!0};for(let l of t.issues)if(!s(l,"l"))e.issues.push(l);for(let l of n.issues)if(!s(l,"r"))e.issues.push(l);let o=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length){let l=i?o.filter((u)=>i.keys.includes(u)):[];if(l.length)e.issues.push({...i,keys:l});for(let u of o)if(!l.includes(u)&&a.has(u))e.issues.push(a.get(u))}let c=gh(t.value,n.value);if(!c.valid){if(_r(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var p_=ae("$ZodTuple",(e,t)=>{zt.init(e,t);let n=t.items,r=zn.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],a):[];let o=[],c=vy(n,"optin"),l=vy(n,"optout");if(!t.rest){if(s.length<c)return i.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),i;if(s.length>n.length)i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let b=n[h]._zod.run({value:s[h],issues:[]},a);if(b instanceof Promise)o.push(b.then((m)=>{u[h]=m}));else if(u[h]=b,d&&!f&&b.issues.length)f=_r(b)}if(t.rest&&!f){let h=n.length-1,b=s.slice(n.length),m=i.issues.length;for(let g of b){if(d&&i.issues.length!==m){if(_r(i,m))break;m=i.issues.length}h++;let p=t.rest._zod.run({value:g,issues:[]},a);if(p instanceof Promise)o.push(p.then((y)=>Ey(y,i,h)));else Ey(p,i,h)}}if(o.length)return Promise.all(o).then(()=>Ay(u,i,n,s,l));return Ay(u,i,n,s,l)}});function vy(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Ey(e,t,n){if(e.issues.length)t.issues.push(...Qr(n,e.issues));t.value[n]=e.value}function Ay(e,t,n,r,i){for(let a=0;a<n.length;a++){let s=e[a],o=a<r.length;if(!o&&a>=i&&n[a]._zod.optin==="optional"){t.value.length=a;break}if(s.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Qr(a,s.issues))}t.value[a]=s.value}for(let a=t.value.length-1;a>=r.length;a--)if(n[a]._zod.optout==="optional"&&t.value[a]===void 0)t.value.length=a;else break;return t}var m_=ae("$ZodRecord",(e,t)=>{zt.init(e,t);let n=zn.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!us(a))return r.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),r;let s=[],o=t.keyType._zod.values;if(o&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let u of o)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},i);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((b)=>ei(b,i,rr())),input:u,path:[u],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:a[u],issues:[]},i);if(h instanceof Promise)s.push(h.then((b)=>{if(b.issues.length)r.issues.push(...Qr(u,b.issues));r.value[f]=b.value}));else{if(h.issues.length)r.issues.push(...Qr(u,h.issues));r.value[f]=h.value}}let l;for(let u in a)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=a[u]}else l=l??[],l.push(u);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let l of Reflect.ownKeys(a)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(a,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},i);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&qs.test(l)&&u.issues.length){let b=t.keyType._zod.run({value:Number(l),issues:[]},i);if(b instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(b.issues.length===0)u=b}if(u.issues.length){if(t.mode==="loose")r.value[l]=a[l];else if(o)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((b)=>ei(b,i,rr())),input:l,path:[l],inst:e});continue}let f=u.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:a[l],issues:[]},i);if(h instanceof Promise)s.push(h.then((b)=>{if(b.issues.length)r.issues.push(...Qr(l,b.issues));r.value[f]=b.value}));else{if(h.issues.length)r.issues.push(...Qr(l,h.issues));r.value[f]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var g_=ae("$ZodEnum",(e,t)=>{zt.init(e,t);let n=dc(t.entries),r=new Set(n);e._zod.values=r,Et(e,"pattern",(i)=>{let a=dc(i.def.entries).filter((s)=>rx.has(typeof s));return new RegExp(a.length?`^(${a.map((s)=>Ii(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,a)=>{let s=i.value;if(r.has(s))return i;return i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),b_=ae("$ZodLiteral",(e,t)=>{zt.init(e,t);let n=new Set(t.values);e._zod.values=n,Et(e,"pattern",(r)=>{let i=r.def.values;return new RegExp(i.length?`^(${i.map((a)=>typeof a==="string"?Ii(a):a?Ii(a.toString()):String(a)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let a=r.value;if(n.has(a))return r;return r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}});var x_=ae("$ZodTransform",(e,t)=>{zt.init(e,t),e._zod.optin="optional",zn.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new mc(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then((s)=>(n.value=s,n));if(i instanceof Promise)throw new ti;return n.value=i,n}});function Ty(e,t){return e.value=t.issues.length?void 0:t.value,e}var Eh=ae("$ZodOptional",(e,t)=>{zt.init(e,t),Et(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Et(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Et(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ra(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((a)=>Ty(n,a));return Ty(n,i)}return t.innerType._zod.run(n,r)}}),y_=ae("$ZodExactOptional",(e,t)=>{Eh.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,r)=>t.innerType._zod.run(n,r)}),__=ae("$ZodNullable",(e,t)=>{zt.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 r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ra(r.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,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),v_=ae("$ZodDefault",(e,t)=>{zt.init(e,t),e._zod.optin="defaulted",Et(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((a)=>wy(a,t));return wy(i,t)}});function wy(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var E_=ae("$ZodPrefault",(e,t)=>{zt.init(e,t),e._zod.optin="defaulted",Et(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),A_=ae("$ZodNonOptional",(e,t)=>{zt.init(e,t),Et(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((i)=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((a)=>My(a,e));return My(i,e)}});function My(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 Sy(e,t,n,r){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((i)=>ei(i,r,rr()))},input:e.value}),e}var T_=ae("$ZodCatch",(e,t)=>{zt.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,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((a)=>Sy(n,a,t,r));return Sy(n,i,t,r)}});var w_=ae("$ZodPipe",(e,t)=>{zt.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,r)=>{if(r.direction==="backward"){let a=t.out._zod.run(n,r);if(a instanceof Promise)return a.then((s)=>hu(s,t.in,r));return hu(a,t.in,r)}let i=t.in._zod.run(n,r);if(i instanceof Promise)return i.then((a)=>hu(a,t.out,r));return hu(i,t.out,r)}});function hu(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var M_=ae("$ZodReadonly",(e,t)=>{zt.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,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then(Ry);return Ry(i)}});function Ry(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function p1(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes("int"),i,a;for(let o of t.checks??[]){let c=o._zod.def;if(c.pattern)n=c.pattern;r||(r=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(i===void 0||l>i))i=l;if(u!==void 0&&(a===void 0||u<a))a=u}if(n)return n.source;if(i!==void 0&&a!==void 0&&i>a)return"(?!)";if(i!==void 0||a!==void 0)return Qx({minimum:i,maximum:a}).source;let s=e._zod.pattern;return(r&&s===qs?du:s)?.source}function bh(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let i=r._zod.pattern?.source,a=bh(r);if(n&&i&&a&&a!==i)return n.replace(ra(i),()=>ra(a));return n}if(t.options){let i=t.options.map(bh);if(i.every(Boolean))return`^(${i.map((a)=>ra(a)).join("|")})$`}return p1(e)}var S_=ae("$ZodTemplateLiteral",(e,t)=>{zt.init(e,t);let n=[];for(let r of t.parts)if(typeof r==="object"&&r!==null){let i=bh(r);if(!i)throw Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(ra(i))}else if(r===null||ix.has(typeof r))n.push(Ii(`${r}`));else throw Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>{if(typeof r.value!=="string")return r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(r.value))return r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r;return r}});var R_=ae("$ZodCustom",(e,t)=>{Mn.init(e,t),zt.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then((a)=>Iy(a,n,r,e));Iy(i,n,r,e);return}});function Iy(e,t,n,r){if(!e){let i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)i.params=r._zod.def.params;t.issues.push(ds(i))}}class C_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Th="~memo",I_=[];function N_(e){return e!==null&&typeof e==="object"}function Ah(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var P_=new WeakMap,xc=0,_u=1,yc=2;function vu(e,t,n){let r=P_.get(e);if(r!==void 0)return r?yc:xc;if(t.has(e))return yc;t.add(e);let i=xc,a=(u)=>{if(i!==yc&&u?._zod){let d=vu(u,t,n);if(d>i)i=d}},s=(u,d)=>{let f=xc;for(let h of Reflect.ownKeys(u)){let b=Object.getOwnPropertyDescriptor(u,h);if(d&&!b.enumerable)continue;let m=b.get?_u:b.value?._zod?vu(b.value,t,n):xc;if(m>f)f=m}return f},o=(u)=>{if(u>i)i=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=pc(c);o(u?s(u,!0):_u),a(c.catchall);break}case"array":a(c.element);break;case"tuple":for(let u of c.items)a(u);a(c.rest);break;case"record":case"map":a(c.keyType),a(c.valueType);break;case"set":a(c.valueType);break;case"union":for(let u of c.options)a(u);break;case"intersection":a(c.left),a(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":a(c.innerType);break;case"pipe":a(c.in),a(c.out);break;case"function":a(c.input),a(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);o(u?vu(u,t,!1):_u);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)a(f);else if(Array.isArray(f))for(let h of f)a(h)}}return t.delete(e),m1(e,i)}function m1(e,t){if(t!==_u)P_.set(e,t===yc);return t}function g1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var xu,yu=[],b1={alloc(e,t,n){let r=xu;if(!r)return n;xu=void 0;let i={value:n,issues:null};return r.set(t.value,i),yu.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(i,a)=>{if(a.direction!=="backward"&&x1(a,i.value))throw new C_;return n(i,a)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,o=(c,l)=>{if(n===void 0){let p=vu(e,new Set,!1);if(p===xc){if(e._zod.parse=s,e._zod.run===o)e._zod.run=s;return s(c,l)}if(p===yc||r)n=!0;else r=!0}let u=c.value;if(!N_(u))return s(c,l);let d=l[Th];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[Th]=d;let f;if(i===l)f=a;else f=g1(d,e),i=l,a=f;let h=f.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Ah(h.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value);return c}xu=f;let b=yu.length,m=s(c,l);xu=void 0;let g=yu.length>b?yu.pop():void 0;if(m instanceof Promise)return m.then((p)=>{if(g)g.issues=p.issues.length?Ah(p.issues):I_;return p});if(g)g.issues=m.issues.length?Ah(m.issues):I_;return m};if(e._zod.parse=o,e._zod.run===s)e._zod.run=o})}};function O_(){return b1}function x1(e,t){let n=e[Th]?.backEdges;return n!==void 0&&N_(t)&&n.has(t)}var y1=()=>{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(a){return e[a]??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"},r={nan:"NaN"};function i(a,s){if(a==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[a]??a}return(a)=>{switch(a.code){case"invalid_type":{let s=i(a.expected),o=lx(a.input),c=i(o,a.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(a.values.length===1)return`Invalid input: expected ${nh(a.values[0])}`;return`Invalid option: expected one of ${Qf(a.values,"|")}`;case"too_big":{let s=a.exact?"exactly ":a.inclusive?"<=":"<",o=t(a.origin);if(o)return`Too big: expected ${a.origin??"value"} to have ${s}${a.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${a.origin??"value"} to be ${s}${a.maximum.toString()}`}case"too_small":{let s=a.exact?"exactly ":a.inclusive?">=":">",o=t(a.origin);if(o)return`Too small: expected ${a.origin} to have ${s}${a.minimum.toString()} ${o.unit}`;return`Too small: expected ${a.origin} to be ${s}${a.minimum.toString()}`}case"invalid_format":{let s=a;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??a.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${a.divisor}`;case"unrecognized_keys":return`Unrecognized key${a.keys.length>1?"s":""}: ${Qf(a.keys,", ")}`;case"invalid_key":return`Invalid key in ${a.origin}`;case"invalid_union":if(a.options&&Array.isArray(a.options)&&a.options.length>0)return`Invalid discriminator value. Expected ${a.options.map((o)=>`'${o}'`).join(" | ")}`;if(a.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${a.origin}`;default:return"Invalid input"}}};function wh(){return{localeError:y1()}}var k_;class L_{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 r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function _1(){return new L_}(k_=globalThis).__zod_globalRegistry??(k_.__zod_globalRegistry=_1());var fs=globalThis.__zod_globalRegistry;function D_(e){if(e.checks)e.checks=[...e.checks];return e}function F_(e,t){return new e(D_({type:"string",...Ue(t)}))}function U_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ue(t)})}function z_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ue(t)})}function B_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ue(t)})}function j_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ue(t)})}function V_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ue(t)})}function G_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ue(t)})}function H_(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ue(t)})}function $_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ue(t)})}function K_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ue(t)})}function W_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ue(t)})}function X_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ue(t)})}function q_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ue(t)})}function J_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ue(t)})}function Z_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ue(t)})}function Y_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ue(t)})}function Q_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ue(t)})}function ev(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ue(t)})}function tv(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ue(t)})}function nv(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ue(t)})}function rv(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ue(t)})}function iv(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ue(t)})}function av(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ue(t)})}function sv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ue(t)})}function ov(e,t){return new e({type:"string",format:"date",check:"string_format",...Ue(t)})}function cv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ue(t)})}function lv(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ue(t)})}function uv(e,t){return new e(D_({type:"number",checks:[],...Ue(t)}))}function dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ue(t)})}function fv(e,t){return new e({type:"boolean",...Ue(t)})}function hv(e){return new e({type:"unknown"})}function pv(e,t){return new e({type:"never",...Ue(t)})}function Eu(e,t){return new hh({check:"less_than",...Ue(t),value:e,inclusive:!1})}function _c(e,t){return new hh({check:"less_than",...Ue(t),value:e,inclusive:!0})}function Au(e,t){return new ph({check:"greater_than",...Ue(t),value:e,inclusive:!1})}function vc(e,t){return new ph({check:"greater_than",...Ue(t),value:e,inclusive:!0})}function Tu(e,t){return new ry({check:"multiple_of",...Ue(t),value:e})}function wu(e,t){return new ay({check:"max_length",...Ue(t),maximum:e})}function Js(e,t){return new sy({check:"min_length",...Ue(t),minimum:e})}function Mu(e,t){return new oy({check:"length_equals",...Ue(t),length:e})}function Mh(e,t){return new cy({check:"string_format",format:"regex",...Ue(t),pattern:e})}function Sh(e){return new ly({check:"string_format",format:"lowercase",...Ue(e)})}function Rh(e){return new uy({check:"string_format",format:"uppercase",...Ue(e)})}function Ih(e,t){return new dy({check:"string_format",format:"includes",...Ue(t),includes:e})}function Ch(e,t){return new fy({check:"string_format",format:"starts_with",...Ue(t),prefix:e})}function Nh(e,t){return new hy({check:"string_format",format:"ends_with",...Ue(t),suffix:e})}function ia(e){return new py({check:"overwrite",tx:e})}function Ph(e){return ia((t)=>t.normalize(e))}function Oh(){return ia((e)=>e.trim())}function kh(){return ia((e)=>e.toLowerCase())}function Lh(){return ia((e)=>e.toUpperCase())}function Dh(){return ia((e)=>tx(e))}function mv(e,t,n){return new e({type:"array",element:t,...Ue(n)})}function gv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ue(n)})}function bv(e,t){let n=v1((r)=>(r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ds(i,r.value,n._zod.def));else{let a=i;if(a.fatal)a.continue=!1;if(a.code??(a.code="custom"),!("input"in a))a.input=r.value;a.inst??(a.inst=n),a.continue??(a.continue=!n._zod.def.abort),r.issues.push(ds(a))}},e(r.value,r)),t);return n}function v1(e,t){let n=new Mn({check:"custom",...Ue(t)});return n._zod.check=e,n}function Ec(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))yr(e,r,n[r]);return e}function Uh(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??fs,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 Ci(e,t,n,r,i){let a=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a==="any")return!1;if(a===void 0||a==="throw")throw Error(i);return Object.assign(n,a),!0}function qt(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a){if(a.count++,n.schemaPath.includes(e))a.cycle=n.path;return a.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let o=e._zod.toJSONSchema?.();if(o)s.schema=o;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{let f=s.schema,h=t.processors[i.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,f,u)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;qt(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ec(s.schema,c);if(t.io==="input"&&Bn(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function xv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function zh(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 r=new Map;for(let s of e.seen.entries()){let o=e.metadataRegistry.get(s[0])?.id;if(o){let c=r.get(o);if(c&&c!==s[0])throw Error(`Duplicate schema id "${o}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(o,s[0])}}let i=(s)=>{let o=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,f=e.external.uri??((b)=>b);if(d)return{ref:f(d)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${f("__shared")}#/${o}/${xv(h)}`}}let c="#",l=`${c}/${o}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+xv(u)}},a=(s)=>{if(s[1].schema.$ref)return;let o=s[1],{ref:c,defId:l}=i(s);if(o.def={...o.schema},l)o.defId=l;let u=o.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let o=s[1];if(o.cycle)throw Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let o=a[1];if(t===a[0]){s(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(o.cycle){s(a);continue}if(o.count>1){if(e.reused==="ref")s(a)}}if(e.external)e.sharedDefsExtractedFor=e.external}function l0(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;l0(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let s=i.type;for(let a of Array.isArray(s)?s:[s]){if(typeof a!=="string")return;if(!n.includes(a))n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var u0=new Set(["type","properties","required","additionalProperties"]),o0=["oneOf","anyOf"];function c0(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 wh(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let a in s)if(!u0.has(a))return null;t.push(s)}let n={},i=new Set;for(let s of t){for(let a in s.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let o=[];for(let l of t){let u=l.properties?.[a]??c0(l);if(u===null||u===void 0)continue;if(!o.some((d)=>JSON.stringify(d)===JSON.stringify(u)))o.push(u)}let c=o.length===1?o[0]:wh(o)??{allOf:o};mi(n,a,c)}for(let a of s.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let a of t){let o=c0(a);if(o&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(o)))s.push(o)}if(s.length===1)r.additionalProperties=s[0];else if(s.length>1)r.additionalProperties={allOf:s}}return r}function i1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of u0)if(r in e)return;let n=t.filter((r)=>o0.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=wh(t);else{let r=n[0],s=o0.find((c)=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter((c)=>c!==r),o=r[s].map((c)=>wh([...a,c]));if(o.some((c)=>!c))return;i={[s]:o}}if(!i)return;delete e.allOf,mc(e,i)}function Rh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(o)=>{let c=e.seen.get(o);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let h=e.seen.get(d),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(b);else mc(l,b);if(mc(l,u),o._zod.parent===d)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(b.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let f=o._zod.parent;if(f&&f!==d){i(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(l[b])===JSON.stringify(h.def[b]))delete l[b]}}}e.override({zodSchema:o,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())i(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())l0(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=o.get(u);if(d)d.push(l);else o.set(u,[l])}for(let c of e.intersections)for(let l of o.get(c)??[])i1(l)}}let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}mc(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let c=o[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;mi(a,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")r.$defs=a;else r.definitions=a;try{let o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:gc(t,"input",e.processors),output:gc(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch(o){throw Error("Error converting schema to JSON.")}}function zn(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 zn(i.element,n);if(i.type==="set")return zn(i.valueType,n);if(i.type==="lazy")return zn(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 zn(i.innerType,n);if(i.type==="intersection")return zn(i.left,n)||zn(i.right,n);if(i.type==="record"||i.type==="map")return zn(i.keyType,n)||zn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return zn(i.in,n)||zn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(zn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(zn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(zn(r,n))return!0;if(i.rest&&zn(i.rest,n))return!0;return!1}return!1}var d0=(e,t={})=>(n)=>{let i=Sh({...n,processors:t});return qt(e,i),Mh(i,e),Rh(i,e)},gc=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},a=Sh({...r??{},target:s,io:t,processors:n});return qt(e,a),Mh(a,e),Rh(a,e)};var Ka=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Wa=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},f0=(e,t)=>{Ka(e,"minimum",t),Wa(e,"maximum",t)},g0=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},b0=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},x0=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},y0=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},h0=(e,t)=>Ka(e,"minimum",t.minimum),p0=(e,t)=>Wa(e,"maximum",t.maximum),m0=(e)=>(t,n)=>{y0(t,n.format);let[i,r]=e[n.format];Ka(t,"minimum",i),Wa(t,"maximum",r)},r1={greater_than:(e,t)=>Ka(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Wa(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>g0(e,t.value),number_format:m0(Kl),bigint_format:m0($f),min_length:h0,max_length:p0,length_equals:(e,t)=>f0(e,t.length),min_size:h0,max_size:p0,size_equals:(e,t)=>f0(e,t.size),string_format:(e,t)=>{if(y0(e,t.format),t.pattern)b0(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)=>x0(e,t.mime)};function ni(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)r1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ka(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ka(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Wa(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Wa(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)g0(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)x0(t,r.mime);for(let s of r.patterns??[])b0(t,s);return t}var s1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},a1=new Map([[oh,Px],[cu,Ox]]),_0=(e)=>a1.get(e)??e,v0=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:a,format:o,patterns:c,contentEncoding:l,laxFormat:u}=ni(e);if(typeof s==="number")r.minLength=s;if(typeof a==="number")r.maxLength=a;if(o){if(r.format=s1[o]??o,r.format==="")delete r.format;if(o==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(_0);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},E0=(e,t,n,i)=>{let r=n,{minimum:s,maximum:a,multipleOf:o,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ni(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(f)if(h)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof a==="number")r.maximum=a;if(o){let b=new Set;for(let p of o)if(Number.isFinite(p)&&p!==0)b.add(Math.abs(p));else Ir(e,t,r,i,`A multipleOf divisor of ${p} cannot be represented in JSON Schema`);let[m,...g]=b;if(m!==void 0)r.multipleOf=m;if(g.length)r.allOf=[...r.allOf??[],...g.map((p)=>({multipleOf:p}))]}},T0=(e,t,n,i)=>{n.type="boolean"};var A0=(e,t,n,i)=>{n.not={}};var w0=(e,t,n,i)=>{};var S0=(e,t,n,i)=>{let r=e._zod.def,s=rc(r.entries);if(s.length===0){n.not={};return}if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";n.enum=s},M0=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let a of r.values)if(a===void 0){if(Ir(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a==="bigint"){if(Ir(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length===0);else if(s.length===1){let a=s[0];if(n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[a];else n.const=a}else{if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";if(s.every((a)=>typeof a==="boolean"))n.type="boolean";if(s.every((a)=>a===null))n.type="null";n.enum=s}};var R0=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var I0=(e,t,n,i)=>{Ir(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var C0=(e,t,n,i)=>{Ir(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var N0=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:a,maximum:o}=ni(e);if(typeof a==="number")r.minItems=a;if(typeof o==="number")r.maxItems=o;r.type="array",r.items=qt(s.element,t,{...i,path:[...i.path,"items"]})};function bc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return bc(t.out);if(t.type==="catch")return bc(t.innerType);return e._zod.optin}var P0=(e,t,n,i)=>{let r=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Ir(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)mi(r.properties,l,qt(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=s.shape[l];if(t.io==="input"?bc(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=qt(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},O0=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,a=r.options.map((o,c)=>qt(o,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=a;else n.anyOf=a},k0=(e,t,n,i)=>{let r=e._zod.def,s=qt(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=qt(r.right,t,{...i,path:[...i.path,"allOf",1]}),o=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...o(s)?s.allOf:[s],...o(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},D0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((m,g)=>qt(m,t,{...i,path:[...i.path,a,g]})),l=s.rest?qt(s.rest,t,{...i,path:[...i.path,o,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let m=s.items[u-1];if(!(t.io==="input"?bc(m)!==void 0:m._zod.optout==="optional"))break;u--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,f)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(f)r.maxItems=d}else{if(r.items=c,f)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(f)r.maxItems=d}let{minimum:h,maximum:b}=ni(e);if(typeof h==="number")r.minItems=h;if(typeof b==="number")r.maxItems=b};function Ih(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let b=e.get(t)?.def;if(!b)return t;let m=Ih(e,b,n);return m===b?t:m}for(let b of["anyOf","oneOf"]){let m=t[b];if(!Array.isArray(m))continue;let g=m.map((p)=>Ih(e,p,n));if(g.some((p,x)=>p!==m[x]))t={...t,[b]:g}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((b)=>b==="number"||b==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((b)=>typeof b==="number"))return t;let{minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((b)=>typeof b==="number"?String(b):b);else if(typeof h.const==="number")h.const=String(h.const);if(!r)return h;if(h.type="string",!s)h.pattern=(i.includes("number")?Ga:nu).source;return h}var Ch=new WeakMap;function o1(e){let t=new Map;for(let i of e.seen.values())if(i.def&&!t.has(i.schema))t.set(i.schema,i);let n=new Map;for(let i of Ch.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let a=Ih(t,s,new Set);if(a!==s)n.set(s,a)}if(!n.size)return;for(let i of e.seen.values())for(let r of[i.schema,i.def]){let s=r&&n.get(r.propertyNames);if(s)r.propertyNames=s}}var L0=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let a=s.keyType,o=ni(a).patterns;if(s.mode==="loose"&&o&&o.size>0){let u=qt(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of o)mi(r.patternProperties,_0(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=qt(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Ch.get(t);if(!u)u=[],Ch.set(t,u),t.deferred.push(()=>o1(t));u.push(e)}r.additionalProperties=qt(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&bc(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},F0=(e,t,n,i)=>{let r=e._zod.def,s=qt(r.innerType,t,i),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},U0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Nh=Symbol();function B0(e,t,n,i,r){let s=!1,a=JSON.stringify(e,(o,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(a);return Ir(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Nh}var z0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a=B0(r.defaultValue,e,t,n,i);if(a!==Nh)n.default=a},V0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let a=B0(r.defaultValue,e,t,n,i);if(a!==Nh)n._prefault=a},j0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{Ir(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},H0=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?r.out:r.in:r.out;qt(a,t,i);let o=t.seen.get(e);o.ref=a},G0=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Ph=(e,t,n,i)=>{let r=e._zod.def;qt(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var $0=new WeakSet([Object.prototype,Error.prototype]);function xu(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 m1=(e,t)=>{sx.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if($0.has(n))return;$0.add(n),xu(n,"format",(i)=>(r)=>ox(i,r)),xu(n,"flatten",(i)=>(r)=>ax(i,r)),xu(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,sc,2)}),xu(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,sc,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ii=se("ZodError",m1,void 0,{Parent:Error});var K0=Yl(ii),W0=Ql(ii),X0=eu(ii),q0=tu(ii),J0=lx(ii),Z0=ux(ii),Y0=dx(ii),Q0=fx(ii),ev=hx(ii),tv=px(ii),nv=mx(ii),iv=gx(ii);function b1(){if(!Bn.localeError)ti(hh())}function xc(){if(!Bn.memoizer)ti({memoizer:v_()})}var Kt=se("ZodType",(e,t)=>(b1(),Ut.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ei(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 Ji(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gC(e,t))},superRefine(e,t){return this.check(bC(e,t))},overwrite(e){return this.check(Qr(e))},optional(){return av(this)},exactOptional(){return tC(this)},nullable(){return ov(this)},nullish(){return av(ov(this))},nonoptional(e){return oC(this,e)},array(){return at(this)},or(e){return Xa([this,e])},and(e){return J1(this,e)},transform(e){return cv(this,eC(e))},default(e){return rC(this,e)},prefault(e){return aC(this,e)},catch(e){return lC(this,e)},pipe(e){return cv(this,e)},readonly(){return fC(this)},describe(e){let t=this.clone();return oa.add(t,{description:e}),t},meta(...e){if(e.length===0)return oa.get(this);let t=this.clone();return oa.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 Jl(this,"~standard",{...ah(this),jsonSchema:{input:gc(this,"input"),output:gc(this,"output")}})},set "~standard"(e){Mr(this,"~standard",e)},parse:function e(t,n){return K0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await W0(this,t,n,{callee:e})},safeParse(e,t){return X0(this,e,t)},async safeParseAsync(e,t){return q0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Mr(this,"spa",e)},validate(e,t){return Jf(this,e,t)},validateAsync(e,t){return Zf(this,e,t)},encode:function e(t,n){return J0(this,t,n,{callee:e})},decode:function e(t,n){return Z0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Y0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Q0(this,t,n,{callee:e})},safeEncode(e,t){return ev(this,e,t)},safeDecode(e,t){return tv(this,e,t)},async safeEncodeAsync(e,t){return nv(this,e,t)},async safeDecodeAsync(e,t){return iv(this,e,t)},toJSONSchema(e){return d0(this,{})(e)},get description(){return oa.get(this)?.description},get _def(){return this._zod.def}}),lv=se("_ZodString",(e,t)=>{ou.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v0(e,n,i,r)},Qb({format:(e)=>ni(e).format??null,minLength:(e)=>ni(e).minimum??null,maxLength:(e)=>ni(e).maximum??null},{regex(...e){return this.check(ph(...e))},includes(...e){return this.check(bh(...e))},startsWith(...e){return this.check(xh(...e))},endsWith(...e){return this.check(yh(...e))},min(...e){return this.check($a(...e))},max(...e){return this.check(gu(...e))},length(...e){return this.check(bu(...e))},nonempty(...e){return this.check($a(1,...e))},lowercase(e){return this.check(mh(e))},uppercase(e){return this.check(gh(e))},trim(){return this.check(vh())},normalize(...e){return this.check(_h(...e))},toLowerCase(){return this.check(Eh())},toUpperCase(){return this.check(Th())},slugify(){return this.check(Ah())}})),x1=se("ZodString",(e,t)=>{ou.init(e,t),lv.init(e,t)},{email(e){return this.check(S_(T1,e))},url(e){return this.check(P_(w1,e))},jwt(e){return this.check(W_(z1,e))},emoji(e){return this.check(O_(S1,e))},guid(e){return this.check(M_(A1,e))},uuid(e){return this.check(R_(yu,e))},uuidv4(e){return this.check(I_(yu,e))},uuidv6(e){return this.check(C_(yu,e))},uuidv7(e){return this.check(N_(yu,e))},nanoid(e){return this.check(k_(M1,e))},cuid(e){return this.check(D_(R1,e))},cuid2(e){return this.check(L_(I1,e))},ulid(e){return this.check(F_(C1,e))},base64(e){return this.check(G_(F1,e))},base64url(e){return this.check($_(U1,e))},xid(e){return this.check(U_(N1,e))},ksuid(e){return this.check(B_(P1,e))},ipv4(e){return this.check(z_(O1,e))},ipv6(e){return this.check(V_(k1,e))},cidrv4(e){return this.check(j_(D1,e))},cidrv6(e){return this.check(H_(L1,e))},e164(e){return this.check(K_(B1,e))},datetime(e){return this.check(X_(y1,e))},date(e){return this.check(q_(_1,e))},time(e){return this.check(J_(v1,e))},duration(e){return this.check(Z_(E1,e))}});function Fe(e){return w_(x1,e)}var Jt=se("ZodStringFormat",(e,t)=>{$t.init(e,t),lv.init(e,t)}),y1=se("ZodISODateTime",(e,t)=>{Py.init(e,t),Jt.init(e,t)}),_1=se("ZodISODate",(e,t)=>{Oy.init(e,t),Jt.init(e,t)}),v1=se("ZodISOTime",(e,t)=>{ky.init(e,t),Jt.init(e,t)}),E1=se("ZodISODuration",(e,t)=>{Dy.init(e,t),Jt.init(e,t)}),T1=se("ZodEmail",(e,t)=>{vy.init(e,t),Jt.init(e,t)});var A1=se("ZodGUID",(e,t)=>{yy.init(e,t),Jt.init(e,t)});var yu=se("ZodUUID",(e,t)=>{_y.init(e,t),Jt.init(e,t)});var w1=se("ZodURL",(e,t)=>{Ay.init(e,t),Jt.init(e,t)});var S1=se("ZodEmoji",(e,t)=>{wy.init(e,t),Jt.init(e,t)});var M1=se("ZodNanoID",(e,t)=>{Sy.init(e,t),Jt.init(e,t)});var R1=se("ZodCUID",(e,t)=>{My.init(e,t),Jt.init(e,t)});var I1=se("ZodCUID2",(e,t)=>{Ry.init(e,t),Jt.init(e,t)});var C1=se("ZodULID",(e,t)=>{Iy.init(e,t),Jt.init(e,t)});var N1=se("ZodXID",(e,t)=>{Cy.init(e,t),Jt.init(e,t)});var P1=se("ZodKSUID",(e,t)=>{Ny.init(e,t),Jt.init(e,t)});var O1=se("ZodIPv4",(e,t)=>{Ly.init(e,t),Jt.init(e,t)});var k1=se("ZodIPv6",(e,t)=>{Uy.init(e,t),Jt.init(e,t)});var D1=se("ZodCIDRv4",(e,t)=>{By.init(e,t),Jt.init(e,t)});var L1=se("ZodCIDRv6",(e,t)=>{zy.init(e,t),Jt.init(e,t)});var F1=se("ZodBase64",(e,t)=>{jy.init(e,t),Jt.init(e,t)});var U1=se("ZodBase64URL",(e,t)=>{Hy.init(e,t),Jt.init(e,t)});var B1=se("ZodE164",(e,t)=>{Gy.init(e,t),Jt.init(e,t)});var z1=se("ZodJWT",(e,t)=>{$y.init(e,t),Jt.init(e,t)});var uv=se("ZodNumber",(e,t)=>{ch.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E0(e,n,i,r),e.isFinite=!0},Qb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=ni(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=ni(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=ni(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>ni(e).format??null},{gt(e,t){return this.check(pu(e,t))},gte(e,t){return this.check(pc(e,t))},min(e,t){return this.check(pc(e,t))},lt(e,t){return this.check(hu(e,t))},lte(e,t){return this.check(hc(e,t))},max(e,t){return this.check(hc(e,t))},int(e){return this.check(rv(e))},safe(e){return this.check(rv(e))},positive(e){return this.check(pu(0,e))},nonnegative(e){return this.check(pc(0,e))},negative(e){return this.check(hu(0,e))},nonpositive(e){return this.check(hc(0,e))},multipleOf(e,t){return this.check(mu(e,t))},step(e,t){return this.check(mu(e,t))},finite(){return this}}));function gt(e){return Y_(uv,e)}var V1=se("ZodNumberFormat",(e,t)=>{Ky.init(e,t),uv.init(e,t)});function rv(e){return Q_(V1,e)}var j1=se("ZodBoolean",(e,t)=>{Wy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>T0(e,n,i,r)});function la(e){return e0(j1,e)}var H1=se("ZodUnknown",(e,t)=>{Xy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w0(e,n,i,r)});function ca(){return t0(H1)}var G1=se("ZodNever",(e,t)=>{qy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>A0(e,n,i,r)});function $1(e){return n0(G1,e)}var K1=se("ZodArray",(e,t)=>{xc(),Jy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>N0(e,n,i,r),e.element=t.element},{min(e,t){return this.check($a(e,t))},nonempty(e){return this.check($a(1,e))},max(e,t){return this.check(gu(e,t))},length(e,t){return this.check(bu(e,t))},unwrap(){return this.element}});function at(e,t){return i0(K1,e,t)}var W1=se("ZodObject",(e,t)=>{xc(),Qy.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>P0(e,n,i,r),AI(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Ct(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ei(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ei(this._zod.def,{catchall:ca()}))},loose(){return this.clone(ei(this._zod.def,{catchall:ca()}))},strict(){return this.clone(ei(this._zod.def,{catchall:$1()}))},strip(){return this.clone(ei(this._zod.def,{catchall:void 0}))},extend(e){return gI(this,e)},safeExtend(e){return bI(this,e)},merge(e){return xI(this,e)},pick(e){return pI(this,e)},omit(e){return mI(this,e)},partial(...e){return qb(Dh,this,e[0])},exactPartial(...e){return qb(hv,this,e[0],"exactPartial")},required(...e){return yI(pv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Ue(t)};return new W1(n)}var dv=se("ZodUnion",(e,t)=>{lh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>O0(e,n,i,r),e.options=t.options});function Xa(e,t){return new dv({type:"union",options:e,...Ue(t)})}var X1=se("ZodDiscriminatedUnion",(e,t)=>{dv.init(e,t),e_.init(e,t)});function Ri(e,t,n){return new X1({type:"union",options:t,discriminator:e,...Ue(n)})}var q1=se("ZodIntersection",(e,t)=>{t_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>k0(e,n,i,r)});function J1(e,t){return new q1({type:"intersection",left:e,right:t})}var Z1=se("ZodTuple",(e,t)=>{xc(),n_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>D0(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Dh({type:"optional",innerType:t}))})}});function fv(e,t,n){let i=t instanceof Ut,r=i?n:t;return new Z1({type:"tuple",items:e,rest:i?t:null,...Ue(r)})}var sv=se("ZodRecord",(e,t)=>{xc(),i_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>L0(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function _u(e,t,n){if(!t||!t._zod)return new sv({type:"record",keyType:Fe(),valueType:e,...Ue(t)});return new sv({type:"record",keyType:e,valueType:t,...Ue(n)})}var kh=se("ZodEnum",(e,t)=>{r_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(i,r,s)=>S0(e,i,r,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let s={};for(let a of i)if(n.has(a))s[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new kh({...t,checks:[],...Ue(r),entries:s})},e.exclude=(i,r)=>{let s={...t.entries};for(let a of i)if(n.has(a))delete s[a];else throw Error(`Key ${a} not found in enum`);return new kh({...t,checks:[],...Ue(r),entries:s})}});function Ct(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new kh({type:"enum",entries:n,...Ue(t)})}var Y1=se("ZodLiteral",(e,t)=>{s_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M0(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $e(e,t){return new Y1({type:"literal",values:Array.isArray(e)?e:[e],...Ue(t)})}var Q1=se("ZodTransform",(e,t)=>{xc(),a_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>C0(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new cc(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(aa(s,n.value,t));else{let a=s;if(a.fatal)a.continue=!1;if(a.code??(a.code="custom"),!("input"in a))a.input=n.value;a.inst??(a.inst=e),n.issues.push(aa(a))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function eC(e){return new Q1({type:"transform",transform:e})}var Dh=se("ZodOptional",(e,t)=>{uh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ph(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function av(e){return new Dh({type:"optional",innerType:e})}var hv=se("ZodExactOptional",(e,t)=>{o_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ph(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tC(e){return new hv({type:"optional",innerType:e})}var nC=se("ZodNullable",(e,t)=>{c_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>F0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ov(e){return new nC({type:"nullable",innerType:e})}var iC=se("ZodDefault",(e,t)=>{l_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>z0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rC(e,t){return new iC({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Hf(t)}})}var sC=se("ZodPrefault",(e,t)=>{u_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>V0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function aC(e,t){return new sC({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Hf(t)}})}var pv=se("ZodNonOptional",(e,t)=>{d_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>U0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function oC(e,t){return new pv({type:"nonoptional",innerType:e,...Ue(t)})}var cC=se("ZodCatch",(e,t)=>{f_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>j0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lC(e,t){return new cC({type:"catch",innerType:e,catchValue:typeof t==="function"?t:ex(t)})}var uC=se("ZodPipe",(e,t)=>{h_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>H0(e,n,i,r),e.in=t.in,e.out=t.out});function cv(e,t){return new uC({type:"pipe",in:e,out:t})}var dC=se("ZodReadonly",(e,t)=>{p_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>G0(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function fC(e){return new dC({type:"readonly",innerType:e})}var hC=se("ZodTemplateLiteral",(e,t)=>{m_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>R0(e,n,i,r)});function pC(e,t){return new hC({type:"template_literal",parts:e,...Ue(t)})}var mC=se("ZodCustom",(e,t)=>{g_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>I0(e,n,i,r)});function gC(e,t={}){return r0(mC,e,t)}function bC(e,t){return s0(e,t)}var vu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var mv;(function(e){})(mv||(mv={}));var gv=["neutral","dark","light"];var Lh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),bv=Object.freeze({neutral:Lh("neutral",[170,177,188]),dark:Lh("dark",[26,26,26]),light:Lh("light",[223,227,232])});var lj=bv.neutral.rgb,uj=bv.neutral.hex;/*!
+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let o=s[1];if(t===s[0]){a(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){a(s);continue}}if(e.metadataRegistry.get(s[0])?.id){a(s);continue}if(o.cycle){a(s);continue}if(o.count>1){if(e.reused==="ref")a(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function vv(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;vv(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;let a=r.type;for(let s of Array.isArray(a)?a:[a]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Ev=new Set(["type","properties","required","additionalProperties"]),yv=["oneOf","anyOf"];function _v(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 Fh(e){let t=[];for(let a of e){if(typeof a!=="object"||a.type!=="object")return null;for(let s in a)if(!Ev.has(s))return null;t.push(a)}let n={},r=new Set;for(let a of t){for(let s in a.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let o=[];for(let l of t){let u=l.properties?.[s]??_v(l);if(u===null||u===void 0)continue;if(!o.some((d)=>JSON.stringify(d)===JSON.stringify(u)))o.push(u)}let c=o.length===1?o[0]:Fh(o)??{allOf:o};yr(n,s,c)}for(let s of a.required??[])r.add(s)}let i={type:"object",properties:n};if(r.size)i.required=[...r];if(t.every((a)=>a.additionalProperties===!1))i.additionalProperties=!1;else{let a=[];for(let s of t){let o=_v(s);if(o&&!a.some((c)=>JSON.stringify(c)===JSON.stringify(o)))a.push(o)}if(a.length===1)i.additionalProperties=a[0];else if(a.length>1)i.additionalProperties={allOf:a}}return i}function E1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let i of Ev)if(i in e)return;let n=t.filter((i)=>yv.some((a)=>Array.isArray(i[a]))),r=null;if(!n.length)r=Fh(t);else{let i=n[0],a=yv.find((c)=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;let s=t.filter((c)=>c!==i),o=i[a].map((c)=>Fh([...s,c]));if(o.some((c)=>!c))return;r={[a]:o}}if(!r)return;delete e.allOf,Ec(e,r)}function Bh(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(o)=>{let c=e.seen.get(o);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){r(d);let h=e.seen.get(d),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(b);else Ec(l,b);if(Ec(l,u),o._zod.parent===d)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(b.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let f=o._zod.parent;if(f&&f!==d){r(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(l[b])===JSON.stringify(h.def[b]))delete l[b]}}}e.override({zodSchema:o,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let o of[...e.seen.entries()].reverse())r(o[0]);if(e.target!=="openapi-3.0")for(let o of e.seen.entries())vv(o[1].def??o[1].schema);for(let o of e.deferred)o();if(e.intersections.length){let o=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=o.get(u);if(d)d.push(l);else o.set(u,[l])}for(let c of e.intersections)for(let l of o.get(c)??[])E1(l)}}let i={};if(e.target==="draft-2020-12")i.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")i.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")i.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let o=e.external.registry.get(t)?.id;if(!o)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(o)}Ec(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;if(a!==void 0&&i.id===a)delete i.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let o of e.seen.entries()){let c=o[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;yr(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")i.$defs=s;else i.definitions=s;try{let o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ac(t,"input",e.processors),output:Ac(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch(o){throw Error("Error converting schema to JSON.")}}function Bn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Bn(r.element,n);if(r.type==="set")return Bn(r.valueType,n);if(r.type==="lazy")return Bn(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Bn(r.innerType,n);if(r.type==="intersection")return Bn(r.left,n)||Bn(r.right,n);if(r.type==="record"||r.type==="map")return Bn(r.keyType,n)||Bn(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Bn(r.in,n)||Bn(r.out,n)}if(r.type==="object"){for(let i in r.shape)if(Bn(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(let i of r.options)if(Bn(i,n))return!0;return!1}if(r.type==="tuple"){for(let i of r.items)if(Bn(i,n))return!0;if(r.rest&&Bn(r.rest,n))return!0;return!1}return!1}var Av=(e,t={})=>(n)=>{let r=Uh({...n,processors:t});return qt(e,r),zh(r,e),Bh(r,e)},Ac=(e,t,n={})=>(r)=>{let{libraryOptions:i,target:a}=r??{},s=Uh({...i??{},target:a,io:t,processors:n});return qt(e,s),zh(s,e),Bh(s,e)};var Zs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Ys=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Tv=(e,t)=>{Zs(e,"minimum",t),Ys(e,"maximum",t)},Rv=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Iv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Cv=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Nv=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},wv=(e,t)=>Zs(e,"minimum",t.minimum),Mv=(e,t)=>Ys(e,"maximum",t.maximum),Sv=(e)=>(t,n)=>{Nv(t,n.format);let[r,i]=e[n.format];Zs(t,"minimum",r),Ys(t,"maximum",i)},A1={greater_than:(e,t)=>Zs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ys(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Rv(e,t.value),number_format:Sv(eu),bigint_format:Sv(rh),min_length:wv,max_length:Mv,length_equals:(e,t)=>Tv(e,t.length),min_size:wv,max_size:Mv,size_equals:(e,t)=>Tv(e,t.size),string_format:(e,t)=>{if(Nv(e,t.format),t.pattern)Iv(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)=>Cv(e,t.mime)};function ir(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let a of r)A1[a._zod.def.check]?.(t,a._zod.def);let i=e._zod.bag;if(i.minimum!==void 0)Zs(t,"minimum",i.minimum);if(i.exclusiveMinimum!==void 0)Zs(t,"exclusiveMinimum",i.exclusiveMinimum);if(i.maximum!==void 0)Ys(t,"maximum",i.maximum);if(i.exclusiveMaximum!==void 0)Ys(t,"exclusiveMaximum",i.exclusiveMaximum);if(i.multipleOf!==void 0)Rv(t,i.multipleOf);if(i.format!==void 0){if(t.format??(t.format=i.format),i.format.includes("int"))t.isInt=!0}if(i.mime)Cv(t,i.mime);for(let a of i.patterns??[])Iv(t,a);return t}var T1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},w1=new Map([[yh,Hx],[bu,$x]]),Pv=(e)=>w1.get(e)??e,Ov=(e,t,n,r)=>{let i=n;i.type="string";let{minimum:a,maximum:s,format:o,patterns:c,contentEncoding:l,laxFormat:u}=ir(e);if(typeof a==="number")i.minLength=a;if(typeof s==="number")i.maxLength=s;if(o){if(i.format=T1[o]??o,i.format==="")delete i.format;if(o==="time"||u)delete i.format}if(l)i.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(Pv);if(d.length===1)i.pattern=d[0].source;else if(d.length>1)i.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},kv=(e,t,n,r)=>{let i=n,{minimum:a,maximum:s,multipleOf:o,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ir(e);i.type=u?"integer":"number";let d=typeof l==="number"&&l>=(a??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(h)i.minimum=l,i.exclusiveMinimum=!0;else i.exclusiveMinimum=l;else if(typeof a==="number")i.minimum=a;if(f)if(h)i.maximum=c,i.exclusiveMaximum=!0;else i.exclusiveMaximum=c;else if(typeof s==="number")i.maximum=s;if(o){let b=new Set;for(let p of o)if(Number.isFinite(p)&&p!==0)b.add(Math.abs(p));else Ci(e,t,i,r,`A multipleOf divisor of ${p} cannot be represented in JSON Schema`);let[m,...g]=b;if(m!==void 0)i.multipleOf=m;if(g.length)i.allOf=[...i.allOf??[],...g.map((p)=>({multipleOf:p}))]}},Lv=(e,t,n,r)=>{n.type="boolean"};var Dv=(e,t,n,r)=>{n.not={}};var Fv=(e,t,n,r)=>{};var Uv=(e,t,n,r)=>{let i=e._zod.def,a=dc(i.entries);if(a.length===0){n.not={};return}if(a.every((s)=>typeof s==="number"))n.type="number";if(a.every((s)=>typeof s==="string"))n.type="string";n.enum=a},zv=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let s of i.values)if(s===void 0){if(Ci(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(Ci(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(s))}else a.push(s);if(a.length===0);else if(a.length===1){let s=a[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(a.every((s)=>typeof s==="number"))n.type="number";if(a.every((s)=>typeof s==="string"))n.type="string";if(a.every((s)=>typeof s==="boolean"))n.type="boolean";if(a.every((s)=>s===null))n.type="null";n.enum=a}};var Bv=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error("Pattern not found in template literal");i.type="string",i.pattern=a.source};var jv=(e,t,n,r)=>{Ci(e,t,n,r,"Custom types cannot be represented in JSON Schema")};var Vv=(e,t,n,r)=>{Ci(e,t,n,r,"Transforms cannot be represented in JSON Schema")};var Gv=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:s,maximum:o}=ir(e);if(typeof s==="number")i.minItems=s;if(typeof o==="number")i.maxItems=o;i.type="array",i.items=qt(a.element,t,{...r,path:[...r.path,"items"]})};function Tc(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Tc(t.out);if(t.type==="catch")return Tc(t.innerType);return e._zod.optin}var Hv=(e,t,n,r)=>{let i=n,a=e._zod.def,s=a.shape;if(Object.getOwnPropertySymbols(s).length&&Ci(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(let l in s)yr(i.properties,l,qt(s[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let u=a.shape[l];if(t.io==="input"?Tc(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)i.required=c;if(a.catchall?._zod.def.type==="never")i.additionalProperties=!1;else if(!a.catchall){if(t.io==="output")i.additionalProperties=!1}else if(a.catchall)i.additionalProperties=qt(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},$v=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,s=i.options.map((o,c)=>qt(o,t,{...r,path:[...r.path,a?"oneOf":"anyOf",c]}));if(a)n.oneOf=s;else n.anyOf=s},Kv=(e,t,n,r)=>{let i=e._zod.def,a=qt(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=qt(i.right,t,{...r,path:[...r.path,"allOf",1]}),o=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...o(a)?a.allOf:[a],...o(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Wv=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",o=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((m,g)=>qt(m,t,{...r,path:[...r.path,s,g]})),l=a.rest?qt(a.rest,t,{...r,path:[...r.path,o,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null,u=a.items.length;while(u>0){let m=a.items[u-1];if(!(t.io==="input"?Tc(m)!==void 0:m._zod.optout==="optional"))break;u--}let d=a.items.length,f=!a.rest;if(t.target==="draft-2020-12"){if(i.prefixItems=c,f)i.items=!1;else if(l)i.items=l;if(u>0)i.minItems=u;if(f)i.maxItems=d}else if(t.target==="openapi-3.0"){if(i.items={anyOf:c},l)i.items.anyOf.push(l);if(u>0)i.minItems=u;if(f)i.maxItems=d}else{if(i.items=c,f)i.additionalItems=!1;else if(l)i.additionalItems=l;if(u>0)i.minItems=u;if(f)i.maxItems=d}let{minimum:h,maximum:b}=ir(e);if(typeof h==="number")i.minItems=h;if(typeof b==="number")i.maxItems=b};function jh(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let b=e.get(t)?.def;if(!b)return t;let m=jh(e,b,n);return m===b?t:m}for(let b of["anyOf","oneOf"]){let m=t[b];if(!Array.isArray(m))continue;let g=m.map((p)=>jh(e,p,n));if(g.some((p,y)=>p!==m[y]))t={...t,[b]:g}}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some((b)=>b==="number"||b==="integer"),a=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!a?.some((b)=>typeof b==="number"))return t;let{minimum:s,maximum:o,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((b)=>typeof b==="number"?String(b):b);else if(typeof h.const==="number")h.const=String(h.const);if(!i)return h;if(h.type="string",!a)h.pattern=(r.includes("number")?qs:du).source;return h}var Vh=new WeakMap;function M1(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Vh.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let s=jh(t,a,new Set);if(s!==a)n.set(a,s)}if(!n.size)return;for(let r of e.seen.values())for(let i of[r.schema,r.def]){let a=i&&n.get(i.propertyNames);if(a)i.propertyNames=a}}var Xv=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type="object";let s=a.keyType,o=ir(s).patterns;if(a.mode==="loose"&&o&&o.size>0){let u=qt(a.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let d of o)yr(i.patternProperties,Pv(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=qt(a.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=Vh.get(t);if(!u)u=[],Vh.set(t,u),t.deferred.push(()=>M1(t));u.push(e)}i.additionalProperties=qt(a.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&Tc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)i.required=u.map(String)}},qv=(e,t,n,r)=>{let i=e._zod.def,a=qt(i.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=i.innerType,n.nullable=!0;else n.anyOf=[a,{type:"null"}]},Jv=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Gh=Symbol();function Zv(e,t,n,r,i){let a=!1,s=JSON.stringify(e,(o,c)=>{if(typeof c!=="bigint")return c;return a=!0,null});if(!a)return JSON.parse(s);return Ci(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Gh}var Yv=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let s=Zv(i.defaultValue,e,t,n,r);if(s!==Gh)n.default=s},Qv=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!=="input")return;let s=Zv(i.defaultValue,e,t,n,r);if(s!==Gh)n._prefault=s},e0=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{Ci(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},t0=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?a?i.out:i.in:i.out;qt(s,t,r);let o=t.seen.get(e);o.ref=s},n0=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0};var Hh=(e,t,n,r)=>{let i=e._zod.def;qt(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};var r0=new WeakSet([Object.prototype,Error.prototype]);function Su(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var k1=(e,t)=>{bx.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(r0.has(n))return;r0.add(n),Su(n,"format",(r)=>(i)=>yx(r,i)),Su(n,"flatten",(r)=>(i)=>xx(r,i)),Su(n,"addIssue",(r)=>(i)=>{r.issues.push(i),r.message=JSON.stringify(r.issues,fc,2)}),Su(n,"addIssues",(r)=>(i)=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,fc,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ar=ae("ZodError",k1,void 0,{Parent:Error});var i0=ou(ar),a0=cu(ar),s0=lu(ar),o0=uu(ar),c0=vx(ar),l0=Ex(ar),u0=Ax(ar),d0=Tx(ar),f0=wx(ar),h0=Mx(ar),p0=Sx(ar),m0=Rx(ar);function D1(){if(!zn.localeError)rr(wh())}function wc(){if(!zn.memoizer)rr({memoizer:O_()})}var Kt=ae("ZodType",(e,t)=>(D1(),zt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(nr(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 Yr(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(LC(e,t))},superRefine(e,t){return this.check(DC(e,t))},overwrite(e){return this.check(ia(e))},optional(){return x0(this)},exactOptional(){return _C(this)},nullable(){return y0(this)},nullish(){return x0(y0(this))},nonoptional(e){return MC(this,e)},array(){return at(this)},or(e){return Qs([this,e])},and(e){return mC(this,e)},transform(e){return _0(this,yC(e))},default(e){return AC(this,e)},prefault(e){return wC(this,e)},catch(e){return RC(this,e)},pipe(e){return _0(this,e)},readonly(){return NC(this)},describe(e){let t=this.clone();return fs.add(t,{description:e}),t},meta(...e){if(e.length===0)return fs.get(this);let t=this.clone();return fs.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 au(this,"~standard",{...xh(this),jsonSchema:{input:Ac(this,"input"),output:Ac(this,"output")}})},set "~standard"(e){Ri(this,"~standard",e)},parse:function e(t,n){return i0(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await a0(this,t,n,{callee:e})},safeParse(e,t){return s0(this,e,t)},async safeParseAsync(e,t){return o0(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ri(this,"spa",e)},validate(e,t){return ch(this,e,t)},validateAsync(e,t){return lh(this,e,t)},encode:function e(t,n){return c0(this,t,n,{callee:e})},decode:function e(t,n){return l0(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await u0(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await d0(this,t,n,{callee:e})},safeEncode(e,t){return f0(this,e,t)},safeDecode(e,t){return h0(this,e,t)},async safeEncodeAsync(e,t){return p0(this,e,t)},async safeDecodeAsync(e,t){return m0(this,e,t)},toJSONSchema(e){return Av(this,{})(e)},get description(){return fs.get(this)?.description},get _def(){return this._zod.def}}),v0=ae("_ZodString",(e,t)=>{gu.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ov(e,n,r,i)},dx({format:(e)=>ir(e).format??null,minLength:(e)=>ir(e).minimum??null,maxLength:(e)=>ir(e).maximum??null},{regex(...e){return this.check(Mh(...e))},includes(...e){return this.check(Ih(...e))},startsWith(...e){return this.check(Ch(...e))},endsWith(...e){return this.check(Nh(...e))},min(...e){return this.check(Js(...e))},max(...e){return this.check(wu(...e))},length(...e){return this.check(Mu(...e))},nonempty(...e){return this.check(Js(1,...e))},lowercase(e){return this.check(Sh(e))},uppercase(e){return this.check(Rh(e))},trim(){return this.check(Oh())},normalize(...e){return this.check(Ph(...e))},toLowerCase(){return this.check(kh())},toUpperCase(){return this.check(Lh())},slugify(){return this.check(Dh())}})),F1=ae("ZodString",(e,t)=>{gu.init(e,t),v0.init(e,t)},{email(e){return this.check(U_(V1,e))},url(e){return this.check(H_(H1,e))},jwt(e){return this.check(av(aC,e))},emoji(e){return this.check($_($1,e))},guid(e){return this.check(z_(G1,e))},uuid(e){return this.check(B_(Ru,e))},uuidv4(e){return this.check(j_(Ru,e))},uuidv6(e){return this.check(V_(Ru,e))},uuidv7(e){return this.check(G_(Ru,e))},nanoid(e){return this.check(K_(K1,e))},cuid(e){return this.check(W_(W1,e))},cuid2(e){return this.check(X_(X1,e))},ulid(e){return this.check(q_(q1,e))},base64(e){return this.check(nv(nC,e))},base64url(e){return this.check(rv(rC,e))},xid(e){return this.check(J_(J1,e))},ksuid(e){return this.check(Z_(Z1,e))},ipv4(e){return this.check(Y_(Y1,e))},ipv6(e){return this.check(Q_(Q1,e))},cidrv4(e){return this.check(ev(eC,e))},cidrv6(e){return this.check(tv(tC,e))},e164(e){return this.check(iv(iC,e))},datetime(e){return this.check(sv(U1,e))},date(e){return this.check(ov(z1,e))},time(e){return this.check(cv(B1,e))},duration(e){return this.check(lv(j1,e))}});function Fe(e){return F_(F1,e)}var Jt=ae("ZodStringFormat",(e,t)=>{$t.init(e,t),v0.init(e,t)}),U1=ae("ZodISODateTime",(e,t)=>{Hy.init(e,t),Jt.init(e,t)}),z1=ae("ZodISODate",(e,t)=>{$y.init(e,t),Jt.init(e,t)}),B1=ae("ZodISOTime",(e,t)=>{Ky.init(e,t),Jt.init(e,t)}),j1=ae("ZodISODuration",(e,t)=>{Wy.init(e,t),Jt.init(e,t)}),V1=ae("ZodEmail",(e,t)=>{Oy.init(e,t),Jt.init(e,t)});var G1=ae("ZodGUID",(e,t)=>{Ny.init(e,t),Jt.init(e,t)});var Ru=ae("ZodUUID",(e,t)=>{Py.init(e,t),Jt.init(e,t)});var H1=ae("ZodURL",(e,t)=>{Dy.init(e,t),Jt.init(e,t)});var $1=ae("ZodEmoji",(e,t)=>{Fy.init(e,t),Jt.init(e,t)});var K1=ae("ZodNanoID",(e,t)=>{Uy.init(e,t),Jt.init(e,t)});var W1=ae("ZodCUID",(e,t)=>{zy.init(e,t),Jt.init(e,t)});var X1=ae("ZodCUID2",(e,t)=>{By.init(e,t),Jt.init(e,t)});var q1=ae("ZodULID",(e,t)=>{jy.init(e,t),Jt.init(e,t)});var J1=ae("ZodXID",(e,t)=>{Vy.init(e,t),Jt.init(e,t)});var Z1=ae("ZodKSUID",(e,t)=>{Gy.init(e,t),Jt.init(e,t)});var Y1=ae("ZodIPv4",(e,t)=>{Xy.init(e,t),Jt.init(e,t)});var Q1=ae("ZodIPv6",(e,t)=>{Jy.init(e,t),Jt.init(e,t)});var eC=ae("ZodCIDRv4",(e,t)=>{Zy.init(e,t),Jt.init(e,t)});var tC=ae("ZodCIDRv6",(e,t)=>{Yy.init(e,t),Jt.init(e,t)});var nC=ae("ZodBase64",(e,t)=>{e_.init(e,t),Jt.init(e,t)});var rC=ae("ZodBase64URL",(e,t)=>{t_.init(e,t),Jt.init(e,t)});var iC=ae("ZodE164",(e,t)=>{n_.init(e,t),Jt.init(e,t)});var aC=ae("ZodJWT",(e,t)=>{r_.init(e,t),Jt.init(e,t)});var E0=ae("ZodNumber",(e,t)=>{_h.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kv(e,n,r,i),e.isFinite=!0},dx({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=ir(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=ir(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=ir(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>ir(e).format??null},{gt(e,t){return this.check(Au(e,t))},gte(e,t){return this.check(vc(e,t))},min(e,t){return this.check(vc(e,t))},lt(e,t){return this.check(Eu(e,t))},lte(e,t){return this.check(_c(e,t))},max(e,t){return this.check(_c(e,t))},int(e){return this.check(g0(e))},safe(e){return this.check(g0(e))},positive(e){return this.check(Au(0,e))},nonnegative(e){return this.check(vc(0,e))},negative(e){return this.check(Eu(0,e))},nonpositive(e){return this.check(_c(0,e))},multipleOf(e,t){return this.check(Tu(e,t))},step(e,t){return this.check(Tu(e,t))},finite(){return this}}));function He(e){return uv(E0,e)}var sC=ae("ZodNumberFormat",(e,t)=>{i_.init(e,t),E0.init(e,t)});function g0(e){return dv(sC,e)}var oC=ae("ZodBoolean",(e,t)=>{a_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lv(e,n,r,i)});function hs(e){return fv(oC,e)}var cC=ae("ZodUnknown",(e,t)=>{s_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fv(e,n,r,i)});function aa(){return hv(cC)}var lC=ae("ZodNever",(e,t)=>{o_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Dv(e,n,r,i)});function uC(e){return pv(lC,e)}var dC=ae("ZodArray",(e,t)=>{wc(),c_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gv(e,n,r,i),e.element=t.element},{min(e,t){return this.check(Js(e,t))},nonempty(e){return this.check(Js(1,e))},max(e,t){return this.check(wu(e,t))},length(e,t){return this.check(Mu(e,t))},unwrap(){return this.element}});function at(e,t){return mv(dC,e,t)}var fC=ae("ZodObject",(e,t)=>{wc(),d_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hv(e,n,r,i),jI(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return wt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(nr(this._zod.def,{catchall:e}))},passthrough(){return this.clone(nr(this._zod.def,{catchall:aa()}))},loose(){return this.clone(nr(this._zod.def,{catchall:aa()}))},strict(){return this.clone(nr(this._zod.def,{catchall:uC()}))},strip(){return this.clone(nr(this._zod.def,{catchall:void 0}))},extend(e){return OI(this,e)},safeExtend(e){return kI(this,e)},merge(e){return LI(this,e)},pick(e){return NI(this,e)},omit(e){return PI(this,e)},partial(...e){return ox(Wh,this,e[0])},exactPartial(...e){return ox(T0,this,e[0],"exactPartial")},required(...e){return DI(w0,this,e[0])}});function ge(e,t){let n={type:"object",shape:e??{},...Ue(t)};return new fC(n)}var A0=ae("ZodUnion",(e,t)=>{vh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$v(e,n,r,i),e.options=t.options});function Qs(e,t){return new A0({type:"union",options:e,...Ue(t)})}var hC=ae("ZodDiscriminatedUnion",(e,t)=>{A0.init(e,t),f_.init(e,t)});function Pr(e,t,n){return new hC({type:"union",options:t,discriminator:e,...Ue(n)})}var pC=ae("ZodIntersection",(e,t)=>{h_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kv(e,n,r,i)});function mC(e,t){return new pC({type:"intersection",left:e,right:t})}var gC=ae("ZodTuple",(e,t)=>{wc(),p_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wv(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Wh({type:"optional",innerType:t}))})}});function Iu(e,t,n){let r=t instanceof zt,i=r?n:t;return new gC({type:"tuple",items:e,rest:r?t:null,...Ue(i)})}var b0=ae("ZodRecord",(e,t)=>{wc(),m_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xv(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Cu(e,t,n){if(!t||!t._zod)return new b0({type:"record",keyType:Fe(),valueType:e,...Ue(t)});return new b0({type:"record",keyType:e,valueType:t,...Ue(n)})}var Kh=ae("ZodEnum",(e,t)=>{g_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(r,i,a)=>Uv(e,r,i,a),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{let a={};for(let s of r)if(n.has(s))a[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Kh({...t,checks:[],...Ue(i),entries:a})},e.exclude=(r,i)=>{let a={...t.entries};for(let s of r)if(n.has(s))delete a[s];else throw Error(`Key ${s} not found in enum`);return new Kh({...t,checks:[],...Ue(i),entries:a})}});function wt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Kh({type:"enum",entries:n,...Ue(t)})}var bC=ae("ZodLiteral",(e,t)=>{b_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zv(e,n,r,i),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 Ge(e,t){return new bC({type:"literal",values:Array.isArray(e)?e:[e],...Ue(t)})}var xC=ae("ZodTransform",(e,t)=>{wc(),x_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vv(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new mc(e.constructor.name);n.addIssue=(a)=>{if(typeof a==="string")n.issues.push(ds(a,n.value,t));else{let s=a;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(ds(s))}};let i=t.transform(n.value,n);if(i instanceof Promise)return i.then((a)=>(n.value=a,n));return n.value=i,n}});function yC(e){return new xC({type:"transform",transform:e})}var Wh=ae("ZodOptional",(e,t)=>{Eh.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function x0(e){return new Wh({type:"optional",innerType:e})}var T0=ae("ZodExactOptional",(e,t)=>{y_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hh(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function _C(e){return new T0({type:"optional",innerType:e})}var vC=ae("ZodNullable",(e,t)=>{__.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function y0(e){return new vC({type:"nullable",innerType:e})}var EC=ae("ZodDefault",(e,t)=>{v_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function AC(e,t){return new EC({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():th(t)}})}var TC=ae("ZodPrefault",(e,t)=>{E_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function wC(e,t){return new TC({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():th(t)}})}var w0=ae("ZodNonOptional",(e,t)=>{A_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jv(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function MC(e,t){return new w0({type:"nonoptional",innerType:e,...Ue(t)})}var SC=ae("ZodCatch",(e,t)=>{T_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>e0(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function RC(e,t){return new SC({type:"catch",innerType:e,catchValue:typeof t==="function"?t:fx(t)})}var IC=ae("ZodPipe",(e,t)=>{w_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>t0(e,n,r,i),e.in=t.in,e.out=t.out});function _0(e,t){return new IC({type:"pipe",in:e,out:t})}var CC=ae("ZodReadonly",(e,t)=>{M_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>n0(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function NC(e){return new CC({type:"readonly",innerType:e})}var PC=ae("ZodTemplateLiteral",(e,t)=>{S_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bv(e,n,r,i)});function OC(e,t){return new PC({type:"template_literal",parts:e,...Ue(t)})}var kC=ae("ZodCustom",(e,t)=>{R_.init(e,t),Kt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jv(e,n,r,i)});function LC(e,t={}){return gv(kC,e,t)}function DC(e,t){return bv(e,t)}var Nu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var M0;(function(e){})(M0||(M0={}));var S0=["neutral","dark","light"];var Xh=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),R0=Object.freeze({neutral:Xh("neutral",[170,177,188]),dark:Xh("dark",[26,26,26]),light:Xh("light",[223,227,232])});var NV=R0.neutral.rgb,PV=R0.neutral.hex;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
-*/var Zt=Uint8Array,ri=Uint16Array,Wh=Int32Array,Tu=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Au=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Vh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Av=function(e,t){var n=new ri(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new Wh(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}},wv=Av(Tu,2),{b:Sv,r:jh}=wv;Sv[28]=258,jh[258]=28;var Mv=Av(Au,0),{b:xC,r:xv}=Mv,Hh=new ri(32768);for(pt=0;pt<32768;++pt)er=(pt&43690)>>1|(pt&21845)<<1,er=(er&52428)>>2|(er&13107)<<2,er=(er&61680)>>4|(er&3855)<<4,Hh[pt]=((er&65280)>>8|(er&255)<<8)>>1;var er,pt,nr=function(e,t,n){var i=e.length,r=0,s=new ri(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var a=new ri(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var o;if(n){o=new ri(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u;for(var f=d|(1<<u)-1;d<=f;++d)o[Hh[d]>>c]=l}}else{o=new ri(i);for(r=0;r<i;++r)if(e[r])o[r]=Hh[a[e[r]-1]++]>>15-e[r]}return o},es=new Zt(288);for(pt=0;pt<144;++pt)es[pt]=8;var pt;for(pt=144;pt<256;++pt)es[pt]=9;var pt;for(pt=256;pt<280;++pt)es[pt]=7;var pt;for(pt=280;pt<288;++pt)es[pt]=8;var pt,vc=new Zt(32);for(pt=0;pt<32;++pt)vc[pt]=5;var pt,yC=nr(es,9,0),_C=nr(es,9,1),vC=nr(vc,5,0),EC=nr(vc,5,1),Fh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Uh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Xh=function(e){return(e+7)/8|0},Ec=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Zt(e.subarray(t,n))};var TC=["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"],Vn=function(e,t,n){var i=Error(t||TC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,Vn);if(!n)throw i;return i},AC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Zt(0);var a=!n,o=a||t.i!=2,c=t.i;if(a)n=new Zt(r*3);var l=function(ce){var _e=n.length;if(ce>_e){var Re=new Zt(Math.max(_e*2,ce));Re.set(n),n=Re}},u=t.f||0,d=t.p||0,f=t.b||0,{l:h,d:b,m,n:g}=t,p=r*8;do{if(!h){u=Ii(e,d,1);var x=Ii(e,d+1,3);if(d+=3,!x){var _=Xh(d)+4,y=e[_-4]|e[_-3]<<8,v=_+y;if(v>r){if(c)Vn(0);break}if(o)l(f+y);n.set(e.subarray(_,v),f),t.b=f+=y,t.p=d=v*8,t.f=u;continue}else if(x==1)h=_C,b=EC,m=9,g=5;else if(x==2){var E=Ii(e,d,31)+257,w=Ii(e,d+10,15)+4,T=E+Ii(e,d+5,31)+1;d+=14;var A=new Zt(T),P=new Zt(19);for(var S=0;S<w;++S)P[Vh[S]]=Ii(e,d+S*3,7);d+=w*3;var R=Fh(P),k=(1<<R)-1,C=nr(P,R,1);for(var S=0;S<T;){var U=C[Ii(e,d,k)];d+=U&15;var _=U>>4;if(_<16)A[S++]=_;else{var L=0,O=0;if(_==16)O=3+Ii(e,d,3),d+=2,L=A[S-1];else if(_==17)O=3+Ii(e,d,7),d+=3;else if(_==18)O=11+Ii(e,d,127),d+=7;while(O--)A[S++]=L}}var K=A.subarray(0,E),B=A.subarray(E);m=Fh(K),g=Fh(B),h=nr(K,m,1),b=nr(B,g,1)}else Vn(1);if(d>p){if(c)Vn(0);break}}if(o)l(f+131072);var X=(1<<m)-1,q=(1<<g)-1,le=d;for(;;le=d){var L=h[Uh(e,d)&X],de=L>>4;if(d+=L&15,d>p){if(c)Vn(0);break}if(!L)Vn(2);if(de<256)n[f++]=de;else if(de==256){le=d,h=null;break}else{var Me=de-254;if(de>264){var S=de-257,pe=Tu[S];Me=Ii(e,d,(1<<pe)-1)+Sv[S],d+=pe}var J=b[Uh(e,d)&q],F=J>>4;if(!J)Vn(3);d+=J&15;var B=xC[F];if(F>3){var pe=Au[F];B+=Uh(e,d)&(1<<pe)-1,d+=pe}if(d>p){if(c)Vn(0);break}if(o)l(f+131072);var W=f+Me;if(f<B){var ne=s-B,ie=Math.min(B,W);if(ne+f<0)Vn(3);for(;f<ie;++f)n[f]=i[ne+f]}for(;f<W;++f)n[f]=n[f-B]}}if(t.l=h,t.p=le,t.b=f,t.f=u,h)u=1,t.m=m,t.d=b,t.n=g}while(!u);return f!=n.length&&a?Ec(n,0,f):n.subarray(0,f)},Cr=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},yc=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Bh=function(e,t){var n=[];for(var i=0;i<e.length;++i)if(e[i])n.push({s:i,f:e[i]});var r=n.length,s=n.slice();if(!r)return{t:Iv,l:0};if(r==1){var a=new Zt(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(v,E){return v.f-E.f}),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:o.f+c.f,l:o,r:c};while(u!=r-1)o=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var f=s[0].s;for(var i=1;i<r;++i)if(s[i].s>f)f=s[i].s;var h=new ri(f+1),b=Gh(n[u-1],h,0);if(b>t){var i=0,m=0,g=b-t,p=1<<g;s.sort(function(E,w){return h[w.s]-h[E.s]||E.f-w.f});for(;i<r;++i){var x=s[i].s;if(h[x]>t)m+=p-(1<<b-h[x]),h[x]=t;else break}m>>=g;while(m>0){var _=s[i].s;if(h[_]<t)m-=1<<t-h[_]++-1;else++i}for(;i>=0&&m;--i){var y=s[i].s;if(h[y]==t)--h[y],++m}b=t}return{t:new Zt(h),l:b}},Gh=function(e,t,n){return e.s==-1?Math.max(Gh(e.l,t,n+1),Gh(e.r,t,n+1)):t[e.s]=n},yv=function(e){var t=e.length;while(t&&!e[--t]);var n=new ri(++t),i=0,r=e[0],s=1,a=function(c){n[i++]=c};for(var o=1;o<=t;++o)if(e[o]==r&&o!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);if(s>2)a(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){a(r),--s;for(;s>6;s-=6)a(8304);if(s>2)a(s-3<<5|8208),s=0}while(s--)a(r);s=1,r=e[o]}return{c:n.subarray(0,i),n:t}},_c=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Rv=function(e,t,n){var i=n.length,r=Xh(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},_v=function(e,t,n,i,r,s,a,o,c,l,u){Cr(t,u++,n),++r[256];var d=Bh(r,15),{t:f,l:h}=d,b=Bh(s,15),{t:m,l:g}=b,p=yv(f),{c:x,n:_}=p,y=yv(m),{c:v,n:E}=y,w=new ri(19);for(var T=0;T<x.length;++T)++w[x[T]&31];for(var T=0;T<v.length;++T)++w[v[T]&31];var A=Bh(w,7),{t:P,l:S}=A,R=19;for(;R>4&&!P[Vh[R-1]];--R);var k=l+5<<3,C=_c(r,es)+_c(s,vc)+a,U=_c(r,f)+_c(s,m)+a+14+3*R+_c(w,P)+2*w[16]+3*w[17]+7*w[18];if(c>=0&&k<=C&&k<=U)return Rv(t,u,e.subarray(c,c+l));var L,O,K,B;if(Cr(t,u,1+(U<C)),u+=2,U<C){L=nr(f,h,0),O=f,K=nr(m,g,0),B=m;var X=nr(P,S,0);Cr(t,u,_-257),Cr(t,u+5,E-1),Cr(t,u+10,R-4),u+=14;for(var T=0;T<R;++T)Cr(t,u+3*T,P[Vh[T]]);u+=3*R;var q=[x,v];for(var le=0;le<2;++le){var de=q[le];for(var T=0;T<de.length;++T){var Me=de[T]&31;if(Cr(t,u,X[Me]),u+=P[Me],Me>15)Cr(t,u,de[T]>>5&127),u+=de[T]>>12}}}else L=yC,O=es,K=vC,B=vc;for(var T=0;T<o;++T){var pe=i[T];if(pe>255){var Me=pe>>18&31;if(yc(t,u,L[Me+257]),u+=O[Me+257],Me>7)Cr(t,u,pe>>23&31),u+=Tu[Me];var J=pe&31;if(yc(t,u,K[J]),u+=B[J],J>3)yc(t,u,pe>>5&8191),u+=Au[J]}else yc(t,u,L[pe]),u+=O[pe]}return yc(t,u,L[256]),u+O[256]},wC=new Wh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Iv=new Zt(0),SC=function(e,t,n,i,r,s){var a=s.z||e.length,o=new Zt(i+a+5*(1+Math.ceil(a/7000))+r),c=o.subarray(i,o.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=wC[t-1],f=d>>13,h=d&8191,b=(1<<n)-1,m=s.p||new ri(32768),g=s.h||new ri(b+1),p=Math.ceil(n/3),x=2*p,_=function(ke){return(e[ke]^e[ke+1]<<p^e[ke+2]<<x)&b},y=new Wh(25000),v=new ri(288),E=new ri(32),w=0,T=0,A=s.i||0,P=0,S=s.w||0,R=0;for(;A+2<a;++A){var k=_(A),C=A&32767,U=g[k];if(m[C]=U,g[k]=C,S<=A){var L=a-A;if((w>7000||P>24576)&&(L>423||!l)){u=_v(e,c,0,y,v,E,T,P,R,A-R,u),P=w=T=0,R=A;for(var O=0;O<286;++O)v[O]=0;for(var O=0;O<30;++O)E[O]=0}var K=2,B=0,X=h,q=C-U&32767;if(L>2&&k==_(A-q)){var le=Math.min(f,L)-1,de=Math.min(32767,A),Me=Math.min(258,L);while(q<=de&&--X&&C!=U){if(e[A+K]==e[A+K-q]){var pe=0;for(;pe<Me&&e[A+pe]==e[A+pe-q];++pe);if(pe>K){if(K=pe,B=q,pe>le)break;var J=Math.min(q,pe-2),F=0;for(var O=0;O<J;++O){var W=A-q+O&32767,ne=m[W],ie=W-ne&32767;if(ie>F)F=ie,U=W}}}C=U,U=m[C],q+=C-U&32767}}if(B){y[P++]=268435456|jh[K]<<18|xv[B];var ce=jh[K]&31,_e=xv[B]&31;T+=Tu[ce]+Au[_e],++v[257+ce],++E[_e],S=A+K,++w}else y[P++]=e[A],++v[e[A]]}}for(A=Math.max(A,S);A<a;++A)y[P++]=e[A],++v[e[A]];if(u=_v(e,c,l,y,v,E,T,P,R,A-R,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=g,s.p=m,s.i=A,s.w=S}else{for(var A=s.w||0;A<a+l;A+=65535){var Re=A+65535;if(Re>=a)c[u/8|0]=l,Re=a;u=Rv(c,u+1,e.subarray(A,Re))}s.i=a}return Ec(o,0,i+Xh(u)+r)},MC=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}(),RC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=MC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var IC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),a=new Zt(s.length+e.length);a.set(s),a.set(e,s.length),e=a,r.w=s.length}}return SC(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},Cv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var tr=function(e,t){return e[t]|e[t+1]<<8},Ci=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},zh=function(e,t){return Ci(e,t)+Ci(e,t+4)*4294967296},Mn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function CC(e,t){return IC(e,t||{},0,0)}function NC(e,t){return AC(e,{i:2},t&&t.out,t&&t.dictionary)}var Nv=function(e,t,n,i){for(var r in e){var s=e[r],a=t+r,o=i;if(Array.isArray(s))o=Cv(i,s[1]),s=s[0];if(s instanceof Zt)n[a]=[s,o];else n[a+="/"]=[new Zt(0),o],Nv(s,a,n,i)}},vv=typeof TextEncoder<"u"&&new TextEncoder,$h=typeof TextDecoder<"u"&&new TextDecoder,PC=0;try{$h.decode(Iv,{stream:!0}),PC=1}catch(e){}var OC=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:Ec(e,n-1)};if(!r)t+=String.fromCharCode(i);else if(r==3)i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|i>>10,56320|i&1023);else if(r&1)t+=String.fromCharCode((i&31)<<6|e[n++]&63);else t+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function Ev(e,t){if(t){var n=new Zt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(vv)return vv.encode(e);var r=e.length,s=new Zt(e.length+(e.length>>1)),a=0,o=function(u){s[a++]=u};for(var i=0;i<r;++i){if(a+5>s.length){var c=new Zt(a+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)o(l);else if(l<2048)o(192|l>>6),o(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63);else o(224|l>>12),o(128|l>>6&63),o(128|l&63)}return Ec(s,0,a)}function kC(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($h)return $h.decode(e);else{var r=OC(e),{s,r:n}=r;if(n.length)Vn(8);return s}}var DC=function(e,t){return t+30+tr(e,t+26)+tr(e,t+28)},LC=function(e,t,n){var i=tr(e,t+28),r=kC(e.subarray(t+46,t+46+i),!(tr(e,t+8)&2048)),s=t+46+i,a=Ci(e,t+20),o=n&&a==4294967295?FC(e,s):[a,Ci(e,t+24),Ci(e,t+42)],c=o[0],l=o[1],u=o[2];return[tr(e,t+10),c,l,r,s+tr(e,t+30)+tr(e,t+32),u]},FC=function(e,t){for(;tr(e,t)!=1;t+=4+tr(e,t+2));return[zh(e,t+12),zh(e,t+4),zh(e,t+20)]},Kh=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)Vn(9);t+=i+4}return t},Tv=function(e,t,n,i,r,s,a,o){var c=i.length,l=n.extra,u=o&&o.length,d=Kh(l);if(Mn(e,t,a!=null?33639248:67324752),t+=4,a!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),h=f.getFullYear()-1980;if(h<0||h>119)Vn(10);if(Mn(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,s!=-1)Mn(e,t,n.crc),Mn(e,t+4,s<0?-s-2:s),Mn(e,t+8,n.size);if(Mn(e,t+12,c),Mn(e,t+14,d),t+=16,a!=null)Mn(e,t,u),Mn(e,t+6,n.attrs),Mn(e,t+10,a),t+=14;if(e.set(i,t),t+=c,d)for(var b in l){var m=l[b],g=m.length;Mn(e,t,+b),Mn(e,t+2,g),e.set(m,t+4),t+=4+g}if(u)e.set(o,t),t+=u;return t},UC=function(e,t,n,i,r){Mn(e,t,101010256),Mn(e,t+8,n),Mn(e,t+10,n),Mn(e,t+12,i),Mn(e,t+16,r)};function Pv(e,t){if(!t)t={};var n={},i=[];Nv(e,"",n,t);var r=0,s=0;for(var a in n){var o=n[a],c=o[0],l=o[1],u=l.level==0?0:8,d=Ev(a),f=d.length,h=l.comment,b=h&&Ev(h),m=b&&b.length,g=Kh(l.extra);if(f>65535)Vn(11);var p=u?CC(c,l):c,x=p.length,_=RC();_.p(c),i.push(Cv(l,{size:c.length,crc:_.d(),c:p,f:d,m:b,u:f!=a.length||b&&h.length!=m,o:r,compression:u})),r+=30+f+g+x,s+=76+2*(f+g)+(m||0)+x}var y=new Zt(s+22),v=r,E=s-r;for(var w=0;w<i.length;++w){var d=i[w];Tv(y,d.o,d,d.f,d.u,d.c.length);var T=30+d.f.length+Kh(d.extra);y.set(d.c,d.o+T),Tv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+T+(d.m?d.m.length:0)}return UC(y,r,i.length,E,v),y}function Ov(e,t){var n={},i=e.length-22;for(;Ci(e,i)!=101010256;--i)if(!i||e.length-i>65558)Vn(13);var r=tr(e,i+8);if(!r)return{};var s=Ci(e,i+16),a=s==4294967295||r==65535;if(a){var o=Ci(e,i-12);if(a=Ci(e,o)==101075792,a)r=Ci(e,o+32),s=Ci(e,o+48)}var c=t&&t.filter;for(var l=0;l<r;++l){var u=LC(e,s,a),d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=u[5],p=DC(e,g);if(s=m,!c||c({name:b,size:f,originalSize:h,compression:d}))if(!d)n[b]=Ec(e,p,p+f);else if(d==8)n[b]=NC(e.subarray(p,p+f),{out:new Zt(h)});else Vn(14,"unknown compression type "+d)}return n}Ja();Ou();Du();Fu();Ja();Ou();Fu();Du();Tc();var oN=(()=>{let e=gt().int().min(0).max(16777215),t=gt().int().min(1).max(fa),n=gt().min(-36000).max(36000),i=gt().min(0).max(1),r={blend:Ct(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:$e(2),size:gt().int().min(Su).max(wu),usage:Ct(ir),name:Fe().min(1).max(80).optional(),layers:at(Ri("op",[be({op:$e("solid"),color:e,...r}).strict(),be({op:$e("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:$e("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:$e("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:$e("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:$e("noise"),colorA:e,colorB:e,scale:t,octaves:gt().int().min(1).max(Jh),seed:gt().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(Mu)}).strict()})();function Zv(e,t=oN){let n=(X,q)=>gt().int().min(X).max(q),i=n(0,255),r=n(-4096,4096),s=fv([r,r]),a=fv([i,i,i,i]),o=Ct(ir),c=pC(["sha256:",Fe().regex(/^[a-f0-9]{64}$/)]),l=Fe().min(1).max(80),u=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),f={width:n(1,4096),height:n(1,4096)},h=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),b=be({x:n(0,4096),y:n(0,4096),...f}).strict(),m=Ri("kind",[h.extend({kind:$e("rectangle")}).strict(),h.extend({kind:$e("ellipse")}).strict(),be({kind:$e("polygon"),points:at(s).min(3).max(Cu)}).strict(),be({kind:$e("line"),from:s,to:s,width:n(1,2048)}).strict()]),g=be({op:$e("paint"),shape:m,rgba:a,opacity:i}).strict(),p=be({op:$e("mask"),shape:m,alpha:i,invert:la()}).strict(),x=be({op:$e("stamps"),shape:m,rgba:a,opacity:i,count:n(1,Sc),seed:n(0,4294967295),area:h,periodic:la()}).strict(),_=be({op:$e("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:at(n(0,16777215)).min(1).max(Nu),dither:Ct(["none","bayer4"])}).strict(),v={schemaVersion:$e(3),width:n(4,Mc),height:n(4,Mc),usage:o,name:l.optional(),background:a},E=be({...v,operations:at(Ri("op",[g,p,x,_.extend({spec:t})])).max(Rc),palette:y.optional()}).strict(),w=be({...v,usage:o.optional(),background:a.optional(),operations:at(Ri("op",[g.partial({opacity:!0}),p.partial({alpha:!0,invert:!0}),x.partial({opacity:!0,periodic:!0}),_.partial({alpha:!0,opacity:!0})])).max(Rc),palette:y.partial({dither:!0}).optional()}).strict(),T=be({minFilter:Ct(Qh),magFilter:Ct(ep),wrapS:Ct(Ic),wrapT:Ct(Ic)}).strict(),A=be({resourceId:u,revisionId:c,sha256:c}).strict(),P=be({kind:$e("resource"),resourceId:d,pin:A,expected:be({...f,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),S=be({name:u,content:b,gutter:n(0,32),edgeMode:Ct(["copy-edge","mask-rgb-dilate"]),source:Ri("kind",[be({kind:$e("procedural"),spec:E}).strict(),P]),crop:b.optional(),packed:$e(!0).optional()}).strict(),R={schemaVersion:$e(1),width:n(4,Nr.edge),height:n(4,Nr.edge),usage:o,sampler:T},k=Xa(np.map((X)=>$e(X))),C=be({...R,regions:at(S).min(1).max(Nr.regions),pack:be({edge:k,gutter:n(0,32),algorithm:$e("maxrects")}).strict().optional()}).strict(),U=be({...R,width:R.width.optional(),height:R.height.optional(),pack:be({edge:k,gutter:n(0,32).optional(),algorithm:$e("maxrects").optional()}).strict().optional(),sampler:T.optional(),regions:at(S.extend({source:Ri("kind",[be({kind:$e("procedural"),spec:w}).strict(),P])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Nr.regions)}).strict(),L=be({materialId:u,revisionId:c,resourceId:d,slot:Ct(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:o,colorSpace:Ct(["srgb","linear"]),...f,encodedByteLength:n(1,ha.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),O={id:Fe().min(1).max(1024),...f,decodedPixelHash:c},K=Ri("kind",[be({...O,kind:$e("procedural"),recipeHash:c,compilerId:$e(Za)}).strict(),be({...O,kind:$e("resource"),descriptor:L}).strict()]),B=be({version:$e("kiln.atlas-manifest.v1"),compilerId:Ct(Lu),width:R.width,height:R.height,usage:o,origin:$e("top-left"),sampler:T,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:at(K).min(1).max(Nr.sources),regions:at(be({name:u,content:b,allocation:b,crop:b,sourceId:Fe().min(1).max(1024)}).strict()).min(1).max(Nr.regions),manifestHash:c}).strict();return{portableSamplerSchema:T,proceduralTextureSpecV3Schema:w,canonicalProceduralTextureSpecV3Schema:E,textureAtlasSpecV1Schema:U,canonicalTextureAtlasSpecV1Schema:C,textureAtlasManifestV1Schema:B,materialMapPinSchema:A,verifiedPinnedMaterialMapDescriptorSchema:L}}var Pn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),Qv=["baseColor","normal","metallicRoughness","emissive","occlusion"],eE={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),ar=Fe().regex(/^sha256:[a-f0-9]{64}$/),sr=Fe().min(1).max(1000),Yv=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),tE=be({id:eo,kind:Ct(["external","procedural"]),provider:sr,creator:sr,assetId:sr.optional(),assetUrl:Yv.optional(),accessedAt:Fe().datetime().optional(),license:be({spdx:sr,url:Yv,attribution:Fe().max(4000)}).strict(),originalFiles:at(be({name:Fe().min(1).max(200),sha256:ar,bytes:gt().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),nE=be({operation:sr,tool:sr,version:sr,parameters:_u(Fe().max(100),Xa([Fe().max(2000),gt().finite(),la()])).optional()}).strict(),Pi=gt().int().min(0).max(16777215),Nc=gt().int().min(1).max(256),Qa={blend:Ct(["normal","multiply","screen","overlay"]).default("normal"),opacity:gt().min(0).max(1).default(1)},kc=be({schemaVersion:$e(2),size:gt().int().min(4).max(1024).default(256),usage:Ct(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:at(Ri("op",[be({op:$e("solid"),color:Pi,...Qa}).strict(),be({op:$e("checker"),colorA:Pi,colorB:Pi,squares:Nc.default(8),...Qa}).strict(),be({op:$e("stripes"),colorA:Pi,colorB:Pi,count:Nc.default(8),angleDeg:gt().min(-36000).max(36000).default(0),...Qa}).strict(),be({op:$e("gradient"),from:Pi,to:Pi,angleDeg:gt().min(-36000).max(36000).default(0),...Qa}).strict(),be({op:$e("bricks"),brick:Pi,mortar:Pi,rows:Nc.default(8),cols:Nc.default(4),mortarWidth:gt().min(0).max(1).default(0.06),stagger:gt().min(0).max(1).default(0.5),...Qa}).strict(),be({op:$e("noise"),colorA:Pi,colorB:Pi,scale:Nc.default(8),octaves:gt().int().min(1).max(6).default(3),seed:gt().int().min(-2147483648).max(2147483647).default(0),...Qa}).strict()])).min(1).max(8)}).strict(),ap=be({kind:$e("normal-from-height"),strength:gt().finite().positive().max(64)}).strict(),cN=be({compiler:$e("kiln.procedural-texture.v2"),spec:kc,derive:ap.optional(),recipeHash:ar,pixelHash:ar,encoder:be({name:$e("sharp"),version:sr}).strict()}).strict(),iE=be({baseColor:gt().int().min(0).max(16777215).optional(),roughness:gt().min(0).max(1).default(1),metalness:gt().min(0).max(1).default(0),emissive:gt().int().min(0).max(16777215).optional(),emissiveIntensity:gt().min(0).max(64).default(1),alphaMode:Ct(["opaque","mask","blend"]).default("opaque"),alphaCutoff:gt().min(0).max(1).default(0.5),doubleSided:la().default(!1)}).strict(),Pc=be({schemaVersion:$e(1),materialId:eo,revisionId:ar,name:Fe().min(1).max(200),tags:at(Fe().min(1).max(80)).max(30),tileable:la(),physicalSizeMeters:be({width:gt().finite().positive().max(1e5),height:gt().finite().positive().max(1e5)}).strict().optional(),parameters:iE,sources:at(tE).min(1).max(20),maps:at(be({slot:Ct(Qv),file:Ct(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:ar,bytes:gt().int().positive().max(Pn.maxMapBytes),width:gt().int().positive().max(Pn.maxMapEdge),height:gt().int().positive().max(Pn.maxMapEdge),usage:Ct(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:Ct(["srgb","linear"]),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Fe().min(1).max(200).optional(),transforms:at(nE).max(30),procedural:cN.optional()}).strict()).min(1).max(5)}).strict(),rp=be({materialId:eo,name:Fe().min(1).max(200),tags:at(Fe().min(1).max(80)).max(30).optional(),tileable:la(),physicalSizeMeters:be({width:gt().finite().positive().max(1e5),height:gt().finite().positive().max(1e5)}).strict().optional(),parameters:iE.partial().optional(),sources:at(tE).min(1).max(20),maps:at(be({slot:Ct(Qv),sourceId:eo,transforms:at(nE).max(30),normalConvention:$e("opengl").optional(),channelPacking:$e("r-occlusion-g-roughness-b-metallic").optional(),procedural:kc,derive:ap.optional()}).strict()).min(1).max(5)}).strict(),sp=be({schemaVersion:$e(1),records:at(be({manifest:Pc,files:_u(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(Pn.maxMapBytes/3)*4))}).strict()).max(Pn.maxPayloadRecords)}).strict();function io(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let a=Object.getOwnPropertyDescriptor(e,s);if(!("value"in a)||!a.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");io(a.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Nn(e){io(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function lN(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>Pn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=Pc.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==eE[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let a=t.sources.find((o)=>o.id===r.sourceId);if(!a)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Nn(r.procedural.spec)!==Nn(wc(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(a.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(a.kind!=="external"||!a.originalFiles.some((o)=>o.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>Pn.maxRecordBytes||i>Pn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Zv(kc),no={when:(e)=>!e.issues.length},rE=(e)=>e instanceof Error?e.message:String(e);function Oc(e,t,n){return(i,r)=>{try{let s=t(i);if(n&&Nn(i)!==Nn(s))r.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(s){r.addIssue({code:"custom",message:rE(s)})}}}var sE=to.portableSamplerSchema.superRefine(Oc("sampler",ku,!0),no),uN=to.canonicalProceduralTextureSpecV3Schema.superRefine(Oc("procedural V3 spec",Zh,!0),no),dN=to.canonicalTextureAtlasSpecV1Schema.superRefine(Oc("atlas spec",pa,!0),no),fN=to.textureAtlasManifestV1Schema,hN=be({resourceId:eo,revisionId:ar,sha256:ar}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),pN=Ri("kind",[be({kind:$e("procedural"),compilerId:Ct(["kiln.procedural-texture.v2",Za]),spec:Xa([kc,uN]),recipeHash:ar,pixelHash:ar,encoder:be({name:$e("sharp"),version:sr}).strict(),derive:ap.optional()}).strict(),be({kind:$e("atlas"),compilerId:Ct(Lu),spec:dN,manifest:fN,encoder:be({name:$e("sharp"),version:sr}).strict()}).strict().superRefine((e,t)=>{try{if(Cc(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${rE(n)}`})}},no)]),aE=Pc.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:$e(2),dependencies:at(hN).max(16),maps:at(Pc.shape.maps.element.omit({procedural:!0}).extend({sampler:sE,pixelHash:ar,recipe:pN.optional()}).strict()).min(1).max(5)}).strict(),mN=Ri("schemaVersion",[Pc,aE]),gN=sp.extend({schemaVersion:$e(2),records:at(sp.shape.records.element.extend({manifest:mN}).strict()).max(Pn.maxPayloadRecords)}).strict(),oE=Ri("schemaVersion",[sp,gN]);function cE(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var bN=rp.extend({schemaVersion:$e(2),maps:at(rp.shape.maps.element.omit({procedural:!0}).extend({sampler:sE,procedural:Xa([kc,to.proceduralTextureSpecV3Schema.superRefine(Oc("procedural V3 spec",Zh,!1),no)]).optional(),atlas:to.textureAtlasSpecV1Schema.superRefine(Oc("atlas spec",pa,!1),no).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),jj=Xa([rp,bN]);function ro(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>Pn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return lN(e);let t=aE.parse(e);if(new Set(t.sources.map((a)=>a.id)).size!==t.sources.length||new Set(t.maps.map((a)=>a.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let a of t.maps){let o=t.sources.find((l)=>l.id===a.sourceId);if(!o||a.file!==`${a.slot}.png`||a.usage!==eE[a.slot]||a.colorSpace!==(a.slot==="baseColor"||a.slot==="emissive"?"srgb":"linear")||a.slot==="normal"!==(a.normalConvention==="opengl")||a.slot==="metallicRoughness"!==(a.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=a.recipe;if(c){if(o.kind!=="procedural"||a.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Za||l.width!==a.width||l.height!==a.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==a.width||a.width!==a.height||Nn(l)!==Nn(wc(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==a.usage||c.pixelHash!==a.pixelHash||c.derive&&a.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Cc(c.manifest,c.spec),c.spec.width!==a.width||c.spec.height!==a.height||c.spec.usage!==a.usage||Nn(c.spec.sampler)!==Nn(a.sampler)||c.manifest.decodedPixelHash!==a.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(o.kind!=="external"||!o.originalFiles.some((l)=>l.name===a.originalFile))throw Error("External material source original file missing");n+=a.bytes,i+=a.width*a.height}let s=t.dependencies.map((a)=>`${a.resourceId}/${a.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((a)=>!r.has(a)))throw Error("Material dependency pin inventory mismatch");if(n>Pn.maxRecordBytes||i>Pn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var Wn=67108864,op=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),xN=Fe().regex(/^sha256:[a-f0-9]{64}$/),lE=be({version:$e("kiln.asset.v1"),assetId:op,revisionId:op,parentRevision:op.optional(),name:Fe().min(1).max(200),tags:at(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:be({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:la(),files:_u(Fe(),be({sha256:xN,bytes:gt().int().nonnegative().max(Wn)})),build:be({engine:Fe(),options:_u(Fe(),ca()),warnings:at(Fe()),integration:ca().optional(),qa:ca().optional(),dependencies:at(ca()).optional(),rebuild:Ct(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:ca().optional(),error:Fe().optional(),backdrop:Ct(gv).optional()}).optional()}),Dc="materials.kiln.json",uE=25165824;function Lc(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=ro(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,a=t.get(s);if(a&&Nn(a)!==Nn(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>Pn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function dE(e,t=!1){let n=Lc(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Nn(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}io(e.materialResources);let r=oE.parse(e.materialResources),s=0,a=0,o=new Map;for(let d of r.records){let f=ro(d.manifest),h=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(o.has(h)||i.has(h)&&i.get(h)!==Nn(f))throw Error("Asset material closure mismatch");if(o.set(h,f),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let b of d.manifest.maps){if(d.files[b.file]?.length!==Math.ceil(b.bytes/3)*4)throw Error("Asset material map size mismatch");s+=b.bytes,a+=b.width*b.height}}if(s>Pn.maxPayloadBytes||a>Pn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let f=o.get(d);if(!f)throw Error("Asset material closure incomplete");l.add(d);for(let h of cE(f))u(`${h.resourceId}/${h.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==o.size)throw Error("Asset material closure has unrelated records")}var yN=new Set(["asset.glb","source.kiln.js","preview.png"]);function Uu(e){let t=lE.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(!yN.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>Wn||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");cp(e.files["asset.glb"]),dE(e)}function cp(e){if(e.length<20||e.length>Wn)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 lp(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){Uu(i),dE(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,a]of Object.entries(i.files))t[r+s]=a;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>uE)throw Error("Asset material payload exceeds byte limit");t[r+Dc]=s}}for(let i of Object.values(t))n+=i.length;if(n>Wn)throw Error("Bundle exceeds 64 MiB");return Pv(t,{level:0})}function fE(e){if(e.length>Wn+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,i=Ov(e,{filter:(a)=>{if(t+=a.originalSize,n++,t>Wn||n>500||a.name.endsWith(`/${Dc}`)&&a.originalSize>uE||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(a.name))throw Error("Unsafe or oversized asset bundle");return!0}}),r=[],s=new Set;for(let[a,o]of Object.entries(i)){if(!a.endsWith("/manifest.json"))continue;if(o.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=lE.parse(JSON.parse(new TextDecoder().decode(o))),l=`${c.assetId}/${c.revisionId}/`;if(a!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};s.add(a);for(let d of Object.keys(c.files)){if(!i[l+d])throw Error("Bundle file missing");u.files[d]=i[l+d],s.add(l+d)}if(i[l+Dc])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(i[l+Dc])),s.add(l+Dc);Uu(u),r.push(u)}if(!r.length||s.size!==Object.keys(i).length)throw Error("Incomplete asset bundle");return r}function hE(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)}ji();ji();var BA={type:"change"},mg={type:"start"},VA={type:"end"},Xd=new ms,zA=new yi,h8=Math.cos(70*el.DEG2RAD),bn=new j,Jn=2*Math.PI,Ot={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},pg=0.000001;class gg extends Hd{constructor(e,t=null){super(e,t);if(this.state=Ot.NONE,this.target=new j,this.cursor=new j,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:us.ROTATE,MIDDLE:us.DOLLY,RIGHT:us.PAN},this.touches={ONE:ds.ROTATE,TWO:ds.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new j,this._lastQuaternion=new ln,this._lastTargetPosition=new j,this._quat=new ln().setFromUnitVectors(e.up,new j(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new pl,this._sphericalDelta=new pl,this._scale=1,this._panOffset=new j,this._rotateStart=new Ke,this._rotateEnd=new Ke,this._rotateDelta=new Ke,this._panStart=new Ke,this._panEnd=new Ke,this._panDelta=new Ke,this._dollyStart=new Ke,this._dollyEnd=new Ke,this._dollyDelta=new Ke,this._dollyDirection=new j,this._mouse=new Ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=m8.bind(this),this._onPointerDown=p8.bind(this),this._onPointerUp=g8.bind(this),this._onContextMenu=T8.bind(this),this._onMouseWheel=y8.bind(this),this._onKeyDown=_8.bind(this),this._onTouchStart=v8.bind(this),this._onTouchMove=E8.bind(this),this._onMouseDown=b8.bind(this),this._onMouseMove=x8.bind(this),this._interceptControlDown=A8.bind(this),this._interceptControlUp=w8.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=Ot.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(BA),this.update(),this.state=Ot.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(bn.copy(t).sub(this.target),bn.applyQuaternion(this._quat),this._spherical.setFromVector3(bn),this.autoRotate&&this.state===Ot.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+=Jn;else if(n>Math.PI)n-=Jn;if(i<-Math.PI)i+=Jn;else if(i>Math.PI)i-=Jn;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(bn.setFromSpherical(this._spherical),bn.applyQuaternion(this._quatInverse),t.copy(this.target).add(bn),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let a=bn.length();s=this._clampDistance(a*this._scale);let o=a-s;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),r=!!o}else if(this.object.isOrthographicCamera){let a=new j(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=o!==this.object.zoom;let c=new j(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),s=bn.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(Xd.origin.copy(this.object.position),Xd.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Xd.direction))<h8)this.object.lookAt(this.target);else zA.setFromNormalAndCoplanarPoint(this.object.up,this.target),Xd.intersectPlane(zA,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)>pg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>pg||this._lastTargetPosition.distanceToSquared(this.target)>pg)return this.dispatchEvent(BA),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 Jn/60*this.autoRotateSpeed*e;else return Jn/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){bn.setFromMatrixColumn(t,0),bn.multiplyScalar(-e),this._panOffset.add(bn)}_panUp(e,t){if(this.screenSpacePanning===!0)bn.setFromMatrixColumn(t,1);else bn.setFromMatrixColumn(t,0),bn.crossVectors(this.object.up,bn);bn.multiplyScalar(e),this._panOffset.add(bn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;bn.copy(i).sub(this.target);let r=bn.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:a}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Jn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Jn*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(Jn*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(-Jn*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(Jn*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(-Jn*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(Jn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Jn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,a=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ke,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function p8(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 m8(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function g8(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(VA),this.state=Ot.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 b8(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 us.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=Ot.DOLLY;break;case us.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}break;case us.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(mg)}function x8(e){switch(this.state){case Ot.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case Ot.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case Ot.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function y8(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==Ot.NONE)return;e.preventDefault(),this.dispatchEvent(mg),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(VA)}function _8(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function v8(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ds.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=Ot.TOUCH_ROTATE;break;case ds.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=Ot.TOUCH_PAN;break;default:this.state=Ot.NONE}break;case 2:switch(this.touches.TWO){case ds.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=Ot.TOUCH_DOLLY_PAN;break;case ds.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=Ot.TOUCH_DOLLY_ROTATE;break;default:this.state=Ot.NONE}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(mg)}function E8(e){switch(this._trackPointer(e),this.state){case Ot.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case Ot.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case Ot.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case Ot.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=Ot.NONE}}function T8(e){if(this.enabled===!1)return;e.preventDefault()}function A8(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function w8(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}ji();class bg extends Po{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new bs;e.deleteAttribute("uv");let t=new zr({side:Dn}),n=new zr,i=new Uo(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new jt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ko(e,n,6),a=new Dt;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-0.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),s.setMatrixAt(0,a.matrix),a.position.set(-5.607,-0.754,-0.758),a.rotation.set(0,0.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),s.setMatrixAt(1,a.matrix),a.position.set(6.167,0.857,7.803),a.rotation.set(0,0.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),s.setMatrixAt(2,a.matrix),a.position.set(-2.017,0.018,6.124),a.rotation.set(0,0.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),s.setMatrixAt(3,a.matrix),a.position.set(2.291,-0.756,-2.621),a.rotation.set(0,-0.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),s.setMatrixAt(4,a.matrix),a.position.set(-2.193,-0.369,-5.547),a.rotation.set(0,0.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),s.setMatrixAt(5,a.matrix),this.add(s);let o=new jt(e,Ho(50));o.position.set(-16.116,14.37,8.208),o.scale.set(0.1,2.428,2.739),this.add(o);let c=new jt(e,Ho(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new jt(e,Ho(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new jt(e,Ho(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new jt(e,Ho(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let f=new jt(e,Ho(100));f.position.set(0,20,0),f.scale.set(1,0.1,1),this.add(f)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Ho(e){return new Dd({color:0,emissive:16777215,emissiveIntensity:e})}ji();ji();ji();function xg(e,t){if(t===Im)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===No||t===Qc){let n=e.getIndex();if(n===null){let s=[],a=e.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)s.push(o);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===No)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 jA(e){let t=new Map,n=new Map,i=e.clone();return HA(e,i,function(r,s){t.set(s,r),n.set(r,s)}),i.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,a=t.get(r),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(c){return n.get(c)}),s.bind(s.skeleton,s.bindMatrix)}),i}function HA(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)HA(e.children[i],t.children[i],n)}class wg extends jr{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ZA(t)}),this.register(function(t){return new YA(t)}),this.register(function(t){return new ow(t)}),this.register(function(t){return new cw(t)}),this.register(function(t){return new lw(t)}),this.register(function(t){return new ew(t)}),this.register(function(t){return new tw(t)}),this.register(function(t){return new nw(t)}),this.register(function(t){return new iw(t)}),this.register(function(t){return new JA(t)}),this.register(function(t){return new rw(t)}),this.register(function(t){return new QA(t)}),this.register(function(t){return new aw(t)}),this.register(function(t){return new sw(t)}),this.register(function(t){return new XA(t)}),this.register(function(t){return new Eg(t,dt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Eg(t,dt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new uw(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=Es.extractUrlBase(e);s=Es.resolveURL(c,this.path)}else s=Es.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},o=new fl(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{r.parse(c,s,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){if(this.pluginCallbacks.indexOf(e)===-1)this.pluginCallbacks.push(e);return this}unregister(e){if(this.pluginCallbacks.indexOf(e)!==-1)this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1);return this}parse(e,t,n,i){let r,s={},a={},o=new TextDecoder;if(typeof e==="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===dw){try{s[dt.KHR_BINARY_GLTF]=new fw(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[dt.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new bw(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");a[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case dt.KHR_MATERIALS_UNLIT:s[u]=new qA;break;case dt.KHR_DRACO_MESH_COMPRESSION:s[u]=new hw(r,this.dracoLoader);break;case dt.KHR_TEXTURE_TRANSFORM:s[u]=new pw;break;case dt.KHR_MESH_QUANTIZATION:s[u]=new mw;break;default:if(d.indexOf(u)>=0&&a[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function S8(){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 sn(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var dt={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 XA{constructor(e){this.parser=e,this.name=dt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new qe(16777215);if(o.color!==void 0)l.setRGB(o.color[0],o.color[1],o.color[2],ci);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new Bo(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Uo(l),c.distance=u;break;case"spot":c=new zd(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}if(c.position.set(0,0,0),xr(c,o),o.intensity!==void 0)c.intensity=o.intensity;return c.name=t.createUniqueName(o.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;if(a===void 0)return null;return this._loadLight(a).then(function(o){return n._getNodeRef(t.cache,a,o)})}}class qA{constructor(){this.name=dt.KHR_MATERIALS_UNLIT}getMaterialType(){return mr}extendParams(e,t,n){let i=[];e.color=new qe(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],ci),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,ps))}return Promise.all(i)}}class JA{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class ZA{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ke(r,r)}}return Promise.all(i)}}class YA{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class QA{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(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 ew{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_SHEEN}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],ci)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,ps));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class tw{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(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 nw{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_VOLUME}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(r[0],r[1],r[2],ci),Promise.all(i)}}class iw{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_IOR}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(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 rw{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new qe().setRGB(r[0],r[1],r[2],ci),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,ps));return Promise.all(i)}}class sw{constructor(e){this.parser=e,this.name=dt.EXT_MATERIALS_BUMP}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(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 aw{constructor(e){this.parser=e,this.name=dt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return sn(this.parser,e,this.name)!==null?di:null}extendMaterialParams(e,t){let n=sn(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 ow{constructor(e){this.parser=e,this.name=dt.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 cw{constructor(e){this.parser=e,this.name=dt.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class lw{constructor(e){this.parser=e,this.name=dt.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],a=i.images[s.source],o=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);if(c!==null)o=c}return n.loadTextureImage(e,s.source,o)}}class Eg{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(a){let o=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(a,o,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(f){return f.buffer});else return s.ready.then(function(){let f=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(f),l,u,d,i.mode,i.filter),f})})}else return null}}class uw{constructor(e){this.name=dt.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!==Ti.TRIANGLES&&c.mode!==Ti.TRIANGLE_STRIP&&c.mode!==Ti.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,a=[],o={};for(let c in s)a.push(this.parser.getDependency("accessor",s[c]).then((l)=>(o[c]=l,o[c])));if(a.length<1)return null;return a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,f=[];for(let h of u){let b=new Je,m=new j,g=new ln,p=new j(1,1,1),x=new ko(h.geometry,h.material,d);for(let y=0;y<d;y++){if(o.TRANSLATION)m.fromBufferAttribute(o.TRANSLATION,y);if(o.ROTATION)g.fromBufferAttribute(o.ROTATION,y);if(o.SCALE)p.fromBufferAttribute(o.SCALE,y);x.setMatrixAt(y,b.compose(m,g,p))}let _=null;for(let y in o)if(y==="_COLOR_0"){let v=o[y];x.instanceColor=new ls(v.array,v.itemSize,v.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(_===null){let E=x.geometry;_=new Ln,_.name=E.name;for(let w in E.attributes)_.setAttribute(w,E.attributes[w]);for(let w in E.morphAttributes)_.morphAttributes[w]=E.morphAttributes[w];if(E.index!==null)_.setIndex(E.index);_.morphTargetsRelative=E.morphTargetsRelative;for(let w of E.groups)_.addGroup(w.start,w.count,w.materialIndex);if(E.boundingBox!==null)_.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)_.boundingSphere=E.boundingSphere.clone();_.drawRange.start=E.drawRange.start,_.drawRange.count=E.drawRange.count,_.userData=Object.assign({},E.userData),x.geometry=_}let v=o[y];_.setAttribute(y,new ls(v.array,v.itemSize,v.normalized))}Dt.prototype.copy.call(x,h),this.parser.assignFinalMaterial(x),f.push(x)}if(l.isGroup)return l.clear(),l.add(...f),l;return f[0]})}}var dw="glTF",_l=12,GA={JSON:1313821514,BIN:5130562};class fw{constructor(e){this.name=dt.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,_l),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!==dw)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-_l,r=new DataView(e,_l),s=0;while(s<i){let a=r.getUint32(s,!0);s+=4;let o=r.getUint32(s,!0);if(s+=4,o===GA.JSON){let c=new Uint8Array(e,_l+s,a);this.content=n.decode(c)}else if(o===GA.BIN){let c=_l+s;this.body=e.slice(c,c+a)}s+=a}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class hw{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=dt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},o={},c={};for(let l in s){let u=Tg[l]||l.toLowerCase();a[u]=s[l]}for(let l in e.attributes){let u=Tg[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],f=Go[d.componentType];c[u]=f.name,o[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(f){for(let h in f.attributes){let b=f.attributes[h],m=o[h];if(m!==void 0)b.normalized=m}u(f)},a,c,ci,d)})})}}class pw{constructor(){this.name=dt.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 mw{constructor(){this.name=dt.KHR_MESH_QUANTIZATION}}class Sg extends Vr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,l=i-t,u=(n-t)/l,d=u*u,f=d*u,h=e*c,b=h-c,m=-2*f+3*d,g=f-d,p=1-m,x=g-d+u;for(let _=0;_!==a;_++){let y=s[b+_+a],v=s[b+_+o]*l,E=s[h+_+a],w=s[h+_]*l;r[_]=p*y+x*v+m*E+g*w}return r}}var M8=new ln;class gw extends Sg{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return M8.fromArray(r).normalize().toArray(r),r}}var Ti={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},Go={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},$A={9728:Bi,9729:Tn,9984:gd,9985:Io,9986:Ea,9987:fr},KA={33071:Ro,33648:md,10497:Mo},yg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tg={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"},Ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},R8={CUBICSPLINE:void 0,LINEAR:Td,STEP:Rm},_g={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function I8(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new zr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:fs});return e.DefaultMaterial}function Pa(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 xr(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 C8(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let a=[],o=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let f=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;a.push(f)}if(r){let f=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(f)}if(s){let f=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(f)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],f=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=f;return e.morphTargetsRelative=!0,e})}function N8(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 P8(e){let t,n=e.extensions&&e.extensions[dt.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+vg(n.attributes);else t=e.indices+":"+vg(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+vg(e.targets[i]);return t}function vg(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 Ag(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 O8(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 k8=new Je;class bw{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new S8,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);i=n&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Lo(this.options.manager);else this.textureLoader=new Vd(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new fl(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Pa(r,a,i),xr(a,i),Promise.all(n._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let a=0,o=s.length;a<o;a++)e[s[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,a)=>{let o=this.associations.get(s);if(o!=null)this.associations.set(a,o);for(let[c,l]of s.children.entries())r(l,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[dt.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(Es.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=yg[i.type],a=Go[i.componentType],o=i.normalized===!0,c=new a(i.count*s);return Promise.resolve(new En(c,s,o))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let a=s[0],o=yg[i.type],c=Go[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,h=i.normalized===!0,b,m;if(f&&f!==u){let g=Math.floor(d/f),p="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+g+":"+i.count,x=t.cache.get(p);if(!x)b=new c(a,g*f,i.count*f/l),x=new il(b,f/l),t.cache.add(p,x);m=new Oo(x,o,d%f/l,h)}else{if(a===null)b=new c(i.count*o);else b=new c(a,d,i.count*o);m=new En(b,o,h)}if(i.sparse!==void 0){let g=yg.SCALAR,p=Go[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,y=new p(s[1],x,i.sparse.count*g),v=new c(s[2],_,i.sparse.count*o);if(a!==null)m=new En(m.array.slice(),m.itemSize,m.normalized);m.normalized=!1;for(let E=0,w=y.length;E<w;E++){let T=y[E];if(m.setX(T,v[E*o]),o>=2)m.setY(T,v[E*o+1]);if(o>=3)m.setZ(T,v[E*o+2]);if(o>=4)m.setW(T,v[E*o+3]);if(o>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=h}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],a=this.textureLoader;if(s.uri){let o=n.manager.getHandler(s.uri);if(o!==null)a=o}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri==="string"&&a.uri.startsWith("data:image/")===!1)l.name=a.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=$A[d.magFilter]||Tn,l.minFilter=$A[d.minFilter]||fr,l.wrapS=KA[d.wrapS]||Mo,l.wrapT=KA[d.wrapT]||Mo,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Bi&&l.minFilter!==Tn,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],a=self.URL||self.webkitURL,o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(d,f){let h=d;if(t.isImageBitmapLoader===!0)h=function(b){let m=new en(b);m.needsUpdate=!0,d(m)};t.load(Es.resolveURL(u,r.path),h,void 0,f)})}).then(function(u){if(c===!0)a.revokeObjectURL(o);return xr(u,s),u.userData.mimeType=s.mimeType||O8(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[dt.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[dt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=r.associations.get(s);s=r.extensions[dt.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new ll,qn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,o.sizeAttenuation=!1,this.cache.add(a,o);n=o}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,o=this.cache.get(a);if(!o)o=new cl,qn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,this.cache.add(a,o);n=o}if(i||r||s){let a="ClonedMaterial:"+n.uuid+":";if(i)a+="derivative-tangents:";if(r)a+="vertex-colors:";if(s)a+="flat-shading:";let o=this.cache.get(a);if(!o){if(o=n.clone(),r)o.vertexColors=!0;if(s)o.flatShading=!0;if(i){if(o.normalScale)o.normalScale.y*=-1;if(o.clearcoatNormalScale)o.clearcoatNormalScale.y*=-1}this.cache.add(a,o),this.associations.set(o,this.associations.get(n))}n=o}e.material=n}getMaterialType(){return zr}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,a={},o=r.extensions||{},c=[];if(o[dt.KHR_MATERIALS_UNLIT]){let u=i[dt.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new qe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],ci),a.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(a,"map",u.baseColorTexture,ps));if(a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}if(r.doubleSided===!0)a.side=vi;let l=r.alphaMode||_g.OPAQUE;if(l===_g.BLEND)a.transparent=!0,a.depthWrite=!1;else if(a.transparent=!1,l===_g.MASK)a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==mr){if(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ke(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;a.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==mr){if(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)a.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==mr){let u=r.emissiveFactor;a.emissive=new qe().setRGB(u[0],u[1],u[2],ci)}if(r.emissiveTexture!==void 0&&s!==mr)c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,ps));return Promise.all(c).then(function(){let u=new s(a);if(r.name)u.name=r.name;if(xr(u,r),t.associations.set(u,{materials:e}),r.extensions)Pa(i,u,r);return u})}createUniqueName(e){let t=Tt.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[dt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return WA(o,a,t)})}let s=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=P8(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[dt.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=WA(new Ln,c,t);if(c.mode===Ti.TRIANGLE_STRIP)d=d.then((f)=>xg(f,Qc));else if(c.mode===Ti.TRIANGLE_FAN)d=d.then((f)=>xg(f,No));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,a=[];for(let o=0,c=s.length;o<c;o++){let l=s[o].material===void 0?I8(this.cache):this.getDependency("material",s[o].material);a.push(l)}return a.push(t.loadGeometries(s)),Promise.all(a).then(async function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let f=0,h=l.length;f<h;f++){let b=l[f],m=s[f],g,p=c[f];if(m.mode===Ti.TRIANGLES||m.mode===Ti.TRIANGLE_STRIP||m.mode===Ti.TRIANGLE_FAN||m.mode===void 0){let x=r.isSkinnedMesh===!0,_=b.hasAttribute("skinIndex")&&b.hasAttribute("skinWeight");if(x&&_===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(g=x&&_?new Cd(b,p):new jt(b,p),g.isSkinnedMesh===!0)g.normalizeSkinWeights()}else if(m.mode===Ti.LINES)g=new Nd(b,p);else if(m.mode===Ti.LINE_STRIP)g=new gs(b,p);else if(m.mode===Ti.LINE_LOOP)g=new Pd(b,p);else if(m.mode===Ti.POINTS)g=new Do(b,p);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);if(Object.keys(g.geometry.morphAttributes).length>0)N8(g,r);if(g.name=t.createUniqueName(r.name||"mesh_"+e),xr(g,r),m.extensions)Pa(i,g,m);t.assignFinalMaterial(g),u.push(g)}for(let f=0,h=u.length;f<h;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1){if(r.extensions)Pa(i,u[0],r);return u[0]}let d=new cr;if(r.extensions)Pa(i,d,r);t.associations.set(d,{meshes:e});for(let f=0,h=u.length;f<h;f++)d.add(u[f]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new hn(el.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new Ca(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return xr(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,a=[],o=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){a.push(u);let d=new Je;if(r!==null)d.fromArray(r.array,c*16);o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new al(a,o)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],a=[],o=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let f=i.channels[u],h=i.samplers[f.sampler],b=f.target,m=b.node,g=i.parameters!==void 0?i.parameters[h.input]:h.input,p=i.parameters!==void 0?i.parameters[h.output]:h.output;if(b.node===void 0)continue;s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",g)),o.push(this.getDependency("accessor",p)),c.push(h),l.push(b)}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=[];for(let x=0,_=d.length;x<_;x++){let y=d[x],v=f[x],E=h[x],w=b[x],T=m[x];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let A=n._createAnimationTracks(y,v,E,w,T);if(A)for(let P=0;P<A.length;P++)g.push(A[P])}let p=new To(r,void 0,g);return xr(p,i),p})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(a){if(!a.isMesh)return;for(let o=0,c=i.weights.length;o<c;o++)a.morphTargetInfluences[o]=i.weights[o]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],a=i.children||[];for(let c=0,l=a.length;c<l;c++)s.push(n.getDependency("node",a[c]));let o=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),o]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(f){if(!f.isSkinnedMesh)return;f.bind(d,k8)});for(let f=0,h=u.length;f<h;f++)l.add(u[f]);if(l.userData.pivot!==void 0&&u.length>0){let f=l.userData.pivot,h=u[0];l.pivot=new j().fromArray(f),l.position.x-=f[0],l.position.y-=f[1],l.position.z-=f[2],h.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",a=[],o=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(o)a.push(o);if(r.camera!==void 0)a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0)l=new rl;else if(c.length>1)l=new cr;else if(c.length===1)l=c[0];else l=new Dt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(xr(l,r),r.extensions)Pa(n,l,r);if(r.matrix!==void 0){let u=new Je;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 cr;if(n.name)r.name=i.createUniqueName(n.name);if(xr(r,n),n.extensions)Pa(t,r,n);let s=n.nodes||[],a=[];for(let o=0,c=s.length;o<c;o++)a.push(i.getDependency("node",s[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++){let d=o[l];if(d.parent!==null)r.add(jA(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,f]of i.associations)if(d instanceof qn||d instanceof en)u.set(d,f);return l.traverse((d)=>{let f=i.associations.get(d);if(f!=null)u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],a=e.name?e.name:e.uuid,o=[];function c(f){if(f.morphTargetInfluences)o.push(f.name?f.name:f.uuid)}if(Ts[r.path]===Ts.weights){if(c(e),e.isGroup)e.children.forEach(c)}else o.push(a);let l;switch(Ts[r.path]){case Ts.weights:l=ys;break;case Ts.rotation:l=_s;break;case Ts.translation:case Ts.scale:l=Ia;break;default:switch(n.itemSize){case 1:l=ys;break;case 2:case 3:default:l=Ia;break}break}let u=i.interpolation!==void 0?R8[i.interpolation]:Td,d=this._getArrayFromAccessor(n);for(let f=0,h=o.length;f<h;f++){let b=new l(o[f]+"."+Ts[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(b);s.push(b)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Ag(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 _s?gw:Sg)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function D8(e,t,n){let i=t.attributes,r=new pn;if(i.POSITION!==void 0){let o=n.json.accessors[i.POSITION],{min:c,max:l}=o;if(c!==void 0&&l!==void 0){if(r.set(new j(c[0],c[1],c[2]),new j(l[0],l[1],l[2])),o.normalized){let u=Ag(Go[o.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let o=new j,c=new j;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let f=n.json.accessors[d.POSITION],{min:h,max:b}=f;if(h!==void 0&&b!==void 0){if(c.setX(Math.max(Math.abs(h[0]),Math.abs(b[0]))),c.setY(Math.max(Math.abs(h[1]),Math.abs(b[1]))),c.setZ(Math.max(Math.abs(h[2]),Math.abs(b[2]))),f.normalized){let m=Ag(Go[f.componentType]);c.multiplyScalar(m)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}e.boundingBox=r;let a=new ui;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=a}function WA(e,t,n){let i=t.attributes,r=[];function s(a,o){return n.getDependency("accessor",a).then(function(c){e.setAttribute(o,c)})}for(let a in i){let o=Tg[a]||a.toLowerCase();if(o in e.attributes)continue;r.push(s(i[a],o))}if(t.indices!==void 0&&!e.index){let a=n.getDependency("accessor",t.indices).then(function(o){e.setIndex(o)});r.push(a)}if(ot.workingColorSpace!==ci&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ot.workingColorSpace}" not supported.`);return xr(e,t),D8(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?C8(e,t.targets,n):e})}function yr(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let a of Array.isArray(s.material)?s.material:[s.material]){n.add(a);for(let o of Object.values(a))if(o instanceof en)i.add(o)}});for(let r of[...t,...n,...i])r.dispose()}async function xw(e){cp(e);let t=new dl,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Lo(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new wg(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let a of s.json.images??[]){if(a.bufferView===void 0)continue;let o=new Uint8Array(await s.getDependency("bufferView",a.bufferView)),c="";for(let l=0;l<o.length;l+=8192)c+=String.fromCharCode(...o.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(a.mimeType??""))throw Error("Unsupported embedded image type");a.uri=`data:${a.mimeType};base64,${btoa(c)}`,delete a.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)yr(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}ji();function yw(e,t,n=40,i=[e]){let r=e.getCenter(new j),s=Math.max(e.getSize(new j).length()/2,0.01),a=new j(1,0.65,1.25).normalize(),o=new j().crossVectors(new j(0,1,0),a).normalize(),c=new j().crossVectors(a,o),l=[];for(let x of i.length?i:[e])for(let _ of[x.min.x,x.max.x])for(let y of[x.min.y,x.max.y])for(let v of[x.min.z,x.max.z])l.push(new j(_,y,v));let u=1/0,d=-1/0,f=1/0,h=-1/0;for(let x of l){let _=x.clone().sub(r),y=_.dot(o),v=_.dot(c);u=Math.min(u,y),d=Math.max(d,y),f=Math.min(f,v),h=Math.max(h,v)}r.addScaledVector(o,(u+d)/2),r.addScaledVector(c,(f+h)/2);let b=Math.tan(n*Math.PI/360),m=b*t,g=s;for(let x of l){let _=x.clone().sub(r),y=_.dot(a);g=Math.max(g,y+Math.abs(_.dot(o))*1.12/m,y+Math.abs(_.dot(c))*1.12/b)}let p=r.clone().addScaledVector(a,g);return{center:r,radius:s,distance:g,position:p}}ji();function Mg(e,t){return{position:e.position.clone(),target:t.clone()}}function Rg(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new j).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new j))+r*20,10),e.updateProjectionMatrix()}function _w(e,t,n){let i=e.getWorldDirection(new j);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new j(0,1,0)),s=new j;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function vw(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function Ew(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let i=JSON.stringify(n),r=await e();if(JSON.stringify(t())!==i)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...r,artifact:n}}function Tw(e,t,n){if(t())return e;n(e);return}ji();function qd(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,a)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(a)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((a)=>{let o=e.parser.associations.get(a)?.nodes;if(o===void 0||!i.has(o))return;a.visible=!1,r++});return r}function Jd(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new pn().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new pn,i=new pn,r=new j;return e.traverseVisible((s)=>{let a=s,o=a.geometry;if(!o)return;let c=o.getAttribute("position");if(c&&a.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(a.isMesh)a.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(o.boundingBox===null)o.computeBoundingBox();i.copy(o.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new pn().setFromObject(e,!0):n}function vl(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Aw(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((b)=>!Number.isInteger(b)||!t[b]||n.has(b)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let f=[l];for(let b of u)f.push(await e.parser.getDependency("node",b));qd(e,f.slice(1)),i.add(l);let h=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:h,levels:f})}if(r.length===0)return;let s=vl(e.scene)-r.reduce((c,l)=>c+Ig(l,0),0),a=Math.max(...r.map((c)=>c.levels.length)),o=Array.from({length:a},(c,l)=>s+r.reduce((u,d)=>u+Ig(d,l),0));return{chains:r,triangles:o}}var ww=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function Ig(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return vl(ww(e,t))}function Sw(e,t){let n=ww(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Mw(e,t){for(let n of e.chains)Sw(n,t)}function Rw(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return Sw(i,n),!0}function Iw(e,t){if(!e)return;return{triangles:vl(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>Ig(n,r))}))}}function $o(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function Cg(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function El(e){let t=new fg({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=Jc,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Po,i=new hn(40,1,0.01,1000),r=new gg(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,a=!1,o=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(O)=>{if(!a||!c.has(O.code))return;O.preventDefault(),s.add(O.code)},u=(O)=>s.delete(O.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let f=new yl(t),h=new bg,b=f.fromScene(h,0.04);n.environment=b.texture,h.dispose(),f.dispose();let m=new Bo(16773591,2.4);m.position.set(4,8,5),n.add(m),n.add(new Ud(14806490,5065021,1.7));let g,p,x,_=[],y=!0,v=performance.now(),E=0,w=0,T=!1,A,P,S,R=(O)=>{if(!S)return;clearTimeout(S.timeout),S.reject(Error(O)),S=void 0},k=(O)=>{let K=t.getContext(),B=K.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:O-S.started,frameMs:vw(S.samples),...P===void 0?{}:{loadToFirstFrameMs:P},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(K.getParameter(K.VERSION)),vendor:String(K.getParameter(K.VENDOR)),renderer:String(K.getParameter(K.RENDERER)),browser:navigator.userAgent,...B?{unmaskedVendor:String(K.getParameter(B.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(K.getParameter(B.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},C=()=>{if(!g)return;let O=Jd(g),K=[];g.traverseVisible((de)=>{if(de instanceof jt||de instanceof gs||de instanceof Do){let Me=new pn().setFromObject(de,!0);if(!Me.isEmpty())K.push(Me)}});let{center:B,radius:X,distance:q,position:le}=yw(O,i.aspect,i.fov,K);if(r.target.copy(B),i.position.copy(le),i.near=Math.max(X/1000,0.0001),i.far=q+X*100,r.minDistance=X*0.1,r.maxDistance=X*80,o=Math.max(X*0.35,0.01),a)r.minDistance=X*0.00001;i.updateProjectionMatrix(),r.update()},U=new ResizeObserver(()=>{let{clientWidth:O,clientHeight:K}=e;if(!O||!K)return;t.setSize(O,K),i.aspect=O/K,i.updateProjectionMatrix()});U.observe(e);let L=(O)=>{if(T)return;let K=Math.min((O-v)/1000,0.1);if(v=O,e.clientWidth&&e.clientHeight){if(y)x?.update(K);if(a&&s.size){let B=_w(i,s,K*o*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(B),r.target.add(B)}if(r.update(),t.render(n,i),A!==void 0)P=performance.now()-A,A=void 0;if(S){if(S.previous>0&&S.samples.length<1800)S.samples.push(O-S.previous);if(S.previous=O,O-S.started>=S.duration&&S.samples.length){let B=k(O);clearTimeout(S.timeout),S.resolve(B),S=void 0}}}else s.clear(),R("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(L)};return E=requestAnimationFrame(L),{async load(O,K={}){let B=performance.now(),X=++w;R("The artifact changed during measurement. Measure the new revision again.");let q=await xw(O);qd(q,[q.scene]);let le=await Aw(q);try{q.assertTexturesLoaded()}catch(ne){yr(q.scene);for(let ie of $o(le))yr(ie);throw ne}let de=Tw(q,()=>!T&&X===w&&K.isCurrent?.()!==!1,(ne)=>{yr(ne.scene);for(let ie of $o(le))yr(ie)});if(!de)return;let Me=g&&K.preserveView?Mg(i,r.target):void 0;if(g){x?.stopAllAction(),x?.uncacheRoot(g),n.remove(g),yr(g);for(let ne of $o(p))yr(ne)}g=de.scene,p=le,A=B,P=void 0,n.add(g),_=de.animations,x=new jd(g),y=!0;let{clientWidth:pe,clientHeight:J}=e;if(t.setSize(pe,J),i.aspect=pe&&J?pe/J:i.aspect,C(),Me)Rg(i,r.target,Me,Jd(g)),r.update();let F=0,W=new Set;return g.traverseVisible((ne)=>{let ie=ne;if(!ie.isMesh)return;F++;for(let ce of Array.isArray(ie.material)?ie.material:[ie.material])W.add(ce)}),K.onCommit?.(),{triangles:vl(g),meshes:F,materials:W.size,clips:_.map((ne)=>ne.name),...p?{levels:p.triangles}:{}}},level(O){if(R("The level of detail changed. Measure the displayed combination again."),p)Mw(p,O)},partLevel(O,K){if(R("The level of detail changed. Measure the displayed combination again."),p)Rw(p,O,K)},lod(){return g?Iw(p,g):void 0},reset:C,cancelMeasurement:R,measure(O=3000){if(T||!g||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(O)||O<1000||O>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(S)return Promise.reject(Error("A measurement is already running."));return new Promise((K,B)=>{S={started:performance.now(),previous:0,duration:O,samples:[],resolve:K,reject:B,timeout:setTimeout(()=>R("Measurement was interrupted or the browser stopped delivering frames."),O+2000)}})},view(){return Mg(i,r.target)},setView(O){if(!g)return;Rg(i,r.target,O,Jd(g)),r.update()},navigation(O){if(a=O==="explore",s.clear(),r.minDistance=a?0.00001:o/3.5,a)i.near=0.0001,i.updateProjectionMatrix()},wire(O){for(let K of g?[g,...$o(p)]:[])K.traverse((B)=>{let X=B;if(X.isMesh){for(let q of Array.isArray(X.material)?X.material:[X.material])if("wireframe"in q)q.wireframe=O}})},lighting(O){t.toneMappingExposure=O==="bright"?1.65:O==="soft"?0.85:1.15,m.intensity=O==="soft"?0.8:2.4},clip(O){if(x?.stopAllAction(),_[O])x?.clipAction(_[O]).play()},pause(O){y=!O},dispose(){if(R("The viewport closed before measurement finished."),T=!0,w++,cancelAnimationFrame(E),U.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),g)yr(g);for(let O of $o(p))yr(O);b.dispose(),t.dispose(),e.replaceChildren()}}}var ue=(e)=>document.getElementById(e);function D(e,t,n){let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i}function In(e){let t=ue("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function un(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),i=await n.json();if(!n.ok)throw Error(i.error??`Request failed (${n.status})`);return i}function Ko(e,t){let n=D("div",void 0,"empty");return n.append(D("b",e),D("p",t)),n}function Hi(e,t){try{localStorage.setItem(e,t)}catch{}}function As(e){try{return localStorage.getItem(e)}catch{return null}}function An(e){return e?e.slice(0,15):"Unspecified"}function Wo(e,t){let n=D("details",void 0,"record-details");return n.append(D("summary",e),D("pre",JSON.stringify(t,null,2))),n}function Tl(e,t,n,i){let r=n.lod();if(e.hidden=!r,t.hidden=!r,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!r)return;e.append(...Cg(r.levels).map((l,u)=>new Option(l,String(u))));let s=new Option("Mixed part levels","mixed");s.disabled=!0,e.append(s);let a=D("p","","lod-total");a.setAttribute("role","status"),t.append(a);let o=new Map;if(r.chains.length>1){let l=D("details",void 0,"lod-parts");l.append(D("summary","Per-part levels")),l.append(D("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=D("div",void 0,"lod-part-fields"),d=new Set(r.chains.filter((f,h,b)=>b.findIndex((m)=>m.label===f.label)!==h).map((f)=>f.label));for(let[f,h]of r.chains.entries()){let b=d.has(h.label)?`${h.label} (part ${f+1})`:h.label,m=D("label",b,"inline-field"),g=D("select");g.setAttribute("aria-label",`${b} level of detail`),g.append(...Cg(h.triangles).map((p,x)=>new Option(p,String(x)))),g.onchange=()=>{n.partLevel(h.id,Number(g.value)),c(),i?.()},o.set(h.id,g),m.append(g),u.append(m)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((d,f)=>l.chains.every((h)=>h.level===Math.min(f,h.triangles.length-1)));e.value=u<0?"mixed":String(u),a.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let d of l.chains){let f=o.get(d.id);if(f)f.value=String(d.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),i?.(l)},c(),{refresh:c}}var Cw=/^[a-z][a-z0-9_-]{0,79}$/u,L8=/^r_[a-z0-9_-]{1,77}$/u;function Nw(e){let t=new URLSearchParams(e),n=t.get("collection"),i=t.get("asset"),r=t.get("revision");if(!n||!i||!r||!Cw.test(n)||!Cw.test(i)||!L8.test(r))return;return{collection:n,assetId:i,revisionId:r}}Pg();var fb=new TextEncoder,SB=new TextDecoder,ec=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),db=(e,t)=>Object.hasOwn(e,t);async function wR(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function MB(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}function RB(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("External texture output must be a portable sibling *.gltf filename")}function IB(e,t){if(t+8>e.length)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(t+4,!0)!==5130562)return;return e.subarray(t+8,t+8+n.getUint32(t,!0))}function CB(e){let t=new Map;for(let i of[...Lc(e),...(e.materialResources?.records??[]).map(({manifest:r})=>r)])t.set(`${i.materialId}/${i.revisionId}`,i);let n=(i,r)=>i<r?-1:i>r?1:0;return[...t.values()].flatMap((i)=>i.maps.map((r)=>({sha256:r.sha256,pin:{resourceId:i.materialId,revisionId:i.revisionId,sha256:i.revisionId},slot:r.slot}))).sort((i,r)=>n(i.pin.resourceId,r.pin.resourceId)||n(i.pin.revisionId,r.pin.revisionId)||n(i.slot,r.slot))}function SR(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=12;while(n<e.length){if(n+8>e.length)throw Error("Invalid GLB chunk header");let s=t.getUint32(n,!0);if(s%4||n+8+s>e.length)throw Error("Invalid GLB chunk length");n+=8+s}let i=20+t.getUint32(12,!0),r=JSON.parse(SB.decode(e.subarray(20,i)));if(!ec(r)||!ec(r.asset)||r.asset.version!=="2.0")throw Error("Invalid glTF asset");return{json:r,jsonEnd:i}}function MR(e,t,n){let i=fb.encode(JSON.stringify(n)),r=Math.ceil(i.length/4)*4,s=new Uint8Array(20+r+e.length-t);if(s.length>Wn)throw Error("Runtime export exceeds 64 MiB");s.set(e.subarray(0,20));let a=new DataView(s.buffer);return a.setUint32(8,s.length,!0),a.setUint32(12,r,!0),s.fill(32,20,20+r),s.set(i,20),s.set(e.subarray(t),20+r),s}async function NB(e,t,n={}){let[{deliverRuntimeThreeGlb:i},{MeshoptEncoder:r}]=await Promise.all([Promise.resolve().then(() => (xR(),bR)),Promise.resolve().then(() => (AR(),TR))]);await r.ready;let s=await i(e,r,t,n);if(s.glb.byteLength>Wn)throw Error("Runtime export exceeds 64 MiB");return s}async function RR(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");if(t.target!==void 0&&t.target!=="three")throw Error("Unknown runtime export target");if(t.target!==void 0&&n!=="runtime")throw Error("A runtime export target requires the runtime profile");if(t.compression!==void 0&&t.target!=="three")throw Error("Runtime compression requires the three runtime target");if(t.maxLod!==void 0&&t.target!=="three")throw Error("Runtime maxLod requires the three runtime target");if(t.positionBits!==void 0&&t.target!=="three")throw Error("Runtime positionBits requires the three runtime target");let i=t.textures;if(i!==void 0&&i!=="manifest"&&i!=="external")throw Error("Unknown runtime texture option");if(i!==void 0&&n!=="runtime")throw Error("A texture manifest requires the runtime profile");if(i==="external"&&t.target!=="three")throw Error("External textures require target three");let r=t.gltfFileName??"runtime.gltf";if(i==="external")RB(r);Uu(e);let s=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:s};let a=t.metadataFileName??"runtime.kiln-metadata.json";MB(a);for(let[A,P]of Object.entries(e.files))if(await wR(P)!==e.manifest.files[A].sha256)throw Error(`Asset integrity mismatch: ${A}`);let{json:o,jsonEnd:c}=SR(s),l=o.asset;if(db(l,"extras")&&!ec(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(db(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let d=[];if(o.scenes!==void 0&&!Array.isArray(o.scenes))throw Error("Invalid glTF scenes");for(let[A,P]of(o.scenes??[]).entries()){if(!ec(P)||!ec(P.extras)||!db(P.extras,"kilnReviewClipsV1"))continue;let S=P.extras.kilnReviewClipsV1;if(!ec(S)||S.version!==1&&S.version!==2||!Array.isArray(S.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");d.push({index:A,kilnReviewClipsV1:S}),delete P.extras.kilnReviewClipsV1}let f={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:d},h=s,b=o,m=c,g,p;if(t.target==="three"){let A=await NB(MR(s,c,o),{...t.ktx2Encoder?{ktx2Encoder:t.ktx2Encoder}:{},...t.compression?{compression:t.compression}:{},...t.maxLod!==void 0?{maxLod:t.maxLod}:{},...t.positionBits!==void 0?{positionBits:t.positionBits}:{}},i==="external"?{gltfBasename:r.slice(0,-5)}:{});f.target="three",f.delivery=A.delivery,h=A.glb,g=A.imageSources,p=A.gltf,{json:b,jsonEnd:m}=SR(h)}if(i!==void 0)f.textures=await Pw(b,IB(h,m),{...g?{sources:g}:{},maps:CB(e)});let x=p?await PB(p,f.textures??[]):void 0,_=fb.encode(JSON.stringify(f));if(_.length>Wn)throw Error("Runtime export exceeds 64 MiB");let y={version:"kiln.provenance.v1",profile:"runtime",...t.target?{target:t.target}:{},metadata:{uri:a,sha256:await wR(_)}},v=b.asset;v.extras={...v.extras??u,kilnProvenanceV1:y};let E=MR(h,m,b);if(!x)return{profile:n,glb:E,metadata:{name:a,bytes:_}};let w=x.json.asset;w.extras={...w.extras??u,kilnProvenanceV1:y};let T=fb.encode(JSON.stringify(x.json));if(T.length>Wn)throw Error("Runtime export exceeds 64 MiB");return{profile:n,layout:"gltf",glb:E,gltf:{name:r,bytes:T},buffers:x.buffers,textures:x.textures,metadata:{name:a,bytes:_}}}async function PB(e,t){let n=structuredClone(e.json),i=new Map(Object.entries(e.resources)),r=Array.isArray(n.images)?n.images:[];if(r.length!==t.length)throw Error("External texture layout mismatch");let s=new Map;for(let[o,c]of r.entries()){let l=t[o],u=typeof c.uri==="string"?c.uri:"",d=i.get(u);if(!d||`sha256:${await Al(d)}`!==l.sha256)throw Error("External texture bytes differ from the delivered GLB");i.delete(u);let f=`textures/${l.sha256.slice(7)}.${Ow(l.mimeType)}`;c.uri=f,l.uri=f,s.set(f,{uri:f,sha256:l.sha256,bytes:d})}let a=[...i].map(([o,c])=>({uri:o,bytes:c}));for(let{uri:o}of a)if(!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(o))throw Error(`Unexpected external glTF resource ${o}`);return{json:n,buffers:a,textures:[...s.values()]}}var Wi=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),hb=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),NR=Fe().regex(/^sha256:[a-f0-9]{64}$/),tc=Fe().max(4000),PR=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),IR=be({collectionId:Wi,assetId:Wi,revisionId:Wi}).strict(),CR=be({style:tc.default(""),scale:Fe().max(1000).default(""),palette:at(be({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:at(be({role:Fe().min(1).max(100),description:tc.default(""),resourceId:PR.optional()}).strict()).max(128).default([]),conventions:at(Fe().max(1000)).max(100).default([]),exceptions:at(Fe().max(1000)).max(100).default([])}).strict(),OB=be({resourceId:PR,revisionId:Fe().min(1).max(200),sha256:NR,role:Fe().max(100).optional()}).strict(),kB=at(OB).max(512),vr={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:CR.default(()=>CR.parse({})),inventory:at(be({id:Wi,name:Fe().trim().min(1).max(200),kind:Ct(["asset","environment"]).default("asset"),brief:tc.default(""),references:at(Wi).max(64).default([]),asset:IR.optional()}).strict()).max(1000).default([]),deliveryProfiles:at(be({id:Wi,target:Ct(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:tc.default(""),performanceIntent:Fe().max(1000).default(""),constraints:at(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:kB.default([]),references:at(be({id:Wi,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:tc.default(""),sha256:NR.optional()}).strict()).max(256).default([]),reviews:at(be({id:Wi,inventoryId:Wi,projectRevisionId:hb,asset:IR,reviewer:Fe().trim().min(1).max(200),verdict:Ct(["comment","changes-requested","accepted"]),notes:tc}).strict()).max(2000).default([])};function OR(e,t){let n=(a,o)=>{if(new Set(a).size!==a.length)t.addIssue({code:vu.custom,path:[o],message:"Duplicate identity"})};n(e.inventory.map((a)=>a.id),"inventory"),n(e.references.map((a)=>a.id),"references"),n(e.deliveryProfiles.map((a)=>a.id),"deliveryProfiles"),n(e.materialDependencies.map((a)=>a.resourceId),"materialDependencies"),n(e.reviews.map((a)=>a.id),"reviews"),n(e.design.palette.map((a)=>a.role),"design.palette"),n(e.design.materialRoles.map((a)=>a.role),"design.materialRoles");let i=new Set(e.references.map((a)=>a.id)),r=new Set(e.inventory.map((a)=>a.id)),s=new Set(e.materialDependencies.map((a)=>a.resourceId));for(let a of e.inventory)if(n(a.references,`inventory.${a.id}.references`),a.references.some((o)=>!i.has(o)))t.addIssue({code:vu.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((a)=>!r.has(a.inventoryId)))t.addIssue({code:vu.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((a)=>a.resourceId&&!s.has(a.resourceId)))t.addIssue({code:vu.custom,path:["design"],message:"Material role requires a locked resource"})}var kR=be({projectId:Wi.optional(),...vr}).strict().superRefine(OR),CX=be({name:vr.name.optional(),brief:vr.brief.removeDefault().optional(),design:vr.design.removeDefault().optional(),inventory:vr.inventory.removeDefault().optional(),deliveryProfiles:vr.deliveryProfiles.removeDefault().optional(),materialDependencies:vr.materialDependencies.removeDefault().optional(),references:vr.references.removeDefault().optional(),reviews:vr.reviews.removeDefault().optional()}).strict(),NX=be({version:$e("kiln.project.v1"),projectId:Wi,revisionId:hb,parentRevision:hb.optional(),createdAt:Fe().datetime(),...vr}).strict().superRefine(OR);function DR(e){let{palette:t,materialRoles:n,conventions:i,exceptions:r}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:i??[],exceptions:r??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function LR(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let i=n,r=i.design??{};if(!r||typeof r!=="object"||Array.isArray(r))throw Error("Design configuration must be a JSON object.");return kR.parse({...i,name:t.name,brief:t.brief,design:{...r,style:t.style,scale:t.scale}})}function FR(e){let t=[],n=As("kiln.project")??"",i,r=()=>{let c=ue("project-list");c.replaceChildren();for(let _ of t){let y=D("button",void 0,_.projectId===n?"active":"");if(y.append(D("strong",_.name),D("small",`${_.inventory.length} inventory items · ${_.materialDependencies.length} resources`)),_.projectId===n)y.setAttribute("aria-current","true");y.onclick=()=>{n=_.projectId,Hi("kiln.project",n),r()},c.append(y)}let l=t.find((_)=>_.projectId===n),u=ue("project-detail");if(u.replaceChildren(),!l){u.append(Ko("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let d=D("div",void 0,"project-summary"),f=D("div");f.append(D("h2",l.name),D("p",l.brief||"Add a brief to describe what this project should deliver."));let h=D("button","Edit project","secondary");h.onclick=()=>a(l),d.append(f,h),u.append(d);let b=D("p",`${l.projectId} · ${An(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(b);let m=D("div",void 0,"project-metrics");for(let[_,y]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let v=D("div");v.append(D("strong",String(_)),D("span",String(y))),m.append(v)}u.append(m);let g=D("div",void 0,"profile-grid");for(let[_,y]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let v=D("div");v.append(D("span",_,"label"),D("p",y)),g.append(v)}u.append(g);let p=D("div",void 0,"palette");for(let _ of l.design.palette){let y=D("div",void 0,"swatch"),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("viewBox","0 0 24 24"),v.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",_.color),v.append(E);let w=D("span",_.role);w.append(D("small",_.color)),y.append(v,w),p.append(y)}if(p.childElementCount)u.append(p);for(let[_,y]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!y.length)continue;u.append(D("h3",_));let v=D("ul",void 0,"subtle");for(let E of y)v.append(D("li",E));u.append(v)}if(u.append(D("h3","Inventory")),!l.inventory.length)u.append(D("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let _=D("div",void 0,"table-wrap"),y=D("table"),v=D("thead"),E=D("tr");for(let T of["Item","Kind","Saved revision","Review"])E.append(D("th",T));v.append(E),y.append(v);let w=D("tbody");for(let T of l.inventory){let A=D("tr"),P=D("td",T.name);P.append(D("small",T.brief));let S=D("td"),R=D("td");if(T.asset){let k=D("button",An(T.asset.revisionId),"secondary");k.onclick=()=>e.openAsset(T.asset),S.append(k);let C=[...l.reviews].reverse().find((L)=>L.inventoryId===T.id&&L.asset.revisionId===T.asset.revisionId&&L.asset.assetId===T.asset.assetId&&L.asset.collectionId===T.asset.collectionId);R.append(D("small",C?`${C.verdict} · ${C.reviewer}`:"Unreviewed"));let U=D("button","Record review","secondary");U.onclick=()=>o(l,T),R.append(U)}else S.textContent="Not linked",R.textContent="No saved revision";A.append(P,D("td",T.kind),S,R),w.append(A)}y.append(w),_.append(y),u.append(_)}if(l.design.materialRoles.length){u.append(D("h3","Material roles"));for(let _ of l.design.materialRoles)u.append(D("p",`${_.role}: ${_.description||"No description"}${_.resourceId?` · ${_.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(D("h3","Delivery intent"));for(let _ of l.deliveryProfiles){if(u.append(D("p",`${_.target} · ${_.description||_.id}`,"subtle")),_.performanceIntent)u.append(D("p",_.performanceIntent,"subtle"));for(let y of _.constraints)u.append(D("p",y,"subtle"))}u.append(D("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(D("h3","Reference records"));for(let _ of l.references){let y=D("p",`${_.title}: ${_.uri}`,"subtle");if(_.description)y.append(D("small",` · ${_.description}`));u.append(y)}}u.append(D("h3","Project downloads"));let x=D("div",void 0,"downloads");for(let _ of["editable","runtime"]){let y=D("a",_==="editable"?"Download editable project bundle":"Download runtime project bundle"),v=new URLSearchParams({profile:_,revision:l.revisionId});y.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${v}`,y.download=`${l.projectId}-${_}.zip`,x.append(y)}x.append(D("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(x),u.append(Wo("Exact project configuration and review records",l))},s=async()=>{let c=await un("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";r(),e.changed(t)};function a(c){i=c,ue("project-editor-title").textContent=c?"Edit project":"New project",ue("project-name").value=c?.name??"",ue("project-brief").value=c?.brief??"",ue("project-style").value=c?.design.style??"",ue("project-scale").value=c?.design.scale??"",ue("project-config").value=JSON.stringify(DR(c??{name:""}),null,2),ue("project-save-status").textContent="",ue("project-editor").showModal(),ue("project-name").focus()}function o(c,l){if(!l.asset)return;let u=D("dialog"),d=D("form"),f=D("div",void 0,"editor-content"),h=D("h2",`Review ${l.name}`);h.id="review-dialog-title",u.setAttribute("aria-labelledby",h.id),f.append(h,D("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),D("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let b=D("input");b.required=!0,b.value=As("kiln.reviewer")??"",b.maxLength=200;let m=D("label","Reviewer","field");m.append(b);let g=D("select");for(let[w,T]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])g.append(new Option(T,w));let p=D("label","Assessment","field");p.append(g);let x=D("textarea");x.rows=4,x.maxLength=4000;let _=D("label","Notes","field");_.append(x);let y=D("p");y.setAttribute("role","status");let v=D("button","Save review");v.type="submit";let E=D("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),f.append(m,p,_,y,v,E),d.append(f),u.append(d),document.body.append(u),u.addEventListener("close",()=>u.remove()),d.onsubmit=async(w)=>{w.preventDefault(),v.disabled=!0,y.textContent="Saving review…";try{await un(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:b.value.trim(),verdict:g.value,notes:x.value}]}}}),Hi("kiln.reviewer",b.value.trim()),u.close(),await s()}catch(T){y.textContent=T instanceof Error?T.message:String(T)}finally{v.disabled=!1}},u.showModal(),b.focus()}return ue("new-project").onclick=()=>a(),ue("close-project-editor").onclick=()=>ue("project-editor").close(),ue("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ue("save-project");l.disabled=!0,ue("project-save-status").textContent="Saving revision…";try{let u=LR(ue("project-config").value,{name:ue("project-name").value,brief:ue("project-brief").value,style:ue("project-style").value,scale:ue("project-scale").value});n=(await un(i?`/api/projects/${encodeURIComponent(i.projectId)}`:"/api/projects",i?{method:"PATCH",body:{expectedRevision:i.revisionId,patch:u}}:{method:"POST",body:u})).projectId,Hi("kiln.project",n),ue("project-editor").close(),In("Project revision saved."),await s()}catch(u){ue("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:s}}var DB="Raw map pixels · unshaded · not GPU capture evidence",pb=/^[a-z][a-z0-9_-]{0,79}$/,mb=/^sha256:[a-f0-9]{64}$/;function Ll(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),i=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!i||!pb.test(n)||!mb.test(i))return;return{materialId:n,revisionId:i}}function Nf(e){if(!pb.test(e.materialId)||!mb.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function gb(e){if(!pb.test(e.materialId)||!mb.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function UR(e){let t=ro(e),n=gb(t),i=t.maps.map((r)=>{let s="recipe"in r?r:void 0,a=s?.recipe?.kind==="atlas"?s.recipe:void 0;return{slot:r.slot,file:r.file,url:`${n}/${encodeURIComponent(r.file)}`,width:r.width,height:r.height,colorSpace:r.colorSpace,imageSha256:r.sha256,..."pixelHash"in r?{pixelHash:r.pixelHash}:{},..."sampler"in r?{sampler:{...r.sampler}}:{},atlas:!!a,...s?.recipe?{compilerId:s.recipe.compilerId}:{},...a?{manifestHash:a.manifest.manifestHash}:{},regions:a?a.manifest.regions.map((o)=>({name:o.name,content:{...o.content},allocation:{...o.allocation},leftPercent:o.content.x/r.width*100,topPercent:o.content.y/r.height*100,widthPercent:o.content.width/r.width*100,heightPercent:o.content.height/r.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:DB,maps:i}}function BR(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let i=new Map;for(let r of n){let s=ro(r),a=`${s.materialId}/${s.revisionId}`,o=i.get(a);if(o&&Nn(o)!==Nn(s))throw Error("Conflicting retained material identity");i.set(a,s)}return[...i.values()]}function Pf(e){let t=UR(e),n=D("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(D("p",`${t.materialId} · ${t.revisionId}`,"mono"),D("p",t.fidelity,"subtle"));let i=D("div",void 0,"material-inspection-controls"),r=(v,E)=>{let w=D("label",v,"inline-field");return w.append(E),i.append(w),E},s=r("Map",D("select"));for(let v of t.maps)s.append(new Option(`${v.slot}${v.atlas?" · atlas":""}`,v.slot));let a=r("Backdrop",D("select"));for(let v of["checker","light","dark"])a.append(new Option(v[0].toUpperCase()+v.slice(1),v));let o=r("Pixel zoom",D("select"));for(let v of[1,2,4])o.append(new Option(`${v}×`,String(v)));let c=D("div",void 0,"material-pixel-frame"),l=D("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=D("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let d=D("div",void 0,"material-region-overlay"),f=D("label","Region overlays","inline-field"),h=D("input");h.type="checkbox",h.checked=!1,f.append(h),i.append(f),h.onchange=()=>{d.hidden=!h.checked},l.append(u,d),c.append(l);let b=D("p",void 0,"subtle");b.setAttribute("role","status");let m=D("dl"),g=D("div",void 0,"material-region-list"),p=D("a","Open this saved material revision");p.href=Nf(t),p.target="_blank",p.rel="noopener",n.append(i,c,b,m,g,p);let x=t.maps[0],_=()=>{l.style.width=`${x.width*Number(o.value)}px`,l.style.height=`${x.height*Number(o.value)}px`},y=()=>{x=t.maps.find((E)=>E.slot===s.value)??t.maps[0],f.hidden=!x.atlas,d.hidden=!x.atlas||!h.checked,b.textContent="Loading exact saved map…",u.alt=`${t.name}: ${x.slot}${x.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=x.width,u.height=x.height,u.src=x.url,_(),m.replaceChildren();let v=(E,w)=>m.append(D("dt",E),D("dd",w));if(v("Image",`${x.width} × ${x.height} · ${x.colorSpace} · nearest pixel display`),v("Sampling declaration",x.sampler?`${x.sampler.minFilter} / ${x.sampler.magFilter} · ${x.sampler.wrapS} / ${x.sampler.wrapT}`:"Not recorded in V1"),v("PNG hash",x.imageSha256),x.pixelHash)v("Decoded RGBA hash",x.pixelHash);if(x.compilerId)v("Compiler",x.compilerId);if(x.manifestHash)v("Atlas manifest hash",x.manifestHash);if(d.replaceChildren(),g.replaceChildren(),x.atlas){g.append(D("h4","Atlas regions · top-left pixel coordinates"));for(let E of x.regions){let w=D("span",void 0,"material-region-box");w.style.left=`${E.leftPercent}%`,w.style.top=`${E.topPercent}%`,w.style.width=`${E.widthPercent}%`,w.style.height=`${E.heightPercent}%`,w.append(D("span",E.name)),w.setAttribute("aria-hidden","true"),d.append(w);let T=D("button",`${E.name}: content ${E.content.x},${E.content.y} ${E.content.width}×${E.content.height}; allocation ${E.allocation.x},${E.allocation.y} ${E.allocation.width}×${E.allocation.height}`,"secondary");T.type="button",T.setAttribute("aria-pressed","false"),T.onclick=()=>{for(let A of d.children)A.classList.remove("selected");for(let A of g.querySelectorAll("button"))A.setAttribute("aria-pressed","false");if(w.classList.add("selected"),T.setAttribute("aria-pressed","true"),!d.hidden)w.scrollIntoView({block:"nearest",inline:"nearest"})},g.append(T)}}};return u.onload=()=>{b.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{b.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},s.onchange=y,a.onchange=()=>{c.dataset.backdrop=a.value},o.onchange=_,y(),n}function zR(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let i=new URL(e.url.trim());if(i.protocol!=="https:"&&i.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function VR(e){let t=[],n=[],i=[],r=ue("materials-project"),s=D("button","Create from preset");ue("materials-refresh").before(s);let a=D("dialog");a.setAttribute("aria-labelledby","material-preset-heading");let o=D("form"),c=D("div",void 0,"detail-top"),l=D("h2","Create a material resource");l.id="material-preset-heading";let u=D("button","Cancel","secondary");u.type="button",u.onclick=()=>a.close(),c.append(l,u);let d=D("div",void 0,"editor-content");d.append(D("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function f(S,R){let k=D("label",S,"field");return k.append(R),d.append(k),R}let h=f("Preset",D("select")),b=D("p",void 0,"subtle");d.append(b);let m=f("Seed",D("input"));m.type="number",m.step="1",m.required=!0,m.min="-2147483648",m.max="2147483647",m.value="0";let g=f("Map size",D("select"));for(let S of[64,128,256,512])g.append(new Option(`${S} × ${S}`,String(S)));g.value="256";let p=f("Creator",D("input"));p.required=!0,p.maxLength=1000;let x=f("License identifier",D("input"));x.required=!0,x.placeholder="For example, CC0-1.0";let _=f("License URL",D("input"));_.type="url",_.required=!0;let y=f("Attribution text",D("textarea"));y.rows=2;let v=D("p");v.setAttribute("role","status");let E=D("button","Create resource");E.type="submit",d.append(v,E),o.append(c,d),a.append(o),document.body.append(a);let w=()=>{let S=i.find((R)=>R.id===h.value);b.textContent=S?`${S.description} Repeat scale: ${S.physicalSizeMeters.width} × ${S.physicalSizeMeters.height} m.`:""};h.onchange=w,s.onclick=async()=>{s.disabled=!0;try{i=(await un("/api/material-presets")).presets,h.replaceChildren(...i.map((S)=>new Option(S.name,S.id))),w(),v.textContent="",E.disabled=!i.length,a.showModal()}catch(S){In(S)}finally{s.disabled=!1}},o.onsubmit=async(S)=>{S.preventDefault(),E.disabled=!0,v.textContent="Creating immutable material resource…";try{let R=zR({presetId:h.value,seed:m.value,size:g.value,creator:p.value,spdx:x.value,url:_.value,attribution:y.value}),k=await un("/api/materials/preset",{method:"POST",body:R});await P(),a.close(),In(`${k.material.name} created at ${k.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(R){v.textContent=R instanceof Error?R.message:String(R)}finally{E.disabled=!1}};let T=gb;function A(){let S=n.find((L)=>L.projectId===r.value),R=ue("material-dependencies");if(R.replaceChildren(),S)if(R.append(D("h2",`${S.name}: locked resources`)),!S.materialDependencies.length)R.append(D("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let L=D("table"),O=D("thead"),K=D("tr"),B=D("tbody");for(let q of["Resource / role","Exact revision","Local availability"])K.append(D("th",q));O.append(K),L.append(O);for(let q of S.materialDependencies){let le=t.find((pe)=>pe.materialId===q.resourceId&&pe.revisionId===q.revisionId),de=D("tr"),Me=D("td",q.resourceId);Me.append(D("small",q.role??S.design.materialRoles.filter((pe)=>pe.resourceId===q.resourceId).map((pe)=>pe.role).join(", "))),de.append(Me,D("td",q.revisionId,"mono"),D("td",le&&le.revisionId===q.sha256?"Exact local record available":le?"Dependency hash differs":"Not in local catalog")),B.append(de)}L.append(B);let X=D("div",void 0,"table-wrap");X.append(L),R.append(X)}let k=ue("material-list");k.replaceChildren();let C=ue("material-search").value.trim().toLowerCase(),U=t.filter((L)=>`${L.name} ${L.materialId} ${L.tags.join(" ")} ${L.sources.map((O)=>O.provider).join(" ")}`.toLowerCase().includes(C));if(ue("material-count").textContent=`${U.length} material revision${U.length===1?"":"s"}`,!U.length){k.append(Ko(C?"No matching materials":"Your material catalog starts here",C?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let L of U){let O=D("article",void 0,"material-card"),K=L.maps.find((F)=>F.slot==="baseColor")??L.maps[0];if(K){let F=D("img");F.src=`${T(L)}/${encodeURIComponent(K.file)}`,F.alt=`${L.name}: ${K.slot} map, not a shaded material preview`,F.loading="lazy",F.className="material-map",O.append(F,D("p",`${K.slot} map · unshaded`,"subtle"))}O.append(D("h3",L.name),D("p",L.tags.join(" · "),"subtle"));let B=D("dl"),X=(F,W)=>B.append(D("dt",F),D("dd",W));X("Revision",L.revisionId),X("Physical scale",L.physicalSizeMeters?`${L.physicalSizeMeters.width} × ${L.physicalSizeMeters.height} m`:"Not specified"),X("Tiling",L.tileable?"Declared tileable":"Not declared tileable"),X("Maps",L.maps.map((F)=>`${F.slot} ${F.width}×${F.height} (${F.colorSpace})`).join(" · ")),X("Surface factors",`Roughness ×${L.parameters.roughness} · Metalness ×${L.parameters.metalness}${L.maps.some((F)=>F.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),O.append(B);for(let F of L.sources){let W=D("p",`${F.provider} · ${F.creator} · ${F.kind}`,"subtle"),ne=D("a",F.license.spdx);if(ne.href=F.license.url,ne.target="_blank",ne.rel="noreferrer",W.append(document.createTextNode(" · "),ne),F.assetUrl){let ie=D("a","Source");ie.href=F.assetUrl,ie.target="_blank",ie.rel="noreferrer",W.append(document.createTextNode(" · "),ie)}if(O.append(W),F.license.attribution)O.append(D("p",F.license.attribution,"subtle"))}let q=D("div",void 0,"material-map-links");for(let F of L.maps){let W=D("a",F.slot);W.href=`${T(L)}/${encodeURIComponent(F.file)}`,W.target="_blank",W.rel="noopener",q.append(W)}O.append(q);let le=D("details",void 0,"material-map-inspection");le.append(D("summary","Inspect maps and atlas regions"));let de=!1;le.ontoggle=()=>{if(le.open&&!de)de=!0,le.append(Pf(L))};let Me=Ll(location.search);if(Me?.materialId===L.materialId&&Me.revisionId===L.revisionId)le.open=!0,O.dataset.selectedMaterial="true";O.append(le);let pe=S?.materialDependencies.find((F)=>F.resourceId===L.materialId),J=D("button",pe?.revisionId===L.revisionId?"Locked to project":pe?"Use this revision":"Add to project","secondary");if(J.disabled=!S||pe?.revisionId===L.revisionId,!S)J.title="Select a project to add a material dependency";J.onclick=async()=>{if(!S)return;J.disabled=!0;try{let F=S.materialDependencies.filter((W)=>W.resourceId!==L.materialId);F.push({resourceId:L.materialId,revisionId:L.revisionId,sha256:L.revisionId,...pe?.role?{role:pe.role}:{}}),await un(`/api/projects/${encodeURIComponent(S.projectId)}`,{method:"PATCH",body:{expectedRevision:S.revisionId,patch:{materialDependencies:F}}}),In(`${L.name} is locked to ${S.name} at this exact revision.`),await e()}catch(F){In(F),J.disabled=!1}},O.append(J,Wo("Map recipes, transformations and provenance",L)),k.append(O)}}let P=async()=>{t=(await un("/api/materials")).materials,A();let S=Ll(location.search);if(S&&!t.some((R)=>R.materialId===S.materialId&&R.revisionId===S.revisionId))In(`Exact material revision unavailable: ${S.materialId} at ${S.revisionId}. No newer revision was selected.`)};return ue("material-search").oninput=A,r.onchange=A,ue("materials-refresh").onclick=()=>void P().catch(In),{refresh:P,projects(S){n=S;let R=r.value;r.replaceChildren(new Option("All materials",""));for(let k of n)r.append(new Option(k.name,k.projectId));if(n.some((k)=>k.projectId===R))r.value=R;A()}}}function bb(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var jR=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function Fl(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),i=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(jR),r=(c)=>i.find((l)=>l.operationId===c?.operationId)??c,s=e.following?i.at(-1):r(e.selected),a=(c)=>!!c&&!!s&&c.projectId===s.projectId&&c.workId===s.workId&&jR(c,s)<=0&&(c.sessionId===s.sessionId||e.following&&e.crossRunContinuity===!0&&!!s.workId),o=s?.artifact?s:s?i.filter((c)=>c.artifact&&a(c)).at(-1)??(a(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:i,selected:s,displayed:o,pinned:r(e.pinned)}}function xb(e,t){return Fl({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function Ys(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function HR(e,t,n,i){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!Ys(e,Ys(i,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let r=t.trim();if(!r||r.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:r,collection:"project"}}}function Of(e,t,n,i){let r;e.onclick=async()=>{let s=n();if(!s){t.replaceChildren(D("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(D("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let a=await Ew(()=>s.measure(3000),i),o=D("div",void 0,"evidence-card");o.append(D("h3","Exploratory browser measurement"),D("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),D("strong",`p50 ${a.frameMs.p50.toFixed(1)} ms · p95 ${a.frameMs.p95.toFixed(1)} ms`),D("p",`${a.frameMs.samples} frame intervals · ${(a.windowMs/1000).toFixed(2)} s · ${a.drawCalls} draws · ${a.triangles.toLocaleString()} rendered triangles`),D("p",`${a.geometryObjects} geometry objects · ${a.textureObjects} texture objects. These counts are not GPU memory bytes.`),D("p",`GLB parse to first frame submission: ${a.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),D("p",`${a.viewport.cssWidth}×${a.viewport.cssHeight} CSS pixels · DPR ${a.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Wo("Exact measurement receipt and limitations",a);if(r)URL.revokeObjectURL(r);r=URL.createObjectURL(new Blob([JSON.stringify(a,null,2)],{type:"application/json"}));let l=D("a","Download measurement receipt");l.href=r,l.download="kiln-viewer-performance.json",o.append(c,l),t.replaceChildren(o)}catch(a){t.replaceChildren(D("p",a instanceof Error?a.message:String(a),"subtle"))}finally{e.disabled=!1}}}function yb(e,t,n,i){let r=e.inventory.find((a)=>a.id===t);if(!r&&!n)throw Error("Inventory item not found");let s=e.inventory.map((a)=>{if(a.id!==t)return a;let{asset:o,...c}=a;return n?{...c,asset:n}:c});if(!r&&n)s.push({id:t,name:i,kind:"asset",brief:"",references:[],asset:n});return{inventory:s}}async function Ul(e,t,n,i){e.replaceChildren(D("h3","Project membership"));let{projects:r}=await un("/api/projects");if(!e.isConnected)return;let s=D("div");e.append(s);let a=D("p");a.setAttribute("role","status");let o=()=>Ul(e,t,n,i);for(let m of r)for(let g of m.inventory){if(!g.asset||g.asset.collectionId!==t.collectionId||g.asset.assetId!==t.assetId)continue;let p=D("div",void 0,"membership-row");p.append(D("span",`${m.name} / ${g.name} · ${An(g.asset.revisionId)}${g.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let x=D("button","Remove membership","secondary");x.onclick=async()=>{x.disabled=!0;try{await un(`/api/projects/${encodeURIComponent(m.projectId)}`,{method:"PATCH",body:{expectedRevision:m.revisionId,patch:yb(m,g.id,null,n)}}),await i(),await o()}catch(_){a.textContent=`${_ instanceof Error?_.message:_} Reopen membership to load the current project.`,x.disabled=!1}},p.append(x),s.append(p)}if(!s.childElementCount)s.append(D("p","This asset is standalone. Project membership is optional.","subtle"));if(!r.length){s.append(D("p","Create a named project in Projects to organize related assets."));return}let c=D("form"),l=D("select"),u=D("select"),d=D("label","Project","field"),f=D("label","Inventory item","field");d.append(l),f.append(u);for(let m of r)l.append(new Option(m.name,m.projectId));let h=()=>{let m=r.find((p)=>p.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let p of m.inventory)u.append(new Option(`${p.name}${p.asset?" (replace linked revision)":""}`,p.id));let g=m.inventory.find((p)=>p.asset?.collectionId===t.collectionId&&p.asset.assetId===t.assetId);if(g)u.value=g.id};l.onchange=h,h();let b=D("button","Link this exact revision");b.type="submit",c.append(d,f,D("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),b,a),c.onsubmit=async(m)=>{m.preventDefault(),b.disabled=!0;let g=r.find((x)=>x.projectId===l.value),p=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await un(`/api/projects/${encodeURIComponent(g.projectId)}`,{method:"PATCH",body:{expectedRevision:g.revisionId,patch:yb(g,p,t,n)}}),await i(),await o()}catch(x){a.textContent=`${x instanceof Error?x.message:x} Reopen membership to load the current project.`,b.disabled=!1}},s.append(c)}function GR(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",i=0,r=!1,s,a=0,o,c,l,u,d,f,h,b=0,m=0,g=!1,p=!1,x,_=ue("live-project"),y=ue("live-source"),v=(F)=>y.value?`${F}${F.includes("?")?"&":"?"}source=${encodeURIComponent(y.value)}`:F,E=ue("live-run"),w=ue("live-work"),T=()=>`kiln.live.selection.${y.value}.${_.value}.${w.value}.${E.value}`,A=()=>`kiln.live.pin.${y.value}`,P=()=>t.filter((F)=>(!E.value||F.sessionId===E.value)&&(!w.value||(w.value==="ungrouped"?!F.workId:F.workId===w.value))),S=(F,W)=>{let ne=ue("live-connection");ne.textContent=F?"Connected":"Reconnecting",ne.className=`pill ${F?"connected":"warning"}`,ue("connection-status").textContent=W};function R(){let F=w.value,W=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(w.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...W.map((ce)=>new Option(ce,ce))),F==="ungrouped"||W.includes(F))w.value=F;let ne=E.value,ie=[...new Set(t.map((ce)=>ce.sessionId))];E.replaceChildren(new Option("All runs",""));for(let ce of ie){let _e=t.find((Re)=>Re.sessionId===ce);E.append(new Option(`${_e.transport} · ${An(ce)}`,ce))}if(ie.includes(ne))E.value=ne}function k(){let F=ue("live-timeline"),W=F.scrollTop,ne=F.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(F.replaceChildren(),!e.operations.length){F.append(Ko("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let ie of[...e.operations].reverse()){let ce=D("button",void 0,`timeline-item ${ie.status}${e.selected?.operationId===ie.operationId?" selected":""}${ie.pinned?" pinned":""}`);ce.dataset.operation=ie.operationId;let _e=D("span",void 0,"timeline-meta");if(_e.append(D("span",ie.transport.toUpperCase()),D("time",new Date(ie.startedAt).toLocaleTimeString())),ce.append(_e,D("strong",ie.tool.replace(/^kiln_/,"")),D("small",`${ie.status} · ${ie.artifact?"artifact available":"no artifact"}`),D("small",ie.workId?`Item ${ie.workId}`:`Ungrouped · run ${An(ie.sessionId)}`)),ce.setAttribute("aria-label",`${ie.tool}, ${ie.status}, ${new Date(ie.startedAt).toLocaleString()}`),e.selected?.operationId===ie.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=xb(e,ie.operationId),Hi(T(),ie.operationId),q()},F.append(ce),ne===ie.operationId)ce.focus({preventScroll:!0})}F.scrollTop=W}function C(F){let W=D("div",void 0,"evidence-card");W.append(D("h3","Capture fidelity"));let ne=F.viewFidelity,ie=ne&&typeof ne==="object"?ne:void 0;if(W.append(D("strong",ie?String(ie.delivered??"Reported"):"No capture receipt yet")),W.append(D("p",ie?.materialFaithful===!0?"Material-faithful capture reported.":ie?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),ie?.degradeReason)W.append(D("p",String(ie.degradeReason)));if(ie?.rendererId)W.append(D("p",`Renderer: ${String(ie.rendererId)}`,"mono"));if(ie?.inputGlbSha256)W.append(D("p",`Capture input: ${String(ie.inputGlbSha256)}`,"mono"));if(ie)W.append(D("p",ie.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return W}function U(){let F=ue("live-evidence"),W=ue("live-downloads");F.replaceChildren(),W.replaceChildren();let ne=e.displayed;if(!ne?.artifact){x=void 0;return}let ie=D("div",void 0,"evidence-card");ie.append(D("h3","Selected observed artifact"),D("strong",`${(ne.artifact.bytes/1024).toFixed(0)} KB GLB`),D("p",ne.artifact.sha256,"mono"),D("p",`Source: ${ne.programRef??"See authored source download"}`,"mono")),F.append(ie,C(ne));let ce=`${y.value}/${ne.operationId}/${ne.artifact.sha256}`;if(x?.key!==ce){let _e=D("div",void 0,"evidence-card live-material-inspection"),Re=D("button","Inspect exact material inputs","secondary");_e.append(D("h3","Materials and atlas sheets"),D("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Re),x={key:ce,card:_e},Re.onclick=async()=>{Re.disabled=!0;let ke=D("p","Reading the displayed artifact evaluation…");ke.setAttribute("role","status"),_e.append(ke);try{let We=await un(v(`/api/live/${encodeURIComponent(ne.operationId)}/evaluation.json`));if(x?.key!==ce)return;let Qe=BR(We,ne.artifact.sha256);ke.textContent=Qe.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Wt of Qe){let lt=D("details");lt.append(D("summary",`${Wt.name} · ${Wt.revisionId}`));let Lt=!1;lt.ontoggle=()=>{if(lt.open&&!Lt)Lt=!0,lt.append(Pf(Wt))},_e.append(lt)}}catch(We){if(x?.key!==ce)return;ke.textContent=`Material inspection unavailable for this exact artifact: ${We instanceof Error?We.message:String(We)}`,Re.disabled=!1}}}if(F.append(x.card),ne.captures.length)for(let _e of ne.captures){let Re=D("div",void 0,"evidence-card");Re.append(D("h3",_e.name));let ke=ne.viewFidelity&&typeof ne.viewFidelity==="object"?ne.viewFidelity:void 0;Re.append(D("p",ke?.materialFaithful===!0?`Recorded capture · ${String(ke.delivered??"material-faithful")}`:`Recorded capture · ${String(ke?.delivered??"fidelity unreported")}. Materials are not verified.`,ke?.materialFaithful===!0?"subtle":"warning"));let We=D("a"),Qe=D("img");Qe.src=_e.url,Qe.alt=`Recorded ${_e.name} for ${ne.tool}`,Qe.loading="lazy",We.href=_e.url,We.target="_blank",We.rel="noopener",We.append(Qe),Re.append(We,D("p",_e.sha256,"mono")),F.append(Re)}else{let _e=D("div",void 0,"evidence-card");_e.append(D("h3","Recorded captures"),D("p",ne.status==="evaluated"||ne.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),F.append(_e)}for(let[_e,Re,ke]of[[ne.artifact.url,"Observed GLB","asset.glb"],[v(`/api/live/${encodeURIComponent(ne.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let We=D("a",Re);We.href=_e,We.download=ke,W.append(We)}W.append(D("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function L(){let F=Ys(e.displayed,l);ue("pin-build").disabled=!F,Me.disabled=F?.status!=="complete"}function O(){if(d&&l)ue("live-stage-label").textContent=bb(d,An(l.operationId),o?.lod())}function K(){if(f&&u)ue("compare-stage-label").textContent=`Pinned · ${bb(f,An(u.operationId),c?.lod())}`}async function B(F){if(ue("live-panel").hidden)return;let W=++b;if(!Ys(F,l))o?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!F?.artifact){ue("live-performance").replaceChildren(),o?.dispose(),o=void 0,l=void 0,d=void 0,ue("live-level-field").hidden=!0,ue("live-lod").replaceChildren(),ue("live-lod").hidden=!0,ue("live-stage-status").textContent="No completed artifact available for this run.",ue("live-stage-label").textContent="Current",L();return}if(l?.artifact?.sha256===F.artifact.sha256){l=F,ue("live-stage-status").textContent="",O(),L();return}ue("live-stage-status").textContent=`Loading ${An(F.operationId)}…${l?` Previous artifact ${An(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let ne=await fetch(F.artifact.url);if(!ne.ok)throw Error("This retained artifact is no longer available");let ie=new Uint8Array(await ne.arrayBuffer());if(W!==b)return;o??=El(ue("live-stage"));let ce=await o.load(ie,{isCurrent:()=>W===b,onCommit:()=>{l=F},preserveView:l?.projectId===F.projectId&&(l?.sessionId===F.sessionId||e.following)});if(!ce||W!==b)return;ue("live-performance").replaceChildren(),l=F,d=ce,L();let _e=ue("live-level");if(ue("live-level-field").hidden=!ce.levels,Tl(_e,ue("live-lod"),o,(Re)=>{if(Re!==void 0)c?.level(Re),h?.refresh(),K();O()}),o.wire(g),o.navigation(ue("live-navigation").value),ue("live-stage-status").textContent="",O(),c)c.setView(o.view())}catch(ne){if(W!==b)return;ue("live-stage-status").textContent=`${ne instanceof Error?ne.message:ne}.${l?` Previous artifact ${An(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,L()}}async function X(F){if(ue("live-panel").hidden)return;let W=++m;if(ue("compare-viewport").hidden=!F?.artifact,ue("review-viewports").classList.toggle("comparing",!!F?.artifact),!F?.artifact){c?.dispose(),c=void 0,u=void 0,f=void 0,h=void 0,ue("compare-lod").replaceChildren(),ue("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===F.artifact.sha256){u=F,K(),ue("compare-stage-status").textContent="";return}if(!u)ue("compare-stage-label").textContent="Comparison";ue("compare-stage-status").textContent=`Loading pinned ${An(F.operationId)}…`;try{let ne=await fetch(F.artifact.url);if(!ne.ok)throw Error("Pinned artifact unavailable");let ie=new Uint8Array(await ne.arrayBuffer());if(W!==m)return;c??=El(ue("compare-stage"));let ce=await c.load(ie,{preserveView:!0,isCurrent:()=>W===m,onCommit:()=>{u=F}});if(!ce||W!==m)return;if(u=F,f=ce,o)c.setView(o.view());let _e=Number(ue("live-level").value||0);c.level(Number.isFinite(_e)?_e:0),ue("compare-level-field").hidden=!ce.levels,h=Tl(ue("compare-level"),ue("compare-lod"),c,K),K(),c.wire(g),c.navigation(ue("live-navigation").value),ue("compare-stage-status").textContent=""}catch(ne){if(W===m)ue("compare-stage-status").textContent=`${ne instanceof Error?ne.message:String(ne)}.${u?` Previous comparison ${An(u.operationId)} remains visible.`:""}`}}function q(){k();let F=e.selected,W=e.displayed,ne=ue("follow-latest");ne.textContent=e.following?"Following latest":"Follow latest",ne.setAttribute("aria-pressed",String(e.following));let ie=ue("live-current-summary");if(ie.replaceChildren(),F){ie.append(D("h2",F.tool.replace(/^kiln_/,"")),D("p",`${F.status} · ${F.transport} · Run ${An(F.sessionId)} · ${new Date(F.updatedAt).toLocaleString()}`));let Re=D("div",void 0,"tags");if(F.projectId)Re.append(D("span",F.projectId,"tag"));for(let ke of F.phases)Re.append(D("span",ke.phase,"tag"));ie.append(Re)}else ie.append(D("h2","No build selected"),D("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=F&&"observationIssues"in F&&Array.isArray(F.observationIssues)?F.observationIssues.map(String):[],_e=[F?.error,...ce,F&&W&&F.operationId!==W.operationId?`Current ${F.status} operation has no retained artifact. Showing the last successful artifact ${An(W.operationId)} from run ${An(W.sessionId)}.`:"",F&&!e.operations.some((Re)=>Re.operationId===F.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ue("live-failure").textContent=_e.join(" "),ue("live-failure").hidden=!_e.length,L(),ue("clear-pin").hidden=!e.pinned,ue("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ue("live-record").textContent=JSON.stringify({selected:F,displayedArtifactOperation:W?.operationId,pinnedOperation:e.pinned?.operationId},null,2),U(),B(W),X(e.pinned)}async function le(){if(r)return;r=!0;let F=i;try{let W=new URLSearchParams;if(_.value)W.set("project",_.value);if(n)W.set("cursor",n);let ne=await un(v(`/api/live?${W}`));if(F!==i)return;if(a=0,S(!0,"Connected · checks every 2 seconds"),n=ne.cursor,ue("live-history-note").textContent=`Up to ${ne.retention.maxOperations} operations`,ue("live-history-issues").textContent=ne.observationIssues?.join(" ")??"",ue("live-history-issues").hidden=!ne.observationIssues?.length,!ne.unchanged){if(t=ne.operations,R(),e=Fl(e,P()),!p){p=!0;let ie=As(T());if(ie&&e.operations.some((_e)=>_e.operationId===ie))e=xb(e,ie);let ce=As(A());e.pinned=t.find((_e)=>_e.operationId===ce&&_e.pinned)??[...t].reverse().find((_e)=>_e.pinned&&_e.artifact)}q()}}catch(W){a++,S(!1,`Connection lost. Retrying; retained views remain available. ${W instanceof Error?W.message:W}`)}finally{if(r=!1,s)clearTimeout(s);s=setTimeout(()=>void le(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(a,4)))}}_.onchange=()=>{i++,n="",t=[],p=!1,E.replaceChildren(new Option("All runs","")),w.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),le()},y.onchange=()=>{_.value="",e.pinned=void 0,_.dispatchEvent(new Event("change"))},un("/api/live-sources").then(({sources:F})=>{y.replaceChildren(...F.map((W)=>new Option(W.label,W.id)))}).catch(In),E.onchange=()=>{e=Fl({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!E.value},P()),q()},w.onchange=()=>E.dispatchEvent(new Event("change")),ue("follow-latest").onclick=()=>{e=Fl({...e,following:!e.following},P()),Hi(T(),e.following?"":e.selected?.operationId??""),q()},ue("live-refresh").onclick=()=>{n="",le(),q()},ue("pin-build").onclick=async()=>{let F=Ys(e.displayed,l);if(!F?.artifact)return;let W=ue("pin-build");W.disabled=!0;try{await un(v(`/api/live/${encodeURIComponent(F.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...F,pinned:!0},Hi(A(),F.operationId),n="",q(),le()}catch(ne){In(ne),L()}},ue("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await un(v(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,Hi(A(),""),n="",q(),le()}catch(F){In(F)}},ue("live-frame").onclick=()=>{if(o?.reset(),o)c?.setView(o.view())},ue("live-wire").onclick=()=>{g=!g,o?.wire(g),c?.wire(g),ue("live-wire").setAttribute("aria-pressed",String(g))};let de=D("button","Match comparison camera","secondary");de.onclick=()=>{if(o)c?.setView(o.view())},ue("live-frame").parentElement?.append(de);let Me=D("button","Save exact artifact");Me.disabled=!0,ue("live-frame").parentElement?.prepend(Me);let pe=D("button","Measure 3 s","secondary"),J=D("div");return J.id="live-performance",ue("live-evidence").after(J),ue("live-frame").parentElement?.append(pe),Of(pe,J,()=>o,()=>Ys(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),Me.onclick=()=>{let F=Ys(e.displayed,l);if(F?.status!=="complete")return;let W=D("dialog"),ne=D("form"),ie=D("div",void 0,"editor-content"),ce=D("h2","Save reviewed artifact");ce.id="save-review-title",W.setAttribute("aria-labelledby",ce.id),ie.append(ce,D("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),D("p",`${F.operationId} · revision ${F.revision}`,"mono"),D("p",F.artifact.sha256,"mono"));let _e=D("input");_e.required=!0,_e.maxLength=200,_e.value="";let Re=D("label","Asset name","field");Re.append(_e);let ke=D("p");ke.setAttribute("role","status");let We=D("button","Save exact artifact");We.type="submit";let Qe=D("button","Cancel","secondary");Qe.type="button",Qe.onclick=()=>W.close(),ie.append(Re,ke,We,Qe),ne.append(ie),W.append(ne),document.body.append(W),W.addEventListener("close",()=>W.remove()),ne.onsubmit=async(Wt)=>{Wt.preventDefault(),We.disabled=!0,ke.textContent="Saving retained bytes…";try{let lt=HR(F,_e.value,l,e.displayed),Lt=await un(v(lt.path),{method:"POST",body:lt.body});ke.replaceChildren(D("span",`Saved ${Lt.asset.assetId} / ${Lt.asset.revisionId}. `));let Qt=D("a","Open saved revision"),nn=new URLSearchParams({collection:Lt.collection,asset:Lt.asset.assetId,revision:Lt.asset.revisionId});Qt.href=`/?${nn}`,ke.append(Qt);let z=D("div");ie.append(z),Ul(z,{collectionId:Lt.collection,assetId:Lt.asset.assetId,revisionId:Lt.asset.revisionId},Lt.asset.name,async()=>{}).catch((_n)=>{z.textContent=`Asset saved; membership unavailable: ${_n instanceof Error?_n.message:_n}. Open the saved asset in Library to link it.`}),_e.disabled=!0,We.textContent="Saved",Qe.textContent="Close"}catch(lt){ke.textContent=lt instanceof Error?lt.message:String(lt),We.disabled=!1}},W.showModal(),_e.focus()},ue("live-navigation").onchange=(F)=>{let W=F.target.value;o?.navigation(W),c?.navigation(W),ue("live-navigation-help").textContent=W==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",le()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)le()}),le(),{activate:q,projects(F){let W=_.value;_.replaceChildren(new Option("All work",""));for(let ne of F)_.append(new Option(ne.name,ne.projectId));if(F.some((ne)=>ne.projectId===W))_.value=W}}}var _b=["projects","live","library","materials"];function $R(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(Ll(e))return"materials";return t&&_b.some((i)=>i===t)?t:"library"}function KR(e,t=()=>{}){let n=_b;function i(c){if(!n.includes(c))return;for(let l of n)ue(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if(Hi("kiln.section",c),c==="live")r.activate();if(c==="materials")s.refresh().catch(In)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>i(c.dataset.section);ue("open-files").onclick=()=>ue("open").click();let r=GR(),s=VR(()=>a.refresh()),a=FR({changed:(c)=>{r.projects(c),s.projects(c),t(c)},openAsset:(c)=>{i("library"),e(c)}});i($R(location.search,As("kiln.section"))),a.refresh().catch(In),s.refresh().catch(In);let o=!1;return window.setInterval(async()=>{if(document.hidden||o||ue("project-editor").open)return;o=!0;try{await a.refresh()}catch{}finally{o=!1}},5000),{library:()=>i("library"),refreshProjects:a.refresh}}var Er=(e)=>`${e.collection}/${e.manifest.assetId}`;function WR(e,t,n){if(!n)return e;if(n==="standalone"){let r=new Set(t.flatMap((s)=>s.inventory.flatMap((a)=>a.asset?[`${a.asset.collectionId}/${a.asset.assetId}`]:[])));return e.filter((s)=>!r.has(Er(s)))}let i=new Set(t.find((r)=>r.projectId===n)?.inventory.flatMap((r)=>r.asset?[`${r.asset.collectionId}/${r.asset.assetId}/${r.asset.revisionId}`]:[])??[]);return e.filter((r)=>i.has(`${Er(r)}/${r.manifest.revisionId}`))}var Be=(e)=>document.getElementById(e),ft=(e,t,n)=>{let i=document.createElement(e);if(t!==void 0)i.textContent=t;if(n)i.className=n;return i},jl=[],Vl=[],na=[],Ba=[],kf="",ea,Tr,wn,Qs=0,XR=0,Bl=!1,zl=!1,ta=new Set,Ab=[],qR=[],Kr=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,Eb=(e)=>{Be("status").textContent=e},Ar=(e)=>Eb(e instanceof Error?e.message:String(e)),za=(e,t,n=Ab)=>{let i=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(i),i};async function Tb(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function vb(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/${Kr(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function LB(e,t){if(e.local){if(t==="editable.zip")return za(lp([e.local]),"application/zip");return za(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return za(e.loose,"model/gltf-binary");return`/files/${Kr(e)}/${t}?download`}function JR(e,t){try{localStorage.setItem(e,t)}catch{}}function FB(e){try{return localStorage.getItem(e)}catch{return null}}function UB(){let e=Be("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...jl,...Ba.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=ft("button",t.label,kf===t.id?"active":"");n.onclick=()=>void nc(t.id).catch(Ar),e.append(n)}}async function nc(e,t=!0){if(t)YR.library();let n=++XR;kf=e,ta.clear(),UB(),Eb("");let i=e==="all"?await(async()=>{let r=await Tb("/api/library");if(r.errors.length)Eb(r.errors.map((s)=>`${s.collectionId}: ${s.message}`).join(" · "));return r.entries.map((s)=>({collection:s.collectionId,manifest:s.manifest}))})():e==="opened-files"?Ba:(await Tb(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((r)=>({collection:e,manifest:r}));if(n!==XR)return;na=i,JR("kiln.collection",e),Be("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":jl.find((r)=>r.id===e)?.label??e,Be("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",Df()}function BB(){let e=new Map;for(let t of WR(na,Vl,Be("library-project").value)){let n=Er(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,i)=>i.manifest.createdAt.localeCompare(n.manifest.createdAt)||i.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===FB(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function Df(){for(let i of qR.splice(0))URL.revokeObjectURL(i);let e=Be("cards");e.replaceChildren();let t=Be("search").value.toLowerCase(),n=BB().filter((i)=>`${i.manifest.name} ${i.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(Be("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,Be("export-selection").disabled=!ta.size,!n.length){let i=ft("div",void 0,"empty");if(i.append(ft("b",t?"No matching assets":"Your next idea belongs here."),ft("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)i.append(ft("code",'kiln save asset.kiln.js --name "My asset"'));e.append(i);return}for(let i of n){let r=i.manifest,s=ft("article",void 0,"card"),a=ft("button",void 0,"card-open");a.setAttribute("aria-label",`View ${r.name}`),a.onclick=()=>void Hl(i).catch(Ar);let o=ft("div",void 0,"thumb");if(r.files["preview.png"]){let b=ft("img");b.loading="lazy",b.alt=r.name,b.src=i.local?za(i.local.files["preview.png"],"image/png",qR):`/files/${Kr(i)}/preview.png`,b.onerror=()=>{b.remove(),o.textContent="◇"},o.append(b)}else o.textContent="◇";let c=ft("div",void 0,"card-content");c.append(ft("span",r.name,"card-title"));let l=na.filter((b)=>Er(b)===Er(i)),u=new Set(l.map((b)=>b.manifest.parentRevision)),d=l.filter((b)=>!u.has(b.manifest.revisionId));c.append(ft("span",`${r.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${d.length>1?` · ${d.length} branches`:""}`,"card-meta"));let f=ft("div",void 0,"tags");for(let b of r.tags)f.append(ft("span",b,"tag"));c.append(f),c.append(ft("small",jl.find((b)=>b.id===i.collection)?.label??i.collection,"card-meta"));let h=Vl.filter((b)=>b.inventory.some((m)=>m.asset&&m.asset.collectionId===i.collection&&m.asset.assetId===r.assetId));if(c.append(ft("small",h.length?h.map((b)=>b.name).join(" · "):"No project membership","card-meta")),a.append(o,c),s.append(a),!i.loose){let b=ft("input");b.type="checkbox",b.className="selection",b.checked=ta.has(Kr(i)),b.setAttribute("aria-label",`Select ${r.name}`),b.onchange=()=>{if(b.checked)ta.add(Kr(i));else ta.delete(Kr(i));Be("export-selection").disabled=!ta.size},s.append(b)}e.append(s)}}async function Hl(e){let t=++Qs;ea=e,Tr=void 0,wn?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),Be("library-performance").replaceChildren(),JR(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of Ab.splice(0))URL.revokeObjectURL(u);let n=Be("detail");if(!n.open)n.showModal();Be("asset-name").textContent=e.manifest.name;let i=Be("asset-membership");if(i.replaceChildren(),!e.local&&!e.loose){let u=ft("div");i.append(u),Ul(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,YR.refreshProjects).catch(Ar)}let r=Be("revisions");r.replaceChildren();for(let u of na.filter((d)=>Er(d)===Er(e))){let d=ft("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);d.value=u.manifest.revisionId,d.selected=u.manifest.revisionId===e.manifest.revisionId,r.append(d)}r.onchange=()=>{let u=na.find((d)=>Er(d)===Er(e)&&d.manifest.revisionId===r.value);if(u)Hl(u).catch(Ar)},Be("asset-description").textContent=e.manifest.description??e.manifest.brief??(e.manifest.editable?"Source travels with this revision. Download the editable bundle to continue elsewhere.":"This GLB has no saved Kiln source. You can view and use the model.");let s=Be("asset-attribution");s.replaceChildren();for(let u of hE(e.manifest)){let d=ft("div");d.append(ft("span",u.label),ft("strong",u.value)),s.append(d)}s.hidden=!s.childElementCount;let a=document.getElementById("asset-material-inputs");if(!a)a=ft("section",void 0,"asset-material-inputs"),a.id="asset-material-inputs",s.after(a);a.replaceChildren();try{let u=Lc({manifest:e.manifest,files:{}});if(u.length){a.append(ft("h3","Exact material build inputs"),ft("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let d of u){let f=ft("a",`${d.name} · ${d.materialId}`);f.href=Nf(d),f.target="_blank",f.rel="noopener",a.append(f,ft("p",d.revisionId,"mono"))}}}catch(u){a.append(ft("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}Be("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=Be("downloads");o.replaceChildren();for(let[u,d]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let f=ft("a",d);f.href=LB(e,u),f.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,o.append(f)}if(!e.loose){let u=ft("button","Runtime GLB"),d=ft("span");d.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,d.textContent="Preparing runtime download…";try{let f=e.local?await RR(e.local,{profile:"runtime"}):void 0,[h,b]=f?.profile==="runtime"?[f.glb,f.metadata.bytes]:await Promise.all([vb(e,"runtime.glb"),vb(e,"runtime.kiln-metadata.json")]);if(t!==Qs)return;let m=ft("a","Runtime GLB");m.href=za(h,"model/gltf-binary"),m.download="runtime.glb";let g=ft("a","Runtime metadata");g.href=za(b,"application/json"),g.download="runtime.kiln-metadata.json",u.replaceWith(m,g),d.textContent="Keep the companion metadata for traceability.",m.click()}catch(f){if(t!==Qs)return;d.textContent=`Runtime export unavailable: ${f instanceof Error?f.message:f}`,u.disabled=!1}},o.append(u,d),o.append(ft("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}Be("refine").disabled=!e.manifest.editable,Be("asset-stats").replaceChildren(),Be("stage-status").textContent="Loading saved GLB…",Bl=!1,zl=!1,Be("wire").setAttribute("aria-pressed","false"),Be("play").textContent="Pause";let c=Be("animation");c.replaceChildren(new Option("Rest pose","")),Be("play").disabled=!0;let l=Be("level");l.replaceChildren(),l.hidden=!0,Be("library-lod").replaceChildren(),Be("library-lod").hidden=!0;try{wn??=El(Be("stage"));let u=await vb(e,"asset.glb");if(t!==Qs)return;let d=await wn.load(u,{isCurrent:()=>t===Qs,onCommit:()=>{Tr=e}});if(!d||t!==Qs)return;Tr=e,wn.wire(!1),wn.navigation(Be("library-navigation").value),wn.lighting(Be("lighting").value),Tl(l,Be("library-lod"),wn);for(let[f,h]of[...d.levels?d.levels.map((b,m)=>[b.toLocaleString(),`LOD${m} triangles`]):[[d.triangles.toLocaleString(),"triangles"]],[d.meshes,d.levels?"LOD0 meshes":"meshes"],[d.materials,d.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let b=ft("div");b.append(ft("strong",String(f)),ft("span",String(h))),Be("asset-stats").append(b)}for(let f=0;f<d.clips.length;f++)c.append(new Option(d.clips[f],String(f)));Be("stage-status").textContent=""}catch(u){if(t===Qs)wn?.dispose(),wn=void 0,Be("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function ZR(e){for(let t of e){if(t.bytes.length>Wn)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of fE(t.bytes)){for(let[i,r]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(r)))).map((a)=>a.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[i]?.sha256)throw Error(`Bundle integrity failure: ${i}`);if(!Ba.some((i)=>i.manifest.revisionId===n.manifest.revisionId&&i.manifest.assetId===n.manifest.assetId))Ba.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Ba.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 nc("opened-files")}Be("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>Wn))throw Error("File exceeds 64 MiB");await ZR(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){Ar(t)}};Be("refresh").onclick=()=>void nc(kf).catch(Ar);Be("search").oninput=Df;Be("library-project").onchange=()=>void nc("all").catch(Ar);Be("close-detail").onclick=()=>Be("detail").close();Be("detail").addEventListener("close",()=>{Qs++,Tr=void 0,wn?.dispose(),wn=void 0;for(let e of Ab.splice(0))URL.revokeObjectURL(e);Df()});Be("frame").onclick=()=>wn?.reset();Be("wire").onclick=()=>{Bl=!Bl,wn?.wire(Bl),Be("wire").setAttribute("aria-pressed",String(Bl))};Be("lighting").onchange=(e)=>wn?.lighting(e.target.value);Be("library-navigation").onchange=(e)=>{let t=e.target.value;wn?.navigation(t),Be("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};Be("animation").onchange=(e)=>{let t=e.target.value;wn?.clip(t===""?-1:Number(t)),Be("play").disabled=t===""};Be("play").onclick=()=>{zl=!zl,wn?.pause(zl),Be("play").textContent=zl?"Play":"Pause"};Be("refine").onclick=async()=>{if(!ea)return;let e=ea.manifest,t=ea.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=${ea.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=${ea.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),Be("refine").textContent="Instructions copied"}catch{Be("provenance").textContent=t,Be("provenance").parentElement?.setAttribute("open","")}};Be("export-selection").onclick=()=>{try{let e=ft("a");if(kf==="opened-files")e.href=za(lp(na.filter((t)=>ta.has(Kr(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of ta)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){Ar(e)}};async function zB(){jl=(await Tb("/api/collections")).collections;let e=Nw(location.search);if(await nc(jl.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=na.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Hl(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await ZR([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),Ba.length===1)await Hl(Ba[0])}}var YR=KR((e)=>{(async()=>{await nc(e.collectionId);let t=na.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Hl(t)})().catch(Ar)},(e)=>{Vl=e;let t=Be("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let i of Vl)t.append(new Option(i.name,i.projectId));if(n==="standalone"||Vl.some((i)=>i.projectId===n))t.value=n;Df()});Of(Be("measure-library"),Be("library-performance"),()=>wn,()=>Tr&&ea&&Kr(Tr)===Kr(ea)?{collection:Tr.collection,assetId:Tr.manifest.assetId,revisionId:Tr.manifest.revisionId,glbSha256:Tr.manifest.files["asset.glb"]?.sha256}:void 0);zB().catch(Ar);
+*/var Zt=Uint8Array,sr=Uint16Array,ap=Int32Array,Ou=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ku=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Qh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),L0=function(e,t){var n=new sr(31);for(var r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new ap(n[30]);for(var r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},D0=L0(Ou,2),{b:F0,r:ep}=D0;F0[28]=258,ep[258]=28;var U0=L0(ku,0),{b:FC,r:I0}=U0,tp=new sr(32768);for(mt=0;mt<32768;++mt)ni=(mt&43690)>>1|(mt&21845)<<1,ni=(ni&52428)>>2|(ni&13107)<<2,ni=(ni&61680)>>4|(ni&3855)<<4,tp[mt]=((ni&65280)>>8|(ni&255)<<8)>>1;var ni,mt,ii=function(e,t,n){var r=e.length,i=0,a=new sr(t);for(;i<r;++i)if(e[i])++a[e[i]-1];var s=new sr(t);for(i=1;i<t;++i)s[i]=s[i-1]+a[i-1]<<1;var o;if(n){o=new sr(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i]){var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u;for(var f=d|(1<<u)-1;d<=f;++d)o[tp[d]>>c]=l}}else{o=new sr(r);for(i=0;i<r;++i)if(e[i])o[i]=tp[s[e[i]-1]++]>>15-e[i]}return o},sa=new Zt(288);for(mt=0;mt<144;++mt)sa[mt]=8;var mt;for(mt=144;mt<256;++mt)sa[mt]=9;var mt;for(mt=256;mt<280;++mt)sa[mt]=7;var mt;for(mt=280;mt<288;++mt)sa[mt]=8;var mt,Rc=new Zt(32);for(mt=0;mt<32;++mt)Rc[mt]=5;var mt,UC=ii(sa,9,0),zC=ii(sa,9,1),BC=ii(Rc,5,0),jC=ii(Rc,5,1),qh=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},Or=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Jh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},sp=function(e){return(e+7)/8|0},Ic=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Zt(e.subarray(t,n))};var VC=["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"],jn=function(e,t,n){var r=Error(t||VC[e]);if(r.code=e,Error.captureStackTrace)Error.captureStackTrace(r,jn);if(!n)throw r;return r},GC=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new Zt(0);var s=!n,o=s||t.i!=2,c=t.i;if(s)n=new Zt(i*3);var l=function(ce){var ve=n.length;if(ce>ve){var Re=new Zt(Math.max(ve*2,ce));Re.set(n),n=Re}},u=t.f||0,d=t.p||0,f=t.b||0,{l:h,d:b,m,n:g}=t,p=i*8;do{if(!h){u=Or(e,d,1);var y=Or(e,d+1,3);if(d+=3,!y){var v=sp(d)+4,x=e[v-4]|e[v-3]<<8,_=v+x;if(_>i){if(c)jn(0);break}if(o)l(f+x);n.set(e.subarray(v,_),f),t.b=f+=x,t.p=d=_*8,t.f=u;continue}else if(y==1)h=zC,b=jC,m=9,g=5;else if(y==2){var E=Or(e,d,31)+257,w=Or(e,d+10,15)+4,A=E+Or(e,d+5,31)+1;d+=14;var T=new Zt(A),N=new Zt(19);for(var M=0;M<w;++M)N[Qh[M]]=Or(e,d+M*3,7);d+=w*3;var R=qh(N),k=(1<<R)-1,C=ii(N,R,1);for(var M=0;M<A;){var U=C[Or(e,d,k)];d+=U&15;var v=U>>4;if(v<16)T[M++]=v;else{var D=0,P=0;if(v==16)P=3+Or(e,d,3),d+=2,D=T[M-1];else if(v==17)P=3+Or(e,d,7),d+=3;else if(v==18)P=11+Or(e,d,127),d+=7;while(P--)T[M++]=D}}var K=T.subarray(0,E),z=T.subarray(E);m=qh(K),g=qh(z),h=ii(K,m,1),b=ii(z,g,1)}else jn(1);if(d>p){if(c)jn(0);break}}if(o)l(f+131072);var W=(1<<m)-1,q=(1<<g)-1,le=d;for(;;le=d){var D=h[Jh(e,d)&W],he=D>>4;if(d+=D&15,d>p){if(c)jn(0);break}if(!D)jn(2);if(he<256)n[f++]=he;else if(he==256){le=d,h=null;break}else{var xe=he-254;if(he>264){var M=he-257,pe=Ou[M];xe=Or(e,d,(1<<pe)-1)+F0[M],d+=pe}var J=b[Jh(e,d)&q],F=J>>4;if(!J)jn(3);d+=J&15;var z=FC[F];if(F>3){var pe=ku[F];z+=Jh(e,d)&(1<<pe)-1,d+=pe}if(d>p){if(c)jn(0);break}if(o)l(f+131072);var X=f+xe;if(f<z){var ne=a-z,re=Math.min(z,X);if(ne+f<0)jn(3);for(;f<re;++f)n[f]=r[ne+f]}for(;f<X;++f)n[f]=n[f-z]}}if(t.l=h,t.p=le,t.b=f,t.f=u,h)u=1,t.m=m,t.d=b,t.n=g}while(!u);return f!=n.length&&s?Ic(n,0,f):n.subarray(0,f)},Ni=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Mc=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Zh=function(e,t){var n=[];for(var r=0;r<e.length;++r)if(e[r])n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:B0,l:0};if(i==1){var s=new Zt(n[0].s+1);return s[n[0].s]=1,{t:s,l:1}}n.sort(function(_,E){return _.f-E.f}),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:o.f+c.f,l:o,r:c};while(u!=i-1)o=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var f=a[0].s;for(var r=1;r<i;++r)if(a[r].s>f)f=a[r].s;var h=new sr(f+1),b=np(n[u-1],h,0);if(b>t){var r=0,m=0,g=b-t,p=1<<g;a.sort(function(E,w){return h[w.s]-h[E.s]||E.f-w.f});for(;r<i;++r){var y=a[r].s;if(h[y]>t)m+=p-(1<<b-h[y]),h[y]=t;else break}m>>=g;while(m>0){var v=a[r].s;if(h[v]<t)m-=1<<t-h[v]++-1;else++r}for(;r>=0&&m;--r){var x=a[r].s;if(h[x]==t)--h[x],++m}b=t}return{t:new Zt(h),l:b}},np=function(e,t,n){return e.s==-1?Math.max(np(e.l,t,n+1),np(e.r,t,n+1)):t[e.s]=n},C0=function(e){var t=e.length;while(t&&!e[--t]);var n=new sr(++t),r=0,i=e[0],a=1,s=function(c){n[r++]=c};for(var o=1;o<=t;++o)if(e[o]==i&&o!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)s(32754);if(a>2)s(a>10?a-11<<5|28690:a-3<<5|12305),a=0}else if(a>3){s(i),--a;for(;a>6;a-=6)s(8304);if(a>2)s(a-3<<5|8208),a=0}while(a--)s(i);a=1,i=e[o]}return{c:n.subarray(0,r),n:t}},Sc=function(e,t){var n=0;for(var r=0;r<t.length;++r)n+=e[r]*t[r];return n},z0=function(e,t,n){var r=n.length,i=sp(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},N0=function(e,t,n,r,i,a,s,o,c,l,u){Ni(t,u++,n),++i[256];var d=Zh(i,15),{t:f,l:h}=d,b=Zh(a,15),{t:m,l:g}=b,p=C0(f),{c:y,n:v}=p,x=C0(m),{c:_,n:E}=x,w=new sr(19);for(var A=0;A<y.length;++A)++w[y[A]&31];for(var A=0;A<_.length;++A)++w[_[A]&31];var T=Zh(w,7),{t:N,l:M}=T,R=19;for(;R>4&&!N[Qh[R-1]];--R);var k=l+5<<3,C=Sc(i,sa)+Sc(a,Rc)+s,U=Sc(i,f)+Sc(a,m)+s+14+3*R+Sc(w,N)+2*w[16]+3*w[17]+7*w[18];if(c>=0&&k<=C&&k<=U)return z0(t,u,e.subarray(c,c+l));var D,P,K,z;if(Ni(t,u,1+(U<C)),u+=2,U<C){D=ii(f,h,0),P=f,K=ii(m,g,0),z=m;var W=ii(N,M,0);Ni(t,u,v-257),Ni(t,u+5,E-1),Ni(t,u+10,R-4),u+=14;for(var A=0;A<R;++A)Ni(t,u+3*A,N[Qh[A]]);u+=3*R;var q=[y,_];for(var le=0;le<2;++le){var he=q[le];for(var A=0;A<he.length;++A){var xe=he[A]&31;if(Ni(t,u,W[xe]),u+=N[xe],xe>15)Ni(t,u,he[A]>>5&127),u+=he[A]>>12}}}else D=UC,P=sa,K=BC,z=Rc;for(var A=0;A<o;++A){var pe=r[A];if(pe>255){var xe=pe>>18&31;if(Mc(t,u,D[xe+257]),u+=P[xe+257],xe>7)Ni(t,u,pe>>23&31),u+=Ou[xe];var J=pe&31;if(Mc(t,u,K[J]),u+=z[J],J>3)Mc(t,u,pe>>5&8191),u+=ku[J]}else Mc(t,u,D[pe]),u+=P[pe]}return Mc(t,u,D[256]),u+P[256]},HC=new ap([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),B0=new Zt(0),$C=function(e,t,n,r,i,a){var s=a.z||e.length,o=new Zt(r+s+5*(1+Math.ceil(s/7000))+i),c=o.subarray(r,o.length-i),l=a.l,u=(a.r||0)&7;if(t){if(u)c[0]=a.r>>3;var d=HC[t-1],f=d>>13,h=d&8191,b=(1<<n)-1,m=a.p||new sr(32768),g=a.h||new sr(b+1),p=Math.ceil(n/3),y=2*p,v=function(ke){return(e[ke]^e[ke+1]<<p^e[ke+2]<<y)&b},x=new ap(25000),_=new sr(288),E=new sr(32),w=0,A=0,T=a.i||0,N=0,M=a.w||0,R=0;for(;T+2<s;++T){var k=v(T),C=T&32767,U=g[k];if(m[C]=U,g[k]=C,M<=T){var D=s-T;if((w>7000||N>24576)&&(D>423||!l)){u=N0(e,c,0,x,_,E,A,N,R,T-R,u),N=w=A=0,R=T;for(var P=0;P<286;++P)_[P]=0;for(var P=0;P<30;++P)E[P]=0}var K=2,z=0,W=h,q=C-U&32767;if(D>2&&k==v(T-q)){var le=Math.min(f,D)-1,he=Math.min(32767,T),xe=Math.min(258,D);while(q<=he&&--W&&C!=U){if(e[T+K]==e[T+K-q]){var pe=0;for(;pe<xe&&e[T+pe]==e[T+pe-q];++pe);if(pe>K){if(K=pe,z=q,pe>le)break;var J=Math.min(q,pe-2),F=0;for(var P=0;P<J;++P){var X=T-q+P&32767,ne=m[X],re=X-ne&32767;if(re>F)F=re,U=X}}}C=U,U=m[C],q+=C-U&32767}}if(z){x[N++]=268435456|ep[K]<<18|I0[z];var ce=ep[K]&31,ve=I0[z]&31;A+=Ou[ce]+ku[ve],++_[257+ce],++E[ve],M=T+K,++w}else x[N++]=e[T],++_[e[T]]}}for(T=Math.max(T,M);T<s;++T)x[N++]=e[T],++_[e[T]];if(u=N0(e,c,l,x,_,E,A,N,R,T-R,u),!l)a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=m,a.i=T,a.w=M}else{for(var T=a.w||0;T<s+l;T+=65535){var Re=T+65535;if(Re>=s)c[u/8|0]=l,Re=s;u=z0(c,u+1,e.subarray(T,Re))}a.i=s}return Ic(o,0,r+sp(u)+i)},KC=function(){var e=new Int32Array(256);for(var t=0;t<256;++t){var n=t,r=9;while(--r)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),WC=function(){var e=-1;return{p:function(t){var n=e;for(var r=0;r<t.length;++r)n=KC[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}};var XC=function(e,t,n,r,i){if(!i){if(i={l:1},t.dictionary){var a=t.dictionary.subarray(-32768),s=new Zt(a.length+e.length);s.set(a),s.set(e,a.length),e=s,i.w=a.length}}return $C(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},j0=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n};var ri=function(e,t){return e[t]|e[t+1]<<8},kr=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Yh=function(e,t){return kr(e,t)+kr(e,t+4)*4294967296},Sn=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function qC(e,t){return XC(e,t||{},0,0)}function JC(e,t){return GC(e,{i:2},t&&t.out,t&&t.dictionary)}var V0=function(e,t,n,r){for(var i in e){var a=e[i],s=t+i,o=r;if(Array.isArray(a))o=j0(r,a[1]),a=a[0];if(a instanceof Zt)n[s]=[a,o];else n[s+="/"]=[new Zt(0),o],V0(a,s,n,r)}},P0=typeof TextEncoder<"u"&&new TextEncoder,rp=typeof TextDecoder<"u"&&new TextDecoder,ZC=0;try{rp.decode(B0,{stream:!0}),ZC=1}catch(e){}var YC=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Ic(e,n-1)};if(!i)t+=String.fromCharCode(r);else if(i==3)r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023);else if(i&1)t+=String.fromCharCode((r&31)<<6|e[n++]&63);else t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63)}};function O0(e,t){if(t){var n=new Zt(e.length);for(var r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(P0)return P0.encode(e);var i=e.length,a=new Zt(e.length+(e.length>>1)),s=0,o=function(u){a[s++]=u};for(var r=0;r<i;++r){if(s+5>a.length){var c=new Zt(s+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);if(l<128||t)o(l);else if(l<2048)o(192|l>>6),o(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++r)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63);else o(224|l>>12),o(128|l>>6&63),o(128|l&63)}return Ic(a,0,s)}function QC(e,t){if(t){var n="";for(var r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else if(rp)return rp.decode(e);else{var i=YC(e),{s:a,r:n}=i;if(n.length)jn(8);return a}}var eN=function(e,t){return t+30+ri(e,t+26)+ri(e,t+28)},tN=function(e,t,n){var r=ri(e,t+28),i=QC(e.subarray(t+46,t+46+r),!(ri(e,t+8)&2048)),a=t+46+r,s=kr(e,t+20),o=n&&s==4294967295?nN(e,a):[s,kr(e,t+24),kr(e,t+42)],c=o[0],l=o[1],u=o[2];return[ri(e,t+10),c,l,i,a+ri(e,t+30)+ri(e,t+32),u]},nN=function(e,t){for(;ri(e,t)!=1;t+=4+ri(e,t+2));return[Yh(e,t+12),Yh(e,t+4),Yh(e,t+20)]},ip=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;if(r>65535)jn(9);t+=r+4}return t},k0=function(e,t,n,r,i,a,s,o){var c=r.length,l=n.extra,u=o&&o.length,d=ip(l);if(Sn(e,t,s!=null?33639248:67324752),t+=4,s!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),h=f.getFullYear()-1980;if(h<0||h>119)jn(10);if(Sn(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1)Sn(e,t,n.crc),Sn(e,t+4,a<0?-a-2:a),Sn(e,t+8,n.size);if(Sn(e,t+12,c),Sn(e,t+14,d),t+=16,s!=null)Sn(e,t,u),Sn(e,t+6,n.attrs),Sn(e,t+10,s),t+=14;if(e.set(r,t),t+=c,d)for(var b in l){var m=l[b],g=m.length;Sn(e,t,+b),Sn(e,t+2,g),e.set(m,t+4),t+=4+g}if(u)e.set(o,t),t+=u;return t},rN=function(e,t,n,r,i){Sn(e,t,101010256),Sn(e,t+8,n),Sn(e,t+10,n),Sn(e,t+12,r),Sn(e,t+16,i)};function G0(e,t){if(!t)t={};var n={},r=[];V0(e,"",n,t);var i=0,a=0;for(var s in n){var o=n[s],c=o[0],l=o[1],u=l.level==0?0:8,d=O0(s),f=d.length,h=l.comment,b=h&&O0(h),m=b&&b.length,g=ip(l.extra);if(f>65535)jn(11);var p=u?qC(c,l):c,y=p.length,v=WC();v.p(c),r.push(j0(l,{size:c.length,crc:v.d(),c:p,f:d,m:b,u:f!=s.length||b&&h.length!=m,o:i,compression:u})),i+=30+f+g+y,a+=76+2*(f+g)+(m||0)+y}var x=new Zt(a+22),_=i,E=a-i;for(var w=0;w<r.length;++w){var d=r[w];k0(x,d.o,d,d.f,d.u,d.c.length);var A=30+d.f.length+ip(d.extra);x.set(d.c,d.o+A),k0(x,i,d,d.f,d.u,d.c.length,d.o,d.m),i+=16+A+(d.m?d.m.length:0)}return rN(x,i,r.length,E,_),x}function H0(e,t){var n={},r=e.length-22;for(;kr(e,r)!=101010256;--r)if(!r||e.length-r>65558)jn(13);var i=ri(e,r+8);if(!i)return{};var a=kr(e,r+16),s=a==4294967295||i==65535;if(s){var o=kr(e,r-12);if(s=kr(e,o)==101075792,s)i=kr(e,o+32),a=kr(e,o+48)}var c=t&&t.filter;for(var l=0;l<i;++l){var u=tN(e,a,s),d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=u[5],p=eN(e,g);if(a=m,!c||c({name:b,size:f,originalSize:h,compression:d}))if(!d)n[b]=Ic(e,p,p+f);else if(d==8)n[b]=JC(e.subarray(p,p+f),{out:new Zt(h)});else jn(14,"unknown compression type "+d)}return n}ro();Gu();Cc();$u();Wu();ro();Gu();Wu();Cc();$u();Nc();var RN=(()=>{let e=He().int().min(0).max(16777215),t=He().int().min(1).max(ki),n=He().min(-36000).max(36000),r=He().min(0).max(1),i={blend:wt(["normal","multiply","screen","overlay"]),opacity:r};return ge({schemaVersion:Ge(2),size:He().int().min(Du).max(Lu),usage:wt(ai),name:Fe().min(1).max(80).optional(),layers:at(Pr("op",[ge({op:Ge("solid"),color:e,...i}).strict(),ge({op:Ge("checker"),colorA:e,colorB:e,squares:t,...i}).strict(),ge({op:Ge("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...i}).strict(),ge({op:Ge("gradient"),from:e,to:e,angleDeg:n,...i}).strict(),ge({op:Ge("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:r,stagger:r,...i}).strict(),ge({op:Ge("noise"),colorA:e,colorB:e,scale:t,octaves:He().int().min(1).max(cp),seed:He().int().min(-2147483648).max(2147483647),...i}).strict(),ge({op:Ge("cellular"),colorA:e,colorB:e,cellsX:t,cellsY:t,seed:He().int().min(-2147483648).max(2147483647),jitterX:r,jitterY:r,metricX:He().min(Pi).max(Oi),metricY:He().min(Pi).max(Oi),weight:He().min(0).max(eo),feature:wt(ps),range:He().min(0.01).max(8),borderOpen:r,borderWidth:He().min(0.001).max(1),facetSlope:r,facetBlend:He().min(0.001).max(1),...i}).strict()])).min(1).max(Fu)}).strict()})();function uE(e,t=RN){let n=(W,q)=>He().int().min(W).max(q),r=n(0,255),i=n(-4096,4096),a=Iu([i,i]),s=Iu([r,r,r,r]),o=wt(ai),c=OC(["sha256:",Fe().regex(/^[a-f0-9]{64}$/)]),l=Fe().min(1).max(80),u=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),f={width:n(1,4096),height:n(1,4096)},h=ge({x:i,y:i,width:n(1,2048),height:n(1,2048)}).strict(),b=ge({x:n(0,4096),y:n(0,4096),...f}).strict(),m=Pr("kind",[h.extend({kind:Ge("rectangle")}).strict(),h.extend({kind:Ge("ellipse")}).strict(),ge({kind:Ge("polygon"),points:at(a).min(3).max(Bu)}).strict(),ge({kind:Ge("line"),from:a,to:a,width:n(1,2048)}).strict()]),g=ge({op:Ge("paint"),shape:m,rgba:s,opacity:r}).strict(),p=ge({op:Ge("mask"),shape:m,alpha:r,invert:hs()}).strict(),y=ge({op:Ge("stamps"),shape:m,rgba:s,opacity:r,count:n(1,Dc),seed:n(0,4294967295),area:h,periodic:hs()}).strict(),v=ge({op:Ge("legacy-v2"),spec:e,alpha:r,opacity:r}).strict(),x=ge({colors:at(n(0,16777215)).min(1).max(ju),dither:wt(["none","bayer4"])}).strict(),_={schemaVersion:Ge(3),width:n(4,Fc),height:n(4,Fc),usage:o,name:l.optional(),background:s},E=ge({..._,operations:at(Pr("op",[g,p,y,v.extend({spec:t})])).max(Uc),palette:x.optional()}).strict(),w=ge({..._,usage:o.optional(),background:s.optional(),operations:at(Pr("op",[g.partial({opacity:!0}),p.partial({alpha:!0,invert:!0}),y.partial({opacity:!0,periodic:!0}),v.partial({alpha:!0,opacity:!0})])).max(Uc),palette:x.partial({dither:!0}).optional()}).strict(),A=ge({minFilter:wt(dp),magFilter:wt(fp),wrapS:wt(zc),wrapT:wt(zc)}).strict(),T=ge({resourceId:u,revisionId:c,sha256:c}).strict(),N=ge({kind:Ge("resource"),resourceId:d,pin:T,expected:ge({...f,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),M=ge({name:u,content:b,gutter:n(0,32),edgeMode:wt(["copy-edge","mask-rgb-dilate"]),source:Pr("kind",[ge({kind:Ge("procedural"),spec:E}).strict(),N]),crop:b.optional(),packed:Ge(!0).optional()}).strict(),R={schemaVersion:Ge(1),width:n(4,Di.edge),height:n(4,Di.edge),usage:o,sampler:A},k=Qs(pp.map((W)=>Ge(W))),C=ge({...R,regions:at(M).min(1).max(Di.regions),pack:ge({edge:k,gutter:n(0,32),algorithm:Ge("maxrects")}).strict().optional()}).strict(),U=ge({...R,width:R.width.optional(),height:R.height.optional(),pack:ge({edge:k,gutter:n(0,32).optional(),algorithm:Ge("maxrects").optional()}).strict().optional(),sampler:A.optional(),regions:at(M.extend({source:Pr("kind",[ge({kind:Ge("procedural"),spec:w}).strict(),N])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Di.regions)}).strict(),D=ge({materialId:u,revisionId:c,resourceId:d,slot:wt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:o,colorSpace:wt(["srgb","linear"]),...f,encodedByteLength:n(1,gs.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:Fe().min(1).max(1024),...f,decodedPixelHash:c},K=Pr("kind",[ge({...P,kind:Ge("procedural"),recipeHash:c,compilerId:Ge(io)}).strict(),ge({...P,kind:Ge("resource"),descriptor:D}).strict()]),z=ge({version:Ge("kiln.atlas-manifest.v1"),compilerId:wt(Ku),width:R.width,height:R.height,usage:o,origin:Ge("top-left"),sampler:A,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:at(K).min(1).max(Di.sources),regions:at(ge({name:u,content:b,allocation:b,crop:b,sourceId:Fe().min(1).max(1024)}).strict()).min(1).max(Di.regions),manifestHash:c}).strict();return{portableSamplerSchema:A,proceduralTextureSpecV3Schema:w,canonicalProceduralTextureSpecV3Schema:E,textureAtlasSpecV1Schema:U,canonicalTextureAtlasSpecV1Schema:C,textureAtlasManifestV1Schema:z,materialMapPinSchema:T,verifiedPinnedMaterialMapDescriptorSchema:D}}var Pn=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),fE=["baseColor","normal","metallicRoughness","emissive","occlusion"],hE={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var so=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Xn=Fe().regex(/^sha256:[a-f0-9]{64}$/),Hn=Fe().min(1).max(1000),dE=Fe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),IN=ge({program:ge({name:Hn,version:Hn,sha256:Xn}).strict(),toolkit:at(ge({name:Hn,sha256:Xn}).strict()).max(32),seed:He().int().optional(),runtimes:at(ge({name:Hn,version:Hn}).strict()).min(1).max(32)}).strict(),pE=ge({id:so,kind:wt(["external","procedural","generated"]),provider:Hn,creator:Hn,assetId:Hn.optional(),assetUrl:dE.optional(),accessedAt:Fe().datetime().optional(),license:ge({spdx:Hn,url:dE,attribution:Fe().max(4000)}).strict(),generator:IN.optional(),originalFiles:at(ge({name:Fe().min(1).max(200),sha256:Xn,bytes:He().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(e.kind==="generated"&&(!e.generator||!e.originalFiles.length))t.addIssue({code:"custom",message:"Generated materials require a generator record and original file hashes"});if(e.kind!=="generated"&&e.generator)t.addIssue({code:"custom",message:"Only a generated material source carries a generator record"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),mE=ge({operation:Hn,tool:Hn,version:Hn,parameters:Cu(Fe().max(100),Qs([Fe().max(2000),He().finite(),hs()])).optional()}).strict(),lr=He().int().min(0).max(16777215),xs=He().int().min(1).max(256),ys={blend:wt(["normal","multiply","screen","overlay"]).default("normal"),opacity:He().min(0).max(1).default(1)},Gc=ge({schemaVersion:Ge(2),size:He().int().min(4).max(1024).default(256),usage:wt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Fe().min(1).max(80).optional(),layers:at(Pr("op",[ge({op:Ge("solid"),color:lr,...ys}).strict(),ge({op:Ge("checker"),colorA:lr,colorB:lr,squares:xs.default(8),...ys}).strict(),ge({op:Ge("stripes"),colorA:lr,colorB:lr,count:xs.default(8),angleDeg:He().min(-36000).max(36000).default(0),...ys}).strict(),ge({op:Ge("gradient"),from:lr,to:lr,angleDeg:He().min(-36000).max(36000).default(0),...ys}).strict(),ge({op:Ge("bricks"),brick:lr,mortar:lr,rows:xs.default(8),cols:xs.default(4),mortarWidth:He().min(0).max(1).default(0.06),stagger:He().min(0).max(1).default(0.5),...ys}).strict(),ge({op:Ge("noise"),colorA:lr,colorB:lr,scale:xs.default(8),octaves:He().int().min(1).max(6).default(3),seed:He().int().min(-2147483648).max(2147483647).default(0),...ys}).strict(),ge({op:Ge("cellular"),colorA:lr,colorB:lr,cellsX:xs.default(8),cellsY:xs.default(8),seed:He().int().min(-2147483648).max(2147483647).default(0),jitterX:He().min(0).max(1).default(1),jitterY:He().min(0).max(1).default(1),metricX:He().min(Pi).max(Oi).default(1),metricY:He().min(Pi).max(Oi).default(1),weight:He().min(0).max(eo).default(0),feature:wt(ps).default("f1"),range:He().min(0.01).max(8).default(1),borderOpen:He().min(0).max(1).default(0.5),borderWidth:He().min(0.001).max(1).default(0.05),facetSlope:He().min(0).max(1).default(0.5),facetBlend:He().min(0.001).max(1).default(0.1),...ys}).strict()])).min(1).max(8)}).strict(),xp=ge({kind:Ge("normal-from-height"),strength:He().finite().positive().max(64)}).strict(),CN=ge({compiler:Ge("kiln.procedural-texture.v2"),spec:Gc,derive:xp.optional(),recipeHash:Xn,pixelHash:Xn,encoder:ge({name:Ge("sharp"),version:Hn}).strict()}).strict(),gE=ge({baseColor:He().int().min(0).max(16777215).optional(),roughness:He().min(0).max(1).default(1),metalness:He().min(0).max(1).default(0),emissive:He().int().min(0).max(16777215).optional(),emissiveIntensity:He().min(0).max(64).default(1),alphaMode:wt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:He().min(0).max(1).default(0.5),doubleSided:hs().default(!1)}).strict(),jc=ge({schemaVersion:Ge(1),materialId:so,revisionId:Xn,parentRevision:Xn.optional(),name:Fe().min(1).max(200),tags:at(Fe().min(1).max(80)).max(30),tileable:hs(),physicalSizeMeters:ge({width:He().finite().positive().max(1e5),height:He().finite().positive().max(1e5)}).strict().optional(),parameters:gE,sources:at(pE).min(1).max(20),maps:at(ge({slot:wt(fE),file:wt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Xn,bytes:He().int().positive().max(Pn.maxMapBytes),width:He().int().positive().max(Pn.maxMapEdge),height:He().int().positive().max(Pn.maxMapEdge),usage:wt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:wt(["srgb","linear"]),normalConvention:Ge("opengl").optional(),channelPacking:Ge("r-occlusion-g-roughness-b-metallic").optional(),sourceId:so,originalFile:Fe().min(1).max(200).optional(),transforms:at(mE).max(30),procedural:CN.optional()}).strict()).min(1).max(5)}).strict(),gp=ge({materialId:so,parentRevision:Xn.optional().describe("The saved revision of this materialId that this one replaces."),name:Fe().min(1).max(200),tags:at(Fe().min(1).max(80)).max(30).optional(),tileable:hs(),physicalSizeMeters:ge({width:He().finite().positive().max(1e5),height:He().finite().positive().max(1e5)}).strict().optional(),parameters:gE.partial().optional(),sources:at(pE).min(1).max(20),maps:at(ge({slot:wt(fE),sourceId:so,transforms:at(mE).max(30),normalConvention:Ge("opengl").optional(),channelPacking:Ge("r-occlusion-g-roughness-b-metallic").optional(),procedural:Gc,derive:xp.optional()}).strict()).min(1).max(5)}).strict(),bp=ge({schemaVersion:Ge(1),records:at(ge({manifest:jc,files:Cu(Fe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Fe().max(Math.ceil(Pn.maxMapBytes/3)*4))}).strict()).max(Pn.maxPayloadRecords)}).strict();function lo(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let r=Array.isArray(e),i=Object.getPrototypeOf(e);if(r?i!==Array.prototype:i!==Object.prototype&&i!==null)throw Error("Material values must have plain JSON prototypes");if(r&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let a of Reflect.ownKeys(e)){if(r&&a==="length")continue;if(typeof a!=="string"||["__proto__","prototype","constructor"].includes(a))throw Error("Material JSON contains a forbidden key");if(r&&(!/^(0|[1-9][0-9]*)$/.test(a)||Number(a)>=e.length))throw Error("Material arrays must contain only indexed data");let s=Object.getOwnPropertyDescriptor(e,a);if(!("value"in s)||!s.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");lo(s.value,t,n+1)}if(r&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Nn(e){lo(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([r],[i])=>r<i?-1:r>i?1:0).map(([r,i])=>[r,t(i)])):n;return JSON.stringify(t(e))}function NN(e){if(lo(e),new TextEncoder().encode(JSON.stringify(e)).length>Pn.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=jc.parse(e);if(new Set(t.sources.map((i)=>i.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((i)=>i.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,r=0;for(let i of t.maps){let a=i.slot==="baseColor"||i.slot==="emissive";if(i.file!==`${i.slot}.png`||i.usage!==hE[i.slot]||i.colorSpace!==(a?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(i.slot==="normal"!==(i.normalConvention==="opengl")||i.slot==="metallicRoughness"!==(i.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let s=t.sources.find((o)=>o.id===i.sourceId);if(!s)throw Error("Material map source is missing");if(i.procedural){if(i.procedural.derive&&i.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Nn(i.procedural.spec)!==Nn(Lc(i.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(s.kind==="generated")throw Error("A recipe map cannot use a generated source; use a procedural source");if(s.kind!=="procedural"||i.originalFile||i.procedural.spec.usage!==i.usage||i.procedural.spec.size!==i.width||i.width!==i.height)throw Error("Procedural material source or map convention mismatch")}else if(s.kind==="procedural"||!s.originalFiles.some((o)=>o.name===i.originalFile))throw Error("Material map must reference an original source file");n+=i.bytes,r+=i.width*i.height}if(n>Pn.maxRecordBytes||r>Pn.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var oo=uE(Gc),co={when:(e)=>!e.issues.length},bE=(e)=>e instanceof Error?e.message:String(e);function Vc(e,t,n){return(r,i)=>{try{let a=t(r);if(n&&Nn(r)!==Nn(a))i.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(a){i.addIssue({code:"custom",message:bE(a)})}}}var xE=oo.portableSamplerSchema.superRefine(Vc("sampler",Hu,!0),co),PN=oo.canonicalProceduralTextureSpecV3Schema.superRefine(Vc("procedural V3 spec",lp,!0),co),ON=oo.canonicalTextureAtlasSpecV1Schema.superRefine(Vc("atlas spec",bs,!0),co),kN=oo.textureAtlasManifestV1Schema,LN=ge({resourceId:so,revisionId:Xn,sha256:Xn}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),DN=Pr("kind",[ge({kind:Ge("procedural"),compilerId:wt(["kiln.procedural-texture.v2",io]),spec:Qs([Gc,PN]),recipeHash:Xn,pixelHash:Xn,encoder:ge({name:Ge("sharp"),version:Hn}).strict(),derive:xp.optional()}).strict(),ge({kind:Ge("atlas"),compilerId:wt(Ku),spec:ON,manifest:kN,encoder:ge({name:Ge("sharp"),version:Hn}).strict()}).strict().superRefine((e,t)=>{try{if(Bc(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${bE(n)}`})}},co)]),yE=jc.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Ge(2),dependencies:at(LN).max(16),maps:at(jc.shape.maps.element.omit({procedural:!0}).extend({sampler:xE,pixelHash:Xn,recipe:DN.optional()}).strict()).min(1).max(5)}).strict(),FN=Pr("schemaVersion",[jc,yE]),UN=bp.extend({schemaVersion:Ge(2),records:at(bp.shape.records.element.extend({manifest:FN}).strict()).max(Pn.maxPayloadRecords)}).strict(),_E=Pr("schemaVersion",[bp,UN]);function vE(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var zN=gp.extend({schemaVersion:Ge(2),maps:at(gp.shape.maps.element.omit({procedural:!0}).extend({sampler:xE,procedural:Qs([Gc,oo.proceduralTextureSpecV3Schema.superRefine(Vc("procedural V3 spec",lp,!1),co)]).optional(),atlas:oo.textureAtlasSpecV1Schema.superRefine(Vc("atlas spec",bs,!1),co).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),mG=Qs([gp,zN]);function uo(e){if(lo(e),new TextEncoder().encode(JSON.stringify(e)).length>Pn.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return NN(e);let t=yE.parse(e);if(new Set(t.sources.map((s)=>s.id)).size!==t.sources.length||new Set(t.maps.map((s)=>s.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,r=0,i=new Map;for(let s of t.maps){let o=t.sources.find((l)=>l.id===s.sourceId);if(!o||s.file!==`${s.slot}.png`||s.usage!==hE[s.slot]||s.colorSpace!==(s.slot==="baseColor"||s.slot==="emissive"?"srgb":"linear")||s.slot==="normal"!==(s.normalConvention==="opengl")||s.slot==="metallicRoughness"!==(s.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=s.recipe;if(c){if(o.kind==="generated")throw Error("A recipe map cannot use a generated source; use a procedural source");if(o.kind!=="procedural"||s.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==io||l.width!==s.width||l.height!==s.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==s.width||s.width!==s.height||Nn(l)!==Nn(Lc(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==s.usage||c.pixelHash!==s.pixelHash||c.derive&&s.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(Bc(c.manifest,c.spec),c.spec.width!==s.width||c.spec.height!==s.height||c.spec.usage!==s.usage||Nn(c.spec.sampler)!==Nn(s.sampler)||c.manifest.decodedPixelHash!==s.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;i.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(o.kind==="procedural"||!o.originalFiles.some((l)=>l.name===s.originalFile))throw Error(`${o.kind==="generated"?"Generated":"External"} material source original file missing`);n+=s.bytes,r+=s.width*s.height}let a=t.dependencies.map((s)=>`${s.resourceId}/${s.revisionId}`);if(new Set(a).size!==a.length||a.length!==i.size||a.some((s)=>!i.has(s)))throw Error("Material dependency pin inventory mismatch");if(n>Pn.maxRecordBytes||r>Pn.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var qn=67108864,yp=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/),BN=Fe().regex(/^sha256:[a-f0-9]{64}$/),EE=ge({version:Ge("kiln.asset.v1"),assetId:yp,revisionId:yp,parentRevision:yp.optional(),name:Fe().min(1).max(200),tags:at(Fe().max(80)).max(30),createdAt:Fe().datetime(),description:Fe().max(4000).optional(),brief:Fe().max(8000).optional(),attribution:ge({model:Fe().max(200).optional(),harness:Fe().max(200).optional(),author:Fe().max(200).optional()}).optional(),editable:hs(),files:Cu(Fe(),ge({sha256:BN,bytes:He().int().nonnegative().max(qn)})),build:ge({engine:Fe(),options:Cu(Fe(),aa()),warnings:at(Fe()),integration:aa().optional(),qa:aa().optional(),composition:aa().optional(),dependencies:at(aa()).optional(),rebuild:wt(["engine-required","external-dependencies-required"])}).optional(),preview:ge({fidelity:aa().optional(),error:Fe().optional(),backdrop:wt(S0).optional()}).optional()}),Hc="materials.kiln.json",AE=25165824;function $c(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let r=n;if(r.kind!=="kiln.material.v1"&&r.kind!=="kiln.material.v2"){if(r.delivery==="runtime")throw Error("Unsupported runtime dependency");if(r.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(r.delivery!=="runtime")throw Error("Invalid saved material dependency");let i=uo(r.manifest);if(r.kind!==`kiln.material.v${i.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let a=`${i.materialId}/${i.revisionId}`,s=t.get(a);if(s&&Nn(s)!==Nn(i))throw Error("Conflicting saved material dependency manifests");if(t.set(a,i),t.size>Pn.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function TE(e,t=!1){let n=$c(e),r=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Nn(d)]));if(!e.materialResources){if(t&&r.size)throw Error("Editable asset material closure unavailable");return}lo(e.materialResources);let i=_E.parse(e.materialResources),a=0,s=0,o=new Map;for(let d of i.records){let f=uo(d.manifest),h=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(o.has(h)||r.has(h)&&r.get(h)!==Nn(f))throw Error("Asset material closure mismatch");if(o.set(h,f),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let b of d.manifest.maps){if(d.files[b.file]?.length!==Math.ceil(b.bytes/3)*4)throw Error("Asset material map size mismatch");a+=b.bytes,s+=b.width*b.height}}if(a>Pn.maxPayloadBytes||s>Pn.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let f=o.get(d);if(!f)throw Error("Asset material closure incomplete");l.add(d);for(let h of vE(f))u(`${h.resourceId}/${h.revisionId}`);l.delete(d),c.add(d)};for(let d of r.keys())u(d);if(c.size!==o.size)throw Error("Asset material closure has unrelated records")}var jN=new Set(["asset.glb","source.kiln.js","preview.png"]);function Xu(e){let t=EE.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 r=0;for(let i of n){if(!jN.has(i)||!t.files[i]||t.files[i].bytes!==e.files[i].length)throw Error("Invalid asset file inventory");r+=e.files[i].length}if(r>qn||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");_p(e.files["asset.glb"]),TE(e)}function _p(e){if(e.length<20||e.length>qn)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 r=JSON.parse(new TextDecoder().decode(e.subarray(20,n)));for(let i of[...r.buffers??[],...r.images??[]])if(i.uri&&!String(i.uri).startsWith("data:"))throw Error("GLB must embed its resources")}function vp(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let r of e){Xu(r),TE(r,!0);let i=`${r.manifest.assetId}/${r.manifest.revisionId}/`;if(t[`${i}manifest.json`])throw Error("Duplicate bundle revision");t[`${i}manifest.json`]=new TextEncoder().encode(JSON.stringify(r.manifest,null,2));for(let[a,s]of Object.entries(r.files))t[i+a]=s;if(r.materialResources){let a=new TextEncoder().encode(JSON.stringify(r.materialResources));if(a.length>AE)throw Error("Asset material payload exceeds byte limit");t[i+Hc]=a}}for(let r of Object.values(t))n+=r.length;if(n>qn)throw Error("Bundle exceeds 64 MiB");return G0(t,{level:0})}function wE(e){if(e.length>qn+1048576)throw Error("Bundle exceeds 64 MiB");let t=0,n=0,r=H0(e,{filter:(s)=>{if(t+=s.originalSize,n++,t>qn||n>500||s.name.endsWith(`/${Hc}`)&&s.originalSize>AE||!/^[a-z][a-z0-9_-]{0,79}\/[a-z][a-z0-9_-]{0,79}\/(manifest\.json|asset\.glb|source\.kiln\.js|preview\.png|materials\.kiln\.json)$/.test(s.name))throw Error("Unsafe or oversized asset bundle");return!0}}),i=[],a=new Set;for(let[s,o]of Object.entries(r)){if(!s.endsWith("/manifest.json"))continue;if(o.length>1048576)throw Error("Manifest exceeds 1 MiB");let c=EE.parse(JSON.parse(new TextDecoder().decode(o))),l=`${c.assetId}/${c.revisionId}/`;if(s!==`${l}manifest.json`)throw Error("Bundle identity mismatch");let u={manifest:c,files:{}};a.add(s);for(let d of Object.keys(c.files)){if(!r[l+d])throw Error("Bundle file missing");u.files[d]=r[l+d],a.add(l+d)}if(r[l+Hc])u.materialResources=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r[l+Hc])),a.add(l+Hc);Xu(u),i.push(u)}if(!i.length||a.size!==Object.keys(r).length)throw Error("Incomplete asset bundle");return i}function ME(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)}Hr();Hr();var YT={type:"change"},Sg={type:"start"},ew={type:"end"},af=new _a,QT=new Ar,LD=Math.cos(70*ll.DEG2RAD),bn=new V,Yn=2*Math.PI,Ot={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Mg=0.000001;class Rg extends Qd{constructor(e,t=null){super(e,t);if(this.state=Ot.NONE,this.target=new V,this.cursor=new V,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:ma.ROTATE,MIDDLE:ma.DOLLY,RIGHT:ma.PAN},this.touches={ONE:ga.ROTATE,TWO:ga.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 V,this._lastQuaternion=new ln,this._lastTargetPosition=new V,this._quat=new ln().setFromUnitVectors(e.up,new V(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Al,this._sphericalDelta=new Al,this._scale=1,this._panOffset=new V,this._rotateStart=new We,this._rotateEnd=new We,this._rotateDelta=new We,this._panStart=new We,this._panEnd=new We,this._panDelta=new We,this._dollyStart=new We,this._dollyEnd=new We,this._dollyDelta=new We,this._dollyDirection=new V,this._mouse=new We,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=FD.bind(this),this._onPointerDown=DD.bind(this),this._onPointerUp=UD.bind(this),this._onContextMenu=$D.bind(this),this._onMouseWheel=jD.bind(this),this._onKeyDown=VD.bind(this),this._onTouchStart=GD.bind(this),this._onTouchMove=HD.bind(this),this._onMouseDown=zD.bind(this),this._onMouseMove=BD.bind(this),this._interceptControlDown=KD.bind(this),this._interceptControlUp=WD.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=Ot.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(YT),this.update(),this.state=Ot.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(bn.copy(t).sub(this.target),bn.applyQuaternion(this._quat),this._spherical.setFromVector3(bn),this.autoRotate&&this.state===Ot.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,r=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(r)){if(n<-Math.PI)n+=Yn;else if(n>Math.PI)n-=Yn;if(r<-Math.PI)r+=Yn;else if(r>Math.PI)r-=Yn;if(n<=r)this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=a!=this._spherical.radius}if(bn.setFromSpherical(this._spherical),bn.applyQuaternion(this._quatInverse),t.copy(this.target).add(bn),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 a=null;if(this.object.isPerspectiveCamera){let s=bn.length();a=this._clampDistance(s*this._scale);let o=s-a;this.object.position.addScaledVector(this._dollyDirection,o),this.object.updateMatrixWorld(),i=!!o}else if(this.object.isOrthographicCamera){let s=new V(this._mouse.x,this._mouse.y,0);s.unproject(this.object);let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=o!==this.object.zoom;let c=new V(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(s),this.object.updateMatrixWorld(),a=bn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(a!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position);else if(af.origin.copy(this.object.position),af.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(af.direction))<LD)this.object.lookAt(this.target);else QT.setFromNormalAndCoplanarPoint(this.object.up,this.target),af.intersectPlane(QT,this.target)}else if(this.object.isOrthographicCamera){let a=this.object.zoom;if(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom)this.object.updateProjectionMatrix(),i=!0}if(this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>Mg||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Mg||this._lastTargetPosition.distanceToSquared(this.target)>Mg)return this.dispatchEvent(YT),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 Yn/60*this.autoRotateSpeed*e;else return Yn/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){bn.setFromMatrixColumn(t,0),bn.multiplyScalar(-e),this._panOffset.add(bn)}_panUp(e,t){if(this.screenSpacePanning===!0)bn.setFromMatrixColumn(t,1);else bn.setFromMatrixColumn(t,0),bn.crossVectors(this.object.up,bn);bn.multiplyScalar(e),this._panOffset.add(bn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;bn.copy(r).sub(this.target);let i=bn.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/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(),r=e-n.left,i=t-n.top,{width:a,height:s}=n;this._mouse.x=r/a*2-1,this._mouse.y=-(i/s)*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(Yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Yn*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(Yn*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(-Yn*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(Yn*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(-Yn*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),r=0.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_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),r=0.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_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),r=0.5*(e.pageX+n.x),i=0.5*(e.pageY+n.y);this._rotateEnd.set(r,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Yn*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),r=0.5*(e.pageY+t.y);this._panEnd.set(n,r)}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,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),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 a=(e.pageX+t.x)*0.5,s=(e.pageY+t.y)*0.5;this._updateZoomParameters(a,s)}_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 We,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 DD(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 FD(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function UD(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(ew),this.state=Ot.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 zD(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 ma.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=Ot.DOLLY;break;case ma.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}break;case ma.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=Ot.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=Ot.PAN}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(Sg)}function BD(e){switch(this.state){case Ot.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case Ot.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case Ot.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function jD(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==Ot.NONE)return;e.preventDefault(),this.dispatchEvent(Sg),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ew)}function VD(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function GD(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ga.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=Ot.TOUCH_ROTATE;break;case ga.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=Ot.TOUCH_PAN;break;default:this.state=Ot.NONE}break;case 2:switch(this.touches.TWO){case ga.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=Ot.TOUCH_DOLLY_PAN;break;case ga.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=Ot.TOUCH_DOLLY_ROTATE;break;default:this.state=Ot.NONE}break;default:this.state=Ot.NONE}if(this.state!==Ot.NONE)this.dispatchEvent(Sg)}function HD(e){switch(this._trackPointer(e),this.state){case Ot.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case Ot.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case Ot.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case Ot.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=Ot.NONE}}function $D(e){if(this.enabled===!1)return;e.preventDefault()}function KD(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function WD(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}Hr();class Ig extends Uo{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new Ea;e.deleteAttribute("uv");let t=new $i({side:Ln}),n=new $i,r=new Ho(16777215,900,28,2);r.position.set(0.418,16.199,0.3),this.add(r);let i=new Gt(e,t);i.position.set(-0.757,13.219,0.717),i.scale.set(31.713,28.305,28.591),this.add(i);let a=new Bo(e,n,6),s=new Lt;s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-0.195,0),s.scale.set(2.328,7.905,4.651),s.updateMatrix(),a.setMatrixAt(0,s.matrix),s.position.set(-5.607,-0.754,-0.758),s.rotation.set(0,0.994,0),s.scale.set(1.97,1.534,3.955),s.updateMatrix(),a.setMatrixAt(1,s.matrix),s.position.set(6.167,0.857,7.803),s.rotation.set(0,0.561,0),s.scale.set(3.927,6.285,3.687),s.updateMatrix(),a.setMatrixAt(2,s.matrix),s.position.set(-2.017,0.018,6.124),s.rotation.set(0,0.333,0),s.scale.set(2.002,4.566,2.064),s.updateMatrix(),a.setMatrixAt(3,s.matrix),s.position.set(2.291,-0.756,-2.621),s.rotation.set(0,-0.286,0),s.scale.set(1.546,1.552,1.496),s.updateMatrix(),a.setMatrixAt(4,s.matrix),s.position.set(-2.193,-0.369,-5.547),s.rotation.set(0,0.516,0),s.scale.set(3.875,3.487,2.986),s.updateMatrix(),a.setMatrixAt(5,s.matrix),this.add(a);let o=new Gt(e,qo(50));o.position.set(-16.116,14.37,8.208),o.scale.set(0.1,2.428,2.739),this.add(o);let c=new Gt(e,qo(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 Gt(e,qo(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 Gt(e,qo(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new Gt(e,qo(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let f=new Gt(e,qo(100));f.position.set(0,20,0),f.scale.set(1,0.1,1),this.add(f)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function qo(e){return new $d({color:0,emissive:16777215,emissiveIntensity:e})}Hr();Hr();Hr();function Cg(e,t){if(t===jm)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Fo||t===cl){let n=e.getIndex();if(n===null){let a=[],s=e.getAttribute("position");if(s!==void 0){for(let o=0;o<s.count;o++)a.push(o);e.setIndex(a),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let r=n.count-2,i=[];if(t===Fo)for(let a=1;a<=r;a++)i.push(n.getX(0)),i.push(n.getX(a)),i.push(n.getX(a+1));else for(let a=0;a<r;a++)if(a%2===0)i.push(n.getX(a)),i.push(n.getX(a+1)),i.push(n.getX(a+2));else i.push(n.getX(a+2)),i.push(n.getX(a+1)),i.push(n.getX(a));if(i.length/3!==r)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(i),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function tw(e){let t=new Map,n=new Map,r=e.clone();return nw(e,r,function(i,a){t.set(a,i),n.set(i,a)}),r.traverse(function(i){if(!i.isSkinnedMesh)return;let a=i,s=t.get(i),o=s.skeleton.bones;a.skeleton=s.skeleton.clone(),a.bindMatrix.copy(s.bindMatrix),a.skeleton.bones=o.map(function(c){return n.get(c)}),a.bind(a.skeleton,a.bindMatrix)}),r}function nw(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)nw(e.children[r],t.children[r],n)}class Fg extends Wi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new uw(t)}),this.register(function(t){return new dw(t)}),this.register(function(t){return new _w(t)}),this.register(function(t){return new vw(t)}),this.register(function(t){return new Ew(t)}),this.register(function(t){return new hw(t)}),this.register(function(t){return new pw(t)}),this.register(function(t){return new mw(t)}),this.register(function(t){return new gw(t)}),this.register(function(t){return new lw(t)}),this.register(function(t){return new bw(t)}),this.register(function(t){return new fw(t)}),this.register(function(t){return new yw(t)}),this.register(function(t){return new xw(t)}),this.register(function(t){return new ow(t)}),this.register(function(t){return new kg(t,ft.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new kg(t,ft.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Aw(t)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){let c=Sa.extractUrlBase(e);a=Sa.resolveURL(c,this.path)}else a=Sa.extractUrlBase(e);this.manager.itemStart(e);let s=function(c){if(r)r(c);else console.error(c);i.manager.itemError(e),i.manager.itemEnd(e)},o=new vl(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{i.parse(c,a,function(l){t(l),i.manager.itemEnd(e)},s)}catch(l){s(l)}},n,s)}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,r){let i,a={},s={},o=new TextDecoder;if(typeof e==="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Tw){try{a[ft.KHR_BINARY_GLTF]=new ww(e)}catch(u){if(r)r(u);return}i=JSON.parse(a[ft.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){if(r)r(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Cw(i,{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");s[u.name]=u,a[u.name]=!0}if(i.extensionsUsed)for(let l=0;l<i.extensionsUsed.length;++l){let u=i.extensionsUsed[l],d=i.extensionsRequired||[];switch(u){case ft.KHR_MATERIALS_UNLIT:a[u]=new cw;break;case ft.KHR_DRACO_MESH_COMPRESSION:a[u]=new Mw(i,this.dracoLoader);break;case ft.KHR_TEXTURE_TRANSFORM:a[u]=new Sw;break;case ft.KHR_MESH_QUANTIZATION:a[u]=new Rw;break;default:if(d.indexOf(u)>=0&&s[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(a),c.setPlugins(s),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function XD(){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 an(e,t,n){let r=e.json.materials[t];if(r.extensions&&r.extensions[n])return r.extensions[n];return null}var ft={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 ow{constructor(e){this.parser=e,this.name=ft.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let i=t[n];if(i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,r=t.cache.get(n);if(r)return r;let i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],c,l=new Je(16777215);if(o.color!==void 0)l.setRGB(o.color[0],o.color[1],o.color[2],fr);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new $o(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Ho(l),c.distance=u;break;case"spot":c=new Jd(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}if(c.position.set(0,0,0),yi(c,o),o.intensity!==void 0)c.intensity=o.intensity;return c.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(c),t.cache.add(n,r),r}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,i=n.json.nodes[e],s=(i.extensions&&i.extensions[this.name]||{}).light;if(s===void 0)return null;return this._loadLight(s).then(function(o){return n._getNodeRef(t.cache,s,o)})}}class cw{constructor(){this.name=ft.KHR_MATERIALS_UNLIT}getMaterialType(){return gi}extendParams(e,t,n){let r=[];e.color=new Je(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let a=i.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],fr),e.opacity=a[3]}if(i.baseColorTexture!==void 0)r.push(n.assignTexture(e,"map",i.baseColorTexture,ya))}return Promise.all(r)}}class lw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class uw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)r.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)r.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(r.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let i=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new We(i,i)}}return Promise.all(r)}}class dw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_DISPERSION}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class fw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)r.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)r.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(r)}}class hw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SHEEN}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new Je(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let i=n.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],fr)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)r.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,ya));if(n.sheenRoughnessTexture!==void 0)r.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(r)}}class pw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)r.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(r)}}class mw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_VOLUME}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)r.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new Je().setRGB(i[0],i[1],i[2],fr),Promise.all(r)}}class gw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IOR}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(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 bw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SPECULAR}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)r.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let i=n.specularColorFactor||[1,1,1];if(t.specularColor=new Je().setRGB(i[0],i[1],i[2],fr),n.specularColorTexture!==void 0)r.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,ya));return Promise.all(r)}}class xw{constructor(e){this.parser=e,this.name=ft.EXT_MATERIALS_BUMP}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)r.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(r)}}class yw{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return an(this.parser,e,this.name)!==null?mr:null}extendMaterialParams(e,t){let n=an(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)r.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(r)}}class _w{constructor(e){this.parser=e,this.name=ft.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a)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,i.source,a)}}class vw{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],s=r.images[a.source],o=n.textureLoader;if(s.uri){let c=n.options.manager.getHandler(s.uri);if(c!==null)o=c}return n.loadTextureImage(e,a.source,o)}}class Ew{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],s=r.images[a.source],o=n.textureLoader;if(s.uri){let c=n.options.manager.getHandler(s.uri);if(c!==null)o=c}return n.loadTextureImage(e,a.source,o)}}class kg{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 r=n.extensions[this.name],i=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.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 i.then(function(s){let o=r.byteOffset||0,c=r.byteLength||0,{count:l,byteStride:u}=r,d=new Uint8Array(s,o,c);if(a.decodeGltfBufferAsync)return a.decodeGltfBufferAsync(l,u,d,r.mode,r.filter).then(function(f){return f.buffer});else return a.ready.then(function(){let f=new ArrayBuffer(l*u);return a.decodeGltfBuffer(new Uint8Array(f),l,u,d,r.mode,r.filter),f})})}else return null}}class Aw{constructor(e){this.name=ft.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 r=t.meshes[n.mesh];for(let c of r.primitives)if(c.mode!==Sr.TRIANGLES&&c.mode!==Sr.TRIANGLE_STRIP&&c.mode!==Sr.TRIANGLE_FAN&&c.mode!==void 0)return null;let a=n.extensions[this.name].attributes,s=[],o={};for(let c in a)s.push(this.parser.getDependency("accessor",a[c]).then((l)=>(o[c]=l,o[c])));if(s.length<1)return null;return s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,f=[];for(let h of u){let b=new Ze,m=new V,g=new ln,p=new V(1,1,1),y=new Bo(h.geometry,h.material,d);for(let x=0;x<d;x++){if(o.TRANSLATION)m.fromBufferAttribute(o.TRANSLATION,x);if(o.ROTATION)g.fromBufferAttribute(o.ROTATION,x);if(o.SCALE)p.fromBufferAttribute(o.SCALE,x);y.setMatrixAt(x,b.compose(m,g,p))}let v=null;for(let x in o)if(x==="_COLOR_0"){let _=o[x];y.instanceColor=new pa(_.array,_.itemSize,_.normalized)}else if(x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"){if(v===null){let E=y.geometry;v=new Dn,v.name=E.name;for(let w in E.attributes)v.setAttribute(w,E.attributes[w]);for(let w in E.morphAttributes)v.morphAttributes[w]=E.morphAttributes[w];if(E.index!==null)v.setIndex(E.index);v.morphTargetsRelative=E.morphTargetsRelative;for(let w of E.groups)v.addGroup(w.start,w.count,w.materialIndex);if(E.boundingBox!==null)v.boundingBox=E.boundingBox.clone();if(E.boundingSphere!==null)v.boundingSphere=E.boundingSphere.clone();v.drawRange.start=E.drawRange.start,v.drawRange.count=E.drawRange.count,v.userData=Object.assign({},E.userData),y.geometry=v}let _=o[x];v.setAttribute(x,new pa(_.array,_.itemSize,_.normalized))}Lt.prototype.copy.call(y,h),this.parser.assignFinalMaterial(y),f.push(y)}if(l.isGroup)return l.clear(),l.add(...f),l;return f[0]})}}var Tw="glTF",Il=12,rw={JSON:1313821514,BIN:5130562};class ww{constructor(e){this.name=ft.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Il),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!==Tw)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-Il,i=new DataView(e,Il),a=0;while(a<r){let s=i.getUint32(a,!0);a+=4;let o=i.getUint32(a,!0);if(a+=4,o===rw.JSON){let c=new Uint8Array(e,Il+a,s);this.content=n.decode(c)}else if(o===rw.BIN){let c=Il+a;this.body=e.slice(c,c+s)}a+=s}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Mw{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ft.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,s={},o={},c={};for(let l in a){let u=Lg[l]||l.toLowerCase();s[u]=a[l]}for(let l in e.attributes){let u=Lg[l]||l.toLowerCase();if(a[l]!==void 0){let d=n.accessors[e.attributes[l]],f=Jo[d.componentType];c[u]=f.name,o[u]=d.normalized===!0}}return t.getDependency("bufferView",i).then(function(l){return new Promise(function(u,d){r.decodeDracoFile(l,function(f){for(let h in f.attributes){let b=f.attributes[h],m=o[h];if(m!==void 0)b.normalized=m}u(f)},s,c,fr,d)})})}}class Sw{constructor(){this.name=ft.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),r=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*r,e.offset.x,-e.repeat.x*r,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Rw{constructor(){this.name=ft.KHR_MESH_QUANTIZATION}}class Ug extends Ki{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let a=0;a!==r;a++)t[a]=n[i+a];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=s*2,c=s*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,h=e*c,b=h-c,m=-2*f+3*d,g=f-d,p=1-m,y=g-d+u;for(let v=0;v!==s;v++){let x=a[b+v+s],_=a[b+v+o]*l,E=a[h+v+s],w=a[h+v]*l;i[v]=p*x+y*_+m*E+g*w}return i}}var qD=new ln;class Iw extends Ug{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return qD.fromArray(i).normalize().toArray(i),i}}var Sr={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},Jo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},iw={9728:jr,9729:An,9984:Md,9985:Lo,9986:Ss,9987:hi},aw={33071:ko,33648:wd,10497:Oo},Ng={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Lg={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"},Ra={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},JD={CUBICSPLINE:void 0,LINEAR:Od,STEP:Bm},Pg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ZD(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ba});return e.DefaultMaterial}function Fs(e,t,n){for(let r in n.extensions)if(e[r]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r]}function yi(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function YD(e,t,n){let r=!1,i=!1,a=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)r=!0;if(d.NORMAL!==void 0)i=!0;if(d.COLOR_0!==void 0)a=!0;if(r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let s=[],o=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(r){let f=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;s.push(f)}if(i){let f=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;o.push(f)}if(a){let f=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(f)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],f=l[2];if(r)e.morphAttributes.position=u;if(i)e.morphAttributes.normal=d;if(a)e.morphAttributes.color=f;return e.morphTargetsRelative=!0,e})}function QD(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;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 r=0,i=n.length;r<i;r++)e.morphTargetDictionary[n[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function e9(e){let t,n=e.extensions&&e.extensions[ft.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Og(n.attributes);else t=e.indices+":"+Og(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let r=0,i=e.targets.length;r<i;r++)t+=":"+Og(e.targets[r]);return t}function Og(e){let t="",n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function Dg(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 t9(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 n9=new Ze;class Cw{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new XD,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,r=-1,i=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let s=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(s)===!0;let o=s.match(/Version\/(\d+)/);r=n&&o?parseInt(o[1],10):-1,i=s.indexOf("Firefox")>-1,a=i?s.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&r<17||i&&a<98)this.textureLoader=new Vo(this.options.manager);else this.textureLoader=new Zd(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new vl(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,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){let s={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return Fs(i,s,r),yi(s,r),Promise.all(n._invokeAll(function(o){return o.afterRoot&&o.afterRoot(s)})).then(function(){for(let o of s.scenes)o.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){let a=t[r].joints;for(let s=0,o=a.length;s<o;s++)e[a[s]].isBone=!0}for(let r=0,i=e.length;r<i;r++){let a=e[r];if(a.mesh!==void 0){if(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0)n[a.mesh].isSkinnedMesh=!0}if(a.camera!==void 0)this._addNodeRef(this.cameraCache,a.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 r=n.clone(),i=(a,s)=>{let o=this.associations.get(a);if(o!=null)this.associations.set(s,o);for(let[c,l]of a.children.entries())i(l,s.children[c])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);if(i)n.push(i)}return n}getDependency(e,t){let n=e+":"+t,r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":r=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!r)throw Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(i,a){return n.getDependency(e,a)})),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[ft.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(i,a){n.load(Sa.resolveURL(t.uri,r.path),i,void 0,function(){a(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 r=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+r)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let a=Ng[r.type],s=Jo[r.componentType],o=r.normalized===!0,c=new s(r.count*a);return Promise.resolve(new En(c,a,o))}let i=[];if(r.bufferView!==void 0)i.push(this.getDependency("bufferView",r.bufferView));else i.push(null);if(r.sparse!==void 0)i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView));return Promise.all(i).then(function(a){let s=a[0],o=Ng[r.type],c=Jo[r.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,d=r.byteOffset||0,f=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,h=r.normalized===!0,b,m;if(f&&f!==u){let g=Math.floor(d/f),p="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+g+":"+r.count,y=t.cache.get(p);if(!y)b=new c(s,g*f,r.count*f/l),y=new fl(b,f/l),t.cache.add(p,y);m=new zo(y,o,d%f/l,h)}else{if(s===null)b=new c(r.count*o);else b=new c(s,d,r.count*o);m=new En(b,o,h)}if(r.sparse!==void 0){let g=Ng.SCALAR,p=Jo[r.sparse.indices.componentType],y=r.sparse.indices.byteOffset||0,v=r.sparse.values.byteOffset||0,x=new p(a[1],y,r.sparse.count*g),_=new c(a[2],v,r.sparse.count*o);if(s!==null)m=new En(m.array.slice(),m.itemSize,m.normalized);m.normalized=!1;for(let E=0,w=x.length;E<w;E++){let A=x[E];if(m.setX(A,_[E*o]),o>=2)m.setY(A,_[E*o+1]);if(o>=3)m.setZ(A,_[E*o+2]);if(o>=4)m.setW(A,_[E*o+3]);if(o>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=h}return m})}loadTexture(e){let t=this.json,n=this.options,i=t.textures[e].source,a=t.images[i],s=this.textureLoader;if(a.uri){let o=n.manager.getHandler(a.uri);if(o!==null)s=o}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],s=i.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=a.name||s.name||"",l.name===""&&typeof s.uri==="string"&&s.uri.startsWith("data:image/")===!1)l.name=s.uri;let d=(i.samplers||{})[a.sampler]||{};return l.magFilter=iw[d.magFilter]||An,l.minFilter=iw[d.minFilter]||hi,l.wrapS=aw[d.wrapS]||Oo,l.wrapT=aw[d.wrapT]||Oo,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==jr&&l.minFilter!==An,r.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let a=r.images[e],s=self.URL||self.webkitURL,o=a.uri||"",c=!1;if(a.bufferView!==void 0)o=n.getDependency("bufferView",a.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:a.mimeType});return o=s.createObjectURL(d),o});else if(a.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(d,f){let h=d;if(t.isImageBitmapLoader===!0)h=function(b){let m=new en(b);m.needsUpdate=!0,d(m)};t.load(Sa.resolveURL(u,i.path),h,void 0,f)})}).then(function(u){if(c===!0)s.revokeObjectURL(o);return yi(u,a),u.userData.mimeType=a.mimeType||t9(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0)a=a.clone(),a.channel=n.texCoord;if(i.extensions[ft.KHR_TEXTURE_TRANSFORM]){let s=n.extensions!==void 0?n.extensions[ft.KHR_TEXTURE_TRANSFORM]:void 0;if(s){let o=i.associations.get(a);a=i.extensions[ft.KHR_TEXTURE_TRANSFORM].extendTexture(a,s),i.associations.set(a,o)}}if(r!==void 0)a.colorSpace=r;return e[t]=a,a})}assignFinalMaterial(e){let{geometry:t,material:n}=e,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let s="PointsMaterial:"+n.uuid,o=this.cache.get(s);if(!o)o=new xl,Zn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,o.sizeAttenuation=!1,this.cache.add(s,o);n=o}else if(e.isLine){let s="LineBasicMaterial:"+n.uuid,o=this.cache.get(s);if(!o)o=new bl,Zn.prototype.copy.call(o,n),o.color.copy(n.color),o.map=n.map,this.cache.add(s,o);n=o}if(r||i||a){let s="ClonedMaterial:"+n.uuid+":";if(r)s+="derivative-tangents:";if(i)s+="vertex-colors:";if(a)s+="flat-shading:";let o=this.cache.get(s);if(!o){if(o=n.clone(),i)o.vertexColors=!0;if(a)o.flatShading=!0;if(r){if(o.normalScale)o.normalScale.y*=-1;if(o.clearcoatNormalScale)o.clearcoatNormalScale.y*=-1}this.cache.add(s,o),this.associations.set(o,this.associations.get(n))}n=o}e.material=n}getMaterialType(){return $i}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,s={},o=i.extensions||{},c=[];if(o[ft.KHR_MATERIALS_UNLIT]){let u=r[ft.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),c.push(u.extendParams(s,i,t))}else{let u=i.pbrMetallicRoughness||{};if(s.color=new Je(1,1,1),s.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;s.color.setRGB(d[0],d[1],d[2],fr),s.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(s,"map",u.baseColorTexture,ya));if(s.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,s.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(s,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(s,"roughnessMap",u.metallicRoughnessTexture));a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,s)})))}if(i.doubleSided===!0)s.side=wr;let l=i.alphaMode||Pg.OPAQUE;if(l===Pg.BLEND)s.transparent=!0,s.depthWrite=!1;else if(s.transparent=!1,l===Pg.MASK)s.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:0.5;if(i.normalTexture!==void 0&&a!==gi){if(c.push(t.assignTexture(s,"normalMap",i.normalTexture)),s.normalScale=new We(1,1),i.normalTexture.scale!==void 0){let u=i.normalTexture.scale;s.normalScale.set(u,u)}}if(i.occlusionTexture!==void 0&&a!==gi){if(c.push(t.assignTexture(s,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0)s.aoMapIntensity=i.occlusionTexture.strength}if(i.emissiveFactor!==void 0&&a!==gi){let u=i.emissiveFactor;s.emissive=new Je().setRGB(u[0],u[1],u[2],fr)}if(i.emissiveTexture!==void 0&&a!==gi)c.push(t.assignTexture(s,"emissiveMap",i.emissiveTexture,ya));return Promise.all(c).then(function(){let u=new a(s);if(i.name)u.name=i.name;if(yi(u,i),t.associations.set(u,{materials:e}),i.extensions)Fs(r,u,i);return u})}createUniqueName(e){let t=At.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,r=this.primitiveCache;function i(s){return n[ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(s,t).then(function(o){return sw(o,s,t)})}let a=[];for(let s=0,o=e.length;s<o;s++){let c=e[s],l=e9(c),u=r[l];if(u)a.push(u.promise);else{let d;if(c.extensions&&c.extensions[ft.KHR_DRACO_MESH_COMPRESSION])d=i(c);else d=sw(new Dn,c,t);if(c.mode===Sr.TRIANGLE_STRIP)d=d.then((f)=>Cg(f,cl));else if(c.mode===Sr.TRIANGLE_FAN)d=d.then((f)=>Cg(f,Fo));r[l]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,s=[];for(let o=0,c=a.length;o<c;o++){let l=a[o].material===void 0?ZD(this.cache):this.getDependency("material",a[o].material);s.push(l)}return s.push(t.loadGeometries(a)),Promise.all(s).then(async function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let f=0,h=l.length;f<h;f++){let b=l[f],m=a[f],g,p=c[f];if(m.mode===Sr.TRIANGLES||m.mode===Sr.TRIANGLE_STRIP||m.mode===Sr.TRIANGLE_FAN||m.mode===void 0){let y=i.isSkinnedMesh===!0,v=b.hasAttribute("skinIndex")&&b.hasAttribute("skinWeight");if(y&&v===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(g=y&&v?new Bd(b,p):new Gt(b,p),g.isSkinnedMesh===!0)g.normalizeSkinWeights()}else if(m.mode===Sr.LINES)g=new jd(b,p);else if(m.mode===Sr.LINE_STRIP)g=new va(b,p);else if(m.mode===Sr.LINE_LOOP)g=new Vd(b,p);else if(m.mode===Sr.POINTS)g=new jo(b,p);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);if(Object.keys(g.geometry.morphAttributes).length>0)QD(g,i);if(g.name=t.createUniqueName(i.name||"mesh_"+e),yi(g,i),m.extensions)Fs(r,g,m);t.assignFinalMaterial(g),u.push(g)}for(let f=0,h=u.length;f<h;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1){if(i.extensions)Fs(r,u[0],i);return u[0]}let d=new li;if(i.extensions)Fs(r,d,i);t.associations.set(d,{meshes:e});for(let f=0,h=u.length;f<h;f++)d.add(u[f]);return d})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new hn(ll.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2000000);else if(n.type==="orthographic")t=new Ls(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar);if(n.name)t.name=this.createUniqueName(n.name);return yi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let r=0,i=t.joints.length;r<i;r++)n.push(this._loadNodeShallow(t.joints[r]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(r){let i=r.pop(),a=r,s=[],o=[];for(let c=0,l=a.length;c<l;c++){let u=a[c];if(u){s.push(u);let d=new Ze;if(i!==null)d.fromArray(i.array,c*16);o.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new ml(s,o)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:"animation_"+e,a=[],s=[],o=[],c=[],l=[];for(let u=0,d=r.channels.length;u<d;u++){let f=r.channels[u],h=r.samplers[f.sampler],b=f.target,m=b.node,g=r.parameters!==void 0?r.parameters[h.input]:h.input,p=r.parameters!==void 0?r.parameters[h.output]:h.output;if(b.node===void 0)continue;a.push(this.getDependency("node",m)),s.push(this.getDependency("accessor",g)),o.push(this.getDependency("accessor",p)),c.push(h),l.push(b)}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],f=u[1],h=u[2],b=u[3],m=u[4],g=[];for(let y=0,v=d.length;y<v;y++){let x=d[y],_=f[y],E=h[y],w=b[y],A=m[y];if(x===void 0)continue;if(x.updateMatrix)x.updateMatrix();let T=n._createAnimationTracks(x,_,E,w,A);if(T)for(let N=0;N<T.length;N++)g.push(T[N])}let p=new Io(i,void 0,g);return yi(p,r),p})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];if(r.mesh===void 0)return null;return n.getDependency("mesh",r.mesh).then(function(i){let a=n._getNodeRef(n.meshCache,r.mesh,i);if(r.weights!==void 0)a.traverse(function(s){if(!s.isMesh)return;for(let o=0,c=r.weights.length;o<c;o++)s.morphTargetInfluences[o]=r.weights[o]});return a})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],s=r.children||[];for(let c=0,l=s.length;c<l;c++)a.push(n.getDependency("node",s[c]));let o=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([i,Promise.all(a),o]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(f){if(!f.isSkinnedMesh)return;f.bind(d,n9)});for(let f=0,h=u.length;f<h;f++)l.add(u[f]);if(l.userData.pivot!==void 0&&u.length>0){let f=l.userData.pivot,h=u[0];l.pivot=new V().fromArray(f),l.position.x-=f[0],l.position.y-=f[1],l.position.z-=f[2],h.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):"",s=[],o=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(o)s.push(o);if(i.camera!==void 0)s.push(r.getDependency("camera",i.camera).then(function(c){return r._getNodeRef(r.cameraCache,i.camera,c)}));return r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){s.push(c)}),this.nodeCache[e]=Promise.all(s).then(function(c){let l;if(i.isBone===!0)l=new hl;else if(c.length>1)l=new li;else if(c.length===1)l=c[0];else l=new Lt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(i.name)l.userData.name=i.name,l.name=a;if(yi(l,i),i.extensions)Fs(n,l,i);if(i.matrix!==void 0){let u=new Ze;u.fromArray(i.matrix),l.applyMatrix4(u)}else{if(i.translation!==void 0)l.position.fromArray(i.translation);if(i.rotation!==void 0)l.quaternion.fromArray(i.rotation);if(i.scale!==void 0)l.scale.fromArray(i.scale)}if(!r.associations.has(l))r.associations.set(l,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let u=r.associations.get(l);r.associations.set(l,{...u})}return r.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new li;if(n.name)i.name=r.createUniqueName(n.name);if(yi(i,n),n.extensions)Fs(t,i,n);let a=n.nodes||[],s=[];for(let o=0,c=a.length;o<c;o++)s.push(r.getDependency("node",a[o]));return Promise.all(s).then(function(o){for(let l=0,u=o.length;l<u;l++){let d=o[l];if(d.parent!==null)i.add(tw(d));else i.add(d)}let c=(l)=>{let u=new Map;for(let[d,f]of r.associations)if(d instanceof Zn||d instanceof en)u.set(d,f);return l.traverse((d)=>{let f=r.associations.get(d);if(f!=null)u.set(d,f)}),u};return r.associations=c(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],s=e.name?e.name:e.uuid,o=[];function c(f){if(f.morphTargetInfluences)o.push(f.name?f.name:f.uuid)}if(Ra[i.path]===Ra.weights){if(c(e),e.isGroup)e.children.forEach(c)}else o.push(s);let l;switch(Ra[i.path]){case Ra.weights:l=Ta;break;case Ra.rotation:l=wa;break;case Ra.translation:case Ra.scale:l=ks;break;default:switch(n.itemSize){case 1:l=Ta;break;case 2:case 3:default:l=ks;break}break}let u=r.interpolation!==void 0?JD[r.interpolation]:Od,d=this._getArrayFromAccessor(n);for(let f=0,h=o.length;f<h;f++){let b=new l(o[f]+"."+Ra[i.path],t.array,d,u);if(r.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(b);a.push(b)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Dg(t.constructor),r=new Float32Array(t.length);for(let i=0,a=t.length;i<a;i++)r[i]=t[i]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof wa?Iw:Ug)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function r9(e,t,n){let r=t.attributes,i=new pn;if(r.POSITION!==void 0){let o=n.json.accessors[r.POSITION],{min:c,max:l}=o;if(c!==void 0&&l!==void 0){if(i.set(new V(c[0],c[1],c[2]),new V(l[0],l[1],l[2])),o.normalized){let u=Dg(Jo[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let a=t.targets;if(a!==void 0){let o=new V,c=new V;for(let l=0,u=a.length;l<u;l++){let d=a[l];if(d.POSITION!==void 0){let f=n.json.accessors[d.POSITION],{min:h,max:b}=f;if(h!==void 0&&b!==void 0){if(c.setX(Math.max(Math.abs(h[0]),Math.abs(b[0]))),c.setY(Math.max(Math.abs(h[1]),Math.abs(b[1]))),c.setZ(Math.max(Math.abs(h[2]),Math.abs(b[2]))),f.normalized){let m=Dg(Jo[f.componentType]);c.multiplyScalar(m)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}e.boundingBox=i;let s=new pr;i.getCenter(s.center),s.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=s}function sw(e,t,n){let r=t.attributes,i=[];function a(s,o){return n.getDependency("accessor",s).then(function(c){e.setAttribute(o,c)})}for(let s in r){let o=Lg[s]||s.toLowerCase();if(o in e.attributes)continue;i.push(a(r[s],o))}if(t.indices!==void 0&&!e.index){let s=n.getDependency("accessor",t.indices).then(function(o){e.setIndex(o)});i.push(s)}if(lt.workingColorSpace!==fr&&"COLOR_0"in r)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${lt.workingColorSpace}" not supported.`);return yi(e,t),r9(e,t,n),Promise.all(i).then(function(){return t.targets!==void 0?YD(e,t.targets,n):e})}function _i(e){let t=new Set,n=new Set,r=new Set;e.traverse((i)=>{let a=i;if(!a.isMesh)return;t.add(a.geometry);for(let s of Array.isArray(a.material)?a.material:[a.material]){n.add(s);for(let o of Object.values(s))if(o instanceof en)r.add(o)}});for(let i of[...t,...n,...r])i.dispose()}async function Nw(e){_p(e);let t=new _l,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Vo(t)),t.setURLModifier((a)=>{if(!a.startsWith("blob:")&&!a.startsWith("data:"))throw Error("External model resources are not loaded");return a});let r=new Fg(t);r.register((a)=>({name:"KILN_embedded_images",async beforeRoot(){for(let s of a.json.images??[]){if(s.bufferView===void 0)continue;let o=new Uint8Array(await a.getDependency("bufferView",s.bufferView)),c="";for(let l=0;l<o.length;l+=8192)c+=String.fromCharCode(...o.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(s.mimeType??""))throw Error("Unsupported embedded image type");s.uri=`data:${s.mimeType};base64,${btoa(c)}`,delete s.bufferView}}}));let i=await r.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let a of i.scenes)_i(a);throw Error("An embedded texture could not be decoded.")}return Object.assign(i,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}Hr();function Pw(e,t,n=40,r=[e]){let i=e.getCenter(new V),a=Math.max(e.getSize(new V).length()/2,0.01),s=new V(1,0.65,1.25).normalize(),o=new V().crossVectors(new V(0,1,0),s).normalize(),c=new V().crossVectors(s,o),l=[];for(let y of r.length?r:[e])for(let v of[y.min.x,y.max.x])for(let x of[y.min.y,y.max.y])for(let _ of[y.min.z,y.max.z])l.push(new V(v,x,_));let u=1/0,d=-1/0,f=1/0,h=-1/0;for(let y of l){let v=y.clone().sub(i),x=v.dot(o),_=v.dot(c);u=Math.min(u,x),d=Math.max(d,x),f=Math.min(f,_),h=Math.max(h,_)}i.addScaledVector(o,(u+d)/2),i.addScaledVector(c,(f+h)/2);let b=Math.tan(n*Math.PI/360),m=b*t,g=a;for(let y of l){let v=y.clone().sub(i),x=v.dot(s);g=Math.max(g,x+Math.abs(v.dot(o))*1.12/m,x+Math.abs(v.dot(c))*1.12/b)}let p=i.clone().addScaledVector(s,g);return{center:i,radius:a,distance:g,position:p}}Hr();function zg(e,t){return{position:e.position.clone(),target:t.clone()}}function Bg(e,t,n,r){e.position.copy(n.position),t.copy(n.target);let i=Math.max(r.getSize(new V).length(),0.001);e.near=Math.min(0.01,Math.max(i/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(r.getCenter(new V))+i*20,10),e.updateProjectionMatrix()}function Ow(e,t,n){let r=e.getWorldDirection(new V);if(r.y=0,r.lengthSq()<0.00000001)r.set(0,0,-1);r.normalize();let i=r.clone().cross(new V(0,1,0)),a=new V;if(t.has("KeyW")||t.has("ArrowUp"))a.add(r);if(t.has("KeyS")||t.has("ArrowDown"))a.sub(r);if(t.has("KeyD")||t.has("ArrowRight"))a.add(i);if(t.has("KeyA")||t.has("ArrowLeft"))a.sub(i);if(t.has("KeyE"))a.y++;if(t.has("KeyQ"))a.y--;return a.normalize().multiplyScalar(n)}function kw(e){let t=e.filter((r)=>Number.isFinite(r)&&r>0).sort((r,i)=>r-i);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(r)=>t[Math.max(0,Math.ceil(t.length*r)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}async function Lw(e,t){let n=t();if(n===void 0)throw Error("Wait for the selected artifact to be loaded before measuring.");let r=JSON.stringify(n),i=await e();if(JSON.stringify(t())!==r)throw Error("The artifact changed during measurement. Measure the loaded revision again.");return{...i,artifact:n}}function Dw(e,t,n){if(t())return e;n(e);return}Hr();function sf(e,t){let n=e.parser.json.nodes??[],r=new Set;if(n.forEach((a,s)=>{if(a?.extensions?.KHR_node_visibility?.visible===!1)r.add(s)}),r.size===0)return 0;let i=0;for(let a of t)a.traverse((s)=>{let o=e.parser.associations.get(s)?.nodes;if(o===void 0||!r.has(o))return;s.visible=!1,i++});return i}function of(e){let t=!1;if(e.traverse((a)=>{if(!a.visible)t=!0}),!t)return new pn().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new pn,r=new pn,i=new V;return e.traverseVisible((a)=>{let s=a,o=s.geometry;if(!o)return;let c=o.getAttribute("position");if(c&&s.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(s.isMesh)s.getVertexPosition(u,i);else i.fromBufferAttribute(c,u);n.expandByPoint(i.applyMatrix4(a.matrixWorld))}return}let l=a;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();r.copy(l.boundingBox)}else{if(o.boundingBox===null)o.computeBoundingBox();r.copy(o.boundingBox)}n.union(r.applyMatrix4(a.matrixWorld))}),n.isEmpty()?new pn().setFromObject(e,!0):n}function Cl(e){let t=0;return e.traverseVisible((n)=>{let r=n;if(!r.isMesh)return;let i=r.geometry.index?.count??r.geometry.attributes.position?.count??0;t+=i/3*(r.isInstancedMesh?r.count:1)}),t}async function Fw(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let r=new Set,i=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((b)=>!Number.isInteger(b)||!t[b]||n.has(b)))continue;let d=l.parent;while(d&&!r.has(d))d=d.parent;if(d)continue;let f=[l];for(let b of u)f.push(await e.parser.getDependency("node",b));sf(e,f.slice(1)),r.add(l);let h=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");i.push({id:String(c),label:h,levels:f})}if(i.length===0)return;let a=Cl(e.scene)-i.reduce((c,l)=>c+jg(l,0),0),s=Math.max(...i.map((c)=>c.levels.length)),o=Array.from({length:s},(c,l)=>a+i.reduce((u,d)=>u+jg(d,l),0));return{chains:i,triangles:o}}var Uw=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function jg(e,t){let n=e.levels.find((r)=>r.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Cl(Uw(e,t))}function zw(e,t){let n=Uw(e,t),r=e.levels.find((a)=>a.parent!==null);if(!r||r===n)return;let i=r.parent;i.children[i.children.indexOf(r)]=n,n.parent=i,r.parent=null}function Bw(e,t){for(let n of e.chains)zw(n,t)}function jw(e,t,n){let r=e.chains.find((i)=>i.id===t);if(!r)return!1;return zw(r,n),!0}function Vw(e,t){if(!e)return;return{triangles:Cl(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((r)=>r.parent!==null),triangles:n.levels.map((r,i)=>jg(n,i))}))}}function Zo(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function Vg(e){return e.map((t,n)=>`LOD${n} · ${t.toLocaleString()} triangles`)}function Nl(e){let t=new Tg({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=al,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Uo,r=new hn(40,1,0.01,1000),i=new Rg(r,t.domElement);i.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let a=new Set,s=!1,o=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!s||!c.has(P.code))return;P.preventDefault(),a.add(P.code)},u=(P)=>a.delete(P.code),d=()=>a.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let f=new Rl(t),h=new Ig,b=f.fromScene(h,0.04);n.environment=b.texture,h.dispose(),f.dispose();let m=new $o(16773591,2.4);m.position.set(4,8,5),n.add(m),n.add(new Xd(14806490,5065021,1.7));let g,p,y,v=[],x=!0,_=performance.now(),E=0,w=0,A=!1,T,N,M,R=(P)=>{if(!M)return;clearTimeout(M.timeout),M.reject(Error(P)),M=void 0},k=(P)=>{let K=t.getContext(),z=K.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-M.started,frameMs:kw(M.samples),...N===void 0?{}:{loadToFirstFrameMs:N},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(K.getParameter(K.VERSION)),vendor:String(K.getParameter(K.VENDOR)),renderer:String(K.getParameter(K.RENDERER)),browser:navigator.userAgent,...z?{unmaskedVendor:String(K.getParameter(z.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(K.getParameter(z.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:r.position.toArray(),target:i.target.toArray(),fov:r.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},C=()=>{if(!g)return;let P=of(g),K=[];g.traverseVisible((he)=>{if(he instanceof Gt||he instanceof va||he instanceof jo){let xe=new pn().setFromObject(he,!0);if(!xe.isEmpty())K.push(xe)}});let{center:z,radius:W,distance:q,position:le}=Pw(P,r.aspect,r.fov,K);if(i.target.copy(z),r.position.copy(le),r.near=Math.max(W/1000,0.0001),r.far=q+W*100,i.minDistance=W*0.1,i.maxDistance=W*80,o=Math.max(W*0.35,0.01),s)i.minDistance=W*0.00001;r.updateProjectionMatrix(),i.update()},U=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:K}=e;if(!P||!K)return;t.setSize(P,K),r.aspect=P/K,r.updateProjectionMatrix()});U.observe(e);let D=(P)=>{if(A)return;let K=Math.min((P-_)/1000,0.1);if(_=P,e.clientWidth&&e.clientHeight){if(x)y?.update(K);if(s&&a.size){let z=Ow(r,a,K*o*(a.has("ShiftLeft")||a.has("ShiftRight")?3:1));r.position.add(z),i.target.add(z)}if(i.update(),t.render(n,r),T!==void 0)N=performance.now()-T,T=void 0;if(M){if(M.previous>0&&M.samples.length<1800)M.samples.push(P-M.previous);if(M.previous=P,P-M.started>=M.duration&&M.samples.length){let z=k(P);clearTimeout(M.timeout),M.resolve(z),M=void 0}}}else a.clear(),R("Keep the measured viewport visible for the complete sampling window.");E=requestAnimationFrame(D)};return E=requestAnimationFrame(D),{async load(P,K={}){let z=performance.now(),W=++w;R("The artifact changed during measurement. Measure the new revision again.");let q=await Nw(P);sf(q,[q.scene]);let le=await Fw(q);try{q.assertTexturesLoaded()}catch(ne){_i(q.scene);for(let re of Zo(le))_i(re);throw ne}let he=Dw(q,()=>!A&&W===w&&K.isCurrent?.()!==!1,(ne)=>{_i(ne.scene);for(let re of Zo(le))_i(re)});if(!he)return;let xe=g&&K.preserveView?zg(r,i.target):void 0;if(g){y?.stopAllAction(),y?.uncacheRoot(g),n.remove(g),_i(g);for(let ne of Zo(p))_i(ne)}g=he.scene,p=le,T=z,N=void 0,n.add(g),v=he.animations,y=new Yd(g),x=!0;let{clientWidth:pe,clientHeight:J}=e;if(t.setSize(pe,J),r.aspect=pe&&J?pe/J:r.aspect,C(),xe)Bg(r,i.target,xe,of(g)),i.update();let F=0,X=new Set;return g.traverseVisible((ne)=>{let re=ne;if(!re.isMesh)return;F++;for(let ce of Array.isArray(re.material)?re.material:[re.material])X.add(ce)}),K.onCommit?.(),{triangles:Cl(g),meshes:F,materials:X.size,clips:v.map((ne)=>ne.name),...p?{levels:p.triangles}:{}}},level(P){if(R("The level of detail changed. Measure the displayed combination again."),p)Bw(p,P)},partLevel(P,K){if(R("The level of detail changed. Measure the displayed combination again."),p)jw(p,P,K)},lod(){return g?Vw(p,g):void 0},reset:C,cancelMeasurement:R,measure(P=3000){if(A||!g||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(M)return Promise.reject(Error("A measurement is already running."));return new Promise((K,z)=>{M={started:performance.now(),previous:0,duration:P,samples:[],resolve:K,reject:z,timeout:setTimeout(()=>R("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return zg(r,i.target)},setView(P){if(!g)return;Bg(r,i.target,P,of(g)),i.update()},navigation(P){if(s=P==="explore",a.clear(),i.minDistance=s?0.00001:o/3.5,s)r.near=0.0001,r.updateProjectionMatrix()},wire(P){for(let K of g?[g,...Zo(p)]:[])K.traverse((z)=>{let W=z;if(W.isMesh){for(let q of Array.isArray(W.material)?W.material:[W.material])if("wireframe"in q)q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,m.intensity=P==="soft"?0.8:2.4},clip(P){if(y?.stopAllAction(),v[P])y?.clipAction(v[P]).play()},pause(P){x=!P},dispose(){if(R("The viewport closed before measurement finished."),A=!0,w++,cancelAnimationFrame(E),U.disconnect(),i.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),g)_i(g);for(let P of Zo(p))_i(P);b.dispose(),t.dispose(),e.replaceChildren()}}}var ue=(e)=>document.getElementById(e);function L(e,t,n){let r=document.createElement(e);if(t!==void 0)r.textContent=t;if(n)r.className=n;return r}function In(e){let t=ue("dashboard-status");t.textContent=e instanceof Error?e.message:String(e),t.hidden=!t.textContent}async function un(e,t){let n=await fetch(e,t?{method:t.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:void 0),r=await n.json();if(!n.ok)throw Error(r.error??`Request failed (${n.status})`);return r}function Yo(e,t){let n=L("div",void 0,"empty");return n.append(L("b",e),L("p",t)),n}function $r(e,t){try{localStorage.setItem(e,t)}catch{}}function Ia(e){try{return localStorage.getItem(e)}catch{return null}}function Tn(e){return e?e.slice(0,15):"Unspecified"}function Qo(e,t){let n=L("details",void 0,"record-details");return n.append(L("summary",e),L("pre",JSON.stringify(t,null,2))),n}function Pl(e,t,n,r){let i=n.lod();if(e.hidden=!i,t.hidden=!i,t.replaceChildren(),e.replaceChildren(),e.onchange=null,!i)return;e.append(...Vg(i.levels).map((l,u)=>new Option(l,String(u))));let a=new Option("Mixed part levels","mixed");a.disabled=!0,e.append(a);let s=L("p","","lod-total");s.setAttribute("role","status"),t.append(s);let o=new Map;if(i.chains.length>1){let l=L("details",void 0,"lod-parts");l.append(L("summary","Per-part levels")),l.append(L("p","Choose a level for each part. The main selector sets every part to the same index.","subtle"));let u=L("div",void 0,"lod-part-fields"),d=new Set(i.chains.filter((f,h,b)=>b.findIndex((m)=>m.label===f.label)!==h).map((f)=>f.label));for(let[f,h]of i.chains.entries()){let b=d.has(h.label)?`${h.label} (part ${f+1})`:h.label,m=L("label",b,"inline-field"),g=L("select");g.setAttribute("aria-label",`${b} level of detail`),g.append(...Vg(h.triangles).map((p,y)=>new Option(p,String(y)))),g.onchange=()=>{n.partLevel(h.id,Number(g.value)),c(),r?.()},o.set(h.id,g),m.append(g),u.append(m)}l.append(u),t.append(l)}function c(){let l=n.lod();if(!l)return;let u=l.levels.findIndex((d,f)=>l.chains.every((h)=>h.level===Math.min(f,h.triangles.length-1)));e.value=u<0?"mixed":String(u),s.textContent=`${l.triangles.toLocaleString()} triangles displayed`;for(let d of l.chains){let f=o.get(d.id);if(f)f.value=String(d.level)}}return e.onchange=()=>{if(e.value==="mixed")return;let l=Number(e.value);n.level(l),c(),r?.(l)},c(),{refresh:c}}var Gw=/^[a-z][a-z0-9_-]{0,79}$/u,i9=/^r_[a-z0-9_-]{1,77}$/u;function Hw(e){let t=new URLSearchParams(e),n=t.get("collection"),r=t.get("asset"),i=t.get("revision");if(!n||!r||!i||!Gw.test(n)||!Gw.test(r)||!i9.test(i))return;return{collection:n,assetId:r,revisionId:i}}cf();cf();var Ab=new TextEncoder,Wz=new TextDecoder,oc=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),Eb=(e,t)=>Object.hasOwn(e,t);async function BR(e){let t=await crypto.subtle.digest("SHA-256",Uint8Array.from(e));return`sha256:${Array.from(new Uint8Array(t),(n)=>n.toString(16).padStart(2,"0")).join("")}`}function Xz(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.kiln-metadata\.json$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("Runtime metadata filename must be a portable sibling *.kiln-metadata.json filename")}function qz(e){if(e.length>200||!/^[a-z0-9][a-z0-9._-]*\.gltf$/i.test(e)||/^(con|prn|aux|nul|com[0-9]|lpt[0-9])\./i.test(e))throw Error("External texture output must be a portable sibling *.gltf filename")}function Jz(e,t){if(t+8>e.length)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(n.getUint32(t+4,!0)!==5130562)return;return e.subarray(t+8,t+8+n.getUint32(t,!0))}function Zz(e){let t=new Map;for(let r of[...$c(e),...(e.materialResources?.records??[]).map(({manifest:i})=>i)])t.set(`${r.materialId}/${r.revisionId}`,r);let n=(r,i)=>r<i?-1:r>i?1:0;return[...t.values()].flatMap((r)=>r.maps.map((i)=>({sha256:i.sha256,pin:{resourceId:r.materialId,revisionId:r.revisionId,sha256:r.revisionId},slot:i.slot}))).sort((r,i)=>n(r.pin.resourceId,i.pin.resourceId)||n(r.pin.revisionId,i.pin.revisionId)||n(r.slot,i.slot))}function jR(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=12;while(n<e.length){if(n+8>e.length)throw Error("Invalid GLB chunk header");let a=t.getUint32(n,!0);if(a%4||n+8+a>e.length)throw Error("Invalid GLB chunk length");n+=8+a}let r=20+t.getUint32(12,!0),i=JSON.parse(Wz.decode(e.subarray(20,r)));if(!oc(i)||!oc(i.asset)||i.asset.version!=="2.0")throw Error("Invalid glTF asset");return{json:i,jsonEnd:r}}function VR(e,t,n){let r=Ab.encode(JSON.stringify(n)),i=Math.ceil(r.length/4)*4,a=new Uint8Array(20+i+e.length-t);if(a.length>qn)throw Error("Runtime export exceeds 64 MiB");a.set(e.subarray(0,20));let s=new DataView(a.buffer);return s.setUint32(8,a.length,!0),s.setUint32(12,i,!0),a.fill(32,20,20+i),a.set(r,20),a.set(e.subarray(t),20+i),a}async function Yz(e,t,n={}){let[{deliverRuntimeThreeGlb:r},{MeshoptEncoder:i}]=await Promise.all([Promise.resolve().then(() => (PR(),NR)),Promise.resolve().then(() => (zR(),UR))]);await i.ready;let a=await r(e,i,t,n);if(a.glb.byteLength>qn)throw Error("Runtime export exceeds 64 MiB");return a}async function GR(e,t={}){let n=t.profile??"editable";if(n!=="editable"&&n!=="runtime")throw Error("Unknown export profile");if(t.target!==void 0&&t.target!=="three")throw Error("Unknown runtime export target");if(t.target!==void 0&&n!=="runtime")throw Error("A runtime export target requires the runtime profile");if(t.compression!==void 0&&t.target!=="three")throw Error("Runtime compression requires the three runtime target");if(t.maxLod!==void 0&&t.target!=="three")throw Error("Runtime maxLod requires the three runtime target");if(t.positionBits!==void 0&&t.target!=="three")throw Error("Runtime positionBits requires the three runtime target");let r=t.textures;if(r!==void 0&&r!=="manifest"&&r!=="external")throw Error("Unknown runtime texture option");if(r!==void 0&&n!=="runtime")throw Error("A texture manifest requires the runtime profile");if(r==="external"&&t.target!=="three")throw Error("External textures require target three");let i=t.gltfFileName??"runtime.gltf";if(r==="external")qz(i);Xu(e);let a=e.files["asset.glb"];if(n==="editable")return{profile:n,glb:a};let s=t.metadataFileName??"runtime.kiln-metadata.json";Xz(s);for(let[T,N]of Object.entries(e.files))if(await BR(N)!==e.manifest.files[T].sha256)throw Error(`Asset integrity mismatch: ${T}`);let{json:o,jsonEnd:c}=jR(a),l=o.asset;if(Eb(l,"extras")&&!oc(l.extras))throw Error("Cannot add provenance to non-object asset extras");let u=l.extras??{};if(Eb(u,"kilnProvenanceV1"))throw Error("Asset extras already contain kilnProvenanceV1; export from the canonical revision");let d=[];if(o.scenes!==void 0&&!Array.isArray(o.scenes))throw Error("Invalid glTF scenes");for(let[T,N]of(o.scenes??[]).entries()){if(!oc(N)||!oc(N.extras)||!Eb(N.extras,"kilnReviewClipsV1"))continue;let M=N.extras.kilnReviewClipsV1;if(!oc(M)||M.version!==1&&M.version!==2||!Array.isArray(M.clips))throw Error("Unsupported scenes[].extras.kilnReviewClipsV1");d.push({index:T,kilnReviewClipsV1:M}),delete N.extras.kilnReviewClipsV1}let f={version:"kiln.runtime-metadata.v1",source:{assetId:e.manifest.assetId,revisionId:e.manifest.revisionId,glbSha256:e.manifest.files["asset.glb"].sha256,...e.manifest.files["source.kiln.js"]?{sourceSha256:e.manifest.files["source.kiln.js"].sha256}:{}},scenes:d},h=a,b=o,m=c,g,p;if(t.target==="three"){let T=await Yz(VR(a,c,o),{...t.ktx2Encoder?{ktx2Encoder:t.ktx2Encoder}:{},...t.compression?{compression:t.compression}:{},...t.maxLod!==void 0?{maxLod:t.maxLod}:{},...t.positionBits!==void 0?{positionBits:t.positionBits}:{}},r==="external"?{gltfBasename:i.slice(0,-5)}:{});f.target="three",f.delivery=T.delivery,h=T.glb,g=T.imageSources,p=T.gltf,{json:b,jsonEnd:m}=jR(h)}if(r!==void 0)f.textures=await Kw(b,Jz(h,m),{...g?{sources:g}:{},maps:Zz(e)});let y=p?await Qz(p,f.textures??[]):void 0,v=Ab.encode(JSON.stringify(f));if(v.length>qn)throw Error("Runtime export exceeds 64 MiB");let x={version:"kiln.provenance.v1",profile:"runtime",...t.target?{target:t.target}:{},metadata:{uri:s,sha256:await BR(v)}},_=b.asset;_.extras={..._.extras??u,kilnProvenanceV1:x};let E=VR(h,m,b);if(!y)return{profile:n,glb:E,metadata:{name:s,bytes:v}};let w=y.json.asset;w.extras={...w.extras??u,kilnProvenanceV1:x};let A=Ab.encode(JSON.stringify(y.json));if(A.length>qn)throw Error("Runtime export exceeds 64 MiB");return{profile:n,layout:"gltf",glb:E,gltf:{name:i,bytes:A},buffers:y.buffers,textures:y.textures,metadata:{name:s,bytes:v}}}async function Qz(e,t){let n=structuredClone(e.json),r=new Map(Object.entries(e.resources)),i=Array.isArray(n.images)?n.images:[];if(i.length!==t.length)throw Error("External texture layout mismatch");let a=new Map;for(let[o,c]of i.entries()){let l=t[o],u=typeof c.uri==="string"?c.uri:"",d=r.get(u);if(!d||`sha256:${await ec(d)}`!==l.sha256)throw Error("External texture bytes differ from the delivered GLB");r.delete(u);let f=`textures/${l.sha256.slice(7)}.${Ww(l.mimeType)}`;c.uri=f,l.uri=f,a.set(f,{uri:f,sha256:l.sha256,bytes:d})}let s=[...r].map(([o,c])=>({uri:o,bytes:c}));for(let{uri:o}of s)if(!/^[a-z0-9][a-z0-9._-]*\.bin$/i.test(o))throw Error(`Unexpected external glTF resource ${o}`);return{json:n,buffers:s,textures:[...a.values()]}}var qr=Fe().regex(/^[a-z][a-z0-9_-]{0,79}$/).refine((e)=>!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(e),"Reserved filesystem name"),wb=Fe().regex(/^r_[0-9]{10}_[a-f0-9]{64}$/),WR=Fe().regex(/^sha256:[a-f0-9]{64}$/),cc=Fe().max(4000),XR=Fe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),HR=ge({collectionId:qr,assetId:qr,revisionId:qr}).strict(),Vf=He().min(-1e6).max(1e6),$R=Iu([Vf,Vf,Vf]),Tb=Vf.min(-1000).max(1000).refine((e)=>e!==0,{message:"A zero scale collapses the module."}),eB=ge({translation:$R.optional(),rotation:$R.optional(),scale:Iu([Tb,Tb,Tb]).optional()}).strict(),KR=ge({style:cc.default(""),scale:Fe().max(1000).default(""),palette:at(ge({role:Fe().min(1).max(100),color:Fe().regex(/^#[a-fA-F0-9]{6}$/)}).strict()).max(64).default([]),materialRoles:at(ge({role:Fe().min(1).max(100),description:cc.default(""),resourceId:XR.optional()}).strict()).max(128).default([]),conventions:at(Fe().max(1000)).max(100).default([]),exceptions:at(Fe().max(1000)).max(100).default([])}).strict(),tB=ge({resourceId:XR,revisionId:Fe().min(1).max(200),sha256:WR,role:Fe().max(100).optional()}).strict(),nB=at(tB).max(512),Ei={name:Fe().trim().min(1).max(200),brief:Fe().max(16000).default(""),design:KR.default(()=>KR.parse({})),inventory:at(ge({id:qr,name:Fe().trim().min(1).max(200),kind:wt(["asset","environment"]).default("asset"),brief:cc.default(""),references:at(qr).max(64).default([]),asset:HR.optional(),placement:eB.optional()}).strict()).max(1000).default([]),deliveryProfiles:at(ge({id:qr,target:wt(["three","godot","unity","unreal","roblox","sbox","usdz","custom"]),description:cc.default(""),performanceIntent:Fe().max(1000).default(""),constraints:at(Fe().max(1000)).max(100).default([])}).strict()).max(32).default([]),materialDependencies:nB.default([]),references:at(ge({id:qr,title:Fe().min(1).max(200),uri:Fe().min(1).max(2048),description:cc.default(""),sha256:WR.optional()}).strict()).max(256).default([]),reviews:at(ge({id:qr,inventoryId:qr,projectRevisionId:wb,asset:HR,reviewer:Fe().trim().min(1).max(200),verdict:wt(["comment","changes-requested","accepted"]),notes:cc}).strict()).max(2000).default([])};function qR(e,t){let n=(s,o)=>{if(new Set(s).size!==s.length)t.addIssue({code:Nu.custom,path:[o],message:"Duplicate identity"})};n(e.inventory.map((s)=>s.id),"inventory"),n(e.references.map((s)=>s.id),"references"),n(e.deliveryProfiles.map((s)=>s.id),"deliveryProfiles"),n(e.materialDependencies.map((s)=>s.resourceId),"materialDependencies"),n(e.reviews.map((s)=>s.id),"reviews"),n(e.design.palette.map((s)=>s.role),"design.palette"),n(e.design.materialRoles.map((s)=>s.role),"design.materialRoles");let r=new Set(e.references.map((s)=>s.id)),i=new Set(e.inventory.map((s)=>s.id)),a=new Set(e.materialDependencies.map((s)=>s.resourceId));for(let s of e.inventory)if(n(s.references,`inventory.${s.id}.references`),s.references.some((o)=>!r.has(o)))t.addIssue({code:Nu.custom,path:["inventory"],message:"Unknown reference"});if(e.reviews.some((s)=>!i.has(s.inventoryId)))t.addIssue({code:Nu.custom,path:["reviews"],message:"Unknown inventory item"});if(e.design.materialRoles.some((s)=>s.resourceId&&!a.has(s.resourceId)))t.addIssue({code:Nu.custom,path:["design"],message:"Material role requires a locked resource"})}var JR=ge({projectId:qr.optional(),...Ei}).strict().superRefine(qR),uq=ge({name:Ei.name.optional(),brief:Ei.brief.removeDefault().optional(),design:Ei.design.removeDefault().optional(),inventory:Ei.inventory.removeDefault().optional(),deliveryProfiles:Ei.deliveryProfiles.removeDefault().optional(),materialDependencies:Ei.materialDependencies.removeDefault().optional(),references:Ei.references.removeDefault().optional(),reviews:Ei.reviews.removeDefault().optional()}).strict(),dq=ge({version:Ge("kiln.project.v1"),projectId:qr,revisionId:wb,parentRevision:wb.optional(),createdAt:Fe().datetime(),...Ei}).strict().superRefine(qR);function ZR(e){if(!e)return"Not composed";let{translation:t,rotation:n,scale:r}=e;return[t&&`Move ${t.join(", ")}`,n&&`turn ${n.join(", ")}°`,r&&`scale ${r.join(", ")}`].filter(Boolean).join(" · ")||"At origin"}function YR(e){let{palette:t,materialRoles:n,conventions:r,exceptions:i}=e.design??{};return{design:{palette:t??[],materialRoles:n??[],conventions:r??[],exceptions:i??[]},inventory:e.inventory??[],deliveryProfiles:e.deliveryProfiles??[],materialDependencies:e.materialDependencies??[],references:e.references??[],reviews:e.reviews??[]}}function QR(e,t){let n=JSON.parse(e);if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Project configuration must be a JSON object.");let r=n,i=r.design??{};if(!i||typeof i!=="object"||Array.isArray(i))throw Error("Design configuration must be a JSON object.");return JR.parse({...r,name:t.name,brief:t.brief,design:{...i,style:t.style,scale:t.scale}})}function eI(e){let t=[],n=Ia("kiln.project")??"",r,i=()=>{let c=ue("project-list");c.replaceChildren();for(let v of t){let x=L("button",void 0,v.projectId===n?"active":"");if(x.append(L("strong",v.name),L("small",`${v.inventory.length} inventory items · ${v.materialDependencies.length} resources`)),v.projectId===n)x.setAttribute("aria-current","true");x.onclick=()=>{n=v.projectId,$r("kiln.project",n),i()},c.append(x)}let l=t.find((v)=>v.projectId===n),u=ue("project-detail");if(u.replaceChildren(),!l){u.append(Yo("A direction for what comes next.","Projects are optional. Group related assets, materials and design decisions here, or build and review standalone assets in Library and Live Review."));return}let d=L("div",void 0,"project-summary"),f=L("div");f.append(L("h2",l.name),L("p",l.brief||"Add a brief to describe what this project should deliver."));let h=L("button","Edit project","secondary");h.onclick=()=>s(l),d.append(f,h),u.append(d);let b=L("p",`${l.projectId} · ${Tn(l.revisionId)} · ${new Date(l.createdAt).toLocaleString()}`,"mono");u.append(b);let m=L("div",void 0,"project-metrics");for(let[v,x]of[[l.inventory.length,"inventory items"],[l.materialDependencies.length,"locked resources"],[l.deliveryProfiles.length,"delivery profiles"]]){let _=L("div");_.append(L("strong",String(v)),L("span",String(x))),m.append(_)}u.append(m);let g=L("div",void 0,"profile-grid");for(let[v,x]of[["Visual direction",l.design.style||"Not specified"],["Scale",l.design.scale||"Not specified"]]){let _=L("div");_.append(L("span",v,"label"),L("p",x)),g.append(_)}u.append(g);let p=L("div",void 0,"palette");for(let v of l.design.palette){let x=L("div",void 0,"swatch"),_=document.createElementNS("http://www.w3.org/2000/svg","svg");_.setAttribute("viewBox","0 0 24 24"),_.setAttribute("aria-hidden","true");let E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("width","24"),E.setAttribute("height","24"),E.setAttribute("fill",v.color),_.append(E);let w=L("span",v.role);w.append(L("small",v.color)),x.append(_,w),p.append(x)}if(p.childElementCount)u.append(p);for(let[v,x]of[["Conventions",l.design.conventions],["Declared exceptions",l.design.exceptions]]){if(!x.length)continue;u.append(L("h3",v));let _=L("ul",void 0,"subtle");for(let E of x)_.append(L("li",E));u.append(_)}if(u.append(L("h3","Inventory")),!l.inventory.length)u.append(L("p","No inventory yet. Add deliberate asset and environment entries in the project configuration.","subtle"));else{let v=L("div",void 0,"table-wrap"),x=L("table"),_=L("thead"),E=L("tr");for(let A of["Item","Kind","Saved revision","Placement","Review"])E.append(L("th",A));_.append(E),x.append(_);let w=L("tbody");for(let A of l.inventory){let T=L("tr"),N=L("td",A.name);N.append(L("small",A.brief));let M=L("td"),R=L("td");if(A.asset){let C=L("button",Tn(A.asset.revisionId),"secondary");C.onclick=()=>e.openAsset(A.asset),M.append(C);let U=[...l.reviews].reverse().find((P)=>P.inventoryId===A.id&&P.asset.revisionId===A.asset.revisionId&&P.asset.assetId===A.asset.assetId&&P.asset.collectionId===A.asset.collectionId);R.append(L("small",U?`${U.verdict} · ${U.reviewer}`:"Unreviewed"));let D=L("button","Record review","secondary");D.onclick=()=>o(l,A),R.append(D)}else M.textContent="Not linked",R.textContent="No saved revision";let k=L("td",ZR(A.placement));T.append(N,L("td",A.kind),M,k,R),w.append(T)}x.append(w),v.append(x),u.append(v)}if(l.design.materialRoles.length){u.append(L("h3","Material roles"));for(let v of l.design.materialRoles)u.append(L("p",`${v.role}: ${v.description||"No description"}${v.resourceId?` · ${v.resourceId}`:" · No resource assigned"}`,"subtle"))}if(l.deliveryProfiles.length){u.append(L("h3","Delivery intent"));for(let v of l.deliveryProfiles){if(u.append(L("p",`${v.target} · ${v.description||v.id}`,"subtle")),v.performanceIntent)u.append(L("p",v.performanceIntent,"subtle"));for(let x of v.constraints)u.append(L("p",x,"subtle"))}u.append(L("p","Declared targets are project intent. They do not establish consumer or performance qualification.","subtle"))}if(l.references.length){u.append(L("h3","Reference records"));for(let v of l.references){let x=L("p",`${v.title}: ${v.uri}`,"subtle");if(v.description)x.append(L("small",` · ${v.description}`));u.append(x)}}u.append(L("h3","Project downloads"));let y=L("div",void 0,"downloads");for(let v of["editable","runtime"]){let x=L("a",v==="editable"?"Download editable project bundle":"Download runtime project bundle"),_=new URLSearchParams({profile:v,revision:l.revisionId});x.href=`/api/projects/${encodeURIComponent(l.projectId)}/bundle?${_}`,x.download=`${l.projectId}-${v}.zip`,y.append(x)}y.append(L("p","Both downloads bind this exact project revision and its linked saved inventory. Editable includes authored source and material resources for rebuilding. Runtime is delivery-only and cannot restore editable source. Unlinked inventory entries remain plans, not bundled assets.")),u.append(y),u.append(Qo("Exact project configuration and review records",l))},a=async()=>{let c=await un("/api/projects");if(t.length===c.projects.length&&t.every((l,u)=>l.revisionId===c.projects[u]?.revisionId))return;if(t=c.projects,!t.some((l)=>l.projectId===n))n=t[0]?.projectId??"";i(),e.changed(t)};function s(c){r=c,ue("project-editor-title").textContent=c?"Edit project":"New project",ue("project-name").value=c?.name??"",ue("project-brief").value=c?.brief??"",ue("project-style").value=c?.design.style??"",ue("project-scale").value=c?.design.scale??"",ue("project-config").value=JSON.stringify(YR(c??{name:""}),null,2),ue("project-save-status").textContent="",ue("project-editor").showModal(),ue("project-name").focus()}function o(c,l){if(!l.asset)return;let u=L("dialog"),d=L("form"),f=L("div",void 0,"editor-content"),h=L("h2",`Review ${l.name}`);h.id="review-dialog-title",u.setAttribute("aria-labelledby",h.id),f.append(h,L("p","Record an assessment of this exact saved revision. This is a review annotation; structural QA and release qualification remain separate.","subtle"),L("code",`${l.asset.assetId} / ${l.asset.revisionId}`,"mono"));let b=L("input");b.required=!0,b.value=Ia("kiln.reviewer")??"",b.maxLength=200;let m=L("label","Reviewer","field");m.append(b);let g=L("select");for(let[w,A]of[["comment","Comment"],["changes-requested","Changes requested"],["accepted","Visually accepted"]])g.append(new Option(A,w));let p=L("label","Assessment","field");p.append(g);let y=L("textarea");y.rows=4,y.maxLength=4000;let v=L("label","Notes","field");v.append(y);let x=L("p");x.setAttribute("role","status");let _=L("button","Save review");_.type="submit";let E=L("button","Cancel","secondary");E.type="button",E.onclick=()=>u.close(),f.append(m,p,v,x,_,E),d.append(f),u.append(d),document.body.append(u),u.addEventListener("close",()=>u.remove()),d.onsubmit=async(w)=>{w.preventDefault(),_.disabled=!0,x.textContent="Saving review…";try{await un(`/api/projects/${encodeURIComponent(c.projectId)}`,{method:"PATCH",body:{expectedRevision:c.revisionId,patch:{reviews:[...c.reviews,{id:`review_${crypto.randomUUID().replaceAll("-","")}`,inventoryId:l.id,projectRevisionId:c.revisionId,asset:l.asset,reviewer:b.value.trim(),verdict:g.value,notes:y.value}]}}}),$r("kiln.reviewer",b.value.trim()),u.close(),await a()}catch(A){x.textContent=A instanceof Error?A.message:String(A)}finally{_.disabled=!1}},u.showModal(),b.focus()}return ue("new-project").onclick=()=>s(),ue("close-project-editor").onclick=()=>ue("project-editor").close(),ue("project-form").onsubmit=async(c)=>{c.preventDefault();let l=ue("save-project");l.disabled=!0,ue("project-save-status").textContent="Saving revision…";try{let u=QR(ue("project-config").value,{name:ue("project-name").value,brief:ue("project-brief").value,style:ue("project-style").value,scale:ue("project-scale").value});n=(await un(r?`/api/projects/${encodeURIComponent(r.projectId)}`:"/api/projects",r?{method:"PATCH",body:{expectedRevision:r.revisionId,patch:u}}:{method:"POST",body:u})).projectId,$r("kiln.project",n),ue("project-editor").close(),In("Project revision saved."),await a()}catch(u){ue("project-save-status").textContent=u instanceof Error?u.message:String(u)}finally{l.disabled=!1}},{refresh:a}}var rB="Raw map pixels · unshaded · not GPU capture evidence",Mb=/^[a-z][a-z0-9_-]{0,79}$/,Sb=/^sha256:[a-f0-9]{64}$/;function Hl(e){let t=new URLSearchParams(e.startsWith("?")?e:e.slice(e.indexOf("?")+1)),n=t.get("material"),r=t.get("materialRevision");if(t.getAll("material").length!==1||t.getAll("materialRevision").length!==1||!n||!r||!Mb.test(n)||!Sb.test(r))return;return{materialId:n,revisionId:r}}function Gf(e){if(!Mb.test(e.materialId)||!Sb.test(e.revisionId))throw Error("Invalid exact material selection");return`/?${new URLSearchParams({material:e.materialId,materialRevision:e.revisionId})}`}function Rb(e){if(!Mb.test(e.materialId)||!Sb.test(e.revisionId))throw Error("Invalid exact material selection");return`/api/materials/${encodeURIComponent(e.materialId)}/${encodeURIComponent(e.revisionId)}`}function tI(e){let t=uo(e),n=Rb(t),r=t.maps.map((i)=>{let a="recipe"in i?i:void 0,s=a?.recipe?.kind==="atlas"?a.recipe:void 0;return{slot:i.slot,file:i.file,url:`${n}/${encodeURIComponent(i.file)}`,width:i.width,height:i.height,colorSpace:i.colorSpace,imageSha256:i.sha256,..."pixelHash"in i?{pixelHash:i.pixelHash}:{},..."sampler"in i?{sampler:{...i.sampler}}:{},atlas:!!s,...a?.recipe?{compilerId:a.recipe.compilerId}:{},...s?{manifestHash:s.manifest.manifestHash}:{},regions:s?s.manifest.regions.map((o)=>({name:o.name,content:{...o.content},allocation:{...o.allocation},leftPercent:o.content.x/i.width*100,topPercent:o.content.y/i.height*100,widthPercent:o.content.width/i.width*100,heightPercent:o.content.height/i.height*100})):[]}});return{materialId:t.materialId,revisionId:t.revisionId,name:t.name,fidelity:rB,maps:r}}function nI(e,t){if(!e||typeof e!=="object"||Array.isArray(e)||e.artifactGlbSha256!==t)throw Error("Retained evaluation does not identify the displayed artifact");let n=e.materialLibraryDependencies;if(n===void 0)return[];if(!Array.isArray(n)||n.length>16)throw Error("Invalid retained material dependency list");let r=new Map;for(let i of n){let a=uo(i),s=`${a.materialId}/${a.revisionId}`,o=r.get(s);if(o&&Nn(o)!==Nn(a))throw Error("Conflicting retained material identity");r.set(s,a)}return[...r.values()]}function Hf(e){let t=tI(e),n=L("section",void 0,"material-inspection");n.setAttribute("aria-label",`${t.name}: exact material maps`),n.append(L("p",`${t.materialId} · ${t.revisionId}`,"mono"),L("p",t.fidelity,"subtle"));let r=L("div",void 0,"material-inspection-controls"),i=(_,E)=>{let w=L("label",_,"inline-field");return w.append(E),r.append(w),E},a=i("Map",L("select"));for(let _ of t.maps)a.append(new Option(`${_.slot}${_.atlas?" · atlas":""}`,_.slot));let s=i("Backdrop",L("select"));for(let _ of["checker","light","dark"])s.append(new Option(_[0].toUpperCase()+_.slice(1),_));let o=i("Pixel zoom",L("select"));for(let _ of[1,2,4])o.append(new Option(`${_}×`,String(_)));let c=L("div",void 0,"material-pixel-frame"),l=L("div",void 0,"material-pixel-sheet");c.dataset.backdrop="checker",c.tabIndex=0;let u=L("img");u.className="material-pixel-image",u.loading="lazy",u.draggable=!1;let d=L("div",void 0,"material-region-overlay"),f=L("label","Region overlays","inline-field"),h=L("input");h.type="checkbox",h.checked=!1,f.append(h),r.append(f),h.onchange=()=>{d.hidden=!h.checked},l.append(u,d),c.append(l);let b=L("p",void 0,"subtle");b.setAttribute("role","status");let m=L("dl"),g=L("div",void 0,"material-region-list"),p=L("a","Open this saved material revision");p.href=Gf(t),p.target="_blank",p.rel="noopener",n.append(r,c,b,m,g,p);let y=t.maps[0],v=()=>{l.style.width=`${y.width*Number(o.value)}px`,l.style.height=`${y.height*Number(o.value)}px`},x=()=>{y=t.maps.find((E)=>E.slot===a.value)??t.maps[0],f.hidden=!y.atlas,d.hidden=!y.atlas||!h.checked,b.textContent="Loading exact saved map…",u.alt=`${t.name}: ${y.slot}${y.atlas?" atlas sheet":""}, raw unshaded pixels`,u.width=y.width,u.height=y.height,u.src=y.url,v(),m.replaceChildren();let _=(E,w)=>m.append(L("dt",E),L("dd",w));if(_("Image",`${y.width} × ${y.height} · ${y.colorSpace} · nearest pixel display`),_("Sampling declaration",y.sampler?`${y.sampler.minFilter} / ${y.sampler.magFilter} · ${y.sampler.wrapS} / ${y.sampler.wrapT}`:"Not recorded in V1"),_("PNG hash",y.imageSha256),y.pixelHash)_("Decoded RGBA hash",y.pixelHash);if(y.compilerId)_("Compiler",y.compilerId);if(y.manifestHash)_("Atlas manifest hash",y.manifestHash);if(d.replaceChildren(),g.replaceChildren(),y.atlas){g.append(L("h4","Atlas regions · top-left pixel coordinates"));for(let E of y.regions){let w=L("span",void 0,"material-region-box");w.style.left=`${E.leftPercent}%`,w.style.top=`${E.topPercent}%`,w.style.width=`${E.widthPercent}%`,w.style.height=`${E.heightPercent}%`,w.append(L("span",E.name)),w.setAttribute("aria-hidden","true"),d.append(w);let A=L("button",`${E.name}: content ${E.content.x},${E.content.y} ${E.content.width}×${E.content.height}; allocation ${E.allocation.x},${E.allocation.y} ${E.allocation.width}×${E.allocation.height}`,"secondary");A.type="button",A.setAttribute("aria-pressed","false"),A.onclick=()=>{for(let T of d.children)T.classList.remove("selected");for(let T of g.querySelectorAll("button"))T.setAttribute("aria-pressed","false");if(w.classList.add("selected"),A.setAttribute("aria-pressed","true"),!d.hidden)w.scrollIntoView({block:"nearest",inline:"nearest"})},g.append(A)}}};return u.onload=()=>{b.textContent="Raw map loaded. These pixels are not a shaded capture."},u.onerror=()=>{b.textContent=`Exact ${t.materialId} revision map unavailable. No newer revision was substituted.`},a.onchange=x,s.onchange=()=>{c.dataset.backdrop=s.value},o.onchange=v,x(),n}function rI(e){if(!e.presetId.trim())throw Error("Choose a material preset");if(!e.seed.trim())throw Error("Enter an explicit seed");let t=Number(e.seed),n=Number(e.size);if(!Number.isInteger(t)||t<-2147483648||t>2147483647)throw Error("Seed must be a signed 32-bit integer");if(![64,128,256,512].includes(n))throw Error("Choose a supported map size");if(!e.creator.trim()||!e.spdx.trim()||!e.url.trim())throw Error("Creator and license details are required");let r=new URL(e.url.trim());if(r.protocol!=="https:"&&r.protocol!=="http:")throw Error("License URL must be HTTP(S)");return{presetId:e.presetId,seed:t,size:n,creator:e.creator.trim(),license:{spdx:e.spdx.trim(),url:e.url.trim(),attribution:e.attribution}}}function iI(e){let t=[],n=[],r=[],i=ue("materials-project"),a=L("button","Create from preset");ue("materials-refresh").before(a);let s=L("dialog");s.setAttribute("aria-labelledby","material-preset-heading");let o=L("form"),c=L("div",void 0,"detail-top"),l=L("h2","Create a material resource");l.id="material-preset-heading";let u=L("button","Cancel","secondary");u.type="button",u.onclick=()=>s.close(),c.append(l,u);let d=L("div",void 0,"editor-content");d.append(L("p","Offline starting recipes with editable layers and height-derived normals. Choose an explicit seed and provenance for the resource. Map images are not shaded material previews.","subtle"));function f(M,R){let k=L("label",M,"field");return k.append(R),d.append(k),R}let h=f("Preset",L("select")),b=L("p",void 0,"subtle");d.append(b);let m=f("Seed",L("input"));m.type="number",m.step="1",m.required=!0,m.min="-2147483648",m.max="2147483647",m.value="0";let g=f("Map size",L("select"));for(let M of[64,128,256,512])g.append(new Option(`${M} × ${M}`,String(M)));g.value="256";let p=f("Creator",L("input"));p.required=!0,p.maxLength=1000;let y=f("License identifier",L("input"));y.required=!0,y.placeholder="For example, CC0-1.0";let v=f("License URL",L("input"));v.type="url",v.required=!0;let x=f("Attribution text",L("textarea"));x.rows=2;let _=L("p");_.setAttribute("role","status");let E=L("button","Create resource");E.type="submit",d.append(_,E),o.append(c,d),s.append(o),document.body.append(s);let w=()=>{let M=r.find((R)=>R.id===h.value);b.textContent=M?`${M.description} Repeat scale: ${M.physicalSizeMeters.width} × ${M.physicalSizeMeters.height} m.`:""};h.onchange=w,a.onclick=async()=>{a.disabled=!0;try{r=(await un("/api/material-presets")).presets,h.replaceChildren(...r.map((M)=>new Option(M.name,M.id))),w(),_.textContent="",E.disabled=!r.length,s.showModal()}catch(M){In(M)}finally{a.disabled=!1}},o.onsubmit=async(M)=>{M.preventDefault(),E.disabled=!0,_.textContent="Creating immutable material resource…";try{let R=rI({presetId:h.value,seed:m.value,size:g.value,creator:p.value,spdx:y.value,url:v.value,attribution:x.value}),k=await un("/api/materials/preset",{method:"POST",body:R});await N(),s.close(),In(`${k.material.name} created at ${k.material.revisionId}. Ready for standalone assets. You can also lock this revision to an optional project.`)}catch(R){_.textContent=R instanceof Error?R.message:String(R)}finally{E.disabled=!1}};let A=Rb;function T(){let M=n.find((D)=>D.projectId===i.value),R=ue("material-dependencies");if(R.replaceChildren(),M)if(R.append(L("h2",`${M.name}: locked resources`)),!M.materialDependencies.length)R.append(L("p","No materials are locked to this project yet. Select a resource revision below or configure dependencies with your agent.","subtle"));else{let D=L("table"),P=L("thead"),K=L("tr"),z=L("tbody");for(let q of["Resource / role","Exact revision","Local availability"])K.append(L("th",q));P.append(K),D.append(P);for(let q of M.materialDependencies){let le=t.find((pe)=>pe.materialId===q.resourceId&&pe.revisionId===q.revisionId),he=L("tr"),xe=L("td",q.resourceId);xe.append(L("small",q.role??M.design.materialRoles.filter((pe)=>pe.resourceId===q.resourceId).map((pe)=>pe.role).join(", "))),he.append(xe,L("td",q.revisionId,"mono"),L("td",le&&le.revisionId===q.sha256?"Exact local record available":le?"Dependency hash differs":"Not in local catalog")),z.append(he)}D.append(z);let W=L("div",void 0,"table-wrap");W.append(D),R.append(W)}let k=ue("material-list");k.replaceChildren();let C=ue("material-search").value.trim().toLowerCase(),U=t.filter((D)=>`${D.name} ${D.materialId} ${D.tags.join(" ")} ${D.sources.map((P)=>P.provider).join(" ")}`.toLowerCase().includes(C));if(ue("material-count").textContent=`${U.length} material revision${U.length===1?"":"s"}`,!U.length){k.append(Yo(C?"No matching materials":"Your material catalog starts here",C?"Try another material name, tag or provider.":"Materials added through Kiln appear here with their map roles, source records and exact revisions."));return}for(let D of U){let P=L("article",void 0,"material-card"),K=D.maps.find((F)=>F.slot==="baseColor")??D.maps[0];if(K){let F=L("img");F.src=`${A(D)}/${encodeURIComponent(K.file)}`,F.alt=`${D.name}: ${K.slot} map, not a shaded material preview`,F.loading="lazy",F.className="material-map",P.append(F,L("p",`${K.slot} map · unshaded`,"subtle"))}P.append(L("h3",D.name),L("p",D.tags.join(" · "),"subtle"));let z=L("dl"),W=(F,X)=>z.append(L("dt",F),L("dd",X));W("Revision",D.revisionId),W("Physical scale",D.physicalSizeMeters?`${D.physicalSizeMeters.width} × ${D.physicalSizeMeters.height} m`:"Not specified"),W("Tiling",D.tileable?"Declared tileable":"Not declared tileable"),W("Maps",D.maps.map((F)=>`${F.slot} ${F.width}×${F.height} (${F.colorSpace})`).join(" · ")),W("Surface factors",`Roughness ×${D.parameters.roughness} · Metalness ×${D.parameters.metalness}${D.maps.some((F)=>F.slot==="metallicRoughness")?" · multiplied by packed map channels":""}`),P.append(z);for(let F of D.sources){let X=L("p",`${F.provider} · ${F.creator} · ${F.kind}`,"subtle"),ne=L("a",F.license.spdx);if(ne.href=F.license.url,ne.target="_blank",ne.rel="noreferrer",X.append(document.createTextNode(" · "),ne),F.assetUrl){let re=L("a","Source");re.href=F.assetUrl,re.target="_blank",re.rel="noreferrer",X.append(document.createTextNode(" · "),re)}if(P.append(X),F.license.attribution)P.append(L("p",F.license.attribution,"subtle"))}let q=L("div",void 0,"material-map-links");for(let F of D.maps){let X=L("a",F.slot);X.href=`${A(D)}/${encodeURIComponent(F.file)}`,X.target="_blank",X.rel="noopener",q.append(X)}P.append(q);let le=L("details",void 0,"material-map-inspection");le.append(L("summary","Inspect maps and atlas regions"));let he=!1;le.ontoggle=()=>{if(le.open&&!he)he=!0,le.append(Hf(D))};let xe=Hl(location.search);if(xe?.materialId===D.materialId&&xe.revisionId===D.revisionId)le.open=!0,P.dataset.selectedMaterial="true";P.append(le);let pe=M?.materialDependencies.find((F)=>F.resourceId===D.materialId),J=L("button",pe?.revisionId===D.revisionId?"Locked to project":pe?"Use this revision":"Add to project","secondary");if(J.disabled=!M||pe?.revisionId===D.revisionId,!M)J.title="Select a project to add a material dependency";J.onclick=async()=>{if(!M)return;J.disabled=!0;try{let F=M.materialDependencies.filter((X)=>X.resourceId!==D.materialId);F.push({resourceId:D.materialId,revisionId:D.revisionId,sha256:D.revisionId,...pe?.role?{role:pe.role}:{}}),await un(`/api/projects/${encodeURIComponent(M.projectId)}`,{method:"PATCH",body:{expectedRevision:M.revisionId,patch:{materialDependencies:F}}}),In(`${D.name} is locked to ${M.name} at this exact revision.`),await e()}catch(F){In(F),J.disabled=!1}},P.append(J,Qo("Map recipes, transformations and provenance",D)),k.append(P)}}let N=async()=>{t=(await un("/api/materials")).materials,T();let M=Hl(location.search);if(M&&!t.some((R)=>R.materialId===M.materialId&&R.revisionId===M.revisionId))In(`Exact material revision unavailable: ${M.materialId} at ${M.revisionId}. No newer revision was selected.`)};return ue("material-search").oninput=T,i.onchange=T,ue("materials-refresh").onclick=()=>void N().catch(In),{refresh:N,projects(M){n=M;let R=i.value;i.replaceChildren(new Option("All materials",""));for(let k of n)i.append(new Option(k.name,k.projectId));if(n.some((k)=>k.projectId===R))i.value=R;T()}}}function Ib(e,t,n){return n?`${n.triangles.toLocaleString()} triangles displayed · ${t}`:`${e.triangles.toLocaleString()} triangles · ${e.meshes} meshes · ${t}`}var aI=(e,t)=>e.startedAt.localeCompare(t.startedAt)||e.operationId.localeCompare(t.operationId);function $l(e,t){let n=new Map(e.operations.map((c)=>[c.operationId,c])),r=t.map((c)=>{let l=n.get(c.operationId);return l&&l.revision>c.revision?l:c}).sort(aI),i=(c)=>r.find((l)=>l.operationId===c?.operationId)??c,a=e.following?r.at(-1):i(e.selected),s=(c)=>!!c&&!!a&&c.projectId===a.projectId&&c.workId===a.workId&&aI(c,a)<=0&&(c.sessionId===a.sessionId||e.following&&e.crossRunContinuity===!0&&!!a.workId),o=a?.artifact?a:a?r.filter((c)=>c.artifact&&s(c)).at(-1)??(s(e.displayed)?e.displayed:void 0):void 0;return{...e,operations:r,selected:a,displayed:o,pinned:i(e.pinned)}}function Cb(e,t){return $l({...e,following:!1,selected:e.operations.find((n)=>n.operationId===t)??e.selected},e.operations)}function rs(e,t){return e?.artifact&&t?.artifact&&e.operationId===t.operationId&&e.revision===t.revision&&e.artifact.sha256===t.artifact.sha256?t:void 0}function sI(e,t,n,r){if(e.status!=="complete"||!e.artifact)throw Error("Save requires a completed operation with an artifact.");if(!rs(e,rs(r,n)))throw Error("The visible artifact changed or has not loaded. Close this dialog and review it before saving.");let i=t.trim();if(!i||i.length>200)throw Error("Choose an asset name of 1–200 characters.");return{path:`/api/live/${encodeURIComponent(e.operationId)}/save`,body:{expectedRevision:e.revision,name:i,collection:"project"}}}function $f(e,t,n,r){let i;e.onclick=async()=>{let a=n();if(!a){t.replaceChildren(L("p","Load an artifact before measuring.","subtle"));return}e.disabled=!0,t.replaceChildren(L("p","Measuring frame pacing for 3 seconds. Keep this viewport visible and the camera steady.","subtle"));try{let s=await Lw(()=>a.measure(3000),r),o=L("div",void 0,"evidence-card");o.append(L("h3","Exploratory browser measurement"),L("p","Other workloads are not controlled. This sample is not an isolated performance baseline or budget acceptance."),L("strong",`p50 ${s.frameMs.p50.toFixed(1)} ms · p95 ${s.frameMs.p95.toFixed(1)} ms`),L("p",`${s.frameMs.samples} frame intervals · ${(s.windowMs/1000).toFixed(2)} s · ${s.drawCalls} draws · ${s.triangles.toLocaleString()} rendered triangles`),L("p",`${s.geometryObjects} geometry objects · ${s.textureObjects} texture objects. These counts are not GPU memory bytes.`),L("p",`GLB parse to first frame submission: ${s.loadToFirstFrameMs?.toFixed(1)??"unavailable"} ms. Download time excluded.`),L("p",`${s.viewport.cssWidth}×${s.viewport.cssHeight} CSS pixels · DPR ${s.viewport.devicePixelRatio.toFixed(2)}. Frame pacing includes browser scheduling and vertical sync, not GPU execution timing.`));let c=Qo("Exact measurement receipt and limitations",s);if(i)URL.revokeObjectURL(i);i=URL.createObjectURL(new Blob([JSON.stringify(s,null,2)],{type:"application/json"}));let l=L("a","Download measurement receipt");l.href=i,l.download="kiln-viewer-performance.json",o.append(c,l),t.replaceChildren(o)}catch(s){t.replaceChildren(L("p",s instanceof Error?s.message:String(s),"subtle"))}finally{e.disabled=!1}}}function Nb(e,t,n,r){let i=e.inventory.find((s)=>s.id===t);if(!i&&!n)throw Error("Inventory item not found");let a=e.inventory.map((s)=>{if(s.id!==t)return s;let{asset:o,...c}=s;return n?{...c,asset:n}:c});if(!i&&n)a.push({id:t,name:r,kind:"asset",brief:"",references:[],asset:n});return{inventory:a}}async function Kl(e,t,n,r){e.replaceChildren(L("h3","Project membership"));let{projects:i}=await un("/api/projects");if(!e.isConnected)return;let a=L("div");e.append(a);let s=L("p");s.setAttribute("role","status");let o=()=>Kl(e,t,n,r);for(let m of i)for(let g of m.inventory){if(!g.asset||g.asset.collectionId!==t.collectionId||g.asset.assetId!==t.assetId)continue;let p=L("div",void 0,"membership-row");p.append(L("span",`${m.name} / ${g.name} · ${Tn(g.asset.revisionId)}${g.asset.revisionId===t.revisionId?" · this revision":" · another revision"}`));let y=L("button","Remove membership","secondary");y.onclick=async()=>{y.disabled=!0;try{await un(`/api/projects/${encodeURIComponent(m.projectId)}`,{method:"PATCH",body:{expectedRevision:m.revisionId,patch:Nb(m,g.id,null,n)}}),await r(),await o()}catch(v){s.textContent=`${v instanceof Error?v.message:v} Reopen membership to load the current project.`,y.disabled=!1}},p.append(y),a.append(p)}if(!a.childElementCount)a.append(L("p","This asset is standalone. Project membership is optional.","subtle"));if(!i.length){a.append(L("p","Create a named project in Projects to organize related assets."));return}let c=L("form"),l=L("select"),u=L("select"),d=L("label","Project","field"),f=L("label","Inventory item","field");d.append(l),f.append(u);for(let m of i)l.append(new Option(m.name,m.projectId));let h=()=>{let m=i.find((p)=>p.projectId===l.value);u.replaceChildren(new Option("Add as a new inventory item",""));for(let p of m.inventory)u.append(new Option(`${p.name}${p.asset?" (replace linked revision)":""}`,p.id));let g=m.inventory.find((p)=>p.asset?.collectionId===t.collectionId&&p.asset.assetId===t.assetId);if(g)u.value=g.id};l.onchange=h,h();let b=L("button","Link this exact revision");b.type="submit",c.append(d,f,L("p","Linking preserves the saved asset and its original build provenance. Replacing a link advances only this project.","subtle"),b,s),c.onsubmit=async(m)=>{m.preventDefault(),b.disabled=!0;let g=i.find((y)=>y.projectId===l.value),p=u.value||`asset_${crypto.randomUUID().replaceAll("-","")}`;try{await un(`/api/projects/${encodeURIComponent(g.projectId)}`,{method:"PATCH",body:{expectedRevision:g.revisionId,patch:Nb(g,p,t,n)}}),await r(),await o()}catch(y){s.textContent=`${y instanceof Error?y.message:y} Reopen membership to load the current project.`,b.disabled=!1}},a.append(c)}function oI(){let e={following:!0,crossRunContinuity:!0,operations:[]},t=[],n="",r=0,i=!1,a,s=0,o,c,l,u,d,f,h,b=0,m=0,g=!1,p=!1,y,v=ue("live-project"),x=ue("live-source"),_=(F)=>x.value?`${F}${F.includes("?")?"&":"?"}source=${encodeURIComponent(x.value)}`:F,E=ue("live-run"),w=ue("live-work"),A=()=>`kiln.live.selection.${x.value}.${v.value}.${w.value}.${E.value}`,T=()=>`kiln.live.pin.${x.value}`,N=()=>t.filter((F)=>(!E.value||F.sessionId===E.value)&&(!w.value||(w.value==="ungrouped"?!F.workId:F.workId===w.value))),M=(F,X)=>{let ne=ue("live-connection");ne.textContent=F?"Connected":"Reconnecting",ne.className=`pill ${F?"connected":"warning"}`,ue("connection-status").textContent=X};function R(){let F=w.value,X=[...new Set(t.flatMap((ce)=>ce.workId?[ce.workId]:[]))];if(w.replaceChildren(new Option("All authoring items",""),new Option("Ungrouped history","ungrouped"),...X.map((ce)=>new Option(ce,ce))),F==="ungrouped"||X.includes(F))w.value=F;let ne=E.value,re=[...new Set(t.map((ce)=>ce.sessionId))];E.replaceChildren(new Option("All runs",""));for(let ce of re){let ve=t.find((Re)=>Re.sessionId===ce);E.append(new Option(`${ve.transport} · ${Tn(ce)}`,ce))}if(re.includes(ne))E.value=ne}function k(){let F=ue("live-timeline"),X=F.scrollTop,ne=F.contains(document.activeElement)?document.activeElement.dataset.operation:void 0;if(F.replaceChildren(),!e.operations.length){F.append(Yo("Nothing observed yet","Actual Kiln operations will appear here. There is no agent running state to infer."));return}for(let re of[...e.operations].reverse()){let ce=L("button",void 0,`timeline-item ${re.status}${e.selected?.operationId===re.operationId?" selected":""}${re.pinned?" pinned":""}`);ce.dataset.operation=re.operationId;let ve=L("span",void 0,"timeline-meta");if(ve.append(L("span",re.transport.toUpperCase()),L("time",new Date(re.startedAt).toLocaleTimeString())),ce.append(ve,L("strong",re.tool.replace(/^kiln_/,"")),L("small",`${re.status} · ${re.artifact?"artifact available":"no artifact"}`),L("small",re.workId?`Item ${re.workId}`:`Ungrouped · run ${Tn(re.sessionId)}`)),ce.setAttribute("aria-label",`${re.tool}, ${re.status}, ${new Date(re.startedAt).toLocaleString()}`),e.selected?.operationId===re.operationId)ce.setAttribute("aria-current","true");if(ce.onclick=()=>{e=Cb(e,re.operationId),$r(A(),re.operationId),q()},F.append(ce),ne===re.operationId)ce.focus({preventScroll:!0})}F.scrollTop=X}function C(F){let X=L("div",void 0,"evidence-card");X.append(L("h3","Capture fidelity"));let ne=F.viewFidelity,re=ne&&typeof ne==="object"?ne:void 0;if(X.append(L("strong",re?String(re.delivered??"Reported"):"No capture receipt yet")),X.append(L("p",re?.materialFaithful===!0?"Material-faithful capture reported.":re?"Geometry evidence only. Do not use this capture to judge materials.":"The interactive viewport uses local browser lighting; it is not a recorded capture.")),re?.degradeReason)X.append(L("p",String(re.degradeReason)));if(re?.rendererId)X.append(L("p",`Renderer: ${String(re.rendererId)}`,"mono"));if(re?.inputGlbSha256)X.append(L("p",`Capture input: ${String(re.inputGlbSha256)}`,"mono"));if(re)X.append(L("p",re.exactArtifact===!0?"Receipt identifies the exact evaluated artifact.":"Capture does not claim exact artifact equivalence."));return X}function U(){let F=ue("live-evidence"),X=ue("live-downloads");F.replaceChildren(),X.replaceChildren();let ne=e.displayed;if(!ne?.artifact){y=void 0;return}let re=L("div",void 0,"evidence-card");re.append(L("h3","Selected observed artifact"),L("strong",`${(ne.artifact.bytes/1024).toFixed(0)} KB GLB`),L("p",ne.artifact.sha256,"mono"),L("p",`Source: ${ne.programRef??"See authored source download"}`,"mono")),F.append(re,C(ne));let ce=`${x.value}/${ne.operationId}/${ne.artifact.sha256}`;if(y?.key!==ce){let ve=L("div",void 0,"evidence-card live-material-inspection"),Re=L("button","Inspect exact material inputs","secondary");ve.append(L("h3","Materials and atlas sheets"),L("p","Declared inputs for this displayed artifact. Raw sheets are unshaded; capture fidelity is reported separately."),Re),y={key:ce,card:ve},Re.onclick=async()=>{Re.disabled=!0;let ke=L("p","Reading the displayed artifact evaluation…");ke.setAttribute("role","status"),ve.append(ke);try{let Xe=await un(_(`/api/live/${encodeURIComponent(ne.operationId)}/evaluation.json`));if(y?.key!==ce)return;let et=nI(Xe,ne.artifact.sha256);ke.textContent=et.length?"Exact declared revisions. Map images require the matching record in this local material library.":"No saved material resource declarations in this artifact. Embedded textures can still be viewed in the viewport.";for(let Wt of et){let dt=L("details");dt.append(L("summary",`${Wt.name} · ${Wt.revisionId}`));let Ft=!1;dt.ontoggle=()=>{if(dt.open&&!Ft)Ft=!0,dt.append(Hf(Wt))},ve.append(dt)}}catch(Xe){if(y?.key!==ce)return;ke.textContent=`Material inspection unavailable for this exact artifact: ${Xe instanceof Error?Xe.message:String(Xe)}`,Re.disabled=!1}}}if(F.append(y.card),ne.captures.length)for(let ve of ne.captures){let Re=L("div",void 0,"evidence-card");Re.append(L("h3",ve.name));let ke=ne.viewFidelity&&typeof ne.viewFidelity==="object"?ne.viewFidelity:void 0;Re.append(L("p",ke?.materialFaithful===!0?`Recorded capture · ${String(ke.delivered??"material-faithful")}`:`Recorded capture · ${String(ke?.delivered??"fidelity unreported")}. Materials are not verified.`,ke?.materialFaithful===!0?"subtle":"warning"));let Xe=L("a"),et=L("img");et.src=ve.url,et.alt=`Recorded ${ve.name} for ${ne.tool}`,et.loading="lazy",Xe.href=ve.url,Xe.target="_blank",Xe.rel="noopener",Xe.append(et),Re.append(Xe,L("p",ve.sha256,"mono")),F.append(Re)}else{let ve=L("div",void 0,"evidence-card");ve.append(L("h3","Recorded captures"),L("p",ne.status==="evaluated"||ne.status==="running"?"Artifact is ready. Capture work may still be in progress.":"No capture image was retained for this operation.")),F.append(ve)}for(let[ve,Re,ke]of[[ne.artifact.url,"Observed GLB","asset.glb"],[_(`/api/live/${encodeURIComponent(ne.operationId)}/source.kiln.js`),"Authored source","source.kiln.js"]]){let Xe=L("a",Re);Xe.href=ve,Xe.download=ke,X.append(Xe)}X.append(L("p","These are the observed artifact and source. Use the saved Library revision for an editable bundle with resources or a separate runtime export. A live observation is not a saved release."))}function D(){let F=rs(e.displayed,l);ue("pin-build").disabled=!F,xe.disabled=F?.status!=="complete"}function P(){if(d&&l)ue("live-stage-label").textContent=Ib(d,Tn(l.operationId),o?.lod())}function K(){if(f&&u)ue("compare-stage-label").textContent=`Pinned · ${Ib(f,Tn(u.operationId),c?.lod())}`}async function z(F){if(ue("live-panel").hidden)return;let X=++b;if(!rs(F,l))o?.cancelMeasurement("The review selection changed. Measure the loaded revision again.");if(!F?.artifact){ue("live-performance").replaceChildren(),o?.dispose(),o=void 0,l=void 0,d=void 0,ue("live-level-field").hidden=!0,ue("live-lod").replaceChildren(),ue("live-lod").hidden=!0,ue("live-stage-status").textContent="No completed artifact available for this run.",ue("live-stage-label").textContent="Current",D();return}if(l?.artifact?.sha256===F.artifact.sha256){l=F,ue("live-stage-status").textContent="",P(),D();return}ue("live-stage-status").textContent=`Loading ${Tn(F.operationId)}…${l?` Previous artifact ${Tn(l.operationId)} remains visible; Save and Pin are unavailable until the selection loads.`:""}`;try{let ne=await fetch(F.artifact.url);if(!ne.ok)throw Error("This retained artifact is no longer available");let re=new Uint8Array(await ne.arrayBuffer());if(X!==b)return;o??=Nl(ue("live-stage"));let ce=await o.load(re,{isCurrent:()=>X===b,onCommit:()=>{l=F},preserveView:l?.projectId===F.projectId&&(l?.sessionId===F.sessionId||e.following)});if(!ce||X!==b)return;ue("live-performance").replaceChildren(),l=F,d=ce,D();let ve=ue("live-level");if(ue("live-level-field").hidden=!ce.levels,Pl(ve,ue("live-lod"),o,(Re)=>{if(Re!==void 0)c?.level(Re),h?.refresh(),K();P()}),o.wire(g),o.navigation(ue("live-navigation").value),ue("live-stage-status").textContent="",P(),c)c.setView(o.view())}catch(ne){if(X!==b)return;ue("live-stage-status").textContent=`${ne instanceof Error?ne.message:ne}.${l?` Previous artifact ${Tn(l.operationId)} remains visible. Save and Pin are unavailable for the unloaded selection.`:""}`,D()}}async function W(F){if(ue("live-panel").hidden)return;let X=++m;if(ue("compare-viewport").hidden=!F?.artifact,ue("review-viewports").classList.toggle("comparing",!!F?.artifact),!F?.artifact){c?.dispose(),c=void 0,u=void 0,f=void 0,h=void 0,ue("compare-lod").replaceChildren(),ue("compare-level-field").hidden=!0;return}if(u?.artifact?.sha256===F.artifact.sha256){u=F,K(),ue("compare-stage-status").textContent="";return}if(!u)ue("compare-stage-label").textContent="Comparison";ue("compare-stage-status").textContent=`Loading pinned ${Tn(F.operationId)}…`;try{let ne=await fetch(F.artifact.url);if(!ne.ok)throw Error("Pinned artifact unavailable");let re=new Uint8Array(await ne.arrayBuffer());if(X!==m)return;c??=Nl(ue("compare-stage"));let ce=await c.load(re,{preserveView:!0,isCurrent:()=>X===m,onCommit:()=>{u=F}});if(!ce||X!==m)return;if(u=F,f=ce,o)c.setView(o.view());let ve=Number(ue("live-level").value||0);c.level(Number.isFinite(ve)?ve:0),ue("compare-level-field").hidden=!ce.levels,h=Pl(ue("compare-level"),ue("compare-lod"),c,K),K(),c.wire(g),c.navigation(ue("live-navigation").value),ue("compare-stage-status").textContent=""}catch(ne){if(X===m)ue("compare-stage-status").textContent=`${ne instanceof Error?ne.message:String(ne)}.${u?` Previous comparison ${Tn(u.operationId)} remains visible.`:""}`}}function q(){k();let F=e.selected,X=e.displayed,ne=ue("follow-latest");ne.textContent=e.following?"Following latest":"Follow latest",ne.setAttribute("aria-pressed",String(e.following));let re=ue("live-current-summary");if(re.replaceChildren(),F){re.append(L("h2",F.tool.replace(/^kiln_/,"")),L("p",`${F.status} · ${F.transport} · Run ${Tn(F.sessionId)} · ${new Date(F.updatedAt).toLocaleString()}`));let Re=L("div",void 0,"tags");if(F.projectId)Re.append(L("span",F.projectId,"tag"));for(let ke of F.phases)Re.append(L("span",ke.phase,"tag"));re.append(Re)}else re.append(L("h2","No build selected"),L("p","Run Kiln tools from your agent or CLI. Completed evaluations appear here automatically."));let ce=F&&"observationIssues"in F&&Array.isArray(F.observationIssues)?F.observationIssues.map(String):[],ve=[F?.error,...ce,F&&X&&F.operationId!==X.operationId?`Current ${F.status} operation has no retained artifact. Showing the last successful artifact ${Tn(X.operationId)} from run ${Tn(X.sessionId)}.`:"",F&&!e.operations.some((Re)=>Re.operationId===F.operationId)?"This selection is outside the current retained history. Its loaded view remains until you choose another build.":""].filter(Boolean);ue("live-failure").textContent=ve.join(" "),ue("live-failure").hidden=!ve.length,D(),ue("clear-pin").hidden=!e.pinned,ue("live-count").textContent=`${e.operations.length} retained operation${e.operations.length===1?"":"s"}`,ue("live-record").textContent=JSON.stringify({selected:F,displayedArtifactOperation:X?.operationId,pinnedOperation:e.pinned?.operationId},null,2),U(),z(X),W(e.pinned)}async function le(){if(i)return;i=!0;let F=r;try{let X=new URLSearchParams;if(v.value)X.set("project",v.value);if(n)X.set("cursor",n);let ne=await un(_(`/api/live?${X}`));if(F!==r)return;if(s=0,M(!0,"Connected · checks every 2 seconds"),n=ne.cursor,ue("live-history-note").textContent=`Up to ${ne.retention.maxOperations} operations`,ue("live-history-issues").textContent=ne.observationIssues?.join(" ")??"",ue("live-history-issues").hidden=!ne.observationIssues?.length,!ne.unchanged){if(t=ne.operations,R(),e=$l(e,N()),!p){p=!0;let re=Ia(A());if(re&&e.operations.some((ve)=>ve.operationId===re))e=Cb(e,re);let ce=Ia(T());e.pinned=t.find((ve)=>ve.operationId===ce&&ve.pinned)??[...t].reverse().find((ve)=>ve.pinned&&ve.artifact)}q()}}catch(X){s++,M(!1,`Connection lost. Retrying; retained views remain available. ${X instanceof Error?X.message:X}`)}finally{if(i=!1,a)clearTimeout(a);a=setTimeout(()=>void le(),document.hidden?1e4:Math.min(30000,2000*2**Math.min(s,4)))}}v.onchange=()=>{r++,n="",t=[],p=!1,E.replaceChildren(new Option("All runs","")),w.value="",e={following:!0,crossRunContinuity:!0,operations:[]},q(),le()},x.onchange=()=>{v.value="",e.pinned=void 0,v.dispatchEvent(new Event("change"))},un("/api/live-sources").then(({sources:F})=>{x.replaceChildren(...F.map((X)=>new Option(X.label,X.id)))}).catch(In),E.onchange=()=>{e=$l({...e,selected:void 0,displayed:void 0,following:!0,crossRunContinuity:!E.value},N()),q()},w.onchange=()=>E.dispatchEvent(new Event("change")),ue("follow-latest").onclick=()=>{e=$l({...e,following:!e.following},N()),$r(A(),e.following?"":e.selected?.operationId??""),q()},ue("live-refresh").onclick=()=>{n="",le(),q()},ue("pin-build").onclick=async()=>{let F=rs(e.displayed,l);if(!F?.artifact)return;let X=ue("pin-build");X.disabled=!0;try{await un(_(`/api/live/${encodeURIComponent(F.operationId)}/pin`),{method:"POST",body:{pinned:!0}}),e.pinned={...F,pinned:!0},$r(T(),F.operationId),n="",q(),le()}catch(ne){In(ne),D()}},ue("clear-pin").onclick=async()=>{if(!e.pinned)return;try{await un(_(`/api/live/${encodeURIComponent(e.pinned.operationId)}/pin`),{method:"POST",body:{pinned:!1}}),e.pinned=void 0,$r(T(),""),n="",q(),le()}catch(F){In(F)}},ue("live-frame").onclick=()=>{if(o?.reset(),o)c?.setView(o.view())},ue("live-wire").onclick=()=>{g=!g,o?.wire(g),c?.wire(g),ue("live-wire").setAttribute("aria-pressed",String(g))};let he=L("button","Match comparison camera","secondary");he.onclick=()=>{if(o)c?.setView(o.view())},ue("live-frame").parentElement?.append(he);let xe=L("button","Save exact artifact");xe.disabled=!0,ue("live-frame").parentElement?.prepend(xe);let pe=L("button","Measure 3 s","secondary"),J=L("div");return J.id="live-performance",ue("live-evidence").after(J),ue("live-frame").parentElement?.append(pe),$f(pe,J,()=>o,()=>rs(e.displayed,l)?{operationId:l.operationId,revision:l.revision,glbSha256:l.artifact?.sha256}:void 0),xe.onclick=()=>{let F=rs(e.displayed,l);if(F?.status!=="complete")return;let X=L("dialog"),ne=L("form"),re=L("div",void 0,"editor-content"),ce=L("h2","Save reviewed artifact");ce.id="save-review-title",X.setAttribute("aria-labelledby",ce.id),re.append(ce,L("p","Save the exact source, GLB and recorded capture to Library. Then optionally link the saved revision to one or more named projects. Kiln will not evaluate the source again.","subtle"),L("p",`${F.operationId} · revision ${F.revision}`,"mono"),L("p",F.artifact.sha256,"mono"));let ve=L("input");ve.required=!0,ve.maxLength=200,ve.value="";let Re=L("label","Asset name","field");Re.append(ve);let ke=L("p");ke.setAttribute("role","status");let Xe=L("button","Save exact artifact");Xe.type="submit";let et=L("button","Cancel","secondary");et.type="button",et.onclick=()=>X.close(),re.append(Re,ke,Xe,et),ne.append(re),X.append(ne),document.body.append(X),X.addEventListener("close",()=>X.remove()),ne.onsubmit=async(Wt)=>{Wt.preventDefault(),Xe.disabled=!0,ke.textContent="Saving retained bytes…";try{let dt=sI(F,ve.value,l,e.displayed),Ft=await un(_(dt.path),{method:"POST",body:dt.body});ke.replaceChildren(L("span",`Saved ${Ft.asset.assetId} / ${Ft.asset.revisionId}. `));let Qt=L("a","Open saved revision"),nn=new URLSearchParams({collection:Ft.collection,asset:Ft.asset.assetId,revision:Ft.asset.revisionId});Qt.href=`/?${nn}`,ke.append(Qt);let B=L("div");re.append(B),Kl(B,{collectionId:Ft.collection,assetId:Ft.asset.assetId,revisionId:Ft.asset.revisionId},Ft.asset.name,async()=>{}).catch((_n)=>{B.textContent=`Asset saved; membership unavailable: ${_n instanceof Error?_n.message:_n}. Open the saved asset in Library to link it.`}),ve.disabled=!0,Xe.textContent="Saved",et.textContent="Close"}catch(dt){ke.textContent=dt instanceof Error?dt.message:String(dt),Xe.disabled=!1}},X.showModal(),ve.focus()},ue("live-navigation").onchange=(F)=>{let X=F.target.value;o?.navigation(X),c?.navigation(X),ue("live-navigation-help").textContent=X==="explore"?"Focus a viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan · Your camera stays in place between iterations."},window.addEventListener("online",()=>{n="",le()}),document.addEventListener("visibilitychange",()=>{if(!document.hidden)le()}),le(),{activate:q,projects(F){let X=v.value;v.replaceChildren(new Option("All work",""));for(let ne of F)v.append(new Option(ne.name,ne.projectId));if(F.some((ne)=>ne.projectId===X))v.value=X}}}var Pb=["projects","live","library","materials"];function cI(e,t){let n=new URLSearchParams(e);if(n.has("asset")||n.has("open"))return"library";if(Hl(e))return"materials";return t&&Pb.some((r)=>r===t)?t:"library"}function lI(e,t=()=>{}){let n=Pb;function r(c){if(!n.includes(c))return;for(let l of n)ue(`${l}-panel`).hidden=l!==c;for(let l of document.querySelectorAll("#workspace-nav button")){let u=l.dataset.section===c;if(l.classList.toggle("active",u),u)l.setAttribute("aria-current","page");else l.removeAttribute("aria-current")}if($r("kiln.section",c),c==="live")i.activate();if(c==="materials")a.refresh().catch(In)}for(let c of document.querySelectorAll("#workspace-nav button"))c.onclick=()=>r(c.dataset.section);ue("open-files").onclick=()=>ue("open").click();let i=oI(),a=iI(()=>s.refresh()),s=eI({changed:(c)=>{i.projects(c),a.projects(c),t(c)},openAsset:(c)=>{r("library"),e(c)}});r(cI(location.search,Ia("kiln.section"))),s.refresh().catch(In),a.refresh().catch(In);let o=!1;return window.setInterval(async()=>{if(document.hidden||o||ue("project-editor").open)return;o=!0;try{await s.refresh()}catch{}finally{o=!1}},5000),{library:()=>r("library"),refreshProjects:s.refresh}}var Ai=(e)=>`${e.collection}/${e.manifest.assetId}`;function uI(e,t,n){if(!n)return e;if(n==="standalone"){let i=new Set(t.flatMap((a)=>a.inventory.flatMap((s)=>s.asset?[`${s.asset.collectionId}/${s.asset.assetId}`]:[])));return e.filter((a)=>!i.has(Ai(a)))}let r=new Set(t.find((i)=>i.projectId===n)?.inventory.flatMap((i)=>i.asset?[`${i.asset.collectionId}/${i.asset.assetId}/${i.asset.revisionId}`]:[])??[]);return e.filter((i)=>r.has(`${Ai(i)}/${i.manifest.revisionId}`))}var ze=(e)=>document.getElementById(e),ht=(e,t,n)=>{let r=document.createElement(e);if(t!==void 0)r.textContent=t;if(n)r.className=n;return r},Jl=[],ql=[],os=[],Hs=[],Kf="",as,Ti,wn,is=0,dI=0,Wl=!1,Xl=!1,ss=new Set,Db=[],fI=[],Zi=(e)=>`${e.collection}/${e.manifest.assetId}/${e.manifest.revisionId}`,kb=(e)=>{ze("status").textContent=e},wi=(e)=>kb(e instanceof Error?e.message:String(e)),$s=(e,t,n=Db)=>{let r=URL.createObjectURL(new Blob([Uint8Array.from(e)],{type:t}));return n.push(r),r};async function Lb(e){let t=await fetch(e),n=await t.json();if(!t.ok)throw Error(n.error??"Request failed");return n}async function Ob(e,t){if(e.local){let r=e.local.files[t];if(!r)throw Error("File unavailable");return r}if(e.loose&&t==="asset.glb")return e.loose;let n=await fetch(`/files/${Zi(e)}/${t}`);if(!n.ok)throw Error((await n.json()).error??"File unavailable");return new Uint8Array(await n.arrayBuffer())}function iB(e,t){if(e.local){if(t==="editable.zip")return $s(vp([e.local]),"application/zip");return $s(e.local.files[t],t.endsWith(".js")?"text/javascript":"model/gltf-binary")}if(e.loose)return $s(e.loose,"model/gltf-binary");return`/files/${Zi(e)}/${t}?download`}function hI(e,t){try{localStorage.setItem(e,t)}catch{}}function aB(e){try{return localStorage.getItem(e)}catch{return null}}function sB(){let e=ze("collections");e.replaceChildren();for(let t of[{id:"all",label:"All saved assets"},...Jl,...Hs.length?[{id:"opened-files",label:"Opened files"}]:[]]){let n=ht("button",t.label,Kf===t.id?"active":"");n.onclick=()=>void lc(t.id).catch(wi),e.append(n)}}async function lc(e,t=!0){if(t)mI.library();let n=++dI;Kf=e,ss.clear(),sB(),kb("");let r=e==="all"?await(async()=>{let i=await Lb("/api/library");if(i.errors.length)kb(i.errors.map((a)=>`${a.collectionId}: ${a.message}`).join(" · "));return i.entries.map((a)=>({collection:a.collectionId,manifest:a.manifest}))})():e==="opened-files"?Hs:(await Lb(`/api/assets?collection=${encodeURIComponent(e)}`)).assets.map((i)=>({collection:e,manifest:i}));if(n!==dI)return;os=r,hI("kiln.collection",e),ze("collection-title").textContent=e==="all"?"Library":e==="opened-files"?"Opened files":Jl.find((i)=>i.id===e)?.label??e,ze("collection-caption").textContent=e==="opened-files"?"Previewed in your browser. Your original files stay untouched.":"Saved assets across registered storage. Projects link exact revisions; standalone assets belong here too.",Wf()}function oB(){let e=new Map;for(let t of uI(os,ql,ze("library-project").value)){let n=Ai(t);e.set(n,[...e.get(n)??[],t])}return[...e.values()].map((t)=>(t.sort((n,r)=>r.manifest.createdAt.localeCompare(n.manifest.createdAt)||r.manifest.revisionId.localeCompare(n.manifest.revisionId)),t.find((n)=>n.manifest.revisionId===aB(`kiln.revision.${n.collection}.${n.manifest.assetId}`))??t[0]))}function Wf(){for(let r of fI.splice(0))URL.revokeObjectURL(r);let e=ze("cards");e.replaceChildren();let t=ze("search").value.toLowerCase(),n=oB().filter((r)=>`${r.manifest.name} ${r.manifest.tags.join(" ")}`.toLowerCase().includes(t));if(ze("count").textContent=`${n.length} asset${n.length===1?"":"s"}`,ze("export-selection").disabled=!ss.size,!n.length){let r=ht("div",void 0,"empty");if(r.append(ht("b",t?"No matching assets":"Your next idea belongs here."),ht("p",t?"Try another name or tag.":"Save an asset with your agent, or open a GLB or editable bundle.")),!t)r.append(ht("code",'kiln save asset.kiln.js --name "My asset"'));e.append(r);return}for(let r of n){let i=r.manifest,a=ht("article",void 0,"card"),s=ht("button",void 0,"card-open");s.setAttribute("aria-label",`View ${i.name}`),s.onclick=()=>void Zl(r).catch(wi);let o=ht("div",void 0,"thumb");if(i.files["preview.png"]){let b=ht("img");b.loading="lazy",b.alt=i.name,b.src=r.local?$s(r.local.files["preview.png"],"image/png",fI):`/files/${Zi(r)}/preview.png`,b.onerror=()=>{b.remove(),o.textContent="◇"},o.append(b)}else o.textContent="◇";let c=ht("div",void 0,"card-content");c.append(ht("span",i.name,"card-title"));let l=os.filter((b)=>Ai(b)===Ai(r)),u=new Set(l.map((b)=>b.manifest.parentRevision)),d=l.filter((b)=>!u.has(b.manifest.revisionId));c.append(ht("span",`${i.editable?"Editable source":"Source unavailable"} · ${l.length} revision${l.length===1?"":"s"}${d.length>1?` · ${d.length} branches`:""}`,"card-meta"));let f=ht("div",void 0,"tags");for(let b of i.tags)f.append(ht("span",b,"tag"));c.append(f),c.append(ht("small",Jl.find((b)=>b.id===r.collection)?.label??r.collection,"card-meta"));let h=ql.filter((b)=>b.inventory.some((m)=>m.asset&&m.asset.collectionId===r.collection&&m.asset.assetId===i.assetId));if(c.append(ht("small",h.length?h.map((b)=>b.name).join(" · "):"No project membership","card-meta")),s.append(o,c),a.append(s),!r.loose){let b=ht("input");b.type="checkbox",b.className="selection",b.checked=ss.has(Zi(r)),b.setAttribute("aria-label",`Select ${i.name}`),b.onchange=()=>{if(b.checked)ss.add(Zi(r));else ss.delete(Zi(r));ze("export-selection").disabled=!ss.size},a.append(b)}e.append(a)}}async function Zl(e){let t=++is;as=e,Ti=void 0,wn?.cancelMeasurement("The Library selection changed. Measure the loaded revision again."),ze("library-performance").replaceChildren(),hI(`kiln.revision.${e.collection}.${e.manifest.assetId}`,e.manifest.revisionId);for(let u of Db.splice(0))URL.revokeObjectURL(u);let n=ze("detail");if(!n.open)n.showModal();ze("asset-name").textContent=e.manifest.name;let r=ze("asset-membership");if(r.replaceChildren(),!e.local&&!e.loose){let u=ht("div");r.append(u),Kl(u,{collectionId:e.collection,assetId:e.manifest.assetId,revisionId:e.manifest.revisionId},e.manifest.name,mI.refreshProjects).catch(wi)}let i=ze("revisions");i.replaceChildren();for(let u of os.filter((d)=>Ai(d)===Ai(e))){let d=ht("option",`${new Date(u.manifest.createdAt).toLocaleString()} · ${u.manifest.description||u.manifest.revisionId.slice(0,10)}`);d.value=u.manifest.revisionId,d.selected=u.manifest.revisionId===e.manifest.revisionId,i.append(d)}i.onchange=()=>{let u=os.find((d)=>Ai(d)===Ai(e)&&d.manifest.revisionId===i.value);if(u)Zl(u).catch(wi)},ze("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 a=ze("asset-attribution");a.replaceChildren();for(let u of ME(e.manifest)){let d=ht("div");d.append(ht("span",u.label),ht("strong",u.value)),a.append(d)}a.hidden=!a.childElementCount;let s=document.getElementById("asset-material-inputs");if(!s)s=ht("section",void 0,"asset-material-inputs"),s.id="asset-material-inputs",a.after(s);s.replaceChildren();try{let u=$c({manifest:e.manifest,files:{}});if(u.length){s.append(ht("h3","Exact material build inputs"),ht("p","Open the saved revision to inspect its raw maps, sampling declaration and atlas regions. Declared inputs do not prove every map was used.","subtle"));for(let d of u){let f=ht("a",`${d.name} · ${d.materialId}`);f.href=Gf(d),f.target="_blank",f.rel="noopener",s.append(f,ht("p",d.revisionId,"mono"))}}}catch(u){s.append(ht("p",`Material revision links unavailable: ${u instanceof Error?u.message:String(u)}`,"subtle"))}ze("provenance").textContent=e.loose?"Standalone GLB. No source or build provenance supplied.":JSON.stringify(e.manifest,null,2);let o=ze("downloads");o.replaceChildren();for(let[u,d]of[["asset.glb","Original GLB"],...e.manifest.editable?[["source.kiln.js","Download source"]]:[],...!e.loose?[["editable.zip",e.manifest.editable?"Download editable bundle":"Download asset bundle"]]:[]]){let f=ht("a",d);f.href=iB(e,u),f.download=`${e.manifest.name.replace(/[^a-z0-9_-]/gi,"-")}${u==="asset.glb"?".glb":u==="source.kiln.js"?".kiln.js":".zip"}`,o.append(f)}if(!e.loose){let u=ht("button","Runtime GLB"),d=ht("span");d.setAttribute("role","status"),u.onclick=async()=>{u.disabled=!0,d.textContent="Preparing runtime download…";try{let f=e.local?await GR(e.local,{profile:"runtime"}):void 0,[h,b]=f?.profile==="runtime"?[f.glb,f.metadata.bytes]:await Promise.all([Ob(e,"runtime.glb"),Ob(e,"runtime.kiln-metadata.json")]);if(t!==is)return;let m=ht("a","Runtime GLB");m.href=$s(h,"model/gltf-binary"),m.download="runtime.glb";let g=ht("a","Runtime metadata");g.href=$s(b,"application/json"),g.download="runtime.kiln-metadata.json",u.replaceWith(m,g),d.textContent="Keep the companion metadata for traceability.",m.click()}catch(f){if(t!==is)return;d.textContent=`Runtime export unavailable: ${f instanceof Error?f.message:f}`,u.disabled=!1}},o.append(u,d),o.append(ht("p","Original GLB retains Kiln review data. Runtime GLB moves duplicate animation-review data into a companion JSON file; geometry and textures are unchanged. Keep the editable bundle for source and build records."))}ze("refine").disabled=!e.manifest.editable,ze("asset-stats").replaceChildren(),ze("stage-status").textContent="Loading saved GLB…",Wl=!1,Xl=!1,ze("wire").setAttribute("aria-pressed","false"),ze("play").textContent="Pause";let c=ze("animation");c.replaceChildren(new Option("Rest pose","")),ze("play").disabled=!0;let l=ze("level");l.replaceChildren(),l.hidden=!0,ze("library-lod").replaceChildren(),ze("library-lod").hidden=!0;try{wn??=Nl(ze("stage"));let u=await Ob(e,"asset.glb");if(t!==is)return;let d=await wn.load(u,{isCurrent:()=>t===is,onCommit:()=>{Ti=e}});if(!d||t!==is)return;Ti=e,wn.wire(!1),wn.navigation(ze("library-navigation").value),wn.lighting(ze("lighting").value),Pl(l,ze("library-lod"),wn);for(let[f,h]of[...d.levels?d.levels.map((b,m)=>[b.toLocaleString(),`LOD${m} triangles`]):[[d.triangles.toLocaleString(),"triangles"]],[d.meshes,d.levels?"LOD0 meshes":"meshes"],[d.materials,d.levels?"LOD0 materials":"materials"],[`${(u.length/1024).toFixed(0)} KB`,"GLB"]]){let b=ht("div");b.append(ht("strong",String(f)),ht("span",String(h))),ze("asset-stats").append(b)}for(let f=0;f<d.clips.length;f++)c.append(new Option(d.clips[f],String(f)));ze("stage-status").textContent=""}catch(u){if(t===is)wn?.dispose(),wn=void 0,ze("stage-status").textContent=`3D preview unavailable: ${u instanceof Error?u.message:u}. Downloads remain available.`}}async function pI(e){for(let t of e){if(t.bytes.length>qn)throw Error("File exceeds 64 MiB");if(t.name.toLowerCase().endsWith(".zip"))for(let n of wE(t.bytes)){for(let[r,i]of Object.entries(n.files))if(`sha256:${Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(i)))).map((s)=>s.toString(16).padStart(2,"0")).join("")}`!==n.manifest.files[r]?.sha256)throw Error(`Bundle integrity failure: ${r}`);if(!Hs.some((r)=>r.manifest.revisionId===n.manifest.revisionId&&r.manifest.assetId===n.manifest.assetId))Hs.push({collection:"opened-files",manifest:n.manifest,local:n})}else{let n=`a_${crypto.randomUUID().replaceAll("-","")}`;Hs.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 lc("opened-files")}ze("open").onchange=async(e)=>{try{let t=Array.from(e.target.files??[]);if(t.some((n)=>n.size>qn))throw Error("File exceeds 64 MiB");await pI(await Promise.all(t.map(async(n)=>({name:n.name,bytes:new Uint8Array(await n.arrayBuffer())}))))}catch(t){wi(t)}};ze("refresh").onclick=()=>void lc(Kf).catch(wi);ze("search").oninput=Wf;ze("library-project").onchange=()=>void lc("all").catch(wi);ze("close-detail").onclick=()=>ze("detail").close();ze("detail").addEventListener("close",()=>{is++,Ti=void 0,wn?.dispose(),wn=void 0;for(let e of Db.splice(0))URL.revokeObjectURL(e);Wf()});ze("frame").onclick=()=>wn?.reset();ze("wire").onclick=()=>{Wl=!Wl,wn?.wire(Wl),ze("wire").setAttribute("aria-pressed",String(Wl))};ze("lighting").onchange=(e)=>wn?.lighting(e.target.value);ze("library-navigation").onchange=(e)=>{let t=e.target.value;wn?.navigation(t),ze("library-navigation-help").textContent=t==="explore"?"Focus the viewport, then W A S D to move · Q / E down / up · Shift faster · Drag to look around · No collision simulation.":"Drag to orbit · Scroll to zoom · Right-drag to pan"};ze("animation").onchange=(e)=>{let t=e.target.value;wn?.clip(t===""?-1:Number(t)),ze("play").disabled=t===""};ze("play").onclick=()=>{Xl=!Xl,wn?.pause(Xl),ze("play").textContent=Xl?"Play":"Pause"};ze("refine").onclick=async()=>{if(!as)return;let e=as.manifest,t=as.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=${as.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=${as.collection}. Requested change: `;try{await navigator.clipboard.writeText(t),ze("refine").textContent="Instructions copied"}catch{ze("provenance").textContent=t,ze("provenance").parentElement?.setAttribute("open","")}};ze("export-selection").onclick=()=>{try{let e=ht("a");if(Kf==="opened-files")e.href=$s(vp(os.filter((t)=>ss.has(Zi(t))).map((t)=>t.local)),"application/zip");else{let t=new URLSearchParams;for(let n of ss)t.append("revision",n);e.href=`/api/bundle?${t}`}e.download="kiln-assets.zip",e.click()}catch(e){wi(e)}};async function cB(){Jl=(await Lb("/api/collections")).collections;let e=Hw(location.search);if(await lc(Jl.find((t)=>t.id===e?.collection)?.id??"all",!1),e){let t=os.find((n)=>n.collection===e.collection&&n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The requested saved revision is not available.");await Zl(t)}if(new URLSearchParams(location.search).has("open")){let t=await fetch("/api/standalone");if(!t.ok)throw Error("File unavailable");if(await pI([{name:t.headers.get("Content-Type")?.includes("zip")?"asset.zip":"asset.glb",bytes:new Uint8Array(await t.arrayBuffer())}]),Hs.length===1)await Zl(Hs[0])}}var mI=lI((e)=>{(async()=>{await lc(e.collectionId);let t=os.find((n)=>n.manifest.assetId===e.assetId&&n.manifest.revisionId===e.revisionId);if(!t)throw Error("The linked saved revision is not available in this collection.");await Zl(t)})().catch(wi)},(e)=>{ql=e;let t=ze("library-project"),n=t.value;t.replaceChildren(new Option("All projects and standalone",""),new Option("Standalone assets","standalone"));for(let r of ql)t.append(new Option(r.name,r.projectId));if(n==="standalone"||ql.some((r)=>r.projectId===n))t.value=n;Wf()});$f(ze("measure-library"),ze("library-performance"),()=>wn,()=>Ti&&as&&Zi(Ti)===Zi(as)?{collection:Ti.collection,assetId:Ti.manifest.assetId,revisionId:Ti.manifest.revisionId,glbSha256:Ti.manifest.files["asset.glb"]?.sha256}:void 0);cB().catch(wi);
diff --git a/dist/viewer/chat.html b/dist/viewer/chat.html
index 547e574f..75edec0a 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 hp="186",cr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},lr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dp=0,Kl=1,fp=2;var _o=1,pp=2,Ms=3,ur=0,rn=1,kn=2,di=0,xo=1,Ql=2,eu=3,tu=4,mp=5;var ws=100,gp=101,_p=102,xp=103,yp=104,vp=200,bp=201,Sp=202,Mp=203,wp=204,Ep=205,Ap=206,Tp=207,Rp=208,Cp=209,Pp=210,Ip=211,Lp=212,Np=213,Dp=214,Op=0,Up=1,Fp=2,nu=3,zp=4,kp=5,Bp=6,Vp=7,Gp=0,Hp=1,$p=2,Jn=0,iu=1,ru=2,su=3,yo=4,ou=5,au=6,cu=7;var Es=301,Or=302,Ka=303,Qa=304,vo=306,As=1000,Ts=1001,ec=1002,Kn=1003,tc=1004;var Ur=1005;var qt=1006,Rs=1007;var fi=1008;var Qn=1009,Wp=1010,Zp=1011,bo=1012,lu=1013,hr=1014,Gi=1015,pi=1016,uu=1017,hu=1018,Cs=1020,Xp=35902,jp=35899,qp=1021,Yp=1022,mi=1023,Fr=1026,zr=1027,Jp=1028,du=1029,kr=1030,fu=1031;var pu=1033,nc=33776,ic=33777,rc=33778,sc=33779,mu=35840,gu=35841,_u=35842,xu=35843,yu=36196,vu=37492,bu=37496,Su=37488,Mu=37489,oc=37490,wu=37491,Eu=37808,Au=37809,Tu=37810,Ru=37811,Cu=37812,Pu=37813,Iu=37814,Lu=37815,Nu=37816,Du=37817,Ou=37818,Uu=37819,Fu=37820,zu=37821,ku=36492,Bu=36494,Vu=36495,Gu=36283,Hu=36284,ac=36285,$u=36286;var Wu=2300,cc=2301;var Zu=0,So=1,Ps=2;var Xu=0,Kp=1,Br="",dr="srgb",Sn="srgb-linear",ju="linear",yt="srgb";var Qp=512,em=513,tm=514,lc=515,nm=516,im=517,uc=518,rm=519;var qu="300 es",Yu=2000;function Ob(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Ub(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vs(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function sm(){let e=vs("canvas");return e.style.display="block",e}var Rf={},bs=null;function go(...e){let t="THREE."+e.shift();if(bs)bs("log",t,...e);else console.log(t,...e)}function om(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Le(...e){e=om(e);let t="THREE."+e.shift();if(bs)bs("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function ke(...e){e=om(e);let t="THREE."+e.shift();if(bs)bs("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function Nr(...e){let t=e.join(" ");if(t in Rf)return;Rf[t]=!0,Le(...e)}function am(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 cm={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ei{addEventListener(e,t){if(this._listeners===void 0)this._listeners={};let n=this._listeners;if(n[e]===void 0)n[e]=[];if(n[e].indexOf(t)===-1)n[e].push(t)}hasEventListener(e,t){let n=this._listeners;if(n===void 0)return!1;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let i=n[e];if(i!==void 0){let r=i.indexOf(t);if(r!==-1)i.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}}var tn=["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"],Cf=1234567,po=Math.PI/180,Dr=180/Math.PI;function Yn(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(tn[e&255]+tn[e>>8&255]+tn[e>>16&255]+tn[e>>24&255]+"-"+tn[t&255]+tn[t>>8&255]+"-"+tn[t>>16&15|64]+tn[t>>24&255]+"-"+tn[n&63|128]+tn[n>>8&255]+"-"+tn[n>>16&255]+tn[n>>24&255]+tn[i&255]+tn[i>>8&255]+tn[i>>16&255]+tn[i>>24&255]).toLowerCase()}function qe(e,t,n){return Math.max(t,Math.min(n,e))}function Ju(e,t){return(e%t+t)%t}function Fb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function zb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function mo(e,t,n){return(1-n)*e+n*t}function kb(e,t,n,i){return mo(e,t,1-Math.exp(-n*i))}function Bb(e,t=1){return t-Math.abs(Ju(e,t*2)-t)}function Vb(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 Gb(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 Hb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function $b(e,t){return e+Math.random()*(t-e)}function Wb(e){return e*(0.5-Math.random())}function Zb(e){if(e!==void 0)Cf=e;let t=Cf+=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 Xb(e){return e*po}function jb(e){return e*Dr}function qb(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function Yb(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Jb(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Kb(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),d=s((t-i)/2),h=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*d,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*d,a*l);break;case"ZXZ":e.set(c*d,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function dt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Mo={DEG2RAD:po,RAD2DEG:Dr,generateUUID:Yn,clamp:qe,euclideanModulo:Ju,mapLinear:Fb,inverseLerp:zb,lerp:mo,damp:kb,pingpong:Bb,smoothstep:Vb,smootherstep:Gb,randInt:Hb,randFloat:$b,randFloatSpread:Wb,seededRandom:Zb,degToRad:Xb,radToDeg:jb,isPowerOfTwo:qb,ceilPowerOfTwo:Yb,floorPowerOfTwo:Jb,setQuaternionFromProperEuler:Kb,normalize:dt,denormalize:qn};class Ue{static{Ue.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],h=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==d||c!==h||l!==f){let _=a*d+c*h+l*f+u*m;if(_<0)d=-d,h=-h,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],h=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*h-c*d,e[t+1]=a*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-a*u,e[t+3]=l*f-o*u-a*d-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),d=a(n/2),h=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(qe(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();if(e===0)this._x=0,this._y=0,this._z=0,this._w=1;else e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e;return this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,{_x:o,_y:a,_z:c,_w:l}=t;return this._x=n*l+s*o+i*c-r*a,this._y=i*l+s*a+r*o-n*c,this._z=r*l+s*c+n*a-i*o,this._w=s*l-n*o-i*a-r*c,this._onChangeCallback(),this}slerp(e,t){let{_x:n,_y:i,_z:r,_w:s}=e,o=this.dot(e);if(o<0)n=-n,i=-i,r=-r,s=-s,o=-o;let a=1-t;if(o<0.9995){let c=Math.acos(o),l=Math.sin(c);a=Math.sin(a*c)/l,t=Math.sin(t*c)/l,this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this._onChangeCallback()}else this._x=this._x*a+n*t,this._y=this._y*a+i*t,this._z=this._z*a+r*t,this._w=this._w*a+s*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{static{U.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){if(n===void 0)n=this.z;return this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Pf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pf.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,{x:r,y:s,z:o,w:a}=e,c=2*(s*i-o*n),l=2*(o*t-r*i),u=2*(r*n-s*t);return this.x=t+a*c+s*u-o*l,this.y=n+a*l+o*c-r*u,this.z=i+a*u+r*l-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let{x:n,y:i,z:r}=e,{x:s,y:o,z:a}=t;return this.x=i*a-r*o,this.y=r*s-n*a,this.z=n*o-i*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Tl.copy(this).projectOnVector(e),this.sub(Tl)}reflect(e){return this.sub(Tl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(qe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var Tl=new U,Pf=new Xt;class Ve{static{Ve.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=d*m+h*g+f*y,r[5]=d*_+h*S+f*w,r[8]=d*p+h*T+f*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,d=o*a-l*r,h=c*r-s*a,f=t*u+n*d+i*h;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=d*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=h*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return Nr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Rl.makeScale(e,t)),this}rotate(e){return Nr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Rl.makeRotation(-e)),this}translate(e,t){return Nr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Rl.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 Rl=new Ve,If=new Ve().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Lf=new Ve().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Qb(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Vi(r.r),r.g=Vi(r.g),r.b=Vi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ys(r.r),r.g=ys(r.g),r.b=ys(r.b);return r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){if(r==="")return"linear";return this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Nr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Nr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(r,s)}},t=[0.64,0.33,0.3,0.6,0.15,0.06],n=[0.2126,0.7152,0.0722],i=[0.3127,0.329];return e.define({["srgb-linear"]:{primaries:t,whitePoint:i,transfer:"linear",toXYZ:If,fromXYZ:Lf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:If,fromXYZ:Lf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var je=Qb();function Vi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ys(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var ss;class Ku{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if(typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{if(ss===void 0)ss=vs("canvas");ss.width=e.width,ss.height=e.height;let i=ss.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=ss}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=vs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Vi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Vi(t[n]/255)*255);else t[n]=Vi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var eS=0;class wo{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:eS++}),this.uuid=Yn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)e.set(t.videoWidth,t.videoHeight,0);else if(typeof VideoFrame<"u"&&t instanceof VideoFrame)e.set(t.displayWidth,t.displayHeight,0);else if(t!==null)e.set(t.width,t.height,t.depth||0);else e.set(0,0,0);return e}set needsUpdate(e){if(e===!0)this.version++}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let s=0,o=i.length;s<o;s++)if(i[s].isDataTexture)r.push(Cl(i[s].image));else r.push(Cl(i[s]))}else r=Cl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Cl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return Ku.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Le("Texture: Unable to serialize Texture."),{}}var tS=0,Pl=new U;class Nt extends ei{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:tS++}),this.uuid=Yn(),this.name="",this.source=new wo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new Ue(0,0),this.repeat=new Ue(1,1),this.center=new Ue(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ve,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=e&&e.depth&&e.depth>1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Pl).x}get height(){return this.source.getSize(Pl).y}get depth(){return this.source.getSize(Pl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],d=a[1],h=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-d)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(h+1)/2,y=(p+1)/2,w=(l+d)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(d-l)*(d-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(d-l)/g,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=qe(this.x,e.x,t.x),this.y=qe(this.y,e.y,t.y),this.z=qe(this.z,e.z,t.z),this.w=qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=qe(this.x,e,t),this.y=qe(this.y,e,t),this.z=qe(this.z,e,t),this.w=qe(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(qe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Qu extends ei{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new wo(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 Mn extends Qu{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class hc extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class eh extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class $e{static{$e.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=d,p[3]=h,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new $e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){if(this.determinantAffine()===0)return e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this;return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,i=1/os.setFromMatrixColumn(e,0).length(),r=1/os.setFromMatrixColumn(e,1).length(),s=1/os.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+f*c,t[5]=d-m*c,t[9]=-o*a,t[2]=m-d*c,t[6]=f+h*c,t[10]=s*a}else if(e.order==="YXZ"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d+m*o,t[4]=f*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-f,t[6]=m+d*o,t[10]=s*a}else if(e.order==="ZXY"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d-m*o,t[4]=-s*u,t[8]=f+h*o,t[1]=h+f*o,t[5]=s*l,t[9]=m-d*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-h,t[8]=d*c+m,t[1]=a*u,t[5]=m*c+d,t[9]=h*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-d*u,t[8]=f*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+f,t[10]=d-m*u}else if(e.order==="XZY"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=d*u+m,t[5]=s*l,t[9]=h*u-f,t[2]=f*u-h,t[6]=o*l,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(nS,e,iS)}lookAt(e,t,n){let i=this.elements;if(vn.subVectors(e,t),vn.lengthSq()===0)vn.z=1;if(vn.normalize(),tr.crossVectors(n,vn),tr.lengthSq()===0){if(Math.abs(n.z)===1)vn.x+=0.0001;else vn.z+=0.0001;vn.normalize(),tr.crossVectors(n,vn)}return tr.normalize(),wa.crossVectors(vn,tr),i[0]=tr.x,i[4]=wa.x,i[8]=vn.x,i[1]=tr.y,i[5]=wa.y,i[9]=vn.y,i[2]=tr.z,i[6]=wa.z,i[10]=vn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],z=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],k=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*z+a*I+c*j,r[8]=s*R+o*C+a*G+c*k,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+d*K+h*P,r[5]=l*A+u*z+d*I+h*j,r[9]=l*R+u*C+d*G+h*k,r[13]=l*x+u*L+d*X+h*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*z+_*I+p*j,r[10]=f*R+m*C+_*G+p*k,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*z+T*I+y*j,r[11]=g*R+S*C+T*G+y*k,r[15]=g*x+S*L+T*X+y*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*h-c*d,S=o*h-c*u,T=o*d-a*u,y=s*h-c*l,w=s*d-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-d*f,M=l*p-h*f,z=u*_-d*m,C=u*p-h*m,L=d*p-h*_,K=g*L-S*C+T*z+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*z)*I,e[1]=(i*C-n*L-r*z)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(d*w-u*A-h*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-d*T+h*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-h*g)*I,e[12]=(o*x-s*z-a*R)*I,e[13]=(t*z-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+d*g)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,d=r*c,h=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(h+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(h-T)*w,i[5]=(1-(d+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(d+m))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=os.set(i[0],i[1],i[2]).length(),o=os.set(i[4],i[5],i[6]).length(),a=os.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Zn.copy(this);let c=1/s,l=1/o,u=1/a;return Zn.elements[0]*=c,Zn.elements[1]*=c,Zn.elements[2]*=c,Zn.elements[4]*=l,Zn.elements[5]*=l,Zn.elements[6]*=l,Zn.elements[8]*=u,Zn.elements[9]*=u,Zn.elements[10]*=u,t.setFromRotationMatrix(Zn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var os=new U,Zn=new $e,nS=new U(0,0,0),iS=new U(1,1,1),tr=new U,wa=new U,vn=new U,Nf=new $e,Df=new Xt;class hi{constructor(e=0,t=0,n=0,i=hi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(qe(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-qe(l,-1,1)),Math.abs(l)<0.9999999)this._y=Math.atan2(o,h),this._z=Math.atan2(a,c);else this._y=Math.atan2(-u,r),this._z=0;break;case"ZXY":if(this._x=Math.asin(qe(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-qe(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(qe(a,-1,1)),Math.abs(a)<0.9999999)this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r);else this._x=0,this._y=Math.atan2(o,h);break;case"XZY":if(this._z=Math.asin(-qe(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Nf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Nf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Df.setFromEuler(this),this.setFromQuaternion(Df,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){if(this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0)this._order=e[3];return this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hi.DEFAULT_ORDER="XYZ";class dc{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 rS=0,Of=new U,as=new Xt,Oi=new $e,Ea=new U,so=new U,sS=new U,oS=new Xt,Uf=new U(1,0,0),Ff=new U(0,1,0),zf=new U(0,0,1),kf={type:"added"},aS={type:"removed"},cs={type:"childadded",child:null},Il={type:"childremoved",child:null};class gt extends ei{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:rS++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();let e=new U,t=new hi,n=new Xt,i=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new $e},normalMatrix:{value:new Ve}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){if(this.matrixAutoUpdate)this.updateMatrix();this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.multiply(as),this}rotateOnWorldAxis(e,t){return as.setFromAxisAngle(e,t),this.quaternion.premultiply(as),this}rotateX(e){return this.rotateOnAxis(Uf,e)}rotateY(e){return this.rotateOnAxis(Ff,e)}rotateZ(e){return this.rotateOnAxis(zf,e)}translateOnAxis(e,t){return Of.copy(e).applyQuaternion(this.quaternion),this.position.add(Of.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Uf,e)}translateY(e){return this.translateOnAxis(Ff,e)}translateZ(e){return this.translateOnAxis(zf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Oi.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)Ea.copy(e);else Ea.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),so.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Oi.lookAt(so,Ea,this.up);else Oi.lookAt(Ea,so,this.up);if(this.quaternion.setFromRotationMatrix(Oi),i)Oi.extractRotation(i.matrixWorld),as.setFromRotationMatrix(Oi),this.quaternion.premultiply(as.invert())}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}if(e===this)return ke("Object3D.add: object can't be added as a child of itself.",e),this;if(e&&e.isObject3D)e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(kf),cs.child=e,this.dispatchEvent(cs),cs.child=null;else ke("Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);if(t!==-1)e.parent=null,this.children.splice(t,1),e.dispatchEvent(aS),Il.child=e,this.dispatchEvent(Il),Il.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Oi.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Oi.multiply(e.parent.matrixWorld);return e.applyMatrix4(Oi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(kf),cs.child=e,this.dispatchEvent(cs),cs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let s=this.children[n].getObjectByProperty(e,t);if(s!==void 0)return s}return}getObjectsByProperty(e,t,n=[]){if(this[e]===t)n.push(this);let i=this.children;for(let r=0,s=i.length;r<s;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,e,sS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,oS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),h=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}gt.DEFAULT_UP=new U(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class li extends gt{constructor(){super();this.isGroup=!0,this.type="Group"}}var cS={type:"move"};class Eo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new li,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1};return this._hand}getTargetRaySpace(){if(this._targetRay===null)this._targetRay=new li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U;return this._targetRay}getGripSpace(){if(this._grip===null)this._grip=new li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),h=0.02,f=0.005;if(c.inputState.pinching&&d>h+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=h-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(cS)}}}if(o!==null)o.visible=i!==null;if(a!==null)a.visible=r!==null;if(c!==null)c.visible=s!==null;return this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var lm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},nr={h:0,s:0,l:0},Aa={h:0,s:0,l:0};function Ll(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,je.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=je.workingColorSpace){return this.r=e,this.g=t,this.b=n,je.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=je.workingColorSpace){if(e=Ju(e,1),t=qe(t,0,1),n=qe(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=0.5?n*(1+t):n+t-n*t,s=2*n-r;this.r=Ll(s,r,e+0.3333333333333333),this.g=Ll(s,r,e),this.b=Ll(s,r,e-0.3333333333333333)}return je.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=lm[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}copyLinearToSRGB(e){return this.r=ys(e.r),this.g=ys(e.g),this.b=ys(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return je.workingToColorSpace(nn.copy(this),e),Math.round(qe(nn.r*255,0,255))*65536+Math.round(qe(nn.g*255,0,255))*256+Math.round(qe(nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=je.workingColorSpace){je.workingToColorSpace(nn.copy(this),t);let{r:n,g:i,b:r}=nn,s=Math.max(n,i,r),o=Math.min(n,i,r),a,c,l=(o+s)/2;if(o===s)a=0,c=0;else{let u=s-o;switch(c=l<=0.5?u/(s+o):u/(2-s-o),s){case n:a=(i-r)/u+(i<r?6:0);break;case i:a=(r-n)/u+2;break;case r:a=(n-i)/u+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,t=je.workingColorSpace){return je.workingToColorSpace(nn.copy(this),t),e.r=nn.r,e.g=nn.g,e.b=nn.b,e}getStyle(e="srgb"){je.workingToColorSpace(nn.copy(this),e);let{r:t,g:n,b:i}=nn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(nr),this.setHSL(nr.h+e,nr.s+t,nr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(nr),e.getHSL(Aa);let n=mo(nr.h,Aa.h,t),i=mo(nr.s,Aa.s,t),r=mo(nr.l,Aa.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 nn=new ze;ze.NAMES=lm;class Is extends gt{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hi,this.environmentIntensity=1,this.environmentRotation=new hi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Xn=new U,Ui=new U,Nl=new U,Fi=new U,ls=new U,us=new U,Bf=new U,Dl=new U,Ol=new U,Ul=new U,Fl=new ft,zl=new ft,kl=new ft;class zn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Xn.subVectors(e,t),i.cross(Xn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Xn.subVectors(i,t),Ui.subVectors(n,t),Nl.subVectors(e,t);let s=Xn.dot(Xn),o=Xn.dot(Ui),a=Xn.dot(Nl),c=Ui.dot(Ui),l=Ui.dot(Nl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,h=(c*a-o*l)*d,f=(s*l-o*a)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,Fi)===null)return!1;return Fi.x>=0&&Fi.y>=0&&Fi.x+Fi.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,Fi)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,Fi.x),a.addScaledVector(s,Fi.y),a.addScaledVector(o,Fi.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Fl.setScalar(0),zl.setScalar(0),kl.setScalar(0),Fl.fromBufferAttribute(e,t),zl.fromBufferAttribute(e,n),kl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Fl,r.x),s.addScaledVector(zl,r.y),s.addScaledVector(kl,r.z),s}static isFrontFacing(e,t,n,i){return Xn.subVectors(n,t),Ui.subVectors(e,t),Xn.cross(Ui).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Xn.subVectors(this.c,this.b),Ui.subVectors(this.a,this.b),Xn.cross(Ui).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,s,o;ls.subVectors(i,n),us.subVectors(r,n),Dl.subVectors(e,n);let a=ls.dot(Dl),c=us.dot(Dl);if(a<=0&&c<=0)return t.copy(n);Ol.subVectors(e,i);let l=ls.dot(Ol),u=us.dot(Ol);if(l>=0&&u<=l)return t.copy(i);let d=a*u-l*c;if(d<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ls,s);Ul.subVectors(e,r);let h=ls.dot(Ul),f=us.dot(Ul);if(f>=0&&h<=f)return t.copy(r);let m=h*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(us,o);let _=l*f-h*u;if(_<=0&&u-l>=0&&h-f>=0)return Bf.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(Bf,o);let p=1/(_+m+d);return s=m*p,o=d*p,t.copy(n).addScaledVector(ls,s).addScaledVector(us,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(jn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(jn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=jn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,jn);else jn.fromBufferAttribute(r,s);jn.applyMatrix4(e.matrixWorld),this.expandByPoint(jn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Ta.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Ta.copy(n.boundingBox)}Ta.applyMatrix4(e.matrixWorld),this.union(Ta)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(oo),Ra.subVectors(this.max,oo),hs.subVectors(e.a,oo),ds.subVectors(e.b,oo),fs.subVectors(e.c,oo),ir.subVectors(ds,hs),rr.subVectors(fs,ds),Cr.subVectors(hs,fs);let t=[0,-ir.z,ir.y,0,-rr.z,rr.y,0,-Cr.z,Cr.y,ir.z,0,-ir.x,rr.z,0,-rr.x,Cr.z,0,-Cr.x,-ir.y,ir.x,0,-rr.y,rr.x,0,-Cr.y,Cr.x,0];if(!Bl(t,hs,ds,fs,Ra))return!1;if(t=[1,0,0,0,1,0,0,0,1],!Bl(t,hs,ds,fs,Ra))return!1;return Ca.crossVectors(ir,rr),t=[Ca.x,Ca.y,Ca.z],Bl(t,hs,ds,fs,Ra)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(jn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var zi=[new U,new U,new U,new U,new U,new U,new U,new U],jn=new U,Ta=new Gt,hs=new U,ds=new U,fs=new U,ir=new U,rr=new U,Cr=new U,oo=new U,Ra=new U,Ca=new U,Pr=new U;function Bl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Pr.fromArray(e,s);let a=r.x*Math.abs(Pr.x)+r.y*Math.abs(Pr.y)+r.z*Math.abs(Pr.z),c=t.dot(Pr),l=n.dot(Pr),u=i.dot(Pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var zt=new U,Pa=new Ue,lS=0;class jt extends ei{constructor(e,t,n=!1){super();if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lS++}),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++)Pa.fromBufferAttribute(this,t),Pa.applyMatrix3(e),this.setXY(t,Pa.x,Pa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix3(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyMatrix4(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.applyNormalMatrix(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)zt.fromBufferAttribute(this,t),zt.transformDirection(e),this.setXYZ(t,zt.x,zt.y,zt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=qn(t,this.array);return t}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=qn(t,this.array);return t}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=qn(t,this.array);return t}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=qn(t,this.array);return t}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class fc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class pc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class _n extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var uS=new Gt,ao=new U,Vl=new U;class wn{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 uS.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;ao.subVectors(e,this.center);let t=ao.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(ao,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 Vl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ao.copy(e.center).add(Vl)),this.expandByPoint(ao.copy(e.center).sub(Vl));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 hS=0,Un=new $e,Gl=new gt,ps=new U,bn=new Gt,co=new Gt,Zt=new U;class sn extends ei{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=Yn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){if(Array.isArray(e))this.index=new((Ob(e))?pc:fc)(e,1);else this.index=e;return this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;if(t!==void 0)t.applyMatrix4(e),t.needsUpdate=!0;let n=this.attributes.normal;if(n!==void 0){let r=new Ve().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;if(i!==void 0)i.transformDirection(e),i.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this._transformed=!0,this}applyQuaternion(e){return Un.makeRotationFromQuaternion(e),this.applyMatrix4(Un),this}rotateX(e){return Un.makeRotationX(e),this.applyMatrix4(Un),this}rotateY(e){return Un.makeRotationY(e),this.applyMatrix4(Un),this}rotateZ(e){return Un.makeRotationZ(e),this.applyMatrix4(Un),this}translate(e,t,n){return Un.makeTranslation(e,t,n),this.applyMatrix4(Un),this}scale(e,t,n){return Un.makeScale(e,t,n),this.applyMatrix4(Un),this}lookAt(e){return Gl.lookAt(e),Gl.updateMatrix(),this.applyMatrix4(Gl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new _n(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];if(bn.setFromBufferAttribute(r),this.morphTargetsRelative)Zt.addVectors(this.boundingBox.min,bn.min),this.boundingBox.expandByPoint(Zt),Zt.addVectors(this.boundingBox.max,bn.max),this.boundingBox.expandByPoint(Zt);else this.boundingBox.expandByPoint(bn.min),this.boundingBox.expandByPoint(bn.max)}}else this.boundingBox.makeEmpty();if(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new wn;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){let n=this.boundingSphere.center;if(bn.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){let o=t[r];if(co.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(bn.min,co.min),bn.expandByPoint(Zt),Zt.addVectors(bn.max,co.max),bn.expandByPoint(Zt);else bn.expandByPoint(co.min),bn.expandByPoint(co.max)}bn.getCenter(n);let i=0;for(let r=0,s=e.count;r<s;r++)Zt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Zt));if(t)for(let r=0,s=t.length;r<s;r++){let o=t[r],a=this.morphTargetsRelative;for(let c=0,l=o.count;c<l;c++){if(Zt.fromBufferAttribute(o,c),a)ps.fromBufferAttribute(e,c),Zt.add(ps);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))ke('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,d=new Ue,h=new Ue,f=new Ue,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(d),f.sub(d);let z=1/(h.x*f.y-f.x*h.y);if(!isFinite(z))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-h.y).multiplyScalar(z),_.copy(u).multiplyScalar(h.x).addScaledVector(l,-f.x).multiplyScalar(z),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let z=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,z)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:z,count:C}=M;for(let L=z,K=z+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let d=0,h=e.count;d<h;d+=3){let f=e.getX(d+0),m=e.getX(d+1),_=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,d=new c.constructor(a.length*l),h=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)h=a[m]*o.data.stride+o.offset;else h=a[m]*l;for(let p=0;p<l;p++)d[f++]=c[h++]}return new jt(d,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new sn,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let d=c[l],h=e(d,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,d=c.length;u<d;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,h=u.length;d<h;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class 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=Yn()}onUploadCallback(){}set needsUpdate(e){if(e===!0)this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer;let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){if(e.arrayBuffers===void 0)e.arrayBuffers={};if(this.array.buffer._uuid===void 0)this.array.buffer._uuid=Yn();if(e.arrayBuffers[this.array.buffer._uuid]===void 0)e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer));let t={uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride};return t.usage=this.usage,t}}var un=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++)un.fromBufferAttribute(this,t),un.applyMatrix4(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyNormalMatrix(e),this.setXYZ(t,un.x,un.y,un.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.transformDirection(e),this.setXYZ(t,un.x,un.y,un.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=dt(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=dt(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=qn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=qn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=qn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=qn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=dt(t,this.array),n=dt(n,this.array),i=dt(i,this.array),r=dt(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){go("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new jt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Ls(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){go("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e);return{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}}var Hl=new U,dS=new U,fS=new Ve;class Fn{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Hl.subVectors(n,t).cross(dS.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(Hl),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||fS.getNormalMatrix(e),i=this.coplanarPoint(Hl).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 pS=0;class xn extends ei{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:pS++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new ze().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Fn().fromJSON(n));if(e.clipIntersection!==void 0)this.clipIntersection=e.clipIntersection;if(e.clipShadows!==void 0)this.clipShadows=e.clipShadows;if(e.depthPacking!==void 0)this.depthPacking=e.depthPacking;if(e.blendSrc!==void 0)this.blendSrc=e.blendSrc;if(e.blendDst!==void 0)this.blendDst=e.blendDst;if(e.blendEquation!==void 0)this.blendEquation=e.blendEquation;if(e.blendSrcAlpha!==void 0)this.blendSrcAlpha=e.blendSrcAlpha;if(e.blendDstAlpha!==void 0)this.blendDstAlpha=e.blendDstAlpha;if(e.blendEquationAlpha!==void 0)this.blendEquationAlpha=e.blendEquationAlpha;if(e.blendColor!==void 0&&this.blendColor!==void 0)this.blendColor.setHex(e.blendColor);if(e.blendAlpha!==void 0)this.blendAlpha=e.blendAlpha;if(e.stencilWriteMask!==void 0)this.stencilWriteMask=e.stencilWriteMask;if(e.stencilFunc!==void 0)this.stencilFunc=e.stencilFunc;if(e.stencilRef!==void 0)this.stencilRef=e.stencilRef;if(e.stencilFuncMask!==void 0)this.stencilFuncMask=e.stencilFuncMask;if(e.stencilFail!==void 0)this.stencilFail=e.stencilFail;if(e.stencilZFail!==void 0)this.stencilZFail=e.stencilZFail;if(e.stencilZPass!==void 0)this.stencilZPass=e.stencilZPass;if(e.stencilWrite!==void 0)this.stencilWrite=e.stencilWrite;if(e.wireframe!==void 0)this.wireframe=e.wireframe;if(e.wireframeLinewidth!==void 0)this.wireframeLinewidth=e.wireframeLinewidth;if(e.wireframeLinecap!==void 0)this.wireframeLinecap=e.wireframeLinecap;if(e.wireframeLinejoin!==void 0)this.wireframeLinejoin=e.wireframeLinejoin;if(e.rotation!==void 0)this.rotation=e.rotation;if(e.linewidth!==void 0)this.linewidth=e.linewidth;if(e.linecap!==void 0)this.linecap=e.linecap;if(e.linejoin!==void 0)this.linejoin=e.linejoin;if(e.dashSize!==void 0)this.dashSize=e.dashSize;if(e.gapSize!==void 0)this.gapSize=e.gapSize;if(e.scale!==void 0)this.scale=e.scale;if(e.polygonOffset!==void 0)this.polygonOffset=e.polygonOffset;if(e.polygonOffsetFactor!==void 0)this.polygonOffsetFactor=e.polygonOffsetFactor;if(e.polygonOffsetUnits!==void 0)this.polygonOffsetUnits=e.polygonOffsetUnits;if(e.dithering!==void 0)this.dithering=e.dithering;if(e.alphaToCoverage!==void 0)this.alphaToCoverage=e.alphaToCoverage;if(e.premultipliedAlpha!==void 0)this.premultipliedAlpha=e.premultipliedAlpha;if(e.forceSinglePass!==void 0)this.forceSinglePass=e.forceSinglePass;if(e.allowOverride!==void 0)this.allowOverride=e.allowOverride;if(e.visible!==void 0)this.visible=e.visible;if(e.toneMapped!==void 0)this.toneMapped=e.toneMapped;if(e.userData!==void 0)this.userData=e.userData;if(e.vertexColors!==void 0)if(typeof e.vertexColors==="number")this.vertexColors=e.vertexColors>0;else this.vertexColors=e.vertexColors;if(e.size!==void 0)this.size=e.size;if(e.sizeAttenuation!==void 0)this.sizeAttenuation=e.sizeAttenuation;if(e.map!==void 0)this.map=t[e.map]||null;if(e.matcap!==void 0)this.matcap=t[e.matcap]||null;if(e.alphaMap!==void 0)this.alphaMap=t[e.alphaMap]||null;if(e.bumpMap!==void 0)this.bumpMap=t[e.bumpMap]||null;if(e.bumpScale!==void 0)this.bumpScale=e.bumpScale;if(e.normalMap!==void 0)this.normalMap=t[e.normalMap]||null;if(e.normalMapType!==void 0)this.normalMapType=e.normalMapType;if(e.normalScale!==void 0){let n=e.normalScale;if(Array.isArray(n)===!1)n=[n,n];this.normalScale=new Ue().fromArray(n)}if(e.displacementMap!==void 0)this.displacementMap=t[e.displacementMap]||null;if(e.displacementScale!==void 0)this.displacementScale=e.displacementScale;if(e.displacementBias!==void 0)this.displacementBias=e.displacementBias;if(e.roughnessMap!==void 0)this.roughnessMap=t[e.roughnessMap]||null;if(e.metalnessMap!==void 0)this.metalnessMap=t[e.metalnessMap]||null;if(e.emissiveMap!==void 0)this.emissiveMap=t[e.emissiveMap]||null;if(e.emissiveIntensity!==void 0)this.emissiveIntensity=e.emissiveIntensity;if(e.specularMap!==void 0)this.specularMap=t[e.specularMap]||null;if(e.specularIntensityMap!==void 0)this.specularIntensityMap=t[e.specularIntensityMap]||null;if(e.specularColorMap!==void 0)this.specularColorMap=t[e.specularColorMap]||null;if(e.envMap!==void 0)this.envMap=t[e.envMap]||null;if(e.envMapRotation!==void 0)this.envMapRotation.fromArray(e.envMapRotation);if(e.envMapIntensity!==void 0)this.envMapIntensity=e.envMapIntensity;if(e.reflectivity!==void 0)this.reflectivity=e.reflectivity;if(e.refractionRatio!==void 0)this.refractionRatio=e.refractionRatio;if(e.lightMap!==void 0)this.lightMap=t[e.lightMap]||null;if(e.lightMapIntensity!==void 0)this.lightMapIntensity=e.lightMapIntensity;if(e.aoMap!==void 0)this.aoMap=t[e.aoMap]||null;if(e.aoMapIntensity!==void 0)this.aoMapIntensity=e.aoMapIntensity;if(e.gradientMap!==void 0)this.gradientMap=t[e.gradientMap]||null;if(e.clearcoatMap!==void 0)this.clearcoatMap=t[e.clearcoatMap]||null;if(e.clearcoatRoughnessMap!==void 0)this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null;if(e.clearcoatNormalMap!==void 0)this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null;if(e.clearcoatNormalScale!==void 0)this.clearcoatNormalScale=new Ue().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var ki=new U,$l=new U,Ia=new U,La=new U;class fr{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ki.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){$l.copy(e).add(t).multiplyScalar(0.5),Ia.copy(t).sub(e).normalize(),La.copy(this.origin).sub($l);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(Ia),o=La.dot(this.direction),a=-La.dot(Ia),c=La.lengthSq(),l=Math.abs(1-s*s),u,d,h,f;if(l>0)if(u=s*a-o,d=s*o-a,f=r*l,u>=0)if(d>=-f)if(d<=f){let m=1/l;u*=m,d*=m,h=u*(u+s*d+2*o)+d*(s*u+d+2*a)+c}else d=r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else d=-r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else if(d<=-f)u=Math.max(0,-(-s*r+o)),d=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else if(d<=f)u=0,d=Math.min(Math.max(-r,-a),r),h=d*(d+2*a)+c;else u=Math.max(0,-(s*r+o)),d=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy($l).addScaledVector(Ia,d);return h}intersectSphere(e,t){if(e.radius<0)return null;ki.subVectors(e.center,this.origin);let n=ki.dot(this.direction),i=ki.dot(ki)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-d.z)*u,a=(e.max.z-d.z)*u;else o=(e.max.z-d.z)*u,a=(e.min.z-d.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ki)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,d=e.y-s.y,h=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,z,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=d,z=h,L=m,K=_,G=g,X=S;else A=l,R=c,M=h,z=d,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=d,I=m,P=g,c>=0)A=l,R=a,M=h,z=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,z=h,L=f,K=_,G=p,X=S;else if(x=l,C=h,I=_,P=S,l>=0)A=a,R=c,M=u,z=d,L=f,K=m,G=p,X=g;else A=c,R=a,M=d,z=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,k=R/x,q=1/x,Q=M-j*C,Me=z-k*C,ue=L-j*I,Be=K-k*I,we=G-j*P,Z=X-k*P,re=we*Be-Z*ue,se=Q*Z-Me*we,xe=ue*Me-Be*Q;if(i){if(re<0||se<0||xe<0)return null}else if((re<0||se<0||xe<0)&&(re>0||se>0||xe>0))return null;let Ee=re+se+xe;if(Ee===0)return null;let Ae=q*(re*C+se*I+xe*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class gi extends xn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}var Vf=new $e,Ir=new fr,Na=new wn,Gf=new U,Da=new U,Oa=new U,Ua=new U,Wl=new U,Fa=new U,Hf=new U,za=new U;class Mt extends gt{constructor(e=new sn,t=new gi){super();this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){if(super.copy(e,t),e.morphTargetInfluences!==void 0)this.morphTargetInfluences=e.morphTargetInfluences.slice();if(e.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary);return this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,s=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let o=this.morphTargetInfluences;if(r&&o){Fa.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(Wl.fromBufferAttribute(u,e),s)Fa.addScaledVector(Wl,l);else Fa.addScaledVector(Wl.sub(t),l)}t.add(Fa)}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(Na.copy(n.boundingSphere),Na.applyMatrix4(r),Ir.copy(e.ray).recast(e.near),Na.containsPoint(Ir.origin)===!1){if(Ir.intersectSphere(Na,Gf)===null)return;if(Ir.origin.distanceToSquared(Gf)>(e.far-e.near)**2)return}if(Vf.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(Vf),n.boundingBox!==null){if(Ir.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ir)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(o.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=ka(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(o.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=ka(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(a.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=ka(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(a.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=ka(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function mS(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;za.copy(a),za.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(za);if(l<n.near||l>n.far)return null;return{distance:l,point:za.clone(),object:e}}function ka(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Da),e.getVertexPosition(c,Oa),e.getVertexPosition(l,Ua);let u=mS(e,t,n,i,Da,Oa,Ua,Hf);if(u){let d=new U;if(zn.getBarycoord(Hf,Da,Oa,Ua,d),r)u.uv=zn.getInterpolatedAttribute(r,a,c,l,d,new Ue);if(s)u.uv1=zn.getInterpolatedAttribute(s,a,c,l,d,new Ue);if(o){if(u.normal=zn.getInterpolatedAttribute(o,a,c,l,d,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};zn.getNormal(Da,Oa,Ua,h.normal),u.face=h,u.barycoord=d}return u}var lo=new ft,$f=new ft,Wf=new ft,gS=new ft,Zf=new $e,Ba=new U,Zl=new wn,Xf=new $e,Xl=new fr;class mc extends Mt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ba),this.boundingBox.expandByPoint(Ba)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new wn;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Ba),this.boundingSphere.expandByPoint(Ba)}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(Zl.copy(this.boundingSphere),Zl.applyMatrix4(i),e.ray.intersectsSphere(Zl)===!1)return;if(Xf.copy(i).invert(),Xl.copy(e.ray).applyMatrix4(Xf),this.boundingBox!==null){if(Xl.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,Xl)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ft,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if($f.fromBufferAttribute(i.attributes.skinIndex,e),Wf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)lo.copy(t),t.set(0,0,0,0);else lo.set(...t,1),t.set(0,0,0);lo.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Wf.getComponent(r);if(s!==0){let o=$f.getComponent(r);Zf.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(gS.copy(lo).applyMatrix4(Zf),s)}}if(t.isVector4)t.w=lo.w;return t.applyMatrix4(this.bindMatrixInverse)}}class To extends gt{constructor(){super();this.isBone=!0,this.type="Bone"}}class Ro extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,d){super(null,s,o,a,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var jf=new $e,_S=new $e;class Co{constructor(e=[],t=[]){this.uuid=Yn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Le("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new $e;if(this.bones[e])n.copy(this.bones[e].matrixWorld).invert();this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n)n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];if(n){if(n.parent&&n.parent.isBone)n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld);else n.matrix.copy(n.matrixWorld);n.matrix.decompose(n.position,n.quaternion,n.scale)}}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,s=e.length;r<s;r++){let o=e[r]?e[r].matrixWorld:_S;jf.multiplyMatrices(o,t[r]),jf.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Co(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 Ro(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Le("Skeleton: No bone found with UUID:",r),s=new To;this.bones.push(s),this.boneInverses.push(new $e().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let s=t[i];e.bones.push(s.uuid);let o=n[i];e.boneInverses.push(o.toArray())}return e}}class ar extends jt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var ms=new $e,qf=new $e,Va=[],Yf=new Gt,xS=new $e,uo=new Mt,ho=new wn;class Ns extends Mt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new ar(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,xS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),Yf.copy(e.boundingBox).applyMatrix4(ms),this.boundingBox.union(Yf)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new wn;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ms),ho.copy(e.boundingSphere).applyMatrix4(ms),this.boundingSphere.union(ho)}copy(e,t){if(super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null)this.morphTexture=e.morphTexture.clone();if(e.instanceColor!==null)this.instanceColor=e.instanceColor.clone();if(this.count=e.count,e.boundingBox!==null)this.boundingBox=e.boundingBox.clone();if(e.boundingSphere!==null)this.boundingSphere=e.boundingSphere.clone();return this}getColorAt(e,t){if(this.instanceColor===null)return t.setRGB(1,1,1);else return t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,s=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[s+o]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(uo.geometry=this.geometry,uo.material=this.material,uo.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(ho.copy(this.boundingSphere),ho.applyMatrix4(n),e.ray.intersectsSphere(ho)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,ms),qf.multiplyMatrices(n,ms),uo.matrixWorld=qf,uo.raycast(e,Va);for(let s=0,o=Va.length;s<o;s++){let a=Va[s];a.instanceId=r,a.object=this,t.push(a)}Va.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new ar(new Float32Array(this.instanceMatrix.count*3).fill(1),3);return t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;if(this.morphTexture===null)this.morphTexture=new Ro(new Float32Array(i*this.count),i,this.count,1028,1015);let r=this.morphTexture.source.data.data,s=0;for(let c=0;c<n.length;c++)s+=n[c];let o=this.geometry.morphTargetsRelative?1:1-s,a=i*e;return r[a]=o,r.set(n,a+1),this}updateMorphTargets(){}dispose(){if(super.dispose(),this.morphTexture!==null)this.morphTexture.dispose(),this.morphTexture=null}}var Lr=new wn,yS=new Ue(0.5,0.5),Ga=new U;class Po{constructor(e=new Fn,t=new Fn,n=new Fn,i=new Fn,r=new Fn,s=new Fn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,h-l,p-f,y-g).normalize(),i[1].setComponents(c+s,h+l,p+f,y+g).normalize(),i[2].setComponents(c+o,h+u,p+m,y+S).normalize(),i[3].setComponents(c-o,h-u,p-m,y-S).normalize(),n)i[4].setComponents(a,d,_,T).normalize(),i[5].setComponents(c-a,h-d,p-_,y-T).normalize();else if(i[4].setComponents(c-a,h-d,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,h+d,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,d,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();Lr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld)}else{let t=e.geometry;if(t.boundingSphere===null)t.computeBoundingSphere();Lr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lr)}intersectsSprite(e){Lr.center.set(0,0,0);let t=yS.distanceTo(e.center);return Lr.radius=0.7071067811865476+t,Lr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lr)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ga.x=i.normal.x>0?e.max.x:e.min.x,Ga.y=i.normal.y>0?e.max.y:e.min.y,Ga.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ga)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Io extends xn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var Ya=new U,Ja=new U,Jf=new $e,fo=new fr,Ha=new wn,jl=new U,Kf=new U;class pr extends gt{constructor(e=new sn,t=new Io){super();this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Ya.fromBufferAttribute(t,i-1),Ja.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ya.distanceTo(Ja);e.setAttribute("lineDistance",new _n(n,1))}else Le("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ha.copy(n.boundingSphere),Ha.applyMatrix4(i),Ha.radius+=r,e.ray.intersectsSphere(Ha)===!1)return;Jf.copy(i).invert(),fo.copy(e.ray).applyMatrix4(Jf);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=$a(this,e,fo,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(h),p=$a(this,e,fo,a,m,_,f-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=$a(this,e,fo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=$a(this,e,fo,a,f-1,h,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function $a(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(Ya.fromBufferAttribute(a,r),Ja.fromBufferAttribute(a,s),n.distanceSqToSegment(Ya,Ja,jl,Kf)>i)return;jl.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(jl);if(l<t.near||l>t.far)return;return{distance:l,point:Kf.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Qf=new U,ep=new U;class gc extends pr{constructor(e,t){super(e,t);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Qf.fromBufferAttribute(t,i),ep.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Qf.distanceTo(ep);e.setAttribute("lineDistance",new _n(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class _c extends pr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class Lo extends xn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var tp=new $e,Jl=new fr,Wa=new wn,Za=new U;class Ds extends gt{constructor(e=new sn,t=new Lo){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(Wa.copy(n.boundingSphere),Wa.applyMatrix4(i),Wa.radius+=r,e.ray.intersectsSphere(Wa)===!1)return;tp.copy(i).invert(),Jl.copy(e.ray).applyMatrix4(tp);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let f=d,m=h;f<m;f++){let _=c.getX(f);Za.fromBufferAttribute(u,_),np(Za,_,a,i,e,t,this)}}else{let d=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let f=d,m=h;f<m;f++)Za.fromBufferAttribute(u,f),np(Za,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function np(e,t,n,i,r,s,o){let a=Jl.distanceSqToPoint(e);if(a<n){let c=new U;Jl.closestPointToPoint(e,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}class xc extends Nt{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Vr extends Nt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class th extends Vr{constructor(e,t=1014,n=301,i,r,s=1003,o=1003,a,c=1026){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,i,r,s,o,a,c);this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class yc extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class mr extends sn{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],d=0,h=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new _n(c,3)),this.setAttribute("normal",new _n(l,3)),this.setAttribute("uv",new _n(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,z=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let k=0;k<G;k++){let q=k*z-L;for(let Q=0;Q<I;Q++){let Me=Q*M-C;j[m]=Me*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(Q/A),u.push(1-k/R),X+=1}}for(let k=0;k<R;k++)for(let q=0;q<A;q++){let Q=d+q+I*k,Me=d+q+I*(k+1),ue=d+(q+1)+I*(k+1),Be=d+(q+1)+I*k;a.push(Q,Me,Be),a.push(Me,ue,Be),P+=6}o.addGroup(h,P,x),h+=P,d+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class No extends sn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,d=t/a,h=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*d-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;h.push(S,T,w),h.push(T,y,w)}this.setIndex(h),this.setAttribute("position",new _n(f,3)),this.setAttribute("normal",new _n(m,3)),this.setAttribute("uv",new _n(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(ip(r))if(r.isRenderTargetTexture)Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(ip(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 on(e){let t={};for(let n=0;n<e.length;n++){let i=Gr(e[n]);for(let r in i)t[r]=i[r]}return t}function ip(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function vS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function nh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return je.workingColorSpace}var um={clone:Gr,merge:on},bS=`void main() {
+ var yp="186",fr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},pr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},vp=0,ou=1,bp=2;var Mo=1,Sp=2,Rs=3,mr=0,rn=1,Hn=2,pi=0,wo=1,au=2,cu=3,lu=4,Mp=5;var Cs=100,wp=101,Ep=102,Ap=103,Tp=104,Rp=200,Cp=201,Pp=202,Ip=203,Lp=204,Np=205,Dp=206,Op=207,Up=208,Fp=209,kp=210,zp=211,Bp=212,Vp=213,Gp=214,Hp=0,$p=1,Wp=2,uu=3,Zp=4,Xp=5,jp=6,qp=7,Yp=0,Jp=1,Kp=2,ti=0,hu=1,du=2,fu=3,Eo=4,pu=5,mu=6,gu=7;var Ps=301,Br=302,sc=303,oc=304,Ao=306,Is=1000,Ls=1001,ac=1002,ni=1003,cc=1004;var Vr=1005;var qt=1006,Ns=1007;var mi=1008;var ii=1009,Qp=1010,em=1011,To=1012,_u=1013,gr=1014,Hi=1015,gi=1016,xu=1017,yu=1018,Ds=1020,tm=35902,nm=35899,im=1021,rm=1022,_i=1023,Gr=1026,Hr=1027,sm=1028,vu=1029,$r=1030,bu=1031;var Su=1033,lc=33776,uc=33777,hc=33778,dc=33779,Mu=35840,wu=35841,Eu=35842,Au=35843,Tu=36196,Ru=37492,Cu=37496,Pu=37488,Iu=37489,fc=37490,Lu=37491,Nu=37808,Du=37809,Ou=37810,Uu=37811,Fu=37812,ku=37813,zu=37814,Bu=37815,Vu=37816,Gu=37817,Hu=37818,$u=37819,Wu=37820,Zu=37821,Xu=36492,ju=36494,qu=36495,Yu=36283,Ju=36284,pc=36285,Ku=36286;var Qu=2300,mc=2301;var eh=0,Ro=1,Os=2;var th=0,om=1,Wr="",_r="srgb",wn="srgb-linear",nh="linear",vt="srgb";var am=512,cm=513,lm=514,gc=515,um=516,hm=517,_c=518,dm=519;var ih="300 es",rh=2000;function Wb(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Zb(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Es(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function fm(){let e=Es("canvas");return e.style.display="block",e}var Uf={},As=null;function So(...e){let t="THREE."+e.shift();if(As)As("log",t,...e);else console.log(t,...e)}function pm(e){let t=e[0];if(typeof t==="string"&&t.startsWith("TSL:")){let n=e[1];if(n&&n.isStackTrace)e[0]+=" "+n.getLocation();else e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function Le(...e){e=pm(e);let t="THREE."+e.shift();if(As)As("warn",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.warn(n.getError(t));else console.warn(t,...e)}}function Be(...e){e=pm(e);let t="THREE."+e.shift();if(As)As("error",t,...e);else{let n=e[0];if(n&&n.isStackTrace)console.error(n.getError(t));else console.error(t,...e)}}function kr(...e){let t=e.join(" ");if(t in Uf)return;Uf[t]=!0,Le(...e)}function mm(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 gm={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class ri{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 tn=["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"],Ff=1234567,vo=Math.PI/180,zr=180/Math.PI;function ei(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(tn[e&255]+tn[e>>8&255]+tn[e>>16&255]+tn[e>>24&255]+"-"+tn[t&255]+tn[t>>8&255]+"-"+tn[t>>16&15|64]+tn[t>>24&255]+"-"+tn[n&63|128]+tn[n>>8&255]+"-"+tn[n>>16&255]+tn[n>>24&255]+tn[i&255]+tn[i>>8&255]+tn[i>>16&255]+tn[i>>24&255]).toLowerCase()}function Ye(e,t,n){return Math.max(t,Math.min(n,e))}function sh(e,t){return(e%t+t)%t}function Xb(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function jb(e,t,n){if(e!==t)return(n-e)/(t-e);else return 0}function bo(e,t,n){return(1-n)*e+n*t}function qb(e,t,n,i){return bo(e,t,1-Math.exp(-n*i))}function Yb(e,t=1){return t-Math.abs(sh(e,t*2)-t)}function Jb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*(3-2*e)}function Kb(e,t,n){if(e<=t)return 0;if(e>=n)return 1;return e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10)}function Qb(e,t){return e+Math.floor(Math.random()*(t-e+1))}function eS(e,t){return e+Math.random()*(t-e)}function tS(e){return e*(0.5-Math.random())}function nS(e){if(e!==void 0)Ff=e;let t=Ff+=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 iS(e){return e*vo}function rS(e){return e*zr}function sS(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function oS(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function aS(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function cS(e,t,n,i,r){let{cos:s,sin:o}=Math,a=s(n/2),c=o(n/2),l=s((t+i)/2),u=o((t+i)/2),d=s((t-i)/2),h=o((t-i)/2),f=s((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,c*d,c*h,a*l);break;case"YZY":e.set(c*h,a*u,c*d,a*l);break;case"ZXZ":e.set(c*d,c*h,a*u,a*l);break;case"XZX":e.set(a*u,c*m,c*f,a*l);break;case"YXY":e.set(c*f,a*u,c*m,a*l);break;case"ZYZ":e.set(c*m,c*f,a*u,a*l);break;default:Le("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Qn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:case Uint8ClampedArray:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error("THREE.MathUtils: Invalid component type.")}}var Co={DEG2RAD:vo,RAD2DEG:zr,generateUUID:ei,clamp:Ye,euclideanModulo:sh,mapLinear:Xb,inverseLerp:jb,lerp:bo,damp:qb,pingpong:Yb,smoothstep:Jb,smootherstep:Kb,randInt:Qb,randFloat:eS,randFloatSpread:tS,seededRandom:nS,degToRad:iS,radToDeg:rS,isPowerOfTwo:sS,ceilPowerOfTwo:oS,floorPowerOfTwo:aS,setQuaternionFromProperEuler:cS,normalize:ft,denormalize:Qn};class Fe{static{Fe.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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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(Ye(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,s,o){let a=n[i+0],c=n[i+1],l=n[i+2],u=n[i+3],d=r[s+0],h=r[s+1],f=r[s+2],m=r[s+3];if(u!==m||a!==d||c!==h||l!==f){let _=a*d+c*h+l*f+u*m;if(_<0)d=-d,h=-h,f=-f,m=-m,_=-_;let p=1-o;if(_<0.9995){let g=Math.acos(_),S=Math.sin(g);p=Math.sin(p*g)/S,o=Math.sin(o*g)/S,a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o}else{a=a*p+d*o,c=c*p+h*o,l=l*p+f*o,u=u*p+m*o;let g=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=g,c*=g,l*=g,u*=g}}e[t]=a,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,s){let o=n[i],a=n[i+1],c=n[i+2],l=n[i+3],u=r[s],d=r[s+1],h=r[s+2],f=r[s+3];return e[t]=o*f+l*u+a*h-c*d,e[t+1]=a*f+l*d+c*u-o*h,e[t+2]=c*f+l*h+o*d-a*u,e[t+3]=l*f-o*u-a*d-c*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let{_x:n,_y:i,_z:r,_order:s}=e,{cos:o,sin:a}=Math,c=o(n/2),l=o(i/2),u=o(r/2),d=a(n/2),h=a(i/2),f=a(r/2);switch(s){case"XYZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"YXZ":this._x=d*l*u+c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"ZXY":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u-d*h*f;break;case"ZYX":this._x=d*l*u-c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u+d*h*f;break;case"YZX":this._x=d*l*u+c*h*f,this._y=c*h*u+d*l*f,this._z=c*l*f-d*h*u,this._w=c*l*u-d*h*f;break;case"XZY":this._x=d*l*u-c*h*f,this._y=c*h*u-d*l*f,this._z=c*l*f+d*h*u,this._w=c*l*u+d*h*f;break;default:Le("Quaternion: .setFromEuler() encountered an unknown order: "+s)}if(t===!0)this._onChangeCallback();return this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],o=t[5],a=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let h=0.5/Math.sqrt(d+1);this._w=0.25/h,this._x=(l-a)*h,this._y=(r-c)*h,this._z=(s-i)*h}else if(n>o&&n>u){let h=2*Math.sqrt(1+n-o-u);this._w=(l-a)/h,this._x=0.25*h,this._y=(i+s)/h,this._z=(r+c)/h}else if(o>u){let h=2*Math.sqrt(1+o-n-u);this._w=(r-c)/h,this._x=(i+s)/h,this._y=0.25*h,this._z=(a+l)/h}else{let h=2*Math.sqrt(1+u-n-o);this._w=(s-i)/h,this._x=(r+c)/h,this._y=(a+l)/h,this._z=0.25*h}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;if(n<0.00000001)if(n=0,Math.abs(e.x)>Math.abs(e.z))this._x=-e.y,this._y=e.x,this._z=0,this._w=n;else this._x=0,this._y=-e.z,this._z=e.y,this._w=n;else this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n;return this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ye(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(kf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(kf.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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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 Ol.copy(this).projectOnVector(e),this.sub(Ol)}reflect(e){return this.sub(Ol.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(Ye(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 Ol=new U,kf=new Xt;class Ge{static{Ge.prototype.isMatrix3=!0}constructor(e,t,n,i,r,s,o,a,c){if(this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c)}set(e,t,n,i,r,s,o,a,c){let l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=n,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[3],a=n[6],c=n[1],l=n[4],u=n[7],d=n[2],h=n[5],f=n[8],m=i[0],_=i[3],p=i[6],g=i[1],S=i[4],T=i[7],y=i[2],w=i[5],A=i[8];return r[0]=s*m+o*g+a*y,r[3]=s*_+o*S+a*w,r[6]=s*p+o*T+a*A,r[1]=c*m+l*g+u*y,r[4]=c*_+l*S+u*w,r[7]=c*p+l*T+u*A,r[2]=d*m+h*g+f*y,r[5]=d*_+h*S+f*w,r[8]=d*p+h*T+f*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*s*l-t*o*c-n*r*l+n*o*a+i*r*c-i*s*a}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=l*s-o*c,d=o*a-l*r,h=c*r-s*a,f=t*u+n*d+i*h;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/f;return e[0]=u*m,e[1]=(i*c-l*n)*m,e[2]=(o*n-i*s)*m,e[3]=d*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=h*m,e[7]=(n*a-c*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,o){let a=Math.cos(r),c=Math.sin(r);return this.set(n*a,n*c,-n*(a*s+c*o)+s+e,-i*c,i*a,-i*(-c*s+a*o)+o+t,0,0,1),this}scale(e,t){return kr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ul.makeScale(e,t)),this}rotate(e){return kr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ul.makeRotation(-e)),this}translate(e,t){return kr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ul.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 Ul=new Ge,zf=new Ge().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),Bf=new Ge().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function lS(){let e={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(r,s,o){if(this.enabled===!1||s===o||!s||!o)return r;if(this.spaces[s].transfer==="srgb")r.r=Gi(r.r),r.g=Gi(r.g),r.b=Gi(r.b);if(this.spaces[s].primaries!==this.spaces[o].primaries)r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ);if(this.spaces[o].transfer==="srgb")r.r=ws(r.r),r.g=ws(r.g),r.b=ws(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 kr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return kr("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:zf,fromXYZ:Bf,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:t,whitePoint:i,transfer:"srgb",toXYZ:zf,fromXYZ:Bf,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),e}var qe=lS();function Gi(e){return e<0.04045?e*0.0773993808:Math.pow(e*0.9478672986+0.0521327014,2.4)}function ws(e){return e<0.0031308?e*12.92:1.055*Math.pow(e,0.41666)-0.055}var us;class oh{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(us===void 0)us=Es("canvas");us.width=e.width,us.height=e.height;let i=us.getContext("2d");if(e instanceof ImageData)i.putImageData(e,0,0);else i.drawImage(e,0,0,e.width,e.height);n=us}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Es("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let s=0;s<r.length;s++)r[s]=Gi(r[s]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)t[n]=Math.floor(Gi(t[n]/255)*255);else t[n]=Gi(t[n]);return{data:t,width:e.width,height:e.height}}else return Le("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}var uS=0;class Po{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:uS++}),this.uuid=ei(),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(Fl(i[s].image));else r.push(Fl(i[s]))}else r=Fl(i);n.url=r}if(!t)e.images[this.uuid]=n;return n}}function Fl(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)return oh.getDataURL(e);else if(e.data)return{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name};else return Le("Texture: Unable to serialize Texture."),{}}var hS=0,kl=new U;class Nt extends ri{constructor(e=Nt.DEFAULT_IMAGE,t=Nt.DEFAULT_MAPPING,n=1001,i=1001,r=1006,s=1008,o=1023,a=1009,c=Nt.DEFAULT_ANISOTROPY,l=""){super();this.isTexture=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=ei(),this.name="",this.source=new Po(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 Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ge,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(kl).x}get height(){return this.source.getSize(kl).y}get depth(){return this.source.getSize(kl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Le(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Texture.setValues(): property '${t}' does not exist.`);continue}if(i&&n&&(i.isVector2&&n.isVector2))i.copy(n);else if(i&&n&&(i.isVector3&&n.isVector3))i.copy(n);else if(i&&n&&(i.isMatrix3&&n.isMatrix3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)n.userData=this.userData;if(!t)e.textures[this.uuid]=n;return n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1000:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.x)%2)===1)e.x=Math.ceil(e.x)-e.x;else e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case 1000:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(e.y)%2)===1)e.y=Math.ceil(e.y)-e.y;else e.y=e.y-Math.floor(e.y);break}if(this.flipY)e.y=1-e.y;return e}set needsUpdate(e){if(e===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(e){if(e===!0)this.pmremVersion++}}Nt.DEFAULT_IMAGE=null;Nt.DEFAULT_MAPPING=300;Nt.DEFAULT_ANISOTROPY=1;class pt{static{pt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);if(t<0.0001)this.x=1,this.y=0,this.z=0;else this.x=e.x/t,this.y=e.y/t,this.z=e.z/t;return this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,s=0.01,o=0.1,a=e.elements,c=a[0],l=a[4],u=a[8],d=a[1],h=a[5],f=a[9],m=a[2],_=a[6],p=a[10];if(Math.abs(l-d)<0.01&&Math.abs(u-m)<0.01&&Math.abs(f-_)<0.01){if(Math.abs(l+d)<0.1&&Math.abs(u+m)<0.1&&Math.abs(f+_)<0.1&&Math.abs(c+h+p-3)<0.1)return this.set(1,0,0,0),this;t=Math.PI;let S=(c+1)/2,T=(h+1)/2,y=(p+1)/2,w=(l+d)/4,A=(u+m)/4,R=(f+_)/4;if(S>T&&S>y)if(S<0.01)n=0,i=0.707106781,r=0.707106781;else n=Math.sqrt(S),i=w/n,r=A/n;else if(T>y)if(T<0.01)n=0.707106781,i=0,r=0.707106781;else i=Math.sqrt(T),n=w/i,r=R/i;else if(y<0.01)n=0.707106781,i=0.707106781,r=0;else r=Math.sqrt(y),n=A/r,i=R/r;return this.set(n,i,r,t),this}let g=Math.sqrt((_-f)*(_-f)+(u-m)*(u-m)+(d-l)*(d-l));if(Math.abs(g)<0.001)g=1;return this.x=(_-f)/g,this.y=(u-m)/g,this.z=(d-l)/g,this.w=Math.acos((c+h+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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 ah extends ri{constructor(e=1,t=1,n={}){super();n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new pt(0,0,e,t),this.scissorTest=!1,this.viewport=new pt(0,0,e,t),this.textures=[];let i={width:e,height:t,depth:n.depth},r=new Nt(i),s=n.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:1006,generateMipmaps:!1,flipY:!1,internalFormat:null};if(e.mapping!==void 0)t.mapping=e.mapping;if(e.wrapS!==void 0)t.wrapS=e.wrapS;if(e.wrapT!==void 0)t.wrapT=e.wrapT;if(e.wrapR!==void 0)t.wrapR=e.wrapR;if(e.magFilter!==void 0)t.magFilter=e.magFilter;if(e.minFilter!==void 0)t.minFilter=e.minFilter;if(e.format!==void 0)t.format=e.format;if(e.type!==void 0)t.type=e.type;if(e.anisotropy!==void 0)t.anisotropy=e.anisotropy;if(e.colorSpace!==void 0)t.colorSpace=e.colorSpace;if(e.flipY!==void 0)t.flipY=e.flipY;if(e.generateMipmaps!==void 0)t.generateMipmaps=e.generateMipmaps;if(e.internalFormat!==void 0)t.internalFormat=e.internalFormat;for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){if(this._depthTexture!==null&&this._depthTexture.renderTarget===this)this._depthTexture.renderTarget=null;if(e!==null&&e.renderTarget===null)e.renderTarget=this;this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)if(this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0)this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let i=Object.assign({},e.textures[t].image);this.textures[t].source=new Po(i)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class En extends ah{constructor(e=1,t=1,n={}){super(e,t,n);this.isWebGLRenderTarget=!0}}class xc extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ch extends Nt{constructor(e=null,t=1,n=1,i=1){super(null);this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}}class We{static{We.prototype.isMatrix4=!0}constructor(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){if(this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0)this.set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_)}set(e,t,n,i,r,s,o,a,c,l,u,d,h,f,m,_){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=s,p[9]=o,p[13]=a,p[2]=c,p[6]=l,p[10]=u,p[14]=d,p[3]=h,p[7]=f,p[11]=m,p[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new We().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/hs.setFromMatrixColumn(e,0).length(),r=1/hs.setFromMatrixColumn(e,1).length(),s=1/hs.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,{x:n,y:i,z:r}=e,s=Math.cos(n),o=Math.sin(n),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=-a*u,t[8]=c,t[1]=h+f*c,t[5]=d-m*c,t[9]=-o*a,t[2]=m-d*c,t[6]=f+h*c,t[10]=s*a}else if(e.order==="YXZ"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d+m*o,t[4]=f*o-h,t[8]=s*c,t[1]=s*u,t[5]=s*l,t[9]=-o,t[2]=h*o-f,t[6]=m+d*o,t[10]=s*a}else if(e.order==="ZXY"){let d=a*l,h=a*u,f=c*l,m=c*u;t[0]=d-m*o,t[4]=-s*u,t[8]=f+h*o,t[1]=h+f*o,t[5]=s*l,t[9]=m-d*o,t[2]=-s*c,t[6]=o,t[10]=s*a}else if(e.order==="ZYX"){let d=s*l,h=s*u,f=o*l,m=o*u;t[0]=a*l,t[4]=f*c-h,t[8]=d*c+m,t[1]=a*u,t[5]=m*c+d,t[9]=h*c-f,t[2]=-c,t[6]=o*a,t[10]=s*a}else if(e.order==="YZX"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=m-d*u,t[8]=f*u+h,t[1]=u,t[5]=s*l,t[9]=-o*l,t[2]=-c*l,t[6]=h*u+f,t[10]=d-m*u}else if(e.order==="XZY"){let d=s*a,h=s*c,f=o*a,m=o*c;t[0]=a*l,t[4]=-u,t[8]=c*l,t[1]=d*u+m,t[5]=s*l,t[9]=h*u-f,t[2]=f*u-h,t[6]=o*l,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(dS,e,fS)}lookAt(e,t,n){let i=this.elements;if(Sn.subVectors(e,t),Sn.lengthSq()===0)Sn.z=1;if(Sn.normalize(),or.crossVectors(n,Sn),or.lengthSq()===0){if(Math.abs(n.z)===1)Sn.x+=0.0001;else Sn.z+=0.0001;Sn.normalize(),or.crossVectors(n,Sn)}return or.normalize(),Ia.crossVectors(Sn,or),i[0]=or.x,i[4]=Ia.x,i[8]=Sn.x,i[1]=or.y,i[5]=Ia.y,i[9]=Sn.y,i[2]=or.z,i[6]=Ia.z,i[10]=Sn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,s=n[0],o=n[4],a=n[8],c=n[12],l=n[1],u=n[5],d=n[9],h=n[13],f=n[2],m=n[6],_=n[10],p=n[14],g=n[3],S=n[7],T=n[11],y=n[15],w=i[0],A=i[4],R=i[8],x=i[12],M=i[1],k=i[5],C=i[9],L=i[13],K=i[2],I=i[6],G=i[10],X=i[14],P=i[3],j=i[7],z=i[11],q=i[15];return r[0]=s*w+o*M+a*K+c*P,r[4]=s*A+o*k+a*I+c*j,r[8]=s*R+o*C+a*G+c*z,r[12]=s*x+o*L+a*X+c*q,r[1]=l*w+u*M+d*K+h*P,r[5]=l*A+u*k+d*I+h*j,r[9]=l*R+u*C+d*G+h*z,r[13]=l*x+u*L+d*X+h*q,r[2]=f*w+m*M+_*K+p*P,r[6]=f*A+m*k+_*I+p*j,r[10]=f*R+m*C+_*G+p*z,r[14]=f*x+m*L+_*X+p*q,r[3]=g*w+S*M+T*K+y*P,r[7]=g*A+S*k+T*I+y*j,r[11]=g*R+S*C+T*G+y*z,r[15]=g*x+S*L+T*X+y*q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],o=e[5],a=e[9],c=e[13],l=e[2],u=e[6],d=e[10],h=e[14],f=e[3],m=e[7],_=e[11],p=e[15],g=a*h-c*d,S=o*h-c*u,T=o*d-a*u,y=s*h-c*l,w=s*d-a*l,A=s*u-o*l;return t*(m*g-_*S+p*T)-n*(f*g-_*y+p*w)+i*(f*S-m*y+p*A)-r*(f*T-m*w+_*A)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],s=e[5],o=e[9],a=e[2],c=e[6],l=e[10];return t*(s*l-o*c)-n*(r*l-o*a)+i*(r*c-s*a)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;if(e.isVector3)i[12]=e.x,i[13]=e.y,i[14]=e.z;else i[12]=e,i[13]=t,i[14]=n;return this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],d=e[10],h=e[11],f=e[12],m=e[13],_=e[14],p=e[15],g=t*o-n*s,S=t*a-i*s,T=t*c-r*s,y=n*a-i*o,w=n*c-r*o,A=i*c-r*a,R=l*m-u*f,x=l*_-d*f,M=l*p-h*f,k=u*_-d*m,C=u*p-h*m,L=d*p-h*_,K=g*L-S*C+T*k+y*M-w*x+A*R;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let I=1/K;return e[0]=(o*L-a*C+c*k)*I,e[1]=(i*C-n*L-r*k)*I,e[2]=(m*A-_*w+p*y)*I,e[3]=(d*w-u*A-h*y)*I,e[4]=(a*M-s*L-c*x)*I,e[5]=(t*L-i*M+r*x)*I,e[6]=(_*T-f*A-p*S)*I,e[7]=(l*A-d*T+h*S)*I,e[8]=(s*C-o*M+c*R)*I,e[9]=(n*M-t*C-r*R)*I,e[10]=(f*w-m*T+p*g)*I,e[11]=(u*T-l*w-h*g)*I,e[12]=(o*x-s*k-a*R)*I,e[13]=(t*k-n*x+i*R)*I,e[14]=(m*S-f*y-_*g)*I,e[15]=(l*y-u*S+d*g)*I,this}scale(e){let t=this.elements,{x:n,y:i,z:r}=e;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){if(e.isVector3)this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1);else this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1);return this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,{x:s,y:o,z:a}=e,c=r*s,l=r*o;return this.set(c*s+n,c*o-i*a,c*a+i*o,0,c*o+i*a,l*o+n,l*a-i*s,0,c*a-i*o,l*a+i*s,r*a*a+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,{_x:r,_y:s,_z:o,_w:a}=t,c=r+r,l=s+s,u=o+o,d=r*c,h=r*l,f=r*u,m=s*l,_=s*u,p=o*u,g=a*c,S=a*l,T=a*u,{x:y,y:w,z:A}=n;return i[0]=(1-(m+p))*y,i[1]=(h+T)*y,i[2]=(f-S)*y,i[3]=0,i[4]=(h-T)*w,i[5]=(1-(d+p))*w,i[6]=(_+g)*w,i[7]=0,i[8]=(f+S)*A,i[9]=(_-g)*A,i[10]=(1-(d+m))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let s=hs.set(i[0],i[1],i[2]).length(),o=hs.set(i[4],i[5],i[6]).length(),a=hs.set(i[8],i[9],i[10]).length();if(r<0)s=-s;Yn.copy(this);let c=1/s,l=1/o,u=1/a;return Yn.elements[0]*=c,Yn.elements[1]*=c,Yn.elements[2]*=c,Yn.elements[4]*=l,Yn.elements[5]*=l,Yn.elements[6]*=l,Yn.elements[8]*=u,Yn.elements[9]*=u,Yn.elements[10]*=u,t.setFromRotationMatrix(Yn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i),f,m;if(a)f=r/(s-r),m=s*r/(s-r);else if(o===2000)f=-(s+r)/(s-r),m=-2*s*r/(s-r);else if(o===2001)f=-s/(s-r),m=-s*r/(s-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,s,o=2000,a=!1){let c=this.elements,l=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i),f,m;if(a)f=1/(s-r),m=s/(s-r);else if(o===2000)f=-2/(s-r),m=-(s+r)/(s-r);else if(o===2001)f=-1/(s-r),m=-r/(s-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=h,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}var hs=new U,Yn=new We,dS=new U(0,0,0),fS=new U(1,1,1),or=new U,Ia=new U,Sn=new U,Vf=new We,Gf=new Xt;class fi{constructor(e=0,t=0,n=0,i=fi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],s=i[4],o=i[8],a=i[1],c=i[5],l=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":if(this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<0.9999999)this._x=Math.atan2(-l,h),this._z=Math.atan2(-s,r);else this._x=Math.atan2(d,c),this._z=0;break;case"YXZ":if(this._x=Math.asin(-Ye(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(Ye(d,-1,1)),Math.abs(d)<0.9999999)this._y=Math.atan2(-u,h),this._z=Math.atan2(-s,c);else this._y=0,this._z=Math.atan2(a,r);break;case"ZYX":if(this._y=Math.asin(-Ye(u,-1,1)),Math.abs(u)<0.9999999)this._x=Math.atan2(d,h),this._z=Math.atan2(a,r);else this._x=0,this._z=Math.atan2(-s,c);break;case"YZX":if(this._z=Math.asin(Ye(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(-Ye(s,-1,1)),Math.abs(s)<0.9999999)this._x=Math.atan2(d,c),this._y=Math.atan2(o,r);else this._x=Math.atan2(-l,h),this._y=0;break;default:Le("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}if(this._order=t,n===!0)this._onChangeCallback();return this}setFromQuaternion(e,t,n){return Vf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Vf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Gf.setFromEuler(this),this.setFromQuaternion(Gf,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}}fi.DEFAULT_ORDER="XYZ";class yc{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 pS=0,Hf=new U,ds=new Xt,Ui=new We,La=new U,ho=new U,mS=new U,gS=new Xt,$f=new U(1,0,0),Wf=new U(0,1,0),Zf=new U(0,0,1),Xf={type:"added"},_S={type:"removed"},fs={type:"childadded",child:null},zl={type:"childremoved",child:null};class _t extends ri{constructor(){super();this.isObject3D=!0,Object.defineProperty(this,"id",{value:pS++}),this.uuid=ei(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_t.DEFAULT_UP.clone();let e=new U,t=new fi,n=new Xt,i=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function s(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new We},normalMatrix:{value:new Ge}}),this.matrix=new We,this.matrixWorld=new We,this.matrixAutoUpdate=_t.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yc,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 ds.setFromAxisAngle(e,t),this.quaternion.multiply(ds),this}rotateOnWorldAxis(e,t){return ds.setFromAxisAngle(e,t),this.quaternion.premultiply(ds),this}rotateX(e){return this.rotateOnAxis($f,e)}rotateY(e){return this.rotateOnAxis(Wf,e)}rotateZ(e){return this.rotateOnAxis(Zf,e)}translateOnAxis(e,t){return Hf.copy(e).applyQuaternion(this.quaternion),this.position.add(Hf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($f,e)}translateY(e){return this.translateOnAxis(Wf,e)}translateZ(e){return this.translateOnAxis(Zf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ui.copy(this.matrixWorld).invert())}lookAt(e,t,n){if(e.isVector3)La.copy(e);else La.set(e,t,n);let i=this.parent;if(this.updateWorldMatrix(!0,!1),ho.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight)Ui.lookAt(ho,La,this.up);else Ui.lookAt(La,ho,this.up);if(this.quaternion.setFromRotationMatrix(Ui),i)Ui.extractRotation(i.matrixWorld),ds.setFromRotationMatrix(Ui),this.quaternion.premultiply(ds.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 Be("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(Xf),fs.child=e,this.dispatchEvent(fs),fs.child=null;else Be("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(_S),zl.child=e,this.dispatchEvent(zl),zl.child=null;return this}removeFromParent(){let e=this.parent;if(e!==null)e.remove(this);return this}clear(){return this.remove(...this.children)}attach(e){if(this.updateWorldMatrix(!0,!1),Ui.copy(this.matrixWorld).invert(),e.parent!==null)e.parent.updateWorldMatrix(!0,!1),Ui.multiply(e.parent.matrixWorld);return e.applyMatrix4(Ui),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Xf),fs.child=e,this.dispatchEvent(fs),fs.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(ho,e,mS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ho,gS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;if(t!==null)e(t),t.traverseAncestors(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let{x:t,y:n,z:i}=e,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,e=!0}let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let i=this.parent;if(e===!0&&i!==null)i.updateWorldMatrix(!0,!1);if(this.matrixAutoUpdate)this.updateMatrix();if(this.matrixWorldNeedsUpdate||n){if(this.matrixWorldAutoUpdate===!0)if(this.parent===null)this.matrixWorld.copy(this.matrix);else this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix);this.matrixWorldNeedsUpdate=!1,n=!0}if(t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==="string",n={};if(t)e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"};let i={};if(i.uuid=this.uuid,i.type=this.type,i.name=this.name,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow,i.visible=this.visible,i.frustumCulled=this.frustumCulled,i.renderOrder=this.renderOrder,i.static=this.static,i.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0)i.userData=this.userData;if(i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null)i.pivot=this.pivot.toArray();if(this.morphTargetDictionary!==void 0)i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)i.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)i.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map((o)=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map((o)=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null)i.colorsTexture=this._colorsTexture.toJSON(e);if(this.boundingSphere!==null)i.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)i.boundingBox=this.boundingBox.toJSON()}function r(o,a){if(o[a.uuid]===void 0)o[a.uuid]=a.toJSON(e);return a.uuid}if(this.isScene){if(this.background){if(this.background.isColor)i.background=this.background.toJSON();else if(this.background.isTexture)i.background=this.background.toJSON(e).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)i.environment=this.environment.toJSON(e).uuid}else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){let u=a[c];r(e.shapes,u)}else r(e.shapes,a)}}if(this.isSkinnedMesh){if(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0)r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid}if(this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,c=this.material.length;a<c;a++)o.push(r(e.materials,this.material[a]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(r(e.animations,a))}}if(t){let o=s(e.geometries),a=s(e.materials),c=s(e.textures),l=s(e.images),u=s(e.shapes),d=s(e.skeletons),h=s(e.animations),f=s(e.nodes);if(o.length>0)n.geometries=o;if(a.length>0)n.materials=a;if(c.length>0)n.textures=c;if(l.length>0)n.images=l;if(u.length>0)n.shapes=u;if(d.length>0)n.skeletons=d;if(h.length>0)n.animations=h;if(f.length>0)n.nodes=f}return n.object=i,n;function s(o){let a=[];for(let c in o){let l=o[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}}_t.DEFAULT_UP=new U(0,1,0);_t.DEFAULT_MATRIX_AUTO_UPDATE=!0;_t.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class hi extends _t{constructor(){super();this.isGroup=!0,this.type="Group"}}var xS={type:"move"};class Io{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){if(this._hand===null)this._hand=new hi,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 hi,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 hi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1;return this._grip}dispatchEvent(e){if(this._targetRay!==null)this._targetRay.dispatchEvent(e);if(this._grip!==null)this._grip.dispatchEvent(e);if(this._hand!==null)this._hand.dispatchEvent(e);return this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){if(this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null)this._targetRay.visible=!1;if(this._grip!==null)this._grip.visible=!1;if(this._hand!==null)this._hand.visible=!1;return this}update(e,t,n){let i=null,r=null,s=null,o=this._targetRay,a=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(let m of e.hand.values()){let _=t.getJointPose(m,n),p=this._getHandJoint(c,m);if(_!==null)p.matrix.fromArray(_.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=_.radius;p.visible=_!==null}let l=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=l.position.distanceTo(u.position),h=0.02,f=0.005;if(c.inputState.pinching&&d>h+f)c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this});else if(!c.inputState.pinching&&d<=h-f)c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this})}else if(a!==null&&e.gripSpace){if(r=t.getPose(e.gripSpace,n),r!==null){if(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity)a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity);else a.hasLinearVelocity=!1;if(r.angularVelocity)a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity);else a.hasAngularVelocity=!1;if(a.eventsEnabled)a.dispatchEvent({type:"gripUpdated",data:e,target:this})}}if(o!==null){if(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null)i=r;if(i!==null){if(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity)o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity);else o.hasLinearVelocity=!1;if(i.angularVelocity)o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity);else o.hasAngularVelocity=!1;this.dispatchEvent(xS)}}}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 hi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}var _m={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},ar={h:0,s:0,l:0},Na={h:0,s:0,l:0};function Bl(e,t,n){if(n<0)n+=1;if(n>1)n-=1;if(n<0.16666666666666666)return e+(t-e)*6*n;if(n<0.5)return t;if(n<0.6666666666666666)return e+(t-e)*6*(0.6666666666666666-n);return e}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let i=e;if(i&&i.isColor)this.copy(i);else if(typeof i==="number")this.setHex(i);else if(typeof i==="string")this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t="srgb"){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=qe.workingColorSpace){if(e=sh(e,1),t=Ye(t,0,1),n=Ye(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=Bl(s,r,e+0.3333333333333333),this.g=Bl(s,r,e),this.b=Bl(s,r,e-0.3333333333333333)}return qe.colorSpaceToWorking(this,i),this}setStyle(e,t="srgb"){function n(r){if(r===void 0)return;if(parseFloat(r)<1)Le("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Le("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);else if(s===6)return this.setHex(parseInt(r,16),t);else Le("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t="srgb"){let n=_m[e.toLowerCase()];if(n!==void 0)this.setHex(n,t);else Le("Color: Unknown color "+e);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Gi(e.r),this.g=Gi(e.g),this.b=Gi(e.b),this}copyLinearToSRGB(e){return this.r=ws(e.r),this.g=ws(e.g),this.b=ws(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e="srgb"){return qe.workingToColorSpace(nn.copy(this),e),Math.round(Ye(nn.r*255,0,255))*65536+Math.round(Ye(nn.g*255,0,255))*256+Math.round(Ye(nn.b*255,0,255))}getHexString(e="srgb"){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(nn.copy(this),t);let{r:n,g:i,b:r}=nn,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=qe.workingColorSpace){return qe.workingToColorSpace(nn.copy(this),t),e.r=nn.r,e.g=nn.g,e.b=nn.b,e}getStyle(e="srgb"){qe.workingToColorSpace(nn.copy(this),e);let{r:t,g:n,b:i}=nn;if(e!=="srgb")return`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`;return`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ar),this.setHSL(ar.h+e,ar.s+t,ar.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(ar),e.getHSL(Na);let n=bo(ar.h,Na.h,t),i=bo(ar.s,Na.s,t),r=bo(ar.l,Na.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 nn=new ze;ze.NAMES=_m;class Us extends _t{constructor(){super();if(this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fi,this.environmentIntensity=1,this.environmentRotation=new fi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){if(super.copy(e,t),e.background!==null)this.background=e.background.clone();if(e.environment!==null)this.environment=e.environment.clone();if(e.fog!==null)this.fog=e.fog.clone();if(this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null)this.overrideMaterial=e.overrideMaterial.clone();return this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);if(this.fog!==null)t.object.fog=this.fog.toJSON();return t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}}var Jn=new U,Fi=new U,Vl=new U,ki=new U,ps=new U,ms=new U,jf=new U,Gl=new U,Hl=new U,$l=new U,Wl=new pt,Zl=new pt,Xl=new pt;class Gn{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Jn.subVectors(e,t),i.cross(Jn);let r=i.lengthSq();if(r>0)return i.multiplyScalar(1/Math.sqrt(r));return i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Jn.subVectors(i,t),Fi.subVectors(n,t),Vl.subVectors(e,t);let s=Jn.dot(Jn),o=Jn.dot(Fi),a=Jn.dot(Vl),c=Fi.dot(Fi),l=Fi.dot(Vl),u=s*c-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,h=(c*a-o*l)*d,f=(s*l-o*a)*d;return r.set(1-h-f,f,h)}static containsPoint(e,t,n,i){if(this.getBarycoord(e,t,n,i,ki)===null)return!1;return ki.x>=0&&ki.y>=0&&ki.x+ki.y<=1}static getInterpolation(e,t,n,i,r,s,o,a){if(this.getBarycoord(e,t,n,i,ki)===null){if(a.x=0,a.y=0,"z"in a)a.z=0;if("w"in a)a.w=0;return null}return a.setScalar(0),a.addScaledVector(r,ki.x),a.addScaledVector(s,ki.y),a.addScaledVector(o,ki.z),a}static getInterpolatedAttribute(e,t,n,i,r,s){return Wl.setScalar(0),Zl.setScalar(0),Xl.setScalar(0),Wl.fromBufferAttribute(e,t),Zl.fromBufferAttribute(e,n),Xl.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Wl,r.x),s.addScaledVector(Zl,r.y),s.addScaledVector(Xl,r.z),s}static isFrontFacing(e,t,n,i){return Jn.subVectors(n,t),Fi.subVectors(e,t),Jn.cross(Fi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Jn.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),Jn.cross(Fi).length()*0.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(e){return Gn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Gn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Gn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Gn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Gn.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;ps.subVectors(i,n),ms.subVectors(r,n),Gl.subVectors(e,n);let a=ps.dot(Gl),c=ms.dot(Gl);if(a<=0&&c<=0)return t.copy(n);Hl.subVectors(e,i);let l=ps.dot(Hl),u=ms.dot(Hl);if(l>=0&&u<=l)return t.copy(i);let d=a*u-l*c;if(d<=0&&a>=0&&l<=0)return s=a/(a-l),t.copy(n).addScaledVector(ps,s);$l.subVectors(e,r);let h=ps.dot($l),f=ms.dot($l);if(f>=0&&h<=f)return t.copy(r);let m=h*c-a*f;if(m<=0&&c>=0&&f<=0)return o=c/(c-f),t.copy(n).addScaledVector(ms,o);let _=l*f-h*u;if(_<=0&&u-l>=0&&h-f>=0)return jf.subVectors(r,i),o=(u-l)/(u-l+(h-f)),t.copy(i).addScaledVector(jf,o);let p=1/(_+m+d);return s=m*p,o=d*p,t.copy(n).addScaledVector(ps,s).addScaledVector(ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Gt{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Kn.copy(t).multiplyScalar(0.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(0.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++){if(e.isMesh===!0)e.getVertexPosition(s,Kn);else Kn.fromBufferAttribute(r,s);Kn.applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else{if(e.boundingBox!==void 0){if(e.boundingBox===null)e.computeBoundingBox();Da.copy(e.boundingBox)}else{if(n.boundingBox===null)n.computeBoundingBox();Da.copy(n.boundingBox)}Da.applyMatrix4(e.matrixWorld),this.union(Da)}}let i=e.children;for(let r=0,s=i.length;r<s;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;if(e.normal.x>0)t=e.normal.x*this.min.x,n=e.normal.x*this.max.x;else t=e.normal.x*this.max.x,n=e.normal.x*this.min.x;if(e.normal.y>0)t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y;else t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y;if(e.normal.z>0)t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z;else t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z;return t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(fo),Oa.subVectors(this.max,fo),gs.subVectors(e.a,fo),_s.subVectors(e.b,fo),xs.subVectors(e.c,fo),cr.subVectors(_s,gs),lr.subVectors(xs,_s),Dr.subVectors(gs,xs);let t=[0,-cr.z,cr.y,0,-lr.z,lr.y,0,-Dr.z,Dr.y,cr.z,0,-cr.x,lr.z,0,-lr.x,Dr.z,0,-Dr.x,-cr.y,cr.x,0,-lr.y,lr.x,0,-Dr.y,Dr.x,0];if(!jl(t,gs,_s,xs,Oa))return!1;if(t=[1,0,0,0,1,0,0,0,1],!jl(t,gs,_s,xs,Oa))return!1;return Ua.crossVectors(cr,lr),t=[Ua.x,Ua.y,Ua.z],jl(t,gs,_s,xs,Oa)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){if(this.isEmpty())e.makeEmpty();else this.getCenter(e.center),e.radius=this.getSize(Kn).length()*0.5;return e}intersect(e){if(this.min.max(e.min),this.max.min(e.max),this.isEmpty())this.makeEmpty();return this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){if(this.isEmpty())return this;return zi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zi),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}var zi=[new U,new U,new U,new U,new U,new U,new U,new U],Kn=new U,Da=new Gt,gs=new U,_s=new U,xs=new U,cr=new U,lr=new U,Dr=new U,fo=new U,Oa=new U,Ua=new U,Or=new U;function jl(e,t,n,i,r){for(let s=0,o=e.length-3;s<=o;s+=3){Or.fromArray(e,s);let a=r.x*Math.abs(Or.x)+r.y*Math.abs(Or.y)+r.z*Math.abs(Or.z),c=t.dot(Or),l=n.dot(Or),u=i.dot(Or);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var kt=new U,Fa=new Fe,yS=0;class jt extends ri{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:yS++}),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++)Fa.fromBufferAttribute(this,t),Fa.applyMatrix3(e),this.setXY(t,Fa.x,Fa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix3(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyMatrix4(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyNormalMatrix(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.transformDirection(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];if(this.normalized)n=Qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];if(this.normalized)t=Qn(t,this.array);return t}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];if(this.normalized)t=Qn(t,this.array);return t}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];if(this.normalized)t=Qn(t,this.array);return t}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];if(this.normalized)t=Qn(t,this.array);return t}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e*=this.itemSize,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}}class vc extends jt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class bc extends jt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class xn extends jt{constructor(e,t,n){super(new Float32Array(e),t,n)}}var vS=new Gt,po=new U,ql=new U;class An{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;if(t!==void 0)n.copy(t);else vS.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;po.subVectors(e,this.center);let t=po.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*0.5;this.center.addScaledVector(po,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 ql.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(po.copy(e.center).add(ql)),this.expandByPoint(po.copy(e.center).sub(ql));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 bS=0,Bn=new We,Yl=new _t,ys=new U,Mn=new Gt,mo=new Gt,Zt=new U;class sn extends ri{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bS++}),this.uuid=ei(),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((Wb(e))?bc:vc)(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 Ge().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 Bn.makeRotationFromQuaternion(e),this.applyMatrix4(Bn),this}rotateX(e){return Bn.makeRotationX(e),this.applyMatrix4(Bn),this}rotateY(e){return Bn.makeRotationY(e),this.applyMatrix4(Bn),this}rotateZ(e){return Bn.makeRotationZ(e),this.applyMatrix4(Bn),this}translate(e,t,n){return Bn.makeTranslation(e,t,n),this.applyMatrix4(Bn),this}scale(e,t,n){return Bn.makeScale(e,t,n),this.applyMatrix4(Bn),this}lookAt(e){return Yl.lookAt(e),Yl.updateMatrix(),this.applyMatrix4(Yl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ys).negate(),this.translate(ys.x,ys.y,ys.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];n.push(s.x,s.y,s.z||0)}this.setAttribute("position",new xn(n,3))}else{let n=Math.min(e.length,t.count);for(let i=0;i<n;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}if(e.length>t.count)Le("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");t.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new Gt;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("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))Be('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){if(this.boundingSphere===null)this.boundingSphere=new An;let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("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(mo.setFromBufferAttribute(o),this.morphTargetsRelative)Zt.addVectors(Mn.min,mo.min),Mn.expandByPoint(Zt),Zt.addVectors(Mn.max,mo.max),Mn.expandByPoint(Zt);else Mn.expandByPoint(mo.min),Mn.expandByPoint(mo.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)ys.fromBufferAttribute(e,c),Zt.add(ys);i=Math.max(i,n.distanceToSquared(Zt))}}if(this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius))Be('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){Be("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let{position:n,normal:i,uv:r}=t,s=this.getAttribute("tangent");if(s===void 0||s.count!==n.count)s=new jt(new Float32Array(4*n.count),4),this.setAttribute("tangent",s);let o=[],a=[];for(let R=0;R<n.count;R++)o[R]=new U,a[R]=new U;let c=new U,l=new U,u=new U,d=new Fe,h=new Fe,f=new Fe,m=new U,_=new U;function p(R,x,M){c.fromBufferAttribute(n,R),l.fromBufferAttribute(n,x),u.fromBufferAttribute(n,M),d.fromBufferAttribute(r,R),h.fromBufferAttribute(r,x),f.fromBufferAttribute(r,M),l.sub(c),u.sub(c),h.sub(d),f.sub(d);let k=1/(h.x*f.y-f.x*h.y);if(!isFinite(k))return;m.copy(l).multiplyScalar(f.y).addScaledVector(u,-h.y).multiplyScalar(k),_.copy(u).multiplyScalar(h.x).addScaledVector(l,-f.x).multiplyScalar(k),o[R].add(m),o[x].add(m),o[M].add(m),a[R].add(_),a[x].add(_),a[M].add(_)}let g=this.groups;if(g.length===0)g=[{start:0,count:e.count}];for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:k,count:C}=M;for(let L=k,K=k+C;L<K;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let S=new U,T=new U,y=new U,w=new U;function A(R){y.fromBufferAttribute(i,R),w.copy(y);let x=o[R];S.copy(x),S.sub(y.multiplyScalar(y.dot(x))).normalize(),T.crossVectors(w,x);let k=T.dot(a[R])<0?-1:1;s.setXYZW(R,S.x,S.y,S.z,k)}for(let R=0,x=g.length;R<x;++R){let M=g[R],{start:k,count:C}=M;for(let L=k,K=k+C;L<K;L+=3)A(e.getX(L+0)),A(e.getX(L+1)),A(e.getX(L+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new jt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,h=n.count;d<h;d++)n.setXYZ(d,0,0,0);let i=new U,r=new U,s=new U,o=new U,a=new U,c=new U,l=new U,u=new U;if(e)for(let d=0,h=e.count;d<h;d+=3){let f=e.getX(d+0),m=e.getX(d+1),_=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,m),s.fromBufferAttribute(t,_),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),o.fromBufferAttribute(n,f),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,_),o.add(l),a.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z)}else for(let d=0,h=t.count;d<h;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),s.fromBufferAttribute(t,d+2),l.subVectors(s,r),u.subVectors(i,r),l.cross(u),n.setXYZ(d+0,l.x,l.y,l.z),n.setXYZ(d+1,l.x,l.y,l.z),n.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Zt.fromBufferAttribute(e,t),Zt.normalize(),e.setXYZ(t,Zt.x,Zt.y,Zt.z)}toNonIndexed(){function e(o,a){let{array:c,itemSize:l,normalized:u}=o,d=new c.constructor(a.length*l),h=0,f=0;for(let m=0,_=a.length;m<_;m++){if(o.isInterleavedBufferAttribute)h=a[m]*o.data.stride+o.offset;else h=a[m]*l;for(let p=0;p<l;p++)d[f++]=c[h++]}return new jt(d,l,u)}if(this.index===null)return Le("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new sn,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],c=e(a,n);t.setAttribute(o,c)}let r=this.morphAttributes;for(let o in r){let a=[],c=r[o];for(let l=0,u=c.length;l<u;l++){let d=c[l],h=e(d,n);a.push(h)}t.morphAttributes[o]=a}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,a=s.length;o<a;o++){let c=s[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0)e.userData=this.userData;if(this.parameters!==void 0&&this._transformed!==!0){let a=this.parameters;for(let c in a)if(a[c]!==void 0)e[c]=a[c];return e}e.data={attributes:{}};let t=this.index;if(t!==null)e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)};let n=this.attributes;for(let a in n){let c=n[a];e.data.attributes[a]=c.toJSON(e.data)}let i={},r=!1;for(let a in this.morphAttributes){let c=this.morphAttributes[a],l=[];for(let u=0,d=c.length;u<d;u++){let h=c[u];l.push(h.toJSON(e.data))}if(l.length>0)i[a]=l,r=!0}if(r)e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;if(s.length>0)e.data.groups=JSON.parse(JSON.stringify(s));let o=this.boundingSphere;if(o!==null)e.data.boundingSphere=o.toJSON();return e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;if(n!==null)this.setIndex(n.clone());let i=e.attributes;for(let c in i){let l=i[c];this.setAttribute(c,l.clone(t))}let r=e.morphAttributes;for(let c in r){let l=[],u=r[c];for(let d=0,h=u.length;d<h;d++)l.push(u[d].clone(t));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let c=0,l=s.length;c<l;c++){let u=s[c];this.addGroup(u.start,u.count,u.materialIndex)}let o=e.boundingBox;if(o!==null)this.boundingBox=o.clone();let a=e.boundingSphere;if(a!==null)this.boundingSphere=a.clone();return this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Lo{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=ei()}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=ei();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=ei();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 un=new U;class Fs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyMatrix4(e),this.setXYZ(t,un.x,un.y,un.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.applyNormalMatrix(e),this.setXYZ(t,un.x,un.y,un.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)un.fromBufferAttribute(this,t),un.transformDirection(e),this.setXYZ(t,un.x,un.y,un.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];if(this.normalized)n=Qn(n,this.array);return n}setComponent(e,t,n){if(this.normalized)n=ft(n,this.array);return this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){if(this.normalized)t=ft(t,this.array);return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];if(this.normalized)t=Qn(t,this.array);return t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];if(this.normalized)t=Qn(t,this.array);return t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];if(this.normalized)t=Qn(t,this.array);return t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];if(this.normalized)t=Qn(t,this.array);return t}setXY(e,t,n){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){if(e=e*this.data.stride+this.offset,this.normalized)t=ft(t,this.array),n=ft(n,this.array),i=ft(i,this.array),r=ft(r,this.array);return this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){So("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new jt(new this.array.constructor(t),this.itemSize,this.normalized)}else{if(e.interleavedBuffers===void 0)e.interleavedBuffers={};if(e.interleavedBuffers[this.data.uuid]===void 0)e.interleavedBuffers[this.data.uuid]=this.data.clone(e);return new Fs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}}toJSON(e){if(e===void 0){So("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 Jl=new U,SS=new U,MS=new Ge;class Vn{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=Jl.subVectors(n,t).cross(SS.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(Jl),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||MS.getNormalMatrix(e),i=this.coplanarPoint(Jl).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 wS=0;class yn extends ri{constructor(){super();this.isMaterial=!0,Object.defineProperty(this,"id",{value:wS++}),this.uuid=ei(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){if(this._alphaTest>0!==e>0)this.version++;this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e===void 0)return;for(let t in e){let n=e[t];if(n===void 0){Le(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(i===void 0){Le(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}if(i&&i.isColor)i.set(n);else if(i&&i.isVector2&&(n&&n.isVector2)||i&&i.isEuler&&(n&&n.isEuler)||i&&i.isVector3&&(n&&n.isVector3))i.copy(n);else this[t]=n}}toJSON(e){let t=e===void 0||typeof e==="string";if(t)e={textures:{},images:{}};let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor)n.color=this.color.getHex();if(this.roughness!==void 0)n.roughness=this.roughness;if(this.metalness!==void 0)n.metalness=this.metalness;if(this.sheen!==void 0)n.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)n.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)n.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)n.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0)n.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)n.specular=this.specular.getHex();if(this.specularIntensity!==void 0)n.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)n.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)n.shininess=this.shininess;if(this.clearcoat!==void 0)n.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)n.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid;if(this.dispersion!==void 0)n.dispersion=this.dispersion;if(this.retroreflectivity!==void 0)n.retroreflectivity=this.retroreflectivity;if(this.iridescence!==void 0)n.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)n.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)n.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid;if(this.anisotropy!==void 0)n.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)n.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid;if(this.map&&this.map.isTexture)n.map=this.map.toJSON(e).uuid;if(this.matcap&&this.matcap.isTexture)n.matcap=this.matcap.toJSON(e).uuid;if(this.alphaMap&&this.alphaMap.isTexture)n.alphaMap=this.alphaMap.toJSON(e).uuid;if(this.lightMap&&this.lightMap.isTexture)n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)n.roughnessMap=this.roughnessMap.toJSON(e).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)n.metalnessMap=this.metalnessMap.toJSON(e).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)n.emissiveMap=this.emissiveMap.toJSON(e).uuid;if(this.specularMap&&this.specularMap.isTexture)n.specularMap=this.specularMap.toJSON(e).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)n.specularColorMap=this.specularColorMap.toJSON(e).uuid;if(this.envMap&&this.envMap.isTexture){if(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0)n.combine=this.combine}if(this.envMapRotation!==void 0)n.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)n.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)n.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)n.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)n.gradientMap=this.gradientMap.toJSON(e).uuid;if(this.transmission!==void 0)n.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)n.transmissionMap=this.transmissionMap.toJSON(e).uuid;if(this.thickness!==void 0)n.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)n.thicknessMap=this.thicknessMap.toJSON(e).uuid;if(this.attenuationDistance!==void 0)n.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)n.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)n.size=this.size;if(this.sizeAttenuation!==void 0)n.sizeAttenuation=this.sizeAttenuation;if(Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0)n.clippingPlanes=this.clippingPlanes.map((r)=>r.toJSON());if(this.rotation!==void 0)n.rotation=this.rotation;if(this.depthPacking!==void 0)n.depthPacking=this.depthPacking;if(this.linewidth!==void 0)n.linewidth=this.linewidth;if(this.linecap!==void 0)n.linecap=this.linecap;if(this.linejoin!==void 0)n.linejoin=this.linejoin;if(this.dashSize!==void 0)n.dashSize=this.dashSize;if(this.gapSize!==void 0)n.gapSize=this.gapSize;if(this.scale!==void 0)n.scale=this.scale;if(this.wireframe!==void 0)n.wireframe=this.wireframe;if(this.wireframeLinewidth!==void 0)n.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!==void 0)n.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!==void 0)n.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading!==void 0)n.flatShading=this.flatShading;if(this.fog!==void 0)n.fog=this.fog;if(Object.keys(this.userData).length>0)n.userData=this.userData;function i(r){let s=[];for(let o in r){let a=r[o];delete a.metadata,s.push(a)}return s}if(t){let r=i(e.textures),s=i(e.images);if(r.length>0)n.textures=r;if(s.length>0)n.images=s}return n}fromJSON(e,t){if(e.uuid!==void 0)this.uuid=e.uuid;if(e.name!==void 0)this.name=e.name;if(e.color!==void 0&&this.color!==void 0)this.color.setHex(e.color);if(e.roughness!==void 0)this.roughness=e.roughness;if(e.metalness!==void 0)this.metalness=e.metalness;if(e.sheen!==void 0)this.sheen=e.sheen;if(e.sheenColor!==void 0)this.sheenColor=new ze().setHex(e.sheenColor);if(e.sheenRoughness!==void 0)this.sheenRoughness=e.sheenRoughness;if(e.emissive!==void 0&&this.emissive!==void 0)this.emissive.setHex(e.emissive);if(e.specular!==void 0&&this.specular!==void 0)this.specular.setHex(e.specular);if(e.specularIntensity!==void 0)this.specularIntensity=e.specularIntensity;if(e.specularColor!==void 0&&this.specularColor!==void 0)this.specularColor.setHex(e.specularColor);if(e.shininess!==void 0)this.shininess=e.shininess;if(e.clearcoat!==void 0)this.clearcoat=e.clearcoat;if(e.clearcoatRoughness!==void 0)this.clearcoatRoughness=e.clearcoatRoughness;if(e.dispersion!==void 0)this.dispersion=e.dispersion;if(e.retroreflectivity!==void 0)this.retroreflectivity=e.retroreflectivity;if(e.iridescence!==void 0)this.iridescence=e.iridescence;if(e.iridescenceIOR!==void 0)this.iridescenceIOR=e.iridescenceIOR;if(e.iridescenceThicknessRange!==void 0)this.iridescenceThicknessRange=e.iridescenceThicknessRange;if(e.transmission!==void 0)this.transmission=e.transmission;if(e.thickness!==void 0)this.thickness=e.thickness;if(e.attenuationDistance!==void 0)this.attenuationDistance=e.attenuationDistance;if(e.attenuationColor!==void 0&&this.attenuationColor!==void 0)this.attenuationColor.setHex(e.attenuationColor);if(e.anisotropy!==void 0)this.anisotropy=e.anisotropy;if(e.anisotropyRotation!==void 0)this.anisotropyRotation=e.anisotropyRotation;if(e.fog!==void 0)this.fog=e.fog;if(e.flatShading!==void 0)this.flatShading=e.flatShading;if(e.blending!==void 0)this.blending=e.blending;if(e.combine!==void 0)this.combine=e.combine;if(e.side!==void 0)this.side=e.side;if(e.shadowSide!==void 0)this.shadowSide=e.shadowSide;if(e.opacity!==void 0)this.opacity=e.opacity;if(e.transparent!==void 0)this.transparent=e.transparent;if(e.alphaTest!==void 0)this.alphaTest=e.alphaTest;if(e.alphaHash!==void 0)this.alphaHash=e.alphaHash;if(e.depthFunc!==void 0)this.depthFunc=e.depthFunc;if(e.depthTest!==void 0)this.depthTest=e.depthTest;if(e.depthWrite!==void 0)this.depthWrite=e.depthWrite;if(e.colorWrite!==void 0)this.colorWrite=e.colorWrite;if(e.clippingPlanes!==void 0)this.clippingPlanes=e.clippingPlanes.map((n)=>new Vn().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 Fe().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 Fe().fromArray(e.clearcoatNormalScale);if(e.iridescenceMap!==void 0)this.iridescenceMap=t[e.iridescenceMap]||null;if(e.iridescenceThicknessMap!==void 0)this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null;if(e.transmissionMap!==void 0)this.transmissionMap=t[e.transmissionMap]||null;if(e.thicknessMap!==void 0)this.thicknessMap=t[e.thicknessMap]||null;if(e.anisotropyMap!==void 0)this.anisotropyMap=t[e.anisotropyMap]||null;if(e.sheenColorMap!==void 0)this.sheenColorMap=t[e.sheenColorMap]||null;if(e.sheenRoughnessMap!==void 0)this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null;return this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){if(e===!0)this.version++}}var Bi=new U,Kl=new U,ka=new U,za=new U;class xr{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Bi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);if(n<0)return t.copy(this.origin);return t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Bi.subVectors(e,this.origin).dot(this.direction);if(t<0)return this.origin.distanceToSquared(e);return Bi.copy(this.origin).addScaledVector(this.direction,t),Bi.distanceToSquared(e)}distanceSqToSegment(e,t,n,i){Kl.copy(e).add(t).multiplyScalar(0.5),ka.copy(t).sub(e).normalize(),za.copy(this.origin).sub(Kl);let r=e.distanceTo(t)*0.5,s=-this.direction.dot(ka),o=za.dot(this.direction),a=-za.dot(ka),c=za.lengthSq(),l=Math.abs(1-s*s),u,d,h,f;if(l>0)if(u=s*a-o,d=s*o-a,f=r*l,u>=0)if(d>=-f)if(d<=f){let m=1/l;u*=m,d*=m,h=u*(u+s*d+2*o)+d*(s*u+d+2*a)+c}else d=r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else d=-r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;else if(d<=-f)u=Math.max(0,-(-s*r+o)),d=u>0?-r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else if(d<=f)u=0,d=Math.min(Math.max(-r,-a),r),h=d*(d+2*a)+c;else u=Math.max(0,-(s*r+o)),d=u>0?r:Math.min(Math.max(-r,-a),r),h=-u*u+d*(d+2*a)+c;else d=s>0?-r:r,u=Math.max(0,-(s*d+o)),h=-u*u+d*(d+2*a)+c;if(n)n.copy(this.origin).addScaledVector(this.direction,u);if(i)i.copy(Kl).addScaledVector(ka,d);return h}intersectSphere(e,t){if(e.radius<0)return null;Bi.subVectors(e.center,this.origin);let n=Bi.dot(this.direction),i=Bi.dot(Bi)-n*n,r=e.radius*e.radius;if(i>r)return null;let s=Math.sqrt(r-i),o=n-s,a=n+s;if(a<0)return null;if(o<0)return this.at(a,t);return this.at(o,t)}intersectsSphere(e){if(e.radius<0)return!1;return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0){if(e.distanceToPoint(this.origin)===0)return 0;return null}let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);if(n===null)return null;return this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;if(e.normal.dot(this.direction)*t<0)return!0;return!1}intersectBox(e,t){let n,i,r,s,o,a,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;if(c>=0)n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c;else n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c;if(l>=0)r=(e.min.y-d.y)*l,s=(e.max.y-d.y)*l;else r=(e.max.y-d.y)*l,s=(e.min.y-d.y)*l;if(n>s||r>i)return null;if(r>n||isNaN(n))n=r;if(s<i||isNaN(i))i=s;if(u>=0)o=(e.min.z-d.z)*u,a=(e.max.z-d.z)*u;else o=(e.max.z-d.z)*u,a=(e.min.z-d.z)*u;if(n>a||o>i)return null;if(o>n||n!==n)n=o;if(a<i||i!==i)i=a;if(i<0)return null;return this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Bi)!==null}intersectTriangle(e,t,n,i,r){let s=this.origin,o=this.direction,{x:a,y:c,z:l}=o,u=e.x-s.x,d=e.y-s.y,h=e.z-s.z,f=t.x-s.x,m=t.y-s.y,_=t.z-s.z,p=n.x-s.x,g=n.y-s.y,S=n.z-s.z,T=Math.abs(a),y=Math.abs(c),w=Math.abs(l),A,R,x,M,k,C,L,K,I,G,X,P;if(T>=y&&T>=w)if(x=a,C=u,I=f,P=p,a>=0)A=c,R=l,M=d,k=h,L=m,K=_,G=g,X=S;else A=l,R=c,M=h,k=d,L=_,K=m,G=S,X=g;else if(y>=w)if(x=c,C=d,I=m,P=g,c>=0)A=l,R=a,M=h,k=u,L=_,K=f,G=S,X=p;else A=a,R=l,M=u,k=h,L=f,K=_,G=p,X=S;else if(x=l,C=h,I=_,P=S,l>=0)A=a,R=c,M=u,k=d,L=f,K=m,G=p,X=g;else A=c,R=a,M=d,k=u,L=m,K=f,G=g,X=p;if(x===0)return null;let j=A/x,z=R/x,q=1/x,Q=M-j*C,Me=k-z*C,ue=L-j*I,Ve=K-z*I,we=G-j*P,Z=X-z*P,re=we*Ve-Z*ue,se=Q*Z-Me*we,ye=ue*Me-Ve*Q;if(i){if(re<0||se<0||ye<0)return null}else if((re<0||se<0||ye<0)&&(re>0||se>0||ye>0))return null;let Ee=re+se+ye;if(Ee===0)return null;let Ae=q*(re*C+se*I+ye*P);if(Ee>0?Ae<0:Ae>0)return null;return this.at(Ae/Ee,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class xi extends yn{constructor(e){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,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 qf=new We,Ur=new xr,Ba=new An,Yf=new U,Va=new U,Ga=new U,Ha=new U,Ql=new U,$a=new U,Jf=new U,Wa=new U;class wt extends _t{constructor(e=new sn,t=new xi){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){$a.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(Ql.fromBufferAttribute(u,e),s)$a.addScaledVector(Ql,l);else $a.addScaledVector(Ql.sub(t),l)}t.add($a)}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),Ur.copy(e.ray).recast(e.near),Ba.containsPoint(Ur.origin)===!1){if(Ur.intersectSphere(Ba,Yf)===null)return;if(Ur.origin.distanceToSquared(Yf)>(e.far-e.near)**2)return}if(qf.copy(r).invert(),Ur.copy(e.ray).applyMatrix4(qf),n.boundingBox!==null){if(Ur.intersectsBox(n.boundingBox)===!1)return}this._computeIntersections(e,t,Ur)}_computeIntersections(e,t,n){let i,r=this.geometry,s=this.material,o=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,{groups:d,drawRange:h}=r;if(o!==null)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(o.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=o.getX(T),A=o.getX(T+1),R=o.getX(T+2);if(i=Za(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(o.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);if(i=Za(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}else if(a!==void 0)if(Array.isArray(s))for(let f=0,m=d.length;f<m;f++){let _=d[f],p=s[_.materialIndex],g=Math.max(_.start,h.start),S=Math.min(a.count,Math.min(_.start+_.count,h.start+h.count));for(let T=g,y=S;T<y;T+=3){let w=T,A=T+1,R=T+2;if(i=Za(this,p,e,n,c,l,u,w,A,R),i)i.faceIndex=Math.floor(T/3),i.face.materialIndex=_.materialIndex,t.push(i)}}else{let f=Math.max(0,h.start),m=Math.min(a.count,h.start+h.count);for(let _=f,p=m;_<p;_+=3){let g=_,S=_+1,T=_+2;if(i=Za(this,s,e,n,c,l,u,g,S,T),i)i.faceIndex=Math.floor(_/3),t.push(i)}}}}function ES(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;Wa.copy(a),Wa.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Wa);if(l<n.near||l>n.far)return null;return{distance:l,point:Wa.clone(),object:e}}function Za(e,t,n,i,r,s,o,a,c,l){e.getVertexPosition(a,Va),e.getVertexPosition(c,Ga),e.getVertexPosition(l,Ha);let u=ES(e,t,n,i,Va,Ga,Ha,Jf);if(u){let d=new U;if(Gn.getBarycoord(Jf,Va,Ga,Ha,d),r)u.uv=Gn.getInterpolatedAttribute(r,a,c,l,d,new Fe);if(s)u.uv1=Gn.getInterpolatedAttribute(s,a,c,l,d,new Fe);if(o){if(u.normal=Gn.getInterpolatedAttribute(o,a,c,l,d,new U),u.normal.dot(i.direction)>0)u.normal.multiplyScalar(-1)}let h={a,b:c,c:l,normal:new U,materialIndex:0};Gn.getNormal(Va,Ga,Ha,h.normal),u.face=h,u.barycoord=d}return u}var go=new pt,Kf=new pt,Qf=new pt,AS=new pt,ep=new We,Xa=new U,eu=new An,tp=new We,tu=new xr;class Sc extends wt{constructor(e,t){super(e,t);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new We,this.bindMatrixInverse=new We,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;if(this.boundingBox===null)this.boundingBox=new Gt;this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Xa),this.boundingBox.expandByPoint(Xa)}computeBoundingSphere(){let e=this.geometry;if(this.boundingSphere===null)this.boundingSphere=new An;this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Xa),this.boundingSphere.expandByPoint(Xa)}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(eu.copy(this.boundingSphere),eu.applyMatrix4(i),e.ray.intersectsSphere(eu)===!1)return;if(tp.copy(i).invert(),tu.copy(e.ray).applyMatrix4(tp),this.boundingBox!==null){if(tu.intersectsBox(this.boundingBox)===!1)return}this._computeIntersections(e,t,tu)}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){if(this.skeleton=e,t===void 0)this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld;this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new pt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();if(r!==1/0)e.multiplyScalar(r);else e.set(1,0,0,0);t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.bindMode==="attached")this.bindMatrixInverse.copy(this.matrixWorld).invert();else if(this.bindMode==="detached")this.bindMatrixInverse.copy(this.bindMatrix).invert();else Le("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;if(Kf.fromBufferAttribute(i.attributes.skinIndex,e),Qf.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4)go.copy(t),t.set(0,0,0,0);else go.set(...t,1),t.set(0,0,0);go.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){let s=Qf.getComponent(r);if(s!==0){let o=Kf.getComponent(r);ep.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(AS.copy(go).applyMatrix4(ep),s)}}if(t.isVector4)t.w=go.w;return t.applyMatrix4(this.bindMatrixInverse)}}class No extends _t{constructor(){super();this.isBone=!0,this.type="Bone"}}class Do extends Nt{constructor(e=null,t=1,n=1,i,r,s,o,a,c=1003,l=1003,u,d){super(null,s,o,a,c,l,i,r,u,d);this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}var np=new We,TS=new We;class Oo{constructor(e=[],t=[]){this.uuid=ei(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Le("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new We)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new We;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:TS;np.multiplyMatrices(o,t[r]),np.toArray(n,r*16)}if(i!==null)i.needsUpdate=!0}clone(){return new Oo(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 Do(t,e,e,1023,1015);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}return}dispose(){if(this.boneTexture!==null)this.boneTexture.dispose(),this.boneTexture=null}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],s=t[r];if(s===void 0)Le("Skeleton: No bone found with UUID:",r),s=new No;this.bones.push(s),this.boneInverses.push(new We().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 dr extends jt{constructor(e,t,n,i=1){super(e,t,n);this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}var vs=new We,ip=new We,ja=[],rp=new Gt,RS=new We,_o=new wt,xo=new An;class ks extends wt{constructor(e,t,n){super(e,t);this.isInstancedMesh=!0,this.instanceMatrix=new dr(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,RS)}computeBoundingBox(){let e=this.geometry,t=this.count;if(this.boundingBox===null)this.boundingBox=new Gt;if(e.boundingBox===null)e.computeBoundingBox();this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,vs),rp.copy(e.boundingBox).applyMatrix4(vs),this.boundingBox.union(rp)}computeBoundingSphere(){let e=this.geometry,t=this.count;if(this.boundingSphere===null)this.boundingSphere=new An;if(e.boundingSphere===null)e.computeBoundingSphere();this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,vs),xo.copy(e.boundingSphere).applyMatrix4(vs),this.boundingSphere.union(xo)}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(_o.geometry=this.geometry,_o.material=this.material,_o.material===void 0)return;if(this.boundingSphere===null)this.computeBoundingSphere();if(xo.copy(this.boundingSphere),xo.applyMatrix4(n),e.ray.intersectsSphere(xo)===!1)return;for(let r=0;r<i;r++){this.getMatrixAt(r,vs),ip.multiplyMatrices(n,vs),_o.matrixWorld=ip,_o.raycast(e,ja);for(let s=0,o=ja.length;s<o;s++){let a=ja[s];a.instanceId=r,a.object=this,t.push(a)}ja.length=0}}setColorAt(e,t){if(this.instanceColor===null)this.instanceColor=new dr(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 Do(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 An,CS=new Fe(0.5,0.5),qa=new U;class Uo{constructor(e=new Vn,t=new Vn,n=new Vn,i=new Vn,r=new Vn,s=new Vn){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2000,n=!1){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],m=r[9],_=r[10],p=r[11],g=r[12],S=r[13],T=r[14],y=r[15];if(i[0].setComponents(c-s,h-l,p-f,y-g).normalize(),i[1].setComponents(c+s,h+l,p+f,y+g).normalize(),i[2].setComponents(c+o,h+u,p+m,y+S).normalize(),i[3].setComponents(c-o,h-u,p-m,y-S).normalize(),n)i[4].setComponents(a,d,_,T).normalize(),i[5].setComponents(c-a,h-d,p-_,y-T).normalize();else if(i[4].setComponents(c-a,h-d,p-_,y-T).normalize(),t===2000)i[5].setComponents(c+a,h+d,p+_,y+T).normalize();else if(t===2001)i[5].setComponents(a,d,_,T).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0){if(e.boundingSphere===null)e.computeBoundingSphere();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=CS.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(qa.x=i.normal.x>0?e.max.x:e.min.x,qa.y=i.normal.y>0?e.max.y:e.min.y,qa.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(qa)<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 yn{constructor(e){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}var ic=new U,rc=new U,sp=new We,yo=new xr,Ya=new An,nu=new U,op=new U;class yr extends _t{constructor(e=new sn,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++)ic.fromBufferAttribute(t,i-1),rc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=ic.distanceTo(rc);e.setAttribute("lineDistance",new xn(n,1))}else Le("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,s=n.drawRange;if(n.boundingSphere===null)n.computeBoundingSphere();if(Ya.copy(n.boundingSphere),Ya.applyMatrix4(i),Ya.radius+=r,e.ray.intersectsSphere(Ya)===!1)return;sp.copy(i).invert(),yo.copy(e.ray).applyMatrix4(sp);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=this.isLineSegments?2:1,l=n.index,d=n.attributes.position;if(l!==null){let h=Math.max(0,s.start),f=Math.min(l.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=l.getX(m),g=l.getX(m+1),S=Ja(this,e,yo,a,p,g,m);if(S)t.push(S)}if(this.isLineLoop){let m=l.getX(f-1),_=l.getX(h),p=Ja(this,e,yo,a,m,_,f-1);if(p)t.push(p)}}else{let h=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=h,_=f-1;m<_;m+=c){let p=Ja(this,e,yo,a,m,m+1,m);if(p)t.push(p)}if(this.isLineLoop){let m=Ja(this,e,yo,a,f-1,h,f-1);if(m)t.push(m)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Ja(e,t,n,i,r,s,o){let a=e.geometry.attributes.position;if(ic.fromBufferAttribute(a,r),rc.fromBufferAttribute(a,s),n.distanceSqToSegment(ic,rc,nu,op)>i)return;nu.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(nu);if(l<t.near||l>t.far)return;return{distance:l,point:op.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var ap=new U,cp=new U;class Mc extends yr{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)ap.fromBufferAttribute(t,i),cp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ap.distanceTo(cp);e.setAttribute("lineDistance",new xn(n,1))}else Le("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wc extends yr{constructor(e,t){super(e,t);this.isLineLoop=!0,this.type="LineLoop"}}class ko extends yn{constructor(e){super();this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ze(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var lp=new We,su=new xr,Ka=new An,Qa=new U;class zs extends _t{constructor(e=new sn,t=new ko){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(Ka.copy(n.boundingSphere),Ka.applyMatrix4(i),Ka.radius+=r,e.ray.intersectsSphere(Ka)===!1)return;lp.copy(i).invert(),su.copy(e.ray).applyMatrix4(lp);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,c=n.index,u=n.attributes.position;if(c!==null){let d=Math.max(0,s.start),h=Math.min(c.count,s.start+s.count);for(let f=d,m=h;f<m;f++){let _=c.getX(f);Qa.fromBufferAttribute(u,_),up(Qa,_,a,i,e,t,this)}}else{let d=Math.max(0,s.start),h=Math.min(u.count,s.start+s.count);for(let f=d,m=h;f<m;f++)Qa.fromBufferAttribute(u,f),up(Qa,f,a,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function up(e,t,n,i,r,s,o){let a=su.distanceSqToPoint(e);if(a<n){let c=new U;su.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 Ec extends Nt{constructor(e=[],t=301,n,i,r,s,o,a,c,l){super(e,t,n,i,r,s,o,a,c,l);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Zr extends Nt{constructor(e,t,n=1014,i,r,s,o=1003,a=1003,c,l=1026,u=1){if(l!==1026&&l!==1027)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,i,r,s,o,a,l,n,c);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Po(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}}class lh extends Zr{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 Ac extends Nt{constructor(e=null){super();this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class vr extends sn{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super();this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};let o=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);let a=[],c=[],l=[],u=[],d=0,h=0;f("z","y","x",-1,-1,n,t,e,s,r,0),f("z","y","x",1,-1,n,t,-e,s,r,1),f("x","z","y",1,1,e,n,t,i,s,2),f("x","z","y",1,-1,e,n,-t,i,s,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(a),this.setAttribute("position",new xn(c,3)),this.setAttribute("normal",new xn(l,3)),this.setAttribute("uv",new xn(u,2));function f(m,_,p,g,S,T,y,w,A,R,x){let M=T/A,k=y/R,C=T/2,L=y/2,K=w/2,I=A+1,G=R+1,X=0,P=0,j=new U;for(let z=0;z<G;z++){let q=z*k-L;for(let Q=0;Q<I;Q++){let Me=Q*M-C;j[m]=Me*g,j[_]=q*S,j[p]=K,c.push(j.x,j.y,j.z),j[m]=0,j[_]=0,j[p]=w>0?1:-1,l.push(j.x,j.y,j.z),u.push(Q/A),u.push(1-z/R),X+=1}}for(let z=0;z<R;z++)for(let q=0;q<A;q++){let Q=d+q+I*z,Me=d+q+I*(z+1),ue=d+(q+1)+I*(z+1),Ve=d+(q+1)+I*z;a.push(Q,Me,Ve),a.push(Me,ue,Ve),P+=6}o.addGroup(h,P,x),h+=P,d+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class zo extends sn{constructor(e=1,t=1,n=1,i=1){super();this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,s=t/2,o=Math.floor(n),a=Math.floor(i),c=o+1,l=a+1,u=e/o,d=t/a,h=[],f=[],m=[],_=[];for(let p=0;p<l;p++){let g=p*d-s;for(let S=0;S<c;S++){let T=S*u-r;f.push(T,-g,0),m.push(0,0,1),_.push(S/o),_.push(1-p/a)}}for(let p=0;p<a;p++)for(let g=0;g<o;g++){let S=g+c*p,T=g+c*(p+1),y=g+1+c*(p+1),w=g+1+c*p;h.push(S,T,w),h.push(T,y,w)}this.setIndex(h),this.setAttribute("position",new xn(f,3)),this.setAttribute("normal",new xn(m,3)),this.setAttribute("uv",new xn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zo(e.width,e.height,e.widthSegments,e.heightSegments)}}function Xr(e){let t={};for(let n in e){t[n]={};for(let i in e[n]){let r=e[n][i];if(hp(r))if(r.isRenderTargetTexture)Le("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null;else t[n][i]=r.clone();else if(Array.isArray(r))if(hp(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 on(e){let t={};for(let n=0;n<e.length;n++){let i=Xr(e[n]);for(let r in i)t[r]=i[r]}return t}function hp(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function PS(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function uh(e){let t=e.getRenderTarget();if(t===null)return e.outputColorSpace;if(t.isXRRenderTarget===!0)return t.texture.colorSpace;return qe.workingColorSpace}var xm={clone:Xr,merge:on},IS=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,SS=`void main() {
+}`,LS=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;class Bn extends xn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=bS,this.fragmentShader=SS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0)this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Gr(e.uniforms),this.uniformsGroups=vS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ue().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ve().fromArray(i.value);break;case"m4":this.uniforms[n].value=new $e().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0)this.defines=e.defines;if(e.vertexShader!==void 0)this.vertexShader=e.vertexShader;if(e.fragmentShader!==void 0)this.fragmentShader=e.fragmentShader;if(e.glslVersion!==void 0)this.glslVersion=e.glslVersion;if(e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];if(e.lights!==void 0)this.lights=e.lights;if(e.clipping!==void 0)this.clipping=e.clipping;return this}}class ih extends Bn{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Hi extends xn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class En extends Hi{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ze(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class vc extends xn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hi,this.combine=0,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class rh extends xn{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 sh extends xn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function or(e,t){if(!e||e.constructor===t)return e;if(typeof t.BYTES_PER_ELEMENT==="number")return new t(e);return Array.prototype.slice.call(e)}function qa(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function MS(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 rp(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 wS(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class $i{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class oh extends $i{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-d*_+2*d*m-d*f,g=(1+d)*_+(-1.5-2*d)*m+(-0.5+d)*f+1,S=(-1-h)*_+(1.5+h)*m+0.5*f,T=h*_-h*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class bc extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==o;++d)r[d]=s[c+d]*u+s[a+d]*l;return r}}class ah extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class ch extends $i{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let d=o*2,h=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=h*d+f*2,g=u[p],S=u[p+1],T=e*d+f*2,y=l[T],w=l[T+1],A=AS(n,t,g,y,i);r[f]=hm(A,m,S,w,_)}return r}}function hm(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 ES(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 AS(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=hm(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=ES(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 An{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=or(t,this.TimeBufferType),this.values=or(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:or(e.times,Array),values:or(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(qa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Array),outTangents:or(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ah(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new bc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new oh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new ch(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Le("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(qa(this.settings))sp(this.settings.inTangents,e),sp(this.settings.outTangents,e)}return this}trim(e,t){let n=this.times,i=n.length,r=0,s=i-1;while(r!==i&&n[r]<e)++r;while(s!==-1&&n[s]>t)--s;if(++s,r!==0||s!==i){if(r>=s)s=Math.max(s,1),r=s-1;let o=this.getValueSize();this.times=n.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();if(t-Math.floor(t)!==0)ke("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)ke("KeyframeTrack: Track is empty.",this),e=!1;let s=null;for(let o=0;o!==r;o++){let a=n[o];if(typeof a==="number"&&isNaN(a)){ke("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){ke("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Ub(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){ke("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,d=u-n,h=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[d+f]||m!==t[h+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,d=s*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,qa(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function sp(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}An.prototype.ValueTypeName="";An.prototype.TimeBufferType=Float32Array;An.prototype.ValueBufferType=Float32Array;An.prototype.DefaultInterpolation=2301;class gr extends An{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="bool";gr.prototype.ValueBufferType=Array;gr.prototype.DefaultInterpolation=2300;gr.prototype.InterpolantFactoryMethodLinear=void 0;gr.prototype.InterpolantFactoryMethodSmooth=void 0;class Sc extends An{constructor(e,t,n,i){super(e,t,n,i)}}Sc.prototype.ValueTypeName="color";class _r extends An{constructor(e,t,n,i){super(e,t,n,i)}}_r.prototype.ValueTypeName="number";class lh extends $i{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class xr extends An{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new lh(this.times,this.values,this.getValueSize(),e)}}xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;class yr extends An{constructor(e,t,n){super(e,t,n)}}yr.prototype.ValueTypeName="string";yr.prototype.ValueBufferType=Array;yr.prototype.DefaultInterpolation=2300;yr.prototype.InterpolantFactoryMethodLinear=void 0;yr.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends An{constructor(e,t,n,i){super(e,t,n,i)}}Hr.prototype.ValueTypeName="vector";class Ss{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Yn(),this.userData={},this.duration<0)this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let s=0,o=n.length;s!==o;++s)t.push(RS(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(An.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=MS(a);if(a=rp(a,1,l),c=rp(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new _r(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function TS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return Sc;case"quaternion":return xr;case"bool":case"boolean":return gr;case"string":return yr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RS(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=TS(e.type);if(e.times===void 0){let i=[],r=[];wS(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(qa(e.settings))n.settings={inTangents:or(e.settings.inTangents,Float32Array),outTangents:or(e.settings.outTangents,Float32Array)};return n}var ui={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(op(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(op(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function op(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Do{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let h=c[u],f=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var dm=new Do;class Wi{constructor(e){if(this.manager=e!==void 0?e:dm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Bi={};class fm extends Error{constructor(e,t){super(e);this.response=t}}class Oo extends Wi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=ui.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Bi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,f=h!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:h});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new fm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then((f)=>h.decode(f))}}}).then((c)=>{ui.add(`file:${e}`,c);let l=Bi[e];delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Bi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var gs=new WeakMap;class uh extends Wi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);else{let u=gs.get(s);if(u===void 0)u=[],gs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=vs("img");function a(){if(l(),t)t(this);let u=gs.get(this)||[];for(let d=0;d<u.length;d++){let h=u[d];if(h.onLoad)h.onLoad(this)}gs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);ui.remove(`image:${e}`);let d=gs.get(this)||[];for(let h=0;h<d.length;h++){let f=d[h];if(f.onError)f.onError(u)}gs.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function l(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1)}if(o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"){if(this.crossOrigin!==void 0)o.crossOrigin=this.crossOrigin}return ui.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Os extends Wi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new uh(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Us extends gt{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Mc extends Us{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var ql=new $e,ap=new U,cp=new U;class Uo{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Po,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;ap.setFromMatrixPosition(e.matrixWorld),t.position.copy(ap),cp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cp),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){ql.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(ql,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(ql)}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 Xa=new U,ja=new Xt,ci=new U;class wc extends gt{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=2000,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.matrixWorld.decompose(Xa,ja,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Xa,ja,ci.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Xa,ja,ci),ci.x===1&&ci.y===1&&ci.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(Xa,ja,ci.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var sr=new U,lp=new Ue,up=new Ue;class Vt extends wc{constructor(e=50,t=1,n=0.1,i=2000){super();this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=0.5*this.getFilmHeight()/e;this.fov=Dr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(po*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return Dr*2*Math.atan(Math.tan(po*0.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){sr.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(sr.x,sr.y).multiplyScalar(-e/sr.z),sr.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(sr.x,sr.y).multiplyScalar(-e/sr.z)}getViewSize(e,t){return this.getViewBounds(e,lp,up),t.subVectors(up,lp)}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(po*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 pm extends Uo{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=Dr*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;if(n!==t.fov||i!==t.aspect||r!==t.far)t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix();super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this.aspect=e.aspect,this}toJSON(){let e=super.toJSON();return e.focus=this.focus,e.aspect=this.aspect,e}}class Ec extends Us{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new pm}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 mm extends Uo{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Fs extends Us{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new mm}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 wc{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 gm extends Uo{constructor(){super(new $r(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class zs extends Us{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new gm}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class vr{static extractUrlBase(e){let t=e.lastIndexOf("/");if(t===-1)return"./";return e.slice(0,t+1)}static resolveURL(e,t){if(typeof e!=="string"||e==="")return"";if(/^https?:\/\//i.test(t)&&/^\//.test(e))t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1");if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;if(/^blob:.*$/i.test(e))return e;return t+e}}var Yl=new WeakMap;class Ac extends Wi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=ui.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(Yl.has(s)===!0){if(i)i(Yl.get(s));r.manager.itemError(e),r.manager.itemEnd(e)}else{if(t)t(c);r.manager.itemEnd(e)}});return}setTimeout(function(){if(t)t(s);r.manager.itemEnd(e)},0);return}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let a=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){if(ui.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);Yl.set(a,c),ui.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});ui.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var _s=-90,xs=1;class hh extends gt{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(_s,xs,e,t);i.layers=this.layers,this.add(i);let r=new Vt(_s,xs,e,t);r.layers=this.layers,this.add(r);let s=new Vt(_s,xs,e,t);s.layers=this.layers,this.add(s);let o=new Vt(_s,xs,e,t);o.layers=this.layers,this.add(o);let a=new Vt(_s,xs,e,t);a.layers=this.layers,this.add(a);let c=new Vt(_s,xs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,h),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class dh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class fh{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var ph="\\[\\]\\.:\\/",CS=new RegExp("["+ph+"]","g"),mh="[^"+ph+"]",PS="[^"+ph.replace("\\.","")+"]",IS=/((?:WC+[\/:])*)/.source.replace("WC",mh),LS=/(WCOD+)?/.source.replace("WCOD",PS),NS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",mh),DS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",mh),OS=new RegExp("^"+IS+LS+NS+DS+"$"),US=["material","materials","bones","map"];class _m{constructor(e,t,n){let i=n||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(CS,"")}static parseTrackName(e){let t=OS.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(US.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let l=0;l<e.length;l++)if(e[l].name===c){c=l;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let s=e[i];if(s===void 0){let c=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;if(this.targetObject=e,e.isMaterial===!0)o=this.Versioning.NeedsUpdate;else if(e.isObject3D===!0)o=this.Versioning.MatrixWorldNeedsUpdate;let a=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=_m;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gh{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 FS=new Float32Array(1);class Tc extends ei{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let d=i[u],h=d.name,f=l[h];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,h);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new fh(ot.create(n,h,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,h),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new bc(new Float32Array(2),new Float32Array(2),1,FS),n.__cacheIndex=t,e[t]=n;return n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,s=typeof e==="string"?Ss.findByName(i,e):e,o=s!==null?s.uuid:e,a=this._actionsByClip[o],c=null;if(n===void 0)if(s!==null)n=s.blendMode;else n=2500;if(a!==void 0){let u=a.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;if(c=a.knownActions[0],s===null)s=c._clip}if(s===null)return null;let l=new gh(this,s,t,n);return this._bindAction(l,c),this._addInactiveAction(l,o,r),l}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e==="string"?Ss.findByName(n,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];if(o!==void 0)return o.actionByRoot[i]||null;return null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,s);let o=this._bindings,a=this._nActiveBindings;for(let c=0;c!==a;++c)o[c].apply(s);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let s=r.knownActions;for(let o=0,a=s.length;o!==a;++o){let c=s[o];this._deactivateAction(c);let l=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,t[l]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let s in n){let o=n[s].actionByRoot,a=o[t];if(a!==void 0)this._deactivateAction(a),this._removeInactiveAction(a)}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let s in r){let o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){let n=this.existingAction(e,t);if(n!==null)this._deactivateAction(n),this._removeInactiveAction(n)}}class Fo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=qe(this.phi,0.000001,Math.PI-0.000001),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){if(this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0)this.theta=0,this.phi=0;else this.theta=Math.atan2(e,n),this.phi=Math.acos(qe(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class _h{static{_h.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 Rc extends ei{constructor(e,t=null){super();this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(this.domElement!==null)this.disconnect();this.domElement=e}disconnect(){}dispose(){}update(){}}function xh(e,t,n,i){let r=zS(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 zS(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function km(){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 kS(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,d=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,a),d.length===0)e.bufferSubData(l,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],_=d[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++h,d[h]=_}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let _=d[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var BS=`#ifdef USE_ALPHAHASH
+}`;class $n extends yn{constructor(e){super();if(this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=IS,this.fragmentShader=LS,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=Xr(e.uniforms),this.uniformsGroups=PS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let s=this.uniforms[i].value;if(s&&s.isTexture)t.uniforms[i]={type:"t",value:s.toJSON(e).uuid};else if(s&&s.isColor)t.uniforms[i]={type:"c",value:s.getHex()};else if(s&&s.isVector2)t.uniforms[i]={type:"v2",value:s.toArray()};else if(s&&s.isVector3)t.uniforms[i]={type:"v3",value:s.toArray()};else if(s&&s.isVector4)t.uniforms[i]={type:"v4",value:s.toArray()};else if(s&&s.isMatrix3)t.uniforms[i]={type:"m3",value:s.toArray()};else if(s&&s.isMatrix4)t.uniforms[i]={type:"m4",value:s.toArray()};else t.uniforms[i]={value:s}}if(Object.keys(this.defines).length>0)t.defines=this.defines;t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)if(this.extensions[i]===!0)n[i]=!0;if(Object.keys(n).length>0)t.extensions=n;return t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(i.value);break;case"v2":this.uniforms[n].value=new Fe().fromArray(i.value);break;case"v3":this.uniforms[n].value=new U().fromArray(i.value);break;case"v4":this.uniforms[n].value=new pt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Ge().fromArray(i.value);break;case"m4":this.uniforms[n].value=new We().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 hh extends $n{constructor(e){super(e);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends yn{constructor(e){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ze(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Fe(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 fi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Tn extends $i{constructor(e){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Fe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ye(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+0.4*t)/(1-0.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ze(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ze(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ze(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){if(this._anisotropy>0!==e>0)this.version++;this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){if(this._clearcoat>0!==e>0)this.version++;this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){if(this._iridescence>0!==e>0)this.version++;this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){if(this._dispersion>0!==e>0)this.version++;this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){if(this._retroreflectivity>0!==e>0)this.version++;this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){if(this._sheen>0!==e>0)this.version++;this._sheen=e}get transmission(){return this._transmission}set transmission(e){if(this._transmission>0!==e>0)this.version++;this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Tc extends yn{constructor(e){super();this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,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 dh extends yn{constructor(e){super();this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class fh extends yn{constructor(e){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function hr(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 nc(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function NS(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 dp(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 DS(e,t,n,i){let r=1,s=e[0];while(s!==void 0&&s[i]===void 0)s=e[r++];if(s===void 0)return;let o=s[i];if(o===void 0)return;if(Array.isArray(o))do{if(o=s[i],o!==void 0)t.push(s.time),n.push(...o);s=e[r++]}while(s!==void 0);else if(o.toArray!==void 0)do{if(o=s[i],o!==void 0)t.push(s.time),o.toArray(n,n.length);s=e[r++]}while(s!==void 0);else do{if(o=s[i],o!==void 0)t.push(s.time),n.push(o);s=e[r++]}while(s!==void 0)}class Wi{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let s;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break t}s=t.length;break n}if(!(e>=r)){let o=t[1];if(e<o)n=2,r=o;for(let a=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=r,r=t[--n-1],e>=r)break t}s=n,n=0;break n}break e}while(n<s){let o=n+s>>>1;if(e<t[o])s=o;else n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let s=0;s!==i;++s)t[s]=n[r+s];return t}interpolate_(){throw Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class ph extends Wi{constructor(e,t,n,i){super(e,t,n,i);this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:2400,endingEnd:2400}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,s=e+1,o=i[r],a=i[s];if(o===void 0)switch(this.getSettings_().endingStart){case 2401:r=e,o=2*t-n;break;case 2402:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case 2401:s=e,a=2*n-t;break;case 2402:s=1,a=n+i[1]-i[0];break;default:s=e-1,a=t}let c=(n-t)*0.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(a-n),this._offsetPrev=r*l,this._offsetNext=s*l}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,f=(n-t)/(i-t),m=f*f,_=m*f,p=-d*_+2*d*m-d*f,g=(1+d)*_+(-1.5-2*d)*m+(-0.5+d)*f+1,S=(-1-h)*_+(1.5+h)*m+0.5*f,T=h*_-h*m;for(let y=0;y!==o;++y)r[y]=p*s[l+y]+g*s[c+y]+S*s[a+y]+T*s[u+y];return r}}class Rc extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=(n-t)/(i-t),u=1-l;for(let d=0;d!==o;++d)r[d]=s[c+d]*u+s[a+d]*l;return r}}class mh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class gh extends Wi{interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=e*o,c=a-o,l=this.inTangents,u=this.outTangents;if(!l||!u){let f=(n-t)/(i-t),m=1-f;for(let _=0;_!==o;++_)r[_]=s[c+_]*m+s[a+_]*f;return r}let d=o*2,h=e-1;for(let f=0;f!==o;++f){let m=s[c+f],_=s[a+f],p=h*d+f*2,g=u[p],S=u[p+1],T=e*d+f*2,y=l[T],w=l[T+1],A=US(n,t,g,y,i);r[f]=ym(A,m,S,w,_)}return r}}function ym(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 OS(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 US(e,t,n,i,r){let s=(e-t)/(r-t);for(let o=0;o<8;o++){let a=ym(s,t,n,i,r)-e;if(Math.abs(a)<0.0000000001)break;let c=OS(s,t,n,i,r);if(Math.abs(c)<0.0000000001)break;s=Math.max(0,Math.min(1,s-a/c))}return s}class Rn{constructor(e,t,n,i){if(e===void 0)throw Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=hr(t,this.TimeBufferType),this.values=hr(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:hr(e.times,Array),values:hr(e.values,Array)};let i=e.getInterpolation();if(i!==e.DefaultInterpolation)n.interpolation=i;if(nc(e.settings))n.settings={inTangents:hr(e.settings.inTangents,Array),outTangents:hr(e.settings.outTangents,Array)}}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new mh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Rc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ph(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new gh(this.times,this.values,this.getValueSize(),e);if(this.settings)t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents;return t}setInterpolation(e){let t;switch(e){case 2300:t=this.InterpolantFactoryMethodDiscrete;break;case 2301:t=this.InterpolantFactoryMethodLinear;break;case 2302:t=this.InterpolantFactoryMethodSmooth;break;case 2303:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(n);return Le("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302;case this.InterpolantFactoryMethodBezier:return 2303}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e;if(nc(this.settings))fp(this.settings.inTangents,e),fp(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)Be("KeyframeTrack: Invalid value size in track.",this),e=!1;let n=this.times,i=this.values,r=n.length;if(r===0)Be("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)){Be("KeyframeTrack: Time is not a valid number.",this,o,a),e=!1;break}if(s!==null&&s>a){Be("KeyframeTrack: Out of order keys.",this,o,a,s),e=!1;break}s=a}if(i!==void 0){if(Zb(i))for(let o=0,a=i.length;o!==a;++o){let c=i[o];if(isNaN(c)){Be("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===2302,r=e.length-1,s=1;for(let o=1;o<r;++o){let a=!1,c=e[o],l=e[o+1];if(c!==l&&(o!==1||c!==e[0]))if(!i){let u=o*n,d=u-n,h=u+n;for(let f=0;f!==n;++f){let m=t[u+f];if(m!==t[d+f]||m!==t[h+f]){a=!0;break}}}else a=!0;if(a){if(o!==s){e[s]=e[o];let u=o*n,d=s*n;for(let h=0;h!==n;++h)t[d+h]=t[u+h]}++s}}if(r>0){e[s]=e[r];for(let o=r*n,a=s*n,c=0;c!==n;++c)t[a+c]=t[o+c];++s}if(s!==e.length)this.times=e.slice(0,s),this.values=t.slice(0,s*n);else this.times=e,this.values=t;return this}clone(){let e=this.times.slice(),t=this.values.slice(),i=new this.constructor(this.name,e,t);if(i.createInterpolant=this.createInterpolant,nc(this.settings))i.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()};return i}}function fp(e,t){for(let n=0,i=e.length;n!==i;n+=2)e[n]*=t}Rn.prototype.ValueTypeName="";Rn.prototype.TimeBufferType=Float32Array;Rn.prototype.ValueBufferType=Float32Array;Rn.prototype.DefaultInterpolation=2301;class br extends Rn{constructor(e,t,n){super(e,t,n)}}br.prototype.ValueTypeName="bool";br.prototype.ValueBufferType=Array;br.prototype.DefaultInterpolation=2300;br.prototype.InterpolantFactoryMethodLinear=void 0;br.prototype.InterpolantFactoryMethodSmooth=void 0;class Cc extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}Cc.prototype.ValueTypeName="color";class Sr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}Sr.prototype.ValueTypeName="number";class _h extends Wi{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(n-t)/(i-t),c=e*o;for(let l=c+o;c!==l;c+=4)Xt.slerpFlat(r,0,s,c-o,s,c,a);return r}}class Mr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new _h(this.times,this.values,this.getValueSize(),e)}}Mr.prototype.ValueTypeName="quaternion";Mr.prototype.InterpolantFactoryMethodSmooth=void 0;class wr extends Rn{constructor(e,t,n){super(e,t,n)}}wr.prototype.ValueTypeName="string";wr.prototype.ValueBufferType=Array;wr.prototype.DefaultInterpolation=2300;wr.prototype.InterpolantFactoryMethodLinear=void 0;wr.prototype.InterpolantFactoryMethodSmooth=void 0;class jr extends Rn{constructor(e,t,n,i){super(e,t,n,i)}}jr.prototype.ValueTypeName="vector";class Ts{constructor(e="",t=-1,n=[],i=2500){if(this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ei(),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(kS(n[s]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=n.length;r!==s;++r)t.push(Rn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,s=[];for(let o=0;o<r;o++){let a=[],c=[];a.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);let l=NS(a);if(a=dp(a,1,l),c=dp(c,1,l),!i&&a[0]===0)a.push(r),c.push(c[0]);s.push(new Sr(".morphTargetInfluences["+t[o].name+"]",a,c).scale(1/n))}return new this(e,-1,s)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.name.match(r);if(l&&l.length>1){let u=l[1],d=i[u];if(!d)i[u]=d=[];d.push(c)}}let s=[];for(let o in i)s.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return s}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());let t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function FS(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Sr;case"vector":case"vector2":case"vector3":case"vector4":return jr;case"color":return Cc;case"quaternion":return Mr;case"bool":case"boolean":return br;case"string":return wr}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function kS(e){if(e.type===void 0)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=FS(e.type);if(e.times===void 0){let i=[],r=[];DS(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(nc(e.settings))n.settings={inTangents:hr(e.settings.inTangents,Float32Array),outTangents:hr(e.settings.outTangents,Float32Array)};return n}var di={enabled:!1,files:{},add:function(e,t){if(this.enabled===!1)return;if(pp(e))return;this.files[e]=t},get:function(e){if(this.enabled===!1)return;if(pp(e))return;return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};function pp(e){try{let t=e.slice(e.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch(t){return!1}}class Bo{constructor(e,t,n){let i=this,r=!1,s=0,o=0,a=void 0,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(l){if(o++,r===!1){if(i.onStart!==void 0)i.onStart(l,s,o)}r=!0},this.itemEnd=function(l){if(s++,i.onProgress!==void 0)i.onProgress(l,s,o);if(s===o){if(r=!1,i.onLoad!==void 0)i.onLoad()}},this.itemError=function(l){if(i.onError!==void 0)i.onError(l)},this.resolveURL=function(l){if(l=l.normalize("NFC"),a)return a(l);return l},this.setURLModifier=function(l){return a=l,this},this.addHandler=function(l,u){return c.push(l,u),this},this.removeHandler=function(l){let u=c.indexOf(l);if(u!==-1)c.splice(u,2);return this},this.getHandler=function(l){for(let u=0,d=c.length;u<d;u+=2){let h=c[u],f=c[u+1];if(h.global)h.lastIndex=0;if(h.test(l))return f}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){if(!this._abortController)this._abortController=new AbortController;return this._abortController}}var vm=new Bo;class Zi{constructor(e){if(this.manager=e!==void 0?e:vm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Zi.DEFAULT_MATERIAL_NAME="__DEFAULT";var Vi={};class bm extends Error{constructor(e,t){super(e);this.response=t}}class Vo extends Zi{constructor(e){super(e);this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=di.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{if(t)t(r);this.manager.itemEnd(e)},0);return}if(Vi[e]!==void 0){Vi[e].push({onLoad:t,onProgress:n,onError:i});return}Vi[e]=[],Vi[e].push({onLoad:t,onProgress:n,onError:i});let s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,a=this.responseType;fetch(s).then((c)=>{if(c.status===200||c.status===0){if(c.status===0)Le("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let l=Vi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),h=d?parseInt(d):0,f=h!==0,m=0,_=new ReadableStream({start(p){g();function g(){u.read().then(({done:S,value:T})=>{if(S)p.close();else{m+=T.byteLength;let y=new ProgressEvent("progress",{lengthComputable:f,loaded:m,total:h});for(let w=0,A=l.length;w<A;w++){let R=l[w];if(R.onProgress)R.onProgress(y)}p.enqueue(T),g()}},(S)=>{p.error(S)})}}});return new Response(_)}else throw new bm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then((c)=>{switch(a){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((l)=>new DOMParser().parseFromString(l,o));case"json":return c.json();default:if(o==="")return c.text();else{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,h=new TextDecoder(d);return c.arrayBuffer().then((f)=>h.decode(f))}}}).then((c)=>{di.add(`file:${e}`,c);let l=Vi[e];delete Vi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onLoad)h.onLoad(c)}}).catch((c)=>{let l=Vi[e];if(l===void 0)throw this.manager.itemError(e),c;delete Vi[e];for(let u=0,d=l.length;u<d;u++){let h=l[u];if(h.onError)h.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var bs=new WeakMap;class xh extends Zi{constructor(e){super(e)}load(e,t,n,i){if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=di.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=bs.get(s);if(u===void 0)u=[],bs.set(s,u);u.push({onLoad:t,onError:i})}return s}let o=Es("img");function a(){if(l(),t)t(this);let u=bs.get(this)||[];for(let d=0;d<u.length;d++){let h=u[d];if(h.onLoad)h.onLoad(this)}bs.delete(this),r.manager.itemEnd(e)}function c(u){if(l(),i)i(u);di.remove(`image:${e}`);let d=bs.get(this)||[];for(let h=0;h<d.length;h++){let f=d[h];if(f.onError)f.onError(u)}bs.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 di.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class Bs extends Zi{constructor(e){super(e)}load(e,t,n,i){let r=new Nt,s=new xh(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){if(r.image=o,r.needsUpdate=!0,t!==void 0)t(r)},n,i),r}}class Vs extends _t{constructor(e,t=1){super();this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Pc extends Vs{constructor(e,t,n){super(e,n);this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}var iu=new We,mp=new U,gp=new U;class Go{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 Fe(512,512),this.mapType=1009,this.map=null,this.mapPass=null,this.matrix=new We,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Uo,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;mp.setFromMatrixPosition(e.matrixWorld),t.position.copy(mp),gp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(gp),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,i){iu.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(iu,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(iu)}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 ec=new U,tc=new Xt,ui=new U;class Ic extends _t{constructor(){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new We,this.projectionMatrix=new We,this.projectionMatrixInverse=new We,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(ec,tc,ui),ui.x===1&&ui.y===1&&ui.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ec,tc,ui.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){if(super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(ec,tc,ui),ui.x===1&&ui.y===1&&ui.z===1)this.matrixWorldInverse.copy(this.matrixWorld).invert();else this.matrixWorldInverse.compose(ec,tc,ui.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}var ur=new U,_p=new Fe,xp=new Fe;class Vt extends Ic{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=zr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(vo*0.5*this.fov);return 0.5*this.getFilmHeight()/e}getEffectiveFOV(){return zr*2*Math.atan(Math.tan(vo*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){ur.set(-1,-1,0.5).applyMatrix4(this.projectionMatrixInverse),t.set(ur.x,ur.y).multiplyScalar(-e/ur.z),ur.set(1,1,0.5).applyMatrix4(this.projectionMatrixInverse),n.set(ur.x,ur.y).multiplyScalar(-e/ur.z)}getViewSize(e,t){return this.getViewBounds(e,_p,xp),t.subVectors(xp,_p)}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(vo*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 Sm extends Go{constructor(){super(new Vt(50,1,0.5,500));this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,n=zr*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 Lc extends Vs{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t);this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Sm}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 Mm extends Go{constructor(){super(new Vt(90,1,0.5,500));this.isPointLightShadow=!0}}class Gs extends Vs{constructor(e,t,n=0,i=2){super(e,t);this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Mm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class qr extends Ic{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 wm extends Go{constructor(){super(new qr(-5,5,5,-5,0.5,500));this.isDirectionalLightShadow=!0}}class Hs extends Vs{constructor(e,t){super(e,t);this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new wm}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 ru=new WeakMap;class Nc extends Zi{constructor(e){super(e);if(this.isImageBitmapLoader=!0,typeof createImageBitmap>"u")Le("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")Le("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){if(e===void 0)e="";if(this.path!==void 0)e=this.path+e;e=this.manager.resolveURL(e);let r=this,s=di.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then((c)=>{if(ru.has(s)===!0){if(i)i(ru.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(di.add(`image-bitmap:${e}`,c),t)t(c);return r.manager.itemEnd(e),c}).catch(function(c){if(i)i(c);ru.set(a,c),di.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});di.add(`image-bitmap:${e}`,a),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var Ss=-90,Ms=1;class yh extends _t{constructor(e,t,n){super();this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new Vt(Ss,Ms,e,t);i.layers=this.layers,this.add(i);let r=new Vt(Ss,Ms,e,t);r.layers=this.layers,this.add(r);let s=new Vt(Ss,Ms,e,t);s.layers=this.layers,this.add(s);let o=new Vt(Ss,Ms,e,t);o.layers=this.layers,this.add(o);let a=new Vt(Ss,Ms,e,t);a.layers=this.layers,this.add(a);let c=new Vt(Ss,Ms,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,o,a]=t;for(let c of t)this.remove(c);if(e===2000)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;if(this.coordinateSystem!==e.coordinateSystem)this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem();let[r,s,o,a,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;if(e.isWebGLRenderer===!0)_=e.state.buffers.depth.getReversed();else _=e.reversedDepthBuffer;if(e.setRenderTarget(n,0,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,r),e.setRenderTarget(n,1,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,s),e.setRenderTarget(n,2,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,o),e.setRenderTarget(n,3,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,a),e.setRenderTarget(n,4,i),_&&e.autoClear===!1)e.clearDepth();if(e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,i),_&&e.autoClear===!1)e.clearDepth();e.render(t,l),e.setRenderTarget(u,d,h),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class vh extends Vt{constructor(e=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class bh{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,s;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,s=this.cumulativeWeight;if(s===0){for(let o=0;o!==i;++o)n[r+o]=n[o];s=t}else{s+=t;let o=t/s;this._mixBufferRegion(n,r,0,o,i)}this.cumulativeWeight=s}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;if(this.cumulativeWeightAdditive===0)this._setIdentity();this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let a=t*this._origIndex;this._mixBufferRegion(n,i,a,1-r,t)}if(s>0)this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let a=t,c=t+t;a!==c;++a)if(n[a]!==n[a+t]){o.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,s=i;r!==s;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=0.5)for(let s=0;s!==r;++s)e[t+s]=e[n+s]}_slerp(e,t,n,i){Xt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let s=this._workIndex*r;Xt.multiplyQuaternionsFlat(e,s,e,t,e,n),Xt.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){let s=1-i;for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]*s+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){let o=t+s;e[o]=e[o]+e[n+s]*i}}}var Sh="\\[\\]\\.:\\/",zS=new RegExp("["+Sh+"]","g"),Mh="[^"+Sh+"]",BS="[^"+Sh.replace("\\.","")+"]",VS=/((?:WC+[\/:])*)/.source.replace("WC",Mh),GS=/(WCOD+)?/.source.replace("WCOD",BS),HS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Mh),$S=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Mh),WS=new RegExp("^"+VS+GS+HS+$S+"$"),ZS=["material","materials","bones","map"];class Em{constructor(e,t,n){let i=n||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];if(i!==void 0)i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){if(!(e&&e.isAnimationObjectGroup))return new ot(e,t,n);else return new ot.Composite(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(zS,"")}static parseTrackName(e){let t=WS.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(ZS.indexOf(r)!==-1)n.nodeName=n.nodeName.substring(0,i),n.objectName=r}if(n.propertyName===null||n.propertyName.length===0)throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let s=0;s<r.length;s++){let o=r[s];if(o.name===t||o.uuid===t)return o;let a=n(o.children);if(a)return a}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,{objectName:n,propertyName:i,propertyIndex:r}=t;if(!e)e=ot.findNode(this.rootNode,t.nodeName),this.node=e;if(this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Le("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Be("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){Be("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){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Be("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){Be("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Be("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;Be("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){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}if(e.morphTargetDictionary[r]!==void 0)r=e.morphTargetDictionary[r]}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else if(s.fromArray!==void 0&&s.toArray!==void 0)a=this.BindingType.HasFromToArray,this.resolvedProperty=s;else if(Array.isArray(s))a=this.BindingType.EntireArray,this.resolvedProperty=s;else this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=Em;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class wh{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 XS=new Float32Array(1);class Dc extends ri{constructor(e){super();if(this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,{_propertyBindings:s,_interpolants:o}=e,a=n.uuid,c=this._bindingsByRootAndName,l=c[a];if(l===void 0)l={},c[a]=l;for(let u=0;u!==r;++u){let d=i[u],h=d.name,f=l[h];if(f!==void 0)++f.referenceCount,s[u]=f;else{if(f=s[u],f!==void 0){if(f._cacheIndex===null)++f.referenceCount,this._addInactiveBinding(f,a,h);continue}let m=t&&t._propertyBindings[u].binding.parsedPath;f=new bh(ot.create(n,h,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,a,h),s[u]=f}o[u].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(r.useCount++===0)this._lendBinding(r),r.saveOriginalState()}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.useCount===0)r.restoreOriginalState(),this._takeBackBinding(r)}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{let o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],l=e._byClipCacheIndex;c._byClipCacheIndex=l,a[l]=c,a.pop(),e._byClipCacheIndex=null;let u=o.actionByRoot,d=(e._localRoot||this._root).uuid;if(delete u[d],a.length===0)delete s[r];this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];if(--r.referenceCount===0)this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,s=i[t];if(s===void 0)s={},i[t]=s;s[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,s=this._bindingsByRootAndName,o=s[i],a=t[t.length-1],c=e._cacheIndex;if(a._cacheIndex=c,t[c]=a,t.pop(),delete o[r],Object.keys(o).length===0)delete s[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];if(n===void 0)n=new Rc(new Float32Array(2),new Float32Array(2),1,XS),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"?Ts.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 wh(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"?Ts.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 Ho{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=Ye(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(Ye(t/this.radius,-1,1));return this}clone(){return new this.constructor().copy(this)}}class Eh{static{Eh.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 Oc extends ri{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 Ah(e,t,n,i){let r=jS(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 jS(e){switch(e){case 1009:case 1010:return{byteLength:1,components:1};case 1012:case 1011:case 1016:return{byteLength:2,components:1};case 1017:case 1018:return{byteLength:2,components:4};case 1014:case 1013:case 1015:return{byteLength:4,components:1};case 35902:case 35899:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}if(typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));if(typeof window<"u")if(window.__THREE__)Le("WARNING: Multiple instances of Three.js being imported.");else window.__THREE__="186";function Xm(){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 qS(e){let t=new WeakMap;function n(a,c){let{array:l,usage:u}=a,d=l.byteLength,h=e.createBuffer();e.bindBuffer(c,h),e.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=e.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=e.HALF_FLOAT;else if(l instanceof Uint16Array)if(a.isFloat16BufferAttribute)f=e.HALF_FLOAT;else f=e.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=e.SHORT;else if(l instanceof Uint32Array)f=e.UNSIGNED_INT;else if(l instanceof Int32Array)f=e.INT;else if(l instanceof Int8Array)f=e.BYTE;else if(l instanceof Uint8Array)f=e.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let{array:u,updateRanges:d}=c;if(e.bindBuffer(l,a),d.length===0)e.bufferSubData(l,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],_=d[f];if(_.start<=m.start+m.count+1)m.count=Math.max(m.count,_.start+_.count-m.start);else++h,d[h]=_}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let _=d[f];e.bufferSubData(l,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){if(a.isInterleavedBufferAttribute)a=a.data;return t.get(a)}function s(a){if(a.isInterleavedBufferAttribute)a=a.data;let c=t.get(a);if(c)e.deleteBuffer(c.buffer),t.delete(a)}function o(a,c){if(a.isInterleavedBufferAttribute)a=a.data;if(a.isGLBufferAttribute){let u=t.get(a);if(!u||u.version<a.version)t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,n(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var YS=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
-#endif`,VS=`#ifdef USE_ALPHAHASH
+#endif`,JS=`#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`,GS=`#ifdef USE_ALPHAMAP
+#endif`,KS=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
-#endif`,HS=`#ifdef USE_ALPHAMAP
+#endif`,QS=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
-#endif`,$S=`#ifdef USE_ALPHATEST
+#endif`,eM=`#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`,WS=`#ifdef USE_ALPHATEST
+#endif`,tM=`#ifdef USE_ALPHATEST
uniform float alphaTest;
-#endif`,ZS=`#ifdef USE_AOMAP
+#endif`,nM=`#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`,XS=`#ifdef USE_AOMAP
+#endif`,iM=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
-#endif`,jS=`#ifdef USE_BATCHING
+#endif`,rM=`#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`,qS=`#ifdef USE_BATCHING
+#endif`,sM=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
-#endif`,YS=`vec3 transformed = vec3( position );
+#endif`,oM=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
-#endif`,JS=`vec3 objectNormal = vec3( normal );
+#endif`,aM=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
-#endif`,KS=`float G_BlinnPhong_Implicit( ) {
+#endif`,cM=`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`,QS=`#ifdef USE_IRIDESCENCE
+} // validated`,lM=`#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`,eM=`#ifdef USE_BUMPMAP
+#endif`,uM=`#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`,tM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,hM=`#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`,nM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,dM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,iM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,fM=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
-#endif`,rM=`#if NUM_CLIPPING_PLANES > 0
+#endif`,pM=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
-#endif`,sM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,mM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
-#endif`,oM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
+#endif`,gM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
-#endif`,aM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,_M=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
-#endif`,cM=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
+#endif`,xM=`#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`,lM=`#define PI 3.141592653589793
+#endif`,yM=`#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`,uM=`#ifdef ENVMAP_TYPE_CUBE_UV
+} // validated`,vM=`#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`,hM=`vec3 transformedNormal = objectNormal;
+#endif`,bM=`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`,dM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,SM=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
-#endif`,fM=`#ifdef USE_DISPLACEMENTMAP
+#endif`,MM=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
-#endif`,pM=`#ifdef USE_EMISSIVEMAP
+#endif`,wM=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,mM=`#ifdef USE_EMISSIVEMAP
+#endif`,EM=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
-#endif`,gM="gl_FragColor = linearToOutputTexel( gl_FragColor );",_M=`vec4 LinearTransferOETF( in vec4 value ) {
+#endif`,AM="gl_FragColor = linearToOutputTexel( gl_FragColor );",TM=`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 );
-}`,xM=`#ifdef USE_ENVMAP
+}`,RM=`#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`,yM=`#ifdef USE_ENVMAP
+#endif`,CM=`#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`,vM=`#ifdef USE_ENVMAP
+#endif`,PM=`#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`,bM=`#ifdef USE_ENVMAP
+#endif`,IM=`#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`,SM=`#ifdef USE_ENVMAP
+#endif`,LM=`#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`,MM=`#ifdef USE_FOG
+#endif`,NM=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
-#endif`,wM=`#ifdef USE_FOG
+#endif`,DM=`#ifdef USE_FOG
varying float vFogDepth;
-#endif`,EM=`#ifdef USE_FOG
+#endif`,OM=`#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`,AM=`#ifdef USE_FOG
+#endif`,UM=`#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`,TM=`#ifdef USE_GRADIENTMAP
+#endif`,FM=`#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
-}`,RM=`#ifdef USE_LIGHTMAP
+}`,kM=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
-#endif`,CM=`LambertMaterial material;
+#endif`,zM=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
-material.specularStrength = specularStrength;`,PM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,BM=`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`,IM=`uniform bool receiveShadow;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,VM=`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>`,LM=`#ifdef USE_ENVMAP
+#include <lightprobes_pars_fragment>`,GM=`#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`,NM=`ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,DM=`varying vec3 vViewPosition;
+#endif`,HM=`ToonMaterial material;
+material.diffuseColor = diffuseColor.rgb;`,$M=`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`,OM=`BlinnPhongMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,WM=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,UM=`varying vec3 vViewPosition;
+material.specularStrength = specularStrength;`,ZM=`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`,FM=`PhysicalMaterial material;
+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,XM=`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`,zM=`uniform sampler2D dfgLUT;
+#endif`,jM=`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 );
-}`,kM=`
+}`,qM=`
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`,BM=`#if defined( RE_IndirectDiffuse )
+#endif`,YM=`#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`,VM=`#if defined( RE_IndirectDiffuse )
+#endif`,JM=`#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`,GM=`#ifdef USE_LIGHT_PROBES_GRID
+#endif`,KM=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
@@ -1652,27 +1652,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
-#endif`,HM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,QM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,$M=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
+#endif`,ew=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,WM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,tw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
-#endif`,ZM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
+#endif`,nw=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
-#endif`,XM=`#ifdef USE_MAP
+#endif`,iw=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
-#endif`,jM=`#ifdef USE_MAP
+#endif`,rw=`#ifdef USE_MAP
uniform sampler2D map;
-#endif`,qM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
+#endif`,sw=`#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`,YM=`#if defined( USE_POINTS_UV )
+#endif`,ow=`#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`,JM=`float metalnessFactor = metalness;
+#endif`,aw=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
-#endif`,KM=`#ifdef USE_METALNESSMAP
+#endif`,cw=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
-#endif`,QM=`#ifdef USE_INSTANCING_MORPH
+#endif`,lw=`#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`,ew=`#if defined( USE_MORPHCOLORS )
+#endif`,uw=`#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`,tw=`#ifdef USE_MORPHNORMALS
+#endif`,hw=`#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`,nw=`#ifdef USE_MORPHTARGETS
+#endif`,dw=`#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`,iw=`#ifdef USE_MORPHTARGETS
+#endif`,fw=`#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`,rw=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
+#endif`,pw=`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;`,sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
+vec3 nonPerturbedNormal = normal;`,mw=`#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;`,sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,ow=`#ifndef FLAT_SHADED
+#endif`,gw=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,aw=`#ifndef FLAT_SHADED
+#endif`,_w=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
-#endif`,cw=`#ifndef FLAT_SHADED
+#endif`,xw=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
@@ -1821,7 +1821,7 @@ vec3 nonPerturbedNormal = normal;`,sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
vBitangent = - vBitangent;
#endif
#endif
-#endif`,lw=`#ifdef USE_NORMALMAP
+#endif`,yw=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
@@ -1843,13 +1843,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`,uw=`#ifdef USE_CLEARCOAT
+#endif`,vw=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
-#endif`,hw=`#ifdef USE_CLEARCOAT_NORMALMAP
+#endif`,bw=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
-#endif`,dw=`#ifdef USE_CLEARCOATMAP
+#endif`,Sw=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
@@ -1858,18 +1858,18 @@ vec3 nonPerturbedNormal = normal;`,sw=`#ifdef USE_NORMALMAP_OBJECTSPACE
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
-#endif`,fw=`#ifdef USE_IRIDESCENCEMAP
+#endif`,Mw=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
-#endif`,pw=`#ifdef OPAQUE
+#endif`,ww=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mw=`vec3 packNormalToRGB( const in vec3 normal ) {
+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ew=`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
-}`,gw=`#ifdef PREMULTIPLIED_ALPHA
+}`,Aw=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,_w=`vec4 mvPosition = vec4( transformed, 1.0 );
+#endif`,Tw=`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;`,xw=`#ifdef DITHERING
+gl_Position = projectionMatrix * mvPosition;`,Rw=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,yw=`#ifdef DITHERING
+#endif`,Cw=`#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`,vw=`float roughnessFactor = roughness;
+#endif`,Pw=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
-#endif`,bw=`#ifdef USE_ROUGHNESSMAP
+#endif`,Iw=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
-#endif`,Sw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,Lw=`#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;`,xw=`#ifdef DITHERING
}
#endif
#endif
-#endif`,Mw=`#if NUM_SPOT_LIGHT_COORDS > 0
+#endif`,Nw=`#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;`,xw=`#ifdef DITHERING
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
-#endif`,ww=`#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`,Dw=`#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;`,xw=`#ifdef DITHERING
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
-#endif`,Ew=`float getShadowMask() {
+#endif`,Ow=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2350,12 +2350,12 @@ gl_Position = projectionMatrix * mvPosition;`,xw=`#ifdef DITHERING
#endif
#endif
return shadow;
-}`,Aw=`#ifdef USE_SKINNING
+}`,Uw=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,Tw=`#ifdef USE_SKINNING
+#endif`,Fw=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,xw=`#ifdef DITHERING
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
-#endif`,Rw=`#ifdef USE_SKINNING
+#endif`,kw=`#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;`,xw=`#ifdef DITHERING
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
-#endif`,Cw=`#ifdef USE_SKINNING
+#endif`,zw=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
@@ -2389,17 +2389,17 @@ gl_Position = projectionMatrix * mvPosition;`,xw=`#ifdef DITHERING
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
-#endif`,Pw=`float specularStrength;
+#endif`,Bw=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
-#endif`,Iw=`#ifdef USE_SPECULARMAP
+#endif`,Vw=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
-#endif`,Lw=`#if defined( TONE_MAPPING )
+#endif`,Gw=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,Nw=`#ifndef saturate
+#endif`,Hw=`#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; }`,Dw=`#ifdef USE_TRANSMISSION
+vec3 CustomToneMapping( vec3 color ) { return color; }`,$w=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
@@ -2517,7 +2517,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Dw=`#ifdef USE_TRANSMISS
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
-#endif`,Ow=`#ifdef USE_TRANSMISSION
+#endif`,Ww=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
@@ -2643,7 +2643,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Dw=`#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`,Uw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,Zw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2713,7 +2713,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Dw=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,Fw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,Xw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
@@ -2807,7 +2807,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Dw=`#ifdef USE_TRANSMISS
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
-#endif`,zw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
+#endif`,jw=`#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; }`,Dw=`#ifdef USE_TRANSMISS
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
-#endif`;var kw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
+#endif`;var qw=`#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; }`,Dw=`#ifdef USE_TRANSMISS
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
-#endif`,Bw=`varying vec2 vUv;
+#endif`,Yw=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,Vw=`uniform sampler2D t2D;
+}`,Jw=`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>
-}`,Gw=`varying vec3 vWorldDirection;
+}`,Kw=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Hw=`#ifdef ENVMAP_TYPE_CUBE
+}`,Qw=`#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>
-}`,$w=`varying vec3 vWorldDirection;
+}`,eE=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
-}`,Ww=`uniform samplerCube tCube;
+}`,tE=`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>
-}`,Zw=`#include <common>
+}`,nE=`#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;
-}`,Xw=`#if DEPTH_PACKING == 3200
+}`,iE=`#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
-}`,jw=`#define DISTANCE
+}`,rE=`#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;
-}`,qw=`#define DISTANCE
+}`,sE=`#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 );
-}`,Yw=`varying vec3 vWorldDirection;
+}`,oE=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
-}`,Jw=`uniform sampler2D tEquirect;
+}`,aE=`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>
-}`,Kw=`uniform float scale;
+}`,cE=`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>
-}`,Qw=`uniform vec3 diffuse;
+}`,lE=`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>
-}`,eE=`#include <common>
+}`,uE=`#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>
-}`,tE=`uniform vec3 diffuse;
+}`,hE=`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>
-}`,nE=`#define LAMBERT
+}`,dE=`#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>
-}`,iE=`#define LAMBERT
+}`,fE=`#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>
-}`,rE=`#define MATCAP
+}`,pE=`#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;
-}`,sE=`#define MATCAP
+}`,mE=`#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>
-}`,oE=`#define NORMAL
+}`,gE=`#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
-}`,aE=`#define NORMAL
+}`,_E=`#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
-}`,cE=`#define PHONG
+}`,xE=`#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>
-}`,lE=`#define PHONG
+}`,yE=`#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>
-}`,uE=`#define STANDARD
+}`,vE=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
@@ -3583,7 +3583,7 @@ void main() {
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
-}`,hE=`#define STANDARD
+}`,bE=`#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>
-}`,dE=`#define TOON
+}`,SE=`#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>
-}`,fE=`#define TOON
+}`,ME=`#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>
-}`,pE=`uniform float size;
+}`,wE=`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>
-}`,mE=`uniform vec3 diffuse;
+}`,EE=`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>
-}`,gE=`#include <common>
+}`,AE=`#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>
-}`,_E=`uniform vec3 color;
+}`,TE=`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>
-}`,xE=`uniform float rotation;
+}`,RE=`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>
-}`,yE=`uniform vec3 diffuse;
+}`,CE=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
@@ -3944,7 +3944,7 @@ void main() {
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
-}`,Ze={alphahash_fragment:BS,alphahash_pars_fragment:VS,alphamap_fragment:GS,alphamap_pars_fragment:HS,alphatest_fragment:$S,alphatest_pars_fragment:WS,aomap_fragment:ZS,aomap_pars_fragment:XS,batching_pars_vertex:jS,batching_vertex:qS,begin_vertex:YS,beginnormal_vertex:JS,bsdfs:KS,iridescence_fragment:QS,bumpmap_pars_fragment:eM,clipping_planes_fragment:tM,clipping_planes_pars_fragment:nM,clipping_planes_pars_vertex:iM,clipping_planes_vertex:rM,color_fragment:sM,color_pars_fragment:oM,color_pars_vertex:aM,color_vertex:cM,common:lM,cube_uv_reflection_fragment:uM,defaultnormal_vertex:hM,displacementmap_pars_vertex:dM,displacementmap_vertex:fM,emissivemap_fragment:pM,emissivemap_pars_fragment:mM,colorspace_fragment:gM,colorspace_pars_fragment:_M,envmap_fragment:xM,envmap_common_pars_fragment:yM,envmap_pars_fragment:vM,envmap_pars_vertex:bM,envmap_physical_pars_fragment:LM,envmap_vertex:SM,fog_vertex:MM,fog_pars_vertex:wM,fog_fragment:EM,fog_pars_fragment:AM,gradientmap_pars_fragment:TM,lightmap_pars_fragment:RM,lights_lambert_fragment:CM,lights_lambert_pars_fragment:PM,lights_pars_begin:IM,lights_toon_fragment:NM,lights_toon_pars_fragment:DM,lights_phong_fragment:OM,lights_phong_pars_fragment:UM,lights_physical_fragment:FM,lights_physical_pars_fragment:zM,lights_fragment_begin:kM,lights_fragment_maps:BM,lights_fragment_end:VM,lightprobes_pars_fragment:GM,logdepthbuf_fragment:HM,logdepthbuf_pars_fragment:$M,logdepthbuf_pars_vertex:WM,logdepthbuf_vertex:ZM,map_fragment:XM,map_pars_fragment:jM,map_particle_fragment:qM,map_particle_pars_fragment:YM,metalnessmap_fragment:JM,metalnessmap_pars_fragment:KM,morphinstance_vertex:QM,morphcolor_vertex:ew,morphnormal_vertex:tw,morphtarget_pars_vertex:nw,morphtarget_vertex:iw,normal_fragment_begin:rw,normal_fragment_maps:sw,normal_pars_fragment:ow,normal_pars_vertex:aw,normal_vertex:cw,normalmap_pars_fragment:lw,clearcoat_normal_fragment_begin:uw,clearcoat_normal_fragment_maps:hw,clearcoat_pars_fragment:dw,iridescence_pars_fragment:fw,opaque_fragment:pw,packing:mw,premultiplied_alpha_fragment:gw,project_vertex:_w,dithering_fragment:xw,dithering_pars_fragment:yw,roughnessmap_fragment:vw,roughnessmap_pars_fragment:bw,shadowmap_pars_fragment:Sw,shadowmap_pars_vertex:Mw,shadowmap_vertex:ww,shadowmask_pars_fragment:Ew,skinbase_vertex:Aw,skinning_pars_vertex:Tw,skinning_vertex:Rw,skinnormal_vertex:Cw,specularmap_fragment:Pw,specularmap_pars_fragment:Iw,tonemapping_fragment:Lw,tonemapping_pars_fragment:Nw,transmission_fragment:Dw,transmission_pars_fragment:Ow,uv_pars_fragment:Uw,uv_pars_vertex:Fw,uv_vertex:zw,worldpos_vertex:kw,background_vert:Bw,background_frag:Vw,backgroundCube_vert:Gw,backgroundCube_frag:Hw,cube_vert:$w,cube_frag:Ww,depth_vert:Zw,depth_frag:Xw,distance_vert:jw,distance_frag:qw,equirect_vert:Yw,equirect_frag:Jw,linedashed_vert:Kw,linedashed_frag:Qw,meshbasic_vert:eE,meshbasic_frag:tE,meshlambert_vert:nE,meshlambert_frag:iE,meshmatcap_vert:rE,meshmatcap_frag:sE,meshnormal_vert:oE,meshnormal_frag:aE,meshphong_vert:cE,meshphong_frag:lE,meshphysical_vert:uE,meshphysical_frag:hE,meshtoon_vert:dE,meshtoon_frag:fE,points_vert:pE,points_frag:mE,shadow_vert:gE,shadow_frag:_E,sprite_vert:xE,sprite_frag:yE},fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ve}},envmap:{envMap:{value:null},envMapRotation:{value:new Ve},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ve},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0},uvTransform:{value:new Ve}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ue(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ve},alphaMap:{value:null},alphaMapTransform:{value:new Ve},alphaTest:{value:0}}},xi={basic:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ze.meshbasic_vert,fragmentShader:Ze.meshbasic_frag},lambert:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ze.meshlambert_vert,fragmentShader:Ze.meshlambert_frag},phong:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphong_vert,fragmentShader:Ze.meshphong_frag},standard:{uniforms:on([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag},toon:{uniforms:on([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ze.meshtoon_vert,fragmentShader:Ze.meshtoon_frag},matcap:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ze.meshmatcap_vert,fragmentShader:Ze.meshmatcap_frag},points:{uniforms:on([fe.points,fe.fog]),vertexShader:Ze.points_vert,fragmentShader:Ze.points_frag},dashed:{uniforms:on([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ze.linedashed_vert,fragmentShader:Ze.linedashed_frag},depth:{uniforms:on([fe.common,fe.displacementmap]),vertexShader:Ze.depth_vert,fragmentShader:Ze.depth_frag},normal:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ze.meshnormal_vert,fragmentShader:Ze.meshnormal_frag},sprite:{uniforms:on([fe.sprite,fe.fog]),vertexShader:Ze.sprite_vert,fragmentShader:Ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ze.background_vert,fragmentShader:Ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ve}},vertexShader:Ze.backgroundCube_vert,fragmentShader:Ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ze.cube_vert,fragmentShader:Ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ze.equirect_vert,fragmentShader:Ze.equirect_frag},distance:{uniforms:on([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Ze.distance_vert,fragmentShader:Ze.distance_frag},shadow:{uniforms:on([fe.lights,fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ze.shadow_vert,fragmentShader:Ze.shadow_frag}};xi.physical={uniforms:on([xi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ve},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ve},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ve},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ve},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ve},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ve},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ve}}]),vertexShader:Ze.meshphysical_vert,fragmentShader:Ze.meshphysical_frag};var Cc={r:0,b:0,g:0},vE=new $e,Bm=new Ve;Bm.set(-1,0,0,0,1,0,0,0,1);function bE(e,t,n,i,r,s){let o=new ze(0),a=r===!0?0:1,c,l,u=null,d=0,h=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===vo)){if(l===void 0)l=new Mt(new mr(1,1,1),new Bn({name:"BackgroundCubeMaterial",uniforms:Gr(xi.backgroundCube.uniforms),vertexShader:xi.backgroundCube.vertexShader,fragmentShader:xi.backgroundCube.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(vE.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(Bm);if(l.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new Mt(new No(2,2),new Bn({name:"BackgroundMaterial",uniforms:Gr(xi.background.uniforms),vertexShader:xi.background.vertexShader,fragmentShader:xi.background.fragmentShader,side:ur,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=je.getTransfer(y.colorSpace)!==yt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Cc,nh(e)),n.buffers.color.setClear(Cc.r,Cc.g,Cc.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function SE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=d(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function d(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let k=j[K.id];if(k===void 0)k={},j[K.id]=k;let q=k[G];if(q===void 0)q=h(c()),k[G]=q;return q}function h(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=G[k],Me=X[k];if(Me===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Me=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Me=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Me)return!0;if(Me&&Q.data!==Me.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let k in j)if(j[k].location>=0){let Q=X[k];if(Q===void 0){if(k==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(k==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let Me={};if(Me.attribute=Q,Q&&Q.data)Me.data=Q.data;G[k]=Me,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let k=X[j];if(k.location>=0){let q=G[j];if(q===void 0){if(j==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(j==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,Me=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Be,type:we,bytesPerElement:Z}=ue,re=we===e.INT||we===e.UNSIGNED_INT||q.gpuType===lu;if(q.isInterleavedBufferAttribute){let se=q.data,xe=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<k.locationSize;Ae++)g(k.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<k.locationSize;Ae++)p(k.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let Ae=0;Ae<k.locationSize;Ae++)T(k.location+Ae,Me/k.locationSize,we,Q,xe*Z,(Ee+Me/k.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<k.locationSize;se++)g(k.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<k.locationSize;se++)p(k.location+se);e.bindBuffer(e.ARRAY_BUFFER,Be);for(let se=0;se<k.locationSize;se++)T(k.location+se,Me/k.locationSize,we,Q,Me*Z,Me/k.locationSize*se*Z,re)}}else if(P!==void 0){let Q=P[j];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(k.location,Q);break;case 3:e.vertexAttrib3fv(k.location,Q);break;case 4:e.vertexAttrib4fv(k.location,Q);break;default:e.vertexAttrib1fv(k.location,Q)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){if(z(),o=!0,s===r)return;s=r,l(s.object)}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:z,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function ME(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let f=0;f<u;f++)h+=l[f];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function wE(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==mi&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===pi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==Qn&&R!==Gi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Le("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function EE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Fn,a=new Ve,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=d,g=e.get(d);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,h,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,f,m){let _=d!==null?d.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=h.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(d[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Bs=4,AE=6,TE=20,RE=256,zo=new $r,xm=new ze,yh=null,vh=0,bh=0,Sh=!1,CE=new U,Wr=new U;class Go{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=CE}=r;yh=this._renderer.getRenderTarget(),vh=this._renderer.getActiveCubeFace(),bh=this._renderer.getActiveMipmapLevel(),Sh=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=bm(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=vm(),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(yh,vh,bh),this._renderer.xr.enabled=Sh,e.scissorTest=!1,ks(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Es||e.mapping===Or)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);yh=this._renderer.getRenderTarget(),vh=this._renderer.getActiveCubeFace(),bh=this._renderer.getActiveMipmapLevel(),Sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:pi,format:mi,colorSpace:Sn,depthBuffer:!1},i=ym(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=ym(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=PE(r)),this._blurMaterial=LE(r,e,t),this._ggxMaterial=IE(r,e,t)}return i}_compileMaterial(e){let t=new Mt(new sn,e);this._renderer.compile(t,zo)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(xm),u.toneMapping=Jn,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new Mt(new mr,new gi({name:"PMREM.Background",side:rn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(xm),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if(ks(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Es||e.mapping===Or;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=bm();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=vm();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;ks(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,zo)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,h=u*d,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Bs?n-f+Bs:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=f-t,ks(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,zo),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,ks(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,zo)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Bs?i-this._lodMax+Bs:0),d=4*(this._cubeSize-l);ks(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(a,zo)}}function PE(e){let t=[],n=[],i=e,r=e-Bs+1+AE;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,m=new Float32Array(f*h*d),_=new Float32Array(f*h*d);for(let g=0;g<d;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*h*g);for(let w=0;w<h;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Wr.set(1,R,A);else if(g===1)Wr.set(-A,1,-R);else if(g===2)Wr.set(-A,R,1);else if(g===3)Wr.set(-1,R,-A);else if(g===4)Wr.set(-A,-1,R);else Wr.set(A,R,-1);Wr.toArray(_,(g*h+w)*f)}}let p=new sn;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new Mt(p,null)),i>Bs)i--}return{lodMeshes:n,sizeLods:t}}function ym(e,t,n){let i=new Mn(e,t,n);return i.texture.mapping=vo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function ks(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function IE(e,t,n){return new Bn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:RE,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:Ic(),fragmentShader:`
+}`,Xe={alphahash_fragment:YS,alphahash_pars_fragment:JS,alphamap_fragment:KS,alphamap_pars_fragment:QS,alphatest_fragment:eM,alphatest_pars_fragment:tM,aomap_fragment:nM,aomap_pars_fragment:iM,batching_pars_vertex:rM,batching_vertex:sM,begin_vertex:oM,beginnormal_vertex:aM,bsdfs:cM,iridescence_fragment:lM,bumpmap_pars_fragment:uM,clipping_planes_fragment:hM,clipping_planes_pars_fragment:dM,clipping_planes_pars_vertex:fM,clipping_planes_vertex:pM,color_fragment:mM,color_pars_fragment:gM,color_pars_vertex:_M,color_vertex:xM,common:yM,cube_uv_reflection_fragment:vM,defaultnormal_vertex:bM,displacementmap_pars_vertex:SM,displacementmap_vertex:MM,emissivemap_fragment:wM,emissivemap_pars_fragment:EM,colorspace_fragment:AM,colorspace_pars_fragment:TM,envmap_fragment:RM,envmap_common_pars_fragment:CM,envmap_pars_fragment:PM,envmap_pars_vertex:IM,envmap_physical_pars_fragment:GM,envmap_vertex:LM,fog_vertex:NM,fog_pars_vertex:DM,fog_fragment:OM,fog_pars_fragment:UM,gradientmap_pars_fragment:FM,lightmap_pars_fragment:kM,lights_lambert_fragment:zM,lights_lambert_pars_fragment:BM,lights_pars_begin:VM,lights_toon_fragment:HM,lights_toon_pars_fragment:$M,lights_phong_fragment:WM,lights_phong_pars_fragment:ZM,lights_physical_fragment:XM,lights_physical_pars_fragment:jM,lights_fragment_begin:qM,lights_fragment_maps:YM,lights_fragment_end:JM,lightprobes_pars_fragment:KM,logdepthbuf_fragment:QM,logdepthbuf_pars_fragment:ew,logdepthbuf_pars_vertex:tw,logdepthbuf_vertex:nw,map_fragment:iw,map_pars_fragment:rw,map_particle_fragment:sw,map_particle_pars_fragment:ow,metalnessmap_fragment:aw,metalnessmap_pars_fragment:cw,morphinstance_vertex:lw,morphcolor_vertex:uw,morphnormal_vertex:hw,morphtarget_pars_vertex:dw,morphtarget_vertex:fw,normal_fragment_begin:pw,normal_fragment_maps:mw,normal_pars_fragment:gw,normal_pars_vertex:_w,normal_vertex:xw,normalmap_pars_fragment:yw,clearcoat_normal_fragment_begin:vw,clearcoat_normal_fragment_maps:bw,clearcoat_pars_fragment:Sw,iridescence_pars_fragment:Mw,opaque_fragment:ww,packing:Ew,premultiplied_alpha_fragment:Aw,project_vertex:Tw,dithering_fragment:Rw,dithering_pars_fragment:Cw,roughnessmap_fragment:Pw,roughnessmap_pars_fragment:Iw,shadowmap_pars_fragment:Lw,shadowmap_pars_vertex:Nw,shadowmap_vertex:Dw,shadowmask_pars_fragment:Ow,skinbase_vertex:Uw,skinning_pars_vertex:Fw,skinning_vertex:kw,skinnormal_vertex:zw,specularmap_fragment:Bw,specularmap_pars_fragment:Vw,tonemapping_fragment:Gw,tonemapping_pars_fragment:Hw,transmission_fragment:$w,transmission_pars_fragment:Ww,uv_pars_fragment:Zw,uv_pars_vertex:Xw,uv_vertex:jw,worldpos_vertex:qw,background_vert:Yw,background_frag:Jw,backgroundCube_vert:Kw,backgroundCube_frag:Qw,cube_vert:eE,cube_frag:tE,depth_vert:nE,depth_frag:iE,distance_vert:rE,distance_frag:sE,equirect_vert:oE,equirect_frag:aE,linedashed_vert:cE,linedashed_frag:lE,meshbasic_vert:uE,meshbasic_frag:hE,meshlambert_vert:dE,meshlambert_frag:fE,meshmatcap_vert:pE,meshmatcap_frag:mE,meshnormal_vert:gE,meshnormal_frag:_E,meshphong_vert:xE,meshphong_frag:yE,meshphysical_vert:vE,meshphysical_frag:bE,meshtoon_vert:SE,meshtoon_frag:ME,points_vert:wE,points_frag:EE,shadow_vert:AE,shadow_frag:TE,sprite_vert:RE,sprite_frag:CE},fe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ge}},envmap:{envMap:{value:null},envMapRotation:{value:new Ge},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ge}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ge}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ge},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ge},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ge},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ge}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ge}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ge}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0},uvTransform:{value:new Ge}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Fe(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},vi={basic:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:on([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:on([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:on([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:on([fe.points,fe.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:on([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:on([fe.common,fe.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:on([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.meshnormal_vert,fragmentShader:Xe.meshnormal_frag},sprite:{uniforms:on([fe.sprite,fe.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:Xe.backgroundCube_vert,fragmentShader:Xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distance:{uniforms:on([fe.common,fe.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:Xe.distance_vert,fragmentShader:Xe.distance_frag},shadow:{uniforms:on([fe.lights,fe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};vi.physical={uniforms:on([vi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ge},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ge},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ge},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ge},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ge},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ge},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};var Uc={r:0,b:0,g:0},PE=new We,jm=new Ge;jm.set(-1,0,0,0,1,0,0,0,1);function IE(e,t,n,i,r,s){let o=new ze(0),a=r===!0?0:1,c,l,u=null,d=0,h=null;function f(S){let T=S.isScene===!0?S.background:null;if(T&&T.isTexture){let y=S.backgroundBlurriness>0;T=t.get(T,y)}return T}function m(S){let T=!1,y=f(S);if(y===null)p(o,a);else if(y&&y.isColor)p(y,1),T=!0;let w=e.xr.getEnvironmentBlendMode();if(w==="additive")n.buffers.color.setClear(0,0,0,1,s);else if(w==="alpha-blend")n.buffers.color.setClear(0,0,0,0,s);if(e.autoClear||T)n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}function _(S,T){let y=f(T);if(y&&(y.isCubeTexture||y.mapping===Ao)){if(l===void 0)l=new wt(new vr(1,1,1),new $n({name:"BackgroundCubeMaterial",uniforms:Xr(vi.backgroundCube.uniforms),vertexShader:vi.backgroundCube.vertexShader,fragmentShader:vi.backgroundCube.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(w,A,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l);if(l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(PE.makeRotationFromEuler(T.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1)l.material.uniforms.backgroundRotation.value.premultiply(jm);if(l.material.toneMapped=qe.getTransfer(y.colorSpace)!==vt,u!==y||d!==y.version||h!==e.toneMapping)l.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)}else if(y&&y.isTexture){if(c===void 0)c=new wt(new zo(2,2),new $n({name:"BackgroundMaterial",uniforms:Xr(vi.background.uniforms),vertexShader:vi.background.vertexShader,fragmentShader:vi.background.fragmentShader,side:mr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c);if(c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=qe.getTransfer(y.colorSpace)!==vt,y.matrixAutoUpdate===!0)y.updateMatrix();if(c.material.uniforms.uvTransform.value.copy(y.matrix),u!==y||d!==y.version||h!==e.toneMapping)c.material.needsUpdate=!0,u=y,d=y.version,h=e.toneMapping;c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null)}}function p(S,T){S.getRGB(Uc,uh(e)),n.buffers.color.setClear(Uc.r,Uc.g,Uc.b,T,s)}function g(){if(l!==void 0)l.geometry.dispose(),l.material.dispose(),l=void 0;if(c!==void 0)c.geometry.dispose(),c.material.dispose(),c=void 0}return{getClearColor:function(){return o},setClearColor:function(S,T=1){o.set(S),a=T,p(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(S){a=S,p(o,a)},render:m,addToRenderList:_,dispose:g}}function LE(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(C,L,K,I,G){let X=!1,P=d(C,I,K,L);if(s!==P)s=P,l(s.object);if(X=f(C,I,K,G),X)m(C,I,K,G);if(G!==null)t.update(G,e.ELEMENT_ARRAY_BUFFER);if(X||o){if(o=!1,y(C,L,K,I),G!==null)e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(G).buffer)}}function c(){return e.createVertexArray()}function l(C){return e.bindVertexArray(C)}function u(C){return e.deleteVertexArray(C)}function d(C,L,K,I){let G=I.wireframe===!0,X=i[L.id];if(X===void 0)X={},i[L.id]=X;let P=C.isInstancedMesh===!0?C.id:0,j=X[P];if(j===void 0)j={},X[P]=j;let z=j[K.id];if(z===void 0)z={},j[K.id]=z;let q=z[G];if(q===void 0)q=h(c()),z[G]=q;return q}function h(C){let L=[],K=[],I=[];for(let G=0;G<n;G++)L[G]=0,K[G]=0,I[G]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:K,attributeDivisors:I,object:C,attributes:{},index:null}}function f(C,L,K,I){let G=s.attributes,X=L.attributes,P=0,j=K.getAttributes();for(let z in j)if(j[z].location>=0){let Q=G[z],Me=X[z];if(Me===void 0){if(z==="instanceMatrix"&&C.instanceMatrix)Me=C.instanceMatrix;if(z==="instanceColor"&&C.instanceColor)Me=C.instanceColor}if(Q===void 0)return!0;if(Q.attribute!==Me)return!0;if(Me&&Q.data!==Me.data)return!0;P++}if(s.attributesNum!==P)return!0;if(s.index!==I)return!0;return!1}function m(C,L,K,I){let G={},X=L.attributes,P=0,j=K.getAttributes();for(let z in j)if(j[z].location>=0){let Q=X[z];if(Q===void 0){if(z==="instanceMatrix"&&C.instanceMatrix)Q=C.instanceMatrix;if(z==="instanceColor"&&C.instanceColor)Q=C.instanceColor}let Me={};if(Me.attribute=Q,Q&&Q.data)Me.data=Q.data;G[z]=Me,P++}s.attributes=G,s.attributesNum=P,s.index=I}function _(){let C=s.newAttributes;for(let L=0,K=C.length;L<K;L++)C[L]=0}function p(C){g(C,0)}function g(C,L){let K=s.newAttributes,I=s.enabledAttributes,G=s.attributeDivisors;if(K[C]=1,I[C]===0)e.enableVertexAttribArray(C),I[C]=1;if(G[C]!==L)e.vertexAttribDivisor(C,L),G[C]=L}function S(){let C=s.newAttributes,L=s.enabledAttributes;for(let K=0,I=L.length;K<I;K++)if(L[K]!==C[K])e.disableVertexAttribArray(K),L[K]=0}function T(C,L,K,I,G,X,P){if(P===!0)e.vertexAttribIPointer(C,L,K,G,X);else e.vertexAttribPointer(C,L,K,I,G,X)}function y(C,L,K,I){_();let G=I.attributes,X=K.getAttributes(),P=L.defaultAttributeValues;for(let j in X){let z=X[j];if(z.location>=0){let q=G[j];if(q===void 0){if(j==="instanceMatrix"&&C.instanceMatrix)q=C.instanceMatrix;if(j==="instanceColor"&&C.instanceColor)q=C.instanceColor}if(q!==void 0){let Q=q.normalized,Me=q.itemSize,ue=t.get(q);if(ue===void 0)continue;let{buffer:Ve,type:we,bytesPerElement:Z}=ue,re=we===e.INT||we===e.UNSIGNED_INT||q.gpuType===_u;if(q.isInterleavedBufferAttribute){let se=q.data,ye=se.stride,Ee=q.offset;if(se.isInstancedInterleavedBuffer){for(let Ae=0;Ae<z.locationSize;Ae++)g(z.location+Ae,se.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=se.meshPerAttribute*se.count}else for(let Ae=0;Ae<z.locationSize;Ae++)p(z.location+Ae);e.bindBuffer(e.ARRAY_BUFFER,Ve);for(let Ae=0;Ae<z.locationSize;Ae++)T(z.location+Ae,Me/z.locationSize,we,Q,ye*Z,(Ee+Me/z.locationSize*Ae)*Z,re)}else{if(q.isInstancedBufferAttribute){for(let se=0;se<z.locationSize;se++)g(z.location+se,q.meshPerAttribute);if(C.isInstancedMesh!==!0&&I._maxInstanceCount===void 0)I._maxInstanceCount=q.meshPerAttribute*q.count}else for(let se=0;se<z.locationSize;se++)p(z.location+se);e.bindBuffer(e.ARRAY_BUFFER,Ve);for(let se=0;se<z.locationSize;se++)T(z.location+se,Me/z.locationSize,we,Q,Me*Z,Me/z.locationSize*se*Z,re)}}else if(P!==void 0){let Q=P[j];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(z.location,Q);break;case 3:e.vertexAttrib3fv(z.location,Q);break;case 4:e.vertexAttrib4fv(z.location,Q);break;default:e.vertexAttrib1fv(z.location,Q)}}}}S()}function w(){M();for(let C in i){let L=i[C];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C]}}function A(C){if(i[C.id]===void 0)return;let L=i[C.id];for(let K in L){let I=L[K];for(let G in I){let X=I[G];for(let P in X)u(X[P].object),delete X[P];delete I[G]}}delete i[C.id]}function R(C){for(let L in i){let K=i[L];for(let I in K){let G=K[I];if(G[C.id]===void 0)continue;let X=G[C.id];for(let P in X)u(X[P].object),delete X[P];delete G[C.id]}}}function x(C){for(let L in i){let K=i[L],I=C.isInstancedMesh===!0?C.id:0,G=K[I];if(G===void 0)continue;for(let X in G){let P=G[X];for(let j in P)u(P[j].object),delete P[j];delete G[X]}if(delete K[I],Object.keys(K).length===0)delete i[L]}}function M(){if(k(),o=!0,s===r)return;s=r,l(s.object)}function k(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:M,resetDefaultState:k,dispose:w,releaseStatesOfGeometry:A,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:_,enableAttribute:p,disableUnusedAttributes:S}}function NE(e,t,n){let i;function r(c){i=c}function s(c,l){e.drawArrays(i,c,l),n.update(l,i,1)}function o(c,l,u){if(u===0)return;e.drawArraysInstanced(i,c,l,u),n.update(l,i,u)}function a(c,l,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,u);let h=0;for(let f=0;f<u;f++)h+=l[f];n.update(h,i,1)}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a}function DE(e,t,n,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){if(R!==_i&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT))return!1;return!0}function a(R){let x=R===gi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));if(R!==ii&&R!==Hi&&!x&&i.convert(R)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE))return!1;return!0}function c(R){if(R==="highp"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";R="mediump"}if(R==="mediump"){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let l=n.precision!==void 0?n.precision:"highp",u=c(l);if(u!==l)Le("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u;let d=n.logarithmicDepthBuffer===!0,h=n.reversedDepthBuffer===!0&&t.has("EXT_clip_control");if(n.reversedDepthBuffer===!0&&h===!1)Le("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),g=e.getParameter(e.MAX_VERTEX_ATTRIBS),S=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),T=e.getParameter(e.MAX_VARYING_VECTORS),y=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),w=e.getParameter(e.MAX_SAMPLES),A=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:p,maxAttributes:g,maxVertexUniforms:S,maxVaryings:T,maxFragmentUniforms:y,maxSamples:w,samples:A}}function OE(e){let t=this,n=null,i=0,r=!1,s=!1,o=new Vn,a=new Ge,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){n=u(d,h,0)},this.setState=function(d,h,f){let{clippingPlanes:m,clipIntersection:_,clipShadows:p}=d,g=e.get(d);if(!r||m===null||m.length===0||s&&!p)if(s)u(null);else l();else{let S=s?0:i,T=S*4,y=g.clippingState||null;c.value=y,y=u(m,h,T,f);for(let w=0;w!==T;++w)y[w]=n[w];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=S}};function l(){if(c.value!==n)c.value=n,c.needsUpdate=i>0;t.numPlanes=i,t.numIntersection=0}function u(d,h,f,m){let _=d!==null?d.length:0,p=null;if(_!==0){if(p=c.value,m!==!0||p===null){let g=f+_*4,S=h.matrixWorldInverse;if(a.getNormalMatrix(S),p===null||p.length<g)p=new Float32Array(g);for(let T=0,y=f;T!==_;++T,y+=4)o.copy(d[T]).applyMatrix4(S,a),o.normal.toArray(p,y),p[y+3]=o.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}var Ws=4,UE=6,FE=20,kE=256,$o=new qr,Am=new ze,Th=null,Rh=0,Ch=0,Ph=!1,zE=new U,Yr=new U;class jo{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=zE}=r;Th=this._renderer.getRenderTarget(),Rh=this._renderer.getActiveCubeFace(),Ch=this._renderer.getActiveMipmapLevel(),Ph=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=Cm(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=Rm(),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(Th,Rh,Ch),this._renderer.xr.enabled=Ph,e.scissorTest=!1,$s(e,0,0,e.width,e.height)}_fromTexture(e,t){if(e.mapping===Ps||e.mapping===Br)this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width);else this._setSize(e.image.width/4);Th=this._renderer.getRenderTarget(),Rh=this._renderer.getActiveCubeFace(),Ch=this._renderer.getActiveMipmapLevel(),Ph=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:qt,minFilter:qt,generateMipmaps:!1,type:gi,format:_i,colorSpace:wn,depthBuffer:!1},i=Tm(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){if(this._pingPongRenderTarget!==null)this._dispose();this._pingPongRenderTarget=Tm(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=BE(r)),this._blurMaterial=GE(r,e,t),this._ggxMaterial=VE(r,e,t)}return i}_compileMaterial(e){let t=new wt(new sn,e);this._renderer.compile(t,$o)}_sceneToCubeUV(e,t,n,i,r){let a=new Vt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,{autoClear:d,toneMapping:h}=u;if(u.getClearColor(Am),u.toneMapping=ti,u.autoClear=!1,u.state.buffers.depth.getReversed())u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null);if(this._backgroundBox===null)this._backgroundBox=new wt(new vr,new xi({name:"PMREM.Background",side:rn,depthWrite:!1,depthTest:!1}));let m=this._backgroundBox,_=m.material,p=!1,g=e.background;if(g){if(g.isColor)_.color.copy(g),e.background=null,p=!0}else _.color.copy(Am),p=!0;for(let S=0;S<6;S++){let T=S%3;if(T===0)a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+l[S],r.y,r.z);else if(T===1)a.up.set(0,0,c[S]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+l[S],r.z);else a.up.set(0,c[S],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+l[S]);let y=this._cubeSize;if($s(i,T*y,S>2?y:0,y,y),u.setRenderTarget(i),p)u.render(m,a);u.render(e,a)}u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ps||e.mapping===Br;if(i){if(this._cubemapMaterial===null)this._cubemapMaterial=Cm();this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=Rm();let r=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;let o=r.uniforms;o.envMap.value=e;let a=this._cubeSize;$s(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,$o)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let i=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[n];o.material=s;let a=s.uniforms,c=n/(this._lodMeshes.length-1),l=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-l*l),d=c*1.25,h=u*d,{_lodMax:f}=this,m=this._sizeLods[n],_=3*m*(n>f-Ws?n-f+Ws:0),p=4*(this._cubeSize-m);a.envMap.value=e.texture,a.roughness.value=h,a.mipInt.value=f-t,$s(r,_,p,3*m,2*m),i.setRenderTarget(r),i.render(o,$o),a.envMap.value=r.texture,a.roughness.value=0,a.mipInt.value=f-n,$s(e,_,p,3*m,2*m),i.setRenderTarget(e),i.render(o,$o)}_blur(e,t,n,i){let r=this._pingPongRenderTarget,s=Math.min(i,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,s),this._blurPass(r,e,n,n,s)}_blurPass(e,t,n,i,r){let s=this._renderer,o=this._blurMaterial,a=this._lodMeshes[i];a.material=o;let c=o.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let l=this._sizeLods[i],u=3*l*(i>this._lodMax-Ws?i-this._lodMax+Ws:0),d=4*(this._cubeSize-l);$s(t,u,d,3*l,2*l),s.setRenderTarget(t),s.render(a,$o)}}function BE(e){let t=[],n=[],i=e,r=e-Ws+1+UE;for(let s=0;s<r;s++){let o=Math.pow(2,i);t.push(o);let a=1/(o-2),c=-a,l=1+a,u=[c,c,l,c,l,l,c,c,l,l,c,l],d=6,h=6,f=3,m=new Float32Array(f*h*d),_=new Float32Array(f*h*d);for(let g=0;g<d;g++){let S=g%3*2/3-1,T=g>2?0:-1,y=[S,T,0,S+0.6666666666666666,T,0,S+0.6666666666666666,T+1,0,S,T,0,S+0.6666666666666666,T+1,0,S,T+1,0];m.set(y,f*h*g);for(let w=0;w<h;w++){let A=u[w*2]*2-1,R=u[w*2+1]*2-1;if(g===0)Yr.set(1,R,A);else if(g===1)Yr.set(-A,1,-R);else if(g===2)Yr.set(-A,R,1);else if(g===3)Yr.set(-1,R,-A);else if(g===4)Yr.set(-A,-1,R);else Yr.set(A,R,-1);Yr.toArray(_,(g*h+w)*f)}}let p=new sn;if(p.setAttribute("position",new jt(m,f)),p.setAttribute("outputDirection",new jt(_,f)),n.push(new wt(p,null)),i>Ws)i--}return{lodMeshes:n,sizeLods:t}}function Tm(e,t,n){let i=new En(e,t,n);return i.texture.mapping=Ao,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function $s(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function VE(e,t,n){return new $n({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kE,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:kc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4048,7 +4048,7 @@ void main() {
gl_FragColor = vec4(prefilteredColor, 1.0);
}
- `,blending:di,depthTest:!1,depthWrite:!1})}function LE(e,t,n){return new Bn({name:"SphericalGaussianBlur",defines:{SAMPLES:TE,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:Ic(),fragmentShader:`
+ `,blending:pi,depthTest:!1,depthWrite:!1})}function GE(e,t,n){return new $n({name:"SphericalGaussianBlur",defines:{SAMPLES:FE,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:kc(),fragmentShader:`
precision highp float;
precision highp int;
@@ -4108,7 +4108,7 @@ void main() {
gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
}
- `,blending:di,depthTest:!1,depthWrite:!1})}function vm(){return new Bn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ic(),fragmentShader:`
+ `,blending:pi,depthTest:!1,depthWrite:!1})}function Rm(){return new $n({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:kc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4127,7 +4127,7 @@ void main() {
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
- `,blending:di,depthTest:!1,depthWrite:!1})}function bm(){return new Bn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ic(),fragmentShader:`
+ `,blending:pi,depthTest:!1,depthWrite:!1})}function Cm(){return new $n({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:kc(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -4143,7 +4143,7 @@ void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
- `,blending:di,depthTest:!1,depthWrite:!1})}function Ic(){return`
+ `,blending:pi,depthTest:!1,depthWrite:!1})}function kc(){return`
precision mediump float;
precision mediump int;
@@ -4158,7 +4158,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}class Th extends Mn{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 xc(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 Oh extends En{constructor(e=1,t={}){super(e,e,t);this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new Ec(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -4193,7 +4193,7 @@ void main() {
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},i=new mr(5,5,5),r=new Bn({name:"CubemapFromEquirect",uniforms:Gr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:rn,blending:di});r.uniforms.tEquirect.value=t;let s=new Mt(i,r),o=t.minFilter;if(t.minFilter===fi)t.minFilter=qt;return new hh(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 NE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,f=!1){if(h===null||h===void 0)return null;if(f)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let f=h.mapping;if(f===Ka||f===Qa)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let _=new Th(m.height);return _.fromEquirectangularTexture(e,h),t.set(h,_),h.addEventListener("dispose",l),a(_.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===Ka||f===Qa,_=f===Es||f===Or;if(m||_){let p=n.get(h),g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g){if(i===null)i=new Go(e);return p=m?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let S=h.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new Go(e);return p=m?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,f){if(f===Ka)h.mapping=Es;else if(f===Qa)h.mapping=Or;return h}function c(h){let f=0,m=6;for(let _=0;_<m;_++)if(h[_]!==void 0)f++;return f===m}function l(h){let f=h.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function DE(e){let t={};function n(i){if(t[i]!==void 0)return t[i];let r=e.getExtension(i);return t[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){let r=n(i);if(r===null)Nr("WebGLRenderer: "+i+" extension not supported.");return r}}}function OE(e,t,n,i){let r={},s=new WeakMap;function o(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);if(f)t.remove(f),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(d,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(d){let h=d.attributes;for(let f in h)t.update(h[f],e.ARRAY_BUFFER)}function l(d){let h=[],f=d.index,m=d.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];h.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;h.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?pc:fc)(h,1);p.version=_;let g=s.get(d);if(g)t.remove(g);s.set(d,p)}function u(d){let h=s.get(d);if(h){let f=d.index;if(f!==null){if(h.version<f.version)l(d)}}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function UE(e,t,n){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,h){e.drawElements(i,h,s,d*o),n.update(h,i,1)}function l(d,h,f){if(f===0)return;e.drawElementsInstanced(i,h,s,d*o,f),n.update(h,i,f)}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,d,0,f);let _=0;for(let p=0;p<f;p++)_+=h[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function FE(e){let t={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(n.calls++,o){case e.TRIANGLES:n.triangles+=a*(s/3);break;case e.LINES:n.lines+=a*(s/2);break;case e.LINE_STRIP:n.lines+=a*(s-1);break;case e.LINE_LOOP:n.lines+=a*s;break;case e.POINTS:n.points+=a*s;break;default:ke("WebGLInfo: Unknown draw mode:",o);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:t,render:n,programs:null,autoReset:!0,reset:r,update:i}}function zE(e,t,n){let i=new WeakMap,r=new ft;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*d),R=new hc(A,y,w,d);R.type=Gi,R.needsUpdate=!0;let x=T*4;for(let z=0;z<d;z++){let C=p[z],L=g[z],K=S[z],I=y*w*4*z;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}h={count:d,texture:R,size:new Ue(y,w)},i.set(a,h),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function kE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,d=l.geometry,h=t.get(l,d);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var BE={[iu]:"LINEAR_TONE_MAPPING",[ru]:"REINHARD_TONE_MAPPING",[su]:"CINEON_TONE_MAPPING",[yo]:"ACES_FILMIC_TONE_MAPPING",[au]:"AGX_TONE_MAPPING",[cu]:"NEUTRAL_TONE_MAPPING",[ou]:"CUSTOM_TONE_MAPPING"};function VE(e,t,n,i,r,s){let o=new Mn(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 sn;l.setAttribute("position",new _n([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new _n([0,2,0,0,2,0],2));let u=new ih({uniforms:{tDiffuse:{value:null}},vertexShader:`
+ `},i=new vr(5,5,5),r=new $n({name:"CubemapFromEquirect",uniforms:Xr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:rn,blending:pi});r.uniforms.tEquirect.value=t;let s=new wt(i,r),o=t.minFilter;if(t.minFilter===mi)t.minFilter=qt;return new yh(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 HE(e){let t=new WeakMap,n=new WeakMap,i=null;function r(h,f=!1){if(h===null||h===void 0)return null;if(f)return o(h);return s(h)}function s(h){if(h&&h.isTexture){let f=h.mapping;if(f===sc||f===oc)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let _=new Oh(m.height);return _.fromEquirectangularTexture(e,h),t.set(h,_),h.addEventListener("dispose",l),a(_.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===sc||f===oc,_=f===Ps||f===Br;if(m||_){let p=n.get(h),g=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g){if(i===null)i=new jo(e);return p=m?i.fromEquirectangular(h,p):i.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),p.texture}else if(p!==void 0)return p.texture;else{let S=h.image;if(m&&S&&S.height>0||_&&S&&c(S)){if(i===null)i=new jo(e);return p=m?i.fromEquirectangular(h):i.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,n.set(h,p),h.addEventListener("dispose",u),p.texture}else return null}}}return h}function a(h,f){if(f===sc)h.mapping=Ps;else if(f===oc)h.mapping=Br;return h}function c(h){let f=0,m=6;for(let _=0;_<m;_++)if(h[_]!==void 0)f++;return f===m}function l(h){let f=h.target;f.removeEventListener("dispose",l);let m=t.get(f);if(m!==void 0)t.delete(f),m.dispose()}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=n.get(f);if(m!==void 0)n.delete(f),m.dispose()}function d(){if(t=new WeakMap,n=new WeakMap,i!==null)i.dispose(),i=null}return{get:r,dispose:d}}function $E(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)kr("WebGLRenderer: "+i+" extension not supported.");return r}}}function WE(e,t,n,i){let r={},s=new WeakMap;function o(d){let h=d.target;if(h.index!==null)t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);if(f)t.remove(f),s.delete(h);if(i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0)delete h._maxInstanceCount;n.memory.geometries--}function a(d,h){if(r[h.id]===!0)return h;return h.addEventListener("dispose",o),r[h.id]=!0,n.memory.geometries++,h}function c(d){let h=d.attributes;for(let f in h)t.update(h[f],e.ARRAY_BUFFER)}function l(d){let h=[],f=d.index,m=d.attributes.position,_=0;if(m===void 0)return;if(f!==null){let S=f.array;_=f.version;for(let T=0,y=S.length;T<y;T+=3){let w=S[T+0],A=S[T+1],R=S[T+2];h.push(w,A,A,R,R,w)}}else{let S=m.array;_=m.version;for(let T=0,y=S.length/3-1;T<y;T+=3){let w=T+0,A=T+1,R=T+2;h.push(w,A,A,R,R,w)}}let p=new(m.count>=65535?bc:vc)(h,1);p.version=_;let g=s.get(d);if(g)t.remove(g);s.set(d,p)}function u(d){let h=s.get(d);if(h){let f=d.index;if(f!==null){if(h.version<f.version)l(d)}}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function ZE(e,t,n){let i;function r(d){i=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,h){e.drawElements(i,h,s,d*o),n.update(h,i,1)}function l(d,h,f){if(f===0)return;e.drawElementsInstanced(i,h,s,d*o,f),n.update(h,i,f)}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,s,d,0,f);let _=0;for(let p=0;p<f;p++)_+=h[p];n.update(_,i,1)}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u}function XE(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:Be("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 jE(e,t,n){let i=new WeakMap,r=new pt;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let M=function(){R.dispose(),i.delete(a),a.removeEventListener("dispose",M)};if(h!==void 0)h.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],T=0;if(f===!0)T=1;if(m===!0)T=2;if(_===!0)T=3;let y=a.attributes.position.count*T,w=1;if(y>t.maxTextureSize)w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize;let A=new Float32Array(y*w*4*d),R=new xc(A,y,w,d);R.type=Hi,R.needsUpdate=!0;let x=T*4;for(let k=0;k<d;k++){let C=p[k],L=g[k],K=S[k],I=y*w*4*k;for(let G=0;G<C.count;G++){let X=G*x;if(f===!0)r.fromBufferAttribute(C,G),A[I+X+0]=r.x,A[I+X+1]=r.y,A[I+X+2]=r.z,A[I+X+3]=0;if(m===!0)r.fromBufferAttribute(L,G),A[I+X+4]=r.x,A[I+X+5]=r.y,A[I+X+6]=r.z,A[I+X+7]=0;if(_===!0)r.fromBufferAttribute(K,G),A[I+X+8]=r.x,A[I+X+9]=r.y,A[I+X+10]=r.z,A[I+X+11]=K.itemSize===4?r.w:1}}h={count:d,texture:R,size:new Fe(y,w)},i.set(a,h),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(e,"morphTexture",o.morphTexture,n);else{let f=0;for(let _=0;_<l.length;_++)f+=l[_];let m=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",l)}c.getUniforms().setValue(e,"morphTargetsTexture",h.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",h.size)}return{update:s}}function qE(e,t,n,i,r){let s=new WeakMap;function o(l){let u=r.render.frame,d=l.geometry,h=t.get(l,d);if(s.get(h)!==u)t.update(h),s.set(h,u);if(l.isInstancedMesh){if(l.hasEventListener("dispose",c)===!1)l.addEventListener("dispose",c);if(s.get(l)!==u){if(n.update(l.instanceMatrix,e.ARRAY_BUFFER),l.instanceColor!==null)n.update(l.instanceColor,e.ARRAY_BUFFER);s.set(l,u)}}if(l.isSkinnedMesh){let f=l.skeleton;if(s.get(f)!==u)f.update(),s.set(f,u)}return h}function a(){s=new WeakMap}function c(l){let u=l.target;if(u.removeEventListener("dispose",c),i.releaseStatesOfObject(u),n.remove(u.instanceMatrix),u.instanceColor!==null)n.remove(u.instanceColor)}return{update:o,dispose:a}}var YE={[hu]:"LINEAR_TONE_MAPPING",[du]:"REINHARD_TONE_MAPPING",[fu]:"CINEON_TONE_MAPPING",[Eo]:"ACES_FILMIC_TONE_MAPPING",[mu]:"AGX_TONE_MAPPING",[gu]:"NEUTRAL_TONE_MAPPING",[pu]:"CUSTOM_TONE_MAPPING"};function JE(e,t,n,i,r,s){let o=new En(t,n,{type:e,depthBuffer:r,stencilBuffer:s,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=new sn;l.setAttribute("position",new xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new xn([0,2,0,0,2,0],2));let u=new hh({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}),d=new Mt(l,u),h=new $r(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new Mn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1}),c=new Mn(w,A,{type:pi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===Jn&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=Jn,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},je.getTransfer(f)===yt)u.defines.SRGB_TRANSFER="";let x=BE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(d,h),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var Vm=new Nt,Eh=new Vr(1,1),Gm=new hc,Hm=new eh,$m=new xc,Sm=[],Mm=[],wm=new Float32Array(16),Em=new Float32Array(9),Am=new Float32Array(4);function Vs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Sm[r];if(s===void 0)s=new Float32Array(r),Sm[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function Ht(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Lc(e,t){let n=Mm[t];if(n===void 0)n=new Int32Array(t),Mm[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function GE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function HE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function $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.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function WE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function ZE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Am.set(i),e.uniformMatrix2fv(this.addr,!1,Am),$t(n,i)}}function XE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Em.set(i),e.uniformMatrix3fv(this.addr,!1,Em),$t(n,i)}}function jE(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;wm.set(i),e.uniformMatrix4fv(this.addr,!1,wm),$t(n,i)}}function qE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function YE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function JE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function KE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function QE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function eA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function tA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function nA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function iA(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)Eh.compareFunction=n.isReversedDepthBuffer()?uc:lc,s=Eh;else s=Vm;n.setTexture2D(t||s,r)}function rA(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||Hm,r)}function sA(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||$m,r)}function oA(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||Gm,r)}function aA(e){switch(e){case 5126:return GE;case 35664:return HE;case 35665:return $E;case 35666:return WE;case 35674:return ZE;case 35675:return XE;case 35676:return jE;case 5124:case 35670:return qE;case 35667:case 35671:return YE;case 35668:case 35672:return JE;case 35669:case 35673:return KE;case 5125:return QE;case 36294:return eA;case 36295:return tA;case 36296:return nA;case 35678:case 36198:case 36298:case 36306:case 35682:return iA;case 35679:case 36299:case 36307:return rA;case 35680:case 36300:case 36308:case 36293:return sA;case 36289:case 36303:case 36311:case 36292:return oA}}function cA(e,t){e.uniform1fv(this.addr,t)}function lA(e,t){let n=Vs(t,this.size,2);e.uniform2fv(this.addr,n)}function uA(e,t){let n=Vs(t,this.size,3);e.uniform3fv(this.addr,n)}function hA(e,t){let n=Vs(t,this.size,4);e.uniform4fv(this.addr,n)}function dA(e,t){let n=Vs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function fA(e,t){let n=Vs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function pA(e,t){let n=Vs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function mA(e,t){e.uniform1iv(this.addr,t)}function gA(e,t){e.uniform2iv(this.addr,t)}function _A(e,t){e.uniform3iv(this.addr,t)}function xA(e,t){e.uniform4iv(this.addr,t)}function yA(e,t){e.uniform1uiv(this.addr,t)}function vA(e,t){e.uniform2uiv(this.addr,t)}function bA(e,t){e.uniform3uiv(this.addr,t)}function SA(e,t){e.uniform4uiv(this.addr,t)}function MA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Eh;else o=Vm;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function wA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Hm,s[o])}function EA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||$m,s[o])}function AA(e,t,n){let i=this.cache,r=t.length,s=Lc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Gm,s[o])}function TA(e){switch(e){case 5126:return cA;case 35664:return lA;case 35665:return uA;case 35666:return hA;case 35674:return dA;case 35675:return fA;case 35676:return pA;case 5124:case 35670:return mA;case 35667:case 35671:return gA;case 35668:case 35672:return _A;case 35669:case 35673:return xA;case 5125:return yA;case 36294:return vA;case 36295:return bA;case 36296:return SA;case 35678:case 36198:case 36298:case 36306:case 35682:return MA;case 35679:case 36299:case 36307:return wA;case 35680:case 36300:case 36308:case 36293:return EA;case 36289:case 36303:case 36311:case 36292:return AA}}class Wm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=aA(t.type)}}class Zm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=TA(t.type)}}class Xm{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 Mh=/(\w+)(\])?(\[|\.)?/g;function Tm(e,t){e.seq.push(t),e.map[t.id]=t}function RA(e,t,n){let i=e.name,r=i.length;Mh.lastIndex=0;while(!0){let s=Mh.exec(i),o=Mh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Tm(n,l===void 0?new Wm(a,e,t):new Zm(a,e,t));break}else{let d=n.map[a];if(d===void 0)d=new Xm(a),Tm(n,d);n=d}}}class Vo{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);RA(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 Rm(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var CA=37297,PA=0;function IA(e,t){let n=e.split(`
+ }`,depthTest:!1,depthWrite:!1}),d=new wt(l,u),h=new qr(-1,1,1,-1,0,1),f=null,m=null,_=!1,p,g=null,S=[],T=!1;this.setSize=function(y,w){if(o.setSize(y,w),a!==null)a.setSize(y,w);if(c!==null)c.setSize(y,w);for(let A=0;A<S.length;A++){let R=S[A];if(R.setSize)R.setSize(y,w)}},this.setEffects=function(y){S=y,T=S.length>0&&S[0].isRenderPass===!0;let{width:w,height:A}=o;if(S.length>0&&a===null)a=new En(w,A,{type:gi,depthBuffer:!1,stencilBuffer:!1}),c=new En(w,A,{type:gi,depthBuffer:!1,stencilBuffer:!1});for(let R=0;R<S.length;R++){let x=S[R];if(x.setSize)x.setSize(w,A)}},this.begin=function(y,w){if(_)return!1;if(y.toneMapping===ti&&S.length===0)return!1;if(g=w,w!==null){let{width:A,height:R}=w;if(o.width!==A||o.height!==R)this.setSize(A,R)}if(T===!1)y.setRenderTarget(o);return p=y.toneMapping,y.toneMapping=ti,!0},this.hasRenderPass=function(){return T},this.end=function(y,w){y.toneMapping=p,_=!0;let A=o,R=a;for(let x=0;x<S.length;x++){let M=S[x];if(M.enabled===!1)continue;if(M.render(y,R,A,w),M.needsSwap!==!1)A=R,R=R===a?c:a}if(f!==y.outputColorSpace||m!==y.toneMapping){if(f=y.outputColorSpace,m=y.toneMapping,u.defines={},qe.getTransfer(f)===vt)u.defines.SRGB_TRANSFER="";let x=YE[m];if(x)u.defines[x]="";u.needsUpdate=!0}u.uniforms.tDiffuse.value=A.texture,y.setRenderTarget(g),y.render(d,h),g=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){if(o.dispose(),a!==null)a.dispose();if(c!==null)c.dispose();l.dispose(),u.dispose()}}var qm=new Nt,Nh=new Zr(1,1),Ym=new xc,Jm=new ch,Km=new Ec,Pm=[],Im=[],Lm=new Float32Array(16),Nm=new Float32Array(9),Dm=new Float32Array(4);function Zs(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,s=Pm[r];if(s===void 0)s=new Float32Array(r),Pm[r]=s;if(t!==0){i.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=n,e[o].toArray(s,a)}return s}function Ht(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function $t(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function zc(e,t){let n=Im[t];if(n===void 0)n=new Int32Array(t),Im[t]=n;for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function KE(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1f(this.addr,t),n[0]=t}function QE(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2fv(this.addr,t),$t(n,t)}}function eA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else if(t.r!==void 0){if(n[0]!==t.r||n[1]!==t.g||n[2]!==t.b)e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b}else{if(Ht(n,t))return;e.uniform3fv(this.addr,t),$t(n,t)}}function tA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4fv(this.addr,t),$t(n,t)}}function nA(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Dm.set(i),e.uniformMatrix2fv(this.addr,!1,Dm),$t(n,i)}}function iA(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Nm.set(i),e.uniformMatrix3fv(this.addr,!1,Nm),$t(n,i)}}function rA(e,t){let n=this.cache,i=t.elements;if(i===void 0){if(Ht(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),$t(n,t)}else{if(Ht(n,i))return;Lm.set(i),e.uniformMatrix4fv(this.addr,!1,Lm),$t(n,i)}}function sA(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1i(this.addr,t),n[0]=t}function oA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2iv(this.addr,t),$t(n,t)}}function aA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3iv(this.addr,t),$t(n,t)}}function cA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4iv(this.addr,t),$t(n,t)}}function lA(e,t){let n=this.cache;if(n[0]===t)return;e.uniform1ui(this.addr,t),n[0]=t}function uA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y)e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y}else{if(Ht(n,t))return;e.uniform2uiv(this.addr,t),$t(n,t)}}function hA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z)e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z}else{if(Ht(n,t))return;e.uniform3uiv(this.addr,t),$t(n,t)}}function dA(e,t){let n=this.cache;if(t.x!==void 0){if(n[0]!==t.x||n[1]!==t.y||n[2]!==t.z||n[3]!==t.w)e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w}else{if(Ht(n,t))return;e.uniform4uiv(this.addr,t),$t(n,t)}}function fA(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)Nh.compareFunction=n.isReversedDepthBuffer()?_c:gc,s=Nh;else s=qm;n.setTexture2D(t||s,r)}function pA(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||Jm,r)}function mA(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||Km,r)}function gA(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||Ym,r)}function _A(e){switch(e){case 5126:return KE;case 35664:return QE;case 35665:return eA;case 35666:return tA;case 35674:return nA;case 35675:return iA;case 35676:return rA;case 5124:case 35670:return sA;case 35667:case 35671:return oA;case 35668:case 35672:return aA;case 35669:case 35673:return cA;case 5125:return lA;case 36294:return uA;case 36295:return hA;case 36296:return dA;case 35678:case 36198:case 36298:case 36306:case 35682:return fA;case 35679:case 36299:case 36307:return pA;case 35680:case 36300:case 36308:case 36293:return mA;case 36289:case 36303:case 36311:case 36292:return gA}}function xA(e,t){e.uniform1fv(this.addr,t)}function yA(e,t){let n=Zs(t,this.size,2);e.uniform2fv(this.addr,n)}function vA(e,t){let n=Zs(t,this.size,3);e.uniform3fv(this.addr,n)}function bA(e,t){let n=Zs(t,this.size,4);e.uniform4fv(this.addr,n)}function SA(e,t){let n=Zs(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function MA(e,t){let n=Zs(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function wA(e,t){let n=Zs(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function EA(e,t){e.uniform1iv(this.addr,t)}function AA(e,t){e.uniform2iv(this.addr,t)}function TA(e,t){e.uniform3iv(this.addr,t)}function RA(e,t){e.uniform4iv(this.addr,t)}function CA(e,t){e.uniform1uiv(this.addr,t)}function PA(e,t){e.uniform2uiv(this.addr,t)}function IA(e,t){e.uniform3uiv(this.addr,t)}function LA(e,t){e.uniform4uiv(this.addr,t)}function NA(e,t,n){let i=this.cache,r=t.length,s=zc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);let o;if(this.type===e.SAMPLER_2D_SHADOW)o=Nh;else o=qm;for(let a=0;a!==r;++a)n.setTexture2D(t[a]||o,s[a])}function DA(e,t,n){let i=this.cache,r=t.length,s=zc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture3D(t[o]||Jm,s[o])}function OA(e,t,n){let i=this.cache,r=t.length,s=zc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTextureCube(t[o]||Km,s[o])}function UA(e,t,n){let i=this.cache,r=t.length,s=zc(n,r);if(!Ht(i,s))e.uniform1iv(this.addr,s),$t(i,s);for(let o=0;o!==r;++o)n.setTexture2DArray(t[o]||Ym,s[o])}function FA(e){switch(e){case 5126:return xA;case 35664:return yA;case 35665:return vA;case 35666:return bA;case 35674:return SA;case 35675:return MA;case 35676:return wA;case 5124:case 35670:return EA;case 35667:case 35671:return AA;case 35668:case 35672:return TA;case 35669:case 35673:return RA;case 5125:return CA;case 36294:return PA;case 36295:return IA;case 36296:return LA;case 35678:case 36198:case 36298:case 36306:case 35682:return NA;case 35679:case 36299:case 36307:return DA;case 35680:case 36300:case 36308:case 36293:return OA;case 36289:case 36303:case 36311:case 36292:return UA}}class Qm{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=_A(t.type)}}class eg{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=FA(t.type)}}class tg{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 Ih=/(\w+)(\])?(\[|\.)?/g;function Om(e,t){e.seq.push(t),e.map[t.id]=t}function kA(e,t,n){let i=e.name,r=i.length;Ih.lastIndex=0;while(!0){let s=Ih.exec(i),o=Ih.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c)a=a|0;if(l===void 0||l==="["&&o+2===r){Om(n,l===void 0?new Qm(a,e,t):new eg(a,e,t));break}else{let d=n.map[a];if(d===void 0)d=new tg(a),Om(n,d);n=d}}}class Xo{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);kA(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 Um(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var zA=37297,BA=0;function VA(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 Cm=new Ve;function LA(e){je._getMatrix(Cm,je.workingColorSpace,e);let t=`mat3( ${Cm.elements.map((n)=>n.toFixed(4))} )`;switch(je.getTransfer(e)){case ju:return[t,"LinearTransferOETF"];case yt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function Pm(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 Fm=new Ge;function GA(e){qe._getMatrix(Fm,qe.workingColorSpace,e);let t=`mat3( ${Fm.elements.map((n)=>n.toFixed(4))} )`;switch(qe.getTransfer(e)){case nh:return[t,"LinearTransferOETF"];case vt:return[t,"sRGBTransferOETF"];default:return Le("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function km(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+`
-`+IA(e.getShaderSource(t),a)}else return s}function NA(e,t){let n=LA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
-`)}var DA={[iu]:"Linear",[ru]:"Reinhard",[su]:"Cineon",[yo]:"ACESFilmic",[au]:"AgX",[cu]:"Neutral",[ou]:"Custom"};function OA(e,t){let n=DA[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Pc=new U;function UA(){je.getLuminanceCoefficients(Pc);let e=Pc.x.toFixed(4),t=Pc.y.toFixed(4),n=Pc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
-`)}function FA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bo).join(`
-`)}function zA(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 kA(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 Im(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 Lm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var BA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ah(e){return e.replace(BA,GA)}var VA=new Map;function GA(e,t){let n=Ze[t];if(n===void 0){let i=VA.get(t);if(i!==void 0)n=Ze[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Ah(n)}var HA=/#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 Nm(e){return e.replace(HA,$A)}function $A(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 Dm(e){let t=`precision ${e.precision} float;
+`+VA(e.getShaderSource(t),a)}else return s}function HA(e,t){let n=GA(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
+`)}var $A={[hu]:"Linear",[du]:"Reinhard",[fu]:"Cineon",[Eo]:"ACESFilmic",[mu]:"AgX",[gu]:"Neutral",[pu]:"Custom"};function WA(e,t){let n=$A[t];if(n===void 0)return Le("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}var Fc=new U;function ZA(){qe.getLuminanceCoefficients(Fc);let e=Fc.x.toFixed(4),t=Fc.y.toFixed(4),n=Fc.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join(`
+`)}function XA(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Zo).join(`
+`)}function jA(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 qA(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 Zo(e){return e!==""}function zm(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 Bm(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var YA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Dh(e){return e.replace(YA,KA)}var JA=new Map;function KA(e,t){let n=Xe[t];if(n===void 0){let i=JA.get(t);if(i!==void 0)n=Xe[i],Le('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Dh(n)}var QA=/#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 Vm(e){return e.replace(QA,eT)}function eT(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 Gm(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 WA={[_o]:"SHADOWMAP_TYPE_PCF",[Ms]:"SHADOWMAP_TYPE_VSM"};function ZA(e){return WA[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var XA={[Es]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE",[vo]:"ENVMAP_TYPE_CUBE_UV"};function jA(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return XA[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var qA={[Or]:"ENVMAP_MODE_REFRACTION"};function YA(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return qA[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var JA={[Gp]:"ENVMAP_BLENDING_MULTIPLY",[Hp]:"ENVMAP_BLENDING_MIX",[$p]:"ENVMAP_BLENDING_ADD"};function KA(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return JA[e.combine]||"ENVMAP_BLENDING_NONE"}function QA(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 eT(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=ZA(n),l=jA(n),u=YA(n),d=KA(n),h=QA(n),f=FA(n),m=zA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`
-`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Bo).join(`
+#define LOW_PRECISION`;return t}var tT={[Mo]:"SHADOWMAP_TYPE_PCF",[Rs]:"SHADOWMAP_TYPE_VSM"};function nT(e){return tT[e.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var iT={[Ps]:"ENVMAP_TYPE_CUBE",[Br]:"ENVMAP_TYPE_CUBE",[Ao]:"ENVMAP_TYPE_CUBE_UV"};function rT(e){if(e.envMap===!1)return"ENVMAP_TYPE_CUBE";return iT[e.envMapMode]||"ENVMAP_TYPE_CUBE"}var sT={[Br]:"ENVMAP_MODE_REFRACTION"};function oT(e){if(e.envMap===!1)return"ENVMAP_MODE_REFLECTION";return sT[e.envMapMode]||"ENVMAP_MODE_REFLECTION"}var aT={[Yp]:"ENVMAP_BLENDING_MULTIPLY",[Jp]:"ENVMAP_BLENDING_MIX",[Kp]:"ENVMAP_BLENDING_ADD"};function cT(e){if(e.envMap===!1)return"ENVMAP_BLENDING_NONE";return aT[e.combine]||"ENVMAP_BLENDING_NONE"}function lT(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 uT(e,t,n,i){let r=e.getContext(),{defines:s,vertexShader:o,fragmentShader:a}=n,c=nT(n),l=rT(n),u=oT(n),d=cT(n),h=lT(n),f=XA(n),m=jA(s),_=r.createProgram(),p,g,S=n.glslVersion?"#version "+n.glslVersion+`
+`:"";if(n.isRawShaderMaterial){if(p=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Zo).join(`
`),p.length>0)p+=`
-`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Bo).join(`
+`;if(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(Zo).join(`
`),g.length>0)g+=`
-`}else p=[Dm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
-`].filter(Bo).join(`
-`),g=[Dm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Jn?"#define TONE_MAPPING":"",n.toneMapping!==Jn?Ze.tonemapping_pars_fragment:"",n.toneMapping!==Jn?OA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ze.colorspace_pars_fragment,NA("linearToOutputTexel",n.outputColorSpace),UA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
-`].filter(Bo).join(`
-`);if(o=Ah(o),o=Im(o,n),o=Lm(o,n),a=Ah(a),a=Im(a,n),a=Lm(a,n),o=Nm(o),a=Nm(a),n.isRawShaderMaterial!==!0)S=`#version 300 es
+`}else p=[Gm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`
+`].filter(Zo).join(`
+`),g=[Gm(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.retroreflection?"#define USE_RETROREFLECTION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ti?"#define TONE_MAPPING":"",n.toneMapping!==ti?Xe.tonemapping_pars_fragment:"",n.toneMapping!==ti?WA("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Xe.colorspace_pars_fragment,HA("linearToOutputTexel",n.outputColorSpace),ZA(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
+`].filter(Zo).join(`
+`);if(o=Dh(o),o=zm(o,n),o=Bm(o,n),a=Dh(a),a=zm(a,n),a=Bm(a,n),o=Vm(o),a=Vm(a),n.isRawShaderMaterial!==!0)S=`#version 300 es
`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
-`+p,g=["#define varying in",n.glslVersion===qu?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===qu?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
+`+p,g=["#define varying in",n.glslVersion===ih?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ih?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
-`+g;let T=S+p+o,y=S+g+a,w=Rm(r,r.VERTEX_SHADER,T),A=Rm(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,k=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=Pm(r,w,"vertex"),Q=Pm(r,A,"fragment");ke("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
+`+g;let T=S+p+o,y=S+g+a,w=Um(r,r.VERTEX_SHADER,T),A=Um(r,r.FRAGMENT_SHADER,y);if(r.attachShader(_,w),r.attachShader(_,A),n.index0AttributeName!==void 0)r.bindAttribLocation(_,0,n.index0AttributeName);else if(n.hasPositionAttribute===!0)r.bindAttribLocation(_,0,"position");r.linkProgram(_);function R(C){if(e.debug.checkShaderErrors){let L=r.getProgramInfoLog(_)||"",K=r.getShaderInfoLog(w)||"",I=r.getShaderInfoLog(A)||"",G=L.trim(),X=K.trim(),P=I.trim(),j=!0,z=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(j=!1,typeof e.debug.onShaderError==="function")e.debug.onShaderError(r,_,w,A);else{let q=km(r,w,"vertex"),Q=km(r,A,"fragment");Be("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
Material Name: `+C.name+`
Material Type: `+C.type+`
Program Info Log: `+G+`
`+q+`
-`+Q)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")k=!1;if(k)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new Vo(r,_),M=kA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let z=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(z===!1)z=r.getProgramParameter(_,CA);return z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=PA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var tT=0;class jm{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 qm(e),t.set(e,n);return n}}class qm{constructor(e){this.id=tT++,this.code=e,this.usedTimes=0}}function nT(e){return e===kr||e===oc||e===ac}function iT(e,t,n,i,r,s){let o=new dc,a=new jm,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,M,z,C,L,K){let I=C.fog,G=L.geometry,X=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,j=t.get(x.envMap||X,P),k=!!j&&j.mapping===vo?j.image.height:null,q=f[x.type];if(x.precision!==null){if(h=i.getMaxPrecision(x.precision),h!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead.")}let Q=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Me=Q!==void 0?Q.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Be,we,Z,re;if(q){let bt=xi[q];Be=bt.vertexShader,we=bt.fragmentShader}else{Be=x.vertexShader,we=x.fragmentShader;let bt=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,bt,lt),Z=bt.id,re=lt.id}let se=e.getRenderTarget(),xe=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,Et=!!x.map,Ge=!!x.matcap,Ye=!!j,ht=!!x.aoMap,tt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,At=!!x.normalMap,mn=!!x.displacementMap,kt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,gn=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=gn&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,_e=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,De=!!x.specularColorMap,Fe=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,ee=!!x.alphaMap,le=x.alphaTest>0,ye=!!x.alphaHash,ne=!!x.extensions,pe=Jn;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let He={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Be,fragmentShader:we,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:je.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Et,matcap:Ge,envMap:Ye,envMapMode:Ye&&j.mapping,envMapCubeUVHeight:k,aoMap:ht,lightMap:tt,bumpMap:Jt,normalMap:At,displacementMap:mn,emissiveMap:kt,normalMapObjectSpace:At&&x.normalMapType===Kp,normalMapTangentSpace:At&&x.normalMapType===Xu,packedNormalMap:At&&x.normalMapType===Xu&&nT(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:gn,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:_e,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:De,specularIntensityMap:Fe,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===xo&&x.alphaToCoverage===!1,alphaMap:ee,alphaTest:le,alphaHash:ye,combine:x.combine,mapUv:Et&&m(x.map.channel),aoMapUv:ht&&m(x.aoMap.channel),lightMapUv:tt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:At&&m(x.normalMap.channel),displacementMapUv:mn&&m(x.displacementMap.channel),emissiveMapUv:kt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:_e&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:De&&m(x.specularColorMap.channel),specularIntensityMapUv:Fe&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:ee&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(At||gn),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Et||ee),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&At===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&z.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Et&&x.map.isVideoTexture===!0&&je.getTransfer(x.map.colorSpace)===yt,decodeVideoTextureEmissive:kt&&x.emissiveMap.isVideoTexture===!0&&je.getTransfer(x.emissiveMap.colorSpace)===yt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===kn,flipSided:x.side===rn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return He.vertexUv1s=c.has(1),He.vertexUv2s=c.has(2),He.vertexUv3s=c.has(3),c.clear(),He}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let z in x.defines)M.push(z),M.push(x.defines[z]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],z;if(M){let C=xi[M];z=um.clone(C.uniforms)}else z=x.uniforms;return z}function y(x,M){let z=u.get(M);if(z!==void 0)++z.usedTimes;else z=new eT(e,M,x,r),l.push(z),u.set(M,z);return z}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function rT(){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 sT(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 Om(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 Um(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let f=0;if(h.isInstancedMesh)f+=2;if(h.isSkinnedMesh)f+=1;return f}function a(h,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:_,renderOrder:h.renderOrder,z:p,group:g},e[t]=S;else S.id=h.id,S.object=h,S.geometry=f,S.material=m,S.materialVariant=o(h),S.groupOrder=_,S.renderOrder=h.renderOrder,S.z=p,S.group=g;return t++,S}function c(h,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(h,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(h,f,m,_,p,g){let S=a(h,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(h,f){if(n.length>1)n.sort(h||sT);if(i.length>1)i.sort(f||Om);if(r.length>1)r.sort(f||Om)}function d(){for(let h=t,f=e.length;h<f;h++){let m=e[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function oT(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new Um,e.set(i,[o]);else if(r>=s.length)o=new Um,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function aT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new U,color:new ze};break;case"SpotLight":n={position:new U,direction:new U,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":n={color:new ze,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function cT(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var lT=0;function uT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function hT(e){let t=new aT,n=cT(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new U);let r=new U,s=new $e,o=new $e;function a(l){let u=0,d=0,h=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,z=0;l.sort(uT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===kr)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,d+=G.g*X,h+=G.b*X;else if(I.isLightProbe){for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],X);z++}else if(I.isSunLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=j;let Me=q.getViewportCount();for(let ue=0;ue<Me;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Me,m++}i.sun[f]=k,f++}else if(I.isDirectionalLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=k,p++}else if(I.isSpotLight){let k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(G).multiplyScalar(X),k.distance=P,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[S]=k;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[S]=Q,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let k=t.get(I);k.color.copy(G).multiplyScalar(X),k.halfWidth.set(I.width*0.5,0,0),k.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=k,T++}else if(I.isPointLight){let k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity),k.distance=I.distance,k.decay=I.decay,I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=k,g++}else if(I.isHemisphereLight){let k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(X),k.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=k,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==z)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=z,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=z,i.version=lT++}function c(l,u){let d=0,h=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[d];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),d++}else if(y.isDirectionalLight){let w=i.directional[h];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),h++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Fm(e){let t=new hT(e),n=[],i=[],r=[];function s(h){d.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function dT(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Fm(e),t.set(r,[a]);else if(s>=o.length)a=new Fm(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var fT=`void main() {
+`+Q)}else if(G!=="")Le("WebGLProgram: Program Info Log:",G);else if(X===""||P==="")z=!1;if(z)C.diagnostics={runnable:j,programLog:G,vertexShader:{log:X,prefix:p},fragmentShader:{log:P,prefix:g}}}r.deleteShader(w),r.deleteShader(A),x=new Xo(r,_),M=qA(r,_)}let x;this.getUniforms=function(){if(x===void 0)R(this);return x};let M;this.getAttributes=function(){if(M===void 0)R(this);return M};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(k===!1)k=r.getProgramParameter(_,zA);return k},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=BA++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=A,this}var hT=0;class ng{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 ig(e),t.set(e,n);return n}}class ig{constructor(e){this.id=hT++,this.code=e,this.usedTimes=0}}function dT(e){return e===$r||e===fc||e===pc}function fT(e,t,n,i,r,s){let o=new yc,a=new ng,c=new Set,l=[],u=new Map,{logarithmicDepthBuffer:d,precision:h}=i,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(x){if(c.add(x),x===0)return"uv";return`uv${x}`}function _(x,M,k,C,L,K){let I=C.fog,G=L.geometry,X=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,P=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,j=t.get(x.envMap||X,P),z=!!j&&j.mapping===Ao?j.image.height:null,q=f[x.type];if(x.precision!==null){if(h=i.getMaxPrecision(x.precision),h!==x.precision)Le("WebGLProgram.getParameters:",x.precision,"not supported, using",h,"instead.")}let Q=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Me=Q!==void 0?Q.length:0,ue=0;if(G.morphAttributes.position!==void 0)ue=1;if(G.morphAttributes.normal!==void 0)ue=2;if(G.morphAttributes.color!==void 0)ue=3;let Ve,we,Z,re;if(q){let St=vi[q];Ve=St.vertexShader,we=St.fragmentShader}else{Ve=x.vertexShader,we=x.fragmentShader;let St=a.getVertexShaderStage(x),lt=a.getFragmentShaderStage(x);a.update(x,St,lt),Z=St.id,re=lt.id}let se=e.getRenderTarget(),ye=e.state.buffers.depth.getReversed(),Ee=L.isInstancedMesh===!0,Ae=L.isBatchedMesh===!0,Et=!!x.map,He=!!x.matcap,Je=!!j,dt=!!x.aoMap,nt=!!x.lightMap,Jt=!!x.bumpMap&&x.wireframe===!1,At=!!x.normalMap,gn=!!x.displacementMap,zt=!!x.emissiveMap,Bt=!!x.metalnessMap,D=!!x.roughnessMap,_n=x.anisotropy>0,ct=x.clearcoat>0,Pt=x.dispersion>0,E=x.retroreflectivity>0,v=x.iridescence>0,N=x.sheen>0,H=x.transmission>0,ie=_n&&!!x.anisotropyMap,ae=ct&&!!x.clearcoatMap,he=ct&&!!x.clearcoatNormalMap,Y=ct&&!!x.clearcoatRoughnessMap,te=v&&!!x.iridescenceMap,xe=v&&!!x.iridescenceThicknessMap,Ie=N&&!!x.sheenColorMap,de=N&&!!x.sheenRoughnessMap,oe=!!x.specularMap,Oe=!!x.specularColorMap,ke=!!x.specularIntensityMap,st=H&&!!x.transmissionMap,F=H&&!!x.thicknessMap,ce=!!x.gradientMap,ee=!!x.alphaMap,le=x.alphaTest>0,ve=!!x.alphaHash,ne=!!x.extensions,pe=ti;if(x.toneMapped){if(se===null||se.isXRRenderTarget===!0)pe=e.toneMapping}let $e={shaderID:q,shaderType:x.type,shaderName:x.name,vertexShader:Ve,fragmentShader:we,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:h,batching:Ae,batchingColor:Ae&&L._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&L.instanceColor!==null,instancingMorph:Ee&&L.morphTexture!==null,outputColorSpace:se===null?e.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:qe.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Et,matcap:He,envMap:Je,envMapMode:Je&&j.mapping,envMapCubeUVHeight:z,aoMap:dt,lightMap:nt,bumpMap:Jt,normalMap:At,displacementMap:gn,emissiveMap:zt,normalMapObjectSpace:At&&x.normalMapType===om,normalMapTangentSpace:At&&x.normalMapType===th,packedNormalMap:At&&x.normalMapType===th&&dT(x.normalMap.format),metalnessMap:Bt,roughnessMap:D,anisotropy:_n,anisotropyMap:ie,clearcoat:ct,clearcoatMap:ae,clearcoatNormalMap:he,clearcoatRoughnessMap:Y,dispersion:Pt,retroreflection:E,iridescence:v,iridescenceMap:te,iridescenceThicknessMap:xe,sheen:N,sheenColorMap:Ie,sheenRoughnessMap:de,specularMap:oe,specularColorMap:Oe,specularIntensityMap:ke,transmission:H,transmissionMap:st,thicknessMap:F,gradientMap:ce,opaque:x.transparent===!1&&x.blending===wo&&x.alphaToCoverage===!1,alphaMap:ee,alphaTest:le,alphaHash:ve,combine:x.combine,mapUv:Et&&m(x.map.channel),aoMapUv:dt&&m(x.aoMap.channel),lightMapUv:nt&&m(x.lightMap.channel),bumpMapUv:Jt&&m(x.bumpMap.channel),normalMapUv:At&&m(x.normalMap.channel),displacementMapUv:gn&&m(x.displacementMap.channel),emissiveMapUv:zt&&m(x.emissiveMap.channel),metalnessMapUv:Bt&&m(x.metalnessMap.channel),roughnessMapUv:D&&m(x.roughnessMap.channel),anisotropyMapUv:ie&&m(x.anisotropyMap.channel),clearcoatMapUv:ae&&m(x.clearcoatMap.channel),clearcoatNormalMapUv:he&&m(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Y&&m(x.clearcoatRoughnessMap.channel),iridescenceMapUv:te&&m(x.iridescenceMap.channel),iridescenceThicknessMapUv:xe&&m(x.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&m(x.sheenColorMap.channel),sheenRoughnessMapUv:de&&m(x.sheenRoughnessMap.channel),specularMapUv:oe&&m(x.specularMap.channel),specularColorMapUv:Oe&&m(x.specularColorMap.channel),specularIntensityMapUv:ke&&m(x.specularIntensityMap.channel),transmissionMapUv:st&&m(x.transmissionMap.channel),thicknessMapUv:F&&m(x.thicknessMap.channel),alphaMapUv:ee&&m(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(At||_n),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!G.attributes.uv&&(Et||ee),fog:!!I,useFog:x.fog===!0,fogExp2:!!I&&I.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&At===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ye,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:ue,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:e.shadowMap.enabled&&k.length>0,shadowMapType:e.shadowMap.type,toneMapping:pe,decodeVideoTexture:Et&&x.map.isVideoTexture===!0&&qe.getTransfer(x.map.colorSpace)===vt,decodeVideoTextureEmissive:zt&&x.emissiveMap.isVideoTexture===!0&&qe.getTransfer(x.emissiveMap.colorSpace)===vt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Hn,flipSided:x.side===rn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ne&&x.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&x.extensions.multiDraw===!0||Ae)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return $e.vertexUv1s=c.has(1),$e.vertexUv2s=c.has(2),$e.vertexUv3s=c.has(3),c.clear(),$e}function p(x){let M=[];if(x.shaderID)M.push(x.shaderID);else M.push(x.customVertexShaderID),M.push(x.customFragmentShaderID);if(x.defines!==void 0)for(let k in x.defines)M.push(k),M.push(x.defines[k]);if(x.isRawShaderMaterial===!1)g(M,x),S(M,x),M.push(e.outputColorSpace);return M.push(x.customProgramCacheKey),M.join()}function g(x,M){x.push(M.precision),x.push(M.outputColorSpace),x.push(M.envMapMode),x.push(M.envMapCubeUVHeight),x.push(M.mapUv),x.push(M.alphaMapUv),x.push(M.lightMapUv),x.push(M.aoMapUv),x.push(M.bumpMapUv),x.push(M.normalMapUv),x.push(M.displacementMapUv),x.push(M.emissiveMapUv),x.push(M.metalnessMapUv),x.push(M.roughnessMapUv),x.push(M.anisotropyMapUv),x.push(M.clearcoatMapUv),x.push(M.clearcoatNormalMapUv),x.push(M.clearcoatRoughnessMapUv),x.push(M.iridescenceMapUv),x.push(M.iridescenceThicknessMapUv),x.push(M.sheenColorMapUv),x.push(M.sheenRoughnessMapUv),x.push(M.specularMapUv),x.push(M.specularColorMapUv),x.push(M.specularIntensityMapUv),x.push(M.transmissionMapUv),x.push(M.thicknessMapUv),x.push(M.combine),x.push(M.fogExp2),x.push(M.sizeAttenuation),x.push(M.morphTargetsCount),x.push(M.morphAttributeCount),x.push(M.numSunLights),x.push(M.numDirLights),x.push(M.numPointLights),x.push(M.numSpotLights),x.push(M.numSpotLightMaps),x.push(M.numHemiLights),x.push(M.numRectAreaLights),x.push(M.numSunLightShadows),x.push(M.numDirLightShadows),x.push(M.numPointLightShadows),x.push(M.numSpotLightShadows),x.push(M.numSpotLightShadowsWithMaps),x.push(M.numLightProbes),x.push(M.shadowMapType),x.push(M.toneMapping),x.push(M.numClippingPlanes),x.push(M.numClipIntersection),x.push(M.depthPacking)}function S(x,M){if(o.disableAll(),M.instancing)o.enable(0);if(M.instancingColor)o.enable(1);if(M.instancingMorph)o.enable(2);if(M.matcap)o.enable(3);if(M.envMap)o.enable(4);if(M.normalMapObjectSpace)o.enable(5);if(M.normalMapTangentSpace)o.enable(6);if(M.clearcoat)o.enable(7);if(M.iridescence)o.enable(8);if(M.alphaTest)o.enable(9);if(M.vertexColors)o.enable(10);if(M.vertexAlphas)o.enable(11);if(M.vertexUv1s)o.enable(12);if(M.vertexUv2s)o.enable(13);if(M.vertexUv3s)o.enable(14);if(M.vertexTangents)o.enable(15);if(M.anisotropy)o.enable(16);if(M.alphaHash)o.enable(17);if(M.batching)o.enable(18);if(M.dispersion)o.enable(19);if(M.retroreflection)o.enable(24);if(M.batchingColor)o.enable(20);if(M.gradientMap)o.enable(21);if(M.packedNormalMap)o.enable(22);if(M.vertexNormals)o.enable(23);if(x.push(o.mask),o.disableAll(),M.fog)o.enable(0);if(M.useFog)o.enable(1);if(M.flatShading)o.enable(2);if(M.logarithmicDepthBuffer)o.enable(3);if(M.reversedDepthBuffer)o.enable(4);if(M.skinning)o.enable(5);if(M.morphTargets)o.enable(6);if(M.morphNormals)o.enable(7);if(M.morphColors)o.enable(8);if(M.premultipliedAlpha)o.enable(9);if(M.shadowMapEnabled)o.enable(10);if(M.doubleSided)o.enable(11);if(M.flipSided)o.enable(12);if(M.useDepthPacking)o.enable(13);if(M.dithering)o.enable(14);if(M.transmission)o.enable(15);if(M.sheen)o.enable(16);if(M.opaque)o.enable(17);if(M.pointsUvs)o.enable(18);if(M.decodeVideoTexture)o.enable(19);if(M.decodeVideoTextureEmissive)o.enable(20);if(M.alphaToCoverage)o.enable(21);if(M.numLightProbeGrids>0)o.enable(22);if(M.hasPositionAttribute)o.enable(23);x.push(o.mask)}function T(x){let M=f[x.type],k;if(M){let C=vi[M];k=xm.clone(C.uniforms)}else k=x.uniforms;return k}function y(x,M){let k=u.get(M);if(k!==void 0)++k.usedTimes;else k=new uT(e,M,x,r),l.push(k),u.set(M,k);return k}function w(x){if(--x.usedTimes===0){let M=l.indexOf(x);l[M]=l[l.length-1],l.pop(),u.delete(x.cacheKey),x.destroy()}}function A(x){a.remove(x)}function R(){a.dispose()}return{getParameters:_,getProgramCacheKey:p,getUniforms:T,acquireProgram:y,releaseProgram:w,releaseShaderCache:A,programs:l,dispose:R}}function pT(){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 mT(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 Hm(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 $m(){let e=[],t=0,n=[],i=[],r=[];function s(){t=0,n.length=0,i.length=0,r.length=0}function o(h){let f=0;if(h.isInstancedMesh)f+=2;if(h.isSkinnedMesh)f+=1;return f}function a(h,f,m,_,p,g){let S=e[t];if(S===void 0)S={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:_,renderOrder:h.renderOrder,z:p,group:g},e[t]=S;else S.id=h.id,S.object=h,S.geometry=f,S.material=m,S.materialVariant=o(h),S.groupOrder=_,S.renderOrder=h.renderOrder,S.z=p,S.group=g;return t++,S}function c(h,f,m,_,p,g,S){if(S.reversedDepth===!0)p=-p;let T=a(h,f,m,_,p,g);if(m.transmission>0)i.push(T);else if(m.transparent===!0)r.push(T);else n.push(T)}function l(h,f,m,_,p,g){let S=a(h,f,m,_,p,g);if(m.transmission>0)i.unshift(S);else if(m.transparent===!0)r.unshift(S);else n.unshift(S)}function u(h,f){if(n.length>1)n.sort(h||mT);if(i.length>1)i.sort(f||Hm);if(r.length>1)r.sort(f||Hm)}function d(){for(let h=t,f=e.length;h<f;h++){let m=e[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:s,push:c,unshift:l,finish:d,sort:u}}function gT(){let e=new WeakMap;function t(i,r){let s=e.get(i),o;if(s===void 0)o=new $m,e.set(i,[o]);else if(r>=s.length)o=new $m,s.push(o);else o=s[r];return o}function n(){e=new WeakMap}return{get:t,dispose:n}}function _T(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"SunLight":case"DirectionalLight":n={direction:new U,color:new ze};break;case"SpotLight":n={position:new U,direction:new U,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new U,color:new ze,distance:0,decay:0};break;case"HemisphereLight":n={direction:new U,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":n={color:new ze,position:new U,halfWidth:new U,halfHeight:new U};break}return e[t.id]=n,n}}}function xT(){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 Fe};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1000};break}return e[t.id]=n,n}}}var yT=0;function vT(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function bT(e){let t=new _T,n=xT(),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 We,o=new We;function a(l){let u=0,d=0,h=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let f=0,m=0,_=0,p=0,g=0,S=0,T=0,y=0,w=0,A=0,R=0,x=0,M=0,k=0;l.sort(vT);for(let L=0,K=l.length;L<K;L++){let I=l[L],{color:G,intensity:X,distance:P}=I,j=null;if(I.shadow&&I.shadow.map)if(I.shadow.map.texture.format===$r)j=I.shadow.map.texture;else j=I.shadow.map.depthTexture||I.shadow.map.texture;if(I.isAmbientLight)u+=G.r*X,d+=G.g*X,h+=G.b*X;else if(I.isLightProbe){for(let z=0;z<9;z++)i.probe[z].addScaledVector(I.sh.coefficients[z],X);k++}else if(I.isSunLight){let z=t.get(I);if(z.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize.copy(q.mapSize).multiply(q.getFrameExtents()),i.sunShadow[m]=Q,i.sunShadowMap[m]=j;let Me=q.getViewportCount();for(let ue=0;ue<Me;ue++)i.sunShadowMatrix[_+ue]=q.getMatrix(ue),i.sunShadowCascade[_+ue]=q._cascadeData[ue];_+=Me,m++}i.sun[f]=z,f++}else if(I.isDirectionalLight){let z=t.get(I);if(z.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.directionalShadow[p]=Q,i.directionalShadowMap[p]=j,i.directionalShadowMatrix[p]=I.shadow.matrix,w++}i.directional[p]=z,p++}else if(I.isSpotLight){let z=t.get(I);z.position.setFromMatrixPosition(I.matrixWorld),z.color.copy(G).multiplyScalar(X),z.distance=P,z.coneCos=Math.cos(I.angle),z.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),z.decay=I.decay,i.spot[S]=z;let q=I.shadow;if(I.map){if(i.spotLightMap[x]=I.map,x++,q.updateMatrices(I),I.castShadow)M++}if(i.spotLightMatrix[S]=q.matrix,I.castShadow){let Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,i.spotShadow[S]=Q,i.spotShadowMap[S]=j,R++}S++}else if(I.isRectAreaLight){let z=t.get(I);z.color.copy(G).multiplyScalar(X),z.halfWidth.set(I.width*0.5,0,0),z.halfHeight.set(0,I.height*0.5,0),i.rectArea[T]=z,T++}else if(I.isPointLight){let z=t.get(I);if(z.color.copy(I.color).multiplyScalar(I.intensity),z.distance=I.distance,z.decay=I.decay,I.castShadow){let q=I.shadow,Q=n.get(I);Q.shadowIntensity=q.intensity,Q.shadowBias=q.bias,Q.shadowNormalBias=q.normalBias,Q.shadowRadius=q.radius,Q.shadowMapSize=q.mapSize,Q.shadowCameraNear=q.camera.near,Q.shadowCameraFar=q.camera.far,i.pointShadow[g]=Q,i.pointShadowMap[g]=j,i.pointShadowMatrix[g]=I.shadow.matrix,A++}i.point[g]=z,g++}else if(I.isHemisphereLight){let z=t.get(I);z.skyColor.copy(I.color).multiplyScalar(X),z.groundColor.copy(I.groundColor).multiplyScalar(X),i.hemi[y]=z,y++}}if(T>0)if(e.has("OES_texture_float_linear")===!0)i.rectAreaLTC1=fe.LTC_FLOAT_1,i.rectAreaLTC2=fe.LTC_FLOAT_2;else i.rectAreaLTC1=fe.LTC_HALF_1,i.rectAreaLTC2=fe.LTC_HALF_2;i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;let C=i.hash;if(C.sunLength!==f||C.directionalLength!==p||C.pointLength!==g||C.spotLength!==S||C.rectAreaLength!==T||C.hemiLength!==y||C.numSunShadows!==m||C.numDirectionalShadows!==w||C.numPointShadows!==A||C.numSpotShadows!==R||C.numSpotMaps!==x||C.numLightProbes!==k)i.sun.length=f,i.directional.length=p,i.spot.length=S,i.rectArea.length=T,i.point.length=g,i.hemi.length=y,i.sunShadow.length=m,i.sunShadowMap.length=m,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.directionalShadowMatrix.length=w,i.pointShadow.length=A,i.pointShadowMap.length=A,i.pointShadowMatrix.length=A,i.spotShadow.length=R,i.spotShadowMap.length=R,i.spotLightMatrix.length=R+x-M,i.spotLightMap.length=x,i.numSpotLightShadowsWithMaps=M,i.numLightProbes=k,C.sunLength=f,C.directionalLength=p,C.pointLength=g,C.spotLength=S,C.rectAreaLength=T,C.hemiLength=y,C.numSunShadows=m,C.numDirectionalShadows=w,C.numPointShadows=A,C.numSpotShadows=R,C.numSpotMaps=x,C.numLightProbes=k,i.version=yT++}function c(l,u){let d=0,h=0,f=0,m=0,_=0,p=0,g=u.matrixWorldInverse;for(let S=0,T=l.length;S<T;S++){let y=l[S];if(y.isSunLight){let w=i.sun[d];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),d++}else if(y.isDirectionalLight){let w=i.directional[h];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),h++}else if(y.isSpotLight){let w=i.spot[m];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),m++}else if(y.isRectAreaLight){let w=i.rectArea[_];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(y.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(y.width*0.5,0,0),w.halfHeight.set(0,y.height*0.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),_++}else if(y.isPointLight){let w=i.point[f];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(g),f++}else if(y.isHemisphereLight){let w=i.hemi[p];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(g),p++}}}return{setup:a,setupView:c,state:i}}function Wm(e){let t=new bT(e),n=[],i=[],r=[];function s(h){d.camera=h,n.length=0,i.length=0,r.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){r.push(h)}function l(){t.setup(n)}function u(h){t.setupView(n,h)}let d={lightsArray:n,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:c}}function ST(e){let t=new WeakMap;function n(r,s=0){let o=t.get(r),a;if(o===void 0)a=new Wm(e),t.set(r,[a]);else if(s>=o.length)a=new Wm(e),o.push(a);else a=o[s];return a}function i(){t=new WeakMap}return{get:n,dispose:i}}var MT=`void main() {
gl_Position = vec4( position, 1.0 );
-}`,pT=`uniform sampler2D shadow_pass;
+}`,wT=`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 );
-}`,mT=[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)],gT=[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)],zm=new $e,ko=new U,wh=new U;function _T(e,t,n){let i=new Po,r=new Ue,s=new Ue,o=new ft,a=new rh,c=new sh,l={},u=n.maxTextureSize,d={[ur]:rn,[rn]:ur,[kn]:kn},h=new Bn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:fT,fragmentShader:pT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new sn;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new Mt(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_o;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===pp)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=_o;let M=e.getRenderTarget(),z=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(di),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let j=P.getFrameExtents();if(r.multiply(j),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/j.x),r.x=s.x*j.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/j.y),r.y=s.y*j.y,P.mapSize.y=s.y}let k=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=k,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Ms){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new Mn(r.x,r.y,{format:kr,type:pi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Vr(r.x,r.y,Gi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Fr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}else{if(X.isPointLight)P.map=new Th(r.x),P.map.depthTexture=new th(r.x,hr);else P.map=new Mn(r.x,r.y),P.map.depthTexture=new Vr(r.x,r.y,hr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Fr,this.type===_o)P.map.depthTexture.compareFunction=k?uc:lc,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=Kn,P.map.depthTexture.magFilter=Kn}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(X.isPointLight!==!0)P.updateMatrices(X,x);for(let Q=0;Q<q;Q++){let Me=P.getCamera(Q);if(X.isPointLight){let{camera:ue,matrix:Be}=P,we=X.distance||ue.far;if(we!==ue.far)ue.far=we,ue.updateProjectionMatrix();ko.setFromMatrixPosition(X.matrixWorld),ue.position.copy(ko),wh.copy(ue.position),wh.add(mT[Q]),ue.up.copy(gT[Q]),ue.lookAt(wh),ue.updateMatrixWorld(),Be.makeTranslation(-ko.x,-ko.y,-ko.z),zm.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(zm,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(Q),y(R,x,Me,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Ms)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,z,C)};function S(A,R){let x=t.update(_);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new Mn(r.x,r.y,{format:kr,type:pi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,h,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let z=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)z=C;else if(z=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let L=z.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=z.clone(),I[K]=G,R.addEventListener("dispose",w);z=G}if(z.visible=R.visible,z.wireframe=R.wireframe,M===Ms)z.side=R.shadowSide!==null?R.shadowSide:R.side;else z.side=R.shadowSide!==null?R.shadowSide:d[R.side];if(z.alphaMap=R.alphaMap,z.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,z.map=R.map,z.clipShadows=R.clipShadows,z.clippingPlanes=R.clippingPlanes,z.clipIntersection=R.clipIntersection,z.displacementMap=R.displacementMap,z.displacementScale=R.displacementScale,z.displacementBias=R.displacementBias,z.wireframeLinewidth=R.wireframeLinewidth,z.linewidth=R.linewidth,x.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let L=e.properties.get(z);L.light=x}return z}function y(A,R,x,M,z){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&z===Ms)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],k=I[j.materialIndex];if(k&&k.visible){let q=T(A,k,M,z);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,z);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,z)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],z=A.target.uuid;if(z in M)M[z].dispose(),delete M[z]}}}function xT(e,t){function n(){let F=!1,ce=new ft,ee=null,le=new ft(0,0,0,0);return{setMask:function(ye){if(ee!==ye&&!F)e.colorMask(ye,ye,ye,ye),ee=ye},setLocked:function(ye){F=ye},setClear:function(ye,ne,pe,He,bt){if(bt===!0)ye*=He,ne*=He,pe*=He;if(ce.set(ye,ne,pe,He),le.equals(ce)===!1)e.clearColor(ye,ne,pe,He),le.copy(ce)},reset:function(){F=!1,ee=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,ee=null,le=null,ye=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let He=ye;ye=null,this.setClear(He)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else xe(e.DEPTH_TEST)},setMask:function(ne){if(ee!==ne&&!F)e.depthMask(ne),ee=ne},setFunc:function(ne){if(ce)ne=cm[ne];if(le!==ne){switch(ne){case Op:e.depthFunc(e.NEVER);break;case Up:e.depthFunc(e.ALWAYS);break;case Fp:e.depthFunc(e.LESS);break;case nu:e.depthFunc(e.LEQUAL);break;case zp:e.depthFunc(e.EQUAL);break;case kp:e.depthFunc(e.GEQUAL);break;case Bp:e.depthFunc(e.GREATER);break;case Vp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ye!==ne){if(ye=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,ee=null,le=null,ye=null,ce=!1}}}function r(){let F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else xe(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,oi,Di){if(ee!==lt||le!==oi||ye!==Di)e.stencilFunc(lt,oi,Di),ee=lt,le=oi,ye=Di},setOp:function(lt,oi,Di){if(ne!==lt||pe!==oi||He!==Di)e.stencilOp(lt,oi,Di),ne=lt,pe=oi,He=Di},setLocked:function(lt){F=lt},setClear:function(lt){if(bt!==lt)e.clearStencil(lt),bt=lt},reset:function(){F=!1,ce=null,ee=null,le=null,ye=null,ne=null,pe=null,He=null,bt=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,k=e.getParameter(e.VERSION);if(k.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(k)[1]),P=j>=1;else if(k.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),P=j>=2;let q=null,Q={},Me=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Be=new ft().fromArray(Me),we=new ft().fromArray(ue);function Z(F,ce,ee,le){let ye=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<ee;pe++)if(F===e.TEXTURE_3D||F===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ye);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ye);return ne}let re={};re[e.TEXTURE_2D]=Z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=Z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=Z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=Z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(e.DEPTH_TEST),o.setFunc(nu),Jt(!1),At(Kl),se(e.CULL_FACE),ht(di);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function xe(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(h[F]!==ce){if(e.bindFramebuffer(F,ce),h[F]=ce,F===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let ee=m,le=!1;if(F){if(ee=f.get(ce),ee===void 0)ee=[],f.set(ce,ee);let ye=F.textures;if(ee.length!==ye.length||ee[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ye.length;ne<pe;ne++)ee[ne]=e.COLOR_ATTACHMENT0+ne;ee.length=ye.length,le=!0}}else if(ee[0]!==e.BACK)ee[0]=e.BACK,le=!0;if(le)e.drawBuffers(ee)}function Et(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let Ge={[ws]:e.FUNC_ADD,[gp]:e.FUNC_SUBTRACT,[_p]:e.FUNC_REVERSE_SUBTRACT};Ge[xp]=e.MIN,Ge[yp]=e.MAX;let Ye={[vp]:e.ZERO,[bp]:e.ONE,[Sp]:e.SRC_COLOR,[wp]:e.SRC_ALPHA,[Pp]:e.SRC_ALPHA_SATURATE,[Rp]:e.DST_COLOR,[Ap]:e.DST_ALPHA,[Mp]:e.ONE_MINUS_SRC_COLOR,[Ep]:e.ONE_MINUS_SRC_ALPHA,[Cp]:e.ONE_MINUS_DST_COLOR,[Tp]:e.ONE_MINUS_DST_ALPHA,[Ip]:e.CONSTANT_COLOR,[Lp]:e.ONE_MINUS_CONSTANT_COLOR,[Np]:e.CONSTANT_ALPHA,[Dp]:e.ONE_MINUS_CONSTANT_ALPHA};function ht(F,ce,ee,le,ye,ne,pe,He,bt,lt){if(F===di){if(p===!0)xe(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==mp){if(F!==g||lt!==z){if(S!==ws||w!==ws)e.blendEquation(e.FUNC_ADD),S=ws,w=ws;if(lt)switch(F){case xo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ql:e.blendFunc(e.ONE,e.ONE);break;case eu:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case tu:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:ke("WebGLState: Invalid blending: ",F);break}else switch(F){case xo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ql:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case eu:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case tu:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,z=lt}return}if(ye=ye||ce,ne=ne||ee,pe=pe||le,ce!==S||ye!==w)e.blendEquationSeparate(Ge[ce],Ge[ye]),S=ce,w=ye;if(ee!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Ye[ee],Ye[le],Ye[ne],Ye[pe]),T=ee,y=le,A=ne,R=pe;if(He.equals(x)===!1||bt!==M)e.blendColor(He.r,He.g,He.b,bt),x.copy(He),M=bt;g=F,z=!1}function tt(F,ce){F.side===kn?xe(e.CULL_FACE):se(e.CULL_FACE);let ee=F.side===rn;if(ce)ee=!ee;Jt(ee),F.blending===xo&&F.transparent===!1?ht(di):ht(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);kt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):xe(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function At(F){if(F!==dp){if(se(e.CULL_FACE),F!==L)if(F===Kl)e.cullFace(e.BACK);else if(F===fp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else xe(e.CULL_FACE);L=F}function mn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function kt(F,ce,ee){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==ee){if(I=ce,G=ee,o.getReversed())ce=-ce;e.polygonOffset(ce,ee)}}else xe(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else xe(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function gn(F,ce,ee){if(ee===void 0)if(q===null)ee=e.TEXTURE0+X-1;else ee=q;let le=Q[ee];if(le===void 0)le={type:void 0,texture:void 0},Q[ee]=le;if(le.type!==F||le.texture!==ce){if(q!==ee)e.activeTexture(ee),q=ee;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=Q[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){ke("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){ke("WebGLState:",F)}}function _e(F){if(d[F]!==void 0)return d[F];else return e.getParameter(F)}function Ie(F,ce){if(d[F]!==ce)e.pixelStorei(F,ce),d[F]=ce}function de(F){if(Be.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Be.copy(F)}function oe(F){if(we.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),we.copy(F)}function De(F,ce){let ee=l.get(ce);if(ee===void 0)ee=new WeakMap,l.set(ce,ee);let le=ee.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),ee.set(F,le)}function Fe(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},q=null,Q={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,z=!1,C=null,L=null,K=null,I=null,G=null,Be.set(0,0,e.canvas.width,e.canvas.height),we.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:xe,bindFramebuffer:Ee,drawBuffers:Ae,useProgram:Et,setBlending:ht,setMaterial:tt,setFlipSided:Jt,setCullFace:At,setLineWidth:mn,setPolygonOffset:kt,setScissorTest:Bt,activeTexture:D,bindTexture:gn,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:_e,updateUBOMapping:De,uniformBlockBinding:Fe,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function yT(e,t,n,i,r,s,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ue,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):vs("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(h===void 0)h=_(ae,he);let Y=v?_(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?ju:je.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===yt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function w(E,v){let N;if(E){if(v===null||v===hr||v===Cs)N=e.DEPTH24_STENCIL8;else if(v===Gi)N=e.DEPTH32F_STENCIL8;else if(v===bo)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===hr||v===Cs)N=e.DEPTH_COMPONENT24;else if(v===Gi)N=e.DEPTH_COMPONENT32F;else if(v===bo)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==Kn&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)d.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)z(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function z(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)gn(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function k(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){xe(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function Q(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Me={[As]:e.REPEAT,[Ts]:e.CLAMP_TO_EDGE,[ec]:e.MIRRORED_REPEAT},ue={[Kn]:e.NEAREST,[tc]:e.NEAREST_MIPMAP_NEAREST,[Ur]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Rs]:e.LINEAR_MIPMAP_NEAREST,[fi]:e.LINEAR_MIPMAP_LINEAR},Be={[Qp]:e.NEVER,[rm]:e.ALWAYS,[em]:e.LESS,[lc]:e.LEQUAL,[tm]:e.EQUAL,[uc]:e.GEQUAL,[nm]:e.GREATER,[im]:e.NOTEQUAL};function we(E,v){if(v.type===Gi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Rs||v.magFilter===Ur||v.magFilter===fi||v.minFilter===qt||v.minFilter===Rs||v.minFilter===Ur||v.minFilter===fi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Me[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Me[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Me[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Be[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Kn)return;if(v.minFilter!==Ur&&v.minFilter!==fi)return;if(v.type===Gi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)z(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],De=de.start+de.count,Fe=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=De+1&&Fe===st&&re(oe.start+oe.count-1,v.width,4)===Fe)de.count=Math.max(de.count,oe.start+oe.count-de.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),_e=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],De=Math.floor(oe.start/4),Fe=Math.ceil(oe.count/4),st=De%v.width,F=Math.floor(De/v.width),ce=Fe,ee=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,_e)}}function xe(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let ee=je.getPrimaries(je.workingColorSpace),le=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),ye=v.colorSpace===Br||ee===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let _e=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,_e,Ie,v.normalized,v.colorSpace,v.isVideoTexture);we(H,v);let oe,De=v.mipmaps,Fe=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===zr,v.type),st)if(Fe)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,null)}else if(v.isDataTexture)if(De.length>0){if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data);v.generateMipmaps=!1}else if(Fe){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,_e,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,_e,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(Fe&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,De[0].width,De[0].height,te.depth);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)if(v.layerUpdates.size>0){let ye=xh(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let pe=oe.data.subarray(ne*ye/oe.data.BYTES_PER_ELEMENT,(ne+1)*ye/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,ne,oe.width,oe.height,1,_e,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,_e,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,_e,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(Fe&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,De[0].width,De[0].height);for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],v.format!==mi)if(_e!==null)if(Fe){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,_e,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,_e,Ie,oe.data)}else if(v.isDataArrayTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let ee=xh(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ye=te.data.subarray(le*ee/te.data.BYTES_PER_ELEMENT,(le+1)*ee/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,_e,Ie,ye)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isData3DTexture)if(Fe){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,_e,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,_e,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(Fe)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let ee=te.width,le=te.height;for(let ye=0;ye<ce;ye++)n.texImage2D(e.TEXTURE_2D,ye,de,ee,le,0,_e,Ie,null),ee>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let ee=e.canvas;if(!ee.hasAttribute("layoutsubtree"))ee.setAttribute("layoutsubtree","true");if(te.parentNode!==ee){ee.appendChild(te),d.add(v),ee.onpaint=(le)=>{let ye=le.changedElements;for(let ne of d)if(ye.includes(ne.image))ne.needsUpdate=!0},ee.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ye,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ye,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(De.length>0){if(Fe&&st){let ee=Pt(De[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}for(let ee=0,le=De.length;ee<le;ee++)if(oe=De[ee],Fe){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,_e,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,ee,de,_e,Ie,oe);v.generateMipmaps=!1}else if(Fe){if(st){let ee=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,_e,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,_e,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=je.getPrimaries(je.workingColorSpace),Y=v.colorSpace===Br?null:je.getPrimaries(v.colorSpace),te=v.colorSpace===Br||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let _e=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!_e&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],De=s.convert(v.format,v.colorSpace),Fe=s.convert(v.type),st=y(v.internalFormat,De,Fe,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,ee=ie.dataReady,le=A(v,oe);we(e.TEXTURE_CUBE_MAP,v);let ye;if(_e){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ye=de[ne].mipmaps;for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(v.format!==mi)if(De!==null)if(F){if(ee)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,He.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,He.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,He.width,He.height,De,Fe,He.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,He.width,He.height,0,De,Fe,He.data)}}}else{if(ye=v.mipmaps,F&&ce){if(ye.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,De,Fe,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,De,Fe,de[ne].data);for(let pe=0;pe<ye.length;pe++){let bt=ye[pe].image[ne].image;if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,bt.width,bt.height,De,Fe,bt.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,bt.width,bt.height,0,De,Fe,bt.data)}}else{if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,De,Fe,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,De,Fe,de[ne]);for(let pe=0;pe<ye.length;pe++){let He=ye[pe];if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,De,Fe,He.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,De,Fe,He.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),_e=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!_e.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function Ge(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),we(e.TEXTURE_CUBE_MAP,v.depthTexture);let _e=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Fr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===zr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,_e,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===zr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Fr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===zr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ye(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)Ge(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)Ge(v.__webglFramebuffer[0],E,0);else Ge(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),Et(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),Et(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ht(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Ye(E)}function tt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let _e=i.get(ie[Y]);if(_e.__webglTexture===void 0)_e.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let _e=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,_e,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),we(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let _e=ie[Y],Ie=i.get(_e),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),we(de,_e),Ae(N.__webglFramebuffer,E,_e,e.COLOR_ATTACHMENT0+Y,de,0),g(_e))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),we(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Ye(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let At=[],mn=[];function kt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let _e=0;_e<v.length;_e++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=E.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let _e=0;_e<v.length;_e++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(At.length=0,mn.length=0,At.push(e.COLOR_ATTACHMENT0+_e),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)At.push(ae),mn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,mn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,At)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let _e=0;_e<v.length;_e++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.RENDERBUFFER,he.__webglColorRenderbuffer[_e]);let Ie=i.get(v[_e]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+_e,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function gn(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==Sn&&N!==Br)if(je.getTransfer(N)===yt){if(H!==mi||ie!==Qn)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else ke("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=k,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=ht,this.setupRenderTarget=tt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=kt,this.setupDepthRenderbuffer=Ye,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function vT(e,t){function n(i,r=Br){let s,o=je.getTransfer(r);if(i===Qn)return e.UNSIGNED_BYTE;if(i===uu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===hu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Xp)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===jp)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Wp)return e.BYTE;if(i===Zp)return e.SHORT;if(i===bo)return e.UNSIGNED_SHORT;if(i===lu)return e.INT;if(i===hr)return e.UNSIGNED_INT;if(i===Gi)return e.FLOAT;if(i===pi)return e.HALF_FLOAT;if(i===qp)return e.ALPHA;if(i===Yp)return e.RGB;if(i===mi)return e.RGBA;if(i===Fr)return e.DEPTH_COMPONENT;if(i===zr)return e.DEPTH_STENCIL;if(i===Jp)return e.RED;if(i===du)return e.RED_INTEGER;if(i===kr)return e.RG;if(i===fu)return e.RG_INTEGER;if(i===pu)return e.RGBA_INTEGER;if(i===nc||i===ic||i===rc||i===sc)if(o===yt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===nc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===sc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===nc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ic)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===rc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===sc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===mu||i===gu||i===_u||i===xu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===mu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===gu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===_u)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===xu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===yu||i===vu||i===bu||i===Su||i===Mu||i===oc||i===wu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===yu||i===vu)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===bu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Su)return s.COMPRESSED_R11_EAC;if(i===Mu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===oc)return s.COMPRESSED_RG11_EAC;if(i===wu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Eu||i===Au||i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===Lu||i===Nu||i===Du||i===Ou||i===Uu||i===Fu||i===zu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Eu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Au)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Tu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Ru)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Cu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Pu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Iu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Lu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Nu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Du)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ou)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Uu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Fu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===zu)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ku||i===Bu||i===Vu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===ku)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Bu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Vu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Gu||i===Hu||i===ac||i===$u)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Gu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Hu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ac)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===$u)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Cs)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var bT=`
+}`,ET=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],AT=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Zm=new We,Wo=new U,Lh=new U;function TT(e,t,n){let i=new Uo,r=new Fe,s=new Fe,o=new pt,a=new dh,c=new fh,l={},u=n.maxTextureSize,d={[mr]:rn,[rn]:mr,[Hn]:Hn},h=new $n({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:MT,fragmentShader:wT}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new sn;m.setAttribute("position",new jt(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let _=new wt(m,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mo;let g=this.type;this.render=function(A,R,x){if(p.enabled===!1)return;if(p.autoUpdate===!1&&p.needsUpdate===!1)return;if(A.length===0)return;if(this.type===Sp)Le("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Mo;let M=e.getRenderTarget(),k=e.getActiveCubeFace(),C=e.getActiveMipmapLevel(),L=e.state;if(L.setBlending(pi),L.buffers.depth.getReversed()===!0)L.buffers.color.setClear(0,0,0,0);else L.buffers.color.setClear(1,1,1,1);L.buffers.depth.setTest(!0),L.setScissorTest(!1);let K=g!==this.type;if(K)R.traverse(function(I){if(I.material)if(Array.isArray(I.material))I.material.forEach((G)=>G.needsUpdate=!0);else I.material.needsUpdate=!0});for(let I=0,G=A.length;I<G;I++){let X=A[I],P=X.shadow;if(P===void 0){Le("WebGLShadowMap:",X,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;r.copy(P.mapSize);let j=P.getFrameExtents();if(r.multiply(j),s.copy(P.mapSize),r.x>u||r.y>u){if(r.x>u)s.x=Math.floor(u/j.x),r.x=s.x*j.x,P.mapSize.x=s.x;if(r.y>u)s.y=Math.floor(u/j.y),r.y=s.y*j.y,P.mapSize.y=s.y}let z=e.state.buffers.depth.getReversed();if(P.camera._reversedDepth=z,P.map===null||K===!0){if(P.map!==null){if(P.map.depthTexture!==null)P.map.depthTexture.dispose(),P.map.depthTexture=null;P.map.dispose()}if(this.type===Rs){if(X.isPointLight){Le("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}P.map=new En(r.x,r.y,{format:$r,type:gi,minFilter:qt,magFilter:qt,generateMipmaps:!1}),P.map.texture.name=X.name+".shadowMap",P.map.depthTexture=new Zr(r.x,r.y,Hi),P.map.depthTexture.name=X.name+".shadowMapDepth",P.map.depthTexture.format=Gr,P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ni,P.map.depthTexture.magFilter=ni}else{if(X.isPointLight)P.map=new Oh(r.x),P.map.depthTexture=new lh(r.x,gr);else P.map=new En(r.x,r.y),P.map.depthTexture=new Zr(r.x,r.y,gr);if(P.map.depthTexture.name=X.name+".shadowMap",P.map.depthTexture.format=Gr,this.type===Mo)P.map.depthTexture.compareFunction=z?_c:gc,P.map.depthTexture.minFilter=qt,P.map.depthTexture.magFilter=qt;else P.map.depthTexture.compareFunction=null,P.map.depthTexture.minFilter=ni,P.map.depthTexture.magFilter=ni}P.camera.updateProjectionMatrix()}if(P.map.isWebGLCubeRenderTarget!==!0&&(P.map.width!==r.x||P.map.height!==r.y))P.map.setSize(r.x,r.y);let q=P.map.isWebGLCubeRenderTarget?6:P.getViewportCount();if(X.isPointLight!==!0)P.updateMatrices(X,x);for(let Q=0;Q<q;Q++){let Me=P.getCamera(Q);if(X.isPointLight){let{camera:ue,matrix:Ve}=P,we=X.distance||ue.far;if(we!==ue.far)ue.far=we,ue.updateProjectionMatrix();Wo.setFromMatrixPosition(X.matrixWorld),ue.position.copy(Wo),Lh.copy(ue.position),Lh.add(ET[Q]),ue.up.copy(AT[Q]),ue.lookAt(Lh),ue.updateMatrixWorld(),Ve.makeTranslation(-Wo.x,-Wo.y,-Wo.z),Zm.multiplyMatrices(ue.projectionMatrix,ue.matrixWorldInverse),P._frustum.setFromProjectionMatrix(Zm,ue.coordinateSystem,ue.reversedDepth)}if(P.map.isWebGLCubeRenderTarget)e.setRenderTarget(P.map,Q),e.clear();else{if(Q===0)e.setRenderTarget(P.map),e.clear();let ue=P.getViewport(Q);o.set(s.x*ue.x,s.y*ue.y,s.x*ue.z,s.y*ue.w),L.viewport(o)}i=P.getFrustum(Q),y(R,x,Me,X,this.type)}if(P.isPointLightShadow!==!0&&this.type===Rs)S(P,x);P.needsUpdate=!1}g=this.type,p.needsUpdate=!1,e.setRenderTarget(M,k,C)};function S(A,R){let x=t.update(_);if(h.defines.VSM_SAMPLES!==A.blurSamples)h.defines.VSM_SAMPLES=A.blurSamples,f.defines.VSM_SAMPLES=A.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0;if(A.mapPass===null)A.mapPass=new En(r.x,r.y,{format:$r,type:gi});else if(A.mapPass.width!==A.map.width||A.mapPass.height!==A.map.height)A.mapPass.setSize(A.map.width,A.map.height);h.uniforms.shadow_pass.value=A.map.depthTexture,h.uniforms.resolution.value.set(A.map.width,A.map.height),h.uniforms.radius.value=A.radius,e.setRenderTarget(A.mapPass),e.clear(),e.renderBufferDirect(R,null,x,h,_,null),f.uniforms.shadow_pass.value=A.mapPass.texture,f.uniforms.resolution.value.set(A.map.width,A.map.height),f.uniforms.radius.value=A.radius,e.setRenderTarget(A.map),e.clear(),e.renderBufferDirect(R,null,x,f,_,null)}function T(A,R,x,M){let k=null,C=x.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(C!==void 0)k=C;else if(k=x.isPointLight===!0?c:a,e.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let L=k.uuid,K=R.uuid,I=l[L];if(I===void 0)I={},l[L]=I;let G=I[K];if(G===void 0)G=k.clone(),I[K]=G,R.addEventListener("dispose",w);k=G}if(k.visible=R.visible,k.wireframe=R.wireframe,M===Rs)k.side=R.shadowSide!==null?R.shadowSide:R.side;else k.side=R.shadowSide!==null?R.shadowSide:d[R.side];if(k.alphaMap=R.alphaMap,k.alphaTest=R.alphaToCoverage===!0?0.5:R.alphaTest,k.map=R.map,k.clipShadows=R.clipShadows,k.clippingPlanes=R.clippingPlanes,k.clipIntersection=R.clipIntersection,k.displacementMap=R.displacementMap,k.displacementScale=R.displacementScale,k.displacementBias=R.displacementBias,k.wireframeLinewidth=R.wireframeLinewidth,k.linewidth=R.linewidth,x.isPointLight===!0&&k.isMeshDistanceMaterial===!0){let L=e.properties.get(k);L.light=x}return k}function y(A,R,x,M,k){if(A.visible===!1)return;if(A.layers.test(R.layers)&&(A.isMesh||A.isLine||A.isPoints)){if((A.castShadow||A.receiveShadow&&k===Rs)&&(!A.frustumCulled||A.intersectsFrustum(i))){A.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,A.matrixWorld);let K=t.update(A),I=A.material;if(Array.isArray(I)){let G=K.groups;for(let X=0,P=G.length;X<P;X++){let j=G[X],z=I[j.materialIndex];if(z&&z.visible){let q=T(A,z,M,k);A.onBeforeShadow(e,A,R,x,K,q,j),e.renderBufferDirect(x,null,K,q,A,j),A.onAfterShadow(e,A,R,x,K,q,j)}}}else if(I.visible){let G=T(A,I,M,k);A.onBeforeShadow(e,A,R,x,K,G,null),e.renderBufferDirect(x,null,K,G,A,null),A.onAfterShadow(e,A,R,x,K,G,null)}}}let L=A.children;for(let K=0,I=L.length;K<I;K++)y(L[K],R,x,M,k)}function w(A){A.target.removeEventListener("dispose",w);for(let x in l){let M=l[x],k=A.target.uuid;if(k in M)M[k].dispose(),delete M[k]}}}function RT(e,t){function n(){let F=!1,ce=new pt,ee=null,le=new pt(0,0,0,0);return{setMask:function(ve){if(ee!==ve&&!F)e.colorMask(ve,ve,ve,ve),ee=ve},setLocked:function(ve){F=ve},setClear:function(ve,ne,pe,$e,St){if(St===!0)ve*=$e,ne*=$e,pe*=$e;if(ce.set(ve,ne,pe,$e),le.equals(ce)===!1)e.clearColor(ve,ne,pe,$e),le.copy(ce)},reset:function(){F=!1,ee=null,le.set(-1,0,0,0)}}}function i(){let F=!1,ce=!1,ee=null,le=null,ve=null;return{setReversed:function(ne){if(ce!==ne){let pe=t.get("EXT_clip_control");if(ne)pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT);else pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT);ce=ne;let $e=ve;ve=null,this.setClear($e)}},getReversed:function(){return ce},setTest:function(ne){if(ne)se(e.DEPTH_TEST);else ye(e.DEPTH_TEST)},setMask:function(ne){if(ee!==ne&&!F)e.depthMask(ne),ee=ne},setFunc:function(ne){if(ce)ne=gm[ne];if(le!==ne){switch(ne){case Hp:e.depthFunc(e.NEVER);break;case $p:e.depthFunc(e.ALWAYS);break;case Wp:e.depthFunc(e.LESS);break;case uu:e.depthFunc(e.LEQUAL);break;case Zp:e.depthFunc(e.EQUAL);break;case Xp:e.depthFunc(e.GEQUAL);break;case jp:e.depthFunc(e.GREATER);break;case qp:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}le=ne}},setLocked:function(ne){F=ne},setClear:function(ne){if(ve!==ne){if(ve=ne,ce)ne=1-ne;e.clearDepth(ne)}},reset:function(){F=!1,ee=null,le=null,ve=null,ce=!1}}}function r(){let F=!1,ce=null,ee=null,le=null,ve=null,ne=null,pe=null,$e=null,St=null;return{setTest:function(lt){if(!F)if(lt)se(e.STENCIL_TEST);else ye(e.STENCIL_TEST)},setMask:function(lt){if(ce!==lt&&!F)e.stencilMask(lt),ce=lt},setFunc:function(lt,ci,Oi){if(ee!==lt||le!==ci||ve!==Oi)e.stencilFunc(lt,ci,Oi),ee=lt,le=ci,ve=Oi},setOp:function(lt,ci,Oi){if(ne!==lt||pe!==ci||$e!==Oi)e.stencilOp(lt,ci,Oi),ne=lt,pe=ci,$e=Oi},setLocked:function(lt){F=lt},setClear:function(lt){if(St!==lt)e.clearStencil(lt),St=lt},reset:function(){F=!1,ce=null,ee=null,le=null,ve=null,ne=null,pe=null,$e=null,St=null}}}let s=new n,o=new i,a=new r,c=new WeakMap,l=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,k=!1,C=null,L=null,K=null,I=null,G=null,X=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,j=0,z=e.getParameter(e.VERSION);if(z.indexOf("WebGL")!==-1)j=parseFloat(/^WebGL (\d)/.exec(z)[1]),P=j>=1;else if(z.indexOf("OpenGL ES")!==-1)j=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),P=j>=2;let q=null,Q={},Me=e.getParameter(e.SCISSOR_BOX),ue=e.getParameter(e.VIEWPORT),Ve=new pt().fromArray(Me),we=new pt().fromArray(ue);function Z(F,ce,ee,le){let ve=new Uint8Array(4),ne=e.createTexture();e.bindTexture(F,ne),e.texParameteri(F,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(F,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let pe=0;pe<ee;pe++)if(F===e.TEXTURE_3D||F===e.TEXTURE_2D_ARRAY)e.texImage3D(ce,0,e.RGBA,1,1,le,0,e.RGBA,e.UNSIGNED_BYTE,ve);else e.texImage2D(ce+pe,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,ve);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(uu),Jt(!1),At(ou),se(e.CULL_FACE),dt(pi);function se(F){if(u[F]!==!0)e.enable(F),u[F]=!0}function ye(F){if(u[F]!==!1)e.disable(F),u[F]=!1}function Ee(F,ce){if(h[F]!==ce){if(e.bindFramebuffer(F,ce),h[F]=ce,F===e.DRAW_FRAMEBUFFER)h[e.FRAMEBUFFER]=ce;if(F===e.FRAMEBUFFER)h[e.DRAW_FRAMEBUFFER]=ce;return!0}return!1}function Ae(F,ce){let ee=m,le=!1;if(F){if(ee=f.get(ce),ee===void 0)ee=[],f.set(ce,ee);let ve=F.textures;if(ee.length!==ve.length||ee[0]!==e.COLOR_ATTACHMENT0){for(let ne=0,pe=ve.length;ne<pe;ne++)ee[ne]=e.COLOR_ATTACHMENT0+ne;ee.length=ve.length,le=!0}}else if(ee[0]!==e.BACK)ee[0]=e.BACK,le=!0;if(le)e.drawBuffers(ee)}function Et(F){if(_!==F)return e.useProgram(F),_=F,!0;return!1}let He={[Cs]:e.FUNC_ADD,[wp]:e.FUNC_SUBTRACT,[Ep]:e.FUNC_REVERSE_SUBTRACT};He[Ap]=e.MIN,He[Tp]=e.MAX;let Je={[Rp]:e.ZERO,[Cp]:e.ONE,[Pp]:e.SRC_COLOR,[Lp]:e.SRC_ALPHA,[kp]:e.SRC_ALPHA_SATURATE,[Up]:e.DST_COLOR,[Dp]:e.DST_ALPHA,[Ip]:e.ONE_MINUS_SRC_COLOR,[Np]:e.ONE_MINUS_SRC_ALPHA,[Fp]:e.ONE_MINUS_DST_COLOR,[Op]:e.ONE_MINUS_DST_ALPHA,[zp]:e.CONSTANT_COLOR,[Bp]:e.ONE_MINUS_CONSTANT_COLOR,[Vp]:e.CONSTANT_ALPHA,[Gp]:e.ONE_MINUS_CONSTANT_ALPHA};function dt(F,ce,ee,le,ve,ne,pe,$e,St,lt){if(F===pi){if(p===!0)ye(e.BLEND),p=!1;return}if(p===!1)se(e.BLEND),p=!0;if(F!==Mp){if(F!==g||lt!==k){if(S!==Cs||w!==Cs)e.blendEquation(e.FUNC_ADD),S=Cs,w=Cs;if(lt)switch(F){case wo:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case au:e.blendFunc(e.ONE,e.ONE);break;case cu:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case lu:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Be("WebGLState: Invalid blending: ",F);break}else switch(F){case wo:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case au:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case cu:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case lu:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",F);break}T=null,y=null,A=null,R=null,x.set(0,0,0),M=0,g=F,k=lt}return}if(ve=ve||ce,ne=ne||ee,pe=pe||le,ce!==S||ve!==w)e.blendEquationSeparate(He[ce],He[ve]),S=ce,w=ve;if(ee!==T||le!==y||ne!==A||pe!==R)e.blendFuncSeparate(Je[ee],Je[le],Je[ne],Je[pe]),T=ee,y=le,A=ne,R=pe;if($e.equals(x)===!1||St!==M)e.blendColor($e.r,$e.g,$e.b,St),x.copy($e),M=St;g=F,k=!1}function nt(F,ce){F.side===Hn?ye(e.CULL_FACE):se(e.CULL_FACE);let ee=F.side===rn;if(ce)ee=!ee;Jt(ee),F.blending===wo&&F.transparent===!1?dt(pi):dt(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.blendColor,F.blendAlpha,F.premultipliedAlpha),o.setFunc(F.depthFunc),o.setTest(F.depthTest),o.setMask(F.depthWrite),s.setMask(F.colorWrite);let le=F.stencilWrite;if(a.setTest(le),le)a.setMask(F.stencilWriteMask),a.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),a.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass);zt(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?se(e.SAMPLE_ALPHA_TO_COVERAGE):ye(e.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(F){if(C!==F){if(F)e.frontFace(e.CW);else e.frontFace(e.CCW);C=F}}function At(F){if(F!==vp){if(se(e.CULL_FACE),F!==L)if(F===ou)e.cullFace(e.BACK);else if(F===bp)e.cullFace(e.FRONT);else e.cullFace(e.FRONT_AND_BACK)}else ye(e.CULL_FACE);L=F}function gn(F){if(F!==K){if(P)e.lineWidth(F);K=F}}function zt(F,ce,ee){if(F){if(se(e.POLYGON_OFFSET_FILL),I!==ce||G!==ee){if(I=ce,G=ee,o.getReversed())ce=-ce;e.polygonOffset(ce,ee)}}else ye(e.POLYGON_OFFSET_FILL)}function Bt(F){if(F)se(e.SCISSOR_TEST);else ye(e.SCISSOR_TEST)}function D(F){if(F===void 0)F=e.TEXTURE0+X-1;if(q!==F)e.activeTexture(F),q=F}function _n(F,ce,ee){if(ee===void 0)if(q===null)ee=e.TEXTURE0+X-1;else ee=q;let le=Q[ee];if(le===void 0)le={type:void 0,texture:void 0},Q[ee]=le;if(le.type!==F||le.texture!==ce){if(q!==ee)e.activeTexture(ee),q=ee;e.bindTexture(F,ce||re[F]),le.type=F,le.texture=ce}}function ct(){let F=Q[q];if(F!==void 0&&F.type!==void 0)e.bindTexture(F.type,null),F.type=void 0,F.texture=void 0}function Pt(){try{e.compressedTexImage2D(...arguments)}catch(F){Be("WebGLState:",F)}}function E(){try{e.compressedTexImage3D(...arguments)}catch(F){Be("WebGLState:",F)}}function v(){try{e.texSubImage2D(...arguments)}catch(F){Be("WebGLState:",F)}}function N(){try{e.texSubImage3D(...arguments)}catch(F){Be("WebGLState:",F)}}function H(){try{e.compressedTexSubImage2D(...arguments)}catch(F){Be("WebGLState:",F)}}function ie(){try{e.compressedTexSubImage3D(...arguments)}catch(F){Be("WebGLState:",F)}}function ae(){try{e.texStorage2D(...arguments)}catch(F){Be("WebGLState:",F)}}function he(){try{e.texStorage3D(...arguments)}catch(F){Be("WebGLState:",F)}}function Y(){try{e.texImage2D(...arguments)}catch(F){Be("WebGLState:",F)}}function te(){try{e.texImage3D(...arguments)}catch(F){Be("WebGLState:",F)}}function xe(F){if(d[F]!==void 0)return d[F];else return e.getParameter(F)}function Ie(F,ce){if(d[F]!==ce)e.pixelStorei(F,ce),d[F]=ce}function de(F){if(Ve.equals(F)===!1)e.scissor(F.x,F.y,F.z,F.w),Ve.copy(F)}function oe(F){if(we.equals(F)===!1)e.viewport(F.x,F.y,F.z,F.w),we.copy(F)}function Oe(F,ce){let ee=l.get(ce);if(ee===void 0)ee=new WeakMap,l.set(ce,ee);let le=ee.get(F);if(le===void 0)le=e.getUniformBlockIndex(ce,F.name),ee.set(F,le)}function ke(F,ce){let le=l.get(ce).get(F);if(c.get(ce)!==le)e.uniformBlockBinding(ce,le,F.__bindingPointIndex),c.set(ce,le)}function st(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},q=null,Q={},h={},f=new WeakMap,m=[],_=null,p=!1,g=null,S=null,T=null,y=null,w=null,A=null,R=null,x=new ze(0,0,0),M=0,k=!1,C=null,L=null,K=null,I=null,G=null,Ve.set(0,0,e.canvas.width,e.canvas.height),we.set(0,0,e.canvas.width,e.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:se,disable:ye,bindFramebuffer:Ee,drawBuffers:Ae,useProgram:Et,setBlending:dt,setMaterial:nt,setFlipSided:Jt,setCullFace:At,setLineWidth:gn,setPolygonOffset:zt,setScissorTest:Bt,activeTexture:D,bindTexture:_n,unbindTexture:ct,compressedTexImage2D:Pt,compressedTexImage3D:E,texImage2D:Y,texImage3D:te,pixelStorei:Ie,getParameter:xe,updateUBOMapping:Oe,uniformBlockBinding:ke,texStorage2D:ae,texStorage3D:he,texSubImage2D:v,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:ie,scissor:de,viewport:oe,reset:st}}function CT(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 Fe,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function _(E,v){return m?new OffscreenCanvas(E,v):Es("canvas")}function p(E,v,N){let H=1,ie=Pt(E);if(ie.width>N||ie.height>N)H=N/Math.max(ie.width,ie.height);if(H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let ae=Math.floor(H*ie.width),he=Math.floor(H*ie.height);if(h===void 0)h=_(ae,he);let Y=v?_(ae,he):h;return Y.width=ae,Y.height=he,Y.getContext("2d").drawImage(E,0,0,ae,he),Le("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+ae+"x"+he+")."),Y}else{if("data"in E)Le("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+").");return E}return E}function g(E){return E.generateMipmaps}function S(E){e.generateMipmap(E)}function T(E){if(E.isWebGLCubeRenderTarget)return e.TEXTURE_CUBE_MAP;if(E.isWebGL3DRenderTarget)return e.TEXTURE_3D;if(E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture)return e.TEXTURE_2D_ARRAY;return e.TEXTURE_2D}function y(E,v,N,H,ie,ae=!1){if(E!==null){if(e[E]!==void 0)return e[E];Le("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let he;if(H){if(he=t.get("EXT_texture_norm16"),!he)Le("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let Y=v;if(v===e.RED){if(N===e.FLOAT)Y=e.R32F;if(N===e.HALF_FLOAT)Y=e.R16F;if(N===e.UNSIGNED_BYTE)Y=e.R8;if(N===e.UNSIGNED_SHORT&&he)Y=he.R16_EXT;if(N===e.SHORT&&he)Y=he.R16_SNORM_EXT}if(v===e.RED_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.R8UI;if(N===e.UNSIGNED_SHORT)Y=e.R16UI;if(N===e.UNSIGNED_INT)Y=e.R32UI;if(N===e.BYTE)Y=e.R8I;if(N===e.SHORT)Y=e.R16I;if(N===e.INT)Y=e.R32I}if(v===e.RG){if(N===e.FLOAT)Y=e.RG32F;if(N===e.HALF_FLOAT)Y=e.RG16F;if(N===e.UNSIGNED_BYTE)Y=e.RG8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RG16_EXT;if(N===e.SHORT&&he)Y=he.RG16_SNORM_EXT}if(v===e.RG_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RG8UI;if(N===e.UNSIGNED_SHORT)Y=e.RG16UI;if(N===e.UNSIGNED_INT)Y=e.RG32UI;if(N===e.BYTE)Y=e.RG8I;if(N===e.SHORT)Y=e.RG16I;if(N===e.INT)Y=e.RG32I}if(v===e.RGB_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGB8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGB16UI;if(N===e.UNSIGNED_INT)Y=e.RGB32UI;if(N===e.BYTE)Y=e.RGB8I;if(N===e.SHORT)Y=e.RGB16I;if(N===e.INT)Y=e.RGB32I}if(v===e.RGBA_INTEGER){if(N===e.UNSIGNED_BYTE)Y=e.RGBA8UI;if(N===e.UNSIGNED_SHORT)Y=e.RGBA16UI;if(N===e.UNSIGNED_INT)Y=e.RGBA32UI;if(N===e.BYTE)Y=e.RGBA8I;if(N===e.SHORT)Y=e.RGBA16I;if(N===e.INT)Y=e.RGBA32I}if(v===e.RGB){if(N===e.UNSIGNED_SHORT&&he)Y=he.RGB16_EXT;if(N===e.SHORT&&he)Y=he.RGB16_SNORM_EXT;if(N===e.UNSIGNED_INT_5_9_9_9_REV)Y=e.RGB9_E5;if(N===e.UNSIGNED_INT_10F_11F_11F_REV)Y=e.R11F_G11F_B10F}if(v===e.RGBA){let te=ae?nh:qe.getTransfer(ie);if(N===e.FLOAT)Y=e.RGBA32F;if(N===e.HALF_FLOAT)Y=e.RGBA16F;if(N===e.UNSIGNED_BYTE)Y=te===vt?e.SRGB8_ALPHA8:e.RGBA8;if(N===e.UNSIGNED_SHORT&&he)Y=he.RGBA16_EXT;if(N===e.SHORT&&he)Y=he.RGBA16_SNORM_EXT;if(N===e.UNSIGNED_SHORT_4_4_4_4)Y=e.RGBA4;if(N===e.UNSIGNED_SHORT_5_5_5_1)Y=e.RGB5_A1}if(Y===e.R16F||Y===e.R32F||Y===e.RG16F||Y===e.RG32F||Y===e.RGBA16F||Y===e.RGBA32F)t.get("EXT_color_buffer_float");return Y}function w(E,v){let N;if(E){if(v===null||v===gr||v===Ds)N=e.DEPTH24_STENCIL8;else if(v===Hi)N=e.DEPTH32F_STENCIL8;else if(v===To)N=e.DEPTH24_STENCIL8,Le("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(v===null||v===gr||v===Ds)N=e.DEPTH_COMPONENT24;else if(v===Hi)N=e.DEPTH_COMPONENT32F;else if(v===To)N=e.DEPTH_COMPONENT16;return N}function A(E,v){if(g(E)===!0||E.isFramebufferTexture&&E.minFilter!==ni&&E.minFilter!==qt)return Math.log2(Math.max(v.width,v.height))+1;else if(E.mipmaps!==void 0&&E.mipmaps.length>0)return E.mipmaps.length;else if(E.isCompressedTexture&&Array.isArray(E.image))return v.mipmaps.length;else return 1}function R(E){let v=E.target;if(v.removeEventListener("dispose",R),M(v),v.isVideoTexture)u.delete(v);if(v.isHTMLTexture)d.delete(v)}function x(E){let v=E.target;v.removeEventListener("dispose",x),C(v)}function M(E){let v=i.get(E);if(v.__webglInit===void 0)return;let N=E.source,H=f.get(N);if(H){let ie=H[v.__cacheKey];if(ie.usedTimes--,ie.usedTimes===0)k(E);if(Object.keys(H).length===0)f.delete(N)}i.remove(E)}function k(E){let v=i.get(E);e.deleteTexture(v.__webglTexture);let N=E.source,H=f.get(N);delete H[v.__cacheKey],o.memory.textures--}function C(E){let v=i.get(E);if(E.depthTexture)E.depthTexture.dispose(),i.remove(E.depthTexture);if(E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(v.__webglFramebuffer[H]))for(let ie=0;ie<v.__webglFramebuffer[H].length;ie++)e.deleteFramebuffer(v.__webglFramebuffer[H][ie]);else e.deleteFramebuffer(v.__webglFramebuffer[H]);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer[H])}else{if(Array.isArray(v.__webglFramebuffer))for(let H=0;H<v.__webglFramebuffer.length;H++)e.deleteFramebuffer(v.__webglFramebuffer[H]);else e.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer)e.deleteRenderbuffer(v.__webglDepthbuffer);if(v.__webglMultisampledFramebuffer)e.deleteFramebuffer(v.__webglMultisampledFramebuffer);if(v.__webglColorRenderbuffer){for(let H=0;H<v.__webglColorRenderbuffer.length;H++)if(v.__webglColorRenderbuffer[H])e.deleteRenderbuffer(v.__webglColorRenderbuffer[H])}if(v.__webglDepthRenderbuffer)e.deleteRenderbuffer(v.__webglDepthRenderbuffer)}let N=E.textures;for(let H=0,ie=N.length;H<ie;H++){let ae=i.get(N[H]);if(ae.__webglTexture)e.deleteTexture(ae.__webglTexture),o.memory.textures--;i.remove(N[H])}i.remove(E)}let L=0;function K(){L=0}function I(){return L}function G(E){L=E}function X(){let E=L;if(E>=r.maxTextures)Le("WebGLTextures: Trying to use "+(E+1)+" texture units while this GPU supports only "+r.maxTextures);return L+=1,E}function P(E){let v=[];return v.push(E.wrapS),v.push(E.wrapT),v.push(E.wrapR||0),v.push(E.magFilter),v.push(E.minFilter),v.push(E.anisotropy),v.push(E.internalFormat),v.push(E.format),v.push(E.type),v.push(E.generateMipmaps),v.push(E.premultiplyAlpha),v.push(E.flipY),v.push(E.unpackAlignment),v.push(E.colorSpace),v.join()}function j(E,v){let N=i.get(E);if(E.isVideoTexture)_n(E);if(E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){let H=E.image;if(H===null)Le("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Le("WebGLRenderer: Texture marked for update but image is incomplete");else{ye(N,E,v);return}}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D,N.__webglTexture,e.TEXTURE0+v)}function z(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){ye(N,E,v);return}else if(E.isExternalTexture)N.__webglTexture=E.sourceTexture?E.sourceTexture:null;n.bindTexture(e.TEXTURE_2D_ARRAY,N.__webglTexture,e.TEXTURE0+v)}function q(E,v){let N=i.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){ye(N,E,v);return}n.bindTexture(e.TEXTURE_3D,N.__webglTexture,e.TEXTURE0+v)}function Q(E,v){let N=i.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ee(N,E,v);return}n.bindTexture(e.TEXTURE_CUBE_MAP,N.__webglTexture,e.TEXTURE0+v)}let Me={[Is]:e.REPEAT,[Ls]:e.CLAMP_TO_EDGE,[ac]:e.MIRRORED_REPEAT},ue={[ni]:e.NEAREST,[cc]:e.NEAREST_MIPMAP_NEAREST,[Vr]:e.NEAREST_MIPMAP_LINEAR,[qt]:e.LINEAR,[Ns]:e.LINEAR_MIPMAP_NEAREST,[mi]:e.LINEAR_MIPMAP_LINEAR},Ve={[am]:e.NEVER,[dm]:e.ALWAYS,[cm]:e.LESS,[gc]:e.LEQUAL,[lm]:e.EQUAL,[_c]:e.GEQUAL,[um]:e.GREATER,[hm]:e.NOTEQUAL};function we(E,v){if(v.type===Hi&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===qt||v.magFilter===Ns||v.magFilter===Vr||v.magFilter===mi||v.minFilter===qt||v.minFilter===Ns||v.minFilter===Vr||v.minFilter===mi))Le("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(e.texParameteri(E,e.TEXTURE_WRAP_S,Me[v.wrapS]),e.texParameteri(E,e.TEXTURE_WRAP_T,Me[v.wrapT]),E===e.TEXTURE_3D||E===e.TEXTURE_2D_ARRAY)e.texParameteri(E,e.TEXTURE_WRAP_R,Me[v.wrapR]);if(e.texParameteri(E,e.TEXTURE_MAG_FILTER,ue[v.magFilter]),e.texParameteri(E,e.TEXTURE_MIN_FILTER,ue[v.minFilter]),v.compareFunction)e.texParameteri(E,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(E,e.TEXTURE_COMPARE_FUNC,Ve[v.compareFunction]);if(t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===ni)return;if(v.minFilter!==Vr&&v.minFilter!==mi)return;if(v.type===Hi&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){let N=t.get("EXT_texture_filter_anisotropic");e.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,r.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function Z(E,v){let N=!1;if(E.__webglInit===void 0)E.__webglInit=!0,v.addEventListener("dispose",R);let H=v.source,ie=f.get(H);if(ie===void 0)ie={},f.set(H,ie);let ae=P(v);if(ae!==E.__cacheKey){if(ie[ae]===void 0)ie[ae]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,N=!0;ie[ae].usedTimes++;let he=ie[E.__cacheKey];if(he!==void 0){if(ie[E.__cacheKey].usedTimes--,he.usedTimes===0)k(v)}E.__cacheKey=ae,E.__webglTexture=ie[ae].texture}return N}function re(E,v,N){return Math.floor(Math.floor(E/N)/v)}function se(E,v,N,H){let ae=E.updateRanges;if(ae.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,v.width,v.height,N,H,v.data);else{ae.sort((Ie,de)=>Ie.start-de.start);let he=0;for(let Ie=1;Ie<ae.length;Ie++){let de=ae[he],oe=ae[Ie],Oe=de.start+de.count,ke=re(oe.start,v.width,4),st=re(de.start,v.width,4);if(oe.start<=Oe+1&&ke===st&&re(oe.start+oe.count-1,v.width,4)===ke)de.count=Math.max(de.count,oe.start+oe.count-de.start);else++he,ae[he]=oe}ae.length=he+1;let Y=n.getParameter(e.UNPACK_ROW_LENGTH),te=n.getParameter(e.UNPACK_SKIP_PIXELS),xe=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,v.width);for(let Ie=0,de=ae.length;Ie<de;Ie++){let oe=ae[Ie],Oe=Math.floor(oe.start/4),ke=Math.ceil(oe.count/4),st=Oe%v.width,F=Math.floor(Oe/v.width),ce=ke,ee=1;n.pixelStorei(e.UNPACK_SKIP_PIXELS,st),n.pixelStorei(e.UNPACK_SKIP_ROWS,F),n.texSubImage2D(e.TEXTURE_2D,0,st,F,ce,1,N,H,v.data)}E.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,Y),n.pixelStorei(e.UNPACK_SKIP_PIXELS,te),n.pixelStorei(e.UNPACK_SKIP_ROWS,xe)}}function ye(E,v,N){let H=e.TEXTURE_2D;if(v.isDataArrayTexture||v.isCompressedArrayTexture)H=e.TEXTURE_2D_ARRAY;if(v.isData3DTexture)H=e.TEXTURE_3D;let ie=Z(E,v),ae=v.source;n.bindTexture(H,E.__webglTexture,e.TEXTURE0+N);let he=i.get(ae);if(ae.version!==he.__version||ie===!0){if(n.activeTexture(e.TEXTURE0+N),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){let ee=qe.getPrimaries(qe.workingColorSpace),le=v.colorSpace===Wr?null:qe.getPrimaries(v.colorSpace),ve=v.colorSpace===Wr||ee===le?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment);let te=p(v.image,!1,r.maxTextureSize);te=ct(v,te);let xe=s.convert(v.format,v.colorSpace),Ie=s.convert(v.type),de=y(v.internalFormat,xe,Ie,v.normalized,v.colorSpace,v.isVideoTexture);we(H,v);let oe,Oe=v.mipmaps,ke=v.isVideoTexture!==!0,st=he.__version===void 0||ie===!0,F=ae.dataReady,ce=A(v,te);if(v.isDepthTexture){if(de=w(v.format===Hr,v.type),st)if(ke)n.texStorage2D(e.TEXTURE_2D,1,de,te.width,te.height);else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,xe,Ie,null)}else if(v.isDataTexture)if(Oe.length>0){if(ke&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Oe[0].width,Oe[0].height);for(let ee=0,le=Oe.length;ee<le;ee++)if(oe=Oe[ee],ke){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,xe,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,xe,Ie,oe.data);v.generateMipmaps=!1}else if(ke){if(st)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);if(F)se(v,te,xe,Ie)}else n.texImage2D(e.TEXTURE_2D,0,de,te.width,te.height,0,xe,Ie,te.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){if(ke&&st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,Oe[0].width,Oe[0].height,te.depth);for(let ee=0,le=Oe.length;ee<le;ee++)if(oe=Oe[ee],v.format!==_i)if(xe!==null)if(ke){if(F)if(v.layerUpdates.size>0){let ve=Ah(oe.width,oe.height,v.format,v.type);for(let ne of v.layerUpdates){let pe=oe.data.subarray(ne*ve/oe.data.BYTES_PER_ELEMENT,(ne+1)*ve/oe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,ne,oe.width,oe.height,1,xe,pe)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,xe,oe.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,oe.data,0,0);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(ke){if(F)n.texSubImage3D(e.TEXTURE_2D_ARRAY,ee,0,0,0,oe.width,oe.height,te.depth,xe,Ie,oe.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,ee,de,oe.width,oe.height,te.depth,0,xe,Ie,oe.data);if(v.layerUpdates.size>0)v.clearLayerUpdates()}else{if(ke&&st)n.texStorage2D(e.TEXTURE_2D,ce,de,Oe[0].width,Oe[0].height);for(let ee=0,le=Oe.length;ee<le;ee++)if(oe=Oe[ee],v.format!==_i)if(xe!==null)if(ke){if(F)n.compressedTexSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,xe,oe.data)}else n.compressedTexImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,oe.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(ke){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,oe.width,oe.height,xe,Ie,oe.data)}else n.texImage2D(e.TEXTURE_2D,ee,de,oe.width,oe.height,0,xe,Ie,oe.data)}else if(v.isDataArrayTexture)if(ke){if(st)n.texStorage3D(e.TEXTURE_2D_ARRAY,ce,de,te.width,te.height,te.depth);if(F)if(v.layerUpdates.size>0){let ee=Ah(te.width,te.height,v.format,v.type);for(let le of v.layerUpdates){let ve=te.data.subarray(le*ee/te.data.BYTES_PER_ELEMENT,(le+1)*ee/te.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,le,te.width,te.height,1,xe,Ie,ve)}v.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,xe,Ie,te.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,de,te.width,te.height,te.depth,0,xe,Ie,te.data);else if(v.isData3DTexture)if(ke){if(st)n.texStorage3D(e.TEXTURE_3D,ce,de,te.width,te.height,te.depth);if(F)n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,xe,Ie,te.data)}else n.texImage3D(e.TEXTURE_3D,0,de,te.width,te.height,te.depth,0,xe,Ie,te.data);else if(v.isFramebufferTexture){if(st)if(ke)n.texStorage2D(e.TEXTURE_2D,ce,de,te.width,te.height);else{let ee=te.width,le=te.height;for(let ve=0;ve<ce;ve++)n.texImage2D(e.TEXTURE_2D,ve,de,ee,le,0,xe,Ie,null),ee>>=1,le>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in e){let ee=e.canvas;if(!ee.hasAttribute("layoutsubtree"))ee.setAttribute("layoutsubtree","true");if(te.parentNode!==ee){ee.appendChild(te),d.add(v),ee.onpaint=(le)=>{let ve=le.changedElements;for(let ne of d)if(ve.includes(ne.image))ne.needsUpdate=!0},ee.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,te);else{let{RGBA:ve,RGBA:ne,UNSIGNED_BYTE:pe}=e;e.texElementImage2D(e.TEXTURE_2D,0,ve,ne,pe,te)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(Oe.length>0){if(ke&&st){let ee=Pt(Oe[0]);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}for(let ee=0,le=Oe.length;ee<le;ee++)if(oe=Oe[ee],ke){if(F)n.texSubImage2D(e.TEXTURE_2D,ee,0,0,xe,Ie,oe)}else n.texImage2D(e.TEXTURE_2D,ee,de,xe,Ie,oe);v.generateMipmaps=!1}else if(ke){if(st){let ee=Pt(te);n.texStorage2D(e.TEXTURE_2D,ce,de,ee.width,ee.height)}if(F)n.texSubImage2D(e.TEXTURE_2D,0,0,0,xe,Ie,te)}else n.texImage2D(e.TEXTURE_2D,0,de,xe,Ie,te);if(g(v))S(H);if(he.__version=ae.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ee(E,v,N){if(v.image.length!==6)return;let H=Z(E,v),ie=v.source;n.bindTexture(e.TEXTURE_CUBE_MAP,E.__webglTexture,e.TEXTURE0+N);let ae=i.get(ie);if(ie.version!==ae.__version||H===!0){n.activeTexture(e.TEXTURE0+N);let he=qe.getPrimaries(qe.workingColorSpace),Y=v.colorSpace===Wr?null:qe.getPrimaries(v.colorSpace),te=v.colorSpace===Wr||he===Y?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,v.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,v.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,te);let xe=v.isCompressedTexture||v.image[0].isCompressedTexture,Ie=v.image[0]&&v.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++){if(!xe&&!Ie)de[ne]=p(v.image[ne],!0,r.maxCubemapSize);else de[ne]=Ie?v.image[ne].image:v.image[ne];de[ne]=ct(v,de[ne])}let oe=de[0],Oe=s.convert(v.format,v.colorSpace),ke=s.convert(v.type),st=y(v.internalFormat,Oe,ke,v.normalized,v.colorSpace),F=v.isVideoTexture!==!0,ce=ae.__version===void 0||H===!0,ee=ie.dataReady,le=A(v,oe);we(e.TEXTURE_CUBE_MAP,v);let ve;if(xe){if(F&&ce)n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,oe.width,oe.height);for(let ne=0;ne<6;ne++){ve=de[ne].mipmaps;for(let pe=0;pe<ve.length;pe++){let $e=ve[pe];if(v.format!==_i)if(Oe!==null)if(F){if(ee)n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,$e.width,$e.height,Oe,$e.data)}else n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,$e.width,$e.height,0,$e.data);else Le("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()");else if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,0,0,$e.width,$e.height,Oe,ke,$e.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe,st,$e.width,$e.height,0,Oe,ke,$e.data)}}}else{if(ve=v.mipmaps,F&&ce){if(ve.length>0)le++;let ne=Pt(de[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,le,st,ne.width,ne.height)}for(let ne=0;ne<6;ne++)if(Ie){if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,de[ne].width,de[ne].height,Oe,ke,de[ne].data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,de[ne].width,de[ne].height,0,Oe,ke,de[ne].data);for(let pe=0;pe<ve.length;pe++){let St=ve[pe].image[ne].image;if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,St.width,St.height,Oe,ke,St.data)}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,St.width,St.height,0,Oe,ke,St.data)}}else{if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,0,0,Oe,ke,de[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,st,Oe,ke,de[ne]);for(let pe=0;pe<ve.length;pe++){let $e=ve[pe];if(F){if(ee)n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,0,0,Oe,ke,$e.image[ne])}else n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+ne,pe+1,st,Oe,ke,$e.image[ne])}}}if(g(v))S(e.TEXTURE_CUBE_MAP);if(ae.__version=ie.version,v.onUpdate)v.onUpdate(v)}E.__version=v.version}function Ae(E,v,N,H,ie,ae){let he=s.convert(N.format,N.colorSpace),Y=s.convert(N.type),te=y(N.internalFormat,he,Y,N.normalized,N.colorSpace),xe=i.get(v),Ie=i.get(N);if(Ie.__renderTarget=v,!xe.__hasExternalTextures){let de=Math.max(1,v.width>>ae),oe=Math.max(1,v.height>>ae);if(ie===e.TEXTURE_3D||ie===e.TEXTURE_2D_ARRAY)n.texImage3D(ie,ae,te,de,oe,v.depth,0,he,Y,null);else n.texImage2D(ie,ae,te,de,oe,0,he,Y,null)}if(n.bindFramebuffer(e.FRAMEBUFFER,E),D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,0,Bt(v));else if(ie===e.TEXTURE_2D||ie>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)e.framebufferTexture2D(e.FRAMEBUFFER,H,ie,Ie.__webglTexture,ae);n.bindFramebuffer(e.FRAMEBUFFER,null)}function Et(E,v,N){if(e.bindRenderbuffer(e.RENDERBUFFER,E),v.depthBuffer){let H=v.depthTexture,ie=H&&H.isDepthTexture?H.type:null,ae=w(v.stencilBuffer,ie),he=v.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),ae,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,ae,v.width,v.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,he,e.RENDERBUFFER,E)}else{let H=v.textures;for(let ie=0;ie<H.length;ie++){let ae=H[ie],he=s.convert(ae.format,ae.colorSpace),Y=s.convert(ae.type),te=y(ae.internalFormat,he,Y,ae.normalized,ae.colorSpace);if(D(v))a.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else if(N)e.renderbufferStorageMultisample(e.RENDERBUFFER,Bt(v),te,v.width,v.height);else e.renderbufferStorage(e.RENDERBUFFER,te,v.width,v.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function He(E,v,N){let H=v.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,E),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ie=i.get(v.depthTexture);if(ie.__renderTarget=v,!ie.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0;if(H){if(ie.__webglInit===void 0)ie.__webglInit=!0,v.depthTexture.addEventListener("dispose",R);if(ie.__webglTexture===void 0){ie.__webglTexture=e.createTexture(),n.bindTexture(e.TEXTURE_CUBE_MAP,ie.__webglTexture),we(e.TEXTURE_CUBE_MAP,v.depthTexture);let xe=s.convert(v.depthTexture.format),Ie=s.convert(v.depthTexture.type),de;if(v.depthTexture.format===Gr)de=e.DEPTH_COMPONENT24;else if(v.depthTexture.format===Hr)de=e.DEPTH24_STENCIL8;for(let oe=0;oe<6;oe++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,de,v.width,v.height,0,xe,Ie,null)}}else j(v.depthTexture,0);let ae=ie.__webglTexture,he=Bt(v),Y=H?e.TEXTURE_CUBE_MAP_POSITIVE_X+N:e.TEXTURE_2D,te=v.depthTexture.format===Hr?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(v.depthTexture.format===Gr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else if(v.depthTexture.format===Hr)if(D(v))a.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,te,Y,ae,0,he);else e.framebufferTexture2D(e.FRAMEBUFFER,te,Y,ae,0);else throw Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Je(E){let v=i.get(E),N=E.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==E.depthTexture){let H=E.depthTexture;if(v.__depthDisposeCallback)v.__depthDisposeCallback();if(H){let ie=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,H.removeEventListener("dispose",ie)};H.addEventListener("dispose",ie),v.__depthDisposeCallback=ie}v.__boundDepthTexture=H}if(E.depthTexture&&!v.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)He(v.__webglFramebuffer[H],E,H);else{let H=E.texture.mipmaps;if(H&&H.length>0)He(v.__webglFramebuffer[0],E,0);else He(v.__webglFramebuffer,E,0)}else if(N){v.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[H]),v.__webglDepthbuffer[H]===void 0)v.__webglDepthbuffer[H]=e.createRenderbuffer(),Et(v.__webglDepthbuffer[H],E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer[H];e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}else{let H=E.texture.mipmaps;if(H&&H.length>0)n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer[0]);else n.bindFramebuffer(e.FRAMEBUFFER,v.__webglFramebuffer);if(v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=e.createRenderbuffer(),Et(v.__webglDepthbuffer,E,!1);else{let ie=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,ae=v.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,ae),e.framebufferRenderbuffer(e.FRAMEBUFFER,ie,e.RENDERBUFFER,ae)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function dt(E,v,N){let H=i.get(E);if(v!==void 0)Ae(H.__webglFramebuffer,E,E.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);if(N!==void 0)Je(E)}function nt(E){let v=E.texture,N=i.get(E),H=i.get(v);E.addEventListener("dispose",x);let ie=E.textures,ae=E.isWebGLCubeRenderTarget===!0,he=ie.length>1;if(!he){if(H.__webglTexture===void 0)H.__webglTexture=e.createTexture();H.__version=v.version,o.memory.textures++}if(ae){N.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer[Y]=[];for(let te=0;te<v.mipmaps.length;te++)N.__webglFramebuffer[Y][te]=e.createFramebuffer()}else N.__webglFramebuffer[Y]=e.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){N.__webglFramebuffer=[];for(let Y=0;Y<v.mipmaps.length;Y++)N.__webglFramebuffer[Y]=e.createFramebuffer()}else N.__webglFramebuffer=e.createFramebuffer();if(he)for(let Y=0,te=ie.length;Y<te;Y++){let xe=i.get(ie[Y]);if(xe.__webglTexture===void 0)xe.__webglTexture=e.createTexture(),o.memory.textures++}if(E.samples>0&&D(E)===!1){N.__webglMultisampledFramebuffer=e.createFramebuffer(),N.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let Y=0;Y<ie.length;Y++){let te=ie[Y];N.__webglColorRenderbuffer[Y]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,N.__webglColorRenderbuffer[Y]);let xe=s.convert(te.format,te.colorSpace),Ie=s.convert(te.type),de=y(te.internalFormat,xe,Ie,te.normalized,te.colorSpace,E.isXRRenderTarget===!0),oe=Bt(E);e.renderbufferStorageMultisample(e.RENDERBUFFER,oe,de,E.width,E.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+Y,e.RENDERBUFFER,N.__webglColorRenderbuffer[Y])}if(e.bindRenderbuffer(e.RENDERBUFFER,null),E.depthBuffer)N.__webglDepthRenderbuffer=e.createRenderbuffer(),Et(N.__webglDepthRenderbuffer,E,!0);n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(ae){n.bindTexture(e.TEXTURE_CUBE_MAP,H.__webglTexture),we(e.TEXTURE_CUBE_MAP,v);for(let Y=0;Y<6;Y++)if(v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[Y][te],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,te);else Ae(N.__webglFramebuffer[Y],E,v,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);if(g(v))S(e.TEXTURE_CUBE_MAP);n.unbindTexture()}else if(he){for(let Y=0,te=ie.length;Y<te;Y++){let xe=ie[Y],Ie=i.get(xe),de=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)de=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(de,Ie.__webglTexture),we(de,xe),Ae(N.__webglFramebuffer,E,xe,e.COLOR_ATTACHMENT0+Y,de,0),g(xe))S(de)}n.unbindTexture()}else{let Y=e.TEXTURE_2D;if(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)Y=E.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY;if(n.bindTexture(Y,H.__webglTexture),we(Y,v),v.mipmaps&&v.mipmaps.length>0)for(let te=0;te<v.mipmaps.length;te++)Ae(N.__webglFramebuffer[te],E,v,e.COLOR_ATTACHMENT0,Y,te);else Ae(N.__webglFramebuffer,E,v,e.COLOR_ATTACHMENT0,Y,0);if(g(v))S(Y);n.unbindTexture()}if(E.depthBuffer)Je(E)}function Jt(E){let v=E.textures;for(let N=0,H=v.length;N<H;N++){let ie=v[N];if(g(ie)){let ae=T(E),he=i.get(ie).__webglTexture;n.bindTexture(ae,he),S(ae),n.unbindTexture()}}}let At=[],gn=[];function zt(E){if(E.samples>0){if(D(E)===!1){let{textures:v,width:N,height:H}=E,ie=e.COLOR_BUFFER_BIT,ae=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,he=i.get(E),Y=v.length>1;if(Y)for(let xe=0;xe<v.length;xe++)n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+xe,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+xe,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer);let te=E.texture.mipmaps;if(te&&te.length>0)n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer[0]);else n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let xe=0;xe<v.length;xe++){if(E.resolveDepthBuffer){if(E.depthBuffer)ie|=e.DEPTH_BUFFER_BIT;if(E.stencilBuffer&&E.resolveStencilBuffer)ie|=e.STENCIL_BUFFER_BIT}if(Y){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,he.__webglColorRenderbuffer[xe]);let Ie=i.get(v[xe]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,Ie,0)}if(e.blitFramebuffer(0,0,N,H,0,0,N,H,ie,e.NEAREST),c===!0){if(At.length=0,gn.length=0,At.push(e.COLOR_ATTACHMENT0+xe),E.depthBuffer&&E.storeMultisampledDepthBuffer===!1)At.push(ae),gn.push(ae),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,gn);e.invalidateFramebuffer(e.READ_FRAMEBUFFER,At)}}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),Y)for(let xe=0;xe<v.length;xe++){n.bindFramebuffer(e.FRAMEBUFFER,he.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+xe,e.RENDERBUFFER,he.__webglColorRenderbuffer[xe]);let Ie=i.get(v[xe]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,he.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+xe,e.TEXTURE_2D,Ie,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.storeMultisampledDepthBuffer===!1&&c){let v=E.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[v])}}}function Bt(E){return Math.min(r.maxSamples,E.samples)}function D(E){let v=i.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function _n(E){let v=o.render.frame;if(u.get(E)!==v)u.set(E,v),E.update()}function ct(E,v){let{colorSpace:N,format:H,type:ie}=E;if(E.isCompressedTexture===!0||E.isVideoTexture===!0)return v;if(N!==wn&&N!==Wr)if(qe.getTransfer(N)===vt){if(H!==_i||ie!==ii)Le("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else Be("WebGLTextures: Unsupported texture color space:",N);return v}function Pt(E){if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement)l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height;else if(typeof VideoFrame<"u"&&E instanceof VideoFrame)l.width=E.displayWidth,l.height=E.displayHeight;else l.width=E.width,l.height=E.height;return l}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.getTextureUnits=I,this.setTextureUnits=G,this.setTexture2D=j,this.setTexture2DArray=z,this.setTexture3D=q,this.setTextureCube=Q,this.rebindTextures=dt,this.setupRenderTarget=nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=zt,this.setupDepthRenderbuffer=Je,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=D,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function PT(e,t){function n(i,r=Wr){let s,o=qe.getTransfer(r);if(i===ii)return e.UNSIGNED_BYTE;if(i===xu)return e.UNSIGNED_SHORT_4_4_4_4;if(i===yu)return e.UNSIGNED_SHORT_5_5_5_1;if(i===tm)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===nm)return e.UNSIGNED_INT_10F_11F_11F_REV;if(i===Qp)return e.BYTE;if(i===em)return e.SHORT;if(i===To)return e.UNSIGNED_SHORT;if(i===_u)return e.INT;if(i===gr)return e.UNSIGNED_INT;if(i===Hi)return e.FLOAT;if(i===gi)return e.HALF_FLOAT;if(i===im)return e.ALPHA;if(i===rm)return e.RGB;if(i===_i)return e.RGBA;if(i===Gr)return e.DEPTH_COMPONENT;if(i===Hr)return e.DEPTH_STENCIL;if(i===sm)return e.RED;if(i===vu)return e.RED_INTEGER;if(i===$r)return e.RG;if(i===bu)return e.RG_INTEGER;if(i===Su)return e.RGBA_INTEGER;if(i===lc||i===uc||i===hc||i===dc)if(o===vt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===lc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===uc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===dc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===lc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===uc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===hc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===dc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Mu||i===wu||i===Eu||i===Au)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Mu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===wu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Eu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Au)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Tu||i===Ru||i===Cu||i===Pu||i===Iu||i===fc||i===Lu)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Tu||i===Ru)return o===vt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Cu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===Pu)return s.COMPRESSED_R11_EAC;if(i===Iu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===fc)return s.COMPRESSED_RG11_EAC;if(i===Lu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Nu||i===Du||i===Ou||i===Uu||i===Fu||i===ku||i===zu||i===Bu||i===Vu||i===Gu||i===Hu||i===$u||i===Wu||i===Zu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Nu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Du)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ou)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Uu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ku)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===zu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Bu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Vu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Gu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===$u)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Wu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Zu)return o===vt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Xu||i===ju||i===qu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Xu)return o===vt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ju)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===qu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Yu||i===Ju||i===pc||i===Ku)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Yu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Ju)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===pc)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ku)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(i===Ds)return e.UNSIGNED_INT_24_8;return e[i]!==void 0?e[i]:null}return{convert:n}}var IT=`
void main() {
gl_Position = vec4( position, 1.0 );
-}`,ST=`
+}`,LT=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
@@ -4341,11 +4341,11 @@ void main() {
}
-}`;class Ym{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new yc(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)this.depthNear=e.depthNear,this.depthFar=e.depthFar;this.texture=n}}getMesh(e){if(this.texture!==null){if(this.mesh===null){let t=e.cameras[0].viewport,n=new Bn({vertexShader:bT,fragmentShader:ST,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mt(new No(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Jm extends ei{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,d=null,h=null,f=null,m=typeof XRWebGLBinding<"u",_=new Ym,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new Ue,R=null,x=null,M=new Vt;M.viewport=new ft;let z=new Vt;z.viewport=new ft;let C=[M,z],L=new dh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new Eo,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),h=null,d=null,u=null,i=null,T=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),T=new Mn(h.framebufferWidth,h.framebufferHeight,{format:mi,type:Qn,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,xe=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?zr:Fr,xe=g.stencil?Cs:hr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new Mn(d.textureWidth,d.textureHeight,{format:mi,type:Qn,depthTexture:new Vr(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],xe=w.indexOf(se);if(xe>=0)w[xe]=null,y[xe].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],xe=w.indexOf(se);if(xe===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),xe=Ae;break}else if(w[Ae]===null){w[Ae]=se,xe=Ae;break}if(xe===-1)break}let Ee=y[xe];if(Ee)Ee.connect(se)}}let j=new U,k=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),k.setFromMatrixPosition(se.matrixWorld);let xe=j.distanceTo(k),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,Et=Ee[14]/(Ee[10]-1),Ge=Ee[14]/(Ee[10]+1),Ye=(Ee[9]+1)/Ee[5],ht=(Ee[9]-1)/Ee[5],tt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],At=Et*tt,mn=Et*Jt,kt=xe/(-tt+Jt),Bt=kt*-tt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(kt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=Et+kt,gn=Ge+kt,ct=At-Bt,Pt=mn+(xe-Bt),E=Ye*Ge/gn*D,v=ht*Ge/gn*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,gn),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=z.near=M.near=re,L.far=z.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,z.layers.mask=L.layers.mask&-3;let xe=Z.parent,Ee=L.cameras;Q(L,xe);for(let Ae=0;Ae<Ee.length;Ae++)Q(Ee[Ae],xe);if(Ee.length===2)q(L,M,z);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Me(Z,L,xe)};function Me(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=Dr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(d===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,d!==null)d.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Be(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(T,h.framebuffer),e.setRenderTarget(T);let xe=!1;if(se.length!==L.cameras.length)L.cameras.length=0,xe=!0;for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge],ht=null;if(h!==null)ht=h.getViewport(Ye);else{let Jt=u.getViewSubImage(d,Ye);if(ht=Jt.viewport,Ge===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let tt=C[Ge];if(tt===void 0)tt=new Vt,tt.layers.enable(Ge),tt.viewport=new ft,C[Ge]=tt;if(tt.matrix.fromArray(Ye.transform.matrix),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.projectionMatrix.fromArray(Ye.projectionMatrix),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert(),tt.viewport.set(ht.x,ht.y,ht.width,ht.height),Ge===0)L.matrix.copy(tt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(xe===!0)L.cameras.push(tt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let Ge=u.getDepthInformation(se[0]);if(Ge&&Ge.isValid&&Ge.texture)_.init(Ge,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let Ge=0;Ge<se.length;Ge++){let Ye=se[Ge].camera;if(Ye){let ht=p[Ye];if(!ht)ht=new yc,p[Ye]=ht;let tt=u.getCameraImage(Ye);ht.sourceTexture=tt}}}}for(let se=0;se<y.length;se++){let xe=w[se],Ee=y[se];if(xe!==null&&Ee!==void 0)Ee.update(xe,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let we=new km;we.setAnimationLoop(Be),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var MT=new $e,Km=new Ve;Km.set(-1,0,0,0,1,0,0,0,1);function wT(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,nh(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,S,T,y){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),d(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),h(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,S,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===rn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===rn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(MT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(Km);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function d(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function h(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,S){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===rn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ET(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)h(y),s[y.id]=x}function u(y){let w=d();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function d(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let z=A[x];if(Array.isArray(z))for(let C=0,L=z.length;C<L;C++)f(z[C],x,C,R);else f(z,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let z=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,z),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))z+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let z=R[M];if(typeof x==="number"||typeof x==="boolean"){if(z!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(z.equals(x)===!1)return z.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,z=w.length;M<z;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],k=g(j),q=A%R,Q=q%k.boundary,Me=q+Q;if(A+=Q,Me!==0&&R-Me<k.storage)A+=R-Me;I.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=k.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var AT=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),_i=null;function TT(){if(_i===null)_i=new Ro(AT,16,16,kr,pi),_i.name="DFG_LUT",_i.minFilter=qt,_i.magFilter=qt,_i.wrapS=Ts,_i.wrapT=Ts,_i.generateMipmaps=!1,_i.needsUpdate=!0;return _i}class Rh{constructor(e={}){let{canvas:t=sm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=Qn}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=h,_=new Set([pu,fu,du]),p=new Set([Qn,hr,bo,Cs,uu,hu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,z=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=dr;let G=0,X=0,P=null,j=-1,k=null,q=new ft,Q=new ft,Me=null,ue=new ze(0),Be=0,{width:we,height:Z}=t,re=1,se=null,xe=null,Ee=new ft(0,0,we,Z),Ae=new ft(0,0,we,Z),Et=!1,Ge=new Po,Ye=!1,ht=!1,tt=new $e,Jt=new U,At=new ft,mn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},kt=!1;function Bt(){return P===null?re:1}let D=n;function gn(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,_e,Ie,de,oe,De,Fe,st,F,ce,ee,le,ye;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${hp}`);if(t.addEventListener("webglcontextlost",He,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",lt,!1),D===null){if(D=gn("webgl2",b),D===null)if(gn("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ke("WebGLRenderer: "+b.message),b}function ne(){if(ct=new DE(D),ct.init(),ee=new vT(D,ct),Pt=new wE(D,ct,e,ee),E=new xT(D,ct),Pt.reversedDepthBuffer&&d)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new FE(D),N=new rT,H=new yT(D,ct,E,N,Pt,ee,v),ie=new NE(M),ae=new kS(D),le=new SE(D,ae),he=new OE(D,ae,v,le),Y=new kE(D,he,ae,le,v),st=new zE(D,Pt,H),oe=new EE(N),te=new iT(M,ie,ct,Pt,le,oe),_e=new wT(M,N),Ie=new oT,de=new dT(ct),Fe=new bE(M,ie,E,Y,f,a),De=new _T(M,Y,Pt),ye=new ET(D,v,Pt,E),F=new ME(D,ct,v),ce=new UE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=De,M.state=E,M.info=v}if(m!==Qn)x=new VE(m,t.width,t.height,o,i,r);let pe=new Jm(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(we,Z,!1)},this.getSize=function(b){return b.set(we,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(we=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(we*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){we=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===Qn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(Q.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(b){E.setScissorTest(Et=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){xe=b},this.getClearColor=function(b){return b.copy(Fe.getClearColor())},this.setClearColor=function(){Fe.setClearColor(...arguments)},this.getClearAlpha=function(){return Fe.getClearAlpha()},this.setClearAlpha=function(){Fe.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,Se=p.has(ge),me=Fe.getClearColor(),Te=Fe.getClearAlpha(),{r:Pe,g:We,b:Ke}=me;if(Se)g[0]=Pe,g[1]=We,g[2]=Ke,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=We,S[2]=Ke,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",He,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Fe.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ye.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",yf),pe.removeEventListener("sessionend",vf),Rr.stop()};function He(b){b.preventDefault(),go("WebGLRenderer: Context Lost."),z=!0}function bt(){go("WebGLRenderer: Context Restored."),z=!1;let b=v.autoReset,O=De.enabled,W=De.autoUpdate,B=De.needsUpdate,V=De.type;ne(),v.autoReset=b,De.enabled=O,De.autoUpdate=W,De.needsUpdate=B,De.type=V}function lt(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function oi(b){let O=b.target;O.removeEventListener("dispose",oi),Di(O)}function Di(b){Cb(b),N.remove(b)}function Cb(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=mn;let Se=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Lb(b,O,W,B,V);E.setMaterial(B,Se);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let We=W.drawRange,Ke=W.attributes.position,Re=We.start*Pe,ut=(We.start+We.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Ke!==void 0&&Ke!==null)Re=Math.max(Re,0),ut=Math.min(ut,Ke.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let Tt,xt=F;if(Te!==null)Tt=ae.get(Te),xt=ce,xt.setIndex(Tt);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),xt.setMode(D.LINES);else xt.setMode(D.TRIANGLES);else if(V.isLine){let en=B.linewidth;if(en===void 0)en=1;if(E.setLineWidth(en*Bt()),V.isLineSegments)xt.setMode(D.LINES);else if(V.isLineLoop)xt.setMode(D.LINE_LOOP);else xt.setMode(D.LINE_STRIP)}else if(V.isPoints)xt.setMode(D.POINTS);else if(V.isSprite)xt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:en,_multiDrawCounts:ve,_multiDrawCount:ln}=V,it=Te?ae.get(Te).bytesPerElement:1,On=N.get(B).currentProgram.getUniforms();for(let ai=0;ai<ln;ai++)On.setValue(D,"_gl_DrawID",ai),xt.render(en[ai]/it,ve[ai])}else xt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)xt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let en=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,ve=Math.min(W.instanceCount,en);xt.renderInstances(Re,Ft,ve)}else xt.render(Re,Ft)};function xf(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Ye===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===kn&&b.forceSinglePass===!1)b.side=rn,b.needsUpdate=!0,Ma(b,O,B),b.side=ur,b.needsUpdate=!0,Ma(b,O,B),b.side=kn;else Ma(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),Ye===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)De.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let Se=0;Se<ge.length;Se++){let me=ge[Se];xf(me,W,O,V),B.add(me)}else xf(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(Se){let Te=N.get(Se).currentProgram;if(Te===void 0||Te.isReady())B.delete(Se)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let El=null;function Pb(b){if(El)El(b)}function yf(){Rr.stop()}function vf(){Rr.start()}let Rr=new km;if(Rr.setAnimationLoop(Pb),typeof self<"u")Rr.setContext(self);this.setAnimationLoop=function(b){El=b,pe.setAnimationLoop(b),b===null?Rr.stop():Rr.start()},pe.addEventListener("sessionstart",yf),pe.addEventListener("sessionend",vf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),tt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),Ge.setFromProjectionMatrix(tt,Yu,O.reversedDepth),ht=this.localClippingEnabled,Ye=oe.init(this.clippingPlanes,ht),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let Se=M.xr.getDepthSensingMesh();if(Se!==null)Al(Se,O,-1/0,M.sortObjects)}if(Al(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,xe);if(kt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,kt)Fe.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Ye===!0)oe.beginShadows();let V=w.state.shadowsArray;if(De.render(V,b,O),Ye===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let Se=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];Sf(Se,me,b,Ke)}if(kt)Fe.render(b);for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe];bf(y,b,Ke,Ke.viewport)}}else{if(me.length>0)Sf(Se,me,b,O);if(kt)Fe.render(b);bf(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,k=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Ye===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function Al(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(Ge)){if(B)At.setFromMatrixPosition(b.matrixWorld).applyMatrix4(tt);let Se=Y.update(b),me=b.material;if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(Ge)){let Se=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();At.copy(b.boundingSphere.center)}else{if(Se.boundingSphere===null)Se.computeBoundingSphere();At.copy(Se.boundingSphere.center)}At.applyMatrix4(b.matrixWorld).applyMatrix4(tt)}if(Array.isArray(me)){let Te=Se.groups;for(let Pe=0,We=Te.length;Pe<We;Pe++){let Ke=Te[Pe],Re=me[Ke.materialIndex];if(Re&&Re.visible)y.push(b,Se,Re,W,At.z,Ke,O)}}else if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}}let ge=b.children;for(let Se=0,me=ge.length;Se<me;Se++)Al(ge[Se],O,W,B)}function bf(b,O,W,B){let{opaque:V,transmissive:ge,transparent:Se}=b;if(w.setupLightsView(W),Ye===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)Sa(V,O,W);if(ge.length>0)Sa(ge,O,W);if(Se.length>0)Sa(Se,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function Sf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new Mn(1,1,{generateMipmaps:!0,type:Re?pi:Qn,minFilter:fi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:je.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],Se=B.viewport||q;ge.setSize(Se.z*M.transmissionResolutionScale,Se.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Be=M.getClearAlpha(),Be<1)M.setClearColor(16777215,0.5);if(M.clear(),kt)Fe.render(W);let We=M.toneMapping;M.toneMapping=Jn;let Ke=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Ye===!0)oe.setGlobalState(M.clippingPlanes,B);if(Sa(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let Tt=O[ut],{object:xt,geometry:en,material:ve,group:ln}=Tt;if(ve.side===kn&&xt.layers.test(B.layers)){let it=ve.side;ve.side=rn,ve.needsUpdate=!0,Mf(xt,W,B,en,ve,ln),ve.side=it,ve.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Be),Ke!==void 0)B.viewport=Ke;M.toneMapping=We}function Sa(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let Se=b[V],{object:me,geometry:Te,group:Pe}=Se,We=Se.material;if(We.allowOverride===!0&&B!==null)We=B;if(me.layers.test(W.layers))Mf(me,O,W,Te,We,Pe)}}function Mf(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===kn&&V.forceSinglePass===!1)V.side=rn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=ur,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=kn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function Ma(b,O,W){if(O.isScene!==!0)O=mn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,Se=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let We=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,We),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",oi),Pe=new Map,B.programs=Pe;let Ke=Pe.get(Te);if(Ke!==void 0){if(B.currentProgram===Ke&&B.lightsStateVersion===Se)return Ef(b,me),Ke}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Ke=te.acquireProgram(me,Te),Pe.set(Te,Ke),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(Ef(b,me),B.needsLights=Db(b),B.lightsStateVersion=Se,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Ke,B.uniformsList=null,Ke}function wf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=Vo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Ef(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Ib(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Lb(b,O,W,B,V){if(O.isScene!==!0)O=mn;H.resetTextureUnits();let ge=O.fog,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:je.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||Se,Te),We=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Ke=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,Tt=Jn;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)Tt=M.toneMapping}let xt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,en=xt!==void 0?xt.length:0,ve=N.get(B),ln=w.state.lights;if(Ye===!0){if(ht===!0||b!==k){let St=b===k&&B.id===j;oe.setState(B,b,St)}}let it=!1;if(B.version===ve.__version){if(ve.needsLights&&ve.lightsStateVersion!==ln.state.version)it=!0;else if(ve.outputColorSpace!==me)it=!0;else if(V.isBatchedMesh&&ve.batching===!1)it=!0;else if(!V.isBatchedMesh&&ve.batching===!0)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!0&&V._colorsTexture===null)it=!0;else if(V.isBatchedMesh&&ve.batchingColor===!1&&V._colorsTexture!==null)it=!0;else if(V.isInstancedMesh&&ve.instancing===!1)it=!0;else if(!V.isInstancedMesh&&ve.instancing===!0)it=!0;else if(V.isSkinnedMesh&&ve.skinning===!1)it=!0;else if(!V.isSkinnedMesh&&ve.skinning===!0)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!0&&V.instanceColor===null)it=!0;else if(V.isInstancedMesh&&ve.instancingColor===!1&&V.instanceColor!==null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!0&&V.morphTexture===null)it=!0;else if(V.isInstancedMesh&&ve.instancingMorph===!1&&V.morphTexture!==null)it=!0;else if(ve.envMap!==Pe)it=!0;else if(B.fog===!0&&ve.fog!==ge)it=!0;else if(ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==oe.numPlanes||ve.numIntersection!==oe.numIntersection))it=!0;else if(ve.vertexAlphas!==We)it=!0;else if(ve.vertexTangents!==Ke)it=!0;else if(ve.morphTargets!==Re)it=!0;else if(ve.morphNormals!==ut)it=!0;else if(ve.morphColors!==Ft)it=!0;else if(ve.toneMapping!==Tt)it=!0;else if(ve.morphTargetsCount!==en)it=!0;else if(!!ve.lightProbeGrid!==w.state.lightProbeGridArray.length>0)it=!0}else it=!0,ve.__version=B.version;let On=ve.currentProgram;if(it===!0){if(On=Ma(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,On,ve)}let ai=!1,Ki=!1,is=!1,mt=On.getUniforms(),Ot=ve.uniforms;if(E.useProgram(On.program))ai=!0,Ki=!0,is=!0;if(B.id!==j)j=B.id,Ki=!0;if(ve.needsLights){let St=Ib(w.state.lightProbeGridArray,V);if(ve.lightProbeGrid!==St)ve.lightProbeGrid=St,Ki=!0}if(ai||k!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();mt.setValue(D,"projectionMatrix",b.projectionMatrix),mt.setValue(D,"viewMatrix",b.matrixWorldInverse);let er=mt.map.cameraPosition;if(er!==void 0)er.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)mt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)mt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(k!==b)k=b,Ki=!0,is=!0}if(ve.needsLights){if(ln.state.sunShadowMap.length>0)mt.setValue(D,"sunShadowMap",ln.state.sunShadowMap,H);if(ln.state.directionalShadowMap.length>0)mt.setValue(D,"directionalShadowMap",ln.state.directionalShadowMap,H);if(ln.state.spotShadowMap.length>0)mt.setValue(D,"spotShadowMap",ln.state.spotShadowMap,H);if(ln.state.pointShadowMap.length>0)mt.setValue(D,"pointShadowMap",ln.state.pointShadowMap,H)}if(V.isSkinnedMesh){mt.setOptional(D,V,"bindMatrix"),mt.setOptional(D,V,"bindMatrixInverse");let St=V.skeleton;if(St){if(St.boneTexture===null)St.computeBoneTexture();mt.setValue(D,"boneTexture",St.boneTexture,H)}}if(V.isBatchedMesh){if(mt.setOptional(D,V,"batchingTexture"),mt.setValue(D,"batchingTexture",V._matricesTexture,H),mt.setOptional(D,V,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",V._indirectTexture,H),mt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)mt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let Qi=W.morphAttributes;if(Qi.position!==void 0||Qi.normal!==void 0||Qi.color!==void 0)st.update(V,W,On);if(Ki||ve.receiveShadow!==V.receiveShadow)ve.receiveShadow=V.receiveShadow,mt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=TT();if(Ki){if(mt.setValue(D,"toneMappingExposure",M.toneMappingExposure),ve.needsLights)Nb(Ot,is);if(ge&&B.fog===!0)_e.refreshFogUniforms(Ot,ge);if(_e.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),ve.needsLights&&ve.lightProbeGrid){let St=ve.lightProbeGrid;Ot.probesSH.value=St.texture,Ot.probesMin.value.copy(St.boundingBox.min),Ot.probesMax.value.copy(St.boundingBox.max),Ot.probesResolution.value.copy(St.resolution)}Vo.upload(D,wf(ve),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)Vo.upload(D,wf(ve),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)mt.setValue(D,"center",V.center);if(mt.setValue(D,"modelViewMatrix",V.modelViewMatrix),mt.setValue(D,"normalMatrix",V.normalMatrix),mt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let St=B.uniformsGroups;for(let er=0,rs=St.length;er<rs;er++){let Tf=St[er];ye.update(Tf,On),ye.bind(Tf,On)}}return On}function Nb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function Db(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest,E.viewport(q),E.scissor(Q),E.setScissorTest(Me),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let We=b.depthTexture;if(me.__boundDepthTexture!==We){if(We!==null&&N.has(We)&&(b.width!==We.image.width||b.height!==We.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),Q.copy(Ae).multiplyScalar(re).floor(),Me=Et;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(Q),E.setScissorTest(Me),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function Af(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Af(Pe);if(Re.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:We,type:Ke}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Af(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,ee.convert(We),ee.convert(Ke),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let Tt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await am(D,Tt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(Tt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Se=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,Se,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let Se,me,Te,Pe,We,Ke,Re,ut,Ft,Tt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)Se=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,We=W.min.y,Ke=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(Se=Math.floor(Tt.width*Ot),me=Math.floor(Tt.height*Ot),b.isDataArrayTexture)Te=Tt.depth;else if(b.isData3DTexture)Te=Math.floor(Tt.depth*Ot);else Te=1;Pe=0,We=0,Ke=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let xt=ee.convert(O.format),en=ee.convert(O.type),ve;if(O.isData3DTexture)H.setTexture3D(O,0),ve=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),ve=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),ve=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let ln=E.getParameter(D.UNPACK_ROW_LENGTH),it=E.getParameter(D.UNPACK_IMAGE_HEIGHT),On=E.getParameter(D.UNPACK_SKIP_PIXELS),ai=E.getParameter(D.UNPACK_SKIP_ROWS),Ki=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,We),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ke);let is=b.isDataArrayTexture||b.isData3DTexture,mt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),Qi=N.get(O),St=N.get(Ot.__renderTarget),er=N.get(Qi.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,St.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,er.__webglFramebuffer);for(let rs=0;rs<Te;rs++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Ke+rs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+rs);D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),Qi=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let St=0;St<Te;St++){if(is)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Ke+St);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(mt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Qi.__webglTexture,ge,Ft+St);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Qi.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,We,Se,me,Re,ut,Se,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(mt)D.copyTexSubImage3D(ve,ge,Re,ut,Ft+St,Pe,We,Se,me);else D.copyTexSubImage2D(ve,ge,Re,ut,Pe,We,Se,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(mt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,en,Tt.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,Tt.data);else D.texSubImage3D(ve,ge,Re,ut,Ft,Se,me,Te,xt,en,Tt);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,en,Tt.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,Tt.width,Tt.height,xt,Tt.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,xt,en,Tt);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,ln),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,it),E.pixelStorei(D.UNPACK_SKIP_PIXELS,On),E.pixelStorei(D.UNPACK_SKIP_ROWS,ai),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Ki),ge===0&&O.generateMipmaps)D.generateMipmap(ve);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=je._getDrawingBufferColorSpace(e),t.unpackColorSpace=je._getUnpackColorSpace()}}var eg={type:"change"},Ph={type:"start"},ng={type:"end"},Nc=new fr,tg=new Fn,RT=Math.cos(70*Mo.DEG2RAD),Wt=new U,yn=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ch=0.000001;class Ih extends Rc{constructor(e,t=null){super(e,t);if(this.state=pt.NONE,this.target=new U,this.cursor=new U,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cr.ROTATE,MIDDLE:cr.DOLLY,RIGHT:cr.PAN},this.touches={ONE:lr.ROTATE,TWO:lr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Fo,this._sphericalDelta=new Fo,this._scale=1,this._panOffset=new U,this._rotateStart=new Ue,this._rotateEnd=new Ue,this._rotateDelta=new Ue,this._panStart=new Ue,this._panEnd=new Ue,this._panDelta=new Ue,this._dollyStart=new Ue,this._dollyEnd=new Ue,this._dollyDelta=new Ue,this._dollyDirection=new U,this._mouse=new Ue,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=PT.bind(this),this._onPointerDown=CT.bind(this),this._onPointerUp=IT.bind(this),this._onContextMenu=zT.bind(this),this._onMouseWheel=DT.bind(this),this._onKeyDown=OT.bind(this),this._onTouchStart=UT.bind(this),this._onTouchMove=FT.bind(this),this._onMouseDown=LT.bind(this),this._onMouseMove=NT.bind(this),this._interceptControlDown=kT.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=pt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(eg),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===pt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=yn;else if(n>Math.PI)n-=yn;if(i<-Math.PI)i+=yn;else if(i>Math.PI)i-=yn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Wt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Nc.origin.copy(this.object.position),Nc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Nc.direction))<RT)this.object.lookAt(this.target);else tg.setFromNormalAndCoplanarPoint(this.object.up,this.target),Nc.intersectPlane(tg,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)>Ch||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ch||this._lastTargetPosition.distanceToSquared(this.target)>Ch)return this.dispatchEvent(eg),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 yn/60*this.autoRotateSpeed*e;else return yn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*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(yn*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(-yn*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(yn*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(-yn*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(yn*this._rotateDelta.x/t.clientHeight),this._rotateUp(yn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Ue,this._pointerPositions[e.pointerId]=t;t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}if(e.ctrlKey&&!this._controlActive)n.deltaY*=10;return n}}function CT(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 PT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function IT(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(ng),this.state=pt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function LT(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=pt.DOLLY;break;case cr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}break;case cr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=pt.PAN}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Ph)}function NT(e){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function DT(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE)return;e.preventDefault(),this.dispatchEvent(Ph),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ng)}function OT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function UT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=pt.TOUCH_ROTATE;break;case lr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case lr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=pt.TOUCH_DOLLY_PAN;break;case lr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}if(this.state!==pt.NONE)this.dispatchEvent(Ph)}function FT(e){switch(this._trackPointer(e),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=pt.NONE}}function zT(e){if(this.enabled===!1)return;e.preventDefault()}function kT(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 Lh extends Is{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new mr;e.deleteAttribute("uv");let t=new Hi({side:rn}),n=new Hi,i=new Fs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new Mt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new Ns(e,n,6),o=new gt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new Mt(e,Gs(50));a.position.set(-16.116,14.37,8.208),a.scale.set(0.1,2.428,2.739),this.add(a);let c=new Mt(e,Gs(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(0.1,2.425,2.751),this.add(c);let l=new Mt(e,Gs(17));l.position.set(14.904,12.198,-1.832),l.scale.set(0.15,4.265,6.331),this.add(l);let u=new Mt(e,Gs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new Mt(e,Gs(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let h=new Mt(e,Gs(100));h.position.set(0,20,0),h.scale.set(1,0.1,1),this.add(h)}dispose(){let e=new Set;this.traverse((t)=>{if(t.isMesh)e.add(t.geometry),e.add(t.material)});for(let t of e)t.dispose()}}function Gs(e){return new vc({color:0,emissive:16777215,emissiveIntensity:e})}function Nh(e,t){if(t===Zu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Ps||t===So){let n=e.getIndex();if(n===null){let s=[],o=e.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)s.push(a);e.setIndex(s),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}let i=n.count-2,r=[];if(t===Ps)for(let s=1;s<=i;s++)r.push(n.getX(0)),r.push(n.getX(s)),r.push(n.getX(s+1));else for(let s=0;s<i;s++)if(s%2===0)r.push(n.getX(s)),r.push(n.getX(s+1)),r.push(n.getX(s+2));else r.push(n.getX(s+2)),r.push(n.getX(s+1)),r.push(n.getX(s));if(r.length/3!==i)console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");return e.setIndex(r),e.clearGroups(),e}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}function ig(e){let t=new Map,n=new Map,i=e.clone();return rg(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 rg(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)rg(e.children[i],t.children[i],n)}class Bh extends Wi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new dg(t)}),this.register(function(t){return new fg(t)}),this.register(function(t){return new Sg(t)}),this.register(function(t){return new Mg(t)}),this.register(function(t){return new wg(t)}),this.register(function(t){return new mg(t)}),this.register(function(t){return new gg(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new xg(t)}),this.register(function(t){return new hg(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new pg(t)}),this.register(function(t){return new bg(t)}),this.register(function(t){return new vg(t)}),this.register(function(t){return new lg(t)}),this.register(function(t){return new Fh(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Fh(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Eg(t)})}load(e,t,n,i){let r=this,s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){let c=vr.extractUrlBase(e);s=vr.resolveURL(c,this.path)}else s=vr.extractUrlBase(e);this.manager.itemStart(e);let o=function(c){if(i)i(c);else console.error(c);r.manager.itemError(e),r.manager.itemEnd(e)},a=new Oo(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))===Ag){try{s[Je.KHR_BINARY_GLTF]=new Tg(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(a.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){if(i)i(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new Lg(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:s[u]=new ug;break;case Je.KHR_DRACO_MESH_COMPRESSION:s[u]=new Rg(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:s[u]=new Cg;break;case Je.KHR_MESH_QUANTIZATION:s[u]=new Pg;break;default:if(d.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function VT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lg{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],Sn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new zs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Fs(l),c.distance=u;break;case"spot":c=new Ec(l),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}if(c.position.set(0,0,0),yi(c,a),a.intensity!==void 0)c.intensity=a.intensity;return c.name=t.createUniqueName(a.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e!=="light")return;return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;if(o===void 0)return null;return this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class ug{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return gi}extendParams(e,t,n){let i=[];e.color=new ze(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Sn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,dr))}return Promise.all(i)}}class hg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class dg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ue(r,r)}}return Promise.all(i)}}class fg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class pg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class mg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new ze(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],Sn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,dr));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class gg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class _g{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new ze().setRGB(r[0],r[1],r[2],Sn),Promise.all(i)}}class xg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class yg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new ze().setRGB(r[0],r[1],r[2],Sn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,dr));return Promise.all(i)}}class vg{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class bg{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?En:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Sg{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],s=t.options.ktx2Loader;if(!s)if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return t.loadTextureImage(e,r.source,s)}}class Mg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class wg{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let s=r.extensions[t],o=i.images[s.source],a=n.textureLoader;if(o.uri){let c=n.options.manager.getHandler(o.uri);if(c!==null)a=c}return n.loadTextureImage(e,s.source,a)}}class Fh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported)if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return r.then(function(o){let a=i.byteOffset||0,c=i.byteLength||0,{count:l,byteStride:u}=i,d=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,i.mode,i.filter),h})})}else return null}}class Eg{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(let f of u){let m=new $e,_=new U,p=new Xt,g=new U(1,1,1),S=new Ns(f.geometry,f.material,d);for(let y=0;y<d;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new ar(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new sn,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new ar(w.array,w.itemSize,w.normalized))}gt.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),h.push(S)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Ag="glTF",Ho=12,sg={JSON:1313821514,BIN:5130562};class Tg{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Ho),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ag)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");else if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Ho,r=new DataView(e,Ho),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===sg.JSON){let c=new Uint8Array(e,Ho+s,o);this.content=n.decode(c)}else if(a===sg.BIN){let c=Ho+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Rg{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},c={};for(let l in s){let u=zh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=zh[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],h=Hs[d.componentType];c[u]=h.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(h){for(let f in h.attributes){let m=h.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(h)},o,c,Sn,d)})})}}class Cg{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0)e.channel=t.texCoord;if(t.offset!==void 0)e.offset.fromArray(t.offset);if(t.rotation!==void 0)e.rotation=t.rotation;if(t.scale!==void 0)e.repeat.fromArray(t.scale);if(t.rotation!==void 0){let n=Math.cos(e.rotation),i=Math.sin(e.rotation);e.matrix.set(e.repeat.x*n,e.repeat.y*i,e.offset.x,-e.repeat.x*i,e.repeat.y*n,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}}class Pg{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class Vh extends $i{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,d=u*u,h=d*u,f=e*c,m=f-c,_=-2*h+3*d,p=h-d,g=1-_,S=p-d+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var GT=new Xt;class Ig extends Vh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return GT.fromArray(r).normalize().toArray(r),r}}var Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},og={9728:Kn,9729:qt,9984:tc,9985:Rs,9986:Ur,9987:fi},ag={33071:Ts,33648:ec,10497:As},Dh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},br={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},HT={CUBICSPLINE:void 0,LINEAR:cc,STEP:Wu},Oh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function $T(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new Hi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ur});return e.DefaultMaterial}function Zr(e,t,n){for(let i in n.extensions)if(e[i]===void 0)t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i]}function yi(e,t){if(t.extras!==void 0)if(typeof t.extras==="object")Object.assign(e.userData,t.extras);else console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras)}function WT(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let h=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;o.push(h)}if(r){let h=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function ZT(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 XT(e){let t,n=e.extensions&&e.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(n)t="draco:"+n.bufferView+":"+n.indices+":"+Uh(n.attributes);else t=e.indices+":"+Uh(e.attributes)+":"+e.mode;if(e.targets!==void 0)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+Uh(e.targets[i]);return t}function Uh(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 kh(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 jT(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 qT=new $e;class Lg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new VT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,s=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;let a=o.match(/Version\/(\d+)/);i=n&&a?parseInt(a[1],10):-1,r=o.indexOf("Firefox")>-1,s=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||n&&i<17||r&&s<98)this.textureLoader=new Os(this.options.manager);else this.textureLoader=new Ac(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Oo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){let o={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Zr(r,o,i),yi(o,i),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(let a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i].joints;for(let o=0,a=s.length;o<a;o++)e[s[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let s=e[i];if(s.mesh!==void 0){if(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0)n[s.mesh].isSkinnedMesh=!0}if(s.camera!==void 0)this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){if(t===void 0)return;if(e.refs[t]===void 0)e.refs[t]=e.uses[t]=0;e.refs[t]++}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(s,o)=>{let a=this.associations.get(s);if(a!=null)this.associations.set(o,a);for(let[c,l]of s.children.entries())r(l,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,s){n.load(vr.resolveURL(t.uri,i.path),r,void 0,function(){s(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let s=Dh[i.type],o=Hs[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Dh[i.type],c=Hs[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(h&&h!==u){let p=Math.floor(d/h),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*h,i.count*h/l),S=new Ao(m,h/l),t.cache.add(g,S);_=new Ls(S,a,d%h/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,d,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Dh.SCALAR,g=Hs[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=og[d.magFilter]||qt,l.minFilter=og[d.minFilter]||fi,l.wrapS=ag[d.wrapS]||As,l.wrapT=ag[d.wrapT]||As,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==Kn&&l.minFilter!==qt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(d),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(d,h){let f=d;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,d(_)};t.load(vr.resolveURL(u,r.path),f,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return yi(u,s),u.userData.mimeType=s.mimeType||jT(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0)s=s.clone(),s.channel=n.texCoord;if(r.extensions[Je.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,a)}}if(i!==void 0)s.colorSpace=i;return e[t]=s,s})}assignFinalMaterial(e){let{geometry:t,material:n}=e,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){let o="PointsMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Lo,xn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Io,xn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return Hi}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Je.KHR_MATERIALS_UNLIT]){let u=i[Je.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Sn),o.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,dr));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=kn;let l=r.alphaMode||Oh.OPAQUE;if(l===Oh.BLEND)o.transparent=!0,o.depthWrite=!1;else if(o.transparent=!1,l===Oh.MASK)o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:0.5;if(r.normalTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ue(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==gi){if(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0)o.aoMapIntensity=r.occlusionTexture.strength}if(r.emissiveFactor!==void 0&&s!==gi){let u=r.emissiveFactor;o.emissive=new ze().setRGB(u[0],u[1],u[2],Sn)}if(r.emissiveTexture!==void 0&&s!==gi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,dr));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(yi(u,r),t.associations.set(u,{materials:e}),r.extensions)Zr(i,u,r);return u})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return cg(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=XT(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=cg(new sn,c,t);if(c.mode===Vn.TRIANGLE_STRIP)d=d.then((h)=>Nh(h,So));else if(c.mode===Vn.TRIANGLE_FAN)d=d.then((h)=>Nh(h,Ps));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?$T(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,f=l.length;h<f;h++){let m=l[h],_=s[h],p,g=c[h];if(_.mode===Vn.TRIANGLES||_.mode===Vn.TRIANGLE_STRIP||_.mode===Vn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new mc(m,g):new Mt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Vn.LINES)p=new gc(m,g);else if(_.mode===Vn.LINE_STRIP)p=new pr(m,g);else if(_.mode===Vn.LINE_LOOP)p=new _c(m,g);else if(_.mode===Vn.POINTS)p=new Ds(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)ZT(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),yi(p,r),_.extensions)Zr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let h=0,f=u.length;h<f;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Zr(i,u[0],r);return u[0]}let d=new li;if(r.extensions)Zr(i,d,r);t.associations.set(d,{meshes:e});for(let h=0,f=u.length;h<f;h++)d.add(u[h]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Vt(Mo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new $r(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return yi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let d=new $e;if(r!==null)d.fromArray(r.array,c*16);a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Co(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let h=i.channels[u],f=i.samplers[h.sampler],m=h.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],h=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=d.length;S<T;S++){let y=d[S],w=h[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let z=0;z<M.length;z++)p.push(M[z])}let g=new Ss(r,void 0,p);return yi(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(d,qT)});for(let h=0,f=u.length;h<f;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new To;else if(c.length>1)l=new li;else if(c.length===1)l=c[0];else l=new gt;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(yi(l,r),r.extensions)Zr(n,l,r);if(r.matrix!==void 0){let u=new $e;u.fromArray(r.matrix),l.applyMatrix4(u)}else{if(r.translation!==void 0)l.position.fromArray(r.translation);if(r.rotation!==void 0)l.quaternion.fromArray(r.rotation);if(r.scale!==void 0)l.scale.fromArray(r.scale)}if(!i.associations.has(l))i.associations.set(l,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let u=i.associations.get(l);i.associations.set(l,{...u})}return i.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new li;if(n.name)r.name=i.createUniqueName(n.name);if(yi(r,n),n.extensions)Zr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let d=a[l];if(d.parent!==null)r.add(ig(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,h]of i.associations)if(d instanceof xn||d instanceof Nt)u.set(d,h);return l.traverse((d)=>{let h=i.associations.get(d);if(h!=null)u.set(d,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(br[r.path]===br.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(br[r.path]){case br.weights:l=_r;break;case br.rotation:l=xr;break;case br.translation:case br.scale:l=Hr;break;default:switch(n.itemSize){case 1:l=_r;break;case 2:case 3:default:l=Hr;break}break}let u=i.interpolation!==void 0?HT[i.interpolation]:cc,d=this._getArrayFromAccessor(n);for(let h=0,f=a.length;h<f;h++){let m=new l(a[h]+"."+br[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=kh(t.constructor),i=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){return new(this instanceof xr?Ig:Vh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function YT(e,t,n){let i=t.attributes,r=new Gt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=kh(Hs[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let h=n.json.accessors[d.POSITION],{min:f,max:m}=h;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),h.normalized){let _=kh(Hs[h.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new wn;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function cg(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=zh[o]||o.toLowerCase();if(a in e.attributes)continue;r.push(s(i[o],a))}if(t.indices!==void 0&&!e.index){let o=n.getDependency("accessor",t.indices).then(function(a){e.setIndex(a)});r.push(o)}if(je.workingColorSpace!==Sn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${je.workingColorSpace}" not supported.`);return yi(e,t),YT(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?WT(e,t.targets,n):e})}function Wo(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 Hh(e,t="|"){return e.map((n)=>Zh(n)).join(t)}function Zo(e,t){if(typeof t==="bigint")return t.toString();return t}class Ng{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 Xo(e){return new Ng(e)}function Dg(e){return e===null||e===void 0}function Mr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Og(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-i)<r)return 0;return n-i}function Gn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function jo(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Zi(e){return jo(e._zod.def)??e._zod.def.shape}function Ug(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Gn(this,t,i),i},enumerable:!0,configurable:!0})}function Fg(e,t,n){if(t in e)Gn(e,t,n);else e[t]=n}function Xr(e,t,n,i){let r=Zi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)Ug(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Fg(e,s,i?i(o.value,s):o.value)}}function JT(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)Ug(e,n,()=>t[n]);else Fg(e,n,i.value)}}function Tn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function zg(e){return JSON.stringify(e)}function kg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var $h="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $s(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Bg=Xo(()=>{if(hn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function jr(e){if($s(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if($s(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Wh(e){if(jr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Vg=new Set(["string","number","symbol"]),Gg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ji(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(e,t,n){let i=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)i._zod.parent=e;return i}function Ce(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Zh(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Hg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Dc=(()=>({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]}))(),Xh={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function KT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Xr(s,e,Oc(e,t)),vi(e,Tn(n,{shape:s,checks:[]}))}function Oc(e,t){let n=Zi(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function QT(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Oc(e,t)),o={};return Xr(o,e,Reflect.ownKeys(Zi(e)).filter((a)=>!s.has(a))),vi(e,Tn(n,{shape:o,checks:[]}))}function e1(e,t){if(!jr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Zi(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return vi(e,Tn(e._zod.def,{shape:$g(e,t)}))}function $g(e,t){let n={};return Xr(n,e,Reflect.ownKeys(Zi(e))),JT(n,t),n}function t1(e,t){if(!jr(t))throw Error("Invalid input to safeExtend: expected a plain object");return vi(e,Tn(e._zod.def,{shape:$g(e,t)}))}function n1(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Xr(n,e,Reflect.ownKeys(Zi(e))),Xr(n,t,Reflect.ownKeys(Zi(t)));let i=Tn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return vi(e,i)}function Wg(e,t,n,i="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let a=n?new Set(Oc(t,n)):void 0,c={};return Xr(c,t,Reflect.ownKeys(Zi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),vi(t,Tn(t._zod.def,{shape:c,checks:[]}))}function i1(e,t,n){let i=n?new Set(Oc(t,n)):void 0,r={};return Xr(r,t,Reflect.ownKeys(Zi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),vi(t,Tn(t._zod.def,{shape:r}))}function Hn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zg(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function bi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function $o(e){return typeof e==="string"?e:e?.message}function jh(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Si(e,t,n){var i;let r=e.inst?._zod?.traits;if(r?.has("$ZodType"))if(r.has("$ZodCheck"))(i=e).schema??(i.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:$o(e.inst?._zod.def?.error?.(e))??$o(s?.(e))??$o(t?.error?.(e))??$o(n.customError?.(e))??$o(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var r1=/[\uD800-\uDBFF]/;function Uc(e){let t=e.length;if(!r1.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 Fc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Xg(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function qr(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function jg(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else s1(e,n,i.value)}}function Xi(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function zc(e,t,n){return Xi(e,t,n,!1)}function qg(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Xi(this,n,i(this))},set(r){Xi(this,n,r)}})}return t}function s1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Xi(this,t,n.bind(this))},set(i){Xi(this,t,i)}})}function o1(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Gh,Sr=!1,a1={configurable:!0,get(){Sr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Gh!==e._zod){Gh=void 0;return}Gh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,a1);let r=Sr;Sr=!1;try{let s=n(this);if(Sr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Sr=Sr||r,s}catch(s){throw delete this[t],Sr=Sr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function c1(e,t,n,i){let r=o1(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 l1="~constantCatch";function Yg(e){let t=()=>e;return t[l1]=!0,t}var Jg;var qh={value:void 0,enumerable:!1},Kg="captureStackTrace"in Error?Error:null;function u1(e){let t=Kg;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Kg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=d,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,f){if(!h._zod){qh.value=new s(f);try{Object.defineProperty(h,"_zod",qh)}finally{qh.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),p=h._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),jg(S,o)}let m=d.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in h))h[_]=m[_].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(h){let f=i?.Parent?u1(u):this;c(f,h);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Mi extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Jg=globalThis).__zod_globalConfig??(Jg.__zod_globalConfig={});var hn=globalThis.__zod_globalConfig;function Rn(e){if(e)Object.assign(hn,e);return hn}function h1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Zo,2)),e.message}function d1(e){this._zod.message=e}var f1={get:h1,set:d1,enumerable:!0,configurable:!0},Jh={value:void 0,enumerable:!1},Qg=new WeakSet([Object.prototype,Error.prototype]),e_=(e,t)=>{e.name="$ZodError",Jh.value=t,Object.defineProperty(e,"issues",Jh),Jh.value=void 0,Object.defineProperty(e,"message",f1);let n=Object.getPrototypeOf(e);if(!Qg.has(n))Qg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}})},t_=J("$ZodError",e_),UN=J("$ZodError",e_,void 0,{Parent:Error});function p1(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 n_(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)p1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function i_(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],d=l===a.length-1;if(u==="_errors"){if(d)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(d)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function kc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Bc=(e)=>{let t=(n,i,r,s)=>{let o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new Mi;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Rn())));throw $h(c,s?.callee??t),c}return a.value};return t};var Vc=(e)=>{let t=async(n,i,r,s)=>{let o=r?{...r,async:!0}:{async:!0},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Si(l,o,Rn())));throw $h(c,s?.callee??t),c}return a.value};return t};var Gc=(e)=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Mi;return s.issues.length?r_(e,s.issues,r):{success:!0,data:s.value}};function r_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>Si(r,n,Rn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Hc=(e)=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?r_(e,s.issues,r):{success:!0,data:s.value}};var m1=Symbol.for("zod.compile.invalid"),g1=Symbol.for("zod.compile.fallback"),Kh=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==m1)return!0;if(i.definite===!0&&n===void 0)return!1}return _1(e,t,n)};function _1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[g1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Mi;return s.issues.length===0}var Qh=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},s_=(e)=>{let t=Bc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,kc(n,o))};return n};var o_=(e)=>{let t=Bc(e),n=(i,r,s,o)=>t(i,r,s,kc(n,o));return n};var a_=(e)=>{let t=Vc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,kc(n,o))};return n};var c_=(e)=>{let t=Vc(e),n=async(i,r,s,o)=>await t(i,r,s,kc(n,o));return n};var l_=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Gc(e)(t,n,r)};var u_=(e)=>(t,n,i)=>Gc(e)(t,n,i);var h_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Hc(e)(t,n,r)};var d_=(e)=>async(t,n,i)=>Hc(e)(t,n,i);var f_=/^[cC][0-9a-z]{6,}$/,p_=/^[0-9a-z]+$/,m_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,g_=/^[0-9a-vA-V]{20}$/,__=/^[A-Za-z0-9]{27}$/,x_=/^[a-zA-Z0-9_-]{21}$/;function y_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var v_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var b_=/^([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})$/,td=(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 S_=/^(?:[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 x1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function M_(){return new RegExp(x1,"u")}var w_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,E_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var A_=/^((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])$/,T_=/^(([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])$/,R_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,C_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var P_=/^https?$/,I_=/^\+[1-9]\d{6,14}$/;var L_="(?:(?:\\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 y1(e){return new RegExp(`^${e}$`)}var N_=y1(L_);function ed(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 D_(e){return new RegExp(`^${ed(e)}$`)}function O_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${ed({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${ed({precision:e.precision})}`:n;return new RegExp(`^${L_}T(?:${i})$`)}var U_=/^[\s\S]{0,}$/,F_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var $c=/^-?\d+$/,Ws=/^-?\d+(?:\.\d+)?$/,z_=/^(?:true|false)$/i;var k_=/^[^A-Z]*$/,B_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var nd=(e)=>{let t=e.value;return!Dg(t)&&t.length!==void 0},Wc={number:"number",bigint:"bigint",object:"date"},id=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Wc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Wc[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})}}),rd=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Wc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Wc[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})}}),V_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Og(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})}}),G_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Dc[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 H_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?Uc(r):s)<=t.maximum)return;let a=Fc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?Uc(r):s)>=t.minimum)return;let a=Fc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),W_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=nd),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?Uc(r):s;if(o===t.length)return;let a=Fc(r),c=o>t.length;i.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Jo=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Z_=J("$ZodCheckRegex",(e,t)=>{Jo.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),X_=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=k_),Jo.init(e,t)}),j_=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=B_),Jo.init(e,t)}),q_=J("$ZodCheckIncludes",(e,t)=>{Kt.init(e,t);let n=ji(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Y_=J("$ZodCheckStartsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`^${ji(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),J_=J("$ZodCheckEndsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`.*${ji(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var K_=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class sd{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 rg{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ac(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 $n({vertexShader:IT,fragmentShader:LT,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new wt(new zo(20,20),n)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class sg extends ri{constructor(e,t){super();let n=this,i=null,r=1,s=null,o="local-floor",a=1,c=null,l=null,u=null,d=null,h=null,f=null,m=typeof XRWebGLBinding<"u",_=new rg,p={},g=t.getContextAttributes(),S=null,T=null,y=[],w=[],A=new Fe,R=null,x=null,M=new Vt;M.viewport=new pt;let k=new Vt;k.viewport=new pt;let C=[M,k],L=new vh,K=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];if(re===void 0)re=new Io,y[Z]=re;return re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];if(re===void 0)re=new Io,y[Z]=re;return re.getGripSpace()},this.getHand=function(Z){let re=y[Z];if(re===void 0)re=new Io,y[Z]=re;return re.getHandSpace()};function G(Z){let re=w.indexOf(Z.inputSource);if(re===-1)return;let se=y[re];if(se!==void 0)se.update(Z.inputSource,Z.frame,c||s),se.dispatchEvent({type:Z.type,data:Z.inputSource})}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",P);for(let Z=0;Z<y.length;Z++){let re=w[Z];if(re===null)continue;w[Z]=null,y[Z].disconnect(re)}K=null,I=null,_.reset();for(let Z in p)delete p[Z];if(e.setRenderTarget(S),h=null,d=null,u=null,i=null,T=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(A.width,A.height,!1),x!==null){let Z=x.camera;Z.fov=x.fov,Z.zoom=x.zoom,Z.updateProjectionMatrix(),x=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){if(r=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){if(o=Z,n.isPresenting===!0)Le("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:h},this.getBinding=function(){if(u===null&&m)u=new XRWebGLBinding(i,t);return u},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",P),g.xrCompatible!==!0)await t.makeXRCompatible();if(R=e.getPixelRatio(),e.getSize(A),!(m&&("createProjectionLayer"in XRWebGLBinding.prototype))){let se={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};h=new XRWebGLLayer(i,t,se),i.updateRenderState({baseLayer:h}),e.setPixelRatio(1),e.setSize(h.framebufferWidth,h.framebufferHeight,!1),T=new En(h.framebufferWidth,h.framebufferHeight,{format:_i,type:ii,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let se=null,ye=null,Ee=null;if(g.depth)Ee=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=g.stencil?Hr:Gr,ye=g.stencil?Ds:gr;let Ae={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new En(d.textureWidth,d.textureHeight,{format:_i,type:ii,depthTexture:new Zr(d.textureWidth,d.textureHeight,ye,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(a),c=null,s=await i.requestReferenceSpace(o),we.setContext(i),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function P(Z){for(let re=0;re<Z.removed.length;re++){let se=Z.removed[re],ye=w.indexOf(se);if(ye>=0)w[ye]=null,y[ye].disconnect(se)}for(let re=0;re<Z.added.length;re++){let se=Z.added[re],ye=w.indexOf(se);if(ye===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=w.length){w.push(se),ye=Ae;break}else if(w[Ae]===null){w[Ae]=se,ye=Ae;break}if(ye===-1)break}let Ee=y[ye];if(Ee)Ee.connect(se)}}let j=new U,z=new U;function q(Z,re,se){j.setFromMatrixPosition(re.matrixWorld),z.setFromMatrixPosition(se.matrixWorld);let ye=j.distanceTo(z),Ee=re.projectionMatrix.elements,Ae=se.projectionMatrix.elements,Et=Ee[14]/(Ee[10]-1),He=Ee[14]/(Ee[10]+1),Je=(Ee[9]+1)/Ee[5],dt=(Ee[9]-1)/Ee[5],nt=(Ee[8]-1)/Ee[0],Jt=(Ae[8]+1)/Ae[0],At=Et*nt,gn=Et*Jt,zt=ye/(-nt+Jt),Bt=zt*-nt;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Bt),Z.translateZ(zt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ee[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let D=Et+zt,_n=He+zt,ct=At-Bt,Pt=gn+(ye-Bt),E=Je*He/_n*D,v=dt*He/_n*D;Z.projectionMatrix.makePerspective(ct,Pt,E,v,D,_n),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function Q(Z,re){if(re===null)Z.matrixWorld.copy(Z.matrix);else Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix);Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;let{near:re,far:se}=Z;if(_.texture!==null){if(_.depthNear>0)re=_.depthNear;if(_.depthFar>0)se=_.depthFar}if(L.near=k.near=M.near=re,L.far=k.far=M.far=se,K!==L.near||I!==L.far)i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,I=L.far;L.layers.mask=Z.layers.mask|6,M.layers.mask=L.layers.mask&-5,k.layers.mask=L.layers.mask&-3;let ye=Z.parent,Ee=L.cameras;Q(L,ye);for(let Ae=0;Ae<Ee.length;Ae++)Q(Ee[Ae],ye);if(Ee.length===2)q(L,M,k);else L.projectionMatrix.copy(M.projectionMatrix);if(x===null&&Z.isPerspectiveCamera)x={camera:Z,fov:Z.fov,zoom:Z.zoom};Me(Z,L,ye)};function Me(Z,re,se){if(se===null)Z.matrix.copy(re.matrixWorld);else Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld);if(Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera)Z.fov=zr*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1}this.getCamera=function(){return L},this.getFoveation=function(){if(d===null&&h===null)return;return a},this.setFoveation=function(Z){if(a=Z,d!==null)d.fixedFoveation=Z;if(h!==null&&h.fixedFoveation!==void 0)h.fixedFoveation=Z},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(L)},this.getCameraTexture=function(Z){return p[Z]};let ue=null;function Ve(Z,re){if(l=re.getViewerPose(c||s),f=re,l!==null){let se=l.views;if(h!==null)e.setRenderTargetFramebuffer(T,h.framebuffer),e.setRenderTarget(T);let ye=!1;if(se.length!==L.cameras.length)L.cameras.length=0,ye=!0;for(let He=0;He<se.length;He++){let Je=se[He],dt=null;if(h!==null)dt=h.getViewport(Je);else{let Jt=u.getViewSubImage(d,Je);if(dt=Jt.viewport,He===0)e.setRenderTargetTextures(T,Jt.colorTexture,Jt.depthStencilTexture),e.setRenderTarget(T)}let nt=C[He];if(nt===void 0)nt=new Vt,nt.layers.enable(He),nt.viewport=new pt,C[He]=nt;if(nt.matrix.fromArray(Je.transform.matrix),nt.matrix.decompose(nt.position,nt.quaternion,nt.scale),nt.projectionMatrix.fromArray(Je.projectionMatrix),nt.projectionMatrixInverse.copy(nt.projectionMatrix).invert(),nt.viewport.set(dt.x,dt.y,dt.width,dt.height),He===0)L.matrix.copy(nt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale);if(ye===!0)L.cameras.push(nt)}let Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&m){u=n.getBinding();let He=u.getDepthInformation(se[0]);if(He&&He.isValid&&He.texture)_.init(He,i.renderState)}if(Ee&&Ee.includes("camera-access")&&m){e.state.unbindTexture(),u=n.getBinding();for(let He=0;He<se.length;He++){let Je=se[He].camera;if(Je){let dt=p[Je];if(!dt)dt=new Ac,p[Je]=dt;let nt=u.getCameraImage(Je);dt.sourceTexture=nt}}}}for(let se=0;se<y.length;se++){let ye=w[se],Ee=y[se];if(ye!==null&&Ee!==void 0)Ee.update(ye,re,c||s)}if(ue)ue(Z,re);if(re.detectedPlanes)n.dispatchEvent({type:"planesdetected",data:re});f=null}let we=new Xm;we.setAnimationLoop(Ve),this.setAnimationLoop=function(Z){ue=Z},this.dispose=function(){}}}var NT=new We,og=new Ge;og.set(-1,0,0,0,1,0,0,0,1);function DT(e,t){function n(p,g){if(p.matrixAutoUpdate===!0)p.updateMatrix();g.value.copy(p.matrix)}function i(p,g){if(g.color.getRGB(p.fogColor.value,uh(e)),g.isFog)p.fogNear.value=g.near,p.fogFar.value=g.far;else if(g.isFogExp2)p.fogDensity.value=g.density}function r(p,g,S,T,y){if(g.isNodeMaterial)g.uniformsNeedUpdate=!1;else if(g.isMeshBasicMaterial)s(p,g);else if(g.isMeshLambertMaterial){if(s(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshToonMaterial)s(p,g),d(p,g);else if(g.isMeshPhongMaterial){if(s(p,g),u(p,g),g.envMap)p.envMapIntensity.value=g.envMapIntensity}else if(g.isMeshStandardMaterial){if(s(p,g),h(p,g),g.isMeshPhysicalMaterial)f(p,g,y)}else if(g.isMeshMatcapMaterial)s(p,g),m(p,g);else if(g.isMeshDepthMaterial)s(p,g);else if(g.isMeshDistanceMaterial)s(p,g),_(p,g);else if(g.isMeshNormalMaterial)s(p,g);else if(g.isLineBasicMaterial){if(o(p,g),g.isLineDashedMaterial)a(p,g)}else if(g.isPointsMaterial)c(p,g,S,T);else if(g.isSpriteMaterial)l(p,g);else if(g.isShadowMaterial)p.color.value.copy(g.color),p.opacity.value=g.opacity;else if(g.isShaderMaterial)g.uniformsNeedUpdate=!1}function s(p,g){if(p.opacity.value=g.opacity,g.color)p.diffuse.value.copy(g.color);if(g.emissive)p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity);if(g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.bumpMap){if(p.bumpMap.value=g.bumpMap,n(g.bumpMap,p.bumpMapTransform),p.bumpScale.value=g.bumpScale,g.side===rn)p.bumpScale.value*=-1}if(g.normalMap){if(p.normalMap.value=g.normalMap,n(g.normalMap,p.normalMapTransform),p.normalScale.value.copy(g.normalScale),g.side===rn)p.normalScale.value.negate()}if(g.displacementMap)p.displacementMap.value=g.displacementMap,n(g.displacementMap,p.displacementMapTransform),p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias;if(g.emissiveMap)p.emissiveMap.value=g.emissiveMap,n(g.emissiveMap,p.emissiveMapTransform);if(g.specularMap)p.specularMap.value=g.specularMap,n(g.specularMap,p.specularMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest;let S=t.get(g),{envMap:T,envMapRotation:y}=S;if(T){if(p.envMap.value=T,p.envMapRotation.value.setFromMatrix4(NT.makeRotationFromEuler(y)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1)p.envMapRotation.value.premultiply(og);p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio}if(g.lightMap)p.lightMap.value=g.lightMap,p.lightMapIntensity.value=g.lightMapIntensity,n(g.lightMap,p.lightMapTransform);if(g.aoMap)p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity,n(g.aoMap,p.aoMapTransform)}function o(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,g.map)p.map.value=g.map,n(g.map,p.mapTransform)}function a(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function c(p,g,S,T){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*S,p.scale.value=T*0.5,g.map)p.map.value=g.map,n(g.map,p.uvTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function l(p,g){if(p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map)p.map.value=g.map,n(g.map,p.mapTransform);if(g.alphaMap)p.alphaMap.value=g.alphaMap,n(g.alphaMap,p.alphaMapTransform);if(g.alphaTest>0)p.alphaTest.value=g.alphaTest}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,0.0001)}function d(p,g){if(g.gradientMap)p.gradientMap.value=g.gradientMap}function h(p,g){if(p.metalness.value=g.metalness,g.metalnessMap)p.metalnessMap.value=g.metalnessMap,n(g.metalnessMap,p.metalnessMapTransform);if(p.roughness.value=g.roughness,g.roughnessMap)p.roughnessMap.value=g.roughnessMap,n(g.roughnessMap,p.roughnessMapTransform);if(g.envMap)p.envMapIntensity.value=g.envMapIntensity}function f(p,g,S){if(p.ior.value=g.ior,g.sheen>0){if(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap)p.sheenColorMap.value=g.sheenColorMap,n(g.sheenColorMap,p.sheenColorMapTransform);if(g.sheenRoughnessMap)p.sheenRoughnessMap.value=g.sheenRoughnessMap,n(g.sheenRoughnessMap,p.sheenRoughnessMapTransform)}if(g.clearcoat>0){if(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap)p.clearcoatMap.value=g.clearcoatMap,n(g.clearcoatMap,p.clearcoatMapTransform);if(g.clearcoatRoughnessMap)p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,n(g.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform);if(g.clearcoatNormalMap){if(p.clearcoatNormalMap.value=g.clearcoatNormalMap,n(g.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===rn)p.clearcoatNormalScale.value.negate()}}if(g.dispersion>0)p.dispersion.value=g.dispersion;if(g.retroreflectivity>0)p.retroreflectivity.value=g.retroreflectivity;if(g.iridescence>0){if(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap)p.iridescenceMap.value=g.iridescenceMap,n(g.iridescenceMap,p.iridescenceMapTransform);if(g.iridescenceThicknessMap)p.iridescenceThicknessMap.value=g.iridescenceThicknessMap,n(g.iridescenceThicknessMap,p.iridescenceThicknessMapTransform)}if(g.transmission>0){if(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap)p.transmissionMap.value=g.transmissionMap,n(g.transmissionMap,p.transmissionMapTransform);if(p.thickness.value=g.thickness,g.thicknessMap)p.thicknessMap.value=g.thicknessMap,n(g.thicknessMap,p.thicknessMapTransform);p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)}if(g.anisotropy>0){if(p.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap)p.anisotropyMap.value=g.anisotropyMap,n(g.anisotropyMap,p.anisotropyMapTransform)}if(p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularColorMap)p.specularColorMap.value=g.specularColorMap,n(g.specularColorMap,p.specularColorMapTransform);if(g.specularIntensityMap)p.specularIntensityMap.value=g.specularIntensityMap,n(g.specularIntensityMap,p.specularIntensityMapTransform)}function m(p,g){if(g.matcap)p.matcap.value=g.matcap}function _(p,g){let S=t.get(g).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function OT(e,t,n,i){let r={},s={},o=[],a=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,w){let A=w.program;i.uniformBlockBinding(y,A)}function l(y,w){let A=r[y.id];if(A===void 0)p(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",S);let R=w.program;i.updateUBOMapping(y,R);let x=t.render.frame;if(s[y.id]!==x)h(y),s[y.id]=x}function u(y){let w=d();y.__bindingPointIndex=w;let A=e.createBuffer(),{__size:R,usage:x}=y;return e.bindBuffer(e.UNIFORM_BUFFER,A),e.bufferData(e.UNIFORM_BUFFER,R,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,A),A}function d(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return Be("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(y){let w=r[y.id],{uniforms:A,__cache:R}=y;e.bindBuffer(e.UNIFORM_BUFFER,w);for(let x=0,M=A.length;x<M;x++){let k=A[x];if(Array.isArray(k))for(let C=0,L=k.length;C<L;C++)f(k[C],x,C,R);else f(k,x,0,R)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function f(y,w,A,R){if(_(y,w,A,R)===!0){let{__offset:x,value:M}=y;if(Array.isArray(M)){let k=0;for(let C=0;C<M.length;C++){let L=M[C],K=g(L);if(m(L,y.__data,k),typeof L!=="number"&&typeof L!=="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L))k+=K.storage/Float32Array.BYTES_PER_ELEMENT}}else m(M,y.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,x,y.__data)}}function m(y,w,A){if(typeof y==="number"||typeof y==="boolean")w[0]=y;else if(y.isMatrix3)w[0]=y.elements[0],w[1]=y.elements[1],w[2]=y.elements[2],w[3]=0,w[4]=y.elements[3],w[5]=y.elements[4],w[6]=y.elements[5],w[7]=0,w[8]=y.elements[6],w[9]=y.elements[7],w[10]=y.elements[8],w[11]=0;else if(ArrayBuffer.isView(y))w.set(new y.constructor(y.buffer,y.byteOffset,w.length));else y.toArray(w,A)}function _(y,w,A,R){let x=y.value,M=w+"_"+A;if(R[M]===void 0){if(typeof x==="number"||typeof x==="boolean")R[M]=x;else if(ArrayBuffer.isView(x))R[M]=x.slice();else R[M]=x.clone();return!0}else{let k=R[M];if(typeof x==="number"||typeof x==="boolean"){if(k!==x)return R[M]=x,!0}else if(ArrayBuffer.isView(x))return!0;else if(k.equals(x)===!1)return k.copy(x),!0}return!1}function p(y){let w=y.uniforms,A=0,R=16;for(let M=0,k=w.length;M<k;M++){let C=Array.isArray(w[M])?w[M]:[w[M]];for(let L=0,K=C.length;L<K;L++){let I=C[L],G=Array.isArray(I.value)?I.value:[I.value];for(let X=0,P=G.length;X<P;X++){let j=G[X],z=g(j),q=A%R,Q=q%z.boundary,Me=q+Q;if(A+=Q,Me!==0&&R-Me<z.storage)A+=R-Me;I.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=z.storage}}}let x=A%R;if(x>0)A+=R-x;return y.__size=A,y.__cache={},this}function g(y){let w={boundary:0,storage:0};if(typeof y==="number"||typeof y==="boolean")w.boundary=4,w.storage=4;else if(y.isVector2)w.boundary=8,w.storage=8;else if(y.isVector3||y.isColor)w.boundary=16,w.storage=12;else if(y.isVector4)w.boundary=16,w.storage=16;else if(y.isMatrix3)w.boundary=48,w.storage=48;else if(y.isMatrix4)w.boundary=64,w.storage=64;else if(y.isTexture)Le("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(y))w.boundary=16,w.storage=y.byteLength;else Le("WebGLRenderer: Unsupported uniform value type.",y);return w}function S(y){let w=y.target;w.removeEventListener("dispose",S);let A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),e.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function T(){for(let y in r)e.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:c,update:l,dispose:T}}var UT=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]),yi=null;function FT(){if(yi===null)yi=new Do(UT,16,16,$r,gi),yi.name="DFG_LUT",yi.minFilter=qt,yi.magFilter=qt,yi.wrapS=Ls,yi.wrapT=Ls,yi.generateMipmaps=!1,yi.needsUpdate=!0;return yi}class Uh{constructor(e={}){let{canvas:t=fm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:c=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:h=ii}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=s;let m=h,_=new Set([Su,bu,vu]),p=new Set([ii,gr,To,Ds,xu,yu]),g=new Uint32Array(4),S=new Int32Array(4),T=new U,y=null,w=null,A=[],R=[],x=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ti,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let M=this,k=!1,C=null,L=null,K=null,I=null;this._outputColorSpace=_r;let G=0,X=0,P=null,j=-1,z=null,q=new pt,Q=new pt,Me=null,ue=new ze(0),Ve=0,{width:we,height:Z}=t,re=1,se=null,ye=null,Ee=new pt(0,0,we,Z),Ae=new pt(0,0,we,Z),Et=!1,He=new Uo,Je=!1,dt=!1,nt=new We,Jt=new U,At=new pt,gn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},zt=!1;function Bt(){return P===null?re:1}let D=n;function _n(b,O){return t.getContext(b,O)}let ct,Pt,E,v,N,H,ie,ae,he,Y,te,xe,Ie,de,oe,Oe,ke,st,F,ce,ee,le,ve;try{let b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in t)t.setAttribute("data-engine",`three.js r${yp}`);if(t.addEventListener("webglcontextlost",$e,!1),t.addEventListener("webglcontextrestored",St,!1),t.addEventListener("webglcontextcreationerror",lt,!1),D===null){if(D=_n("webgl2",b),D===null)if(_n("webgl2"))throw Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.");else throw Error("THREE.WebGLRenderer: Error creating WebGL context.")}ne()}catch(b){throw t.removeEventListener("webglcontextlost",$e,!1),t.removeEventListener("webglcontextrestored",St,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),Be("WebGLRenderer: "+b.message),b}function ne(){if(ct=new $E(D),ct.init(),ee=new PT(D,ct),Pt=new DE(D,ct,e,ee),E=new RT(D,ct),Pt.reversedDepthBuffer&&d)E.buffers.depth.setReversed(!0);L=D.createFramebuffer(),K=D.createFramebuffer(),I=D.createFramebuffer(),v=new XE(D),N=new pT,H=new CT(D,ct,E,N,Pt,ee,v),ie=new HE(M),ae=new qS(D),le=new LE(D,ae),he=new WE(D,ae,v,le),Y=new qE(D,he,ae,le,v),st=new jE(D,Pt,H),oe=new OE(N),te=new fT(M,ie,ct,Pt,le,oe),xe=new DT(M,N),Ie=new gT,de=new ST(ct),ke=new IE(M,ie,E,Y,f,a),Oe=new TT(M,Y,Pt),ve=new OT(D,v,Pt,E),F=new NE(D,ct,v),ce=new ZE(D,ct,v),v.programs=te.programs,M.capabilities=Pt,M.extensions=ct,M.properties=N,M.renderLists=Ie,M.shadowMap=Oe,M.state=E,M.info=v}if(m!==ii)x=new JE(m,t.width,t.height,o,i,r);let pe=new sg(M,D);this.xr=pe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let b=ct.get("WEBGL_lose_context");if(b)b.loseContext()},this.forceContextRestore=function(){let b=ct.get("WEBGL_lose_context");if(b)b.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(b){if(b===void 0)return;re=b,this.setSize(we,Z,!1)},this.getSize=function(b){return b.set(we,Z)},this.setSize=function(b,O,W=!0){if(pe.isPresenting){Le("WebGLRenderer: Can't change size while VR device is presenting.");return}if(we=b,Z=O,t.width=Math.floor(b*re),t.height=Math.floor(O*re),W===!0)t.style.width=b+"px",t.style.height=O+"px";if(x!==null)x.setSize(t.width,t.height);this.setViewport(0,0,b,O)},this.getDrawingBufferSize=function(b){return b.set(we*re,Z*re).floor()},this.setDrawingBufferSize=function(b,O,W){we=b,Z=O,re=W,t.width=Math.floor(b*W),t.height=Math.floor(O*W),this.setViewport(0,0,b,O)},this.setEffects=function(b){if(m===ii){Be("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let O=0;O<b.length;O++)if(b[O].isOutputPass===!0){Le("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}x.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(q)},this.getViewport=function(b){return b.copy(Ee)},this.setViewport=function(b,O,W,B){if(b.isVector4)Ee.set(b.x,b.y,b.z,b.w);else Ee.set(b,O,W,B);E.viewport(q.copy(Ee).multiplyScalar(re).round())},this.getScissor=function(b){return b.copy(Ae)},this.setScissor=function(b,O,W,B){if(b.isVector4)Ae.set(b.x,b.y,b.z,b.w);else Ae.set(b,O,W,B);E.scissor(Q.copy(Ae).multiplyScalar(re).round())},this.getScissorTest=function(){return Et},this.setScissorTest=function(b){E.setScissorTest(Et=b)},this.setOpaqueSort=function(b){se=b},this.setTransparentSort=function(b){ye=b},this.getClearColor=function(b){return b.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor(...arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha(...arguments)},this.clear=function(b=!0,O=!0,W=!0){let B=0;if(b){let V=!1;if(P!==null){let ge=P.texture.format;V=_.has(ge)}if(V){let ge=P.texture.type,Se=p.has(ge),me=ke.getClearColor(),Te=ke.getClearAlpha(),{r:Pe,g:Ze,b:Qe}=me;if(Se)g[0]=Pe,g[1]=Ze,g[2]=Qe,g[3]=Te,D.clearBufferuiv(D.COLOR,0,g);else S[0]=Pe,S[1]=Ze,S[2]=Qe,S[3]=Te,D.clearBufferiv(D.COLOR,0,S)}else B|=D.COLOR_BUFFER_BIT}if(O)B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0);if(W)B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295);if(B!==0)D.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),C=b},this.dispose=function(){t.removeEventListener("webglcontextlost",$e,!1),t.removeEventListener("webglcontextrestored",St,!1),t.removeEventListener("webglcontextcreationerror",lt,!1),ke.dispose(),Ie.dispose(),de.dispose(),N.dispose(),ie.dispose(),Y.dispose(),le.dispose(),ve.dispose(),te.dispose(),pe.dispose(),pe.removeEventListener("sessionstart",Tf),pe.removeEventListener("sessionend",Rf),Nr.stop()};function $e(b){b.preventDefault(),So("WebGLRenderer: Context Lost."),k=!0}function St(){So("WebGLRenderer: Context Restored."),k=!1;let b=v.autoReset,O=Oe.enabled,W=Oe.autoUpdate,B=Oe.needsUpdate,V=Oe.type;ne(),v.autoReset=b,Oe.enabled=O,Oe.autoUpdate=W,Oe.needsUpdate=B,Oe.type=V}function lt(b){Be("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function ci(b){let O=b.target;O.removeEventListener("dispose",ci),Oi(O)}function Oi(b){zb(b),N.remove(b)}function zb(b){let O=N.get(b).programs;if(O!==void 0){if(O.forEach(function(W){te.releaseProgram(W)}),b.isShaderMaterial)te.releaseShaderCache(b)}}this.renderBufferDirect=function(b,O,W,B,V,ge){if(O===null)O=gn;let Se=V.isMesh&&V.matrixWorld.determinantAffine()<0,me=Gb(b,O,W,B,V);E.setMaterial(B,Se);let Te=W.index,Pe=1;if(B.wireframe===!0){if(Te=he.getWireframeAttribute(W),Te===void 0)return;Pe=2}let Ze=W.drawRange,Qe=W.attributes.position,Re=Ze.start*Pe,ut=(Ze.start+Ze.count)*Pe;if(ge!==null)Re=Math.max(Re,ge.start*Pe),ut=Math.min(ut,(ge.start+ge.count)*Pe);if(Te!==null)Re=Math.max(Re,0),ut=Math.min(ut,Te.count);else if(Qe!==void 0&&Qe!==null)Re=Math.max(Re,0),ut=Math.min(ut,Qe.count);let Ft=ut-Re;if(Ft<0||Ft===1/0)return;le.setup(V,B,me,W,Te);let Tt,yt=F;if(Te!==null)Tt=ae.get(Te),yt=ce,yt.setIndex(Tt);if(V.isMesh)if(B.wireframe===!0)E.setLineWidth(B.wireframeLinewidth*Bt()),yt.setMode(D.LINES);else yt.setMode(D.TRIANGLES);else if(V.isLine){let en=B.linewidth;if(en===void 0)en=1;if(E.setLineWidth(en*Bt()),V.isLineSegments)yt.setMode(D.LINES);else if(V.isLineLoop)yt.setMode(D.LINE_LOOP);else yt.setMode(D.LINE_STRIP)}else if(V.isPoints)yt.setMode(D.POINTS);else if(V.isSprite)yt.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(!ct.get("WEBGL_multi_draw")){let{_multiDrawStarts:en,_multiDrawCounts:be,_multiDrawCount:ln}=V,rt=Te?ae.get(Te).bytesPerElement:1,zn=N.get(B).currentProgram.getUniforms();for(let li=0;li<ln;li++)zn.setValue(D,"_gl_DrawID",li),yt.render(en[li]/rt,be[li])}else yt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)yt.renderInstances(Re,Ft,V.count);else if(W.isInstancedBufferGeometry){let en=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,be=Math.min(W.instanceCount,en);yt.renderInstances(Re,Ft,be)}else yt.render(Re,Ft)};function Af(b,O,W,B){if(C!==null&&b.isNodeMaterial)C.setObject(B,b);if(Je===!0)oe.setState(b,W,!1);if(b.transparent===!0&&b.side===Hn&&b.forceSinglePass===!1)b.side=rn,b.needsUpdate=!0,Pa(b,O,B),b.side=mr,b.needsUpdate=!0,Pa(b,O,B),b.side=Hn;else Pa(b,O,B)}this.compile=function(b,O,W=null){if(W===null)W=b;if(C!==null)C.renderStart(b,O,W);if(w=de.get(W),w.init(O),R.push(w),W.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}}),b!==W)b.traverseVisible(function(V){if(V.isLight&&V.layers.test(O.layers)){if(w.pushLight(V),V.castShadow)w.pushShadow(V)}});if(w.setupLights(),C!==null)C.updateLights(w.state.lightsArray);if(dt=this.localClippingEnabled,Je=oe.init(this.clippingPlanes,dt),Je===!0)oe.setGlobalState(this.clippingPlanes,O);if(C!==null)Oe.render(w.state.shadowsArray,W,O);let B=new Set;if(b.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let ge=V.material;if(ge)if(Array.isArray(ge))for(let Se=0;Se<ge.length;Se++){let me=ge[Se];Af(me,W,O,V),B.add(me)}else Af(ge,W,O,V),B.add(ge)}),w=R.pop(),C!==null)C.renderEnd();return B},this.compileAsync=function(b,O,W=null){let B=this.compile(b,O,W);return new Promise((V)=>{function ge(){if(B.forEach(function(Se){let Te=N.get(Se).currentProgram;if(Te===void 0||Te.isReady())B.delete(Se)}),B.size===0){V(b);return}setTimeout(ge,10)}if(ct.get("KHR_parallel_shader_compile")!==null)ge();else setTimeout(ge,10)})};let Nl=null;function Bb(b){if(Nl)Nl(b)}function Tf(){Nr.stop()}function Rf(){Nr.start()}let Nr=new Xm;if(Nr.setAnimationLoop(Bb),typeof self<"u")Nr.setContext(self);this.setAnimationLoop=function(b){Nl=b,pe.setAnimationLoop(b),b===null?Nr.stop():Nr.start()},pe.addEventListener("sessionstart",Tf),pe.addEventListener("sessionend",Rf),this.render=function(b,O){if(O!==void 0&&O.isCamera!==!0){Be("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(C!==null)C.renderStart(b,O);let W=pe.enabled===!0&&pe.isPresenting===!0,B=x!==null&&(P===null||W)&&x.begin(M,P);if(b.matrixWorldAutoUpdate===!0)b.updateMatrixWorld();if(O.parent===null&&O.matrixWorldAutoUpdate===!0)O.updateMatrixWorld();if(pe.enabled===!0&&pe.isPresenting===!0&&(x===null||x.isCompositing()===!1)){if(pe.cameraAutoUpdate===!0)pe.updateCamera(O);O=pe.getCamera()}if(b.isScene===!0)b.onBeforeRender(M,b,O,P);if(w=de.get(b,R.length),w.init(O),w.state.textureUnits=H.getTextureUnits(),R.push(w),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),He.setFromProjectionMatrix(nt,rh,O.reversedDepth),dt=this.localClippingEnabled,Je=oe.init(this.clippingPlanes,dt),y=Ie.get(b,A.length),y.init(),A.push(y),pe.enabled===!0&&pe.isPresenting===!0){let Se=M.xr.getDepthSensingMesh();if(Se!==null)Dl(Se,O,-1/0,M.sortObjects)}if(Dl(b,O,0,M.sortObjects),y.finish(),C!==null)C.updateLights(w.state.lightsArray);if(M.sortObjects===!0)y.sort(se,ye);if(zt=pe.enabled===!1||pe.isPresenting===!1||pe.hasDepthSensing()===!1,zt)ke.addToRenderList(y,b);if(this.info.render.frame++,this.info.autoReset===!0)this.info.reset();if(Je===!0)oe.beginShadows();let V=w.state.shadowsArray;if(Oe.render(V,b,O),Je===!0)oe.endShadows();if((B&&x.hasRenderPass())===!1){let Se=y.opaque,me=y.transmissive;if(w.setupLights(),O.isArrayCamera){let Te=O.cameras;if(me.length>0)for(let Pe=0,Ze=Te.length;Pe<Ze;Pe++){let Qe=Te[Pe];Pf(Se,me,b,Qe)}if(zt)ke.render(b);for(let Pe=0,Ze=Te.length;Pe<Ze;Pe++){let Qe=Te[Pe];Cf(y,b,Qe,Qe.viewport)}}else{if(me.length>0)Pf(Se,me,b,O);if(zt)ke.render(b);Cf(y,b,O)}}if(P!==null&&X===0)H.updateMultisampleRenderTarget(P),H.updateRenderTargetMipmap(P);if(B)x.end(M);if(b.isScene===!0)b.onAfterRender(M,b,O);if(le.resetDefaultState(),j=-1,z=null,R.pop(),R.length>0){if(w=R[R.length-1],H.setTextureUnits(w.state.textureUnits),Je===!0)oe.setGlobalState(M.clippingPlanes,w.state.camera)}else w=null;if(A.pop(),A.length>0)y=A[A.length-1];else y=null;if(C!==null)C.renderEnd()};function Dl(b,O,W,B){if(b.visible===!1)return;if(b.layers.test(O.layers)){if(b.isGroup)W=b.renderOrder;else if(b.isLOD){if(b.autoUpdate===!0)b.update(O)}else if(b.isLightProbeGrid)w.pushLightProbeGrid(b);else if(b.isLight){if(w.pushLight(b),b.castShadow)w.pushShadow(b)}else if(b.isSprite){if(!b.frustumCulled||b.intersectsFrustum(He)){if(B)At.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let Se=Y.update(b),me=b.material;if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}else if(b.isMesh||b.isLine||b.isPoints){if(!b.frustumCulled||b.intersectsFrustum(He)){let Se=Y.update(b),me=b.material;if(B){if(b.boundingSphere!==void 0){if(b.boundingSphere===null)b.computeBoundingSphere();At.copy(b.boundingSphere.center)}else{if(Se.boundingSphere===null)Se.computeBoundingSphere();At.copy(Se.boundingSphere.center)}At.applyMatrix4(b.matrixWorld).applyMatrix4(nt)}if(Array.isArray(me)){let Te=Se.groups;for(let Pe=0,Ze=Te.length;Pe<Ze;Pe++){let Qe=Te[Pe],Re=me[Qe.materialIndex];if(Re&&Re.visible)y.push(b,Se,Re,W,At.z,Qe,O)}}else if(me.visible)y.push(b,Se,me,W,At.z,null,O)}}}let ge=b.children;for(let Se=0,me=ge.length;Se<me;Se++)Dl(ge[Se],O,W,B)}function Cf(b,O,W,B){let{opaque:V,transmissive:ge,transparent:Se}=b;if(w.setupLightsView(W),Je===!0)oe.setGlobalState(M.clippingPlanes,W);if(B)E.viewport(q.copy(B));if(V.length>0)Ca(V,O,W);if(ge.length>0)Ca(ge,O,W);if(Se.length>0)Ca(Se,O,W);E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function Pf(b,O,W,B){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){let Re=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new En(1,1,{generateMipmaps:!0,type:Re?gi:ii,minFilter:mi,samples:Math.max(4,Pt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:qe.workingColorSpace})}let ge=w.state.transmissionRenderTarget[B.id],Se=B.viewport||q;ge.setSize(Se.z*M.transmissionResolutionScale,Se.w*M.transmissionResolutionScale);let me=M.getRenderTarget(),Te=M.getActiveCubeFace(),Pe=M.getActiveMipmapLevel();if(M.setRenderTarget(ge),M.getClearColor(ue),Ve=M.getClearAlpha(),Ve<1)M.setClearColor(16777215,0.5);if(M.clear(),zt)ke.render(W);let Ze=M.toneMapping;M.toneMapping=ti;let Qe=B.viewport;if(B.viewport!==void 0)B.viewport=void 0;if(w.setupLightsView(B),Je===!0)oe.setGlobalState(M.clippingPlanes,B);if(Ca(b,W,B),H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ut=0,Ft=O.length;ut<Ft;ut++){let Tt=O[ut],{object:yt,geometry:en,material:be,group:ln}=Tt;if(be.side===Hn&&yt.layers.test(B.layers)){let rt=be.side;be.side=rn,be.needsUpdate=!0,If(yt,W,B,en,be,ln),be.side=rt,be.needsUpdate=!0,Re=!0}}if(Re===!0)H.updateMultisampleRenderTarget(ge),H.updateRenderTargetMipmap(ge)}if(M.setRenderTarget(me,Te,Pe),M.setClearColor(ue,Ve),Qe!==void 0)B.viewport=Qe;M.toneMapping=Ze}function Ca(b,O,W){let B=O.isScene===!0?O.overrideMaterial:null;for(let V=0,ge=b.length;V<ge;V++){let Se=b[V],{object:me,geometry:Te,group:Pe}=Se,Ze=Se.material;if(Ze.allowOverride===!0&&B!==null)Ze=B;if(me.layers.test(W.layers))If(me,O,W,Te,Ze,Pe)}}function If(b,O,W,B,V,ge){if(C!==null&&V.isNodeMaterial)C.setObject(b,V);if(b.onBeforeRender(M,O,W,B,V,ge),b.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),V.onBeforeRender(M,O,W,B,b,ge),V.transparent===!0&&V.side===Hn&&V.forceSinglePass===!1)V.side=rn,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=mr,V.needsUpdate=!0,M.renderBufferDirect(W,O,B,V,b,ge),V.side=Hn;else M.renderBufferDirect(W,O,B,V,b,ge);b.onAfterRender(M,O,W,B,V,ge)}function Pa(b,O,W){if(O.isScene!==!0)O=gn;let B=N.get(b),V=w.state.lights,ge=w.state.shadowsArray,Se=V.state.version,me=te.getParameters(b,V.state,ge,O,W,w.state.lightProbeGridArray),Te=te.getProgramCacheKey(me),Pe=B.programs;B.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?O.environment:null,B.fog=O.fog;let Ze=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;if(B.envMap=ie.get(b.envMap||B.environment,Ze),B.envMapRotation=B.environment!==null&&b.envMap===null?O.environmentRotation:b.envMapRotation,Pe===void 0)b.addEventListener("dispose",ci),Pe=new Map,B.programs=Pe;let Qe=Pe.get(Te);if(Qe!==void 0){if(B.currentProgram===Qe&&B.lightsStateVersion===Se)return Nf(b,me),Qe}else{if(me.uniforms=te.getUniforms(b),C!==null&&b.isNodeMaterial)C.build(b,W,me);b.onBeforeCompile(me,M),Qe=te.acquireProgram(me,Te),Pe.set(Te,Qe),B.uniforms=me.uniforms}let Re=B.uniforms;if(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)Re.clippingPlanes=oe.uniform;if(Nf(b,me),B.needsLights=$b(b),B.lightsStateVersion=Se,B.needsLights)Re.ambientLightColor.value=V.state.ambient,Re.lightProbe.value=V.state.probe,Re.sunLights.value=V.state.sun,Re.sunLightShadows.value=V.state.sunShadow,Re.directionalLights.value=V.state.directional,Re.directionalLightShadows.value=V.state.directionalShadow,Re.spotLights.value=V.state.spot,Re.spotLightShadows.value=V.state.spotShadow,Re.rectAreaLights.value=V.state.rectArea,Re.ltc_1.value=V.state.rectAreaLTC1,Re.ltc_2.value=V.state.rectAreaLTC2,Re.pointLights.value=V.state.point,Re.pointLightShadows.value=V.state.pointShadow,Re.hemisphereLights.value=V.state.hemi,Re.sunShadowMatrix.value=V.state.sunShadowMatrix,Re.sunShadowCascade.value=V.state.sunShadowCascade,Re.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Re.spotLightMatrix.value=V.state.spotLightMatrix,Re.spotLightMap.value=V.state.spotLightMap,Re.pointShadowMatrix.value=V.state.pointShadowMatrix;return B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=Qe,B.uniformsList=null,Qe}function Lf(b){if(b.uniformsList===null){let O=b.currentProgram.getUniforms();b.uniformsList=Xo.seqWithValue(O.seq,b.uniforms)}return b.uniformsList}function Nf(b,O){let W=N.get(b);W.outputColorSpace=O.outputColorSpace,W.batching=O.batching,W.batchingColor=O.batchingColor,W.instancing=O.instancing,W.instancingColor=O.instancingColor,W.instancingMorph=O.instancingMorph,W.skinning=O.skinning,W.morphTargets=O.morphTargets,W.morphNormals=O.morphNormals,W.morphColors=O.morphColors,W.morphTargetsCount=O.morphTargetsCount,W.numClippingPlanes=O.numClippingPlanes,W.numIntersection=O.numClipIntersection,W.vertexAlphas=O.vertexAlphas,W.vertexTangents=O.vertexTangents,W.toneMapping=O.toneMapping}function Vb(b,O){if(b.length===0)return null;if(b.length===1)return b[0].texture!==null?b[0]:null;T.setFromMatrixPosition(O.matrixWorld);for(let W=0,B=b.length;W<B;W++){let V=b[W];if(V.texture!==null&&V.boundingBox.containsPoint(T))return V}return null}function Gb(b,O,W,B,V){if(O.isScene!==!0)O=gn;H.resetTextureUnits();let ge=O.fog,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?O.environment:null,me=P===null?M.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:qe.workingColorSpace,Te=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Pe=ie.get(B.envMap||Se,Te),Ze=B.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Qe=!!W.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Re=!!W.morphAttributes.position,ut=!!W.morphAttributes.normal,Ft=!!W.morphAttributes.color,Tt=ti;if(B.toneMapped){if(P===null||P.isXRRenderTarget===!0)Tt=M.toneMapping}let yt=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,en=yt!==void 0?yt.length:0,be=N.get(B),ln=w.state.lights;if(Je===!0){if(dt===!0||b!==z){let Mt=b===z&&B.id===j;oe.setState(B,b,Mt)}}let rt=!1;if(B.version===be.__version){if(be.needsLights&&be.lightsStateVersion!==ln.state.version)rt=!0;else if(be.outputColorSpace!==me)rt=!0;else if(V.isBatchedMesh&&be.batching===!1)rt=!0;else if(!V.isBatchedMesh&&be.batching===!0)rt=!0;else if(V.isBatchedMesh&&be.batchingColor===!0&&V._colorsTexture===null)rt=!0;else if(V.isBatchedMesh&&be.batchingColor===!1&&V._colorsTexture!==null)rt=!0;else if(V.isInstancedMesh&&be.instancing===!1)rt=!0;else if(!V.isInstancedMesh&&be.instancing===!0)rt=!0;else if(V.isSkinnedMesh&&be.skinning===!1)rt=!0;else if(!V.isSkinnedMesh&&be.skinning===!0)rt=!0;else if(V.isInstancedMesh&&be.instancingColor===!0&&V.instanceColor===null)rt=!0;else if(V.isInstancedMesh&&be.instancingColor===!1&&V.instanceColor!==null)rt=!0;else if(V.isInstancedMesh&&be.instancingMorph===!0&&V.morphTexture===null)rt=!0;else if(V.isInstancedMesh&&be.instancingMorph===!1&&V.morphTexture!==null)rt=!0;else if(be.envMap!==Pe)rt=!0;else if(B.fog===!0&&be.fog!==ge)rt=!0;else if(be.numClippingPlanes!==void 0&&(be.numClippingPlanes!==oe.numPlanes||be.numIntersection!==oe.numIntersection))rt=!0;else if(be.vertexAlphas!==Ze)rt=!0;else if(be.vertexTangents!==Qe)rt=!0;else if(be.morphTargets!==Re)rt=!0;else if(be.morphNormals!==ut)rt=!0;else if(be.morphColors!==Ft)rt=!0;else if(be.toneMapping!==Tt)rt=!0;else if(be.morphTargetsCount!==en)rt=!0;else if(!!be.lightProbeGrid!==w.state.lightProbeGridArray.length>0)rt=!0}else rt=!0,be.__version=B.version;let zn=be.currentProgram;if(rt===!0){if(zn=Pa(B,O,V),C&&B.isNodeMaterial)C.onUpdateProgram(B,zn,be)}let li=!1,ir=!1,cs=!1,gt=zn.getUniforms(),Ot=be.uniforms;if(E.useProgram(zn.program))li=!0,ir=!0,cs=!0;if(B.id!==j)j=B.id,ir=!0;if(be.needsLights){let Mt=Vb(w.state.lightProbeGridArray,V);if(be.lightProbeGrid!==Mt)be.lightProbeGrid=Mt,ir=!0}if(li||z!==b){if(E.buffers.depth.getReversed()&&b.reversedDepth!==!0)b._reversedDepth=!0,b.updateProjectionMatrix();gt.setValue(D,"projectionMatrix",b.projectionMatrix),gt.setValue(D,"viewMatrix",b.matrixWorldInverse);let sr=gt.map.cameraPosition;if(sr!==void 0)sr.setValue(D,Jt.setFromMatrixPosition(b.matrixWorld));if(Pt.logarithmicDepthBuffer)gt.setValue(D,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2));if(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)gt.setValue(D,"isOrthographic",b.isOrthographicCamera===!0);if(z!==b)z=b,ir=!0,cs=!0}if(be.needsLights){if(ln.state.sunShadowMap.length>0)gt.setValue(D,"sunShadowMap",ln.state.sunShadowMap,H);if(ln.state.directionalShadowMap.length>0)gt.setValue(D,"directionalShadowMap",ln.state.directionalShadowMap,H);if(ln.state.spotShadowMap.length>0)gt.setValue(D,"spotShadowMap",ln.state.spotShadowMap,H);if(ln.state.pointShadowMap.length>0)gt.setValue(D,"pointShadowMap",ln.state.pointShadowMap,H)}if(V.isSkinnedMesh){gt.setOptional(D,V,"bindMatrix"),gt.setOptional(D,V,"bindMatrixInverse");let Mt=V.skeleton;if(Mt){if(Mt.boneTexture===null)Mt.computeBoneTexture();gt.setValue(D,"boneTexture",Mt.boneTexture,H)}}if(V.isBatchedMesh){if(gt.setOptional(D,V,"batchingTexture"),gt.setValue(D,"batchingTexture",V._matricesTexture,H),gt.setOptional(D,V,"batchingIdTexture"),gt.setValue(D,"batchingIdTexture",V._indirectTexture,H),gt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null)gt.setValue(D,"batchingColorTexture",V._colorsTexture,H)}let rr=W.morphAttributes;if(rr.position!==void 0||rr.normal!==void 0||rr.color!==void 0)st.update(V,W,zn);if(ir||be.receiveShadow!==V.receiveShadow)be.receiveShadow=V.receiveShadow,gt.setValue(D,"receiveShadow",V.receiveShadow);if((B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&O.environment!==null)Ot.envMapIntensity.value=O.environmentIntensity;if(Ot.dfgLUT!==void 0)Ot.dfgLUT.value=FT();if(ir){if(gt.setValue(D,"toneMappingExposure",M.toneMappingExposure),be.needsLights)Hb(Ot,cs);if(ge&&B.fog===!0)xe.refreshFogUniforms(Ot,ge);if(xe.refreshMaterialUniforms(Ot,B,re,Z,w.state.transmissionRenderTarget[b.id]),be.needsLights&&be.lightProbeGrid){let Mt=be.lightProbeGrid;Ot.probesSH.value=Mt.texture,Ot.probesMin.value.copy(Mt.boundingBox.min),Ot.probesMax.value.copy(Mt.boundingBox.max),Ot.probesResolution.value.copy(Mt.resolution)}Xo.upload(D,Lf(be),Ot,H)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0)Xo.upload(D,Lf(be),Ot,H),B.uniformsNeedUpdate=!1;if(B.isSpriteMaterial)gt.setValue(D,"center",V.center);if(gt.setValue(D,"modelViewMatrix",V.modelViewMatrix),gt.setValue(D,"normalMatrix",V.normalMatrix),gt.setValue(D,"modelMatrix",V.matrixWorld),B.uniformsGroups!==void 0){let Mt=B.uniformsGroups;for(let sr=0,ls=Mt.length;sr<ls;sr++){let Of=Mt[sr];ve.update(Of,zn),ve.bind(Of,zn)}}return zn}function Hb(b,O){b.ambientLightColor.needsUpdate=O,b.lightProbe.needsUpdate=O,b.sunLights.needsUpdate=O,b.sunLightShadows.needsUpdate=O,b.directionalLights.needsUpdate=O,b.directionalLightShadows.needsUpdate=O,b.pointLights.needsUpdate=O,b.pointLightShadows.needsUpdate=O,b.spotLights.needsUpdate=O,b.spotLightShadows.needsUpdate=O,b.rectAreaLights.needsUpdate=O,b.hemisphereLights.needsUpdate=O}function $b(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(b,O,W){let B=N.get(b);if(B.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1)B.__useRenderToTexture=!1;N.get(b.texture).__webglTexture=O,N.get(b.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:W,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,O){let W=N.get(b);W.__webglFramebuffer=O,W.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(b,O=0,W=0){P=b,G=O,X=W;let B=null,V=!1,ge=!1;if(b){let me=N.get(b);if(me.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(D.FRAMEBUFFER,me.__webglFramebuffer),q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest,E.viewport(q),E.scissor(Q),E.setScissorTest(Me),j=-1;return}else if(me.__webglFramebuffer===void 0)H.setupRenderTarget(b);else if(me.__hasExternalTextures)H.rebindTextures(b,N.get(b.texture).__webglTexture,N.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let Ze=b.depthTexture;if(me.__boundDepthTexture!==Ze){if(Ze!==null&&N.has(Ze)&&(b.width!==Ze.image.width||b.height!==Ze.image.height))throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");H.setupDepthRenderbuffer(b)}}let Te=b.texture;if(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)ge=!0;let Pe=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget){if(Array.isArray(Pe[O]))B=Pe[O][W];else B=Pe[O];V=!0}else if(b.samples>0&&H.useMultisampledRTT(b)===!1)B=N.get(b).__webglMultisampledFramebuffer;else if(Array.isArray(Pe))B=Pe[W];else B=Pe;q.copy(b.viewport),Q.copy(b.scissor),Me=b.scissorTest}else q.copy(Ee).multiplyScalar(re).floor(),Q.copy(Ae).multiplyScalar(re).floor(),Me=Et;if(W!==0)B=L;if(E.bindFramebuffer(D.FRAMEBUFFER,B))E.drawBuffers(b,B);if(E.viewport(q),E.scissor(Q),E.setScissorTest(Me),V){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+O,me.__webglTexture,W)}else if(ge){let me=O;for(let Te=0;Te<b.textures.length;Te++){let Pe=N.get(b.textures[Te]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Te,Pe.__webglTexture,W,me)}}else if(b!==null&&W!==0){let me=N.get(b.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,me.__webglTexture,W)}j=-1};function Df(b){let O=N.get(b);if(O.__readFormat!==b.format||O.__readType!==b.type)O.__readFormat=b.format,O.__readType=b.type,O.__formatReadable=Pt.textureFormatReadable(b.format),O.__typeReadable=Pt.textureTypeReadable(b.type);return O}if(this.readRenderTargetPixels=function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te){E.bindFramebuffer(D.FRAMEBUFFER,Te);try{let Pe=b.textures[me],{format:Ze,type:Qe}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Df(Pe);if(Re.__formatReadable===!1){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V))D.readPixels(O,W,B,V,ee.convert(Ze),ee.convert(Qe),ge)}finally{let Pe=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,O,W,B,V,ge,Se,me=0){if(!(b&&b.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Te=N.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Se!==void 0)Te=Te[Se];if(Te)if(O>=0&&O<=b.width-B&&(W>=0&&W<=b.height-V)){E.bindFramebuffer(D.FRAMEBUFFER,Te);let Pe=b.textures[me],{format:Ze,type:Qe}=Pe;if(b.textures.length>1)D.readBuffer(D.COLOR_ATTACHMENT0+me);let Re=Df(Pe);if(Re.__formatReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ut=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.bufferData(D.PIXEL_PACK_BUFFER,ge.byteLength,D.STREAM_READ),D.readPixels(O,W,B,V,ee.convert(Ze),ee.convert(Qe),0),D.bindBuffer(D.PIXEL_PACK_BUFFER,null);let Ft=P!==null?N.get(P).__webglFramebuffer:null;E.bindFramebuffer(D.FRAMEBUFFER,Ft);let Tt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await mm(D,Tt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,ut),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ge),D.bindBuffer(D.PIXEL_PACK_BUFFER,null),D.deleteBuffer(ut),D.deleteSync(Tt),ge}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,O=null,W=0){let B=Math.pow(2,-W),V=Math.floor(b.image.width*B),ge=Math.floor(b.image.height*B),Se=O!==null?O.x:0,me=O!==null?O.y:0;H.setTexture2D(b,0),D.copyTexSubImage2D(D.TEXTURE_2D,W,0,0,Se,me,V,ge),E.unbindTexture()},this.copyTextureToTexture=function(b,O,W=null,B=null,V=0,ge=0){let Se,me,Te,Pe,Ze,Qe,Re,ut,Ft,Tt=b.isCompressedTexture?b.mipmaps[ge]:b.image;if(W!==null)Se=W.max.x-W.min.x,me=W.max.y-W.min.y,Te=W.isBox3?W.max.z-W.min.z:1,Pe=W.min.x,Ze=W.min.y,Qe=W.isBox3?W.min.z:0;else{let Ot=Math.pow(2,-V);if(Se=Math.floor(Tt.width*Ot),me=Math.floor(Tt.height*Ot),b.isDataArrayTexture)Te=Tt.depth;else if(b.isData3DTexture)Te=Math.floor(Tt.depth*Ot);else Te=1;Pe=0,Ze=0,Qe=0}if(B!==null)Re=B.x,ut=B.y,Ft=B.z;else Re=0,ut=0,Ft=0;let yt=ee.convert(O.format),en=ee.convert(O.type),be;if(O.isData3DTexture)H.setTexture3D(O,0),be=D.TEXTURE_3D;else if(O.isDataArrayTexture||O.isCompressedArrayTexture)H.setTexture2DArray(O,0),be=D.TEXTURE_2D_ARRAY;else H.setTexture2D(O,0),be=D.TEXTURE_2D;E.activeTexture(D.TEXTURE0),E.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,O.flipY),E.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),E.pixelStorei(D.UNPACK_ALIGNMENT,O.unpackAlignment);let ln=E.getParameter(D.UNPACK_ROW_LENGTH),rt=E.getParameter(D.UNPACK_IMAGE_HEIGHT),zn=E.getParameter(D.UNPACK_SKIP_PIXELS),li=E.getParameter(D.UNPACK_SKIP_ROWS),ir=E.getParameter(D.UNPACK_SKIP_IMAGES);E.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),E.pixelStorei(D.UNPACK_SKIP_PIXELS,Pe),E.pixelStorei(D.UNPACK_SKIP_ROWS,Ze),E.pixelStorei(D.UNPACK_SKIP_IMAGES,Qe);let cs=b.isDataArrayTexture||b.isData3DTexture,gt=O.isDataArrayTexture||O.isData3DTexture;if(b.isDepthTexture){let Ot=N.get(b),rr=N.get(O),Mt=N.get(Ot.__renderTarget),sr=N.get(rr.__renderTarget);E.bindFramebuffer(D.READ_FRAMEBUFFER,Mt.__webglFramebuffer),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,sr.__webglFramebuffer);for(let ls=0;ls<Te;ls++){if(cs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(b).__webglTexture,V,Qe+ls),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,N.get(O).__webglTexture,ge,Ft+ls);D.blitFramebuffer(Pe,Ze,Se,me,Re,ut,Se,me,D.DEPTH_BUFFER_BIT,D.NEAREST)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||b.isRenderTargetTexture||N.has(b)){let Ot=N.get(b),rr=N.get(O);E.bindFramebuffer(D.READ_FRAMEBUFFER,K),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,I);for(let Mt=0;Mt<Te;Mt++){if(cs)D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ot.__webglTexture,V,Qe+Mt);else D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ot.__webglTexture,V);if(gt)D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,rr.__webglTexture,ge,Ft+Mt);else D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,rr.__webglTexture,ge);if(V!==0)D.blitFramebuffer(Pe,Ze,Se,me,Re,ut,Se,me,D.COLOR_BUFFER_BIT,D.NEAREST);else if(gt)D.copyTexSubImage3D(be,ge,Re,ut,Ft+Mt,Pe,Ze,Se,me);else D.copyTexSubImage2D(be,ge,Re,ut,Pe,Ze,Se,me)}E.bindFramebuffer(D.READ_FRAMEBUFFER,null),E.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(gt)if(b.isDataTexture||b.isData3DTexture)D.texSubImage3D(be,ge,Re,ut,Ft,Se,me,Te,yt,en,Tt.data);else if(O.isCompressedArrayTexture)D.compressedTexSubImage3D(be,ge,Re,ut,Ft,Se,me,Te,yt,Tt.data);else D.texSubImage3D(be,ge,Re,ut,Ft,Se,me,Te,yt,en,Tt);else if(b.isDataTexture)D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,yt,en,Tt.data);else if(b.isCompressedTexture)D.compressedTexSubImage2D(D.TEXTURE_2D,ge,Re,ut,Tt.width,Tt.height,yt,Tt.data);else D.texSubImage2D(D.TEXTURE_2D,ge,Re,ut,Se,me,yt,en,Tt);if(E.pixelStorei(D.UNPACK_ROW_LENGTH,ln),E.pixelStorei(D.UNPACK_IMAGE_HEIGHT,rt),E.pixelStorei(D.UNPACK_SKIP_PIXELS,zn),E.pixelStorei(D.UNPACK_SKIP_ROWS,li),E.pixelStorei(D.UNPACK_SKIP_IMAGES,ir),ge===0&&O.generateMipmaps)D.generateMipmap(be);E.unbindTexture()},this.initRenderTarget=function(b){if(N.get(b).__webglFramebuffer===void 0)H.setupRenderTarget(b)},this.initTexture=function(b){if(b.isCubeTexture)H.setTextureCube(b,0);else if(b.isData3DTexture)H.setTexture3D(b,0);else if(b.isDataArrayTexture||b.isCompressedArrayTexture)H.setTexture2DArray(b,0);else H.setTexture2D(b,0);E.unbindTexture()},this.resetState=function(){G=0,X=0,P=null,E.reset(),le.reset()},typeof __THREE_DEVTOOLS__<"u")__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rh}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=qe._getUnpackColorSpace()}}var cg={type:"change"},kh={type:"start"},ug={type:"end"},Bc=new xr,lg=new Vn,kT=Math.cos(70*Co.DEG2RAD),Wt=new U,vn=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Fh=0.000001;class zh extends Oc{constructor(e,t=null){super(e,t);if(this.state=mt.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:fr.ROTATE,MIDDLE:fr.DOLLY,RIGHT:fr.PAN},this.touches={ONE:pr.ROTATE,TWO:pr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new U,this._lastQuaternion=new Xt,this._lastTargetPosition=new U,this._quat=new Xt().setFromUnitVectors(e.up,new U(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ho,this._sphericalDelta=new Ho,this._scale=1,this._panOffset=new U,this._rotateStart=new Fe,this._rotateEnd=new Fe,this._rotateDelta=new Fe,this._panStart=new Fe,this._panEnd=new Fe,this._panDelta=new Fe,this._dollyStart=new Fe,this._dollyEnd=new Fe,this._dollyDelta=new Fe,this._dollyDirection=new U,this._mouse=new Fe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=BT.bind(this),this._onPointerDown=zT.bind(this),this._onPointerUp=VT.bind(this),this._onContextMenu=jT.bind(this),this._onMouseWheel=$T.bind(this),this._onKeyDown=WT.bind(this),this._onTouchStart=ZT.bind(this),this._onTouchMove=XT.bind(this),this._onMouseDown=GT.bind(this),this._onMouseMove=HT.bind(this),this._interceptControlDown=qT.bind(this),this._interceptControlUp=YT.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(e){if(this._cursorStyle=e,e==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=mt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();let e=this.domElement.getRootNode();e.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),e.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(cg),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;if(Wt.copy(t).sub(this.target),Wt.applyQuaternion(this._quat),this._spherical.setFromVector3(Wt),this.autoRotate&&this.state===mt.NONE)this._rotateLeft(this._getAutoRotationAngle(e));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;if(isFinite(n)&&isFinite(i)){if(n<-Math.PI)n+=vn;else if(n>Math.PI)n-=vn;if(i<-Math.PI)i+=vn;else if(i>Math.PI)i-=vn;if(n<=i)this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=s!=this._spherical.radius}if(Wt.setFromSpherical(this._spherical),Wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Wt),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){let o=Wt.length();s=this._clampDistance(o*this._scale);let a=o-s;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),r=!!a}else if(this.object.isOrthographicCamera){let o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=a!==this.object.zoom;let c=new U(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(s!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position);else if(Bc.origin.copy(this.object.position),Bc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Bc.direction))<kT)this.object.lookAt(this.target);else lg.setFromNormalAndCoplanarPoint(this.object.up,this.target),Bc.intersectPlane(lg,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)>Fh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Fh||this._lastTargetPosition.distanceToSquared(this.target)>Fh)return this.dispatchEvent(cg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(e){if(e!==null)return vn/60*this.autoRotateSpeed*e;else return vn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*0.01);return Math.pow(0.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Wt.setFromMatrixColumn(t,0),Wt.multiplyScalar(-e),this._panOffset.add(Wt)}_panUp(e,t){if(this.screenSpacePanning===!0)Wt.setFromMatrixColumn(t,1);else Wt.setFromMatrixColumn(t,0),Wt.crossVectors(this.object.up,Wt);Wt.multiplyScalar(e),this._panOffset.add(Wt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let i=this.object.position;Wt.copy(i).sub(this.target);let r=Wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(e){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=e;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,{width:s,height:o}=n;this._mouse.x=i/s*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){if(this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){if(this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0)this._dollyIn(this._getZoomScale(e.deltaY));else if(e.deltaY>0)this._dollyOut(this._getZoomScale(e.deltaY));this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);t=!0;break;case this.keys.BOTTOM:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateUp(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);t=!0;break;case this.keys.LEFT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);t=!0;break;case this.keys.RIGHT:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate)this._rotateLeft(-vn*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);t=!0;break}if(t)e.preventDefault(),this.update()}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enablePan)this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){if(this.enableZoom)this._handleTouchStartDolly(e);if(this.enableRotate)this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),i=0.5*(e.pageX+n.x),r=0.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/t.clientHeight),this._rotateUp(vn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=0.5*(e.pageX+t.x),i=0.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let s=(e.pageX+t.x)*0.5,o=(e.pageY+t.y)*0.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enablePan)this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){if(this.enableZoom)this._handleTouchMoveDolly(e);if(this.enableRotate)this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];if(t===void 0)t=new Fe,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 zT(e){if(this.enabled===!1)return;if(this._pointers.length===0)this.domElement.setPointerCapture(e.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp);if(this._isTrackingPointer(e))return;if(this._addPointer(e),e.pointerType==="touch")this._onTouchStart(e);else this._onMouseDown(e);if(this._cursorStyle==="grab")this.domElement.style.cursor="grabbing"}function BT(e){if(this.enabled===!1)return;if(e.pointerType==="touch")this._onTouchMove(e);else this._onMouseMove(e)}function VT(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(ug),this.state=mt.NONE,this._cursorStyle==="grab")this.domElement.style.cursor="grab";break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function GT(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 fr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=mt.DOLLY;break;case fr.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}break;case fr.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=mt.PAN}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(kh)}function HT(e){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function $T(e){if(this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE)return;e.preventDefault(),this.dispatchEvent(kh),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ug)}function WT(e){if(this.enabled===!1)return;this._handleKeyDown(e)}function ZT(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case pr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=mt.TOUCH_ROTATE;break;case pr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case pr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=mt.TOUCH_DOLLY_PAN;break;case pr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}if(this.state!==mt.NONE)this.dispatchEvent(kh)}function XT(e){switch(this._trackPointer(e),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=mt.NONE}}function jT(e){if(this.enabled===!1)return;e.preventDefault()}function qT(e){if(e.key==="Control")this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}function YT(e){if(e.key==="Control")this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}class Bh extends Us{constructor(){super();this.name="RoomEnvironment",this.position.y=-3.5;let e=new vr;e.deleteAttribute("uv");let t=new $i({side:rn}),n=new $i,i=new Gs(16777215,900,28,2);i.position.set(0.418,16.199,0.3),this.add(i);let r=new wt(e,t);r.position.set(-0.757,13.219,0.717),r.scale.set(31.713,28.305,28.591),this.add(r);let s=new ks(e,n,6),o=new _t;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-0.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),s.setMatrixAt(0,o.matrix),o.position.set(-5.607,-0.754,-0.758),o.rotation.set(0,0.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),s.setMatrixAt(1,o.matrix),o.position.set(6.167,0.857,7.803),o.rotation.set(0,0.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),s.setMatrixAt(2,o.matrix),o.position.set(-2.017,0.018,6.124),o.rotation.set(0,0.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),s.setMatrixAt(3,o.matrix),o.position.set(2.291,-0.756,-2.621),o.rotation.set(0,-0.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),s.setMatrixAt(4,o.matrix),o.position.set(-2.193,-0.369,-5.547),o.rotation.set(0,0.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),s.setMatrixAt(5,o.matrix),this.add(s);let a=new wt(e,Xs(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 wt(e,Xs(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 wt(e,Xs(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 wt(e,Xs(43));u.position.set(-0.462,8.89,14.52),u.scale.set(4.38,5.441,0.088),this.add(u);let d=new wt(e,Xs(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,0.1),this.add(d);let h=new wt(e,Xs(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 Xs(e){return new Tc({color:0,emissive:16777215,emissiveIntensity:e})}function Vh(e,t){if(t===eh)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Os||t===Ro){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===Os)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 hg(e){let t=new Map,n=new Map,i=e.clone();return dg(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 dg(e,t,n){n(e,t);for(let i=0;i<e.children.length;i++)dg(e.children[i],t.children[i],n)}class jh extends Zi{constructor(e){super(e);this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new vg(t)}),this.register(function(t){return new bg(t)}),this.register(function(t){return new Pg(t)}),this.register(function(t){return new Ig(t)}),this.register(function(t){return new Lg(t)}),this.register(function(t){return new Mg(t)}),this.register(function(t){return new wg(t)}),this.register(function(t){return new Eg(t)}),this.register(function(t){return new Ag(t)}),this.register(function(t){return new yg(t)}),this.register(function(t){return new Tg(t)}),this.register(function(t){return new Sg(t)}),this.register(function(t){return new Cg(t)}),this.register(function(t){return new Rg(t)}),this.register(function(t){return new _g(t)}),this.register(function(t){return new Wh(t,Ke.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Wh(t,Ke.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Ng(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 Vo(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))===Dg){try{s[Ke.KHR_BINARY_GLTF]=new Og(e)}catch(u){if(i)i(u);return}r=JSON.parse(s[Ke.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 Bg(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);if(!u.name)console.error("THREE.GLTFLoader: Invalid plugin found: missing name");o[u.name]=u,s[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){let u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case Ke.KHR_MATERIALS_UNLIT:s[u]=new xg;break;case Ke.KHR_DRACO_MESH_COMPRESSION:s[u]=new Ug(r,this.dracoLoader);break;case Ke.KHR_TEXTURE_TRANSFORM:s[u]=new Fg;break;case Ke.KHR_MESH_QUANTIZATION:s[u]=new kg;break;default:if(d.indexOf(u)>=0&&o[u]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function JT(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ut(e,t,n){let i=e.json.materials[t];if(i.extensions&&i.extensions[n])return i.extensions[n];return null}var Ke={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 _g{constructor(e){this.parser=e,this.name=Ke.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];if(r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0)e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],c,l=new ze(16777215);if(a.color!==void 0)l.setRGB(a.color[0],a.color[1],a.color[2],wn);let u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Hs(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Gs(l),c.distance=u;break;case"spot":c=new Lc(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),bi(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 xg{constructor(){this.name=Ke.KHR_MATERIALS_UNLIT}getMaterialType(){return xi}extendParams(e,t,n){let i=[];e.color=new ze(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],wn),e.opacity=s[3]}if(r.baseColorTexture!==void 0)i.push(n.assignTexture(e,"map",r.baseColorTexture,_r))}return Promise.all(i)}}class yg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(n.emissiveStrength!==void 0)t.emissiveIntensity=n.emissiveStrength;return Promise.resolve()}}class vg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.clearcoatFactor!==void 0)t.clearcoat=n.clearcoatFactor;if(n.clearcoatTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture));if(n.clearcoatRoughnessFactor!==void 0)t.clearcoatRoughness=n.clearcoatRoughnessFactor;if(n.clearcoatRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture));if(n.clearcoatNormalTexture!==void 0){if(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0){let r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Fe(r,r)}}return Promise.all(i)}}class bg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();return t.dispersion=n.dispersion!==void 0?n.dispersion:0,Promise.resolve()}}class Sg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.iridescenceFactor!==void 0)t.iridescence=n.iridescenceFactor;if(n.iridescenceTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture));if(n.iridescenceIor!==void 0)t.iridescenceIOR=n.iridescenceIor;if(t.iridescenceThicknessRange===void 0)t.iridescenceThicknessRange=[100,400];if(n.iridescenceThicknessMinimum!==void 0)t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum;if(n.iridescenceThicknessMaximum!==void 0)t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum;if(n.iridescenceThicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture));return Promise.all(i)}}class Mg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.sheenColor=new ze(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],wn)}if(n.sheenRoughnessFactor!==void 0)t.sheenRoughness=n.sheenRoughnessFactor;if(n.sheenColorTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,_r));if(n.sheenRoughnessTexture!==void 0)i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture));return Promise.all(i)}}class wg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.transmissionFactor!==void 0)t.transmission=n.transmissionFactor;if(n.transmissionTexture!==void 0)i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture));return Promise.all(i)}}class Eg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0)i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture));t.attenuationDistance=n.attenuationDistance||1/0;let r=n.attenuationColor||[1,1,1];return t.attenuationColor=new ze().setRGB(r[0],r[1],r[2],wn),Promise.all(i)}}class Ag{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_IOR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();if(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0)t.ior=1000;return Promise.resolve()}}class Tg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0)i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));let r=n.specularColorFactor||[1,1,1];if(t.specularColor=new ze().setRGB(r[0],r[1],r[2],wn),n.specularColorTexture!==void 0)i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,_r));return Promise.all(i)}}class Rg{constructor(e){this.parser=e,this.name=Ke.EXT_MATERIALS_BUMP}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0)i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture));return Promise.all(i)}}class Cg{constructor(e){this.parser=e,this.name=Ke.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ut(this.parser,e,this.name)!==null?Tn:null}extendMaterialParams(e,t){let n=Ut(this.parser,e,this.name);if(n===null)return Promise.resolve();let i=[];if(n.anisotropyStrength!==void 0)t.anisotropy=n.anisotropyStrength;if(n.anisotropyRotation!==void 0)t.anisotropyRotation=n.anisotropyRotation;if(n.anisotropyTexture!==void 0)i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture));return Promise.all(i)}}class Pg{constructor(e){this.parser=e,this.name=Ke.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 Ig{constructor(e){this.parser=e,this.name=Ke.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 Lg{constructor(e){this.parser=e,this.name=Ke.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,d=new Uint8Array(o,a,c);if(s.decodeGltfBufferAsync)return s.decodeGltfBufferAsync(l,u,d,i.mode,i.filter).then(function(h){return h.buffer});else return s.ready.then(function(){let h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,i.mode,i.filter),h})})}else return null}}class Ng{constructor(e){this.name=Ke.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!==Wn.TRIANGLES&&c.mode!==Wn.TRIANGLE_STRIP&&c.mode!==Wn.TRIANGLE_FAN&&c.mode!==void 0)return null;let s=n.extensions[this.name].attributes,o=[],a={};for(let c in s)o.push(this.parser.getDependency("accessor",s[c]).then((l)=>(a[c]=l,a[c])));if(o.length<1)return null;return o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((c)=>{let l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(let f of u){let m=new We,_=new U,p=new Xt,g=new U(1,1,1),S=new ks(f.geometry,f.material,d);for(let y=0;y<d;y++){if(a.TRANSLATION)_.fromBufferAttribute(a.TRANSLATION,y);if(a.ROTATION)p.fromBufferAttribute(a.ROTATION,y);if(a.SCALE)g.fromBufferAttribute(a.SCALE,y);S.setMatrixAt(y,m.compose(_,p,g))}let T=null;for(let y in a)if(y==="_COLOR_0"){let w=a[y];S.instanceColor=new dr(w.array,w.itemSize,w.normalized)}else if(y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"){if(T===null){let A=S.geometry;T=new sn,T.name=A.name;for(let R in A.attributes)T.setAttribute(R,A.attributes[R]);for(let R in A.morphAttributes)T.morphAttributes[R]=A.morphAttributes[R];if(A.index!==null)T.setIndex(A.index);T.morphTargetsRelative=A.morphTargetsRelative;for(let R of A.groups)T.addGroup(R.start,R.count,R.materialIndex);if(A.boundingBox!==null)T.boundingBox=A.boundingBox.clone();if(A.boundingSphere!==null)T.boundingSphere=A.boundingSphere.clone();T.drawRange.start=A.drawRange.start,T.drawRange.count=A.drawRange.count,T.userData=Object.assign({},A.userData),S.geometry=T}let w=a[y];T.setAttribute(y,new dr(w.array,w.itemSize,w.normalized))}_t.prototype.copy.call(S,f),this.parser.assignFinalMaterial(S),h.push(S)}if(l.isGroup)return l.clear(),l.add(...h),l;return h[0]})}}var Dg="glTF",qo=12,fg={JSON:1313821514,BIN:5130562};class Og{constructor(e){this.name=Ke.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,qo),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!==Dg)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-qo,r=new DataView(e,qo),s=0;while(s<i){let o=r.getUint32(s,!0);s+=4;let a=r.getUint32(s,!0);if(s+=4,a===fg.JSON){let c=new Uint8Array(e,qo+s,o);this.content=n.decode(c)}else if(a===fg.BIN){let c=qo+s;this.body=e.slice(c,c+o)}s+=o}if(this.content===null)throw Error("THREE.GLTFLoader: JSON content not found.")}}class Ug{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ke.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=Zh[l]||l.toLowerCase();o[u]=s[l]}for(let l in e.attributes){let u=Zh[l]||l.toLowerCase();if(s[l]!==void 0){let d=n.accessors[e.attributes[l]],h=js[d.componentType];c[u]=h.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){i.decodeDracoFile(l,function(h){for(let f in h.attributes){let m=h.attributes[f],_=a[f];if(_!==void 0)m.normalized=_}u(h)},o,c,wn,d)})})}}class Fg{constructor(){this.name=Ke.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 kg{constructor(){this.name=Ke.KHR_MESH_QUANTIZATION}}class qh extends Wi{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,l=i-t,u=(n-t)/l,d=u*u,h=d*u,f=e*c,m=f-c,_=-2*h+3*d,p=h-d,g=1-_,S=p-d+u;for(let T=0;T!==o;T++){let y=s[m+T+o],w=s[m+T+a]*l,A=s[f+T+o],R=s[f+T]*l;r[T]=g*y+S*w+_*A+p*R}return r}}var KT=new Xt;class zg extends qh{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return KT.fromArray(r).normalize().toArray(r),r}}var Wn={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},js={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},pg={9728:ni,9729:qt,9984:cc,9985:Ns,9986:Vr,9987:mi},mg={33071:Ls,33648:ac,10497:Is},Gh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Zh={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"},Ar={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},QT={CUBICSPLINE:void 0,LINEAR:mc,STEP:Qu},Hh={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function e1(e){if(e.DefaultMaterial===void 0)e.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:mr});return e.DefaultMaterial}function Jr(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 bi(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 t1(e,t,n){let i=!1,r=!1,s=!1;for(let l=0,u=t.length;l<u;l++){let d=t[l];if(d.POSITION!==void 0)i=!0;if(d.NORMAL!==void 0)r=!0;if(d.COLOR_0!==void 0)s=!0;if(i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(e);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let d=t[l];if(i){let h=d.POSITION!==void 0?n.getDependency("accessor",d.POSITION):e.attributes.position;o.push(h)}if(r){let h=d.NORMAL!==void 0?n.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(h)}if(s){let h=d.COLOR_0!==void 0?n.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],d=l[1],h=l[2];if(i)e.morphAttributes.position=u;if(r)e.morphAttributes.normal=d;if(s)e.morphAttributes.color=h;return e.morphTargetsRelative=!0,e})}function n1(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 i1(e){let t,n=e.extensions&&e.extensions[Ke.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 Xh(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 r1(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 s1=new We;class Bg{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new JT,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 Bs(this.options.manager);else this.textureLoader=new Nc(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Vo(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 Jr(r,o,i),bi(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[Ke.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=js[i.componentType],a=i.normalized===!0,c=new o(i.count*s);return Promise.resolve(new jt(c,s,a))}let r=[];if(i.bufferView!==void 0)r.push(this.getDependency("bufferView",i.bufferView));else r.push(null);if(i.sparse!==void 0)r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView));return Promise.all(r).then(function(s){let o=s[0],a=Gh[i.type],c=js[i.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=i.byteOffset||0,h=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0,m,_;if(h&&h!==u){let p=Math.floor(d/h),g="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count,S=t.cache.get(g);if(!S)m=new c(o,p*h,i.count*h/l),S=new Lo(m,h/l),t.cache.add(g,S);_=new Fs(S,a,d%h/l,f)}else{if(o===null)m=new c(i.count*a);else m=new c(o,d,i.count*a);_=new jt(m,a,f)}if(i.sparse!==void 0){let p=Gh.SCALAR,g=js[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,T=i.sparse.values.byteOffset||0,y=new g(s[1],S,i.sparse.count*p),w=new c(s[2],T,i.sparse.count*a);if(o!==null)_=new jt(_.array.slice(),_.itemSize,_.normalized);_.normalized=!1;for(let A=0,R=y.length;A<R;A++){let x=y[A];if(_.setX(x,w[A*a]),a>=2)_.setY(x,w[A*a+1]);if(a>=3)_.setZ(x,w[A*a+2]);if(a>=4)_.setW(x,w[A*a+3]);if(a>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=f}return _})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r],o=this.textureLoader;if(s.uri){let a=n.manager.getHandler(s.uri);if(a!==null)o=a}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){let i=this,r=this.json,s=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];let c=this.loadImageSource(t,n).then(function(l){if(l.flipY=!1,l.name=s.name||o.name||"",l.name===""&&typeof o.uri==="string"&&o.uri.startsWith("data:image/")===!1)l.name=o.uri;let d=(r.samplers||{})[s.sampler]||{};return l.magFilter=pg[d.magFilter]||qt,l.minFilter=pg[d.minFilter]||mi,l.wrapS=mg[d.wrapS]||Is,l.wrapT=mg[d.wrapT]||Is,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==ni&&l.minFilter!==qt,i.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((u)=>u.clone());let s=i.images[e],o=self.URL||self.webkitURL,a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=n.getDependency("bufferView",s.bufferView).then(function(u){c=!0;let d=new Blob([u],{type:s.mimeType});return a=o.createObjectURL(d),a});else if(s.uri===void 0)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(u){return new Promise(function(d,h){let f=d;if(t.isImageBitmapLoader===!0)f=function(m){let _=new Nt(m);_.needsUpdate=!0,d(_)};t.load(Er.resolveURL(u,r.path),f,void 0,h)})}).then(function(u){if(c===!0)o.revokeObjectURL(a);return bi(u,s),u.userData.mimeType=s.mimeType||r1(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[Ke.KHR_TEXTURE_TRANSFORM]){let o=n.extensions!==void 0?n.extensions[Ke.KHR_TEXTURE_TRANSFORM]:void 0;if(o){let a=r.associations.get(s);s=r.extensions[Ke.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 ko,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a);n=a}else if(e.isLine){let o="LineBasicMaterial:"+n.uuid,a=this.cache.get(o);if(!a)a=new Fo,yn.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a);n=a}if(i||r||s){let o="ClonedMaterial:"+n.uuid+":";if(i)o+="derivative-tangents:";if(r)o+="vertex-colors:";if(s)o+="flat-shading:";let a=this.cache.get(o);if(!a){if(a=n.clone(),r)a.vertexColors=!0;if(s)a.flatShading=!0;if(i){if(a.normalScale)a.normalScale.y*=-1;if(a.clearcoatNormalScale)a.clearcoatNormalScale.y*=-1}this.cache.add(o,a),this.associations.set(a,this.associations.get(n))}n=a}e.material=n}getMaterialType(){return $i}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],s,o={},a=r.extensions||{},c=[];if(a[Ke.KHR_MATERIALS_UNLIT]){let u=i[Ke.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{let u=r.pbrMetallicRoughness||{};if(o.color=new ze(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],wn),o.opacity=d[3]}if(u.baseColorTexture!==void 0)c.push(t.assignTexture(o,"map",u.baseColorTexture,_r));if(o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0)c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture));s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}if(r.doubleSided===!0)o.side=Hn;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!==xi){if(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Fe(1,1),r.normalTexture.scale!==void 0){let u=r.normalTexture.scale;o.normalScale.set(u,u)}}if(r.occlusionTexture!==void 0&&s!==xi){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!==xi){let u=r.emissiveFactor;o.emissive=new ze().setRGB(u[0],u[1],u[2],wn)}if(r.emissiveTexture!==void 0&&s!==xi)c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,_r));return Promise.all(c).then(function(){let u=new s(o);if(r.name)u.name=r.name;if(bi(u,r),t.associations.set(u,{materials:e}),r.extensions)Jr(i,u,r);return u})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");if(t in this.nodeNamesUsed)return t+"_"+ ++this.nodeNamesUsed[t];else return this.nodeNamesUsed[t]=0,t}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Ke.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return gg(a,o,t)})}let s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=i1(c),u=i[l];if(u)s.push(u.promise);else{let d;if(c.extensions&&c.extensions[Ke.KHR_DRACO_MESH_COMPRESSION])d=r(c);else d=gg(new sn,c,t);if(c.mode===Wn.TRIANGLE_STRIP)d=d.then((h)=>Vh(h,Ro));else if(c.mode===Wn.TRIANGLE_FAN)d=d.then((h)=>Vh(h,Os));i[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],s=r.primitives,o=[];for(let a=0,c=s.length;a<c;a++){let l=s[a].material===void 0?e1(this.cache):this.getDependency("material",s[a].material);o.push(l)}return o.push(t.loadGeometries(s)),Promise.all(o).then(async function(a){let c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let h=0,f=l.length;h<f;h++){let m=l[h],_=s[h],p,g=c[h];if(_.mode===Wn.TRIANGLES||_.mode===Wn.TRIANGLE_STRIP||_.mode===Wn.TRIANGLE_FAN||_.mode===void 0){let S=r.isSkinnedMesh===!0,T=m.hasAttribute("skinIndex")&&m.hasAttribute("skinWeight");if(S&&T===!1)console.warn("THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.");if(p=S&&T?new Sc(m,g):new wt(m,g),p.isSkinnedMesh===!0)p.normalizeSkinWeights()}else if(_.mode===Wn.LINES)p=new Mc(m,g);else if(_.mode===Wn.LINE_STRIP)p=new yr(m,g);else if(_.mode===Wn.LINE_LOOP)p=new wc(m,g);else if(_.mode===Wn.POINTS)p=new zs(m,g);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);if(Object.keys(p.geometry.morphAttributes).length>0)n1(p,r);if(p.name=t.createUniqueName(r.name||"mesh_"+e),bi(p,r),_.extensions)Jr(i,p,_);t.assignFinalMaterial(p),u.push(p)}for(let h=0,f=u.length;h<f;h++)t.associations.set(u[h],{meshes:e,primitives:h});if(u.length===1){if(r.extensions)Jr(i,u[0],r);return u[0]}let d=new hi;if(r.extensions)Jr(i,d,r);t.associations.set(d,{meshes:e});for(let h=0,f=u.length;h<f;h++)d.add(u[h]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}if(n.type==="perspective")t=new Vt(Co.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2000000);else if(n.type==="orthographic")t=new qr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar);if(n.name)t.name=this.createUniqueName(n.name);return bi(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));if(t.inverseBindMatrices!==void 0)n.push(this.getDependency("accessor",t.inverseBindMatrices));else n.push(null);return Promise.all(n).then(function(i){let r=i.pop(),s=i,o=[],a=[];for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u){o.push(u);let d=new We;if(r!==null)d.fromArray(r.array,c*16);a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Oo(o,a)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,s=[],o=[],a=[],c=[],l=[];for(let u=0,d=i.channels.length;u<d;u++){let h=i.channels[u],f=i.samplers[h.sampler],m=h.target,_=m.node,p=i.parameters!==void 0?i.parameters[f.input]:f.input,g=i.parameters!==void 0?i.parameters[f.output]:f.output;if(m.node===void 0)continue;s.push(this.getDependency("node",_)),o.push(this.getDependency("accessor",p)),a.push(this.getDependency("accessor",g)),c.push(f),l.push(m)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){let d=u[0],h=u[1],f=u[2],m=u[3],_=u[4],p=[];for(let S=0,T=d.length;S<T;S++){let y=d[S],w=h[S],A=f[S],R=m[S],x=_[S];if(y===void 0)continue;if(y.updateMatrix)y.updateMatrix();let M=n._createAnimationTracks(y,w,A,R,x);if(M)for(let k=0;k<M.length;k++)p.push(M[k])}let g=new Ts(r,void 0,p);return bi(g,i),g})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];if(i.mesh===void 0)return null;return n.getDependency("mesh",i.mesh).then(function(r){let s=n._getNodeRef(n.meshCache,i.mesh,r);if(i.weights!==void 0)s.traverse(function(o){if(!o.isMesh)return;for(let a=0,c=i.weights.length;a<c;a++)o.morphTargetInfluences[a]=i.weights[a]});return s})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),s=[],o=i.children||[];for(let c=0,l=o.length;c<l;c++)s.push(n.getDependency("node",o[c]));let a=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),a]).then(function(c){let l=c[0],u=c[1],d=c[2];if(d!==null)l.traverse(function(h){if(!h.isSkinnedMesh)return;h.bind(d,s1)});for(let h=0,f=u.length;h<f;h++)l.add(u[h]);if(l.userData.pivot!==void 0&&u.length>0){let h=l.userData.pivot,f=u[0];l.pivot=new U().fromArray(h),l.position.x-=h[0],l.position.y-=h[1],l.position.z-=h[2],f.position.set(0,0,0),delete l.userData.pivot}return l})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],s=r.name?i.createUniqueName(r.name):"",o=[],a=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});if(a)o.push(a);if(r.camera!==void 0)o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)}));return i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let l;if(r.isBone===!0)l=new No;else if(c.length>1)l=new hi;else if(c.length===1)l=c[0];else l=new _t;if(l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name)l.userData.name=r.name,l.name=s;if(bi(l,r),r.extensions)Jr(n,l,r);if(r.matrix!==void 0){let u=new We;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 hi;if(n.name)r.name=i.createUniqueName(n.name);if(bi(r,n),n.extensions)Jr(t,r,n);let s=n.nodes||[],o=[];for(let a=0,c=s.length;a<c;a++)o.push(i.getDependency("node",s[a]));return Promise.all(o).then(function(a){for(let l=0,u=a.length;l<u;l++){let d=a[l];if(d.parent!==null)r.add(hg(d));else r.add(d)}let c=(l)=>{let u=new Map;for(let[d,h]of i.associations)if(d instanceof yn||d instanceof Nt)u.set(d,h);return l.traverse((d)=>{let h=i.associations.get(d);if(h!=null)u.set(d,h)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){let s=[],o=e.name?e.name:e.uuid,a=[];function c(h){if(h.morphTargetInfluences)a.push(h.name?h.name:h.uuid)}if(Ar[r.path]===Ar.weights){if(c(e),e.isGroup)e.children.forEach(c)}else a.push(o);let l;switch(Ar[r.path]){case Ar.weights:l=Sr;break;case Ar.rotation:l=Mr;break;case Ar.translation:case Ar.scale:l=jr;break;default:switch(n.itemSize){case 1:l=Sr;break;case 2:case 3:default:l=jr;break}break}let u=i.interpolation!==void 0?QT[i.interpolation]:mc,d=this._getArrayFromAccessor(n);for(let h=0,f=a.length;h<f;h++){let m=new l(a[h]+"."+Ar[r.path],t.array,d,u);if(i.interpolation==="CUBICSPLINE")this._createCubicSplineTrackInterpolant(m);s.push(m)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Xh(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 Mr?zg:qh)(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function o1(e,t,n){let i=t.attributes,r=new Gt;if(i.POSITION!==void 0){let a=n.json.accessors[i.POSITION],{min:c,max:l}=a;if(c!==void 0&&l!==void 0){if(r.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){let u=Xh(js[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=t.targets;if(s!==void 0){let a=new U,c=new U;for(let l=0,u=s.length;l<u;l++){let d=s[l];if(d.POSITION!==void 0){let h=n.json.accessors[d.POSITION],{min:f,max:m}=h;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),h.normalized){let _=Xh(js[h.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}e.boundingBox=r;let o=new An;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}function gg(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=Zh[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(qe.workingColorSpace!==wn&&"COLOR_0"in i)console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${qe.workingColorSpace}" not supported.`);return bi(e,t),o1(e,t,n),Promise.all(r).then(function(){return t.targets!==void 0?t1(e,t.targets,n):e})}function Jo(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 Jh(e,t="|"){return e.map((n)=>ed(n)).join(t)}function Ko(e,t){if(typeof t==="bigint")return t.toString();return t}class Vg{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 Qo(e){return new Vg(e)}function Gg(e){return e===null||e===void 0}function Rr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Hg(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 ea(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xi(e){return ea(e._zod.def)??e._zod.def.shape}function $g(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Zn(this,t,i),i},enumerable:!0,configurable:!0})}function Wg(e,t,n){if(t in e)Zn(e,t,n);else e[t]=n}function Kr(e,t,n,i){let r=Xi(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(r,s);if(!o.enumerable)continue;if(o.get)$g(e,s,()=>{let a=t._zod.def.shape[s];return i?i(a,s):a});else Wg(e,s,i?i(o.value,s):o.value)}}function a1(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);if(!i.enumerable)continue;if(i.get)$g(e,n,()=>t[n]);else Wg(e,n,i.value)}}function Cn(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function Zg(e){return JSON.stringify(e)}function Xg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Kh="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qs(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var jg=Qo(()=>{if(hn.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Qr(e){if(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 Qh(e){if(Qr(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var qg=new Set(["string","number","symbol"]),Yg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Si(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 ed(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Jg(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Vc=(()=>({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]}))(),td={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function c1(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 Kr(s,e,Gc(e,t)),Si(e,Cn(n,{shape:s,checks:[]}))}function Gc(e,t){let n=Xi(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw Error(`Unrecognized key: "${String(r)}"`);if(t[r])i.push(r)}return i}function l1(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(Gc(e,t)),o={};return Kr(o,e,Reflect.ownKeys(Xi(e)).filter((a)=>!s.has(a))),Si(e,Cn(n,{shape:o,checks:[]}))}function u1(e,t){if(!Qr(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=Xi(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Si(e,Cn(e._zod.def,{shape:Kg(e,t)}))}function Kg(e,t){let n={};return Kr(n,e,Reflect.ownKeys(Xi(e))),a1(n,t),n}function h1(e,t){if(!Qr(t))throw Error("Invalid input to safeExtend: expected a plain object");return Si(e,Cn(e._zod.def,{shape:Kg(e,t)}))}function d1(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={};Kr(n,e,Reflect.ownKeys(Xi(e))),Kr(n,t,Reflect.ownKeys(Xi(t)));let i=Cn(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Si(e,i)}function Qg(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(Gc(t,n)):void 0,c={};return Kr(c,t,Reflect.ownKeys(Xi(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Si(t,Cn(t._zod.def,{shape:c,checks:[]}))}function f1(e,t,n){let i=n?new Set(Gc(t,n)):void 0,r={};return Kr(r,t,Reflect.ownKeys(Xi(t)),(s,o)=>i&&!i.has(o)?s:new e({type:"nonoptional",innerType:s})),Si(t,Cn(t._zod.def,{shape:r}))}function Xn(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 e_(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 Mi(e,t){return t.map((n)=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Yo(e){return typeof e==="string"?e:e?.message}function nd(e){let t=[];for(let n of e??[]){let i=n._zod.def;if(!/_(length|size)$|_equals$/.test(i.check))break;let r=i.maximum??i.length??i.size;if(r>=0)t.push([r,n])}return t}function Hc(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function wi(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:Yo(e.inst?._zod.def?.error?.(e))??Yo(s?.(e))??Yo(t?.error?.(e))??Yo(n.customError?.(e))??Yo(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 p1=/[\uD800-\uDBFF]/;function $c(e){let t=e.length;if(!p1.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 Wc(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function t_(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 es(...e){let[t,n,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:i};return{...t}}function n_(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);if(i.get)Object.defineProperty(e,n,{...i,enumerable:!1});else m1(e,n,i.value)}}function ji(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function Zc(e,t,n){return ji(e,t,n,!1)}function i_(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return ji(this,n,i(this))},set(r){ji(this,n,r)}})}return t}function m1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ji(this,t,n.bind(this))},set(i){ji(this,t,i)}})}function g1(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Yh,Tr=!1,_1={configurable:!0,get(){Tr=!0;return}};function at(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Yh!==e._zod){Yh=void 0;return}Yh=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,_1);let r=Tr;Tr=!1;try{let s=n(this);if(Tr)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return Tr=Tr||r,s}catch(s){throw delete this[t],Tr=Tr||r,s}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function x1(e,t,n,i){let r=g1(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 y1="~constantCatch";function r_(e){let t=()=>e;return t[y1]=!0,t}var s_;var id={value:void 0,enumerable:!1},o_="captureStackTrace"in Error?Error:null;function v1(e){let t=o_;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return o_=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function J(e,t,n,i){let r={};function s(h){this.def=h,this.constr=d,this.traits=new Set}s.prototype=r;let o=n,a=o&&new WeakSet;function c(h,f){if(!h._zod){id.value=new s(f);try{Object.defineProperty(h,"_zod",id)}finally{id.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,f),a){let _=Object.getPrototypeOf(h),p=h._zod.constr.prototype,g=_;while(g&&g!==p)g=Object.getPrototypeOf(g);let S=g??_;if(!a.has(S))a.add(S),n_(S,o)}let m=d.prototype;for(let _ in m){if(!Object.prototype.hasOwnProperty.call(m,_))continue;if(!(_ in h))h[_]=m[_].bind(h)}}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(h){let f=i?.Parent?v1(u):this;c(f,h);let m=f._zod.deferred;if(m){for(let p of m)p();f._zod.deferred=void 0}let _=globalThis.__zod_globalConfig?.postProcessor;if(_)_(f);return f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(i?.Parent&&h instanceof i.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class Ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ta extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(s_=globalThis).__zod_globalConfig??(s_.__zod_globalConfig={});var hn=globalThis.__zod_globalConfig;function Pn(e){if(e)Object.assign(hn,e);return hn}function b1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ko,2)),e.message}function S1(e){this._zod.message=e}var M1={get:b1,set:S1,enumerable:!0,configurable:!0},sd={value:void 0,enumerable:!1},a_=new WeakSet([Object.prototype,Error.prototype]),c_=(e,t)=>{e.name="$ZodError",sd.value=t,Object.defineProperty(e,"issues",sd),sd.value=void 0,Object.defineProperty(e,"message",M1);let n=Object.getPrototypeOf(e);if(!a_.has(n))a_.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})}})},l_=J("$ZodError",c_),J2=J("$ZodError",c_,void 0,{Parent:Error});function w1(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 u_(e,t=(n)=>n.message){let n={},i=[];for(let r of e.issues)if(r.path.length>0)w1(n,r.path[0],()=>[]).push(t(r));else i.push(t(r));return{formErrors:i,fieldErrors:n}}function h_(e,t=(n)=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],d=l===a.length-1;if(u==="_errors"){if(d)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=c[u];if(d)h._errors.push(t(o));c=h,l++}}}};return i(e),n}function Xc(e,t){return{callee:t?.callee??e,Err:t?.Err}}var jc=(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 Ei;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>wi(l,o,Pn())));throw Kh(c,s?.callee??t),c}return a.value};return t};var qc=(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)=>wi(l,o,Pn())));throw Kh(c,s?.callee??t),c}return a.value};return t};var Yc=(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 Ei;return s.issues.length?d_(e,s.issues,r):{success:!0,data:s.value}};function d_(e,t,n){let i;return{success:!1,get error(){if(!i)i=new e(t.map((r)=>wi(r,n,Pn()))),t=void 0,n=void 0;return i},set error(r){i=r,t=void 0,n=void 0}}}var Jc=(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?d_(e,s.issues,r):{success:!0,data:s.value}};var E1=Symbol.for("zod.compile.invalid"),A1=Symbol.for("zod.compile.fallback"),od=(e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==E1)return!0;if(i.definite===!0&&n===void 0)return!1}return T1(e,t,n)};function T1(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,s;if(r)i[A1]=!0,s=r({value:t,issues:[]},i);else s=e._zod.run({value:t,issues:[]},i);if(s instanceof Promise)throw new Ei;return s.issues.length===0}var ad=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},f_=(e)=>{let t=jc(e),n=(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(i,r,a,Xc(n,o))};return n};var p_=(e)=>{let t=jc(e),n=(i,r,s,o)=>t(i,r,s,Xc(n,o));return n};var m_=(e)=>{let t=qc(e),n=async(i,r,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(i,r,a,Xc(n,o))};return n};var g_=(e)=>{let t=qc(e),n=async(i,r,s,o)=>await t(i,r,s,Xc(n,o));return n};var __=(e)=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Yc(e)(t,n,r)};var x_=(e)=>(t,n,i)=>Yc(e)(t,n,i);var y_=(e)=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return Jc(e)(t,n,r)};var v_=(e)=>async(t,n,i)=>Jc(e)(t,n,i);var b_=/^[cC][0-9a-z]{6,}$/,S_=/^[0-9a-z]+$/,M_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,w_=/^[0-9a-vA-V]{20}$/,E_=/^[A-Za-z0-9]{27}$/,A_=/^[a-zA-Z0-9_-]{21}$/;function T_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var R_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var C_=/^([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})$/,ld=(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 P_=/^(?:[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 R1="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function I_(){return new RegExp(R1,"u")}var L_=/^(?:(?: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])$/,N_=/^(([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 D_=/^((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])$/,O_=/^(([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])$/,U_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,F_=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var k_=/^https?$/,z_=/^\+[1-9]\d{6,14}$/;var B_="(?:(?:\\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 C1(e){return new RegExp(`^${e}$`)}var V_=C1(B_);function cd(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 G_(e){return new RegExp(`^${cd(e)}$`)}function H_(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${cd({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${cd({precision:e.precision})}`:n;return new RegExp(`^${B_}T(?:${i})$`)}var $_=/^[\s\S]{0,}$/,W_=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Kc=/^-?\d+$/,Ys=/^-?\d+(?:\.\d+)?$/,Z_=/^(?:true|false)$/i;var X_=/^[^A-Z]*$/,j_=/^[^a-z]*$/;var Kt=J("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var ud=(e)=>{let t=e.value;return!Gg(t)&&t.length!==void 0},Qc={number:"number",bigint:"bigint",object:"date"},hd=J("$ZodCheckLessThan",(e,t)=>{Kt.init(e,t);let n=Qc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:Qc[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})}}),dd=J("$ZodCheckGreaterThan",(e,t)=>{Kt.init(e,t);let n=Qc[typeof t.value];e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:Qc[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})}}),q_=J("$ZodCheckMultipleOf",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Hg(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})}}),Y_=J("$ZodCheckNumberFormat",(e,t)=>{Kt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,s]=Vc[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 J_=J("$ZodCheckMaxLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ud),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>t.maximum?$c(r):s)<=t.maximum)return;let a=Wc(r);i.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),K_=J("$ZodCheckMinLength",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ud),e._zod.check=(i)=>{let r=i.value,s=r.length;if((typeof r==="string"&&s>=t.minimum&&s<t.minimum*2?$c(r):s)>=t.minimum)return;let a=Wc(r);i.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Q_=J("$ZodCheckLengthEquals",(e,t)=>{var n;Kt.init(e,t),(n=e._zod.def).when??(n.when=ud),e._zod.check=(i)=>{let r=i.value,s=r.length,o=typeof r==="string"&&s>=t.length&&s<=t.length*2?$c(r):s;if(o===t.length)return;let a=Wc(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})}}),ia=J("$ZodCheckStringFormat",(e,t)=>{var n,i;if(Kt.init(e,t),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),e0=J("$ZodCheckRegex",(e,t)=>{ia.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})}}),t0=J("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=X_),ia.init(e,t)}),n0=J("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=j_),ia.init(e,t)}),i0=J("$ZodCheckIncludes",(e,t)=>{Kt.init(e,t);let n=qi(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),r0=J("$ZodCheckStartsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`^${qi(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),s0=J("$ZodCheckEndsWith",(e,t)=>{Kt.init(e,t);let n=new RegExp(`.*${qi(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});var o0=J("$ZodCheckOverwrite",(e,t)=>{Kt.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class fd{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 e0={major:4,minor:6,patch:5};var vt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=e0;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let s of r)for(let o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=Hn(a),d;for(let h of c){if(h._zod.def.when){if(Zg(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Mi;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(jh(a.issues,f,e),!u)u=Hn(a,f)});else{if(a.issues.length===f)continue;if(jh(a.issues,f,e),!u)u=Hn(a,f)}}if(d)return d.then(()=>a);return a},o=(a,c,l)=>{if(Hn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Mi;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>o(d,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Mi;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return zc(this,"~standard",cd(this))},set "~standard"(e){Xi(this,"~standard",e)}}),p0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Si(n,t,Rn()))}:{value:e.value};async function v1(e,t){let n={async:!0};return p0(await e._zod.run({value:t,issues:[]},n),n)}function cd(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return p0(i,n)}catch(i){}return v1(e,t)},vendor:"zod",version:1}}var qc=J("$ZodString",(e,t)=>{vt.init(e,t),e._zod.pattern=t.pattern??U_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Rt=J("$ZodStringFormat",(e,t)=>{Jo.init(e,t),qc.init(e,t)}),m0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=b_),Rt.init(e,t)}),g0=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=td(i))}else t.pattern??(t.pattern=td());Rt.init(e,t)}),_0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=S_),Rt.init(e,t)}),x0=1,Xc=2;function y0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function b1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return y0(e)||Xc;return S1(e,t)}function S1(e,t){if(!t.normalize&&t.protocol?.source===P_.source&&!/^https?:\/\//i.test(e))return x0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Xc}return new URL(e)}catch{return Xc}}var M1=/[\t\n\r]/g;function t0(e){return e.replace(M1,"")}function w1(e,t){return t.lastIndex=0,t.test(e.hostname)}function E1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var v0=J("$ZodURL",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=b1(i,t);if(r===x0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Xc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=t0(i);return}if(t.hostname&&!w1(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&&!E1(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:t0(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),b0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=M_()),Rt.init(e,t)}),S0=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?x_:y_(t.length)),Rt.init(e,t)}),M0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=f_),Rt.init(e,t)}),w0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=p_),Rt.init(e,t)}),E0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=m_),Rt.init(e,t)}),A0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=g_),Rt.init(e,t)}),T0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=__),Rt.init(e,t)}),R0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=O_(t)),Rt.init(e,t)}),C0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=N_),Rt.init(e,t)}),P0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=D_(t)),Rt.init(e,t)}),I0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=v_),Rt.init(e,t)}),L0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=w_),Rt.init(e,t)}),A1=/^[0-9a-fA-F:.]+$/;function N0(e){if(!A1.test(e))return!1;return y0(`http://[${e}]`)}var D0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=E_),Rt.init(e,t),e._zod.check=(n)=>{if(!N0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var O0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=A_),Rt.init(e,t)});function T1(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 N0(n)}var U0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=T_),Rt.init(e,t),e._zod.check=(n)=>{if(!T1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function F0(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 ld=/^[0-9a-zA-Z+/]*={0,2}$/,z0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ld),Rt.init(e,t),e._zod.check=(n)=>{if(F0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Yc=/^[A-Za-z0-9_-]*$/;function R1(e){if(!Yc.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return F0(n)}var k0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yc),Rt.init(e,t),e._zod.check=(n)=>{if(R1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),B0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=I_),Rt.init(e,t)});function C1(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 V0=J("$ZodJWT",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{if(C1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var ud=J("$ZodNumber",(e,t)=>{vt.init(e,t),e._zod.pattern=Ws,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?String(r):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),G0=J("$ZodNumberFormat",(e,t)=>{G_.init(e,t),ud.init(e,t)}),H0=J("$ZodBoolean",(e,t)=>{vt.init(e,t),e._zod.pattern=z_,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 $0=J("$ZodUnknown",(e,t)=>{vt.init(e,t),e._zod.parse=(n)=>n}),W0=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 n0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}var Z0=J("$ZodArray",(e,t)=>{vt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((d)=>n0(d,i,c)));else if(n0(u,i,c),a&&u.issues.length!==0&&Hn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i}});function jc(e,t,n,i,r,s){let o=n in i,a=s==="optional";if(!o&&a&&r==="optional")return;if(e.issues.length){if(r!==void 0&&a&&!o)return;t.issues.push(...bi(n,e.issues))}if(!o&&r===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||r==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var P1=[];function X0(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:P1,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=Hg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function j0(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:h}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Hn(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>jc(p,n,m,t,d,h)));else jc(_,n,m,t,d,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var I1=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=Xo(()=>X0(t));at(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let h in u){let f=u[h]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(d,h))Gn(d,h,new Set);for(let m of f.values)d[h].add(m);if(f.optin!==void 0)d[h].add(void 0)}}return d});let s=$s,o=t.catchall,a,c=hn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Hn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:d[p],issues:[]},u);if(y instanceof Promise)h.push(y.then((w)=>jc(w,l,p,d,S,T)));else jc(y,l,p,d,S,T)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return j0(h,d,l,u,r.value,e,m===!0)}}),q0=J("$ZodObjectJIT",(e,t)=>{I1.init(e,t);let n=e._zod.parse,i=Xo(()=>X0(t)),r=hn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new sd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`
+};`)(...Object.values(this.closed))}}var c0={major:4,minor:6,patch:7};var bt=J("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=c0;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=Xn(a),d;for(let h of c){if(h._zod.def.when){if(e_(a))continue;if(!h._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=h._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Ei;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Hc(a.issues,f,e),!u)u=Xn(a,f)});else{if(a.issues.length===f)continue;if(Hc(a.issues,f,e),!u)u=Xn(a,f)}}if(d)return d.then(()=>a);return a},o=(a,c,l)=>{if(Xn(a))return a.aborted=!0,a;let u=s(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Ei;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>o(d,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ei;return l.then((u)=>s(u,r,c))}return s(l,r,c)}}},{get "~standard"(){return Zc(this,"~standard",gd(this))},set "~standard"(e){ji(this,"~standard",e)}}),S0=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>wi(n,t,Pn()))}:{value:e.value};async function P1(e,t){let n={async:!0};return S0(await e._zod.run({value:t,issues:[]},n),n)}function gd(e){return{validate:(t)=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return S0(i,n)}catch(i){}return P1(e,t)},vendor:"zod",version:1}}var il=J("$ZodString",(e,t)=>{bt.init(e,t),e._zod.pattern=t.pattern??$_,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Rt=J("$ZodStringFormat",(e,t)=>{ia.init(e,t),il.init(e,t)}),M0=J("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=C_),Rt.init(e,t)}),w0=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=ld(i))}else t.pattern??(t.pattern=ld());Rt.init(e,t)}),E0=J("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=P_),Rt.init(e,t)}),A0=1,tl=2;function T0(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function I1(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return T0(e)||tl;return L1(e,t)}function L1(e,t){if(!t.normalize&&t.protocol?.source===k_.source&&!/^https?:\/\//i.test(e))return A0;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??tl}return new URL(e)}catch{return tl}}var N1=/[\t\n\r]/g;function l0(e){return e.replace(N1,"")}function D1(e,t){return t.lastIndex=0,t.test(e.hostname)}function O1(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var R0=J("$ZodURL",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{try{let i=n.value.trim(),r=I1(i,t);if(r===A0){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===tl){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=l0(i);return}if(t.hostname&&!D1(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&&!O1(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:l0(i);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),C0=J("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=I_()),Rt.init(e,t)}),P0=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?A_:T_(t.length)),Rt.init(e,t)}),I0=J("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=b_),Rt.init(e,t)}),L0=J("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=S_),Rt.init(e,t)}),N0=J("$ZodULID",(e,t)=>{t.pattern??(t.pattern=M_),Rt.init(e,t)}),D0=J("$ZodXID",(e,t)=>{t.pattern??(t.pattern=w_),Rt.init(e,t)}),O0=J("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=E_),Rt.init(e,t)}),U0=J("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=H_(t)),Rt.init(e,t)}),F0=J("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=V_),Rt.init(e,t)}),k0=J("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=G_(t)),Rt.init(e,t)}),z0=J("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=R_),Rt.init(e,t)}),B0=J("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=L_),Rt.init(e,t)}),U1=/^[0-9a-fA-F:.]+$/;function V0(e){if(!U1.test(e))return!1;return T0(`http://[${e}]`)}var G0=J("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=N_),Rt.init(e,t),e._zod.check=(n)=>{if(!V0(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var H0=J("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=D_),Rt.init(e,t)});function F1(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 V0(n)}var $0=J("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=O_),Rt.init(e,t),e._zod.check=(n)=>{if(!F1(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function W0(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 _d=/^[0-9a-zA-Z+/]*={0,2}$/,Z0=J("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=_d),Rt.init(e,t),e._zod.check=(n)=>{if(W0(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),rl=/^[A-Za-z0-9_-]*$/;function k1(e){if(!rl.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return W0(n)}var X0=J("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rl),Rt.init(e,t),e._zod.check=(n)=>{if(k1(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),j0=J("$ZodE164",(e,t)=>{t.pattern??(t.pattern=z_),Rt.init(e,t)});function z1(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 q0=J("$ZodJWT",(e,t)=>{Rt.init(e,t),e._zod.check=(n)=>{if(z1(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var xd=J("$ZodNumber",(e,t)=>{bt.init(e,t),e._zod.pattern=Ys,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}}),Y0=J("$ZodNumberFormat",(e,t)=>{Y_.init(e,t),xd.init(e,t)}),J0=J("$ZodBoolean",(e,t)=>{bt.init(e,t),e._zod.pattern=Z_,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 K0=J("$ZodUnknown",(e,t)=>{bt.init(e,t),e._zod.parse=(n)=>n}),Q0=J("$ZodNever",(e,t)=>{bt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function B1(e,t){let n=nd(e._zod.def.checks);if(!n.length)return;let i=Math.min(...n.map((s)=>s[0])),r=e._zod.parse;e._zod.parse=(s,o)=>{let a=t(s.value);if(a>i&&!o?.skipChecks&&o?.direction!=="backward"){for(let[c,l]of nd(e._zod.def.checks))if(a>c&&l._zod.def.when(s)){let u=s.issues.length;return l._zod.check(s),s.issues[u].continue=!1,Hc(s.issues,u,e),s}}return r(s,o)}}var V1=(e)=>Array.isArray(e)?e.length:-1;function u0(e,t,n){if(e.issues.length)t.issues.push(...Mi(n,e.issues));t.value[n]=e.value}var ex=J("$ZodArray",(e,t)=>{bt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),i;i.value=n?n.alloc(e,i,Array(s.length),r):Array(s.length);let o=[],a=r?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)o.push(u.then((d)=>u0(d,i,c)));else if(u0(u,i,c),a&&u.issues.length!==0&&Xn(u))break}if(o.length)return Promise.all(o).then(()=>i);return i},B1(e,V1)});function nl(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(...Mi(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 G1=[];function tx(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:G1,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=Jg(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function nx(e,t,n,i,r,s,o){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,{optin:d,optout:h}=l,f=0;for(let m in t){if(o&&n.issues.length!==f){if(Xn(n,f))break;f=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(u==="never")a.push(m);continue}if(u==="never"){a.push(m);continue}let _=l.run({value:t[m],issues:[]},i);if(_ instanceof Promise)e.push(_.then((p)=>nl(p,n,m,t,d,h)));else nl(_,n,m,t,d,h)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var H1=J("$ZodObject",(e,t)=>{bt.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=Qo(()=>tx(t));at(e,"propValues",(l)=>{let u=l.def.shape,d={};for(let h in u){let f=u[h]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(d,h))Zn(d,h,new Set);for(let m of f.values)d[h].add(m);if(f.optin!==void 0)d[h].add(void 0)}}return d});let s=qs,o=t.catchall,a,c=hn.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=r.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let h=[],f=a.shape,m=u?.abortEarly,_=l.issues.length;for(let p of a.allKeys){if(m&&l.issues.length!==_){if(Xn(l,_))break;_=l.issues.length}if(p==="__proto__")continue;let g=f[p],S=g._zod.optin,T=g._zod.optout,y=g._zod.run({value:d[p],issues:[]},u);if(y instanceof Promise)h.push(y.then((w)=>nl(w,l,p,d,S,T)));else nl(y,l,p,d,S,T)}if(!o)return h.length?Promise.all(h).then(()=>l):l;return nx(h,d,l,u,r.value,e,m===!0)}}),ix=J("$ZodObjectJIT",(e,t)=>{H1.init(e,t);let n=e._zod.parse,i=Qo(()=>tx(t)),r=hn.memoizer,s=(f)=>{let m=i.value,_=m.symbolKeys,p=new fd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:_}),g=(w)=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,S=(w,A)=>`
let ${w}_ab = false;
for (let i = 0; i < ${w}.issues.length; i++) {
const iss = ${w}.issues[i];
@@ -4356,7 +4356,7 @@ ${t.join(`
if (${w}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
- }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:zg(w),x=`${R} in input`,M=f[w],z=M?._zod?.optin,C=z!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=z==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`
+ }`;p.write("const input = payload.value;");let T=Object.create(null),y=0;for(let w of m.allKeys)T[w]=`key_${y++}`;p.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let A=T[w],R=typeof w==="symbol"?`syms[${_.indexOf(w)}]`:Zg(w),x=`${R} in input`,M=f[w],k=M?._zod?.optin,C=k!==void 0,L=M?._zod?.optout==="optional";if(p.write(`const ${A} = ${g(R)};`),C&&L){let K=k==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;p.write(`
const ${A}_present = ${x};
if (!${A}.issues.length || ${A}_present) {
if (${A}.issues.length) {${S(A,R)}
@@ -4391,22 +4391,22 @@ ${t.join(`
`);else if(p.write(`
if (${A}.issues.length) {${S(A,R)}
}
- `),z==="defaulted")p.write(`newResult[${R}] = ${A}.value;`);else p.write(`
+ `),k==="defaulted")p.write(`newResult[${R}] = ${A}.value;`);else p.write(`
if (${A}.value !== undefined || ${x}) {
newResult[${R}] = ${A}.value;
}
- `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=$s,c=!hn.jitless,u=c&&Bg.value,d=t.catchall,h;e._zod.parse=(f,m)=>{h??(h=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!d)return f;return j0([],_,f,m,h,e,m?.abortEarly===!0)}return n(f,m)}});function i0(e,t,n,i){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!Hn(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Si(o,i,Rn())))}),t}var hd=J("$ZodUnion",(e,t)=>{vt.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Mr(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return i0(o,i,e,r);return Promise.all(o).then((a)=>i0(a,i,e,r))}});function L1(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var Y0=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,hd.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Gn(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=jo(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Xo(()=>L1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!$s(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),J0=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])=>r0(n,c,l));return r0(n,s,o)}});function od(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(jr(e)&&jr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=od(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=od(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 r0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);d=[h]}else return!1;for(let h of d){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=od(t.value,n.value);if(!c.valid){if(Hn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var K0=J("$ZodTuple",(e,t)=>{vt.init(e,t);let n=t.items,i=hn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=s0(n,"optin"),l=s0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,d&&!h&&m.issues.length)h=Hn(m)}if(t.rest&&!h){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(d&&r.issues.length!==_){if(Hn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>o0(S,r,f)));else o0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>a0(u,r,n,o,l));return a0(u,r,n,o,l)}});function s0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function o0(e,t,n){if(e.issues.length)t.issues.push(...bi(n,e.issues));t.value[n]=e.value}function a0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...bi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Q0=J("$ZodRecord",(e,t)=>{vt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!jr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>Si(m,r,Rn())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(u,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(u,f.issues));i.value[h]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ws.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>Si(m,r,Rn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...bi(l,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...bi(l,f.issues));i.value[h]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var ex=J("$ZodEnum",(e,t)=>{vt.init(e,t);let n=Wo(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=Wo(r.def.entries).filter((o)=>Vg.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>ji(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),tx=J("$ZodLiteral",(e,t)=>{vt.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?ji(s):s?ji(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var nx=J("$ZodTransform",(e,t)=>{vt.init(e,t),e._zod.optin="optional",hn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new qo(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then((o)=>(n.value=o,n));if(r instanceof Promise)throw new Mi;return n.value=r,n}});function c0(e,t){return e.value=t.issues.length?void 0:t.value,e}var dd=J("$ZodOptional",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>c0(n,s));return c0(n,r)}return t.innerType._zod.run(n,i)}}),ix=J("$ZodExactOptional",(e,t)=>{dd.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),rx=J("$ZodNullable",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Mr(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),sx=J("$ZodDefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>l0(s,t));return l0(r,t)}});function l0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var ox=J("$ZodPrefault",(e,t)=>{vt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),ax=J("$ZodNonOptional",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>u0(s,e));return u0(r,e)}});function u0(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 h0(e,t,n,i){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((r)=>Si(r,i,Rn()))},input:e.value}),e}var cx=J("$ZodCatch",(e,t)=>{vt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>h0(n,s,t,i));return h0(n,r,t,i)}});var lx=J("$ZodPipe",(e,t)=>{vt.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>Zc(o,t.in,i));return Zc(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>Zc(s,t.out,i));return Zc(r,t.out,i)}});function Zc(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 ux=J("$ZodReadonly",(e,t)=>{vt.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(d0);return d0(r)}});function d0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function N1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return F_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Ws?$c:o)?.source}function ad(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=ad(i);if(n&&r&&s&&s!==r)return n.replace(Mr(r),()=>Mr(s));return n}if(t.options){let r=t.options.map(ad);if(r.every(Boolean))return`^(${r.map((s)=>Mr(s)).join("|")})$`}return N1(e)}var hx=J("$ZodTemplateLiteral",(e,t)=>{vt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=ad(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Mr(r))}else if(i===null||Gg.has(typeof i))n.push(ji(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var dx=J("$ZodCustom",(e,t)=>{Kt.init(e,t),vt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=(n)=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then((s)=>f0(s,n,i,e));f0(r,n,i,e);return}});function f0(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)r.params=i._zod.def.params;t.issues.push(qr(r))}}class px extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var pd="~memo",fx=[];function mx(e){return e!==null&&typeof e==="object"}function fd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var gx=new WeakMap,Ko=0,Qc=1,Qo=2;function el(e,t,n){let i=gx.get(e);if(i!==void 0)return i?Qo:Ko;if(t.has(e))return Qo;t.add(e);let r=Ko,s=(u)=>{if(r!==Qo&&u?._zod){let d=el(u,t,n);if(d>r)r=d}},o=(u,d)=>{let h=Ko;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let _=m.get?Qc:m.value?._zod?el(m.value,t,n):Ko;if(_>h)h=_}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=jo(c);a(u?o(u,!0):Qc),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?el(u,t,!1):Qc);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}return t.delete(e),D1(e,r)}function D1(e,t){if(t!==Qc)gx.set(e,t===Qo);return t}function O1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Jc,Kc=[],U1={alloc(e,t,n){let i=Jc;if(!i)return n;Jc=void 0;let r={value:n,issues:null};return i.set(t.value,r),Kc.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"&&F1(s,r.value))throw new px;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=el(e,new Set,!1);if(g===Ko){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===Qo||i)n=!0;else i=!0}let u=c.value;if(!mx(u))return o(c,l);let d=l[pd];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[pd]=d;let h;if(r===l)h=s;else h=O1(d,e),r=l,s=h;let f=h.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...fd(f.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value);return c}Jc=h;let m=Kc.length,_=o(c,l);Jc=void 0;let p=Kc.length>m?Kc.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?fd(g.issues):fx;return g});if(p)p.issues=_.issues.length?fd(_.issues):fx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function _x(){return U1}function F1(e,t){let n=e[pd]?.backEdges;return n!==void 0&&mx(t)&&n.has(t)}var z1=()=>{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=Xg(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 ${Zh(s.values[0])}`;return`Invalid option: expected one of ${Hh(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":""}: ${Hh(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 md(){return{localeError:z1()}}var xx;class yx{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 k1(){return new yx}(xx=globalThis).__zod_globalRegistry??(xx.__zod_globalRegistry=k1());var Yr=globalThis.__zod_globalRegistry;function vx(e){if(e.checks)e.checks=[...e.checks];return e}function bx(e,t){return new e(vx({type:"string",...Ce(t)}))}function Sx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function Mx(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function wx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function Ex(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function Ax(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Tx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function Rx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Cx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function Px(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function $x(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Wx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function Zx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function Xx(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function jx(e,t){return new e(vx({type:"number",checks:[],...Ce(t)}))}function qx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function Yx(e,t){return new e({type:"boolean",...Ce(t)})}function Jx(e){return new e({type:"unknown"})}function Kx(e,t){return new e({type:"never",...Ce(t)})}function tl(e,t){return new id({check:"less_than",...Ce(t),value:e,inclusive:!1})}function ea(e,t){return new id({check:"less_than",...Ce(t),value:e,inclusive:!0})}function nl(e,t){return new rd({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function ta(e,t){return new rd({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function il(e,t){return new V_({check:"multiple_of",...Ce(t),value:e})}function rl(e,t){return new H_({check:"max_length",...Ce(t),maximum:e})}function Zs(e,t){return new $_({check:"min_length",...Ce(t),minimum:e})}function sl(e,t){return new W_({check:"length_equals",...Ce(t),length:e})}function gd(e,t){return new Z_({check:"string_format",format:"regex",...Ce(t),pattern:e})}function _d(e){return new X_({check:"string_format",format:"lowercase",...Ce(e)})}function xd(e){return new j_({check:"string_format",format:"uppercase",...Ce(e)})}function yd(e,t){return new q_({check:"string_format",format:"includes",...Ce(t),includes:e})}function vd(e,t){return new Y_({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function bd(e,t){return new J_({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function wr(e){return new K_({check:"overwrite",tx:e})}function Sd(e){return wr((t)=>t.normalize(e))}function Md(){return wr((e)=>e.trim())}function wd(){return wr((e)=>e.toLowerCase())}function Ed(){return wr((e)=>e.toUpperCase())}function Ad(){return wr((e)=>kg(e))}function Qx(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function ey(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function ty(e,t){let n=B1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(qr(r,i.value,n._zod.def));else{let s=r;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=i.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(qr(s))}},e(i.value,i)),t);return n}function B1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function na(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,i))Gn(e,i,n[i]);return e}function Rd(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Yr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function qi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,h,u)}let d=e._zod.parent;if(d){if(!o.ref)o.ref=d;It(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)na(o.schema,c);if(t.io==="input"&&dn(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 ny(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Cd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,h=e.external.uri??((m)=>m);if(d)return{ref:h(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${ny(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+ny(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
+ `)}return p.write("payload.value = newResult;"),p.write("return payload;"),p.compile()},o,a=qs,c=!hn.jitless,u=c&&jg.value,d=t.catchall,h;e._zod.parse=(f,m)=>{h??(h=i.value);let _=f.value;if(!a(_))return f.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),f;if(c&&u&&m?.async===!1&&m.jitless!==!0){if(!o)o=s(t.shape);if(f=o(f,m),!d)return f;return nx([],_,f,m,h,e,m?.abortEarly===!0)}return n(f,m)}});function h0(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)=>!Xn(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)=>wi(o,i,Pn())))}),t}var yd=J("$ZodUnion",(e,t)=>{bt.init(e,t),at(e,"optin",(i)=>i.def.options.some((r)=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some((r)=>r._zod.optin!==void 0)?"optional":void 0),at(e,"optout",(i)=>i.def.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),at(e,"values",(i)=>{if(i.def.options.every((r)=>r._zod.values))return new Set(i.def.options.flatMap((r)=>Array.from(r._zod.values)));return}),at(e,"pattern",(i)=>{if(i.def.options.every((r)=>r._zod.pattern)){let r=i.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Rr(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 h0(o,i,e,r);return Promise.all(o).then((a)=>h0(a,i,e,r))}});function $1(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var rx=J("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,yd.init(e,t);let n=e._zod.parse;at(e,"propValues",(r)=>{let s={},o=0;for(let a of r.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${r.def.options.indexOf(a)}"`);if(c[r.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))Zn(s,l,new Set);for(let d of u)s[l].add(d)}}if(!r.def.unionFallback&&o>1)s[r.def.discriminator]?.delete(void 0);return s}),t.options.forEach((r,s)=>{let o=ea(r._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let i=Qo(()=>$1(t));e._zod.parse=(r,s)=>{let o=r.value;if(!qs(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let a=o?.[t.discriminator],c=i.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(r,s);if(t.unionFallback||s.direction==="backward")return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter((l)=>i.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),r}}),sx=J("$ZodIntersection",(e,t)=>{bt.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])=>d0(n,c,l));return d0(n,s,o)}});function pd(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Qr(e)&&Qr(t)){let n=Object.keys(t),i=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};if(Object.prototype.hasOwnProperty.call(r,"__proto__"))delete r.__proto__;for(let s of i){if(s==="__proto__")continue;let o=pd(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=pd(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 d0(e,t,n){let i=new Map,r,s=new Map,o=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!s.has(h))s.set(h,l);d=[h]}else return!1;for(let h of d){if(!i.has(h))i.set(h,{});i.get(h)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=r?a.filter((u)=>r.keys.includes(u)):[];if(l.length)e.issues.push({...r,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=pd(t.value,n.value);if(!c.valid){if(Xn(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var ox=J("$ZodTuple",(e,t)=>{bt.init(e,t);let n=t.items,i=hn.memoizer;i?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],s):[];let a=[],c=f0(n,"optin"),l=f0(n,"optout");if(!t.rest){if(o.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),r;if(o.length>n.length)r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),d=t.rest?s?.abortEarly:void 0,h=!1;for(let f=0;f<n.length;f++){let m=n[f]._zod.run({value:o[f],issues:[]},s);if(m instanceof Promise)a.push(m.then((_)=>{u[f]=_}));else if(u[f]=m,d&&!h&&m.issues.length)h=Xn(m)}if(t.rest&&!h){let f=n.length-1,m=o.slice(n.length),_=r.issues.length;for(let p of m){if(d&&r.issues.length!==_){if(Xn(r,_))break;_=r.issues.length}f++;let g=t.rest._zod.run({value:p,issues:[]},s);if(g instanceof Promise)a.push(g.then((S)=>p0(S,r,f)));else p0(g,r,f)}}if(a.length)return Promise.all(a).then(()=>m0(u,r,n,o,l));return m0(u,r,n,o,l)}});function f0(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function p0(e,t,n){if(e.issues.length)t.issues.push(...Mi(n,e.issues));t.value[n]=e.value}function m0(e,t,n,i,r){for(let s=0;s<n.length;s++){let o=e[s],a=s<i.length;if(!a&&s>=r&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=r){t.value.length=s;break}t.issues.push(...Mi(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=i.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var ax=J("$ZodRecord",(e,t)=>{bt.init(e,t);let n=hn.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let s=i.value;if(!Qr(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),i;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((m)=>wi(m,r,Pn())),input:u,path:[u],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Mi(u,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...Mi(u,f.issues));i.value[h]=f.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ys.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)u=m}if(u.issues.length){if(t.mode==="loose")i.value[l]=s[l];else if(a)c=c??[],c.push(l);else i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((m)=>wi(m,r,Pn())),input:l,path:[l],inst:e});continue}let h=u.value;if(h==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},r);if(f instanceof Promise)o.push(f.then((m)=>{if(m.issues.length)i.issues.push(...Mi(l,m.issues));i.value[h]=m.value}));else{if(f.issues.length)i.issues.push(...Mi(l,f.issues));i.value[h]=f.value}}if(c&&c.length>0)i.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>i);return i}});var cx=J("$ZodEnum",(e,t)=>{bt.init(e,t);let n=Jo(t.entries),i=new Set(n);e._zod.values=i,at(e,"pattern",(r)=>{let s=Jo(r.def.entries).filter((o)=>qg.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>qi(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(i.has(o))return r;return r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),lx=J("$ZodLiteral",(e,t)=>{bt.init(e,t);let n=new Set(t.values);e._zod.values=n,at(e,"pattern",(i)=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map((s)=>typeof s==="string"?qi(s):s?qi(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let s=i.value;if(n.has(s))return i;return i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});var ux=J("$ZodTransform",(e,t)=>{bt.init(e,t),e._zod.optin="optional",hn.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ta(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 Ei;return n.value=r,n}});function g0(e,t){return e.value=t.issues.length?void 0:t.value,e}var vd=J("$ZodOptional",(e,t)=>{bt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Rr(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)=>g0(n,s));return g0(n,r)}return t.innerType._zod.run(n,i)}}),hx=J("$ZodExactOptional",(e,t)=>{vd.init(e,t),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),dx=J("$ZodNullable",(e,t)=>{bt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"pattern",(n)=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${Rr(i.source)}|null)$`):void 0}),at(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>{if(n.value===null)return n;return t.innerType._zod.run(n,i)}}),fx=J("$ZodDefault",(e,t)=>{bt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>_0(s,t));return _0(r,t)}});function _0(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var px=J("$ZodPrefault",(e,t)=>{bt.init(e,t),e._zod.optin="defaulted",at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,i)}}),mx=J("$ZodNonOptional",(e,t)=>{bt.init(e,t),at(e,"values",(n)=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>x0(s,e));return x0(r,e)}});function x0(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 y0(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)=>wi(r,i,Pn()))},input:e.value}),e}var gx=J("$ZodCatch",(e,t)=>{bt.init(e,t),at(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),at(e,"optout",(n)=>n.def.innerType._zod.optout),at(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);if(r instanceof Promise)return r.then((s)=>y0(n,s,t,i));return y0(n,r,t,i)}});var _x=J("$ZodPipe",(e,t)=>{bt.init(e,t),at(e,"values",(n)=>n.def.in._zod.values),at(e,"optin",(n)=>n.def.in._zod.optin),at(e,"optout",(n)=>n.def.out._zod.optout),at(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=t.out._zod.run(n,i);if(s instanceof Promise)return s.then((o)=>el(o,t.in,i));return el(s,t.in,i)}let r=t.in._zod.run(n,i);if(r instanceof Promise)return r.then((s)=>el(s,t.out,i));return el(r,t.out,i)}});function el(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 xx=J("$ZodReadonly",(e,t)=>{bt.init(e,t),at(e,"propValues",(n)=>n.def.innerType._zod.propValues),at(e,"values",(n)=>n.def.innerType._zod.values),at(e,"optin",(n)=>n.def.innerType?._zod?.optin),at(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);if(r instanceof Promise)return r.then(v0);return v0(r)}});function v0(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function W1(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;if(l!==void 0&&(r===void 0||l>r))r=l;if(u!==void 0&&(s===void 0||u<s))s=u}if(n)return n.source;if(r!==void 0&&s!==void 0&&r>s)return"(?!)";if(r!==void 0||s!==void 0)return W_({minimum:r,maximum:s}).source;let o=e._zod.pattern;return(i&&o===Ys?Kc:o)?.source}function md(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,s=md(i);if(n&&r&&s&&s!==r)return n.replace(Rr(r),()=>Rr(s));return n}if(t.options){let r=t.options.map(md);if(r.every(Boolean))return`^(${r.map((s)=>Rr(s)).join("|")})$`}return W1(e)}var yx=J("$ZodTemplateLiteral",(e,t)=>{bt.init(e,t);let n=[];for(let i of t.parts)if(typeof i==="object"&&i!==null){let r=md(i);if(!r)throw Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(Rr(r))}else if(i===null||Yg.has(typeof i))n.push(qi(`${i}`));else throw Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>{if(typeof i.value!=="string")return i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(i.value))return i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i;return i}});var vx=J("$ZodCustom",(e,t)=>{Kt.init(e,t),bt.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)=>b0(s,n,i,e));b0(r,n,i,e);return}});function b0(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(es(r))}}class Sx extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Sd="~memo",bx=[];function Mx(e){return e!==null&&typeof e==="object"}function bd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var wx=new WeakMap,ra=0,al=1,sa=2;function cl(e,t,n){let i=wx.get(e);if(i!==void 0)return i?sa:ra;if(t.has(e))return sa;t.add(e);let r=ra,s=(u)=>{if(r!==sa&&u?._zod){let d=cl(u,t,n);if(d>r)r=d}},o=(u,d)=>{let h=ra;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let _=m.get?al:m.value?._zod?cl(m.value,t,n):ra;if(_>h)h=_}return h},a=(u)=>{if(u>r)r=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ea(c);a(u?o(u,!0):al),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?cl(u,t,!1):al);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)s(h);else if(Array.isArray(h))for(let f of h)s(f)}}return t.delete(e),Z1(e,r)}function Z1(e,t){if(t!==al)wx.set(e,t===sa);return t}function X1(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var sl,ol=[],j1={alloc(e,t,n){let i=sl;if(!i)return n;sl=void 0;let r={value:n,issues:null};return i.set(t.value,r),ol.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"&&q1(s,r.value))throw new Sx;return n(r,s)};if(e._zod.parse=i,e._zod.run===n)e._zod.run=i})},attach(e){var t;let n,i=!1,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let g=cl(e,new Set,!1);if(g===ra){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(g===sa||i)n=!0;else i=!0}let u=c.value;if(!Mx(u))return o(c,l);let d=l[Sd];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[Sd]=d;let h;if(r===l)h=s;else h=X1(d,e),r=l,s=h;let f=h.get(u);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...bd(f.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value);return c}sl=h;let m=ol.length,_=o(c,l);sl=void 0;let p=ol.length>m?ol.pop():void 0;if(_ instanceof Promise)return _.then((g)=>{if(p)p.issues=g.issues.length?bd(g.issues):bx;return g});if(p)p.issues=_.issues.length?bd(_.issues):bx;return _};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function Ex(){return j1}function q1(e,t){let n=e[Sd]?.backEdges;return n!==void 0&&Mx(t)&&n.has(t)}var Y1=()=>{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=t_(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 ${ed(s.values[0])}`;return`Invalid option: expected one of ${Jh(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":""}: ${Jh(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 Md(){return{localeError:Y1()}}var Ax;class Tx{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 J1(){return new Tx}(Ax=globalThis).__zod_globalRegistry??(Ax.__zod_globalRegistry=J1());var ts=globalThis.__zod_globalRegistry;function Rx(e){if(e.checks)e.checks=[...e.checks];return e}function Cx(e,t){return new e(Rx({type:"string",...Ce(t)}))}function Px(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ce(t)})}function Ix(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ce(t)})}function Lx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ce(t)})}function Nx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ce(t)})}function Dx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ce(t)})}function Ox(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ce(t)})}function Ux(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ce(t)})}function Fx(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ce(t)})}function kx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ce(t)})}function zx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ce(t)})}function Bx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ce(t)})}function Vx(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ce(t)})}function Gx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ce(t)})}function Hx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ce(t)})}function $x(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ce(t)})}function Wx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ce(t)})}function Zx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ce(t)})}function Xx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ce(t)})}function jx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ce(t)})}function qx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ce(t)})}function Yx(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ce(t)})}function Jx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ce(t)})}function Kx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ce(t)})}function Qx(e,t){return new e({type:"string",format:"date",check:"string_format",...Ce(t)})}function ey(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ce(t)})}function ty(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ce(t)})}function ny(e,t){return new e(Rx({type:"number",checks:[],...Ce(t)}))}function iy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ce(t)})}function ry(e,t){return new e({type:"boolean",...Ce(t)})}function sy(e){return new e({type:"unknown"})}function oy(e,t){return new e({type:"never",...Ce(t)})}function ll(e,t){return new hd({check:"less_than",...Ce(t),value:e,inclusive:!1})}function oa(e,t){return new hd({check:"less_than",...Ce(t),value:e,inclusive:!0})}function ul(e,t){return new dd({check:"greater_than",...Ce(t),value:e,inclusive:!1})}function aa(e,t){return new dd({check:"greater_than",...Ce(t),value:e,inclusive:!0})}function hl(e,t){return new q_({check:"multiple_of",...Ce(t),value:e})}function dl(e,t){return new J_({check:"max_length",...Ce(t),maximum:e})}function Js(e,t){return new K_({check:"min_length",...Ce(t),minimum:e})}function fl(e,t){return new Q_({check:"length_equals",...Ce(t),length:e})}function wd(e,t){return new e0({check:"string_format",format:"regex",...Ce(t),pattern:e})}function Ed(e){return new t0({check:"string_format",format:"lowercase",...Ce(e)})}function Ad(e){return new n0({check:"string_format",format:"uppercase",...Ce(e)})}function Td(e,t){return new i0({check:"string_format",format:"includes",...Ce(t),includes:e})}function Rd(e,t){return new r0({check:"string_format",format:"starts_with",...Ce(t),prefix:e})}function Cd(e,t){return new s0({check:"string_format",format:"ends_with",...Ce(t),suffix:e})}function Cr(e){return new o0({check:"overwrite",tx:e})}function Pd(e){return Cr((t)=>t.normalize(e))}function Id(){return Cr((e)=>e.trim())}function Ld(){return Cr((e)=>e.toLowerCase())}function Nd(){return Cr((e)=>e.toUpperCase())}function Dd(){return Cr((e)=>Xg(e))}function ay(e,t,n){return new e({type:"array",element:t,...Ce(n)})}function cy(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ce(n)})}function ly(e,t){let n=K1((i)=>(i.addIssue=(r)=>{if(typeof r==="string")i.issues.push(es(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(es(s))}},e(i.value,i)),t);return n}function K1(e,t){let n=new Kt({check:"custom",...Ce(t)});return n._zod.check=e,n}function ca(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 Ud(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??ts,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Yi(e,t,n,i,r){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(r);return Object.assign(n,s),!0}function It(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let h=o.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,h,u)}let d=e._zod.parent;if(d){if(!o.ref)o.ref=d;It(d,t,u),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)ca(o.schema,c);if(t.io==="input"&&dn(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 uy(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Fd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=i.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,h=e.external.uri??((m)=>m);if(d)return{ref:h(d)};let f=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${uy(f)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+uy(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=r(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
-Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function sy(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;sy(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 oy=new Set(["type","properties","required","additionalProperties"]),iy=["oneOf","anyOf"];function ry(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 Td(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!oy.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]??ry(l);if(u===null||u===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Td(a)??{allOf:a};Gn(n,o,c)}for(let o of s.required??[])i.add(o)}let r={type:"object",properties:n};if(i.size)r.required=[...i];if(t.every((s)=>s.additionalProperties===!1))r.additionalProperties=!1;else{let s=[];for(let o of t){let a=ry(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 V1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of oy)if(r in e)return;let n=t.filter((r)=>iy.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Td(t);else{let r=n[0],s=iy.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)=>Td([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,na(e,i)}function Pd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else na(l,m);if(na(l,u),a._zod.parent===d)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==d){i(h);let f=e.seen.get(h);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())sy(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);if(d)d.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])V1(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)}na(r,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&r.id===s)delete r.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Gn(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")r.$defs=o;else r.definitions=o;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ia(t,"input",e.processors),output:ia(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function dn(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 dn(i.element,n);if(i.type==="set")return dn(i.valueType,n);if(i.type==="lazy")return dn(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 dn(i.innerType,n);if(i.type==="intersection")return dn(i.left,n)||dn(i.right,n);if(i.type==="record"||i.type==="map")return dn(i.keyType,n)||dn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return dn(i.in,n)||dn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(dn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(dn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(dn(r,n))return!0;if(i.rest&&dn(i.rest,n))return!0;return!1}return!1}var ay=(e,t={})=>(n)=>{let i=Rd({...n,processors:t});return It(e,i),Cd(i,e),Pd(i,e)},ia=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Rd({...r??{},target:s,io:t,processors:n});return It(e,o),Cd(o,e),Pd(o,e)};var Xs=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},js=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},cy=(e,t)=>{Xs(e,"minimum",t),js(e,"maximum",t)},dy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},fy=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},py=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},my=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},ly=(e,t)=>Xs(e,"minimum",t.minimum),uy=(e,t)=>js(e,"maximum",t.maximum),hy=(e)=>(t,n)=>{my(t,n.format);let[i,r]=e[n.format];Xs(t,"minimum",i),js(t,"maximum",r)},G1={greater_than:(e,t)=>Xs(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>js(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>dy(e,t.value),number_format:hy(Dc),bigint_format:hy(Xh),min_length:ly,max_length:uy,length_equals:(e,t)=>cy(e,t.length),min_size:ly,max_size:uy,size_equals:(e,t)=>cy(e,t.size),string_format:(e,t)=>{if(my(e,t.format),t.pattern)fy(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)=>py(e,t.mime)};function Cn(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)G1[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Xs(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Xs(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)js(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)js(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)dy(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)py(t,r.mime);for(let s of r.patterns??[])fy(t,s);return t}var H1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$1=new Map([[ld,R_],[Yc,C_]]),gy=(e)=>$1.get(e)??e,_y=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Cn(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=H1[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(gy);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},xy=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Cn(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else qi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},yy=(e,t,n,i)=>{n.type="boolean"};var vy=(e,t,n,i)=>{n.not={}};var by=(e,t,n,i)=>{};var Sy=(e,t,n,i)=>{let r=e._zod.def,s=Wo(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},My=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(qi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(qi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var wy=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var Ey=(e,t,n,i)=>{qi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Ay=(e,t,n,i)=>{qi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Ty=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=Cn(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function ra(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ra(t.out);if(t.type==="catch")return ra(t.innerType);return e._zod.optin}var Ry=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&qi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Gn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?ra(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Cy=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},Py=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Iy=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ra(_)!==void 0:_._zod.optout==="optional"))break;u--}let d=s.items.length,h=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,h)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(h)r.maxItems=d}else{if(r.items=c,h)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}let{minimum:f,maximum:m}=Cn(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function Id(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=Id(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>Id(e,g,n));if(p.some((g,S)=>g!==_[S]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:h,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?Ws:$c).source;return f}var Ld=new WeakMap;function W1(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 Ld.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Id(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 Ly=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=Cn(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of a)Gn(r.patternProperties,gy(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Ld.get(t);if(!u)u=[],Ld.set(t,u),t.deferred.push(()=>W1(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ra(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},Ny=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Dy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Nd=Symbol();function Oy(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return qi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Nd}var Uy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Oy(r.defaultValue,e,t,n,i);if(o!==Nd)n.default=o},Fy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Oy(r.defaultValue,e,t,n,i);if(o!==Nd)n._prefault=o},zy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{qi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},ky=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},By=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Dd=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var Vy=new WeakSet([Object.prototype,Error.prototype]);function ol(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 Q1=(e,t)=>{t_.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Vy.has(n))return;Vy.add(n),ol(n,"format",(i)=>(r)=>i_(i,r)),ol(n,"flatten",(i)=>(r)=>n_(i,r)),ol(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Zo,2)}),ol(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Zo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Pn=J("ZodError",Q1,void 0,{Parent:Error});var Gy=Bc(Pn),Hy=Vc(Pn),$y=Gc(Pn),Wy=Hc(Pn),Zy=s_(Pn),Xy=o_(Pn),jy=a_(Pn),qy=c_(Pn),Yy=l_(Pn),Jy=u_(Pn),Ky=h_(Pn),Qy=d_(Pn);function tR(){if(!hn.localeError)Rn(md())}function sa(){if(!hn.memoizer)Rn({memoizer:_x()})}var Ct=J("ZodType",(e,t)=>(tR(),vt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Tn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return vi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(eC(e,t))},superRefine(e,t){return this.check(tC(e,t))},overwrite(e){return this.check(wr(e))},optional(){return nv(this)},exactOptional(){return kR(this)},nullable(){return iv(this)},nullish(){return nv(iv(this))},nonoptional(e){return WR(this,e)},array(){return _t(this)},or(e){return qs([this,e])},and(e){return DR(this,e)},transform(e){return rv(this,zR(e))},default(e){return GR(this,e)},prefault(e){return $R(this,e)},catch(e){return XR(this,e)},pipe(e){return rv(this,e)},readonly(){return YR(this)},describe(e){let t=this.clone();return Yr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yr.get(this);let t=this.clone();return Yr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return zc(this,"~standard",{...cd(this),jsonSchema:{input:ia(this,"input"),output:ia(this,"output")}})},set "~standard"(e){Xi(this,"~standard",e)},parse:function e(t,n){return Gy(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Hy(this,t,n,{callee:e})},safeParse(e,t){return $y(this,e,t)},async safeParseAsync(e,t){return Wy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Xi(this,"spa",e)},validate(e,t){return Kh(this,e,t)},validateAsync(e,t){return Qh(this,e,t)},encode:function e(t,n){return Zy(this,t,n,{callee:e})},decode:function e(t,n){return Xy(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await jy(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await qy(this,t,n,{callee:e})},safeEncode(e,t){return Yy(this,e,t)},safeDecode(e,t){return Jy(this,e,t)},async safeEncodeAsync(e,t){return Ky(this,e,t)},async safeDecodeAsync(e,t){return Qy(this,e,t)},toJSONSchema(e){return ay(this,{})(e)},get description(){return Yr.get(this)?.description},get _def(){return this._zod.def}}),sv=J("_ZodString",(e,t)=>{qc.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_y(e,n,i,r)},qg({format:(e)=>Cn(e).format??null,minLength:(e)=>Cn(e).minimum??null,maxLength:(e)=>Cn(e).maximum??null},{regex(...e){return this.check(gd(...e))},includes(...e){return this.check(yd(...e))},startsWith(...e){return this.check(vd(...e))},endsWith(...e){return this.check(bd(...e))},min(...e){return this.check(Zs(...e))},max(...e){return this.check(rl(...e))},length(...e){return this.check(sl(...e))},nonempty(...e){return this.check(Zs(1,...e))},lowercase(e){return this.check(_d(e))},uppercase(e){return this.check(xd(e))},trim(){return this.check(Md())},normalize(...e){return this.check(Sd(...e))},toLowerCase(){return this.check(wd())},toUpperCase(){return this.check(Ed())},slugify(){return this.check(Ad())}})),nR=J("ZodString",(e,t)=>{qc.init(e,t),sv.init(e,t)},{email(e){return this.check(Sx(aR,e))},url(e){return this.check(Rx(lR,e))},jwt(e){return this.check(Hx(wR,e))},emoji(e){return this.check(Cx(uR,e))},guid(e){return this.check(Mx(cR,e))},uuid(e){return this.check(wx(al,e))},uuidv4(e){return this.check(Ex(al,e))},uuidv6(e){return this.check(Ax(al,e))},uuidv7(e){return this.check(Tx(al,e))},nanoid(e){return this.check(Px(hR,e))},cuid(e){return this.check(Ix(dR,e))},cuid2(e){return this.check(Lx(fR,e))},ulid(e){return this.check(Nx(pR,e))},base64(e){return this.check(Bx(bR,e))},base64url(e){return this.check(Vx(SR,e))},xid(e){return this.check(Dx(mR,e))},ksuid(e){return this.check(Ox(gR,e))},ipv4(e){return this.check(Ux(_R,e))},ipv6(e){return this.check(Fx(xR,e))},cidrv4(e){return this.check(zx(yR,e))},cidrv6(e){return this.check(kx(vR,e))},e164(e){return this.check(Gx(MR,e))},datetime(e){return this.check($x(iR,e))},date(e){return this.check(Wx(rR,e))},time(e){return this.check(Zx(sR,e))},duration(e){return this.check(Xx(oR,e))}});function Xe(e){return bx(nR,e)}var Lt=J("ZodStringFormat",(e,t)=>{Rt.init(e,t),sv.init(e,t)}),iR=J("ZodISODateTime",(e,t)=>{R0.init(e,t),Lt.init(e,t)}),rR=J("ZodISODate",(e,t)=>{C0.init(e,t),Lt.init(e,t)}),sR=J("ZodISOTime",(e,t)=>{P0.init(e,t),Lt.init(e,t)}),oR=J("ZodISODuration",(e,t)=>{I0.init(e,t),Lt.init(e,t)}),aR=J("ZodEmail",(e,t)=>{_0.init(e,t),Lt.init(e,t)});var cR=J("ZodGUID",(e,t)=>{m0.init(e,t),Lt.init(e,t)});var al=J("ZodUUID",(e,t)=>{g0.init(e,t),Lt.init(e,t)});var lR=J("ZodURL",(e,t)=>{v0.init(e,t),Lt.init(e,t)});var uR=J("ZodEmoji",(e,t)=>{b0.init(e,t),Lt.init(e,t)});var hR=J("ZodNanoID",(e,t)=>{S0.init(e,t),Lt.init(e,t)});var dR=J("ZodCUID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var fR=J("ZodCUID2",(e,t)=>{w0.init(e,t),Lt.init(e,t)});var pR=J("ZodULID",(e,t)=>{E0.init(e,t),Lt.init(e,t)});var mR=J("ZodXID",(e,t)=>{A0.init(e,t),Lt.init(e,t)});var gR=J("ZodKSUID",(e,t)=>{T0.init(e,t),Lt.init(e,t)});var _R=J("ZodIPv4",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var xR=J("ZodIPv6",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var yR=J("ZodCIDRv4",(e,t)=>{O0.init(e,t),Lt.init(e,t)});var vR=J("ZodCIDRv6",(e,t)=>{U0.init(e,t),Lt.init(e,t)});var bR=J("ZodBase64",(e,t)=>{z0.init(e,t),Lt.init(e,t)});var SR=J("ZodBase64URL",(e,t)=>{k0.init(e,t),Lt.init(e,t)});var MR=J("ZodE164",(e,t)=>{B0.init(e,t),Lt.init(e,t)});var wR=J("ZodJWT",(e,t)=>{V0.init(e,t),Lt.init(e,t)});var ov=J("ZodNumber",(e,t)=>{ud.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xy(e,n,i,r),e.isFinite=!0},qg({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=Cn(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=Cn(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=Cn(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>Cn(e).format??null},{gt(e,t){return this.check(nl(e,t))},gte(e,t){return this.check(ta(e,t))},min(e,t){return this.check(ta(e,t))},lt(e,t){return this.check(tl(e,t))},lte(e,t){return this.check(ea(e,t))},max(e,t){return this.check(ea(e,t))},int(e){return this.check(ev(e))},safe(e){return this.check(ev(e))},positive(e){return this.check(nl(0,e))},nonnegative(e){return this.check(ta(0,e))},negative(e){return this.check(tl(0,e))},nonpositive(e){return this.check(ea(0,e))},multipleOf(e,t){return this.check(il(e,t))},step(e,t){return this.check(il(e,t))},finite(){return this}}));function et(e){return jx(ov,e)}var ER=J("ZodNumberFormat",(e,t)=>{G0.init(e,t),ov.init(e,t)});function ev(e){return qx(ER,e)}var AR=J("ZodBoolean",(e,t)=>{H0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yy(e,n,i,r)});function Kr(e){return Yx(AR,e)}var TR=J("ZodUnknown",(e,t)=>{$0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>by(e,n,i,r)});function Jr(){return Jx(TR)}var RR=J("ZodNever",(e,t)=>{W0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vy(e,n,i,r)});function CR(e){return Kx(RR,e)}var PR=J("ZodArray",(e,t)=>{sa(),Z0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Zs(e,t))},nonempty(e){return this.check(Zs(1,e))},max(e,t){return this.check(rl(e,t))},length(e,t){return this.check(sl(e,t))},unwrap(){return this.element}});function _t(e,t){return Qx(PR,e,t)}var IR=J("ZodObject",(e,t)=>{sa(),q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r),c1(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return wt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Tn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Tn(this._zod.def,{catchall:Jr()}))},loose(){return this.clone(Tn(this._zod.def,{catchall:Jr()}))},strict(){return this.clone(Tn(this._zod.def,{catchall:CR()}))},strip(){return this.clone(Tn(this._zod.def,{catchall:void 0}))},extend(e){return e1(this,e)},safeExtend(e){return t1(this,e)},merge(e){return n1(this,e)},pick(e){return KT(this,e)},omit(e){return QT(this,e)},partial(...e){return Wg(Fd,this,e[0])},exactPartial(...e){return Wg(lv,this,e[0],"exactPartial")},required(...e){return i1(uv,this,e[0])}});function be(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new IR(n)}var av=J("ZodUnion",(e,t)=>{hd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r),e.options=t.options});function qs(e,t){return new av({type:"union",options:e,...Ce(t)})}var LR=J("ZodDiscriminatedUnion",(e,t)=>{av.init(e,t),Y0.init(e,t)});function ni(e,t,n){return new LR({type:"union",options:t,discriminator:e,...Ce(n)})}var NR=J("ZodIntersection",(e,t)=>{J0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Py(e,n,i,r)});function DR(e,t){return new NR({type:"intersection",left:e,right:t})}var OR=J("ZodTuple",(e,t)=>{sa(),K0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iy(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Fd({type:"optional",innerType:t}))})}});function cv(e,t,n){let i=t instanceof vt,r=i?n:t;return new OR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var tv=J("ZodRecord",(e,t)=>{sa(),Q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function cl(e,t,n){if(!t||!t._zod)return new tv({type:"record",keyType:Xe(),valueType:e,...Ce(t)});return new tv({type:"record",keyType:e,valueType:t,...Ce(n)})}var Ud=J("ZodEnum",(e,t)=>{ex.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(i,r,s)=>Sy(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 Ud({...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 Ud({...t,checks:[],...Ce(r),entries:s})}});function wt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new Ud({type:"enum",entries:n,...Ce(t)})}var UR=J("ZodLiteral",(e,t)=>{tx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>My(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Oe(e,t){return new UR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var FR=J("ZodTransform",(e,t)=>{sa(),nx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new qo(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(qr(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(qr(o))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function zR(e){return new FR({type:"transform",transform:e})}var Fd=J("ZodOptional",(e,t)=>{dd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function nv(e){return new Fd({type:"optional",innerType:e})}var lv=J("ZodExactOptional",(e,t)=>{ix.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function kR(e){return new lv({type:"optional",innerType:e})}var BR=J("ZodNullable",(e,t)=>{rx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ny(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function iv(e){return new BR({type:"nullable",innerType:e})}var VR=J("ZodDefault",(e,t)=>{sx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function GR(e,t){return new VR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Wh(t)}})}var HR=J("ZodPrefault",(e,t)=>{ox.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function $R(e,t){return new HR({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Wh(t)}})}var uv=J("ZodNonOptional",(e,t)=>{ax.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function WR(e,t){return new uv({type:"nonoptional",innerType:e,...Ce(t)})}var ZR=J("ZodCatch",(e,t)=>{cx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function XR(e,t){return new ZR({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Yg(t)})}var jR=J("ZodPipe",(e,t)=>{lx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ky(e,n,i,r),e.in=t.in,e.out=t.out});function rv(e,t){return new jR({type:"pipe",in:e,out:t})}var qR=J("ZodReadonly",(e,t)=>{ux.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>By(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function YR(e){return new qR({type:"readonly",innerType:e})}var JR=J("ZodTemplateLiteral",(e,t)=>{hx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wy(e,n,i,r)});function KR(e,t){return new JR({type:"template_literal",parts:e,...Ce(t)})}var QR=J("ZodCustom",(e,t)=>{dx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r)});function eC(e,t={}){return ey(QR,e,t)}function tC(e,t){return ty(e,t)}var hv=["neutral","dark","light"];var kd=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),dv=Object.freeze({neutral:kd("neutral",[170,177,188]),dark:kd("dark",[26,26,26]),light:kd("light",[223,227,232])});var QD=dv.neutral.rgb,eO=dv.neutral.hex;/*!
+Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function fy(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;fy(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 py=new Set(["type","properties","required","additionalProperties"]),hy=["oneOf","anyOf"];function dy(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 Od(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!py.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]??dy(l);if(u===null||u===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Od(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=dy(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 Q1(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of py)if(r in e)return;let n=t.filter((r)=>hy.some((s)=>Array.isArray(r[s]))),i=null;if(!n.length)i=Od(t);else{let r=n[0],s=hy.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)=>Od([...o,c]));if(a.some((c)=>!c))return;i={[s]:a}}if(!i)return;delete e.allOf,ca(e,i)}function kd(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else ca(l,m);if(ca(l,u),a._zod.parent===d)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(!(p in u))delete l[p]}if(m.$ref&&f.def)for(let p in l){if(p==="$ref"||p==="allOf")continue;if(p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p]))delete l[p]}}let h=a._zod.parent;if(h&&h!==d){i(h);let f=e.seen.get(h);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())i(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())fy(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);if(d)d.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])Q1(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)}ca(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:la(t,"input",e.processors),output:la(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function dn(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 dn(i.element,n);if(i.type==="set")return dn(i.valueType,n);if(i.type==="lazy")return dn(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 dn(i.innerType,n);if(i.type==="intersection")return dn(i.left,n)||dn(i.right,n);if(i.type==="record"||i.type==="map")return dn(i.keyType,n)||dn(i.valueType,n);if(i.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return dn(i.in,n)||dn(i.out,n)}if(i.type==="object"){for(let r in i.shape)if(dn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(dn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(dn(r,n))return!0;if(i.rest&&dn(i.rest,n))return!0;return!1}return!1}var my=(e,t={})=>(n)=>{let i=Ud({...n,processors:t});return It(e,i),Fd(i,e),kd(i,e)},la=(e,t,n={})=>(i)=>{let{libraryOptions:r,target:s}=i??{},o=Ud({...r??{},target:s,io:t,processors:n});return It(e,o),Fd(o,e),kd(o,e)};var Ks=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Qs=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},gy=(e,t)=>{Ks(e,"minimum",t),Qs(e,"maximum",t)},vy=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},by=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Sy=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},My=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},_y=(e,t)=>Ks(e,"minimum",t.minimum),xy=(e,t)=>Qs(e,"maximum",t.maximum),yy=(e)=>(t,n)=>{My(t,n.format);let[i,r]=e[n.format];Ks(t,"minimum",i),Qs(t,"maximum",r)},eR={greater_than:(e,t)=>Ks(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Qs(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>vy(e,t.value),number_format:yy(Vc),bigint_format:yy(td),min_length:_y,max_length:xy,length_equals:(e,t)=>gy(e,t.length),min_size:_y,max_size:xy,size_equals:(e,t)=>gy(e,t.size),string_format:(e,t)=>{if(My(e,t.format),t.pattern)by(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)=>Sy(e,t.mime)};function In(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of i)eR[s._zod.def.check]?.(t,s._zod.def);let r=e._zod.bag;if(r.minimum!==void 0)Ks(t,"minimum",r.minimum);if(r.exclusiveMinimum!==void 0)Ks(t,"exclusiveMinimum",r.exclusiveMinimum);if(r.maximum!==void 0)Qs(t,"maximum",r.maximum);if(r.exclusiveMaximum!==void 0)Qs(t,"exclusiveMaximum",r.exclusiveMaximum);if(r.multipleOf!==void 0)vy(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)Sy(t,r.mime);for(let s of r.patterns??[])by(t,s);return t}var tR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nR=new Map([[_d,U_],[rl,F_]]),wy=(e)=>nR.get(e)??e,Ey=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=In(e);if(typeof s==="number")r.minLength=s;if(typeof o==="number")r.maxLength=o;if(a){if(r.format=tR[a]??a,r.format==="")delete r.format;if(a==="time"||u)delete r.format}if(l)r.contentEncoding=l;if(c&&c.size>0){let d=[...c].map(wy);if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},Ay=(e,t,n,i)=>{let r=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=In(e);r.type=u?"integer":"number";let d=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(f)r.minimum=l,r.exclusiveMinimum=!0;else r.exclusiveMinimum=l;else if(typeof s==="number")r.minimum=s;if(h)if(f)r.maximum=c,r.exclusiveMaximum=!0;else r.exclusiveMaximum=c;else if(typeof o==="number")r.maximum=o;if(a){let m=new Set;for(let g of a)if(Number.isFinite(g)&&g!==0)m.add(Math.abs(g));else Yi(e,t,r,i,`A multipleOf divisor of ${g} cannot be represented in JSON Schema`);let[_,...p]=m;if(_!==void 0)r.multipleOf=_;if(p.length)r.allOf=[...r.allOf??[],...p.map((g)=>({multipleOf:g}))]}},Ty=(e,t,n,i)=>{n.type="boolean"};var Ry=(e,t,n,i)=>{n.not={}};var Cy=(e,t,n,i)=>{};var Py=(e,t,n,i)=>{let r=e._zod.def,s=Jo(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},Iy=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let s=[];for(let o of r.values)if(o===void 0){if(Yi(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Yi(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}};var Ly=(e,t,n,i)=>{let r=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");r.type="string",r.pattern=s.source};var Ny=(e,t,n,i)=>{Yi(e,t,n,i,"Custom types cannot be represented in JSON Schema")};var Dy=(e,t,n,i)=>{Yi(e,t,n,i,"Transforms cannot be represented in JSON Schema")};var Oy=(e,t,n,i)=>{let r=n,s=e._zod.def,{minimum:o,maximum:a}=In(e);if(typeof o==="number")r.minItems=o;if(typeof a==="number")r.maxItems=a;r.type="array",r.items=It(s.element,t,{...i,path:[...i.path,"items"]})};function ua(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return ua(t.out);if(t.type==="catch")return ua(t.innerType);return e._zod.optin}var Uy=(e,t,n,i)=>{let r=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Yi(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in o)Zn(r.properties,l,It(o[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?ua(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)r.required=c;if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=It(s.catchall,t,{...i,path:[...i.path,"additionalProperties"]})},Fy=(e,t,n,i)=>{let r=e._zod.def,s=r.inclusive===!1,o=r.options.map((a,c)=>It(a,t,{...i,path:[...i.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},ky=(e,t,n,i)=>{let r=e._zod.def,s=It(r.left,t,{...i,path:[...i.path,"allOf",0]}),o=It(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},zy=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((_,p)=>It(_,t,{...i,path:[...i.path,o,p]})),l=s.rest?It(s.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let _=s.items[u-1];if(!(t.io==="input"?ua(_)!==void 0:_._zod.optout==="optional"))break;u--}let d=s.items.length,h=!s.rest;if(t.target==="draft-2020-12"){if(r.prefixItems=c,h)r.items=!1;else if(l)r.items=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}else if(t.target==="openapi-3.0"){if(r.items={anyOf:c},l)r.items.anyOf.push(l);if(u>0)r.minItems=u;if(h)r.maxItems=d}else{if(r.items=c,h)r.additionalItems=!1;else if(l)r.additionalItems=l;if(u>0)r.minItems=u;if(h)r.maxItems=d}let{minimum:f,maximum:m}=In(e);if(typeof f==="number")r.minItems=f;if(typeof m==="number")r.maxItems=m};function zd(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let m=e.get(t)?.def;if(!m)return t;let _=zd(e,m,n);return _===m?t:_}for(let m of["anyOf","oneOf"]){let _=t[m];if(!Array.isArray(_))continue;let p=_.map((g)=>zd(e,g,n));if(p.some((g,S)=>g!==_[S]))t={...t,[m]:p}}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some((m)=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!s?.some((m)=>typeof m==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:h,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!r)return f;if(f.type="string",!s)f.pattern=(i.includes("number")?Ys:Kc).source;return f}var Bd=new WeakMap;function iR(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 Bd.get(e)??[]){let r=e.seen.get(i),s=(r?.def??r?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=zd(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 By=(e,t,n,i)=>{let r=n,s=e._zod.def;r.type="object";let o=s.keyType,a=In(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=It(s.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of a)Zn(r.patternProperties,wy(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=It(s.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=Bd.get(t);if(!u)u=[],Bd.set(t,u),t.deferred.push(()=>iR(t));u.push(e)}r.additionalProperties=It(s.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&ua(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)r.required=u.map(String)}},Vy=(e,t,n,i)=>{let r=e._zod.def,s=It(r.innerType,t,i),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Gy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType},Vd=Symbol();function Hy(e,t,n,i,r){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Yi(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),Vd}var $y=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o=Hy(r.defaultValue,e,t,n,i);if(o!==Vd)n.default=o},Wy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);if(s.ref=r.innerType,t.io!=="input")return;let o=Hy(r.defaultValue,e,t,n,i);if(o!==Vd)n._prefault=o},Zy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{Yi(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},Xy=(e,t,n,i)=>{let r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?r.out:r.in:r.out;It(o,t,i);let a=t.seen.get(e);a.ref=o},jy=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var Gd=(e,t,n,i)=>{let r=e._zod.def;It(r.innerType,t,i);let s=t.seen.get(e);s.ref=r.innerType};var qy=new WeakSet([Object.prototype,Error.prototype]);function pl(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 hR=(e,t)=>{l_.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(qy.has(n))return;qy.add(n),pl(n,"format",(i)=>(r)=>h_(i,r)),pl(n,"flatten",(i)=>(r)=>u_(i,r)),pl(n,"addIssue",(i)=>(r)=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Ko,2)}),pl(n,"addIssues",(i)=>(r)=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Ko,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Ln=J("ZodError",hR,void 0,{Parent:Error});var Yy=jc(Ln),Jy=qc(Ln),Ky=Yc(Ln),Qy=Jc(Ln),ev=f_(Ln),tv=p_(Ln),nv=m_(Ln),iv=g_(Ln),rv=__(Ln),sv=x_(Ln),ov=y_(Ln),av=v_(Ln);function fR(){if(!hn.localeError)Pn(Md())}function ha(){if(!hn.memoizer)Pn({memoizer:Ex()})}var Ct=J("ZodType",(e,t)=>(fR(),bt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Cn(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Si(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dC(e,t))},superRefine(e,t){return this.check(fC(e,t))},overwrite(e){return this.check(Cr(e))},optional(){return uv(this)},exactOptional(){return JR(this)},nullable(){return hv(this)},nullish(){return uv(hv(this))},nonoptional(e){return iC(this,e)},array(){return ht(this)},or(e){return eo([this,e])},and(e){return ZR(this,e)},transform(e){return dv(this,YR(e))},default(e){return eC(this,e)},prefault(e){return nC(this,e)},catch(e){return sC(this,e)},pipe(e){return dv(this,e)},readonly(){return cC(this)},describe(e){let t=this.clone();return ts.add(t,{description:e}),t},meta(...e){if(e.length===0)return ts.get(this);let t=this.clone();return ts.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 Zc(this,"~standard",{...gd(this),jsonSchema:{input:la(this,"input"),output:la(this,"output")}})},set "~standard"(e){ji(this,"~standard",e)},parse:function e(t,n){return Yy(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Jy(this,t,n,{callee:e})},safeParse(e,t){return Ky(this,e,t)},async safeParseAsync(e,t){return Qy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ji(this,"spa",e)},validate(e,t){return od(this,e,t)},validateAsync(e,t){return ad(this,e,t)},encode:function e(t,n){return ev(this,t,n,{callee:e})},decode:function e(t,n){return tv(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await nv(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await iv(this,t,n,{callee:e})},safeEncode(e,t){return rv(this,e,t)},safeDecode(e,t){return sv(this,e,t)},async safeEncodeAsync(e,t){return ov(this,e,t)},async safeDecodeAsync(e,t){return av(this,e,t)},toJSONSchema(e){return my(this,{})(e)},get description(){return ts.get(this)?.description},get _def(){return this._zod.def}}),fv=J("_ZodString",(e,t)=>{il.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ey(e,n,i,r)},i_({format:(e)=>In(e).format??null,minLength:(e)=>In(e).minimum??null,maxLength:(e)=>In(e).maximum??null},{regex(...e){return this.check(wd(...e))},includes(...e){return this.check(Td(...e))},startsWith(...e){return this.check(Rd(...e))},endsWith(...e){return this.check(Cd(...e))},min(...e){return this.check(Js(...e))},max(...e){return this.check(dl(...e))},length(...e){return this.check(fl(...e))},nonempty(...e){return this.check(Js(1,...e))},lowercase(e){return this.check(Ed(e))},uppercase(e){return this.check(Ad(e))},trim(){return this.check(Id())},normalize(...e){return this.check(Pd(...e))},toLowerCase(){return this.check(Ld())},toUpperCase(){return this.check(Nd())},slugify(){return this.check(Dd())}})),pR=J("ZodString",(e,t)=>{il.init(e,t),fv.init(e,t)},{email(e){return this.check(Px(yR,e))},url(e){return this.check(Ux(bR,e))},jwt(e){return this.check(Jx(UR,e))},emoji(e){return this.check(Fx(SR,e))},guid(e){return this.check(Ix(vR,e))},uuid(e){return this.check(Lx(ml,e))},uuidv4(e){return this.check(Nx(ml,e))},uuidv6(e){return this.check(Dx(ml,e))},uuidv7(e){return this.check(Ox(ml,e))},nanoid(e){return this.check(kx(MR,e))},cuid(e){return this.check(zx(wR,e))},cuid2(e){return this.check(Bx(ER,e))},ulid(e){return this.check(Vx(AR,e))},base64(e){return this.check(jx(NR,e))},base64url(e){return this.check(qx(DR,e))},xid(e){return this.check(Gx(TR,e))},ksuid(e){return this.check(Hx(RR,e))},ipv4(e){return this.check($x(CR,e))},ipv6(e){return this.check(Wx(PR,e))},cidrv4(e){return this.check(Zx(IR,e))},cidrv6(e){return this.check(Xx(LR,e))},e164(e){return this.check(Yx(OR,e))},datetime(e){return this.check(Kx(mR,e))},date(e){return this.check(Qx(gR,e))},time(e){return this.check(ey(_R,e))},duration(e){return this.check(ty(xR,e))}});function je(e){return Cx(pR,e)}var Lt=J("ZodStringFormat",(e,t)=>{Rt.init(e,t),fv.init(e,t)}),mR=J("ZodISODateTime",(e,t)=>{U0.init(e,t),Lt.init(e,t)}),gR=J("ZodISODate",(e,t)=>{F0.init(e,t),Lt.init(e,t)}),_R=J("ZodISOTime",(e,t)=>{k0.init(e,t),Lt.init(e,t)}),xR=J("ZodISODuration",(e,t)=>{z0.init(e,t),Lt.init(e,t)}),yR=J("ZodEmail",(e,t)=>{E0.init(e,t),Lt.init(e,t)});var vR=J("ZodGUID",(e,t)=>{M0.init(e,t),Lt.init(e,t)});var ml=J("ZodUUID",(e,t)=>{w0.init(e,t),Lt.init(e,t)});var bR=J("ZodURL",(e,t)=>{R0.init(e,t),Lt.init(e,t)});var SR=J("ZodEmoji",(e,t)=>{C0.init(e,t),Lt.init(e,t)});var MR=J("ZodNanoID",(e,t)=>{P0.init(e,t),Lt.init(e,t)});var wR=J("ZodCUID",(e,t)=>{I0.init(e,t),Lt.init(e,t)});var ER=J("ZodCUID2",(e,t)=>{L0.init(e,t),Lt.init(e,t)});var AR=J("ZodULID",(e,t)=>{N0.init(e,t),Lt.init(e,t)});var TR=J("ZodXID",(e,t)=>{D0.init(e,t),Lt.init(e,t)});var RR=J("ZodKSUID",(e,t)=>{O0.init(e,t),Lt.init(e,t)});var CR=J("ZodIPv4",(e,t)=>{B0.init(e,t),Lt.init(e,t)});var PR=J("ZodIPv6",(e,t)=>{G0.init(e,t),Lt.init(e,t)});var IR=J("ZodCIDRv4",(e,t)=>{H0.init(e,t),Lt.init(e,t)});var LR=J("ZodCIDRv6",(e,t)=>{$0.init(e,t),Lt.init(e,t)});var NR=J("ZodBase64",(e,t)=>{Z0.init(e,t),Lt.init(e,t)});var DR=J("ZodBase64URL",(e,t)=>{X0.init(e,t),Lt.init(e,t)});var OR=J("ZodE164",(e,t)=>{j0.init(e,t),Lt.init(e,t)});var UR=J("ZodJWT",(e,t)=>{q0.init(e,t),Lt.init(e,t)});var pv=J("ZodNumber",(e,t)=>{xd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ay(e,n,i,r),e.isFinite=!0},i_({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=In(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=In(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=In(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>In(e).format??null},{gt(e,t){return this.check(ul(e,t))},gte(e,t){return this.check(aa(e,t))},min(e,t){return this.check(aa(e,t))},lt(e,t){return this.check(ll(e,t))},lte(e,t){return this.check(oa(e,t))},max(e,t){return this.check(oa(e,t))},int(e){return this.check(cv(e))},safe(e){return this.check(cv(e))},positive(e){return this.check(ul(0,e))},nonnegative(e){return this.check(aa(0,e))},negative(e){return this.check(ll(0,e))},nonpositive(e){return this.check(oa(0,e))},multipleOf(e,t){return this.check(hl(e,t))},step(e,t){return this.check(hl(e,t))},finite(){return this}}));function Ue(e){return ny(pv,e)}var FR=J("ZodNumberFormat",(e,t)=>{Y0.init(e,t),pv.init(e,t)});function cv(e){return iy(FR,e)}var kR=J("ZodBoolean",(e,t)=>{J0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ty(e,n,i,r)});function ns(e){return ry(kR,e)}var zR=J("ZodUnknown",(e,t)=>{K0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cy(e,n,i,r)});function Pr(){return sy(zR)}var BR=J("ZodNever",(e,t)=>{Q0.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ry(e,n,i,r)});function VR(e){return oy(BR,e)}var GR=J("ZodArray",(e,t)=>{ha(),ex.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Oy(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Js(e,t))},nonempty(e){return this.check(Js(1,e))},max(e,t){return this.check(dl(e,t))},length(e,t){return this.check(fl(e,t))},unwrap(){return this.element}});function ht(e,t){return ay(GR,e,t)}var HR=J("ZodObject",(e,t)=>{ha(),ix.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Uy(e,n,i,r),x1(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return xt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Cn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Cn(this._zod.def,{catchall:Pr()}))},loose(){return this.clone(Cn(this._zod.def,{catchall:Pr()}))},strict(){return this.clone(Cn(this._zod.def,{catchall:VR()}))},strip(){return this.clone(Cn(this._zod.def,{catchall:void 0}))},extend(e){return u1(this,e)},safeExtend(e){return h1(this,e)},merge(e){return d1(this,e)},pick(e){return c1(this,e)},omit(e){return l1(this,e)},partial(...e){return Qg(Wd,this,e[0])},exactPartial(...e){return Qg(_v,this,e[0],"exactPartial")},required(...e){return f1(xv,this,e[0])}});function _e(e,t){let n={type:"object",shape:e??{},...Ce(t)};return new HR(n)}var mv=J("ZodUnion",(e,t)=>{yd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Fy(e,n,i,r),e.options=t.options});function eo(e,t){return new mv({type:"union",options:e,...Ce(t)})}var $R=J("ZodDiscriminatedUnion",(e,t)=>{mv.init(e,t),rx.init(e,t)});function oi(e,t,n){return new $R({type:"union",options:t,discriminator:e,...Ce(n)})}var WR=J("ZodIntersection",(e,t)=>{sx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ky(e,n,i,r)});function ZR(e,t){return new WR({type:"intersection",left:e,right:t})}var XR=J("ZodTuple",(e,t)=>{ha(),ox.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zy(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Wd({type:"optional",innerType:t}))})}});function gv(e,t,n){let i=t instanceof bt,r=i?n:t;return new XR({type:"tuple",items:e,rest:i?t:null,...Ce(r)})}var lv=J("ZodRecord",(e,t)=>{ha(),ax.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>By(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function gl(e,t,n){if(!t||!t._zod)return new lv({type:"record",keyType:je(),valueType:e,...Ce(t)});return new lv({type:"record",keyType:e,valueType:t,...Ce(n)})}var $d=J("ZodEnum",(e,t)=>{cx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(i,r,s)=>Py(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 $d({...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 $d({...t,checks:[],...Ce(r),entries:s})}});function xt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((i)=>[i,i])):e;return new $d({type:"enum",entries:n,...Ce(t)})}var jR=J("ZodLiteral",(e,t)=>{lx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Iy(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 Ne(e,t){return new jR({type:"literal",values:Array.isArray(e)?e:[e],...Ce(t)})}var qR=J("ZodTransform",(e,t)=>{ha(),ux.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Dy(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ta(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(es(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(es(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 YR(e){return new qR({type:"transform",transform:e})}var Wd=J("ZodOptional",(e,t)=>{vd.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Gd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function uv(e){return new Wd({type:"optional",innerType:e})}var _v=J("ZodExactOptional",(e,t)=>{hx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Gd(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function JR(e){return new _v({type:"optional",innerType:e})}var KR=J("ZodNullable",(e,t)=>{dx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Vy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function hv(e){return new KR({type:"nullable",innerType:e})}var QR=J("ZodDefault",(e,t)=>{fx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$y(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function eC(e,t){return new QR({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Qh(t)}})}var tC=J("ZodPrefault",(e,t)=>{px.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Wy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function nC(e,t){return new tC({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Qh(t)}})}var xv=J("ZodNonOptional",(e,t)=>{mx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Gy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function iC(e,t){return new xv({type:"nonoptional",innerType:e,...Ce(t)})}var rC=J("ZodCatch",(e,t)=>{gx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Zy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sC(e,t){return new rC({type:"catch",innerType:e,catchValue:typeof t==="function"?t:r_(t)})}var oC=J("ZodPipe",(e,t)=>{_x.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Xy(e,n,i,r),e.in=t.in,e.out=t.out});function dv(e,t){return new oC({type:"pipe",in:e,out:t})}var aC=J("ZodReadonly",(e,t)=>{xx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jy(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function cC(e){return new aC({type:"readonly",innerType:e})}var lC=J("ZodTemplateLiteral",(e,t)=>{yx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ly(e,n,i,r)});function uC(e,t){return new lC({type:"template_literal",parts:e,...Ce(t)})}var hC=J("ZodCustom",(e,t)=>{vx.init(e,t),Ct.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ny(e,n,i,r)});function dC(e,t={}){return cy(hC,e,t)}function fC(e,t){return ly(e,t)}var yv=["neutral","dark","light"];var Xd=(e,t)=>Object.freeze({id:e,rgb:Object.freeze([...t]),hex:`#${t.map((n)=>n.toString(16).padStart(2,"0")).join("")}`}),vv=Object.freeze({neutral:Xd("neutral",[170,177,188]),dark:Xd("dark",[26,26,26]),light:Xd("light",[223,227,232])});var pO=vv.neutral.rgb,mO=vv.neutral.hex;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
-*/var Dt=Uint8Array,In=Uint16Array,jd=Int32Array,ll=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ul=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Hd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yv=function(e,t){var n=new In(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new jd(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}},vv=yv(ll,2),{b:bv,r:$d}=vv;bv[28]=258,$d[258]=28;var Sv=yv(ul,0),{b:nC,r:fv}=Sv,Wd=new In(32768);for(Qe=0;Qe<32768;++Qe)wi=(Qe&43690)>>1|(Qe&21845)<<1,wi=(wi&52428)>>2|(wi&13107)<<2,wi=(wi&61680)>>4|(wi&3855)<<4,Wd[Qe]=((wi&65280)>>8|(wi&255)<<8)>>1;var wi,Qe,Ei=function(e,t,n){var i=e.length,r=0,s=new In(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new In(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new In(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=o[e[r]-1]++<<u;for(var h=d|(1<<u)-1;d<=h;++d)a[Wd[d]>>c]=l}}else{a=new In(i);for(r=0;r<i;++r)if(e[r])a[r]=Wd[o[e[r]-1]++]>>15-e[r]}return a},Er=new Dt(288);for(Qe=0;Qe<144;++Qe)Er[Qe]=8;var Qe;for(Qe=144;Qe<256;++Qe)Er[Qe]=9;var Qe;for(Qe=256;Qe<280;++Qe)Er[Qe]=7;var Qe;for(Qe=280;Qe<288;++Qe)Er[Qe]=8;var Qe,ca=new Dt(32);for(Qe=0;Qe<32;++Qe)ca[Qe]=5;var Qe,iC=Ei(Er,9,0),rC=Ei(Er,9,1),sC=Ei(ca,5,0),oC=Ei(ca,5,1),Bd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ii=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},Vd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qd=function(e){return(e+7)/8|0},Yd=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var aC=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],$n=function(e,t,n){var i=Error(t||aC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,$n);if(!n)throw i;return i},cC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(Ae){var Et=n.length;if(Ae>Et){var Ge=new Dt(Math.max(Et*2,Ae));Ge.set(n),n=Ge}},u=t.f||0,d=t.p||0,h=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ii(e,d,1);var S=ii(e,d+1,3);if(d+=3,!S){var T=qd(d)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)$n(0);break}if(a)l(h+y);n.set(e.subarray(T,w),h),t.b=h+=y,t.p=d=w*8,t.f=u;continue}else if(S==1)f=rC,m=oC,_=9,p=5;else if(S==2){var A=ii(e,d,31)+257,R=ii(e,d+10,15)+4,x=A+ii(e,d+5,31)+1;d+=14;var M=new Dt(x),z=new Dt(19);for(var C=0;C<R;++C)z[Hd[C]]=ii(e,d+C*3,7);d+=R*3;var L=Bd(z),K=(1<<L)-1,I=Ei(z,L,1);for(var C=0;C<x;){var G=I[ii(e,d,K)];d+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ii(e,d,3),d+=2,X=M[C-1];else if(T==17)P=3+ii(e,d,7),d+=3;else if(T==18)P=11+ii(e,d,127),d+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),k=M.subarray(A);_=Bd(j),p=Bd(k),f=Ei(j,_,1),m=Ei(k,p,1)}else $n(1);if(d>g){if(c)$n(0);break}}if(a)l(h+131072);var q=(1<<_)-1,Q=(1<<p)-1,Me=d;for(;;Me=d){var X=f[Vd(e,d)&q],ue=X>>4;if(d+=X&15,d>g){if(c)$n(0);break}if(!X)$n(2);if(ue<256)n[h++]=ue;else if(ue==256){Me=d,f=null;break}else{var Be=ue-254;if(ue>264){var C=ue-257,we=ll[C];Be=ii(e,d,(1<<we)-1)+bv[C],d+=we}var Z=m[Vd(e,d)&Q],re=Z>>4;if(!Z)$n(3);d+=Z&15;var k=nC[re];if(re>3){var we=ul[re];k+=Vd(e,d)&(1<<we)-1,d+=we}if(d>g){if(c)$n(0);break}if(a)l(h+131072);var se=h+Be;if(h<k){var xe=s-k,Ee=Math.min(k,se);if(xe+h<0)$n(3);for(;h<Ee;++h)n[h]=i[xe+h]}for(;h<se;++h)n[h]=n[h-k]}}if(t.l=f,t.p=Me,t.b=h,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return h!=n.length&&o?Yd(n,0,h):n.subarray(0,h)},Yi=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},oa=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},Gd=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:wv,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var f=new In(h+1),m=Zd(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},Zd=function(e,t,n){return e.s==-1?Math.max(Zd(e.l,t,n+1),Zd(e.r,t,n+1)):t[e.s]=n},pv=function(e){var t=e.length;while(t&&!e[--t]);var n=new In(++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}},aa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Mv=function(e,t,n){var i=n.length,r=qd(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},mv=function(e,t,n,i,r,s,o,a,c,l,u){Yi(t,u++,n),++r[256];var d=Gd(r,15),{t:h,l:f}=d,m=Gd(s,15),{t:_,l:p}=m,g=pv(h),{c:S,n:T}=g,y=pv(_),{c:w,n:A}=y,R=new In(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=Gd(R,7),{t:z,l:C}=M,L=19;for(;L>4&&!z[Hd[L-1]];--L);var K=l+5<<3,I=aa(r,Er)+aa(s,ca)+o,G=aa(r,h)+aa(s,_)+o+14+3*L+aa(R,z)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return Mv(t,u,e.subarray(c,c+l));var X,P,j,k;if(Yi(t,u,1+(G<I)),u+=2,G<I){X=Ei(h,f,0),P=h,j=Ei(_,p,0),k=_;var q=Ei(z,C,0);Yi(t,u,T-257),Yi(t,u+5,A-1),Yi(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Yi(t,u+3*x,z[Hd[x]]);u+=3*L;var Q=[S,w];for(var Me=0;Me<2;++Me){var ue=Q[Me];for(var x=0;x<ue.length;++x){var Be=ue[x]&31;if(Yi(t,u,q[Be]),u+=z[Be],Be>15)Yi(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=iC,P=Er,j=sC,k=ca;for(var x=0;x<a;++x){var we=i[x];if(we>255){var Be=we>>18&31;if(oa(t,u,X[Be+257]),u+=P[Be+257],Be>7)Yi(t,u,we>>23&31),u+=ll[Be];var Z=we&31;if(oa(t,u,j[Z]),u+=k[Z],Z>3)oa(t,u,we>>5&8191),u+=ul[Z]}else oa(t,u,X[we]),u+=P[we]}return oa(t,u,X[256]),u+P[256]},lC=new jd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wv=new Dt(0),uC=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=lC[t-1],h=d>>13,f=d&8191,m=(1<<n)-1,_=s.p||new In(32768),p=s.h||new In(m+1),g=Math.ceil(n/3),S=2*g,T=function(Ye){return(e[Ye]^e[Ye+1]<<g^e[Ye+2]<<S)&m},y=new jd(25000),w=new In(288),A=new In(32),R=0,x=0,M=s.i||0,z=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||z>24576)&&(X>423||!l)){u=mv(e,c,0,y,w,A,x,z,L,M-L,u),z=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,k=0,q=f,Q=I-G&32767;if(X>2&&K==T(M-Q)){var Me=Math.min(h,X)-1,ue=Math.min(32767,M),Be=Math.min(258,X);while(Q<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-Q]){var we=0;for(;we<Be&&e[M+we]==e[M+we-Q];++we);if(we>j){if(j=we,k=Q,we>Me)break;var Z=Math.min(Q,we-2),re=0;for(var P=0;P<Z;++P){var se=M-Q+P&32767,xe=_[se],Ee=se-xe&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],Q+=I-G&32767}}if(k){y[z++]=268435456|$d[j]<<18|fv[k];var Ae=$d[j]&31,Et=fv[k]&31;x+=ll[Ae]+ul[Et],++w[257+Ae],++A[Et],C=M+j,++R}else y[z++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[z++]=e[M],++w[e[M]];if(u=mv(e,c,l,y,w,A,x,z,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var Ge=M+65535;if(Ge>=o)c[u/8|0]=l,Ge=o;u=Mv(c,u+1,e.subarray(M,Ge))}s.i=o}return Yd(a,0,i+qd(u)+r)},hC=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}(),dC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=hC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var fC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return uC(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)},Ev=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Av(e,t){return fC(e,t||{},0,0)}function Tv(e,t){return cC(e,{i:2},t&&t.out,t&&t.dictionary)}var Rv=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Ev(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],Rv(s,o,n,i)}},gv=typeof TextEncoder<"u"&&new TextEncoder,pC=typeof TextDecoder<"u"&&new TextDecoder,mC=0;try{pC.decode(wv,{stream:!0}),mC=1}catch(e){}function _v(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(gv)return gv.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return Yd(s,0,o)}var Xd=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)$n(9);t+=i+4}return t},xv=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,d=Xd(l);if(Qt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),f=h.getFullYear()-1980;if(f<0||f>119)$n(10);if(Qt(e,t,f<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,d),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,d)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},gC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Cv(e,t){if(!t)t={};var n={},i=[];Rv(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,d=_v(o),h=d.length,f=l.comment,m=f&&_v(f),_=m&&m.length,p=Xd(l.extra);if(h>65535)$n(11);var g=u?Av(c,l):c,S=g.length,T=dC();T.p(c),i.push(Ev(l,{size:c.length,crc:T.d(),c:g,f:d,m,u:h!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+h+p+S,s+=76+2*(h+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var d=i[R];xv(y,d.o,d,d.f,d.u,d.c.length);var x=30+d.f.length+Xd(d.extra);y.set(d.c,d.o+x),xv(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+x+(d.m?d.m.length:0)}return gC(y,r,i.length,A,w),y}var Ai=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function _C(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_SOLID_FAILED")return'PROFILE_SOLID_FAILED: extrudeProfile or revolveProfile could not build a solid from this outline. Reduce bevel or set it to 0. Keep the outline one simple closed loop: no self-intersections, repeated points or zero-length edges, and no neck narrower than twice the bevel. Holes must lie inside the outline and leave material. For revolveProfile, keep points off the axis (x = 0) unless the solid should close there. Keep coordinates at asset scale. Render that helper call alone with kiln_render and simplify the outline until it builds. Call kiln_discover with ids ["extrudeProfile", "revolveProfile"].';if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class la extends Error{diagnostic;constructor(e,t=_C(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var hl=1024,dl=4,fl=8,Kd=6,Pv=80,es=256;class rt extends la{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Iv=["solid","checker","stripes","gradient","bricks","noise"],Lv=["normal","multiply","screen","overlay"],xC=new Set(["__proto__","prototype","constructor"]);function pl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new rt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new rt(`${t} must not contain symbol keys.`);if(xC.has(i))throw new rt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new rt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new rt(`${t}.${i} must be a plain JSON data field.`)}return e}function yC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new rt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new rt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new rt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new rt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function Ar(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new rt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function ri(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new rt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Qr(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new rt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function Dv(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new rt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function Jd(e,t,n){return Dv(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function vC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Pv||n)throw new rt(`${t} must be 1..${Pv} visible characters.`);return e}function bC(e,t,n){if(e===void 0)return n;if(!Ai.includes(e))throw new rt(`${t} must be one of ${Ai.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function Nv(e,t){let i=(Dv(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function SC(e,t){let n=e.blend??"normal";if(!Lv.includes(n))throw new rt(`${t}.blend ${JSON.stringify(n)} is not one of ${Lv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function MC(e,t){let n=`proceduralTexture.layers[${t}]`,i=pl(e,n),r=i.op;if(!Iv.includes(r))throw new rt(`${n}.op ${JSON.stringify(r)} is not one of ${Iv.join(", ")}.`);let s=SC(i,n),o=Jd(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return Ar(i,["op","color","blend","opacity"],n),{op:r,color:ri(i.color,`${n}.color`),...a};case"checker":return Ar(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),squares:Qr(i.squares,`${n}.squares`,8,1,es),...a};case"stripes":return Ar(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),count:Qr(i.count,`${n}.count`,8,1,es),angleDeg:Nv(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return Ar(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:ri(i.from,`${n}.from`),to:ri(i.to,`${n}.to`),angleDeg:Nv(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return Ar(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:ri(i.brick,`${n}.brick`),mortar:ri(i.mortar,`${n}.mortar`),rows:Qr(i.rows,`${n}.rows`,8,1,es),cols:Qr(i.cols,`${n}.cols`,4,1,es),mortarWidth:Jd(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:Jd(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return Ar(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:ri(i.colorA,`${n}.colorA`),colorB:ri(i.colorB,`${n}.colorB`),scale:Qr(i.scale,`${n}.scale`,8,1,es),octaves:Qr(i.octaves,`${n}.octaves`,3,1,Kd),seed:Qr(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};default:throw new rt(`${n}.op is unsupported.`)}}function wC(e){let t=pl(e,"proceduralTexture");if(Ar(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new rt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function ua(e){let t=pl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?pl(wC(t),"proceduralTexture"):t;if(Ar(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new rt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<dl||i>hl||(i&i-1)!==0)throw new rt(`proceduralTexture.size must be a power of two between ${dl} and ${hl}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new rt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=yC(r,"proceduralTexture.layers");if(s.length>fl)throw new rt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${fl}.`);let o=vC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:bC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(MC)}}var EC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ti=(e,t)=>e>>>t|e<<32-t;function Ys(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Ti(T,7)^Ti(T,18)^T>>>3,A=Ti(y,17)^Ti(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,d,h,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Ti(f,6)^Ti(f,11)^Ti(f,25),y=f&m^~f&_,w=p+T+y+EC[S]+a[S]>>>0,A=Ti(l,2)^Ti(l,13)^Ti(l,22),R=l&u^l&d^u&d,x=A+R>>>0;p=_,_=m,m=f,f=h+w>>>0,h=d,d=u,u=l,l=w+x>>>0}let g=[l,u,d,h,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var Js="kiln.procedural-rgba.v3.1";var da=1024,AC=1048576,fa=64,gl=64,ha=256,_l=32,Ov=64000000,TC=67108864;function nt(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new rt(`proceduralTexture V3: ${e}`,t)}var RC=new Set(["__proto__","prototype","constructor"]);function CC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)nt(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)nt(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))nt(`${r} must be finite.`);return}if(typeof i!=="object")nt(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)nt(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))nt(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)nt(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||RC.has(d))nt(`${r} has a forbidden key.`);if(o&&d==="length")continue;let h=u[d];if(!h.enumerable||!("value"in h))nt(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))nt(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)nt(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!o)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function Wn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))nt(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))nt(`${n} has unknown field ${r}.`);return i}function fn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)nt(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Uv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")nt(`${t} must be boolean.`);return e}function ml(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)nt(`${n} must be a ${t}-element array.`);return e.map((s,o)=>fn(s,i,r,`${n}[${o}]`))}function Fv(e,t){let n=ml(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function zv(e,t,n){let i=Wn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:fn(i.x,-4096,4096,`${t}.x`),y:fn(i.y,-4096,4096,`${t}.y`),width:fn(i.width,1,2048,`${t}.width`),height:fn(i.height,1,2048,`${t}.height`)}}function PC(e,t){let n=Wn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...zv(n,t,n.kind)};if(n.kind==="polygon"){Wn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>gl)nt(`${t}.points requires 3..${gl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>ml(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return Wn(n,["kind","from","to","width"],t),{kind:"line",from:ml(n.from,2,`${t}.from`,-4096,4096),to:ml(n.to,2,`${t}.to`,-4096,4096),width:fn(n.width,1,2048,`${t}.width`)};return nt(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function kv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function IC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function LC(e,t,n,i=0,r=0){let[s,o,a,c]=kv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function xl(e){CC(e);let t=Wn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)nt("schemaVersion must be 3.");let n=fn(t.width,4,da,"width"),i=fn(t.height,4,da,"height"),r=n*i;if(r>AC)nt("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ai.includes(s))nt("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))nt("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>fa)nt(`operations must be an array with at most ${fa} entries.`);let l=r,u=0,d=0,h=c.map((p,g)=>{let S=`operations[${g}]`,T=Wn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){Wn(T,["op","spec","alpha","opacity"],S);let j=Wn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)nt(`${S}.spec requires explicit schemaVersion 2.`);let k=ua(j);if(k.size!==n||k.size!==i||k.usage!==s)nt(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);return l+=r*(1+k.layers.reduce((q,Q)=>q+(Q.op==="noise"?Q.octaves*16:4),0)),d+=r*4,{op:"legacy-v2",spec:k,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)}}let y=PC(T.shape,`${S}.shape`),w=IC(y),[A,R,x,M]=LC(y,n,i),z=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return Wn(T,["op","shape","alpha","invert"],S),l+=r+z*w,{op:"mask",shape:y,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),invert:Uv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return nt(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Fv(T.rgba,`${S}.rgba`),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return Wn(T,["op","shape","rgba","opacity"],S),l+=z*(w+1),{op:"paint",...C};Wn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S);let L=fn(T.count,1,ha,`${S}.count`),K=Uv(T.periodic,`${S}.periodic`),[I,G,X,P]=kv(y);if(K&&(X-I>n||P-G>i))nt(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>ha)nt(`expanded stamps budget exceeds ${ha}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:fn(T.seed,0,4294967295,`${S}.seed`),area:zv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)nt("palette and dither are supported only for color usages albedo and emissive.");let p=Wn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>_l)nt(`palette.colors requires 1..${_l} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")nt("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>fn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Ov)nt(`estimated work budget ${l} exceeds ${Ov}.`);if(r*4+d>TC)nt("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Fv(t.background,"background"),operations:h,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)nt("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function Qd(e){return xl(e).spec}function NC(e){return xl(e).canonicalJson}function ef(e){return`sha256:${Ys(`${Js}
-${NC(e)}`)}`}var tf=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],nf=["nearest","linear"],pa=["repeat","clamp-to-edge","mirrored-repeat"];function yl(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new rt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new rt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new rt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:tf,magFilter:nf,wrapS:pa,wrapT:pa};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new rt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new rt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Gv="kiln.texture-atlas.v1.1",Hv="kiln.texture-atlas.v1.2",vl=Object.freeze([Gv,Hv]),ts=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),Ji=Object.freeze({...ts,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),sf=Object.freeze([1024,2048]);function $v(e){return e.pack===void 0?Gv:Hv}function DC(e){return e.pack===void 0?ts:Ji}class Wv extends la{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function Ne(e){throw new Wv(e)}function of(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>ts.jsonBytes)Ne("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)Ne("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))Ne("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)Ne("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")Ne("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)Ne("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))Ne("JSON array budget exceeded.");let d=Reflect.ownKeys(o);if(d.length>1024||c&&d.length!==u+1)Ne("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let h of d){if(c&&h==="length")continue;if(typeof h!=="string"||["__proto__","prototype","constructor"].includes(h))Ne("forbidden JSON field.");if(h.length>4096)Ne("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(h)).length+1);let f=Object.getOwnPropertyDescriptor(o,h);if(!f.enumerable||!("value"in f))Ne("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=u))Ne("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function pn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))Ne(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))Ne(`${n} has an unknown field.`);return i}function Ln(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)Ne(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Tr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))Ne(`${t} must be an exact SHA-256 hash.`);return e}function Bv(e,t){let n=pn(e,["x","y","width","height"],t);return{x:Ln(n.x,0,4096,`${t}.x`),y:Ln(n.y,0,4096,`${t}.y`),width:Ln(n.width,1,4096,`${t}.width`),height:Ln(n.height,1,4096,`${t}.height`)}}function Ks(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function Zv(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)Ne("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)Ne("source crop/content dimensions must match; resampling is unsupported.")}function rf(e){return e.kind==="procedural"?`procedural:${ef(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var OC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Vv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function UC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(a)=>{let c=[];for(let l of r){if(!OC(l,a)){c.push(l);continue}if(a.x>l.x)c.push({x:l.x,y:l.y,width:a.x-l.x,height:l.height});if(a.x+a.width<l.x+l.width)c.push({x:a.x+a.width,y:l.y,width:l.x+l.width-a.x-a.width,height:l.height});if(a.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:a.y-l.y});if(a.y+a.height<l.y+l.height)c.push({x:l.x,y:a.y+a.height,width:l.width,height:l.y+l.height-a.y-a.height})}if(r=c.filter((l,u)=>!c.some((d,h)=>h!==u&&Vv(d,l)&&(!Vv(l,d)||h<u))),r.length>16384)Ne("pack: free-space bookkeeping budget exceeded.")};for(let a of n)s(a);let o=[...i].sort((a,c)=>c.width*c.height-a.width*a.height||(a.region.name<c.region.name?-1:a.region.name>c.region.name?1:0));for(let a of o){let c,l;for(let u of r){if(u.width<a.width||u.height<a.height)continue;let d=u.width-a.width,h=u.height-a.height,f=[Math.min(d,h),Math.max(d,h),u.y,u.x];if(!l||f[0]<l[0]||f[0]===l[0]&&(f[1]<l[1]||f[1]===l[1]&&(f[2]<l[2]||f[2]===l[2]&&f[3]<l[3])))c=u,l=f}if(!c)Ne(`pack: region ${a.region.name} (${a.width}x${a.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);a.region.content={x:c.x+a.region.gutter,y:c.y+a.region.gutter,width:a.region.content.width,height:a.region.content.height},s({x:c.x,y:c.y,width:a.width,height:a.height})}}function ma(e){of(e);let t=pn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)Ne("schemaVersion must be 1.");let n;if(t.pack!==void 0){let h=pn(t.pack,["edge","gutter","algorithm"],"pack");if(!sf.includes(h.edge))Ne("pack.edge must be 1024 or 2048.");if(h.algorithm!==void 0&&h.algorithm!=="maxrects")Ne("pack.algorithm must be 'maxrects'.");n={edge:h.edge,gutter:h.gutter===void 0?2:Ln(h.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?Ji:ts,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:Ln(t.width,4,r,"width"),o=n&&t.height===void 0?n.edge:Ln(t.height,4,r,"height");if(s*o>i.outputTexels)Ne("output texel budget exceeded.");if(!Ai.includes(t.usage))Ne("usage must be a texture usage.");let a=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)Ne(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((h,f)=>{let m=pn(h,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${f}]`);if(typeof m.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(m.name))Ne("region name must be a stable lowercase identifier.");let _=m.content!==void 0;if(!_&&!n)Ne(`region ${m.name}: content is required unless the atlas sets pack.`);if(m.packed!==void 0&&(m.packed!==!0||!n||!_))Ne("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let p=_?Bv(m.content,"content"):void 0,g=m.gutter===void 0?n?.gutter??2:Ln(m.gutter,0,32,"gutter"),S=m.edgeMode===void 0?"copy-edge":m.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(S))Ne("unsupported edgeMode.");if(S==="mask-rgb-dilate"&&a!=="albedo"&&a!=="emissive")Ne("mask RGB dilation requires color usage.");let T=pn(m.source,["kind","spec","resourceId","pin","expected"],"source"),y,w=m.crop===void 0?void 0:Bv(m.crop,"crop");if(T.kind==="procedural"){pn(T,["kind","spec"],"procedural source");let R=xl(T.spec);if(R.spec.usage!==a)Ne("source usage does not match atlas usage.");y={kind:"procedural",spec:R.spec},w??={x:0,y:0,width:R.spec.width,height:R.spec.height},p??={x:0,y:0,width:w.width,height:w.height},Zv(w,p,R.spec.width,R.spec.height)}else if(T.kind==="resource"){if(pn(T,["kind","resourceId","pin","expected"],"resource source"),typeof T.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(T.resourceId))Ne("source resourceId must be an exact returned map ID.");let R=pn(T.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof R.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(R.resourceId))Ne("pin resourceId must be a material ID.");let x=Tr(R.revisionId,"pin revisionId"),M=Tr(R.sha256,"pin sha256");if(x!==M)Ne("source pin revision/hash mismatch.");let z;if(T.expected!==void 0){let C=pn(T.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");z={...C.width===void 0?{}:{width:Ln(C.width,1,4096,"expected.width")},...C.height===void 0?{}:{height:Ln(C.height,1,4096,"expected.height")},...C.imageSha256===void 0?{}:{imageSha256:Tr(C.imageSha256,"expected.imageSha256")},...C.decodedPixelHash===void 0?{}:{decodedPixelHash:Tr(C.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:T.resourceId,pin:{resourceId:R.resourceId,revisionId:x,sha256:M},...z?{expected:z}:{}},!p){let C=w??(z?.width!==void 0&&z.height!==void 0?{width:z.width,height:z.height}:Ne(`region ${m.name}: a packed resource region needs a crop or expected width and height (its size).`));p={x:0,y:0,width:C.width,height:C.height}}if(w&&(w.width!==p.width||w.height!==p.height))Ne("source crop/content dimensions must match; resampling is unsupported.")}else Ne("source kind must be procedural or pinned resource.");let A={name:m.name,content:p,gutter:g,edgeMode:S,source:y,...w?{crop:w}:{},...n&&(!_||m.packed===!0)?{packed:!0}:{}};if(!_)c.push({region:A,width:A.content.width+2*g,height:A.content.height+2*g});return A}).sort((h,f)=>h.name<f.name?-1:h.name>f.name?1:0);if(new Set(l.map((h)=>h.name)).size!==l.length)Ne("duplicate region name.");if(c.length){let h=new Set(c.map((f)=>f.region));UC(s,o,l.filter((f)=>!h.has(f)).map((f)=>Ks(f)),c)}for(let h of l){let f=Ks(h);if(f.x<0||f.y<0||f.x+f.width>s||f.y+f.height>o)Ne("padded allocation is out of bounds.")}for(let h=0;h<l.length;h++)for(let f=h+1;f<l.length;f++){let m=Ks(l[h]),_=Ks(l[f]);if(m.x<_.x+_.width&&_.x<m.x+m.width&&m.y<_.y+_.height&&_.y<m.y+m.height)Ne(`padded allocations overlap: ${l[h].name}, ${l[f].name}.`)}if(new Set(l.map((h)=>rf(h.source))).size>i.sources)Ne(`distinct source budget exceeds ${i.sources}.`);let u;try{u=yl(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(h){Ne(`sampler: ${h.message}`)}let d={schemaVersion:1,width:s,height:o,usage:a,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>ts.jsonBytes)Ne("canonical JSON byte budget exceeded.");return d}function FC(e){let t=ma(e);return`sha256:${Ys(`${$v(t)}
-${JSON.stringify(t)}`)}`}function Ri(e){of(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function zC(e){return`sha256:${Ys(`kiln.atlas-layout.v1
-${Ri({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:Ks(t)}))})}`)}`}function af(e,t){of(e);let n=ma(t),i=pn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==$v(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")Ne("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ri(i.sampler)!==Ri(n.sampler)||i.specHash!==FC(n)||i.layoutHash!==zC(n))Ne("manifest sampler/spec/layout identity mismatch.");Tr(i.decodedPixelHash,"manifest decodedPixelHash"),Tr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[rf(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)Ne("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=pn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))Ne("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)Ne("manifest source identity mismatch.");let d=Ln(l.width,1,4096,"manifest source width"),h=Ln(l.height,1,4096,"manifest source height");if(Tr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(pn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||h!==u.spec.height||l.recipeHash!==ef(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")Ne("manifest procedural source identity mismatch.")}else{pn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=pn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==d||f.height!==h||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))Ne("manifest pinned resource descriptor mismatch.");if(Tr(f.imageSha256,"manifest source imageSha256"),Ln(f.encodedByteLength,1,DC(n).encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)Ne("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))Ne("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:h})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=pn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=rf(l.source),h=s.get(d),f=l.crop??{x:0,y:0,width:h.width,height:h.height};if(Zv(f,l.content,h.width,h.height),u.name!==l.name||u.sourceId!==d||Ri(u.content)!==Ri(l.content)||Ri(u.allocation)!==Ri(Ks(l))||Ri(u.crop)!==Ri(f))Ne("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${Ys(`kiln.atlas-manifest.v1
-${Ri(a)}`)}`)Ne("manifest hash mismatch.");return structuredClone(e)}var kC=(()=>{let e=et().int().min(0).max(16777215),t=et().int().min(1).max(es),n=et().min(-36000).max(36000),i=et().min(0).max(1),r={blend:wt(["normal","multiply","screen","overlay"]),opacity:i};return be({schemaVersion:Oe(2),size:et().int().min(dl).max(hl),usage:wt(Ai),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:e,...r}).strict(),be({op:Oe("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),be({op:Oe("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),be({op:Oe("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),be({op:Oe("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),be({op:Oe("noise"),colorA:e,colorB:e,scale:t,octaves:et().int().min(1).max(Kd),seed:et().int().min(-2147483648).max(2147483647),...r}).strict()])).min(1).max(fl)}).strict()})();function Xv(e,t=kC){let n=(q,Q)=>et().int().min(q).max(Q),i=n(0,255),r=n(-4096,4096),s=cv([r,r]),o=cv([i,i,i,i]),a=wt(Ai),c=KR(["sha256:",Xe().regex(/^[a-f0-9]{64}$/)]),l=Xe().min(1).max(80),u=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=Xe().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),h={width:n(1,4096),height:n(1,4096)},f=be({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=be({x:n(0,4096),y:n(0,4096),...h}).strict(),_=ni("kind",[f.extend({kind:Oe("rectangle")}).strict(),f.extend({kind:Oe("ellipse")}).strict(),be({kind:Oe("polygon"),points:_t(s).min(3).max(gl)}).strict(),be({kind:Oe("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=be({op:Oe("paint"),shape:_,rgba:o,opacity:i}).strict(),g=be({op:Oe("mask"),shape:_,alpha:i,invert:Kr()}).strict(),S=be({op:Oe("stamps"),shape:_,rgba:o,opacity:i,count:n(1,ha),seed:n(0,4294967295),area:f,periodic:Kr()}).strict(),T=be({op:Oe("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=be({colors:_t(n(0,16777215)).min(1).max(_l),dither:wt(["none","bayer4"])}).strict(),w={schemaVersion:Oe(3),width:n(4,da),height:n(4,da),usage:a,name:l.optional(),background:o},A=be({...w,operations:_t(ni("op",[p,g,S,T.extend({spec:t})])).max(fa),palette:y.optional()}).strict(),R=be({...w,usage:a.optional(),background:o.optional(),operations:_t(ni("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(fa),palette:y.partial({dither:!0}).optional()}).strict(),x=be({minFilter:wt(tf),magFilter:wt(nf),wrapS:wt(pa),wrapT:wt(pa)}).strict(),M=be({resourceId:u,revisionId:c,sha256:c}).strict(),z=be({kind:Oe("resource"),resourceId:d,pin:M,expected:be({...h,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=be({name:u,content:m,gutter:n(0,32),edgeMode:wt(["copy-edge","mask-rgb-dilate"]),source:ni("kind",[be({kind:Oe("procedural"),spec:A}).strict(),z]),crop:m.optional(),packed:Oe(!0).optional()}).strict(),L={schemaVersion:Oe(1),width:n(4,Ji.edge),height:n(4,Ji.edge),usage:a,sampler:x},K=qs(sf.map((q)=>Oe(q))),I=be({...L,regions:_t(C).min(1).max(Ji.regions),pack:be({edge:K,gutter:n(0,32),algorithm:Oe("maxrects")}).strict().optional()}).strict(),G=be({...L,width:L.width.optional(),height:L.height.optional(),pack:be({edge:K,gutter:n(0,32).optional(),algorithm:Oe("maxrects").optional()}).strict().optional(),sampler:x.optional(),regions:_t(C.extend({source:ni("kind",[be({kind:Oe("procedural"),spec:R}).strict(),z])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(Ji.regions)}).strict(),X=be({materialId:u,revisionId:c,resourceId:d,slot:wt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:wt(["srgb","linear"]),...h,encodedByteLength:n(1,ts.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:Xe().min(1).max(1024),...h,decodedPixelHash:c},j=ni("kind",[be({...P,kind:Oe("procedural"),recipeHash:c,compilerId:Oe(Js)}).strict(),be({...P,kind:Oe("resource"),descriptor:X}).strict()]),k=be({version:Oe("kiln.atlas-manifest.v1"),compilerId:wt(vl),width:L.width,height:L.height,usage:a,origin:Oe("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:_t(j).min(1).max(Ji.sources),regions:_t(be({name:u,content:m,allocation:m,crop:m,sourceId:Xe().min(1).max(1024)}).strict()).min(1).max(Ji.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:G,canonicalTextureAtlasSpecV1Schema:I,textureAtlasManifestV1Schema:k,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:X}}var an=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),qv=["baseColor","normal","metallicRoughness","emissive","occlusion"],Yv={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var eo=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),Pi=Xe().regex(/^sha256:[a-f0-9]{64}$/),Ci=Xe().min(1).max(1000),jv=Xe().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),Jv=be({id:eo,kind:wt(["external","procedural"]),provider:Ci,creator:Ci,assetId:Ci.optional(),assetUrl:jv.optional(),accessedAt:Xe().datetime().optional(),license:be({spdx:Ci,url:jv,attribution:Xe().max(4000)}).strict(),originalFiles:_t(be({name:Xe().min(1).max(200),sha256:Pi,bytes:et().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),Kv=be({operation:Ci,tool:Ci,version:Ci,parameters:cl(Xe().max(100),qs([Xe().max(2000),et().finite(),Kr()])).optional()}).strict(),si=et().int().min(0).max(16777215),ga=et().int().min(1).max(256),Qs={blend:wt(["normal","multiply","screen","overlay"]).default("normal"),opacity:et().min(0).max(1).default(1)},ya=be({schemaVersion:Oe(2),size:et().int().min(4).max(1024).default(256),usage:wt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:Xe().min(1).max(80).optional(),layers:_t(ni("op",[be({op:Oe("solid"),color:si,...Qs}).strict(),be({op:Oe("checker"),colorA:si,colorB:si,squares:ga.default(8),...Qs}).strict(),be({op:Oe("stripes"),colorA:si,colorB:si,count:ga.default(8),angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("gradient"),from:si,to:si,angleDeg:et().min(-36000).max(36000).default(0),...Qs}).strict(),be({op:Oe("bricks"),brick:si,mortar:si,rows:ga.default(8),cols:ga.default(4),mortarWidth:et().min(0).max(1).default(0.06),stagger:et().min(0).max(1).default(0.5),...Qs}).strict(),be({op:Oe("noise"),colorA:si,colorB:si,scale:ga.default(8),octaves:et().int().min(1).max(6).default(3),seed:et().int().min(-2147483648).max(2147483647).default(0),...Qs}).strict()])).min(1).max(8)}).strict(),uf=be({kind:Oe("normal-from-height"),strength:et().finite().positive().max(64)}).strict(),BC=be({compiler:Oe("kiln.procedural-texture.v2"),spec:ya,derive:uf.optional(),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict(),Qv=be({baseColor:et().int().min(0).max(16777215).optional(),roughness:et().min(0).max(1).default(1),metalness:et().min(0).max(1).default(0),emissive:et().int().min(0).max(16777215).optional(),emissiveIntensity:et().min(0).max(64).default(1),alphaMode:wt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:et().min(0).max(1).default(0.5),doubleSided:Kr().default(!1)}).strict(),_a=be({schemaVersion:Oe(1),materialId:eo,revisionId:Pi,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Qv,sources:_t(Jv).min(1).max(20),maps:_t(be({slot:wt(qv),file:wt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:Pi,bytes:et().int().positive().max(an.maxMapBytes),width:et().int().positive().max(an.maxMapEdge),height:et().int().positive().max(an.maxMapEdge),usage:wt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:wt(["srgb","linear"]),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),sourceId:eo,originalFile:Xe().min(1).max(200).optional(),transforms:_t(Kv).max(30),procedural:BC.optional()}).strict()).min(1).max(5)}).strict(),cf=be({materialId:eo,name:Xe().min(1).max(200),tags:_t(Xe().min(1).max(80)).max(30).optional(),tileable:Kr(),physicalSizeMeters:be({width:et().finite().positive().max(1e5),height:et().finite().positive().max(1e5)}).strict().optional(),parameters:Qv.partial().optional(),sources:_t(Jv).min(1).max(20),maps:_t(be({slot:wt(qv),sourceId:eo,transforms:_t(Kv).max(30),normalConvention:Oe("opengl").optional(),channelPacking:Oe("r-occlusion-g-roughness-b-metallic").optional(),procedural:ya,derive:uf.optional()}).strict()).min(1).max(5)}).strict(),lf=be({schemaVersion:Oe(1),records:_t(be({manifest:_a,files:cl(Xe().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),Xe().max(Math.ceil(an.maxMapBytes/3)*4))}).strict()).max(an.maxPayloadRecords)}).strict();function io(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");io(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Nn(e){io(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function VC(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=_a.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==Yv[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Nn(r.procedural.spec)!==Nn(ua(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind!=="external"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var to=Xv(ya),no={when:(e)=>!e.issues.length},eb=(e)=>e instanceof Error?e.message:String(e);function xa(e,t,n){return(i,r)=>{try{let s=t(i);if(n&&Nn(i)!==Nn(s))r.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(s){r.addIssue({code:"custom",message:eb(s)})}}}var tb=to.portableSamplerSchema.superRefine(xa("sampler",yl,!0),no),GC=to.canonicalProceduralTextureSpecV3Schema.superRefine(xa("procedural V3 spec",Qd,!0),no),HC=to.canonicalTextureAtlasSpecV1Schema.superRefine(xa("atlas spec",ma,!0),no),$C=to.textureAtlasManifestV1Schema,WC=be({resourceId:eo,revisionId:Pi,sha256:Pi}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),ZC=ni("kind",[be({kind:Oe("procedural"),compilerId:wt(["kiln.procedural-texture.v2",Js]),spec:qs([ya,GC]),recipeHash:Pi,pixelHash:Pi,encoder:be({name:Oe("sharp"),version:Ci}).strict(),derive:uf.optional()}).strict(),be({kind:Oe("atlas"),compilerId:wt(vl),spec:HC,manifest:$C,encoder:be({name:Oe("sharp"),version:Ci}).strict()}).strict().superRefine((e,t)=>{try{if(af(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${eb(n)}`})}},no)]),nb=_a.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Oe(2),dependencies:_t(WC).max(16),maps:_t(_a.shape.maps.element.omit({procedural:!0}).extend({sampler:tb,pixelHash:Pi,recipe:ZC.optional()}).strict()).min(1).max(5)}).strict(),XC=ni("schemaVersion",[_a,nb]),jC=lf.extend({schemaVersion:Oe(2),records:_t(lf.shape.records.element.extend({manifest:XC}).strict()).max(an.maxPayloadRecords)}).strict(),ib=ni("schemaVersion",[lf,jC]);function rb(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var qC=cf.extend({schemaVersion:Oe(2),maps:_t(cf.shape.maps.element.omit({procedural:!0}).extend({sampler:tb,procedural:qs([ya,to.proceduralTextureSpecV3Schema.superRefine(xa("procedural V3 spec",Qd,!1),no)]).optional(),atlas:to.textureAtlasSpecV1Schema.superRefine(xa("atlas spec",ma,!1),no).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),LO=qs([cf,qC]);function hf(e){if(io(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return VC(e);let t=nb.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==Yv[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==Js||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||Nn(l)!==Nn(ua(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(af(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||Nn(c.spec.sampler)!==Nn(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind!=="external"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error("External material source original file missing");n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var bl=67108864,df=Xe().regex(/^[a-z][a-z0-9_-]{0,79}$/),YC=Xe().regex(/^sha256:[a-f0-9]{64}$/),ff=be({version:Oe("kiln.asset.v1"),assetId:df,revisionId:df,parentRevision:df.optional(),name:Xe().min(1).max(200),tags:_t(Xe().max(80)).max(30),createdAt:Xe().datetime(),description:Xe().max(4000).optional(),brief:Xe().max(8000).optional(),attribution:be({model:Xe().max(200).optional(),harness:Xe().max(200).optional(),author:Xe().max(200).optional()}).optional(),editable:Kr(),files:cl(Xe(),be({sha256:YC,bytes:et().int().nonnegative().max(bl)})),build:be({engine:Xe(),options:cl(Xe(),Jr()),warnings:_t(Xe()),integration:Jr().optional(),qa:Jr().optional(),dependencies:_t(Jr()).optional(),rebuild:wt(["engine-required","external-dependencies-required"])}).optional(),preview:be({fidelity:Jr().optional(),error:Xe().optional(),backdrop:wt(hv).optional()}).optional()}),JC="materials.kiln.json",KC=25165824;function QC(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=hf(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&Nn(o)!==Nn(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>an.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function sb(e,t=!1){let n=QC(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Nn(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}io(e.materialResources);let r=ib.parse(e.materialResources),s=0,o=0,a=new Map;for(let d of r.records){let h=hf(d.manifest),f=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==Nn(h))throw Error("Asset material closure mismatch");if(a.set(f,h),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of d.manifest.maps){if(d.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>an.maxPayloadBytes||o>an.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let h=a.get(d);if(!h)throw Error("Asset material closure incomplete");l.add(d);for(let f of rb(h))u(`${f.resourceId}/${f.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var eP=new Set(["asset.glb","source.kiln.js","preview.png"]);function tP(e){let t=ff.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(!eP.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>bl||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");pf(e.files["asset.glb"]),sb(e)}function pf(e){if(e.length<20||e.length>bl)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 ob(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){tP(i),sb(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>KC)throw Error("Asset material payload exceeds byte limit");t[r+JC]=s}}for(let i of Object.values(t))n+=i.length;if(n>bl)throw Error("Bundle exceeds 64 MiB");return Cv(t,{level:0})}function Ii(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function ab(e){pf(e);let t=new Do,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Os(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new Bh(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Ii(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function cb(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,d=-1/0,h=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),d=Math.max(d,y),h=Math.min(h,w),f=Math.max(f,w)}r.addScaledVector(a,(u+d)/2),r.addScaledVector(c,(h+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function mf(e,t){return{position:e.position.clone(),target:t.clone()}}function gf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new U))+r*20,10),e.updateProjectionMatrix()}function lb(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function ub(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function hb(e,t,n){if(t())return e;n(e);return}function Sl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function Ml(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Gt().setFromObject(e,!0):n}function va(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function db(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let h=[l];for(let m of u)h.push(await e.parser.getDependency("node",m));Sl(e,h.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:h})}if(r.length===0)return;let s=va(e.scene)-r.reduce((c,l)=>c+_f(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,d)=>u+_f(d,l),0));return{chains:r,triangles:a}}var fb=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function _f(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return va(fb(e,t))}function pb(e,t){let n=fb(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function mb(e,t){for(let n of e.chains)pb(n,t)}function gb(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return pb(i,n),!0}function _b(e,t){if(!e)return;return{triangles:va(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>_f(n,r))}))}}function ro(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function xb(e){let t=new Rh({antialias:!0,alpha:!1});t.setPixelRatio(Math.min(devicePixelRatio,2)),t.setClearColor(1382930),t.toneMapping=yo,t.toneMappingExposure=1.15,e.replaceChildren(t.domElement);let n=new Is,i=new Vt(40,1,0.01,1000),r=new Ih(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let h=new Go(t),f=new Lh,m=h.fromScene(f,0.04);n.environment=m.texture,f.dispose(),h.dispose();let _=new zs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new Mc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,z,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),k=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:ub(C.samples),...z===void 0?{}:{loadToFirstFrameMs:z},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...k?{unmaskedVendor:String(j.getParameter(k.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.getParameter(k.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let P=Ml(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof Mt||ue instanceof pr||ue instanceof Ds){let Be=new Gt().setFromObject(ue,!0);if(!Be.isEmpty())j.push(Be)}});let{center:k,radius:q,distance:Q,position:Me}=cb(P,i.aspect,i.fov,j);if(r.target.copy(k),i.position.copy(Me),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let k=lb(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(k),r.target.add(k)}if(r.update(),t.render(n,i),M!==void 0)z=performance.now()-M,M=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let k=K(P);clearTimeout(C.timeout),C.resolve(k),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let k=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let Q=await ab(P);Sl(Q,[Q.scene]);let Me=await db(Q);try{Q.assertTexturesLoaded()}catch(xe){Ii(Q.scene);for(let Ee of ro(Me))Ii(Ee);throw xe}let ue=hb(Q,()=>!x&&q===R&&j.isCurrent?.()!==!1,(xe)=>{Ii(xe.scene);for(let Ee of ro(Me))Ii(Ee)});if(!ue)return;let Be=p&&j.preserveView?mf(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Ii(p);for(let xe of ro(g))Ii(xe)}p=ue.scene,g=Me,M=k,z=void 0,n.add(p),T=ue.animations,S=new Tc(p),y=!0;let{clientWidth:we,clientHeight:Z}=e;if(t.setSize(we,Z),i.aspect=we&&Z?we/Z:i.aspect,I(),Be)gf(i,r.target,Be,Ml(p)),r.update();let re=0,se=new Set;return p.traverseVisible((xe)=>{let Ee=xe;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:va(p),meshes:re,materials:se.size,clips:T.map((xe)=>xe.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)mb(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)gb(g,P,j)},lod(){return p?_b(g,p):void 0},reset:I,cancelMeasurement:L,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((j,k)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:k,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return mf(i,r.target)},setView(P){if(!p)return;gf(i,r.target,P,Ml(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let j of p?[p,...ro(g)]:[])j.traverse((k)=>{let q=k;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),p)Ii(p);for(let P of ro(g))Ii(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var yb=["127.0.0.1","localhost","[::1]"];async function vb(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let d=new URL(s);if(d.protocol!=="https:"&&!(d.protocol==="http:"&&yb.includes(d.hostname)))throw Error("Invalid host download URL");return{downloadUrl:d.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var Sb=16777216,Mb=Math.ceil(Sb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function nP(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function bb(e){if(typeof e!=="string"||e.length>Mb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(nP(n)!==e)Yt("contains noncanonical base64 data");return n}function ba(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function wb(e){if(!ba(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=ff.safeParse(e.manifest);if(!t.success||!ba(e.files))return Yt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Yt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Yt("file metadata is missing");if(r+=n.files[c].bytes,r>Sb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:ba(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>Mb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],d;if(typeof l==="string")d=bb(l);else{if(!ba(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=bb(l.data);try{d=Tv(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(d.length!==u.bytes)return Yt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(d));if(`sha256:${Array.from(new Uint8Array(h),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=d}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!ba(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Eb(e){let t=e.attribution;if(!t)return[];return[t.model?{label:"Model",value:t.model}:null,t.harness?{label:"Harness",value:t.harness}:null,t.author?{label:"Author",value:t.author}:null].filter((n)=>n!==null)}var Dn=(e)=>document.getElementById(e),Li=Dn("status"),cn,Tb={},ns,iP=0,Ni=0,wl=new Map;function Rb(e,t){let n=++iP;return new Promise((i,r)=>{let s=setTimeout(()=>{wl.delete(n),r(Error("Chat host did not respond."))},20000);wl.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 Ab(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function rP(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 sP(e){let t=++Ni;cn=void 0,Dn("stats").textContent="",Dn("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await oP(e,t)}catch(n){if(t!==Ni)return;Li.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function oP(e,t){if(e.isError){Li.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await wb(e._meta?.kilnAsset)}catch(i){if(t!==Ni)return;Li.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Ni)return;cn=n.record,Dn("name").textContent=cn.manifest.name,Tb=n.downloadUrls,Dn("revision").textContent=`${cn.manifest.editable?"Editable source included":"GLB asset"} · ${cn.manifest.revisionId.slice(0,10)}`,Dn("attribution").textContent=Eb(cn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{ns??=xb(Dn("stage"));let i=await ns.load(cn.files["asset.glb"]);if(t!==Ni)return;if(i){Dn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(cn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=Dn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Li.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Ni)return;ns?.dispose(),ns=void 0;let r=cn.files["preview.png"];if(r){let s=new Image;s.alt=`${cn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${rP(r)}`,Dn("stage").replaceChildren(s)}Li.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;Dn("source").hidden=!cn.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=wl.get(t.id);if(wl.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")sP(t.params);if(t.method==="ui/resource-teardown")ns?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});Dn("reset").onclick=()=>ns?.reset();Dn("clips").onchange=(e)=>ns?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!cn)return;let t=Ni,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?ob([cn]):cn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=cn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Li.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await vb(r,`${o}-${i}`,s,Rb,a,Tb[i]);if(t!==Ni)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},Li.replaceChildren("Download ready. ",l)}else Li.textContent="Download requested."}catch(a){if(t===Ni)Li.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!cn||t!==Ni}};Rb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Ab("ui/notifications/initialized"),Ab("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Li.textContent=e.message});
+*/var Dt=Uint8Array,Nn=Uint16Array,nf=Int32Array,_l=new Dt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xl=new Dt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jd=new Dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Tv=function(e,t){var n=new Nn(31);for(var i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new nf(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}},Rv=Tv(_l,2),{b:Cv,r:Kd}=Rv;Cv[28]=258,Kd[258]=28;var Pv=Tv(xl,0),{b:pC,r:bv}=Pv,Qd=new Nn(32768);for(et=0;et<32768;++et)Ai=(et&43690)>>1|(et&21845)<<1,Ai=(Ai&52428)>>2|(Ai&13107)<<2,Ai=(Ai&61680)>>4|(Ai&3855)<<4,Qd[et]=((Ai&65280)>>8|(Ai&255)<<8)>>1;var Ai,et,Ti=function(e,t,n){var i=e.length,r=0,s=new Nn(t);for(;r<i;++r)if(e[r])++s[e[r]-1];var o=new Nn(t);for(r=1;r<t;++r)o[r]=o[r-1]+s[r-1]<<1;var a;if(n){a=new Nn(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r]){var l=r<<4|e[r],u=t-e[r],d=o[e[r]-1]++<<u;for(var h=d|(1<<u)-1;d<=h;++d)a[Qd[d]>>c]=l}}else{a=new Nn(i);for(r=0;r<i;++r)if(e[r])a[r]=Qd[o[e[r]-1]++]>>15-e[r]}return a},Ir=new Dt(288);for(et=0;et<144;++et)Ir[et]=8;var et;for(et=144;et<256;++et)Ir[et]=9;var et;for(et=256;et<280;++et)Ir[et]=7;var et;for(et=280;et<288;++et)Ir[et]=8;var et,pa=new Dt(32);for(et=0;et<32;++et)pa[et]=5;var et,mC=Ti(Ir,9,0),gC=Ti(Ir,9,1),_C=Ti(pa,5,0),xC=Ti(pa,5,1),jd=function(e){var t=e[0];for(var n=1;n<e.length;++n)if(e[n]>t)t=e[n];return t},ai=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(t&7)&n},qd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},rf=function(e){return(e+7)/8|0},sf=function(e,t,n){if(t==null||t<0)t=0;if(n==null||n>e.length)n=e.length;return new Dt(e.subarray(t,n))};var yC=["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"],jn=function(e,t,n){var i=Error(t||yC[e]);if(i.code=e,Error.captureStackTrace)Error.captureStackTrace(i,jn);if(!n)throw i;return i},vC=function(e,t,n,i){var r=e.length,s=i?i.length:0;if(!r||t.f&&!t.l)return n||new Dt(0);var o=!n,a=o||t.i!=2,c=t.i;if(o)n=new Dt(r*3);var l=function(Ae){var Et=n.length;if(Ae>Et){var He=new Dt(Math.max(Et*2,Ae));He.set(n),n=He}},u=t.f||0,d=t.p||0,h=t.b||0,{l:f,d:m,m:_,n:p}=t,g=r*8;do{if(!f){u=ai(e,d,1);var S=ai(e,d+1,3);if(d+=3,!S){var T=rf(d)+4,y=e[T-4]|e[T-3]<<8,w=T+y;if(w>r){if(c)jn(0);break}if(a)l(h+y);n.set(e.subarray(T,w),h),t.b=h+=y,t.p=d=w*8,t.f=u;continue}else if(S==1)f=gC,m=xC,_=9,p=5;else if(S==2){var A=ai(e,d,31)+257,R=ai(e,d+10,15)+4,x=A+ai(e,d+5,31)+1;d+=14;var M=new Dt(x),k=new Dt(19);for(var C=0;C<R;++C)k[Jd[C]]=ai(e,d+C*3,7);d+=R*3;var L=jd(k),K=(1<<L)-1,I=Ti(k,L,1);for(var C=0;C<x;){var G=I[ai(e,d,K)];d+=G&15;var T=G>>4;if(T<16)M[C++]=T;else{var X=0,P=0;if(T==16)P=3+ai(e,d,3),d+=2,X=M[C-1];else if(T==17)P=3+ai(e,d,7),d+=3;else if(T==18)P=11+ai(e,d,127),d+=7;while(P--)M[C++]=X}}var j=M.subarray(0,A),z=M.subarray(A);_=jd(j),p=jd(z),f=Ti(j,_,1),m=Ti(z,p,1)}else jn(1);if(d>g){if(c)jn(0);break}}if(a)l(h+131072);var q=(1<<_)-1,Q=(1<<p)-1,Me=d;for(;;Me=d){var X=f[qd(e,d)&q],ue=X>>4;if(d+=X&15,d>g){if(c)jn(0);break}if(!X)jn(2);if(ue<256)n[h++]=ue;else if(ue==256){Me=d,f=null;break}else{var Ve=ue-254;if(ue>264){var C=ue-257,we=_l[C];Ve=ai(e,d,(1<<we)-1)+Cv[C],d+=we}var Z=m[qd(e,d)&Q],re=Z>>4;if(!Z)jn(3);d+=Z&15;var z=pC[re];if(re>3){var we=xl[re];z+=qd(e,d)&(1<<we)-1,d+=we}if(d>g){if(c)jn(0);break}if(a)l(h+131072);var se=h+Ve;if(h<z){var ye=s-z,Ee=Math.min(z,se);if(ye+h<0)jn(3);for(;h<Ee;++h)n[h]=i[ye+h]}for(;h<se;++h)n[h]=n[h-z]}}if(t.l=f,t.p=Me,t.b=h,t.f=u,f)u=1,t.m=_,t.d=m,t.n=p}while(!u);return h!=n.length&&o?sf(n,0,h):n.subarray(0,h)},Ji=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},da=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},Yd=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:Lv,l:0};if(r==1){var o=new Dt(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(w,A){return w.f-A.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;n[0]={s:-1,f:a.f+c.f,l:a,r:c};while(u!=r-1)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(var i=1;i<r;++i)if(s[i].s>h)h=s[i].s;var f=new Nn(h+1),m=ef(n[u-1],f,0);if(m>t){var i=0,_=0,p=m-t,g=1<<p;s.sort(function(A,R){return f[R.s]-f[A.s]||A.f-R.f});for(;i<r;++i){var S=s[i].s;if(f[S]>t)_+=g-(1<<m-f[S]),f[S]=t;else break}_>>=p;while(_>0){var T=s[i].s;if(f[T]<t)_-=1<<t-f[T]++-1;else++i}for(;i>=0&&_;--i){var y=s[i].s;if(f[y]==t)--f[y],++_}m=t}return{t:new Dt(f),l:m}},ef=function(e,t,n){return e.s==-1?Math.max(ef(e.l,t,n+1),ef(e.r,t,n+1)):t[e.s]=n},Sv=function(e){var t=e.length;while(t&&!e[--t]);var n=new Nn(++t),i=0,r=e[0],s=1,o=function(c){n[i++]=c};for(var a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);if(s>2)o(s>10?s-11<<5|28690:s-3<<5|12305),s=0}else if(s>3){o(r),--s;for(;s>6;s-=6)o(8304);if(s>2)o(s-3<<5|8208),s=0}while(s--)o(r);s=1,r=e[a]}return{c:n.subarray(0,i),n:t}},fa=function(e,t){var n=0;for(var i=0;i<t.length;++i)n+=e[i]*t[i];return n},Iv=function(e,t,n){var i=n.length,r=rf(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},Mv=function(e,t,n,i,r,s,o,a,c,l,u){Ji(t,u++,n),++r[256];var d=Yd(r,15),{t:h,l:f}=d,m=Yd(s,15),{t:_,l:p}=m,g=Sv(h),{c:S,n:T}=g,y=Sv(_),{c:w,n:A}=y,R=new Nn(19);for(var x=0;x<S.length;++x)++R[S[x]&31];for(var x=0;x<w.length;++x)++R[w[x]&31];var M=Yd(R,7),{t:k,l:C}=M,L=19;for(;L>4&&!k[Jd[L-1]];--L);var K=l+5<<3,I=fa(r,Ir)+fa(s,pa)+o,G=fa(r,h)+fa(s,_)+o+14+3*L+fa(R,k)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&K<=I&&K<=G)return Iv(t,u,e.subarray(c,c+l));var X,P,j,z;if(Ji(t,u,1+(G<I)),u+=2,G<I){X=Ti(h,f,0),P=h,j=Ti(_,p,0),z=_;var q=Ti(k,C,0);Ji(t,u,T-257),Ji(t,u+5,A-1),Ji(t,u+10,L-4),u+=14;for(var x=0;x<L;++x)Ji(t,u+3*x,k[Jd[x]]);u+=3*L;var Q=[S,w];for(var Me=0;Me<2;++Me){var ue=Q[Me];for(var x=0;x<ue.length;++x){var Ve=ue[x]&31;if(Ji(t,u,q[Ve]),u+=k[Ve],Ve>15)Ji(t,u,ue[x]>>5&127),u+=ue[x]>>12}}}else X=mC,P=Ir,j=_C,z=pa;for(var x=0;x<a;++x){var we=i[x];if(we>255){var Ve=we>>18&31;if(da(t,u,X[Ve+257]),u+=P[Ve+257],Ve>7)Ji(t,u,we>>23&31),u+=_l[Ve];var Z=we&31;if(da(t,u,j[Z]),u+=z[Z],Z>3)da(t,u,we>>5&8191),u+=xl[Z]}else da(t,u,X[we]),u+=P[we]}return da(t,u,X[256]),u+P[256]},bC=new nf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Lv=new Dt(0),SC=function(e,t,n,i,r,s){var o=s.z||e.length,a=new Dt(i+o+5*(1+Math.ceil(o/7000))+r),c=a.subarray(i,a.length-r),l=s.l,u=(s.r||0)&7;if(t){if(u)c[0]=s.r>>3;var d=bC[t-1],h=d>>13,f=d&8191,m=(1<<n)-1,_=s.p||new Nn(32768),p=s.h||new Nn(m+1),g=Math.ceil(n/3),S=2*g,T=function(Je){return(e[Je]^e[Je+1]<<g^e[Je+2]<<S)&m},y=new nf(25000),w=new Nn(288),A=new Nn(32),R=0,x=0,M=s.i||0,k=0,C=s.w||0,L=0;for(;M+2<o;++M){var K=T(M),I=M&32767,G=p[K];if(_[I]=G,p[K]=I,C<=M){var X=o-M;if((R>7000||k>24576)&&(X>423||!l)){u=Mv(e,c,0,y,w,A,x,k,L,M-L,u),k=R=x=0,L=M;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)A[P]=0}var j=2,z=0,q=f,Q=I-G&32767;if(X>2&&K==T(M-Q)){var Me=Math.min(h,X)-1,ue=Math.min(32767,M),Ve=Math.min(258,X);while(Q<=ue&&--q&&I!=G){if(e[M+j]==e[M+j-Q]){var we=0;for(;we<Ve&&e[M+we]==e[M+we-Q];++we);if(we>j){if(j=we,z=Q,we>Me)break;var Z=Math.min(Q,we-2),re=0;for(var P=0;P<Z;++P){var se=M-Q+P&32767,ye=_[se],Ee=se-ye&32767;if(Ee>re)re=Ee,G=se}}}I=G,G=_[I],Q+=I-G&32767}}if(z){y[k++]=268435456|Kd[j]<<18|bv[z];var Ae=Kd[j]&31,Et=bv[z]&31;x+=_l[Ae]+xl[Et],++w[257+Ae],++A[Et],C=M+j,++R}else y[k++]=e[M],++w[e[M]]}}for(M=Math.max(M,C);M<o;++M)y[k++]=e[M],++w[e[M]];if(u=Mv(e,c,l,y,w,A,x,k,L,M-L,u),!l)s.r=u&7|c[u/8|0]<<3,u-=7,s.h=p,s.p=_,s.i=M,s.w=C}else{for(var M=s.w||0;M<o+l;M+=65535){var He=M+65535;if(He>=o)c[u/8|0]=l,He=o;u=Iv(c,u+1,e.subarray(M,He))}s.i=o}return sf(a,0,i+rf(u)+r)},MC=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}(),wC=function(){var e=-1;return{p:function(t){var n=e;for(var i=0;i<t.length;++i)n=MC[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}};var EC=function(e,t,n,i,r){if(!r){if(r={l:1},t.dictionary){var s=t.dictionary.subarray(-32768),o=new Dt(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}}return SC(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)},Nv=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n};var Qt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Dv(e,t){return EC(e,t||{},0,0)}function Ov(e,t){return vC(e,{i:2},t&&t.out,t&&t.dictionary)}var Uv=function(e,t,n,i){for(var r in e){var s=e[r],o=t+r,a=i;if(Array.isArray(s))a=Nv(i,s[1]),s=s[0];if(s instanceof Dt)n[o]=[s,a];else n[o+="/"]=[new Dt(0),a],Uv(s,o,n,i)}},wv=typeof TextEncoder<"u"&&new TextEncoder,AC=typeof TextDecoder<"u"&&new TextDecoder,TC=0;try{AC.decode(Lv,{stream:!0}),TC=1}catch(e){}function Ev(e,t){if(t){var n=new Dt(e.length);for(var i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(wv)return wv.encode(e);var r=e.length,s=new Dt(e.length+(e.length>>1)),o=0,a=function(u){s[o++]=u};for(var i=0;i<r;++i){if(o+5>s.length){var c=new Dt(o+8+(r-i<<1));c.set(s),s=c}var l=e.charCodeAt(i);if(l<128||t)a(l);else if(l<2048)a(192|l>>6),a(128|l&63);else if(l>55295&&l<57344)l=65536+(l&1047552)|e.charCodeAt(++i)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63);else a(224|l>>12),a(128|l>>6&63),a(128|l&63)}return sf(s,0,o)}var tf=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;if(i>65535)jn(9);t+=i+4}return t},Av=function(e,t,n,i,r,s,o,a){var c=i.length,l=n.extra,u=a&&a.length,d=tf(l);if(Qt(e,t,o!=null?33639248:67324752),t+=4,o!=null)e[t++]=20,e[t++]=n.os;e[t]=20,t+=2,e[t++]=n.flag<<1|(s<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),f=h.getFullYear()-1980;if(f<0||f>119)jn(10);if(Qt(e,t,f<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,s!=-1)Qt(e,t,n.crc),Qt(e,t+4,s<0?-s-2:s),Qt(e,t+8,n.size);if(Qt(e,t+12,c),Qt(e,t+14,d),t+=16,o!=null)Qt(e,t,u),Qt(e,t+6,n.attrs),Qt(e,t+10,o),t+=14;if(e.set(i,t),t+=c,d)for(var m in l){var _=l[m],p=_.length;Qt(e,t,+m),Qt(e,t+2,p),e.set(_,t+4),t+=4+p}if(u)e.set(a,t),t+=u;return t},RC=function(e,t,n,i,r){Qt(e,t,101010256),Qt(e,t+8,n),Qt(e,t+10,n),Qt(e,t+12,i),Qt(e,t+16,r)};function Fv(e,t){if(!t)t={};var n={},i=[];Uv(e,"",n,t);var r=0,s=0;for(var o in n){var a=n[o],c=a[0],l=a[1],u=l.level==0?0:8,d=Ev(o),h=d.length,f=l.comment,m=f&&Ev(f),_=m&&m.length,p=tf(l.extra);if(h>65535)jn(11);var g=u?Dv(c,l):c,S=g.length,T=wC();T.p(c),i.push(Nv(l,{size:c.length,crc:T.d(),c:g,f:d,m,u:h!=o.length||m&&f.length!=_,o:r,compression:u})),r+=30+h+p+S,s+=76+2*(h+p)+(_||0)+S}var y=new Dt(s+22),w=r,A=s-r;for(var R=0;R<i.length;++R){var d=i[R];Av(y,d.o,d,d.f,d.u,d.c.length);var x=30+d.f.length+tf(d.extra);y.set(d.c,d.o+x),Av(y,r,d,d.f,d.u,d.c.length,d.o,d.m),r+=16+x+(d.m?d.m.length:0)}return RC(y,r,i.length,A,w),y}var is=["f1","f2","f2-f1","cell","border","facet"],Ki=1,Qi=4,to=1,of=(e,t)=>Math.sqrt(e*e+t*t);function CC(e){let{jitterX:t,jitterY:n,metricX:i,metricY:r,weight:s}=e,o=(1+t)/2,a=(1+n)/2,c=1+t/2,l=1+n/2,u=of(i*o,r*a)+s,d=Math.min(of(i*c,r*a),of(i*o,r*l))+s,h=e.feature==="facet"?Math.max(d,u+e.facetBlend):d;return{x:Math.max(1,Math.ceil(h/i+o-1)),y:Math.max(1,Math.ceil(h/r+a-1))}}function kv(e){let{x:t,y:n}=CC(e),i=46+Math.ceil((2*t+1)*(2*n+1)/8)+(e.weight>0?10:0);if(e.feature==="border")return i+8;if(e.feature==="facet")return i+32+Math.ceil(e.facetBlend*30);return i}function zv(e){return e.cellsX*e.cellsY*12}function Bv(e){return e.cellsX*e.cellsY*48+4096}var Ri=["albedo","emissive","normal","roughness","metalness","metallicRoughness","occlusion"];function PC(e){if(e==="PORTABLE_MATERIAL_V3_CONTRACT")return'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';if(e==="TEXTURE_ATLAS_CONTRACT")return'textureAtlas requires bounded named integer content rectangles with nonoverlapping gutter allocations, matching source crops and usage, and explicit portable sampling. Sources are V3 recipes or exact host-injected library map pins. Split atlases exceeding aggregate work or allocation budgets. remapUVToAtlas requires finite unit UV0, a named content region, inputOrigin and mapping mode; it preserves topology and does not unwrap or tile a region. Read kiln_discover ids ["textureAtlas", "remapUVToAtlas"] for the exact contracts.';if(e==="PROCEDURAL_TEXTURE_V3_CONTRACT")return'proceduralTexture schemaVersion 3 requires bounded JSON: width/height 4..1024, byte RGBA, integer pixel shapes and at most 64 operations. Palette/dither supports only albedo/emissive; seeded stamps accept every usage. Work includes polygon edges and periodic copies. Read kiln_discover ids ["proceduralTexture"] for the V3 contract; keep schemaVersion 2 for existing opaque patterns.';if(e==="BONE_CHAIN_ARGUMENT")return'createBoneChain requires 1..1024 valid local joint descriptors with unique roles and animation-safe names across the parent hierarchy. Use normalized perpendicular forward/bend axes and finite rest transforms; an explicit parentRole must match the declared parent. Read the retained source and kiln_discover ids ["createBoneChain"] for the exact contract.';if(e==="SKIN_BINDING_ARGUMENT")return'createSkinnedPart requires four valid bone indices and finite nonnegative weights per vertex, summing to one unless normalizeWeights:true is explicit. Zero sums are rejected. Assemble distinct named Bones and the parent in one rest-pose hierarchy before binding. Use unbound geometry within the documented budgets and finite invertible transforms. Read the retained source and kiln_discover ids ["createSkinnedPart"] for the exact contract; the Three exporter is required for skin delivery.';if(e==="EXPORT_MATERIAL_SIDE_UNSUPPORTED")return"EXPORT_MATERIAL_SIDE_UNSUPPORTED: A used material has BackSide, which glTF cannot encode directly. Author inward-facing triangles with FrontSide, or choose DoubleSide when both faces are intended. Neither adds missing geometry. Read the retained program with kiln_source query BackSide to locate the material; source names and exception text do not cross the evaluator boundary.";if(e==="UNINITIALIZED_BINDING")return"A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.";if(e==="LOD_SET")return'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].';if(e==="OPEN_SHELL")return'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].';if(e==="DELIVERY_CONTRACT")return'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws?, images?, decodedBytes?, materialTier? }) takes positive integers for triangles and draws, non-negative integers for images and decodedBytes, and a reference tier such as "web.portable.v1/standard" for materialTier; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].';if(e==="REQUIRE_SOLID")return'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].';if(e==="BUILD_RESULT")return'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.';if(e==="MATERIAL_RECIPE_OVERRIDE")return'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.';if(e==="PROGRAM_TYPE_ERROR")return"The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.";if(e==="PROGRAM_RANGE_ERROR")return"The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.";if(e==="MESH_DATA_NONFINITE")return"meshGeo positions, normals, UVs and tangents must contain finite numbers representable in Float32. Check missing XYZ components, undefined values, division by zero and overflowing calculations before constructing the arrays. Do not replace invalid values blindly with zero; correct the source calculation. Call kiln_discover for the exact meshGeo data contract.";if(e==="PORTABLE_COLOR_ARGUMENT")return"compilePortableMaterialSpecV2 baseColor and emissive must be numeric color integers from 0x000000 to 0xffffff, for example baseColor: 0x8a867c. CSS strings and materialRecipe hex-string overrides use different contracts. Omit these fields for their defaults, or call kiln_discover for the exact helper contract.";if(e==="MATERIAL_RECIPE_TEXTURE_BINDING")return"materialRecipe textureResources maps portable slots to approved resource ID strings. Slots are baseColor, normal, metallicRoughness, emissive and occlusion. albedo is a pbrMaterial field, not a recipe slot. Use kiln_discover to check each resource allowedSlots and recipeIds before binding it; no slot or resource substitution is applied.";if(e==="PORTABLE_TEXTURE_REFERENCE")return'compilePortableMaterialSpecV2 textures require typed references: { kind: "resource", resourceId: "kiln.texture..." } for an approved resource, or { kind: "procedural", spec: { schemaVersion: 2, ... } } for a procedural texture. Bare resource ID strings are invalid here. Use portable slots such as baseColor and check the exact helper/resource contracts with kiln_discover.';if(e==="TAPER_CONE_AXIS")return'taperConeGeo(radiusBottom, radiusTop, height, axis, segments): the fourth argument is axis, "x", "y" or "z" (default "y"). Segment count is the fifth argument, for example taperConeGeo(0.03, 0.02, 0.01, "x", 12). Call kiln_discover for the full contract.';if(e==="PROCEDURAL_TEXTURE_BLEND")return'proceduralTexture layer blend must be normal, multiply, screen, or overlay. Omit blend for normal compositing. Call kiln_discover with ids ["proceduralTexture"] for the supported layer fields.';if(e==="PART_NAME_ARGUMENT")return"createPart(name, geometry, material, options?): the first argument is a string name. Put the parent Object3D in the fourth argument as { parent: root }.";if(e==="PART_GEOMETRY_ARGUMENT")return"createPart(name, geometry, material, options?): the second argument must be a BufferGeometry. Call geometry helpers, for example boxGeo(1, 1, 1), instead of passing the function. For async helpers such as roundedBoxGeo, extrudeProfile and revolveProfile, await the result inside async build() before passing it to createPart. Call kiln_discover for the exact return contract.";if(e==="PART_MATERIAL_ARGUMENT")return"createPart(name, geometry, material, options?): the third argument must be a Three.js material. Wrap a color with gameMaterial(0x808080); a number or settings object alone is not a material. Call kiln_discover for the chosen material helper contract.";if(e==="SOLID_FLOAT32_COLLAPSE")return"Solid output cannot retain valid faces at Float32 precision. Simplify subprecision features or recenter local geometry; review coincident cut boundaries. Smoothing or replacing normals does not repair collapsed triangles. Kiln did not export a partially repaired solid.";if(e==="PROFILE_BEVEL_COLLAPSE")return"extrudeProfile or revolveProfile: bevel is too large for this profile; erosion leaves nothing. Reduce bevel below half the narrowest section width, set bevel to 0, or widen the profile. Dimensions and bevel use the same asset units.";if(e==="TUBE_RADIUS")return"curveToMesh and pipeAlongPath require an explicit positive finite radius representable in Float32, in asset units. A missing or undefined radius is invalid; check the referenced dimension. Radius is half the tube diameter.";if(e==="MATERIAL_ALPHA_MODE")return'pbrMaterial and portable material specs require lowercase alphaMode: "opaque", "mask", or "blend". Omit it for opaque. Exported glTF uses uppercase mode names; those are not authoring input values.';if(e==="MATERIAL_COLOR_ARGUMENT")return"gameMaterial, basicMaterial, glassMaterial and lambertMaterial take a color first: a hex number or CSS string. Settings belong in the second argument, for example gameMaterial(0x9a9a96, { roughness: 0.4, metalness: 0.8 }). pbrMaterial uses a different object-form contract; call kiln_discover for its texture and material fields.";if(e==="MATERIAL_PACKED_CHANNELS")return'pbrMaterial requires one packed texture with G=roughness and B=metalness. Generate or load it for usage "metallicRoughness" and pass metallicRoughness, or pass the same packed texture in both roughness and metalness. Do not combine those forms or pass a texture in only one scalar slot. Plain roughness and metalness values are 0..1 numbers. Call kiln_discover for the exact texture contract.';if(e==="REMOVED_HELPER")return"Generated source references a retired Kiln global. Call kiln_validate for name-specific migration guidance, then kiln_discover for the replacement contract. No compatibility aliases are provided.";if(e==="UNBOUND_VARIABLE")return"Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.";if(e==="ROUNDED_BOX_RADIUS")return"roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.";if(e==="GEAR_RADII_ORDER")return"gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.";if(e==="PROCEDURAL_TEXTURE_UNKNOWN_KEY")return'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';if(e==="PROCEDURAL_TEXTURE_USAGE")return'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';if(e==="MATERIAL_FRACTION_RANGE")return"Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.";if(e==="MATERIAL_NAME")return'A material name is the key a destination runtime groups draws by, so it is 1 to 200 visible characters: a plain string, no control characters. gameMaterial, basicMaterial, glassMaterial and lambertMaterial take it in their options object, pbrMaterial and foliageMaterial in theirs, for example gameMaterial(0x25342a, { roughness: 0.58, name: "ParkerisedSteel" }). Omit it to leave the material unnamed; materialRecipe and the portable material specs name their output already.';if(e==="PROFILE_HOLES_UNSUPPORTED")return"loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.";if(e==="PROFILE_SOLID_FAILED")return'PROFILE_SOLID_FAILED: extrudeProfile or revolveProfile could not build a solid from this outline. Reduce bevel or set it to 0. Keep the outline one simple closed loop: no self-intersections, repeated points or zero-length edges, and no neck narrower than twice the bevel. Holes must lie inside the outline and leave material. For revolveProfile, keep points off the axis (x = 0) unless the solid should close there. Keep coordinates at asset scale. Render that helper call alone with kiln_render and simplify the outline until it builds. Call kiln_discover with ids ["extrudeProfile", "revolveProfile"].';if(e==="PROFILE_CORRESPONDENCE_COLLAPSE")return"loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.";return e==="PARAMETRIC_PERIODIC_ENDPOINT"?"Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.":""}class ma extends Error{diagnostic;constructor(e,t=PC(e)){super(t);this.diagnostic=e;this.name="AuthoringDiagnosticError"}}var yl=1024,vl=4,bl=8,af=6,Vv=80,er=256;class tt extends ma{constructor(e,t){super(t,e);this.name="ProceduralTextureError"}}var Gv=["solid","checker","stripes","gradient","bricks","noise","cellular"],Hv=["normal","multiply","screen","overlay"],IC=new Set(["__proto__","prototype","constructor"]);function Sl(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new tt(`${t} must be a plain JSON object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new tt(`${t} must be a plain JSON object with no custom prototype.`);for(let i of Reflect.ownKeys(e)){if(typeof i!=="string")throw new tt(`${t} must not contain symbol keys.`);if(IC.has(i))throw new tt(`${t} contains forbidden key ${JSON.stringify(i)}.`);if(!Object.prototype.propertyIsEnumerable.call(e,i))throw new tt(`${t}.${i} must be an enumerable JSON field.`);let r=Object.getOwnPropertyDescriptor(e,i);if(!r||!("value"in r))throw new tt(`${t}.${i} must be a plain JSON data field.`)}return e}function LC(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw new tt(`${t} must be a plain JSON array.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=="string")throw new tt(`${t} must not contain symbol keys.`);if(n==="length")continue;if(!/^(0|[1-9][0-9]*)$/.test(n)||Number(n)>=e.length)throw new tt(`${t} has non-index JSON array key ${JSON.stringify(n)}.`)}for(let n=0;n<e.length;n++)if(!Object.hasOwn(e,n))throw new tt(`${t} must be a dense JSON array (missing index ${n}).`);return e}function tr(e,t,n){let i=new Set(t);for(let r of Object.keys(e))if(!i.has(r))throw new tt(`${n} has unknown key ${JSON.stringify(r)}.`,"PROCEDURAL_TEXTURE_UNKNOWN_KEY")}function Dn(e,t,n){if(typeof e!=="number"||!Number.isInteger(e)||e<0||e>16777215)throw new tt(`${t} must be a color integer between 0x000000 and 0xffffff, got ${JSON.stringify(e)}.`,n);return e}function Ci(e,t,n,i,r){if(e===void 0)return n;if(typeof e!=="number"||!Number.isInteger(e)||e<i||e>r)throw new tt(`${t} must be a whole number between ${i} and ${r}, got ${JSON.stringify(e)}.`);return e}function no(e,t,n,i,r,s){if(e===void 0)return n;if(typeof e!=="number"||!Number.isFinite(e)||e<i||e>r)throw new tt(`${t} must be a finite number between ${i} and ${r}, got ${JSON.stringify(e)}.`,s);return e}function ga(e,t,n){return no(e,t,n,0,1,"MATERIAL_FRACTION_RANGE")}function NC(e,t){if(e===void 0)return;let n=typeof e==="string"&&[...e].some((i)=>{let r=i.charCodeAt(0);return r<32||r===127});if(typeof e!=="string"||e.length===0||e.length>Vv||n)throw new tt(`${t} must be 1..${Vv} visible characters.`);return e}function DC(e,t,n){if(e===void 0)return n;if(!Ri.includes(e))throw new tt(`${t} must be one of ${Ri.join(", ")}, got ${JSON.stringify(e)}.`,"PROCEDURAL_TEXTURE_USAGE");return e}function $v(e,t){let i=(no(e,t,0,-36000,36000)%360+360)%360;return Object.is(i,-0)?0:i}function OC(e,t){let n=e.blend??"normal";if(!Hv.includes(n))throw new tt(`${t}.blend ${JSON.stringify(n)} is not one of ${Hv.join(", ")}.`,"PROCEDURAL_TEXTURE_BLEND");return n}function _a(e,t,n,i,r){let{name:s,fallback:o,min:a,max:c}=i,l=no(e[s],`${t}.${s}`,o,a,c);if(l!==o&&!r.includes(n)){let u=r.length>1?"features":"feature",d=r.length>1?r.join(", "):JSON.stringify(r[0]);throw new tt(`${t}.${s} applies only to ${u} ${d}, not ${JSON.stringify(n)}. Remove it or change feature.`)}return l}function UC(e,t){let n=e??"f1";if(!is.includes(n))throw new tt(`${t}.feature ${JSON.stringify(n)} is not one of ${is.join(", ")}.`);return n}function FC(e,t){let n=`proceduralTexture.layers[${t}]`,i=Sl(e,n),r=i.op;if(!Gv.includes(r))throw new tt(`${n}.op ${JSON.stringify(r)} is not one of ${Gv.join(", ")}.`);let s=OC(i,n),o=ga(i.opacity,`${n}.opacity`,1),a={blend:t===0?"normal":s,opacity:t===0?1:o};switch(r){case"solid":return tr(i,["op","color","blend","opacity"],n),{op:r,color:Dn(i.color,`${n}.color`),...a};case"checker":return tr(i,["op","colorA","colorB","squares","blend","opacity"],n),{op:r,colorA:Dn(i.colorA,`${n}.colorA`),colorB:Dn(i.colorB,`${n}.colorB`),squares:Ci(i.squares,`${n}.squares`,8,1,er),...a};case"stripes":return tr(i,["op","colorA","colorB","count","angleDeg","blend","opacity"],n),{op:r,colorA:Dn(i.colorA,`${n}.colorA`),colorB:Dn(i.colorB,`${n}.colorB`),count:Ci(i.count,`${n}.count`,8,1,er),angleDeg:$v(i.angleDeg,`${n}.angleDeg`),...a};case"gradient":return tr(i,["op","from","to","angleDeg","blend","opacity"],n),{op:r,from:Dn(i.from,`${n}.from`),to:Dn(i.to,`${n}.to`),angleDeg:$v(i.angleDeg,`${n}.angleDeg`),...a};case"bricks":return tr(i,["op","brick","mortar","rows","cols","mortarWidth","stagger","blend","opacity"],n),{op:r,brick:Dn(i.brick,`${n}.brick`),mortar:Dn(i.mortar,`${n}.mortar`),rows:Ci(i.rows,`${n}.rows`,8,1,er),cols:Ci(i.cols,`${n}.cols`,4,1,er),mortarWidth:ga(i.mortarWidth,`${n}.mortarWidth`,0.06),stagger:ga(i.stagger,`${n}.stagger`,0.5),...a};case"noise":return tr(i,["op","colorA","colorB","scale","octaves","seed","blend","opacity"],n),{op:r,colorA:Dn(i.colorA,`${n}.colorA`),colorB:Dn(i.colorB,`${n}.colorB`),scale:Ci(i.scale,`${n}.scale`,8,1,er),octaves:Ci(i.octaves,`${n}.octaves`,3,1,af),seed:Ci(i.seed,`${n}.seed`,0,-2147483648,2147483647),...a};case"cellular":{tr(i,["op","colorA","colorB","cellsX","cellsY","seed","jitterX","jitterY","metricX","metricY","weight","feature","range","borderOpen","borderWidth","facetSlope","facetBlend","blend","opacity"],n);let c=UC(i.feature,n);return{op:r,colorA:Dn(i.colorA,`${n}.colorA`),colorB:Dn(i.colorB,`${n}.colorB`),cellsX:Ci(i.cellsX,`${n}.cellsX`,8,1,er),cellsY:Ci(i.cellsY,`${n}.cellsY`,8,1,er),seed:Ci(i.seed,`${n}.seed`,0,-2147483648,2147483647),jitterX:ga(i.jitterX,`${n}.jitterX`,1),jitterY:ga(i.jitterY,`${n}.jitterY`,1),metricX:no(i.metricX,`${n}.metricX`,1,Ki,Qi),metricY:no(i.metricY,`${n}.metricY`,1,Ki,Qi),weight:no(i.weight,`${n}.weight`,0,0,to),feature:c,range:_a(i,n,c,{name:"range",fallback:1,min:0.01,max:8},["f1","f2","f2-f1","cell"]),borderOpen:_a(i,n,c,{name:"borderOpen",fallback:0.5,min:0,max:1},["border"]),borderWidth:_a(i,n,c,{name:"borderWidth",fallback:0.05,min:0.001,max:1},["border"]),facetSlope:_a(i,n,c,{name:"facetSlope",fallback:0.5,min:0,max:1},["facet"]),facetBlend:_a(i,n,c,{name:"facetBlend",fallback:0.1,min:0.001,max:1},["facet"]),...a}}default:throw new tt(`${n}.op is unsupported.`)}}function kC(e){let t=Sl(e,"proceduralTexture");if(tr(t,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new tt(`proceduralTexture.schemaVersion must be 1 or absent for V1 migration, got ${JSON.stringify(t.schemaVersion)}.`);return{schemaVersion:2,...t.size!==void 0?{size:t.size}:{},...t.usage!==void 0?{usage:t.usage}:{},...t.name!==void 0?{name:t.name}:{},layers:t.layers}}function xa(e){let t=Sl(e,"proceduralTexture"),n=t.schemaVersion===void 0||t.schemaVersion===1?Sl(kC(t),"proceduralTexture"):t;if(tr(n,["schemaVersion","size","usage","name","layers"],"proceduralTexture"),n.schemaVersion!==2)throw new tt(`proceduralTexture.schemaVersion must be 2, got ${JSON.stringify(n.schemaVersion)}.`);let i=n.size??256;if(typeof i!=="number"||!Number.isInteger(i)||i<vl||i>yl||(i&i-1)!==0)throw new tt(`proceduralTexture.size must be a power of two between ${vl} and ${yl}, got ${JSON.stringify(n.size)}.`);let r=n.layers;if(!Array.isArray(r)||r.length===0)throw new tt("proceduralTexture.layers must be a non-empty array — the bottom layer is the base pattern.");let s=LC(r,"proceduralTexture.layers");if(s.length>bl)throw new tt(`proceduralTexture: ${s.length} layers exceeds the maximum of ${bl}.`);let o=NC(n.name,"proceduralTexture.name");return{schemaVersion:2,size:i,usage:DC(n.usage,"proceduralTexture.usage","albedo"),...o!==void 0?{name:o}:{},layers:s.map(FC)}}var zC=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Pi=(e,t)=>e>>>t|e<<32-t;function io(e){let t=new TextEncoder().encode(e),n=t.length*8,i=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(i);r.set(t),r[t.length]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let c=0;c<r.length;c+=64){for(let S=0;S<16;S++)a[S]=s.getUint32(c+S*4,!1);for(let S=16;S<64;S++){let T=a[S-15],y=a[S-2],w=Pi(T,7)^Pi(T,18)^T>>>3,A=Pi(y,17)^Pi(y,19)^y>>>10;a[S]=a[S-16]+w+a[S-7]+A>>>0}let[l,u,d,h,f,m,_,p]=o;for(let S=0;S<64;S++){let T=Pi(f,6)^Pi(f,11)^Pi(f,25),y=f&m^~f&_,w=p+T+y+zC[S]+a[S]>>>0,A=Pi(l,2)^Pi(l,13)^Pi(l,22),R=l&u^l&d^u&d,x=A+R>>>0;p=_,_=m,m=f,f=h+w>>>0,h=d,d=u,u=l,l=w+x>>>0}let g=[l,u,d,h,f,m,_,p];for(let S=0;S<8;S++)o[S]=o[S]+g[S]>>>0}return[...o].map((c)=>c.toString(16).padStart(8,"0")).join("")}var ro="kiln.procedural-rgba.v3.1";var va=1024,BC=1048576,ba=64,wl=64,ya=256,El=32,Wv=64000000,VC=67108864;function it(e,t="PROCEDURAL_TEXTURE_V3_CONTRACT"){throw new tt(`proceduralTexture V3: ${e}`,t)}var GC=new Set(["__proto__","prototype","constructor"]);function HC(e){let t=0,n=(i,r,s)=>{if(++t>16384||s>10)it(`${r} exceeds the JSON size/depth budget.`);if(i===null||typeof i==="boolean")return;if(typeof i==="string"){if(i.length>4096)it(`${r} string is too long.`);return}if(typeof i==="number"){if(!Number.isFinite(i))it(`${r} must be finite.`);return}if(typeof i!=="object")it(`${r} must contain only JSON data.`);let o=Array.isArray(i),a=Object.getPrototypeOf(i);if(o?a!==Array.prototype:a!==Object.prototype&&a!==null)it(`${r} must be a plain JSON ${o?"array":"object"}.`);let c=o?Object.getOwnPropertyDescriptor(i,"length")?.value:void 0;if(o&&(typeof c!=="number"||c>1024))it(`${r} array is too long.`);let l=Reflect.ownKeys(i);if(l.length>1024)it(`${r} has too many fields.`);let u=Object.getOwnPropertyDescriptors(i);for(let d of l){if(typeof d!=="string"||GC.has(d))it(`${r} has a forbidden key.`);if(o&&d==="length")continue;let h=u[d];if(!h.enumerable||!("value"in h))it(`${r}.${d} must be an enumerable JSON data field, never an accessor.`);if(o&&(!/^(0|[1-9][0-9]*)$/.test(d)||Number(d)>=c))it(`${r} has an invalid array key.`)}if(o&&l.length!==c+1)it(`${r} must be a dense JSON array.`);for(let d of l)if(d!=="length"||!o)n(u[d].value,`${r}.${String(d)}`,s+1)};n(e,"recipe",0)}function qn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))it(`${n} must be a JSON object.`);let i=e;for(let r of Object.keys(i))if(!t.includes(r))it(`${n} has unknown field ${r}.`);return i}function fn(e,t,n,i,r){if(e===void 0&&r!==void 0)return r;if(typeof e!=="number"||!Number.isInteger(e)||e<t||e>n)it(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Zv(e,t){if(e===void 0)return!1;if(typeof e!=="boolean")it(`${t} must be boolean.`);return e}function Ml(e,t,n,i,r){if(!Array.isArray(e)||e.length!==t)it(`${n} must be a ${t}-element array.`);return e.map((s,o)=>fn(s,i,r,`${n}[${o}]`))}function Xv(e,t){let n=Ml(e,4,t,0,255);return n[3]===0?[0,0,0,0]:n}function jv(e,t,n){let i=qn(e,["x","y","width","height",...n?["kind"]:[]],t);return{x:fn(i.x,-4096,4096,`${t}.x`),y:fn(i.y,-4096,4096,`${t}.y`),width:fn(i.width,1,2048,`${t}.width`),height:fn(i.height,1,2048,`${t}.height`)}}function $C(e,t){let n=qn(e,["kind","x","y","width","height","from","to","points"],t);if(n.kind==="rectangle"||n.kind==="ellipse")return{kind:n.kind,...jv(n,t,n.kind)};if(n.kind==="polygon"){qn(n,["kind","points"],t);let i=n.points;if(!Array.isArray(i)||i.length<3||i.length>wl)it(`${t}.points requires 3..${wl} vertices.`);return{kind:"polygon",points:i.map((r,s)=>Ml(r,2,`${t}.points[${s}]`,-4096,4096))}}if(n.kind==="line")return qn(n,["kind","from","to","width"],t),{kind:"line",from:Ml(n.from,2,`${t}.from`,-4096,4096),to:Ml(n.to,2,`${t}.to`,-4096,4096),width:fn(n.width,1,2048,`${t}.width`)};return it(`${t}.kind must be rectangle, ellipse, polygon or line.`)}function qv(e){if(e.kind==="rectangle"||e.kind==="ellipse")return[e.x,e.y,e.x+e.width,e.y+e.height];let t=e.kind==="polygon"?e.points:[e.from,e.to],n=e.kind==="line"?e.width/2:0;return[Math.min(...t.map((i)=>i[0]))-n,Math.min(...t.map((i)=>i[1]))-n,Math.max(...t.map((i)=>i[0]))+n,Math.max(...t.map((i)=>i[1]))+n]}function WC(e){return e.kind==="polygon"?e.points.length+1:e.kind==="line"?4:e.kind==="ellipse"?3:1}function ZC(e,t,n,i=0,r=0){let[s,o,a,c]=qv(e);return[Math.max(0,Math.ceil(s+i-0.5)),Math.max(0,Math.ceil(o+r-0.5)),Math.min(t,Math.floor(a+i-0.5)+1),Math.min(n,Math.floor(c+r-0.5)+1)]}function Al(e){HC(e);let t=qn(e,["schemaVersion","width","height","usage","name","background","operations","palette"],"recipe");if(t.schemaVersion!==3)it("schemaVersion must be 3.");let n=fn(t.width,4,va,"width"),i=fn(t.height,4,va,"height"),r=n*i;if(r>BC)it("output texel budget exceeded.");let s=t.usage===void 0?"albedo":t.usage;if(!Ri.includes(s))it("usage must be a known texture usage.","PROCEDURAL_TEXTURE_USAGE");let o=s==="albedo"||s==="emissive",a=t.name;if(a!==void 0&&(typeof a!=="string"||!a.length||a.length>80||[...a].some((p)=>p.charCodeAt(0)<32||p.charCodeAt(0)===127)))it("name must be 1..80 visible characters.");let c=t.operations;if(!Array.isArray(c)||c.length>ba)it(`operations must be an array with at most ${ba} entries.`);let l=r,u=0,d=0,h=c.map((p,g)=>{let S=`operations[${g}]`,T=qn(p,["op","shape","rgba","opacity","alpha","invert","spec","count","seed","area","periodic"],S);if(T.op==="legacy-v2"){qn(T,["op","spec","alpha","opacity"],S);let j=qn(T.spec,["schemaVersion","size","usage","name","layers"],`${S}.spec`);if(j.schemaVersion!==2)it(`${S}.spec requires explicit schemaVersion 2.`);let z=xa(j);if(z.size!==n||z.size!==i||z.usage!==s)it(`${S} legacy-v2 dimensions and usage must match the V3 surface.`);l+=r*(1+z.layers.reduce((q,Q)=>q+(Q.op==="noise"?Q.octaves*16:Q.op==="cellular"?kv(Q):4),0)),d+=r*4;for(let q of z.layers){if(q.op!=="cellular")continue;l+=zv(q),d+=Bv(q)}return{op:"legacy-v2",spec:z,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)}}let y=$C(T.shape,`${S}.shape`),w=WC(y),[A,R,x,M]=ZC(y,n,i),k=Math.max(0,x-A)*Math.max(0,M-R);if(T.op==="mask")return qn(T,["op","shape","alpha","invert"],S),l+=r+k*w,{op:"mask",shape:y,alpha:fn(T.alpha,0,255,`${S}.alpha`,255),invert:Zv(T.invert,`${S}.invert`)};if(T.op!=="paint"&&T.op!=="stamps")return it(`${S}.op must be paint, mask, stamps or legacy-v2.`);let C={shape:y,rgba:Xv(T.rgba,`${S}.rgba`),opacity:fn(T.opacity,0,255,`${S}.opacity`,255)};if(T.op==="paint")return qn(T,["op","shape","rgba","opacity"],S),l+=k*(w+1),{op:"paint",...C};qn(T,["op","shape","rgba","opacity","count","seed","area","periodic"],S);let L=fn(T.count,1,ya,`${S}.count`),K=Zv(T.periodic,`${S}.periodic`),[I,G,X,P]=qv(y);if(K&&(X-I>n||P-G>i))it(`${S} periodic shape bounds must fit one surface period.`);if(u+=L*(K?9:1),u>ya)it(`expanded stamps budget exceeds ${ya}.`);return l+=L*(K?9:1)*Math.min(n,Math.ceil(X-I)+1)*Math.min(i,Math.ceil(P-G)+1)*(w+1),{op:"stamps",...C,count:L,seed:fn(T.seed,0,4294967295,`${S}.seed`),area:jv(T.area,`${S}.area`),periodic:K}}),f;if(t.palette!==void 0){if(!o)it("palette and dither are supported only for color usages albedo and emissive.");let p=qn(t.palette,["colors","dither"],"palette"),g=p.colors;if(!Array.isArray(g)||g.length<1||g.length>El)it(`palette.colors requires 1..${El} entries.`);let S=p.dither===void 0?"none":p.dither;if(S!=="none"&&S!=="bayer4")it("palette.dither must be none or bayer4.");f={colors:g.map((T,y)=>fn(T,0,16777215,`palette.colors[${y}]`)),dither:S},l+=r*(g.length+1)}if(l>Wv)it(`estimated work budget ${l} exceeds ${Wv}.`);if(r*4+d>VC)it("transient allocation budget exceeded.");let m={schemaVersion:3,width:n,height:i,usage:s,...a!==void 0?{name:a}:{},background:t.background===void 0?[0,0,0,0]:Xv(t.background,"background"),operations:h,...f?{palette:f}:{}},_=JSON.stringify(m);if(_.length>262144)it("canonical JSON byte budget exceeded.");return{spec:m,canonicalJson:_,estimatedWorkUnits:l,conservativePixelAllocationBytes:r*4+d}}function cf(e){return Al(e).spec}function XC(e){return Al(e).canonicalJson}function lf(e){return`sha256:${io(`${ro}
+${XC(e)}`)}`}var uf=["nearest","linear","nearest-mipmap-nearest","linear-mipmap-nearest","nearest-mipmap-linear","linear-mipmap-linear"],hf=["nearest","linear"],Sa=["repeat","clamp-to-edge","mirrored-repeat"];function Tl(e){if(!e||typeof e!=="object"||Array.isArray(e))throw new tt("portableSampler requires a complete JSON object.");let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new tt("portableSampler must be plain JSON data.");for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(typeof r!=="string"||!s.enumerable||!("value"in s))throw new tt("portableSampler requires enumerable JSON data fields, never accessors.")}let n=e,i={minFilter:uf,magFilter:hf,wrapS:Sa,wrapT:Sa};if(Object.keys(n).some((r)=>!Object.hasOwn(i,r)))throw new tt("portableSampler contains an unsupported field.");for(let[r,s]of Object.entries(i))if(!s.includes(n[r]))throw new tt(`portableSampler.${r} requires one of ${s.join(", ")}.`);return{minFilter:n.minFilter,magFilter:n.magFilter,wrapS:n.wrapS,wrapT:n.wrapT}}var Kv="kiln.texture-atlas.v1.1",Qv="kiln.texture-atlas.v1.2",Rl=Object.freeze([Kv,Qv]),rs=Object.freeze({edge:1024,outputTexels:1048576,regions:64,sources:16,sourceTexels:4194304,encodedSourceBytes:8388608,encodedBytes:16777216,jsonBytes:262144,work:64000000,allocatedBytes:67108864,uvVertices:262144,uvAttributeBytes:134217728}),nr=Object.freeze({...rs,edge:2048,outputTexels:4194304,regions:128,sources:32,work:192000000,allocatedBytes:134217728}),ff=Object.freeze([1024,2048]);function eb(e){return e.pack===void 0?Kv:Qv}function jC(e){return e.pack===void 0?rs:nr}class tb extends ma{constructor(e){super("TEXTURE_ATLAS_CONTRACT",`textureAtlas: ${e}`);this.name="TextureAtlasError"}}function De(e){throw new tb(e)}function pf(e){let t=0,n=0,i=new TextEncoder,r=(o)=>{if(n+=o,n>rs.jsonBytes)De("JSON byte budget exceeded.")},s=(o,a)=>{if(++t>65536||a>16)De("JSON node/depth budget exceeded.");if(o===null||typeof o==="boolean"){r(o===!1?5:4);return}if(typeof o==="number"){if(!Number.isFinite(o))De("JSON numbers must be finite.");r(JSON.stringify(o).length);return}if(typeof o==="string"){if(o.length>4096)De("JSON string budget exceeded.");r(i.encode(JSON.stringify(o)).length);return}if(typeof o!=="object")De("plain JSON data is required.");let c=Array.isArray(o),l=Object.getPrototypeOf(o);if(c?l!==Array.prototype:l!==null&&l!==Object.prototype)De("plain JSON prototypes are required.");let u=c?Object.getOwnPropertyDescriptor(o,"length")?.value:void 0;if(c&&(!Number.isSafeInteger(u)||u>1024))De("JSON array budget exceeded.");let d=Reflect.ownKeys(o);if(d.length>1024||c&&d.length!==u+1)De("dense bounded JSON fields are required.");r(2+Math.max(0,d.length-(c?1:0)-1));for(let h of d){if(c&&h==="length")continue;if(typeof h!=="string"||["__proto__","prototype","constructor"].includes(h))De("forbidden JSON field.");if(h.length>4096)De("JSON field name budget exceeded.");if(!c)r(i.encode(JSON.stringify(h)).length+1);let f=Object.getOwnPropertyDescriptor(o,h);if(!f.enumerable||!("value"in f))De("JSON accessors/hidden fields are unsupported.");if(c&&(!/^(0|[1-9][0-9]*)$/.test(h)||Number(h)>=u))De("invalid JSON array key.");s(f.value,a+1)}};s(e,0)}function pn(e,t,n){if(!e||typeof e!=="object"||Array.isArray(e))De(`${n} must be a JSON object.`);let i=e;if(Object.keys(i).some((r)=>!t.includes(r)))De(`${n} has an unknown field.`);return i}function On(e,t,n,i){if(typeof e!=="number"||!Number.isSafeInteger(e)||e<t||e>n)De(`${i} must be an integer ${t}..${n}.`);return e===0?0:e}function Lr(e,t){if(typeof e!=="string"||!/^sha256:[a-f0-9]{64}$/.test(e))De(`${t} must be an exact SHA-256 hash.`);return e}function Yv(e,t){let n=pn(e,["x","y","width","height"],t);return{x:On(n.x,0,4096,`${t}.x`),y:On(n.y,0,4096,`${t}.y`),width:On(n.width,1,4096,`${t}.width`),height:On(n.height,1,4096,`${t}.height`)}}function so(e){let{content:t,gutter:n}=e;return{x:t.x-n,y:t.y-n,width:t.width+2*n,height:t.height+2*n}}function nb(e,t,n,i){if(e.x+e.width>n||e.y+e.height>i)De("source crop is out of bounds.");if(e.width!==t.width||e.height!==t.height)De("source crop/content dimensions must match; resampling is unsupported.")}function df(e){return e.kind==="procedural"?`procedural:${lf(e.spec)}`:`resource:${e.pin.resourceId}:${e.pin.revisionId}:${e.resourceId}`}var qC=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Jv=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;function YC(e,t,n,i){let r=[{x:0,y:0,width:e,height:t}],s=(a)=>{let c=[];for(let l of r){if(!qC(l,a)){c.push(l);continue}if(a.x>l.x)c.push({x:l.x,y:l.y,width:a.x-l.x,height:l.height});if(a.x+a.width<l.x+l.width)c.push({x:a.x+a.width,y:l.y,width:l.x+l.width-a.x-a.width,height:l.height});if(a.y>l.y)c.push({x:l.x,y:l.y,width:l.width,height:a.y-l.y});if(a.y+a.height<l.y+l.height)c.push({x:l.x,y:a.y+a.height,width:l.width,height:l.y+l.height-a.y-a.height})}if(r=c.filter((l,u)=>!c.some((d,h)=>h!==u&&Jv(d,l)&&(!Jv(l,d)||h<u))),r.length>16384)De("pack: free-space bookkeeping budget exceeded.")};for(let a of n)s(a);let o=[...i].sort((a,c)=>c.width*c.height-a.width*a.height||(a.region.name<c.region.name?-1:a.region.name>c.region.name?1:0));for(let a of o){let c,l;for(let u of r){if(u.width<a.width||u.height<a.height)continue;let d=u.width-a.width,h=u.height-a.height,f=[Math.min(d,h),Math.max(d,h),u.y,u.x];if(!l||f[0]<l[0]||f[0]===l[0]&&(f[1]<l[1]||f[1]===l[1]&&(f[2]<l[2]||f[2]===l[2]&&f[3]<l[3])))c=u,l=f}if(!c)De(`pack: region ${a.region.name} (${a.width}x${a.height} texels with its gutter) does not fit in the ${e}x${t} atlas beside the regions already placed.`);a.region.content={x:c.x+a.region.gutter,y:c.y+a.region.gutter,width:a.region.content.width,height:a.region.content.height},s({x:c.x,y:c.y,width:a.width,height:a.height})}}function Ma(e){pf(e);let t=pn(e,["schemaVersion","width","height","usage","sampler","regions","pack"],"atlas");if(t.schemaVersion!==1)De("schemaVersion must be 1.");let n;if(t.pack!==void 0){let h=pn(t.pack,["edge","gutter","algorithm"],"pack");if(!ff.includes(h.edge))De("pack.edge must be 1024 or 2048.");if(h.algorithm!==void 0&&h.algorithm!=="maxrects")De("pack.algorithm must be 'maxrects'.");n={edge:h.edge,gutter:h.gutter===void 0?2:On(h.gutter,0,32,"pack.gutter"),algorithm:"maxrects"}}let i=n?nr:rs,r=n?n.edge:i.edge,s=n&&t.width===void 0?n.edge:On(t.width,4,r,"width"),o=n&&t.height===void 0?n.edge:On(t.height,4,r,"height");if(s*o>i.outputTexels)De("output texel budget exceeded.");if(!Ri.includes(t.usage))De("usage must be a texture usage.");let a=t.usage;if(!Array.isArray(t.regions)||!t.regions.length||t.regions.length>i.regions)De(`regions must contain 1..${i.regions} entries.`);let c=[],l=t.regions.map((h,f)=>{let m=pn(h,["name","content","gutter","edgeMode","source","crop","packed"],`regions[${f}]`);if(typeof m.name!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(m.name))De("region name must be a stable lowercase identifier.");let _=m.content!==void 0;if(!_&&!n)De(`region ${m.name}: content is required unless the atlas sets pack.`);if(m.packed!==void 0&&(m.packed!==!0||!n||!_))De("packed is the resolved-placement marker: true, with content, in an atlas that sets pack.");let p=_?Yv(m.content,"content"):void 0,g=m.gutter===void 0?n?.gutter??2:On(m.gutter,0,32,"gutter"),S=m.edgeMode===void 0?"copy-edge":m.edgeMode;if(!["copy-edge","mask-rgb-dilate"].includes(S))De("unsupported edgeMode.");if(S==="mask-rgb-dilate"&&a!=="albedo"&&a!=="emissive")De("mask RGB dilation requires color usage.");let T=pn(m.source,["kind","spec","resourceId","pin","expected"],"source"),y,w=m.crop===void 0?void 0:Yv(m.crop,"crop");if(T.kind==="procedural"){pn(T,["kind","spec"],"procedural source");let R=Al(T.spec);if(R.spec.usage!==a)De("source usage does not match atlas usage.");y={kind:"procedural",spec:R.spec},w??={x:0,y:0,width:R.spec.width,height:R.spec.height},p??={x:0,y:0,width:w.width,height:w.height},nb(w,p,R.spec.width,R.spec.height)}else if(T.kind==="resource"){if(pn(T,["kind","resourceId","pin","expected"],"resource source"),typeof T.resourceId!=="string"||!/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/.test(T.resourceId))De("source resourceId must be an exact returned map ID.");let R=pn(T.pin,["resourceId","revisionId","sha256"],"source pin");if(typeof R.resourceId!=="string"||!/^[a-z][a-z0-9_-]{0,79}$/.test(R.resourceId))De("pin resourceId must be a material ID.");let x=Lr(R.revisionId,"pin revisionId"),M=Lr(R.sha256,"pin sha256");if(x!==M)De("source pin revision/hash mismatch.");let k;if(T.expected!==void 0){let C=pn(T.expected,["width","height","imageSha256","decodedPixelHash"],"source expected");k={...C.width===void 0?{}:{width:On(C.width,1,4096,"expected.width")},...C.height===void 0?{}:{height:On(C.height,1,4096,"expected.height")},...C.imageSha256===void 0?{}:{imageSha256:Lr(C.imageSha256,"expected.imageSha256")},...C.decodedPixelHash===void 0?{}:{decodedPixelHash:Lr(C.decodedPixelHash,"expected.decodedPixelHash")}}}if(y={kind:"resource",resourceId:T.resourceId,pin:{resourceId:R.resourceId,revisionId:x,sha256:M},...k?{expected:k}:{}},!p){let C=w??(k?.width!==void 0&&k.height!==void 0?{width:k.width,height:k.height}:De(`region ${m.name}: a packed resource region needs a crop or expected width and height (its size).`));p={x:0,y:0,width:C.width,height:C.height}}if(w&&(w.width!==p.width||w.height!==p.height))De("source crop/content dimensions must match; resampling is unsupported.")}else De("source kind must be procedural or pinned resource.");let A={name:m.name,content:p,gutter:g,edgeMode:S,source:y,...w?{crop:w}:{},...n&&(!_||m.packed===!0)?{packed:!0}:{}};if(!_)c.push({region:A,width:A.content.width+2*g,height:A.content.height+2*g});return A}).sort((h,f)=>h.name<f.name?-1:h.name>f.name?1:0);if(new Set(l.map((h)=>h.name)).size!==l.length)De("duplicate region name.");if(c.length){let h=new Set(c.map((f)=>f.region));YC(s,o,l.filter((f)=>!h.has(f)).map((f)=>so(f)),c)}for(let h of l){let f=so(h);if(f.x<0||f.y<0||f.x+f.width>s||f.y+f.height>o)De("padded allocation is out of bounds.")}for(let h=0;h<l.length;h++)for(let f=h+1;f<l.length;f++){let m=so(l[h]),_=so(l[f]);if(m.x<_.x+_.width&&_.x<m.x+m.width&&m.y<_.y+_.height&&_.y<m.y+m.height)De(`padded allocations overlap: ${l[h].name}, ${l[f].name}.`)}if(new Set(l.map((h)=>df(h.source))).size>i.sources)De(`distinct source budget exceeds ${i.sources}.`);let u;try{u=Tl(t.sampler===void 0?{minFilter:"linear-mipmap-linear",magFilter:"linear",wrapS:"clamp-to-edge",wrapT:"clamp-to-edge"}:t.sampler)}catch(h){De(`sampler: ${h.message}`)}let d={schemaVersion:1,width:s,height:o,usage:a,sampler:u,regions:l,...n?{pack:n}:{}};if(new TextEncoder().encode(JSON.stringify(d)).length>rs.jsonBytes)De("canonical JSON byte budget exceeded.");return d}function JC(e){let t=Ma(e);return`sha256:${io(`${eb(t)}
+${JSON.stringify(t)}`)}`}function Ii(e){pf(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function KC(e){return`sha256:${io(`kiln.atlas-layout.v1
+${Ii({width:e.width,height:e.height,origin:"top-left",regions:e.regions.map((t)=>({name:t.name,content:t.content,allocation:so(t)}))})}`)}`}function mf(e,t){pf(e);let n=Ma(t),i=pn(e,["version","compilerId","width","height","usage","origin","sampler","specHash","layoutHash","decodedPixelHash","atlasPixelHash","sources","regions","manifestHash"],"manifest");if(i.version!=="kiln.atlas-manifest.v1"||i.compilerId!==eb(n)||i.width!==n.width||i.height!==n.height||i.usage!==n.usage||i.origin!=="top-left")De("manifest version/compiler/dimensions/usage/origin mismatch.");if(Ii(i.sampler)!==Ii(n.sampler)||i.specHash!==JC(n)||i.layoutHash!==KC(n))De("manifest sampler/spec/layout identity mismatch.");Lr(i.decodedPixelHash,"manifest decodedPixelHash"),Lr(i.atlasPixelHash,"manifest atlasPixelHash");let r=new Map(n.regions.map((c)=>[df(c.source),c.source]));if(!Array.isArray(i.sources)||i.sources.length!==r.size||!Array.isArray(i.regions)||i.regions.length!==n.regions.length)De("manifest source/region inventory mismatch.");let s=new Map;for(let c of i.sources){let l=pn(c,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId","descriptor"],"manifest source");if(typeof l.id!=="string"||s.has(l.id))De("duplicate/invalid manifest source identity.");let u=r.get(l.id);if(!u||l.kind!==u.kind)De("manifest source identity mismatch.");let d=On(l.width,1,4096,"manifest source width"),h=On(l.height,1,4096,"manifest source height");if(Lr(l.decodedPixelHash,"manifest source decodedPixelHash"),u.kind==="procedural"){if(pn(l,["id","kind","width","height","decodedPixelHash","recipeHash","compilerId"],"manifest procedural source"),d!==u.spec.width||h!==u.spec.height||l.recipeHash!==lf(u.spec)||l.compilerId!=="kiln.procedural-rgba.v3.1")De("manifest procedural source identity mismatch.")}else{pn(l,["id","kind","width","height","decodedPixelHash","descriptor"],"manifest resource source");let f=pn(l.descriptor,["materialId","revisionId","resourceId","slot","usage","colorSpace","width","height","encodedByteLength","imageSha256","decodedPixelHash"],"manifest source descriptor"),m={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};if(f.materialId!==u.pin.resourceId||f.revisionId!==u.pin.revisionId||f.resourceId!==u.resourceId||f.width!==d||f.height!==h||f.usage!==n.usage||typeof f.slot!=="string"||m[f.slot]!==n.usage||f.colorSpace!==(n.usage==="albedo"||n.usage==="emissive"?"srgb":"linear"))De("manifest pinned resource descriptor mismatch.");if(Lr(f.imageSha256,"manifest source imageSha256"),On(f.encodedByteLength,1,jC(n).encodedSourceBytes,"manifest encodedByteLength"),f.decodedPixelHash!==void 0&&f.decodedPixelHash!==l.decodedPixelHash)De("manifest source decodedPixelHash mismatch.");for(let _ of["width","height","imageSha256","decodedPixelHash"]){let p=u.expected?.[_];if(p!==void 0&&p!==(_==="decodedPixelHash"?l[_]:f[_]))De("manifest source expectation mismatch.")}}s.set(l.id,{width:d,height:h})}for(let c=0;c<n.regions.length;c++){let l=n.regions[c],u=pn(i.regions[c],["name","content","allocation","crop","sourceId"],"manifest region"),d=df(l.source),h=s.get(d),f=l.crop??{x:0,y:0,width:h.width,height:h.height};if(nb(f,l.content,h.width,h.height),u.name!==l.name||u.sourceId!==d||Ii(u.content)!==Ii(l.content)||Ii(u.allocation)!==Ii(so(l))||Ii(u.crop)!==Ii(f))De("manifest named region/crop/allocation identity mismatch.")}let{manifestHash:o,...a}=i;if(o!==`sha256:${io(`kiln.atlas-manifest.v1
+${Ii(a)}`)}`)De("manifest hash mismatch.");return structuredClone(e)}var QC=(()=>{let e=Ue().int().min(0).max(16777215),t=Ue().int().min(1).max(er),n=Ue().min(-36000).max(36000),i=Ue().min(0).max(1),r={blend:xt(["normal","multiply","screen","overlay"]),opacity:i};return _e({schemaVersion:Ne(2),size:Ue().int().min(vl).max(yl),usage:xt(Ri),name:je().min(1).max(80).optional(),layers:ht(oi("op",[_e({op:Ne("solid"),color:e,...r}).strict(),_e({op:Ne("checker"),colorA:e,colorB:e,squares:t,...r}).strict(),_e({op:Ne("stripes"),colorA:e,colorB:e,count:t,angleDeg:n,...r}).strict(),_e({op:Ne("gradient"),from:e,to:e,angleDeg:n,...r}).strict(),_e({op:Ne("bricks"),brick:e,mortar:e,rows:t,cols:t,mortarWidth:i,stagger:i,...r}).strict(),_e({op:Ne("noise"),colorA:e,colorB:e,scale:t,octaves:Ue().int().min(1).max(af),seed:Ue().int().min(-2147483648).max(2147483647),...r}).strict(),_e({op:Ne("cellular"),colorA:e,colorB:e,cellsX:t,cellsY:t,seed:Ue().int().min(-2147483648).max(2147483647),jitterX:i,jitterY:i,metricX:Ue().min(Ki).max(Qi),metricY:Ue().min(Ki).max(Qi),weight:Ue().min(0).max(to),feature:xt(is),range:Ue().min(0.01).max(8),borderOpen:i,borderWidth:Ue().min(0.001).max(1),facetSlope:i,facetBlend:Ue().min(0.001).max(1),...r}).strict()])).min(1).max(bl)}).strict()})();function ib(e,t=QC){let n=(q,Q)=>Ue().int().min(q).max(Q),i=n(0,255),r=n(-4096,4096),s=gv([r,r]),o=gv([i,i,i,i]),a=xt(Ri),c=uC(["sha256:",je().regex(/^[a-f0-9]{64}$/)]),l=je().min(1).max(80),u=je().regex(/^[a-z][a-z0-9_-]{0,79}$/),d=je().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.:/-]{0,199}$/),h={width:n(1,4096),height:n(1,4096)},f=_e({x:r,y:r,width:n(1,2048),height:n(1,2048)}).strict(),m=_e({x:n(0,4096),y:n(0,4096),...h}).strict(),_=oi("kind",[f.extend({kind:Ne("rectangle")}).strict(),f.extend({kind:Ne("ellipse")}).strict(),_e({kind:Ne("polygon"),points:ht(s).min(3).max(wl)}).strict(),_e({kind:Ne("line"),from:s,to:s,width:n(1,2048)}).strict()]),p=_e({op:Ne("paint"),shape:_,rgba:o,opacity:i}).strict(),g=_e({op:Ne("mask"),shape:_,alpha:i,invert:ns()}).strict(),S=_e({op:Ne("stamps"),shape:_,rgba:o,opacity:i,count:n(1,ya),seed:n(0,4294967295),area:f,periodic:ns()}).strict(),T=_e({op:Ne("legacy-v2"),spec:e,alpha:i,opacity:i}).strict(),y=_e({colors:ht(n(0,16777215)).min(1).max(El),dither:xt(["none","bayer4"])}).strict(),w={schemaVersion:Ne(3),width:n(4,va),height:n(4,va),usage:a,name:l.optional(),background:o},A=_e({...w,operations:ht(oi("op",[p,g,S,T.extend({spec:t})])).max(ba),palette:y.optional()}).strict(),R=_e({...w,usage:a.optional(),background:o.optional(),operations:ht(oi("op",[p.partial({opacity:!0}),g.partial({alpha:!0,invert:!0}),S.partial({opacity:!0,periodic:!0}),T.partial({alpha:!0,opacity:!0})])).max(ba),palette:y.partial({dither:!0}).optional()}).strict(),x=_e({minFilter:xt(uf),magFilter:xt(hf),wrapS:xt(Sa),wrapT:xt(Sa)}).strict(),M=_e({resourceId:u,revisionId:c,sha256:c}).strict(),k=_e({kind:Ne("resource"),resourceId:d,pin:M,expected:_e({...h,imageSha256:c,decodedPixelHash:c}).partial().strict().optional()}).strict(),C=_e({name:u,content:m,gutter:n(0,32),edgeMode:xt(["copy-edge","mask-rgb-dilate"]),source:oi("kind",[_e({kind:Ne("procedural"),spec:A}).strict(),k]),crop:m.optional(),packed:Ne(!0).optional()}).strict(),L={schemaVersion:Ne(1),width:n(4,nr.edge),height:n(4,nr.edge),usage:a,sampler:x},K=eo(ff.map((q)=>Ne(q))),I=_e({...L,regions:ht(C).min(1).max(nr.regions),pack:_e({edge:K,gutter:n(0,32),algorithm:Ne("maxrects")}).strict().optional()}).strict(),G=_e({...L,width:L.width.optional(),height:L.height.optional(),pack:_e({edge:K,gutter:n(0,32).optional(),algorithm:Ne("maxrects").optional()}).strict().optional(),sampler:x.optional(),regions:ht(C.extend({source:oi("kind",[_e({kind:Ne("procedural"),spec:R}).strict(),k])}).partial({content:!0,gutter:!0,edgeMode:!0})).min(1).max(nr.regions)}).strict(),X=_e({materialId:u,revisionId:c,resourceId:d,slot:xt(["baseColor","normal","metallicRoughness","emissive","occlusion"]),usage:a,colorSpace:xt(["srgb","linear"]),...h,encodedByteLength:n(1,rs.encodedSourceBytes),imageSha256:c,decodedPixelHash:c.optional()}).strict(),P={id:je().min(1).max(1024),...h,decodedPixelHash:c},j=oi("kind",[_e({...P,kind:Ne("procedural"),recipeHash:c,compilerId:Ne(ro)}).strict(),_e({...P,kind:Ne("resource"),descriptor:X}).strict()]),z=_e({version:Ne("kiln.atlas-manifest.v1"),compilerId:xt(Rl),width:L.width,height:L.height,usage:a,origin:Ne("top-left"),sampler:x,specHash:c,layoutHash:c,decodedPixelHash:c,atlasPixelHash:c,sources:ht(j).min(1).max(nr.sources),regions:ht(_e({name:u,content:m,allocation:m,crop:m,sourceId:je().min(1).max(1024)}).strict()).min(1).max(nr.regions),manifestHash:c}).strict();return{portableSamplerSchema:x,proceduralTextureSpecV3Schema:R,canonicalProceduralTextureSpecV3Schema:A,textureAtlasSpecV1Schema:G,canonicalTextureAtlasSpecV1Schema:I,textureAtlasManifestV1Schema:z,materialMapPinSchema:M,verifiedPinnedMaterialMapDescriptorSchema:X}}var an=Object.freeze({maxMapBytes:8388608,maxRecordBytes:33554432,maxManifestBytes:262144,maxMapEdge:4096,maxRecordPixels:8388608,maxPayloadBytes:16777216,maxPayloadPixels:16777216,maxPayloadRecords:16}),sb=["baseColor","normal","metallicRoughness","emissive","occlusion"],ob={baseColor:"albedo",normal:"normal",metallicRoughness:"metallicRoughness",emissive:"emissive",occlusion:"occlusion"};var oo=je().regex(/^[a-z][a-z0-9_-]{0,79}$/),bn=je().regex(/^sha256:[a-f0-9]{64}$/),mn=je().min(1).max(1000),rb=je().max(2000).url().refine((e)=>/^https?:\/\//.test(e),"Provenance URL must be HTTP(S)"),eP=_e({program:_e({name:mn,version:mn,sha256:bn}).strict(),toolkit:ht(_e({name:mn,sha256:bn}).strict()).max(32),seed:Ue().int().optional(),runtimes:ht(_e({name:mn,version:mn}).strict()).min(1).max(32)}).strict(),ab=_e({id:oo,kind:xt(["external","procedural","generated"]),provider:mn,creator:mn,assetId:mn.optional(),assetUrl:rb.optional(),accessedAt:je().datetime().optional(),license:_e({spdx:mn,url:rb,attribution:je().max(4000)}).strict(),generator:eP.optional(),originalFiles:ht(_e({name:je().min(1).max(200),sha256:bn,bytes:Ue().int().positive().max(1073741824)}).strict()).max(20)}).strict().superRefine((e,t)=>{if(e.kind==="external"&&(!e.assetUrl||!e.originalFiles.length))t.addIssue({code:"custom",message:"External materials require a source URL and original file hashes"});if(e.kind==="generated"&&(!e.generator||!e.originalFiles.length))t.addIssue({code:"custom",message:"Generated materials require a generator record and original file hashes"});if(e.kind!=="generated"&&e.generator)t.addIssue({code:"custom",message:"Only a generated material source carries a generator record"});if(new Set(e.originalFiles.map((n)=>n.name)).size!==e.originalFiles.length)t.addIssue({code:"custom",message:"Duplicate original filename"})}),cb=_e({operation:mn,tool:mn,version:mn,parameters:gl(je().max(100),eo([je().max(2000),Ue().finite(),ns()])).optional()}).strict(),Un=Ue().int().min(0).max(16777215),ss=Ue().int().min(1).max(256),os={blend:xt(["normal","multiply","screen","overlay"]).default("normal"),opacity:Ue().min(0).max(1).default(1)},Aa=_e({schemaVersion:Ne(2),size:Ue().int().min(4).max(1024).default(256),usage:xt(["albedo","normal","roughness","metalness","metallicRoughness","emissive","occlusion"]).default("albedo"),name:je().min(1).max(80).optional(),layers:ht(oi("op",[_e({op:Ne("solid"),color:Un,...os}).strict(),_e({op:Ne("checker"),colorA:Un,colorB:Un,squares:ss.default(8),...os}).strict(),_e({op:Ne("stripes"),colorA:Un,colorB:Un,count:ss.default(8),angleDeg:Ue().min(-36000).max(36000).default(0),...os}).strict(),_e({op:Ne("gradient"),from:Un,to:Un,angleDeg:Ue().min(-36000).max(36000).default(0),...os}).strict(),_e({op:Ne("bricks"),brick:Un,mortar:Un,rows:ss.default(8),cols:ss.default(4),mortarWidth:Ue().min(0).max(1).default(0.06),stagger:Ue().min(0).max(1).default(0.5),...os}).strict(),_e({op:Ne("noise"),colorA:Un,colorB:Un,scale:ss.default(8),octaves:Ue().int().min(1).max(6).default(3),seed:Ue().int().min(-2147483648).max(2147483647).default(0),...os}).strict(),_e({op:Ne("cellular"),colorA:Un,colorB:Un,cellsX:ss.default(8),cellsY:ss.default(8),seed:Ue().int().min(-2147483648).max(2147483647).default(0),jitterX:Ue().min(0).max(1).default(1),jitterY:Ue().min(0).max(1).default(1),metricX:Ue().min(Ki).max(Qi).default(1),metricY:Ue().min(Ki).max(Qi).default(1),weight:Ue().min(0).max(to).default(0),feature:xt(is).default("f1"),range:Ue().min(0.01).max(8).default(1),borderOpen:Ue().min(0).max(1).default(0.5),borderWidth:Ue().min(0.001).max(1).default(0.05),facetSlope:Ue().min(0).max(1).default(0.5),facetBlend:Ue().min(0.001).max(1).default(0.1),...os}).strict()])).min(1).max(8)}).strict(),xf=_e({kind:Ne("normal-from-height"),strength:Ue().finite().positive().max(64)}).strict(),tP=_e({compiler:Ne("kiln.procedural-texture.v2"),spec:Aa,derive:xf.optional(),recipeHash:bn,pixelHash:bn,encoder:_e({name:Ne("sharp"),version:mn}).strict()}).strict(),lb=_e({baseColor:Ue().int().min(0).max(16777215).optional(),roughness:Ue().min(0).max(1).default(1),metalness:Ue().min(0).max(1).default(0),emissive:Ue().int().min(0).max(16777215).optional(),emissiveIntensity:Ue().min(0).max(64).default(1),alphaMode:xt(["opaque","mask","blend"]).default("opaque"),alphaCutoff:Ue().min(0).max(1).default(0.5),doubleSided:ns().default(!1)}).strict(),wa=_e({schemaVersion:Ne(1),materialId:oo,revisionId:bn,parentRevision:bn.optional(),name:je().min(1).max(200),tags:ht(je().min(1).max(80)).max(30),tileable:ns(),physicalSizeMeters:_e({width:Ue().finite().positive().max(1e5),height:Ue().finite().positive().max(1e5)}).strict().optional(),parameters:lb,sources:ht(ab).min(1).max(20),maps:ht(_e({slot:xt(sb),file:xt(["baseColor.png","normal.png","metallicRoughness.png","emissive.png","occlusion.png"]),sha256:bn,bytes:Ue().int().positive().max(an.maxMapBytes),width:Ue().int().positive().max(an.maxMapEdge),height:Ue().int().positive().max(an.maxMapEdge),usage:xt(["albedo","normal","metallicRoughness","emissive","occlusion"]),colorSpace:xt(["srgb","linear"]),normalConvention:Ne("opengl").optional(),channelPacking:Ne("r-occlusion-g-roughness-b-metallic").optional(),sourceId:oo,originalFile:je().min(1).max(200).optional(),transforms:ht(cb).max(30),procedural:tP.optional()}).strict()).min(1).max(5)}).strict(),gf=_e({materialId:oo,parentRevision:bn.optional().describe("The saved revision of this materialId that this one replaces."),name:je().min(1).max(200),tags:ht(je().min(1).max(80)).max(30).optional(),tileable:ns(),physicalSizeMeters:_e({width:Ue().finite().positive().max(1e5),height:Ue().finite().positive().max(1e5)}).strict().optional(),parameters:lb.partial().optional(),sources:ht(ab).min(1).max(20),maps:ht(_e({slot:xt(sb),sourceId:oo,transforms:ht(cb).max(30),normalConvention:Ne("opengl").optional(),channelPacking:Ne("r-occlusion-g-roughness-b-metallic").optional(),procedural:Aa,derive:xf.optional()}).strict()).min(1).max(5)}).strict(),_f=_e({schemaVersion:Ne(1),records:ht(_e({manifest:wa,files:gl(je().regex(/^(baseColor|normal|metallicRoughness|emissive|occlusion)\.png$/),je().max(Math.ceil(an.maxMapBytes/3)*4))}).strict()).max(an.maxPayloadRecords)}).strict();function lo(e,t=!1,n=0){if(n>30)throw Error("Material JSON exceeds nesting limit");if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"&&Number.isFinite(e))return;if(t&&e instanceof Uint8Array)return;if(!e||typeof e!=="object")throw Error("Material values must be plain JSON data");let i=Array.isArray(e),r=Object.getPrototypeOf(e);if(i?r!==Array.prototype:r!==Object.prototype&&r!==null)throw Error("Material values must have plain JSON prototypes");if(i&&e.length>1e4)throw Error("Material JSON array exceeds limit");for(let s of Reflect.ownKeys(e)){if(i&&s==="length")continue;if(typeof s!=="string"||["__proto__","prototype","constructor"].includes(s))throw Error("Material JSON contains a forbidden key");if(i&&(!/^(0|[1-9][0-9]*)$/.test(s)||Number(s)>=e.length))throw Error("Material arrays must contain only indexed data");let o=Object.getOwnPropertyDescriptor(e,s);if(!("value"in o)||!o.enumerable)throw Error("Material JSON accessors or hidden fields are not allowed");lo(o.value,t,n+1)}if(i&&Object.keys(e).length!==e.length)throw Error("Material JSON arrays must be dense")}function Fn(e){lo(e);let t=(n)=>Array.isArray(n)?n.map(t):n!==null&&typeof n==="object"?Object.fromEntries(Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)])):n;return JSON.stringify(t(e))}function nP(e){if(lo(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");let t=wa.parse(e);if(new Set(t.sources.map((r)=>r.id)).size!==t.sources.length)throw Error("Duplicate material source identity");if(new Set(t.maps.map((r)=>r.slot)).size!==t.maps.length)throw Error("Duplicate material map slot");let n=0,i=0;for(let r of t.maps){let s=r.slot==="baseColor"||r.slot==="emissive";if(r.file!==`${r.slot}.png`||r.usage!==ob[r.slot]||r.colorSpace!==(s?"srgb":"linear"))throw Error("Material map filename, usage or color convention mismatch");if(r.slot==="normal"!==(r.normalConvention==="opengl")||r.slot==="metallicRoughness"!==(r.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map convention is missing or invalid");let o=t.sources.find((a)=>a.id===r.sourceId);if(!o)throw Error("Material map source is missing");if(r.procedural){if(r.procedural.derive&&r.slot!=="normal")throw Error("Height derivation requires a normal map slot");if(Fn(r.procedural.spec)!==Fn(xa(r.procedural.spec)))throw Error("Stored procedural material recipe must be canonical");if(o.kind==="generated")throw Error("A recipe map cannot use a generated source; use a procedural source");if(o.kind!=="procedural"||r.originalFile||r.procedural.spec.usage!==r.usage||r.procedural.spec.size!==r.width||r.width!==r.height)throw Error("Procedural material source or map convention mismatch")}else if(o.kind==="procedural"||!o.originalFiles.some((a)=>a.name===r.originalFile))throw Error("Material map must reference an original source file");n+=r.bytes,i+=r.width*r.height}if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte or pixel budget");return t}var ao=ib(Aa),co={when:(e)=>!e.issues.length},ub=(e)=>e instanceof Error?e.message:String(e);function Ea(e,t,n){return(i,r)=>{try{let s=t(i);if(n&&Fn(i)!==Fn(s))r.addIssue({code:"custom",message:`${e} must be stored in canonical form.`})}catch(s){r.addIssue({code:"custom",message:ub(s)})}}}var hb=ao.portableSamplerSchema.superRefine(Ea("sampler",Tl,!0),co),iP=ao.canonicalProceduralTextureSpecV3Schema.superRefine(Ea("procedural V3 spec",cf,!0),co),rP=ao.canonicalTextureAtlasSpecV1Schema.superRefine(Ea("atlas spec",Ma,!0),co),sP=ao.textureAtlasManifestV1Schema,oP=_e({resourceId:oo,revisionId:bn,sha256:bn}).strict().refine((e)=>e.sha256===e.revisionId,"Material pin hash must match revision"),aP=oi("kind",[_e({kind:Ne("procedural"),compilerId:xt(["kiln.procedural-texture.v2",ro]),spec:eo([Aa,iP]),recipeHash:bn,pixelHash:bn,encoder:_e({name:Ne("sharp"),version:mn}).strict(),derive:xf.optional()}).strict(),_e({kind:Ne("atlas"),compilerId:xt(Rl),spec:rP,manifest:sP,encoder:_e({name:Ne("sharp"),version:mn}).strict()}).strict().superRefine((e,t)=>{try{if(mf(e.manifest,e.spec),e.compilerId!==e.manifest.compilerId)throw Error(`recipe compilerId ${e.compilerId} does not match the manifest's ${e.manifest.compilerId}.`)}catch(n){t.addIssue({code:"custom",message:`stored atlas manifest: ${ub(n)}`})}},co)]),db=wa.omit({schemaVersion:!0,maps:!0}).extend({schemaVersion:Ne(2),dependencies:ht(oP).max(16),maps:ht(wa.shape.maps.element.omit({procedural:!0}).extend({sampler:hb,pixelHash:bn,recipe:aP.optional()}).strict()).min(1).max(5)}).strict(),cP=oi("schemaVersion",[wa,db]),lP=_f.extend({schemaVersion:Ne(2),records:ht(_f.shape.records.element.extend({manifest:cP}).strict()).max(an.maxPayloadRecords)}).strict(),fb=oi("schemaVersion",[_f,lP]);function pb(e){return e.schemaVersion===1?[]:e.dependencies.map((t)=>({...t}))}var uP=gf.extend({schemaVersion:Ne(2),maps:ht(gf.shape.maps.element.omit({procedural:!0}).extend({sampler:hb,procedural:eo([Aa,ao.proceduralTextureSpecV3Schema.superRefine(Ea("procedural V3 spec",cf,!1),co)]).optional(),atlas:ao.textureAtlasSpecV1Schema.superRefine(Ea("atlas spec",Ma,!1),co).optional()}).strict().refine((e)=>e.procedural!==void 0!==(e.atlas!==void 0),"Supply exactly one procedural or atlas recipe")).min(1).max(5)}).strict(),KO=eo([gf,uP]);function yf(e){if(lo(e),new TextEncoder().encode(JSON.stringify(e)).length>an.maxManifestBytes)throw Error("Material manifest exceeds size limit");if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Invalid material manifest");if(e.schemaVersion===1)return nP(e);let t=db.parse(e);if(new Set(t.sources.map((o)=>o.id)).size!==t.sources.length||new Set(t.maps.map((o)=>o.slot)).size!==t.maps.length)throw Error("Duplicate material source or slot");let n=0,i=0,r=new Map;for(let o of t.maps){let a=t.sources.find((l)=>l.id===o.sourceId);if(!a||o.file!==`${o.slot}.png`||o.usage!==ob[o.slot]||o.colorSpace!==(o.slot==="baseColor"||o.slot==="emissive"?"srgb":"linear")||o.slot==="normal"!==(o.normalConvention==="opengl")||o.slot==="metallicRoughness"!==(o.channelPacking==="r-occlusion-g-roughness-b-metallic"))throw Error("Material map source/usage/convention mismatch");let c=o.recipe;if(c){if(a.kind==="generated")throw Error("A recipe map cannot use a generated source; use a procedural source");if(a.kind!=="procedural"||o.originalFile)throw Error("Procedural/atlas map source convention mismatch");if(c.kind==="procedural"){let l=c.spec;if(l.schemaVersion===3){if(c.compilerId!==ro||l.width!==o.width||l.height!==o.height)throw Error("V3 compiler/dimensions mismatch")}else if(c.compilerId!=="kiln.procedural-texture.v2"||l.size!==o.width||o.width!==o.height||Fn(l)!==Fn(xa(l)))throw Error("V2 compiler/canonical recipe dimensions mismatch");if(l.usage!==o.usage||c.pixelHash!==o.pixelHash||c.derive&&o.slot!=="normal")throw Error("Procedural recipe pixel/usage mismatch")}else{if(mf(c.manifest,c.spec),c.spec.width!==o.width||c.spec.height!==o.height||c.spec.usage!==o.usage||Fn(c.spec.sampler)!==Fn(o.sampler)||c.manifest.decodedPixelHash!==o.pixelHash)throw Error("Atlas recipe map mismatch");for(let l of c.spec.regions)if(l.source.kind==="resource"){let u=l.source.pin;r.set(`${u.resourceId}/${u.revisionId}`,u)}}}else if(a.kind==="procedural"||!a.originalFiles.some((l)=>l.name===o.originalFile))throw Error(`${a.kind==="generated"?"Generated":"External"} material source original file missing`);n+=o.bytes,i+=o.width*o.height}let s=t.dependencies.map((o)=>`${o.resourceId}/${o.revisionId}`);if(new Set(s).size!==s.length||s.length!==r.size||s.some((o)=>!r.has(o)))throw Error("Material dependency pin inventory mismatch");if(n>an.maxRecordBytes||i>an.maxRecordPixels)throw Error("Material record exceeds byte/pixel budget");return structuredClone(t)}var Cl=67108864,vf=je().regex(/^[a-z][a-z0-9_-]{0,79}$/),hP=je().regex(/^sha256:[a-f0-9]{64}$/),bf=_e({version:Ne("kiln.asset.v1"),assetId:vf,revisionId:vf,parentRevision:vf.optional(),name:je().min(1).max(200),tags:ht(je().max(80)).max(30),createdAt:je().datetime(),description:je().max(4000).optional(),brief:je().max(8000).optional(),attribution:_e({model:je().max(200).optional(),harness:je().max(200).optional(),author:je().max(200).optional()}).optional(),editable:ns(),files:gl(je(),_e({sha256:hP,bytes:Ue().int().nonnegative().max(Cl)})),build:_e({engine:je(),options:gl(je(),Pr()),warnings:ht(je()),integration:Pr().optional(),qa:Pr().optional(),composition:Pr().optional(),dependencies:ht(Pr()).optional(),rebuild:xt(["engine-required","external-dependencies-required"])}).optional(),preview:_e({fidelity:Pr().optional(),error:je().optional(),backdrop:xt(yv).optional()}).optional()}),dP="materials.kiln.json",fP=25165824;function pP(e){let t=new Map;for(let n of e.manifest.build?.dependencies??[]){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("Invalid saved asset dependency");let i=n;if(i.kind!=="kiln.material.v1"&&i.kind!=="kiln.material.v2"){if(i.delivery==="runtime")throw Error("Unsupported runtime dependency");if(i.delivery!=="embedded")throw Error("Unsupported saved asset dependency");continue}if(i.delivery!=="runtime")throw Error("Invalid saved material dependency");let r=yf(i.manifest);if(i.kind!==`kiln.material.v${r.schemaVersion}`)throw Error("Saved material dependency kind/version mismatch");let s=`${r.materialId}/${r.revisionId}`,o=t.get(s);if(o&&Fn(o)!==Fn(r))throw Error("Conflicting saved material dependency manifests");if(t.set(s,r),t.size>an.maxPayloadRecords)throw Error("Saved asset material dependency count exceeds limit")}return[...t.values()]}function mb(e,t=!1){let n=pP(e),i=new Map(n.map((d)=>[`${d.materialId}/${d.revisionId}`,Fn(d)]));if(!e.materialResources){if(t&&i.size)throw Error("Editable asset material closure unavailable");return}lo(e.materialResources);let r=fb.parse(e.materialResources),s=0,o=0,a=new Map;for(let d of r.records){let h=yf(d.manifest),f=`${d.manifest.materialId}/${d.manifest.revisionId}`;if(a.has(f)||i.has(f)&&i.get(f)!==Fn(h))throw Error("Asset material closure mismatch");if(a.set(f,h),Object.keys(d.files).length!==d.manifest.maps.length)throw Error("Asset material map inventory mismatch");for(let m of d.manifest.maps){if(d.files[m.file]?.length!==Math.ceil(m.bytes/3)*4)throw Error("Asset material map size mismatch");s+=m.bytes,o+=m.width*m.height}}if(s>an.maxPayloadBytes||o>an.maxPayloadPixels)throw Error("Asset material closure exceeds allocation limits");let c=new Set,l=new Set,u=(d)=>{if(l.has(d))throw Error("Asset material closure contains a cycle");if(c.has(d))return;let h=a.get(d);if(!h)throw Error("Asset material closure incomplete");l.add(d);for(let f of pb(h))u(`${f.resourceId}/${f.revisionId}`);l.delete(d),c.add(d)};for(let d of i.keys())u(d);if(c.size!==a.size)throw Error("Asset material closure has unrelated records")}var mP=new Set(["asset.glb","source.kiln.js","preview.png"]);function gP(e){let t=bf.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(!mP.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>Cl||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");Sf(e.files["asset.glb"]),mb(e)}function Sf(e){if(e.length<20||e.length>Cl)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 gb(e){if(!e.length||e.length>100)throw Error("Bundle requires 1..100 revisions");let t={},n=0;for(let i of e){gP(i),mb(i,!0);let r=`${i.manifest.assetId}/${i.manifest.revisionId}/`;if(t[`${r}manifest.json`])throw Error("Duplicate bundle revision");t[`${r}manifest.json`]=new TextEncoder().encode(JSON.stringify(i.manifest,null,2));for(let[s,o]of Object.entries(i.files))t[r+s]=o;if(i.materialResources){let s=new TextEncoder().encode(JSON.stringify(i.materialResources));if(s.length>fP)throw Error("Asset material payload exceeds byte limit");t[r+dP]=s}}for(let i of Object.values(t))n+=i.length;if(n>Cl)throw Error("Bundle exceeds 64 MiB");return Fv(t,{level:0})}function Li(e){let t=new Set,n=new Set,i=new Set;e.traverse((r)=>{let s=r;if(!s.isMesh)return;t.add(s.geometry);for(let o of Array.isArray(s.material)?s.material:[s.material]){n.add(o);for(let a of Object.values(o))if(a instanceof Nt)i.add(a)}});for(let r of[...t,...n,...i])r.dispose()}async function _b(e){Sf(e);let t=new Bo,n=!1;t.onError=()=>{n=!0},t.addHandler(/^data:image\//,new Bs(t)),t.setURLModifier((s)=>{if(!s.startsWith("blob:")&&!s.startsWith("data:"))throw Error("External model resources are not loaded");return s});let i=new jh(t);i.register((s)=>({name:"KILN_embedded_images",async beforeRoot(){for(let o of s.json.images??[]){if(o.bufferView===void 0)continue;let a=new Uint8Array(await s.getDependency("bufferView",o.bufferView)),c="";for(let l=0;l<a.length;l+=8192)c+=String.fromCharCode(...a.subarray(l,l+8192));if(!/^image\/(png|jpeg|webp|avif)$/.test(o.mimeType??""))throw Error("Unsupported embedded image type");o.uri=`data:${o.mimeType};base64,${btoa(c)}`,delete o.bufferView}}}));let r=await i.parseAsync(Uint8Array.from(e).buffer,"");if(n){for(let s of r.scenes)Li(s);throw Error("An embedded texture could not be decoded.")}return Object.assign(r,{assertTexturesLoaded(){if(n)throw Error("An embedded texture could not be decoded.")}})}function xb(e,t,n=40,i=[e]){let r=e.getCenter(new U),s=Math.max(e.getSize(new U).length()/2,0.01),o=new U(1,0.65,1.25).normalize(),a=new U().crossVectors(new U(0,1,0),o).normalize(),c=new U().crossVectors(o,a),l=[];for(let S of i.length?i:[e])for(let T of[S.min.x,S.max.x])for(let y of[S.min.y,S.max.y])for(let w of[S.min.z,S.max.z])l.push(new U(T,y,w));let u=1/0,d=-1/0,h=1/0,f=-1/0;for(let S of l){let T=S.clone().sub(r),y=T.dot(a),w=T.dot(c);u=Math.min(u,y),d=Math.max(d,y),h=Math.min(h,w),f=Math.max(f,w)}r.addScaledVector(a,(u+d)/2),r.addScaledVector(c,(h+f)/2);let m=Math.tan(n*Math.PI/360),_=m*t,p=s;for(let S of l){let T=S.clone().sub(r),y=T.dot(o);p=Math.max(p,y+Math.abs(T.dot(a))*1.12/_,y+Math.abs(T.dot(c))*1.12/m)}let g=r.clone().addScaledVector(o,p);return{center:r,radius:s,distance:p,position:g}}function Mf(e,t){return{position:e.position.clone(),target:t.clone()}}function wf(e,t,n,i){e.position.copy(n.position),t.copy(n.target);let r=Math.max(i.getSize(new U).length(),0.001);e.near=Math.min(0.01,Math.max(r/1e5,0.00001)),e.far=Math.max(e.position.distanceTo(i.getCenter(new U))+r*20,10),e.updateProjectionMatrix()}function yb(e,t,n){let i=e.getWorldDirection(new U);if(i.y=0,i.lengthSq()<0.00000001)i.set(0,0,-1);i.normalize();let r=i.clone().cross(new U(0,1,0)),s=new U;if(t.has("KeyW")||t.has("ArrowUp"))s.add(i);if(t.has("KeyS")||t.has("ArrowDown"))s.sub(i);if(t.has("KeyD")||t.has("ArrowRight"))s.add(r);if(t.has("KeyA")||t.has("ArrowLeft"))s.sub(r);if(t.has("KeyE"))s.y++;if(t.has("KeyQ"))s.y--;return s.normalize().multiplyScalar(n)}function vb(e){let t=e.filter((i)=>Number.isFinite(i)&&i>0).sort((i,r)=>i-r);if(!t.length)throw Error("No frame timing evidence was collected.");let n=(i)=>t[Math.max(0,Math.ceil(t.length*i)-1)];return{samples:t.length,min:t[0],p50:n(0.5),p95:n(0.95),max:t.at(-1)}}function bb(e,t,n){if(t())return e;n(e);return}function Pl(e,t){let n=e.parser.json.nodes??[],i=new Set;if(n.forEach((s,o)=>{if(s?.extensions?.KHR_node_visibility?.visible===!1)i.add(o)}),i.size===0)return 0;let r=0;for(let s of t)s.traverse((o)=>{let a=e.parser.associations.get(o)?.nodes;if(a===void 0||!i.has(a))return;o.visible=!1,r++});return r}function Il(e){let t=!1;if(e.traverse((s)=>{if(!s.visible)t=!0}),!t)return new Gt().setFromObject(e,!0);e.updateWorldMatrix(!0,!0);let n=new Gt,i=new Gt,r=new U;return e.traverseVisible((s)=>{let o=s,a=o.geometry;if(!a)return;let c=a.getAttribute("position");if(c&&o.isInstancedMesh!==!0){for(let u=0;u<c.count;u++){if(o.isMesh)o.getVertexPosition(u,r);else r.fromBufferAttribute(c,u);n.expandByPoint(r.applyMatrix4(s.matrixWorld))}return}let l=s;if(l.boundingBox!==void 0){if(l.boundingBox===null)l.computeBoundingBox();i.copy(l.boundingBox)}else{if(a.boundingBox===null)a.computeBoundingBox();i.copy(a.boundingBox)}n.union(i.applyMatrix4(s.matrixWorld))}),n.isEmpty()?new Gt().setFromObject(e,!0):n}function Ta(e){let t=0;return e.traverseVisible((n)=>{let i=n;if(!i.isMesh)return;let r=i.geometry.index?.count??i.geometry.attributes.position?.count??0;t+=r/3*(i.isInstancedMesh?i.count:1)}),t}async function Sb(e){let t=e.parser.json.nodes??[],n=new Map;e.scene.traverse((c)=>{let l=e.parser.associations.get(c)?.nodes;if(l!==void 0&&!n.has(l))n.set(l,c)});let i=new Set,r=[];for(let[c,l]of n){let u=t[c]?.extensions?.MSFT_lod?.ids;if(!Array.isArray(u)||u.length===0)continue;if(u.some((m)=>!Number.isInteger(m)||!t[m]||n.has(m)))continue;let d=l.parent;while(d&&!i.has(d))d=d.parent;if(d)continue;let h=[l];for(let m of u)h.push(await e.parser.getDependency("node",m));Pl(e,h.slice(1)),i.add(l);let f=(l.name.replace(/[_ -]?LOD0$/i,"")||l.parent?.name||`Part ${c}`).replace(/^Mesh_/,"");r.push({id:String(c),label:f,levels:h})}if(r.length===0)return;let s=Ta(e.scene)-r.reduce((c,l)=>c+Ef(l,0),0),o=Math.max(...r.map((c)=>c.levels.length)),a=Array.from({length:o},(c,l)=>s+r.reduce((u,d)=>u+Ef(d,l),0));return{chains:r,triangles:a}}var Mb=(e,t)=>e.levels[Math.min(Math.max(Number.isFinite(t)?Math.floor(t):0,0),e.levels.length-1)];function Ef(e,t){let n=e.levels.find((i)=>i.parent)?.parent;while(n){if(!n.visible)return 0;n=n.parent}return Ta(Mb(e,t))}function wb(e,t){let n=Mb(e,t),i=e.levels.find((s)=>s.parent!==null);if(!i||i===n)return;let r=i.parent;r.children[r.children.indexOf(i)]=n,n.parent=r,i.parent=null}function Eb(e,t){for(let n of e.chains)wb(n,t)}function Ab(e,t,n){let i=e.chains.find((r)=>r.id===t);if(!i)return!1;return wb(i,n),!0}function Tb(e,t){if(!e)return;return{triangles:Ta(t),levels:e.triangles,chains:e.chains.map((n)=>({id:n.id,label:n.label,level:n.levels.findIndex((i)=>i.parent!==null),triangles:n.levels.map((i,r)=>Ef(n,r))}))}}function uo(e){return(e?.chains??[]).flatMap((t)=>t.levels.filter((n)=>n.parent===null))}function Rb(e){let t=new Uh({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 Us,i=new Vt(40,1,0.01,1000),r=new zh(i,t.domElement);r.enableDamping=!0,t.domElement.tabIndex=0,t.domElement.setAttribute("aria-label","Interactive 3D asset. Drag to orbit or use Explore navigation.");let s=new Set,o=!1,a=1,c=new Set(["KeyW","KeyA","KeyS","KeyD","KeyQ","KeyE","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","ShiftLeft","ShiftRight"]),l=(P)=>{if(!o||!c.has(P.code))return;P.preventDefault(),s.add(P.code)},u=(P)=>s.delete(P.code),d=()=>s.clear();t.domElement.addEventListener("keydown",l),t.domElement.addEventListener("keyup",u),t.domElement.addEventListener("blur",d);let h=new jo(t),f=new Bh,m=h.fromScene(f,0.04);n.environment=m.texture,f.dispose(),h.dispose();let _=new Hs(16773591,2.4);_.position.set(4,8,5),n.add(_),n.add(new Pc(14806490,5065021,1.7));let p,g,S,T=[],y=!0,w=performance.now(),A=0,R=0,x=!1,M,k,C,L=(P)=>{if(!C)return;clearTimeout(C.timeout),C.reject(Error(P)),C=void 0},K=(P)=>{let j=t.getContext(),z=j.getExtension("WEBGL_debug_renderer_info");return{version:"kiln.viewer-performance.v1",measuredAt:new Date().toISOString(),windowMs:P-C.started,frameMs:vb(C.samples),...k===void 0?{}:{loadToFirstFrameMs:k},drawCalls:t.info.render.calls,triangles:t.info.render.triangles,lines:t.info.render.lines,points:t.info.render.points,geometryObjects:t.info.memory.geometries,textureObjects:t.info.memory.textures,shaderPrograms:t.info.programs?.length??0,viewport:{cssWidth:e.clientWidth,cssHeight:e.clientHeight,bufferWidth:t.domElement.width,bufferHeight:t.domElement.height,devicePixelRatio:t.getPixelRatio()},renderer:{version:String(j.getParameter(j.VERSION)),vendor:String(j.getParameter(j.VENDOR)),renderer:String(j.getParameter(j.RENDERER)),browser:navigator.userAgent,...z?{unmaskedVendor:String(j.getParameter(z.UNMASKED_VENDOR_WEBGL)),unmaskedRenderer:String(j.getParameter(z.UNMASKED_RENDERER_WEBGL))}:{}},camera:{position:i.position.toArray(),target:r.target.toArray(),fov:i.fov},limitations:["Exploratory measurement: workloads outside this page are uncontrolled. This is not an isolated performance baseline or budget acceptance.","Frame intervals measure browser requestAnimationFrame pacing, including scheduling and vertical sync; they are not GPU execution time.","Load-to-first-frame begins at GLB parsing and ends after the first render submission; it excludes download time and does not measure presentation latency.","Draw and resource counts come from this Three.js renderer, including studio lighting resources. Object counts are not GPU memory bytes.","This receipt describes this viewport, camera and device only. It is not a performance qualification for other consumers or hardware."]}},I=()=>{if(!p)return;let P=Il(p),j=[];p.traverseVisible((ue)=>{if(ue instanceof wt||ue instanceof yr||ue instanceof zs){let Ve=new Gt().setFromObject(ue,!0);if(!Ve.isEmpty())j.push(Ve)}});let{center:z,radius:q,distance:Q,position:Me}=xb(P,i.aspect,i.fov,j);if(r.target.copy(z),i.position.copy(Me),i.near=Math.max(q/1000,0.0001),i.far=Q+q*100,r.minDistance=q*0.1,r.maxDistance=q*80,a=Math.max(q*0.35,0.01),o)r.minDistance=q*0.00001;i.updateProjectionMatrix(),r.update()},G=new ResizeObserver(()=>{let{clientWidth:P,clientHeight:j}=e;if(!P||!j)return;t.setSize(P,j),i.aspect=P/j,i.updateProjectionMatrix()});G.observe(e);let X=(P)=>{if(x)return;let j=Math.min((P-w)/1000,0.1);if(w=P,e.clientWidth&&e.clientHeight){if(y)S?.update(j);if(o&&s.size){let z=yb(i,s,j*a*(s.has("ShiftLeft")||s.has("ShiftRight")?3:1));i.position.add(z),r.target.add(z)}if(r.update(),t.render(n,i),M!==void 0)k=performance.now()-M,M=void 0;if(C){if(C.previous>0&&C.samples.length<1800)C.samples.push(P-C.previous);if(C.previous=P,P-C.started>=C.duration&&C.samples.length){let z=K(P);clearTimeout(C.timeout),C.resolve(z),C=void 0}}}else s.clear(),L("Keep the measured viewport visible for the complete sampling window.");A=requestAnimationFrame(X)};return A=requestAnimationFrame(X),{async load(P,j={}){let z=performance.now(),q=++R;L("The artifact changed during measurement. Measure the new revision again.");let Q=await _b(P);Pl(Q,[Q.scene]);let Me=await Sb(Q);try{Q.assertTexturesLoaded()}catch(ye){Li(Q.scene);for(let Ee of uo(Me))Li(Ee);throw ye}let ue=bb(Q,()=>!x&&q===R&&j.isCurrent?.()!==!1,(ye)=>{Li(ye.scene);for(let Ee of uo(Me))Li(Ee)});if(!ue)return;let Ve=p&&j.preserveView?Mf(i,r.target):void 0;if(p){S?.stopAllAction(),S?.uncacheRoot(p),n.remove(p),Li(p);for(let ye of uo(g))Li(ye)}p=ue.scene,g=Me,M=z,k=void 0,n.add(p),T=ue.animations,S=new Dc(p),y=!0;let{clientWidth:we,clientHeight:Z}=e;if(t.setSize(we,Z),i.aspect=we&&Z?we/Z:i.aspect,I(),Ve)wf(i,r.target,Ve,Il(p)),r.update();let re=0,se=new Set;return p.traverseVisible((ye)=>{let Ee=ye;if(!Ee.isMesh)return;re++;for(let Ae of Array.isArray(Ee.material)?Ee.material:[Ee.material])se.add(Ae)}),j.onCommit?.(),{triangles:Ta(p),meshes:re,materials:se.size,clips:T.map((ye)=>ye.name),...g?{levels:g.triangles}:{}}},level(P){if(L("The level of detail changed. Measure the displayed combination again."),g)Eb(g,P)},partLevel(P,j){if(L("The level of detail changed. Measure the displayed combination again."),g)Ab(g,P,j)},lod(){return p?Tb(g,p):void 0},reset:I,cancelMeasurement:L,measure(P=3000){if(x||!p||!e.clientWidth||!e.clientHeight)return Promise.reject(Error("Load an artifact in a visible viewport before measuring."));if(!Number.isFinite(P)||P<1000||P>5000)return Promise.reject(Error("Measurement duration must be 1–5 seconds."));if(C)return Promise.reject(Error("A measurement is already running."));return new Promise((j,z)=>{C={started:performance.now(),previous:0,duration:P,samples:[],resolve:j,reject:z,timeout:setTimeout(()=>L("Measurement was interrupted or the browser stopped delivering frames."),P+2000)}})},view(){return Mf(i,r.target)},setView(P){if(!p)return;wf(i,r.target,P,Il(p)),r.update()},navigation(P){if(o=P==="explore",s.clear(),r.minDistance=o?0.00001:a/3.5,o)i.near=0.0001,i.updateProjectionMatrix()},wire(P){for(let j of p?[p,...uo(g)]:[])j.traverse((z)=>{let q=z;if(q.isMesh){for(let Q of Array.isArray(q.material)?q.material:[q.material])if("wireframe"in Q)Q.wireframe=P}})},lighting(P){t.toneMappingExposure=P==="bright"?1.65:P==="soft"?0.85:1.15,_.intensity=P==="soft"?0.8:2.4},clip(P){if(S?.stopAllAction(),T[P])S?.clipAction(T[P]).play()},pause(P){y=!P},dispose(){if(L("The viewport closed before measurement finished."),x=!0,R++,cancelAnimationFrame(A),G.disconnect(),r.dispose(),t.domElement.removeEventListener("keydown",l),t.domElement.removeEventListener("keyup",u),t.domElement.removeEventListener("blur",d),p)Li(p);for(let P of uo(g))Li(P);m.dispose(),t.dispose(),e.replaceChildren()}}}var Cb=["127.0.0.1","localhost","[::1]"];async function Pb(e,t,n,i,r,s){let o="";for(let a=0;a<e.length;a+=8192)o+=String.fromCharCode(...e.subarray(a,a+8192));try{if((await i("ui/download-file",{contents:[{type:"resource",resource:{uri:`file:///${t}`,mimeType:n,blob:btoa(o)}}]}))?.isError)throw Error("The chat host could not download this file.");return{}}catch(a){if(a.code!==-32601)throw a;if(s){let d=new URL(s);if(d.protocol!=="https:"&&!(d.protocol==="http:"&&Cb.includes(d.hostname)))throw Error("Invalid host download URL");return{downloadUrl:d.href}}if(!r)throw a;let c=new File([Uint8Array.from(e)],t,{type:n}),{fileId:l}=await r.uploadFile(c),{downloadUrl:u}=await r.getFileDownloadUrl({fileId:l});if(new URL(u).protocol!=="https:")throw Error("Invalid host download URL");return{downloadUrl:u}}}var Lb=16777216,Nb=Math.ceil(Lb/3)*4,Yt=(e)=>{throw Error(`Asset transfer ${e}. Present the saved asset again or open it in Kiln; the saved files are unchanged.`)};function _P(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}function Ib(e){if(typeof e!=="string"||e.length>Nb)return Yt("exceeds the encoded size limit");if(e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))Yt("contains damaged base64 data");let t;try{t=atob(e)}catch{return Yt("contains damaged base64 data")}let n=Uint8Array.from(t,(i)=>i.charCodeAt(0));if(_P(n)!==e)Yt("contains noncanonical base64 data");return n}function Ra(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}async function Db(e){if(!Ra(e))return Yt("metadata is missing");if(typeof e.error==="string")throw Error(e.error);let t=bf.safeParse(e.manifest);if(!t.success||!Ra(e.files))return Yt("metadata is malformed");let n=t.data,i=Object.entries(e.files);if(!i.length||i.length>16||!Object.hasOwn(e.files,"asset.glb"))return Yt("file list is missing or invalid");let r=0,s=0;for(let[c,l]of i){if(!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(c)||!Object.hasOwn(n.files,c))return Yt("file metadata is missing");if(r+=n.files[c].bytes,r>Lb)return Yt("exceeds the decoded size limit");let u=typeof l==="string"?l:Ra(l)?l.data:void 0;if(typeof u!=="string")return Yt("file encoding is malformed");if(s+=u.length,s>Nb)return Yt("exceeds the encoded size limit")}let o={};for(let[c,l]of i){let u=n.files[c],d;if(typeof l==="string")d=Ib(l);else{if(!Ra(l)||l.encoding!=="kiln.deflate-base64.v1")return Yt("encoding is unsupported");let m=Ib(l.data);try{d=Ov(m,{out:new Uint8Array(u.bytes+1)})}catch{return Yt("compressed data is damaged")}}if(d.length!==u.bytes)return Yt("byte count does not match the saved file");let h=await crypto.subtle.digest("SHA-256",Uint8Array.from(d));if(`sha256:${Array.from(new Uint8Array(h),(m)=>m.toString(16).padStart(2,"0")).join("")}`!==u.sha256)return Yt("integrity check failed");o[c]=d}for(let c of Object.keys(n.files))if(!Object.hasOwn(o,c))return Yt("is missing a saved file");let a={};if(e.downloadUrls!==void 0){if(!Ra(e.downloadUrls))return Yt("download metadata is malformed");for(let[c,l]of Object.entries(e.downloadUrls)){if(typeof l!=="string")return Yt("download metadata is malformed");a[c]=l}}return{record:{manifest:n,files:o},downloadUrls:a}}function Ob(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 kn=(e)=>document.getElementById(e),Ni=kn("status"),cn,Fb={},as,xP=0,Di=0,Ll=new Map;function kb(e,t){let n=++xP;return new Promise((i,r)=>{let s=setTimeout(()=>{Ll.delete(n),r(Error("Chat host did not respond."))},20000);Ll.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 Ub(e,t={}){window.parent.postMessage({jsonrpc:"2.0",method:e,params:t},"*")}function yP(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 vP(e){let t=++Di;cn=void 0,kn("stats").textContent="",kn("clips").hidden=!0;for(let n of document.querySelectorAll("button[data-download]"))n.disabled=!0;try{if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Asset transfer metadata is missing. Present the saved asset again.");await bP(e,t)}catch(n){if(t!==Di)return;Ni.textContent=n instanceof Error?n.message:"Asset transfer failed. Present the saved asset again."}}async function bP(e,t){if(e.isError){Ni.textContent=e.content?.find((i)=>i.type==="text")?.text??"This asset could not be opened.";return}let n;try{n=await Db(e._meta?.kilnAsset)}catch(i){if(t!==Di)return;Ni.textContent=i instanceof Error?i.message:"Asset transfer failed. Present the saved asset again.";return}if(t!==Di)return;cn=n.record,kn("name").textContent=cn.manifest.name,Fb=n.downloadUrls,kn("revision").textContent=`${cn.manifest.editable?"Editable source included":"GLB asset"} · ${cn.manifest.revisionId.slice(0,10)}`,kn("attribution").textContent=Ob(cn.manifest).map(({label:i,value:r})=>`${i}: ${r}`).join(" · ");try{as??=Rb(kn("stage"));let i=await as.load(cn.files["asset.glb"]);if(t!==Di)return;if(i){kn("stats").textContent=`${i.triangles.toLocaleString()} triangles · ${i.materials} materials · ${(cn.files["asset.glb"].length/1024).toFixed(0)} KB`;let r=kn("clips");r.replaceChildren(new Option("Rest pose","-1"),...i.clips.map((s,o)=>new Option(s,String(o)))),r.hidden=!i.clips.length}Ni.textContent="Drag to orbit · Scroll to zoom"}catch(i){if(t!==Di)return;as?.dispose(),as=void 0;let r=cn.files["preview.png"];if(r){let s=new Image;s.alt=`${cn.manifest.name} · saved preview image`,s.src=`data:image/png;base64,${yP(r)}`,kn("stage").replaceChildren(s)}Ni.textContent=`${r?"Showing saved preview. ":""}3D preview unavailable: ${String(i)}`}for(let i of document.querySelectorAll("button[data-download]"))i.disabled=!1;kn("source").hidden=!cn.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=Ll.get(t.id);if(Ll.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")vP(t.params);if(t.method==="ui/resource-teardown")as?.dispose(),window.parent.postMessage({jsonrpc:"2.0",id:t.id,result:{}},"*")});kn("reset").onclick=()=>as?.reset();kn("clips").onchange=(e)=>as?.clip(Number(e.target.value));for(let e of document.querySelectorAll("button[data-download]"))e.onclick=async()=>{if(!cn)return;let t=Di,n=e.dataset.download,i=n==="bundle"?"editable.zip":n==="source"?"source.kiln.js":"asset.glb",r=n==="bundle"?gb([cn]):cn.files[i],s=n==="bundle"?"application/zip":n==="source"?"text/javascript":"model/gltf-binary",o=cn.manifest.name.replace(/[^a-zA-Z0-9_-]+/g,"-").slice(0,80);e.disabled=!0,Ni.textContent="Requesting download…";try{let a=typeof window.openai?.uploadFile==="function"&&typeof window.openai?.getFileDownloadUrl==="function"?window.openai:void 0,c=await Pb(r,`${o}-${i}`,s,kb,a,Fb[i]);if(t!==Di)return;if(c.downloadUrl){let l=document.createElement("a");l.href=c.downloadUrl,l.textContent=`Save ${o}-${i}`,l.style.color="#d5f4a2",l.target="_blank",l.rel="noopener noreferrer",l.onclick=(u)=>{if(window.openai?.openExternal)u.preventDefault(),window.openai.openExternal({href:c.downloadUrl})},Ni.replaceChildren("Download ready. ",l)}else Ni.textContent="Download requested."}catch(a){if(t===Di)Ni.textContent=`Download unavailable in this host: ${a.message}`}finally{e.disabled=!cn||t!==Di}};kb("ui/initialize",{appInfo:{name:"Kiln Asset Viewer",version:"0.6.0"},appCapabilities:{},protocolVersion:"2026-01-26"}).then(()=>{Ub("ui/notifications/initialized"),Ub("ui/notifications/size-changed",{height:document.documentElement.scrollHeight})}).catch((e)=>{Ni.textContent=e.message});
</script>
</body>
diff --git a/docs/architecture.md b/docs/architecture.md
index 52e87805..35756fec 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -76,6 +76,6 @@ bun run test:coverage
Prepare the pinned historical corpus once with the explicit fetch command above.
Subsequent tests stay offline, pin CPU rendering and include those archived programs.
-The coverage ratchet lives in [scripts/check-coverage.mjs](https://github.com/instruktlabs/kiln/blob/main/scripts/check-coverage.mjs). Threshold decreases require an explicit measured rationale. Biome limits cognitive complexity to 100; `overrides` in `biome.json` hold each of the 13 existing functions above that at its current score, so they cannot grow. Lower a ceiling when its function is refactored. Live provider tests require an explicit opt-in.
+The coverage ratchet lives in [scripts/check-coverage.mjs](https://github.com/instruktlabs/kiln/blob/main/scripts/check-coverage.mjs). Threshold decreases require an explicit measured rationale. Biome limits cognitive complexity to 100; `overrides` in `biome.json` hold each of the 12 existing functions above that at its current score, so they cannot grow. Lower a ceiling when its function is refactored. Live provider tests require an explicit opt-in.
Core dependencies include Three.js, glTF Transform, Manifold, Acorn, and Zod. The agent SDK is an optional peer. Keep provider adapters compatible with the SDK's declared interface version; a TypeScript cast cannot fix a runtime protocol mismatch.
diff --git a/docs/projects-and-live-review.md b/docs/projects-and-live-review.md
index 2d1882d8..c150bdca 100644
--- a/docs/projects-and-live-review.md
+++ b/docs/projects-and-live-review.md
@@ -70,6 +70,44 @@ node kiln.mjs review save OPERATION_ID --expected OPERATION_REVISION --name "Rev
The default journal retains at most 200 operations and 256 MiB, including pinned operations. It reports overflow or unavailable observation storage without replacing the authoring result. Durable saved assets are separate and are not evicted by the journal. `KILN_LIVE_REVIEW=off` disables automatic observation for local authoring hosts. Feedback still belongs in the agent's existing conversation; launch, cancel, retry, pause and harness proxies are outside this foundation.
+## Modules composed together
+
+Modules saved separately can each pass their own QA and still collide once they stand together, because neither one contains both parts. A project declares that arrangement once, on its inventory: an item's optional `placement` says where its pinned revision sits in the project's shared frame.
+
+```json
+{ "id": "wall", "name": "Wall", "asset": { "collectionId": "project", "assetId": "wall", "revisionId": "r_..." }, "placement": {} }
+```
+
+`placement` holds optional `translation` (metres), `rotation` (Euler XYZ degrees, as Kiln's helpers) and `scale`, applied in the order scale, rotation, translation. Each defaults to identity, so `{}` states "at the shared origin". A missing placement means the item is **not composed**, never identity: most of a pack is unrelated props, and identity would report them all as overlapping at the origin. The field is omitted when absent, so existing project revisions keep their ids. It travels through project bundles, export and import, and the dashboard shows it in the Projects inventory and edits it in the configuration JSON. Linking or unlinking an asset keeps it.
+
+```sh
+node kiln.mjs project check pilot --revision REVISION
+```
+
+`kiln_project` action `check` is the same operation. It reads the exact pinned GLB of every placed item, composes them, and runs the part-volume and open-surface measurements over cross-module pairs only; overlaps inside one module belong to that module's own QA and spend no budget here. `overlaps` names the module and part on each side with shared volume and fraction, and `openSurfaces` names them with depth in metres. Both follow the same contact tolerances as normal QA, so a cloth resting on a neighbour's surface is silent.
+
+`coverage` says what the result can be read as, and only `complete` means every placed item and pair in scope was measured:
+
+| `coverage` | Meaning |
+| --- | --- |
+| `complete` | Every placed item loaded and no budget was reached. Open surfaces are still not measured against each other. |
+| `partial` | Something was not measured, and is named: a placed item in `unmeasured`, a part in `unmeasuredParts`, or `truncated` for a budget. |
+| `nothing-to-compare` | Fewer than two modules were composed. |
+| `failed` | The check itself could not run. This says nothing about the geometry. |
+
+An item in `unmeasured` is not certified clear. Its `reason` is `unpinned` (a placement with no linked revision), `unavailable` (the revision or its collection is not configured), `unreadable` (the bytes failed integrity or would not load) or `budget`. One check composes at most 64 modules, 256 MiB of GLBs and 4,096 parts, and the two passes keep their normal budgets. Items are loaded in inventory order until a budget is reached, and lists are capped with the remainder counted.
+
+A positive is a measurement, not a verdict, and the command exits 0 with findings. A fitting socketed into a neighbour's shell is reported exactly as a bolt in a hole is, so review the pairs you did not intend. The check is at rest and over visible static parts: instanced GLB nodes are expanded, but skinned and morph-deformed parts are named as unmeasured, and LOD alternates are left out. It reads saved GLBs, so a part is measured per glTF primitive. Kiln's builder writes one primitive per mesh node (0 of 20,569 nodes across 64 rendered examples had more), but in an imported GLB a closed part split across materials can read as open surfaces, which are not measured against each other.
+
+`kiln_save` and `kiln save` run the same measurement when the invocation's bound project pins this exact collection and asset at a stated placement. The report is returned as `composition` and recorded in the revision's `build.composition`. It measures the revision being saved in place of the item's older pin, marking that module `saved` because its revision id does not exist until the write, and it covers only pairs involving that asset; `project check` covers the rest. The save happens whatever the report says.
+
+These limits are deliberate:
+
+- A draft is not measured against its neighbours until it is saved. A draft has no inventory identity, and `kiln_render` and `kiln_edit` do not read sibling GLBs.
+- The first save of a new asset has no report, because no item can pin a revision that does not exist yet. Link it, then `project check` or save a child revision.
+- `kiln_review` exact saves and explicit migrations record no report, since they preserve a recorded build without evaluating again. Run `project check` after linking them.
+- A standalone asset has no neighbours. Omitting the project, `--no-project` and `projectId: null` produce no report and no warning, and nothing is inferred from other projects, names or the collection named `project`.
+
## Editable packages and runtime delivery
```sh
diff --git a/docs/tools.md b/docs/tools.md
index 97b6d140..c7a13772 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -1277,7 +1277,7 @@ Read a saved program revision without changing it. Returns exact source text in
## kiln_project
-Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded.
+Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded. check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict.
<details>
<summary>Input JSON Schema</summary>
@@ -1294,16 +1294,17 @@ Manage optional shared workspace projects: list discovers IDs; get reads the cur
"get",
"create",
"update",
- "export"
+ "export",
+ "check"
]
},
"projectId": {
- "description": "get, update, export.",
+ "description": "get, update, export, check.",
"type": "string",
"pattern": "^[a-z][a-z0-9_-]{0,79}$"
},
"revisionId": {
- "description": "get, export: an exact revision; omit for the current one.",
+ "description": "get, export, check: an exact revision; omit for the current one.",
"type": "string",
"pattern": "^r_[0-9]{10}_[a-f0-9]{64}$"
},
diff --git a/scripts/create-workspace.mjs b/scripts/create-workspace.mjs
index 862283f1..b8f5c758 100644
--- a/scripts/create-workspace.mjs
+++ b/scripts/create-workspace.mjs
@@ -400,7 +400,7 @@ Export any time: node kiln.mjs source PROGRAM_REF --out revised.kiln.js and node
## Projects and materials
-Standalone work needs no project. Omitted project selection stays standalone unless KILN_PROJECT is configured (kiln_discover capabilities shows it); --no-project or projectId: null overrides it. A project holds a shared brief, inventory, design profile and material pins; select it per call with --project or projectId. Read skills/kiln-author-asset/references/projects-and-materials.md before creating or updating one. The save collection named project is a destination, not membership.
+Standalone work needs no project. Omitted project selection stays standalone unless KILN_PROJECT is configured (kiln_discover capabilities shows it); --no-project or projectId: null overrides it. A project holds a shared brief, inventory, design profile and material pins; select it per call with --project or projectId. An inventory item that states a placement is measured against the other placed items by project check and on each save under that project; one that states none is not composed. Read skills/kiln-author-asset/references/projects-and-materials.md before creating or updating one. The save collection named project is a destination, not membership.
## Material-faithful views
diff --git a/skills/kiln-author-asset/references/projects-and-materials.md b/skills/kiln-author-asset/references/projects-and-materials.md
index 3bf12b2b..8be96791 100644
--- a/skills/kiln-author-asset/references/projects-and-materials.md
+++ b/skills/kiln-author-asset/references/projects-and-materials.md
@@ -178,6 +178,14 @@ Preserve the returned collection, asset and revision IDs. When an asset belongs
an inventory entry, bind that exact saved revision with a project update. A later
asset revision does not silently update the project inventory.
+When modules are composed, such as room pieces saved separately and assembled at one origin,
+state each item's `placement`: optional `translation` (metres), `rotation` (Euler XYZ degrees)
+and `scale`, with `{}` meaning the shared origin. Only items that state one are composed; a
+missing placement means not composed, never identity, so leave it off unrelated props. Then
+`project check ID` reports parts of different modules that share volume or where a cloth reaches
+inside a neighbour, and each save of a placed asset under its project returns the same report. A
+draft is not measured until it is saved. See `kiln-qa-asset/references/integration-checks.md`.
+
Deliver a standalone asset directly through its collection exports. When delivering
a pack, `project export ID --revision REVISION --profile editable|runtime --out FILE`
packages the linked saved inventory. Editable delivery needs source, build settings
diff --git a/skills/kiln-qa-asset/SKILL.md b/skills/kiln-qa-asset/SKILL.md
index d2a3ca75..853edd22 100644
--- a/skills/kiln-qa-asset/SKILL.md
+++ b/skills/kiln-qa-asset/SKILL.md
@@ -58,7 +58,8 @@ them by code, then review the pairs you did not intend. Vertices are the samples
thinner than the surface's own facet spacing can pass between two of them: `_TRUNCATED`
reports pairs left for budget and vertices whose side could not be settled, and `_UNMEASURED`
names parts that were not sampled at all. A clean result here is not a fit audit, and it says
-nothing about open surfaces meeting each other.
+nothing about open surfaces meeting each other. Both observations see one asset; modules composed
+in a project are measured against each other by the check in `references/integration-checks.md`.
`SWEEP_SELF_INTERSECTION` observes tight station curvature or intersecting
consecutive rings in a sweep/loft. Inspect the station and radius evidence. A
diff --git a/skills/kiln-qa-asset/references/integration-checks.md b/skills/kiln-qa-asset/references/integration-checks.md
index fb3c9c23..b51023a8 100644
--- a/skills/kiln-qa-asset/references/integration-checks.md
+++ b/skills/kiln-qa-asset/references/integration-checks.md
@@ -30,6 +30,12 @@ returns a resource for the bytes `kiln_save` would persist and writes nothing, a
`render REF --out x.glb` reaches the same bytes. A part summary cannot stand in for them, because one
merged mesh reports as one box whatever it contains.
+## Modules composed in a project
+
+An asset's own QA cannot see a neighbour. When modules saved separately stand together, measure them together: give each inventory item a `placement` (`{}` states the shared origin; a missing placement means not composed, never identity), then run `node kiln.mjs project check ID --revision REVISION` or `kiln_project { action: "check", projectId }`. Each `kiln_save` of a placed asset under its bound project also returns this as `composition`, measuring the revision being saved against the pinned neighbours, and records it in the build record.
+
+Read `coverage` before the findings: only `complete` means everything in scope was measured. `partial` names what was not, and an item in `unmeasured` is not certified clear. `overlaps` and `openSurfaces` name the module and part on each side with volume or depth. A positive is a measurement rather than a verdict: a fitting socketed into a neighbour's shell is reported as a bolt in a hole is. A draft is not measured until it is saved, and a standalone asset gets no report. Do not create a project or a placement to obtain one for an asset that stands alone.
+
## What to measure
| Question | Evidence |
diff --git a/src/assets.ts b/src/assets.ts
index bab0003c..0dcec6dc 100644
--- a/src/assets.ts
+++ b/src/assets.ts
@@ -45,6 +45,8 @@ export const assetManifestSchema = z.object({
warnings: z.array(z.string()),
integration: z.unknown().optional(),
qa: z.unknown().optional(),
+ /** ProjectCompositionReportV1: measured against the bound project's placed neighbours. */
+ composition: z.unknown().optional(),
dependencies: z.array(z.unknown()).optional(),
rebuild: z.enum(['engine-required', 'external-dependencies-required']),
})
diff --git a/src/generated/mcp-manifest.json b/src/generated/mcp-manifest.json
index 333e5743..228dd68c 100644
--- a/src/generated/mcp-manifest.json
+++ b/src/generated/mcp-manifest.json
@@ -1236,7 +1236,7 @@
},
{
"name": "kiln_project",
- "description": "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded.",
+ "description": "Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded. check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict.",
"inputSchema": {
"type": "object",
"properties": {
@@ -1247,16 +1247,17 @@
"get",
"create",
"update",
- "export"
+ "export",
+ "check"
]
},
"projectId": {
- "description": "get, update, export.",
+ "description": "get, update, export, check.",
"type": "string",
"pattern": "^[a-z][a-z0-9_-]{0,79}$"
},
"revisionId": {
- "description": "get, export: an exact revision; omit for the current one.",
+ "description": "get, export, check: an exact revision; omit for the current one.",
"type": "string",
"pattern": "^r_[0-9]{10}_[a-f0-9]{64}$"
},
diff --git a/src/project-cli.ts b/src/project-cli.ts
index d3c38408..bde4b3fe 100644
--- a/src/project-cli.ts
+++ b/src/project-cli.ts
@@ -28,6 +28,7 @@ PROJECTS
kiln project update <id> --expected <revision> --file <project-patch.json>
kiln project export <id> --out <project.zip> [--revision <revision>] [--profile editable|runtime]
kiln project import <project.zip> --id <new-project-id> --collection <collection> [--name <name>]
+ kiln project check <id> [--revision <revision>]
MATERIALS
kiln material presets [--tag <tag>]
@@ -56,6 +57,12 @@ selects a project; --no-project overrides that configured default. Use --materia
with an array of exact resourceId/revisionId/sha256 pins for standalone materials.
All commands return JSON; export refuses to overwrite an existing destination.
+Project check composes the inventory items that state a placement, at their exact pinned
+revisions, and reports parts of different modules that share volume or where an open surface
+reaches inside a neighbour. An item with no placement is not composed. A placed item it cannot
+read is reported unmeasured rather than clear. Findings are measurements, not verdicts, so the
+command exits 0 with them.
+
Material export --maps writes <id>.<slot>.png for each map at --size pixels square,
<id>.preview.png (the material on a lit plane repeated --tiles × --tiles, default 3)
and the <id>.maps.json sidecar: each map's slot, colour space, size, sha256 and how it
@@ -163,6 +170,40 @@ async function exportMaterialMapsCommand(
};
}
+/** The `kiln_project` call behind each CLI action that is not a bundle transfer. */
+async function projectToolCall(
+ action: string,
+ positional: readonly string[],
+ flags: Readonly<Record<string, string>>,
+): Promise<unknown> {
+ if (action === 'list') return { action: 'list' };
+ if (action === 'get' || action === 'check')
+ return {
+ action,
+ projectId: positional[0],
+ ...(flags.revision ? { revisionId: flags.revision } : {}),
+ };
+ if (action === 'create') {
+ if (flags.file && (flags.name || flags.id))
+ throw new Error('Use --file or --name with optional --id, not both');
+ if (!flags.file && !flags.name) throw new Error('project create requires --file or --name');
+ return {
+ action: 'create',
+ draft: flags.file
+ ? await jsonFile(flags.file, MAX_PROJECT_BYTES)
+ : { name: flags.name, ...(flags.id ? { projectId: flags.id } : {}) },
+ };
+ }
+ if (!flags.file || !flags.expected)
+ throw new Error('project update requires --expected and --file');
+ return {
+ action: 'update',
+ projectId: positional[0],
+ expectedRevision: flags.expected,
+ patch: await jsonFile(flags.file, MAX_PROJECT_BYTES),
+ };
+}
+
export async function projectMain(argv: readonly string[]): Promise<number> {
const [family, action] = argv;
if (argv.some((value) => value === '--help' || value === '-h')) {
@@ -173,7 +214,7 @@ export async function projectMain(argv: readonly string[]): Promise<number> {
throw new Error('Expected project or material command');
const supported =
family === 'project'
- ? ['list', 'get', 'create', 'update', 'export', 'import']
+ ? ['list', 'get', 'create', 'update', 'export', 'import', 'check']
: ['list', 'get', 'procedural', 'import', 'export', 'presets', 'create-preset'];
if (!action || !supported.includes(action))
throw new Error(`Unknown ${family} action. Run kiln ${family} --help.`);
@@ -184,6 +225,7 @@ export async function projectMain(argv: readonly string[]): Promise<number> {
'project:update': ['file', 'expected'],
'project:export': ['out', 'revision', 'profile'],
'project:import': ['id', 'collection', 'name'],
+ 'project:check': ['revision'],
'material:list': [],
'material:presets': ['tag'],
'material:create-preset': ['file'],
@@ -209,7 +251,7 @@ export async function projectMain(argv: readonly string[]): Promise<number> {
flags[key] = next;
}
const expectedArgs =
- action === 'get' || action === 'export'
+ action === 'get' || action === 'export' || action === 'check'
? family === 'project'
? 1
: 2
@@ -251,36 +293,10 @@ export async function projectMain(argv: readonly string[]): Promise<number> {
console.log(JSON.stringify({ ok: true, project }, null, 2));
return 0;
}
- const tool = createKilnProjectDef(store);
- let input: unknown;
- if (action === 'list') input = { action: 'list' };
- else if (action === 'get')
- input = {
- action: 'get',
- projectId: positional[0],
- ...(flags.revision ? { revisionId: flags.revision } : {}),
- };
- else if (action === 'create') {
- if (flags.file && (flags.name || flags.id))
- throw new Error('Use --file or --name with optional --id, not both');
- if (!flags.file && !flags.name) throw new Error('project create requires --file or --name');
- input = {
- action: 'create',
- draft: flags.file
- ? await jsonFile(flags.file, MAX_PROJECT_BYTES)
- : { name: flags.name, ...(flags.id ? { projectId: flags.id } : {}) },
- };
- } else {
- if (!flags.file || !flags.expected)
- throw new Error('project update requires --expected and --file');
- input = {
- action: 'update',
- projectId: positional[0],
- expectedRevision: flags.expected,
- patch: await jsonFile(flags.file, MAX_PROJECT_BYTES),
- };
- }
- console.log(JSON.stringify(await tool.run(input), null, 2));
+ const tool = createKilnProjectDef(store, undefined, localAssetLibrary());
+ console.log(
+ JSON.stringify(await tool.run(await projectToolCall(action, positional, flags)), null, 2),
+ );
return 0;
}
const materials = workspace.materials;
diff --git a/src/project-composition-tools.test.ts b/src/project-composition-tools.test.ts
new file mode 100644
index 00000000..21e6cb28
--- /dev/null
+++ b/src/project-composition-tools.test.ts
@@ -0,0 +1,363 @@
+/** #277 — the two surfaces of the composed check: an explicit one, and one recorded at save. */
+import { afterEach, expect, test } from 'bun:test';
+import { spawnSync } from 'node:child_process';
+import { mkdtemp, rm } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { z } from 'zod';
+import { FileAssetLibrary } from './assets-node';
+import { exportWorkspaceProjectBundle, importWorkspaceProjectBundle } from './project-bundle-node';
+import type { ProjectCompositionReportV1 } from './project-composition';
+import { MemoryProgramStore, retainProgram } from './program-store';
+import { renderGLBInProcess as render } from './render';
+import { createKilnProgramToolRegistry, type KilnToolContext } from './tools/registry';
+import { FileWorkspace } from './workspace-node';
+
+const box = (name: string, size: number[], at: number[]) =>
+ `createPart('${name}', boxGeo(${size.join(',')}), gameMaterial(0x888888), {parent: r, position: [${at.join(',')}]});`;
+const program = (name: string, ...parts: string[]) =>
+ `function build() { const r = createRoot('${name}'); ${parts.join(' ')} return r; }`;
+const THROW = program(
+ 'Throw',
+ `createPart('ThrowBlanket', planeGeo(1, 1, 8, 8), gameMaterial(0xaa4444), {parent: r, position: [0, 0.7, 0.4]});`,
+);
+const WALL = program('Wall', box('CurvedWall', [2, 1.4, 0.12], [0, 0.7, 0.4]));
+// The first revision of the throw stands clear of the wall; the revision being saved does not.
+const THROW_CLEAR = program(
+ 'Throw',
+ `createPart('ThrowBlanket', planeGeo(1, 1, 8, 8), gameMaterial(0xaa4444), {parent: r, position: [0, 0.7, 3]});`,
+);
+const roots: string[] = [];
+afterEach(async () => {
+ for (const root of roots.splice(0)) await rm(root, { recursive: true, force: true });
+});
+
+/** A workspace holding a wall and the clear throw, and the throw's pin at that revision. */
+async function fixture() {
+ const root = await mkdtemp(join(tmpdir(), 'kiln-composition-tools-'));
+ roots.push(root);
+ const workspace = new FileWorkspace(root);
+ const assetLibrary = new FileAssetLibrary({ project: join(root, 'saved') });
+ const programStore = new MemoryProgramStore();
+ const pin = (assetId: string, revisionId: string) => ({
+ collectionId: 'project',
+ assetId,
+ revisionId,
+ });
+ const context = {
+ workspace,
+ projectStore: workspace.projects,
+ assetLibrary,
+ programStore,
+ } satisfies KilnToolContext;
+ const tools = createKilnProgramToolRegistry(context);
+ const tool = (name: string) => tools.find((def) => def.name === name)!;
+ // Saved through the tool, so a revision has the source and receipt a child revision needs.
+ const saved = async (code: string, name: string, assetId: string) =>
+ pin(
+ assetId,
+ (
+ (await tool('kiln_save').run({
+ programRef: await retainProgram(programStore, code),
+ name,
+ assetId,
+ })) as { asset: { revisionId: string } }
+ ).asset.revisionId,
+ );
+ return {
+ root,
+ workspace,
+ assetLibrary,
+ programStore,
+ tool,
+ wall: await saved(WALL, 'Wall', 'wall'),
+ throwPin: await saved(THROW_CLEAR, 'Throw', 'throw'),
+ refs: {
+ throw: await retainProgram(programStore, THROW),
+ },
+ };
+}
+type Fixture = Awaited<ReturnType<typeof fixture>>;
+
+const placedProject = (f: Fixture, projectId = 'cove') =>
+ f.workspace.projects.create({
+ projectId,
+ name: 'Cove',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ { id: 'throw', name: 'Throw', asset: f.throwPin, placement: {} },
+ ],
+ });
+
+interface SaveResult {
+ composition?: ProjectCompositionReportV1;
+ asset: { revisionId: string };
+}
+const saveThrow = (f: Fixture, extra: Record<string, unknown> = {}) =>
+ f.tool('kiln_save').run({
+ programRef: f.refs.throw,
+ name: 'Throw',
+ assetId: 'throw',
+ parentRevision: f.throwPin.revisionId,
+ ...extra,
+ }) as Promise<SaveResult>;
+
+test('kiln_project check measures the current revision or an exact historical one', async () => {
+ const f = await fixture();
+ // A throw placed through the wall in its first revision, moved clear in the second.
+ const throwNow = await f.assetLibrary.save('project', {
+ name: 'Through',
+ assetId: 'through',
+ glb: (await render(THROW)).glb,
+ });
+ const through = { collectionId: 'project', assetId: 'through', revisionId: throwNow.revisionId };
+ const first = await f.workspace.projects.create({
+ projectId: 'cove',
+ name: 'Cove',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ { id: 'cloth', name: 'Cloth', asset: through, placement: {} },
+ ],
+ });
+ const second = await f.workspace.projects.update('cove', first.revisionId, {
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ { id: 'cloth', name: 'Cloth', asset: through, placement: { translation: [0, 0, 5] } },
+ ],
+ });
+ const check = f.tool('kiln_project');
+ const current = (await check.run({ action: 'check', projectId: 'cove' })) as {
+ ok: boolean;
+ composition: ProjectCompositionReportV1;
+ };
+ expect(current.ok).toBe(true);
+ expect(current.composition.projectRevision).toBe(second.revisionId);
+ expect(current.composition.openSurfaces).toEqual([]);
+ expect(current.composition.coverage).toBe('complete');
+ const exact = (await check.run({
+ action: 'check',
+ projectId: 'cove',
+ revisionId: first.revisionId,
+ })) as { composition: ProjectCompositionReportV1 };
+ expect(exact.composition.projectRevision).toBe(first.revisionId);
+ expect(exact.composition.openSurfaces).toHaveLength(1);
+ expect(exact.composition.openSurfaces[0]!.open.inventoryId).toBe('cloth');
+ expect(exact.composition.openSurfaces[0]!.solid.inventoryId).toBe('wall');
+});
+
+test('kiln_project check names what it needs, and is only offered with an asset library', async () => {
+ const f = await fixture();
+ const check = f.tool('kiln_project');
+ await expect(check.run({ action: 'check' })).rejects.toThrow(/projectId/);
+ await expect(check.run({ action: 'check', projectId: 'nope' })).rejects.toThrow(/action: 'list'/);
+ const hostless = createKilnProgramToolRegistry({ projectStore: f.workspace.projects }).find(
+ (def) => def.name === 'kiln_project',
+ )!;
+ await expect(hostless.run({ action: 'check', projectId: 'nope' })).rejects.toThrow();
+ const advertised = z.toJSONSchema(hostless.inputSchema as z.ZodType) as unknown as {
+ properties: { action: { enum: string[] } };
+ };
+ expect(advertised.properties.action.enum).not.toContain('check');
+});
+
+test('kiln_save records the report in the result and the build record, measuring the revision being saved', async () => {
+ const f = await fixture();
+ // Against the pinned clear throw this project is clean, so a finding can only come from
+ // the bytes being saved.
+ const project = await placedProject(f);
+ const pinned = (await f.tool('kiln_project').run({ action: 'check', projectId: 'cove' })) as {
+ composition: ProjectCompositionReportV1;
+ };
+ expect(pinned.composition.openSurfaces).toEqual([]);
+
+ const saved = await saveThrow(f, { projectId: 'cove' });
+ const report = saved.composition!;
+ expect(report.projectRevision).toBe(project.revisionId);
+ expect(report.subject).toEqual(['throw']);
+ expect(report.openSurfaces).toHaveLength(1);
+ expect(report.openSurfaces[0]!.solid.part).toContain('CurvedWall');
+ expect(report.openSurfaces[0]!.depth).toBeCloseTo(0.06, 3);
+ const record = await f.assetLibrary.read('project', 'throw', saved.asset.revisionId);
+ expect(record.manifest.build?.composition).toEqual(report);
+});
+
+test('a positive never stops the save, and an unreadable sibling is partial rather than clear', async () => {
+ const f = await fixture();
+ await f.workspace.projects.create({
+ projectId: 'cove',
+ name: 'Cove',
+ inventory: [
+ {
+ id: 'wall',
+ name: 'Wall',
+ asset: { ...f.wall, revisionId: 'r_evicted' },
+ placement: {},
+ },
+ { id: 'throw', name: 'Throw', asset: f.throwPin, placement: {} },
+ ],
+ });
+ const saved = await saveThrow(f, { projectId: 'cove' });
+ expect(saved.asset.revisionId).toBeTruthy();
+ expect(saved.composition!.coverage).toBe('partial');
+ expect(saved.composition!.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'wall', reason: 'unavailable' }),
+ ]);
+});
+
+test('standalone work gets no report, no finding and no warning', async () => {
+ const f = await fixture();
+ await placedProject(f);
+ // A placed project exists in this workspace, but nothing selected it.
+ const saved = await saveThrow(f);
+ expect('composition' in saved).toBe(false);
+ const record = await f.assetLibrary.read('project', 'throw', saved.asset.revisionId);
+ expect('composition' in (record.manifest.build ?? {})).toBe(false);
+ expect(JSON.stringify(saved)).not.toMatch(/neighbour/i);
+});
+
+test('projectId null overrides a configured default', async () => {
+ const f = await fixture();
+ await placedProject(f);
+ const workspace = new FileWorkspace(f.root, 'cove');
+ const save = createKilnProgramToolRegistry({
+ workspace,
+ projectStore: workspace.projects,
+ assetLibrary: f.assetLibrary,
+ programStore: f.programStore,
+ }).find((def) => def.name === 'kiln_save')!;
+ const request = { programRef: f.refs.throw, name: 'Throw', assetId: 'throw' };
+ const standalone = (await save.run({
+ ...request,
+ parentRevision: f.throwPin.revisionId,
+ projectId: null,
+ })) as SaveResult;
+ expect('composition' in standalone).toBe(false);
+ // Negative control: the same workspace and call without the opt-out is measured.
+ const configured = (await save.run({
+ ...request,
+ parentRevision: standalone.asset.revisionId,
+ })) as SaveResult;
+ expect(configured.composition?.openSurfaces).toHaveLength(1);
+});
+
+test('an item that states no placement, or is another collection, is not a save-time subject', async () => {
+ const f = await fixture();
+ await f.workspace.projects.create({
+ projectId: 'unplaced',
+ name: 'Unplaced',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ { id: 'throw', name: 'Throw', asset: f.throwPin },
+ ],
+ });
+ await f.workspace.projects.create({
+ projectId: 'other',
+ name: 'Other',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ {
+ id: 'throw',
+ name: 'Throw',
+ asset: { ...f.throwPin, collectionId: 'library' },
+ placement: {},
+ },
+ ],
+ });
+ await f.workspace.projects.create({
+ projectId: 'named-only',
+ name: 'Named only',
+ // Sharing a name or an item id with the asset is not membership.
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ { id: 'throw', name: 'throw', placement: {} },
+ ],
+ });
+ for (const projectId of ['unplaced', 'other', 'named-only']) {
+ const saved = await saveThrow(f, { projectId });
+ expect('composition' in saved, projectId).toBe(false);
+ }
+});
+
+test('placement survives a project bundle, and an unselected asset leaves it unpinned', async () => {
+ const f = await fixture();
+ const placement = {
+ translation: [1, 2, 3] as [number, number, number],
+ rotation: [0, 90, 0] as [number, number, number],
+ scale: [2, 2, 2] as [number, number, number],
+ };
+ await f.workspace.projects.create({
+ projectId: 'cove',
+ name: 'Cove',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement },
+ { id: 'throw', name: 'Throw', asset: f.throwPin, placement: {} },
+ { id: 'planned', name: 'Planned' },
+ ],
+ });
+ const bytes = await exportWorkspaceProjectBundle(f.workspace, f.assetLibrary, 'cove', {
+ profile: 'editable',
+ inventoryIds: ['wall'],
+ });
+ const targetRoot = await mkdtemp(join(tmpdir(), 'kiln-composition-import-'));
+ roots.push(targetRoot);
+ const target = new FileWorkspace(targetRoot);
+ const library = new FileAssetLibrary({ project: join(targetRoot, 'saved') });
+ const imported = await importWorkspaceProjectBundle(target, library, bytes, {
+ projectId: 'imported',
+ collectionId: 'project',
+ });
+ const items = Object.fromEntries(imported.inventory.map((item) => [item.id, item]));
+ expect(items.wall!.placement).toEqual(placement);
+ expect(items.wall!.asset).toBeDefined();
+ expect(items.throw!.placement).toEqual({});
+ expect(items.throw!.asset).toBeUndefined();
+ expect('placement' in items.planned!).toBe(false);
+ // A placement with its asset left behind is declared and unmeasured, never clear.
+ const { composeProjectModules } = await import('./project-composition');
+ const report = await composeProjectModules(imported, library);
+ expect(report.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'throw', reason: 'unpinned' }),
+ ]);
+});
+
+test('the CLI checks an exact revision through the same path', async () => {
+ const f = await fixture();
+ const env = {
+ ...process.env,
+ KILN_RENDER: 'cpu',
+ KILN_WORKSPACE: f.root,
+ KILN_PROGRAM_STORE: join(f.root, '.kiln', 'programs'),
+ KILN_COLLECTIONS: JSON.stringify({ project: join(f.root, 'saved') }),
+ };
+ const through = await f.assetLibrary.save('project', {
+ name: 'Through',
+ assetId: 'through',
+ glb: (await render(THROW)).glb,
+ });
+ const created = await f.workspace.projects.create({
+ projectId: 'cove',
+ name: 'Cove',
+ inventory: [
+ { id: 'wall', name: 'Wall', asset: f.wall, placement: {} },
+ {
+ id: 'cloth',
+ name: 'Cloth',
+ asset: { collectionId: 'project', assetId: 'through', revisionId: through.revisionId },
+ placement: {},
+ },
+ ],
+ });
+ const run = (...args: string[]) =>
+ spawnSync(process.execPath, [resolve('src/cli.ts'), 'project', ...args], {
+ cwd: f.root,
+ env,
+ encoding: 'utf8',
+ windowsHide: true,
+ });
+ const result = run('check', 'cove', '--revision', created.revisionId);
+ expect(result.status, result.stderr).toBe(0);
+ const { composition } = JSON.parse(result.stdout) as { composition: ProjectCompositionReportV1 };
+ expect(composition.projectRevision).toBe(created.revisionId);
+ expect(composition.openSurfaces[0]!.solid.inventoryId).toBe('wall');
+ expect(run('check').status).toBe(1);
+}, 60_000);
diff --git a/src/project-composition.test.ts b/src/project-composition.test.ts
new file mode 100644
index 00000000..518a18a5
--- /dev/null
+++ b/src/project-composition.test.ts
@@ -0,0 +1,632 @@
+/**
+ * #277 — modules that are correct alone and wrong together.
+ *
+ * The fixtures are real GLBs from the real builder, stored in a real library, because
+ * the failure this exists for only appears after a GLB round trip: separately saved
+ * modules composed at one origin, each of which passes on its own.
+ */
+import { beforeAll, describe, expect, test } from 'bun:test';
+import { mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import * as THREE from 'three';
+import { FileAssetLibrary } from './assets-node';
+import { createGltfIO } from './gltf-io';
+import type { AssetLibrary } from './assets';
+import {
+ composeProjectModules,
+ placementMatrix,
+ type ProjectCompositionReportV1,
+} from './project-composition';
+import { projectDraftSchema, projectRevisionSchema, type ProjectRevision } from './projects';
+import { FileProjectStore } from './projects-node';
+import { analyzeOpenSurfacePenetration } from './qa/open-surface-penetration';
+import { analyzePartPenetration } from './qa/self-intersection';
+import { renderGLBInProcess as render } from './render';
+import { loadGlbReviewScene } from './views/glb';
+
+const box = (name: string, size: number[], at: number[]) =>
+ `createPart('${name}', boxGeo(${size.join(',')}), gameMaterial(0x888888), {parent: r, position: [${at.join(',')}]});`;
+const sheet = (name: string, at: number[], rotation = [0, 0, 0]) =>
+ `createPart('${name}', planeGeo(1, 1, 8, 8), gameMaterial(0xaa4444), {parent: r, position: [${at.join(',')}], rotation: [${rotation.join(',')}]});`;
+const program = (name: string, ...parts: string[]) =>
+ `function build() { const r = createRoot('${name}'); ${parts.join(' ')} return r; }`;
+
+const MODULES = {
+ // A 12 cm wall, and a cloth in another module running straight through it.
+ wall: program('WallModule', box('CurvedWall', [2, 1.4, 0.12], [0, 0.7, 0.4])),
+ throw: program('ThrowModule', sheet('ThrowBlanket', [0, 0.7, 0.4])),
+ // A seat, and a cloth resting exactly on its top.
+ seat: program('SeatModule', box('Seat', [2, 0.5, 1], [0, 0.25, 0])),
+ drape: program('DrapeModule', sheet('Drape', [0, 0.5, 0], [-90, 0, 0])),
+ // Two closed solids that share volume at the shared origin.
+ post: program('PostModule', box('Post', [0.4, 1, 0.4], [0, 0.5, 0])),
+ beam: program('BeamModule', box('Beam', [1, 0.2, 0.2], [0, 0.5, 0])),
+ // Overlaps only inside itself: normal QA reports this, the composed check must not.
+ knot: program(
+ 'KnotModule',
+ box('KnotA', [0.5, 0.5, 0.5], [10, 0.25, 0]),
+ box('KnotB', [0.5, 0.5, 0.5], [10.2, 0.25, 0]),
+ ),
+ // Many internal overlaps to exhaust a budget, far from one real neighbour overlap.
+ clutter: program(
+ 'ClutterModule',
+ ...Array.from({ length: 16 }, (_, i) => box(`Clutter${i}`, [1, 1, 1], [20 + i * 0.01, 0.5, 0])),
+ box('Reach', [0.2, 0.2, 0.2], [-5, 0.5, 0]),
+ ),
+ target: program('TargetModule', box('Target', [0.2, 0.2, 0.2], [-5.05, 0.5, 0])),
+ // Nine by nine neighbour overlaps: 81 pairs against the real 64-boolean budget.
+ many: program(
+ 'ManyModule',
+ ...Array.from({ length: 9 }, (_, i) => box(`Crowd${i}`, [0.1, 0.1, 0.1], [i * 0.001, 0.5, 0])),
+ ),
+ crowd: program(
+ 'CrowdModule',
+ ...Array.from({ length: 9 }, (_, i) =>
+ box(`Cover${i}`, [0.1, 0.1, 0.1], [0.02 + i * 0.001, 0.5, 0]),
+ ),
+ ),
+ // Its level 1 alternate alone reaches the post; level 0 stands clear of it.
+ tiered: program(
+ 'TieredModule',
+ `const near = ${box('Stand_LOD0', [0.2, 1, 0.2], [3, 0.5, 0])}`,
+ `const far = ${box('Stand_LOD1', [0.2, 1, 0.2], [0, 0.5, 0])}`,
+ 'defineLod([near, far], { screenCoverage: [0.25, 0.06] });',
+ ),
+} as const;
+type ModuleName = keyof typeof MODULES;
+
+const glbs = {} as Record<ModuleName, Uint8Array>;
+let library: AssetLibrary;
+const pins = {} as Record<
+ ModuleName,
+ { collectionId: string; assetId: string; revisionId: string }
+>;
+let root: string;
+
+beforeAll(async () => {
+ root = await mkdtemp(join(tmpdir(), 'kiln-composition-'));
+ library = new FileAssetLibrary({ project: join(root, 'project') });
+ for (const name of Object.keys(MODULES) as ModuleName[]) {
+ glbs[name] = (await render(MODULES[name])).glb;
+ const manifest = await library.save('project', { name, assetId: name, glb: glbs[name] });
+ pins[name] = { collectionId: 'project', assetId: name, revisionId: manifest.revisionId };
+ }
+ return async () => rm(root, { recursive: true, force: true });
+}, 60_000);
+
+type Item = {
+ id: string;
+ asset?: { collectionId: string; assetId: string; revisionId: string };
+ placement?: ProjectRevision['inventory'][number]['placement'];
+};
+const project = (items: Item[]): ProjectRevision =>
+ projectRevisionSchema.parse({
+ version: 'kiln.project.v1',
+ projectId: 'cove',
+ revisionId: `r_0000000001_${'0'.repeat(64)}`,
+ createdAt: '2026-11-06T00:00:00.000Z',
+ name: 'Cove',
+ inventory: items.map((item) => ({ name: item.id, ...item })),
+ });
+/** Each named module pinned and explicitly placed at the shared origin. */
+const composed = (...names: ModuleName[]): Item[] =>
+ names.map((name) => ({ id: name, asset: pins[name], placement: {} }));
+
+describe('the issue: modules correct alone, wrong together', () => {
+ test('each module alone reports nothing, and the composition names both parts and the depth', async () => {
+ for (const name of ['wall', 'throw'] as const) {
+ const alone = (await loadGlbReviewScene(glbs[name])).root as THREE.Object3D;
+ expect(analyzeOpenSurfacePenetration(alone).penetrations).toEqual([]);
+ expect((await analyzePartPenetration(alone)).penetrations).toEqual([]);
+ }
+ const report = await composeProjectModules(project(composed('wall', 'throw')), library);
+ expect(report.openSurfaces).toHaveLength(1);
+ const [finding] = report.openSurfaces;
+ expect(finding!.open.inventoryId).toBe('throw');
+ expect(finding!.open.part).toContain('ThrowBlanket');
+ expect(finding!.solid.inventoryId).toBe('wall');
+ expect(finding!.solid.part).toContain('CurvedWall');
+ expect(finding!.depth).toBeCloseTo(0.06, 3);
+ expect(report.coverage).toBe('complete');
+ });
+
+ test('a cloth resting on a declared surface within tolerance is not reported', async () => {
+ const report = await composeProjectModules(project(composed('seat', 'drape')), library);
+ expect(report.openSurfaces).toEqual([]);
+ expect(report.overlaps).toEqual([]);
+ // Resting is contact, measured: the cloth's volume being unmeasurable does not make
+ // the whole check partial, because the surface pass sampled that part instead.
+ expect(report.coverage).toBe('complete');
+ });
+
+ test('two closed solids in different modules report shared volume with both parts named', async () => {
+ const report = await composeProjectModules(project(composed('post', 'beam')), library);
+ expect(report.overlaps).toHaveLength(1);
+ const [overlap] = report.overlaps;
+ expect(
+ [overlap!.a, overlap!.b].map((side) => side.inventoryId).sort((x, y) => x.localeCompare(y)),
+ ).toEqual(['beam', 'post']);
+ expect(overlap!.a.part + overlap!.b.part).toContain('Post');
+ expect(overlap!.a.part + overlap!.b.part).toContain('Beam');
+ // The beam's middle 0.4 m of its 1 m length sits inside the post: 0.4 × 0.2 × 0.2.
+ expect(overlap!.volume).toBeCloseTo(0.016, 5);
+ expect(overlap!.fraction).toBeCloseTo(0.4, 5);
+ });
+
+ test('negative control: moving the same modules apart clears what the origin reported', async () => {
+ const apart = await composeProjectModules(
+ project([
+ { id: 'wall', asset: pins.wall, placement: {} },
+ { id: 'throw', asset: pins.throw, placement: { translation: [0, 0, 3] } },
+ { id: 'post', asset: pins.post, placement: { translation: [10, 0, 0] } },
+ { id: 'beam', asset: pins.beam, placement: { translation: [10, 0, 3] } },
+ ]),
+ library,
+ );
+ expect(apart.openSurfaces).toEqual([]);
+ expect(apart.overlaps).toEqual([]);
+ expect(apart.coverage).toBe('complete');
+ });
+});
+
+describe('placement', () => {
+ test('rotation is Euler XYZ degrees and scale is applied, so both change what overlaps', async () => {
+ const wall = { id: 'wall', asset: pins.wall, placement: {} };
+ const moved = await composeProjectModules(
+ project([wall, { id: 'throw', asset: pins.throw, placement: { translation: [0, 0, 2] } }]),
+ library,
+ );
+ expect(moved.openSurfaces).toEqual([]);
+ // Turned 90 degrees about Y at the origin, the sheet stands at x=0.4 and crosses the
+ // wall edge on: its row at z=0.375 lies 3.5 cm inside the wall's near face at z=0.34.
+ const turned = await composeProjectModules(
+ project([wall, { id: 'throw', asset: pins.throw, placement: { rotation: [0, 90, 0] } }]),
+ library,
+ );
+ expect(turned.openSurfaces[0]!.depth).toBeCloseTo(0.035, 3);
+ const scaled = await composeProjectModules(
+ project([
+ { id: 'post', asset: pins.post, placement: {} },
+ // Halved, the beam's half-length shrinks to 0.25 m but still crosses the 0.2 m post.
+ { id: 'beam', asset: pins.beam, placement: { scale: [0.5, 1, 1] } },
+ ]),
+ library,
+ );
+ expect(scaled.overlaps[0]!.volume).toBeCloseTo(0.016, 5);
+ const clear = await composeProjectModules(
+ project([
+ { id: 'post', asset: pins.post, placement: {} },
+ { id: 'beam', asset: pins.beam, placement: { scale: [0.3, 1, 1] } },
+ ]),
+ library,
+ );
+ // 0.3 m long, it now lies wholly inside the post: all of the beam, none of it outside.
+ expect(clear.overlaps[0]!.fraction).toBeCloseTo(1, 3);
+ });
+
+ test('placementMatrix treats an empty placement as identity', () => {
+ expect(placementMatrix({}).equals(new THREE.Matrix4())).toBe(true);
+ });
+});
+
+describe('only cross-module pairs are measured', () => {
+ test('a module overlapping itself is not reported here: normal QA already does', async () => {
+ const report = await composeProjectModules(project(composed('knot', 'seat')), library);
+ expect(report.overlaps).toEqual([]);
+ expect(report.openSurfaces).toEqual([]);
+ });
+
+ test('negative control: the same module overlap is real, and only the filter hides it', async () => {
+ const alone = (await loadGlbReviewScene(glbs.knot)).root as THREE.Object3D;
+ expect((await analyzePartPenetration(alone)).penetrations).toHaveLength(1);
+ });
+
+ test('internal overlaps do not spend the neighbour budget', async () => {
+ // Clutter alone holds 120 overlapping internal pairs, about twice the 64-boolean
+ // budget. Unfiltered, its near-total box overlaps sort first and the budget runs out
+ // before the neighbour's pair is reached.
+ const alone = (await loadGlbReviewScene(glbs.clutter)).root as THREE.Object3D;
+ expect((await analyzePartPenetration(alone)).truncated).toBe(true);
+ const report = await composeProjectModules(project(composed('clutter', 'target')), library);
+ expect(report.truncated).toBe(false);
+ expect(report.overlaps).toHaveLength(1);
+ expect(report.overlaps[0]!.a.part + report.overlaps[0]!.b.part).toContain('Reach');
+ });
+});
+
+describe('LOD alternates are not present beside a neighbour', () => {
+ test('a declared lower level reaching a neighbour is not compared, and level 0 is', async () => {
+ const report = await composeProjectModules(project(composed('tiered', 'post')), library);
+ expect(report.overlaps).toEqual([]);
+ // Negative control: at a placement that brings level 0 onto the post, it is measured.
+ const moved = await composeProjectModules(
+ project([
+ { id: 'tiered', asset: pins.tiered, placement: { translation: [-3, 0, 0] } },
+ { id: 'post', asset: pins.post, placement: {} },
+ ]),
+ library,
+ );
+ expect(moved.overlaps).toHaveLength(1);
+ expect(moved.overlaps[0]!.a.part + moved.overlaps[0]!.b.part).toContain('Stand');
+ });
+
+ test('a mesh only named as a lower level is counted and left out', async () => {
+ const io = createGltfIO();
+ const document = await io.readBinary(glbs.post);
+ for (const node of document.getRoot().listNodes())
+ if (node.getMesh()) node.setName(`${node.getName()}_LOD1`);
+ const named = await library.save('project', {
+ name: 'Named',
+ assetId: 'named',
+ glb: await io.writeBinary(document),
+ });
+ const report = await composeProjectModules(
+ project([
+ {
+ id: 'named',
+ asset: { collectionId: 'project', assetId: 'named', revisionId: named.revisionId },
+ placement: {},
+ },
+ { id: 'beam', asset: pins.beam, placement: {} },
+ ]),
+ library,
+ );
+ expect(report.overlaps).toEqual([]);
+ expect(report.lodAlternatesExcluded).toBe(1);
+ });
+});
+
+describe('membership and the items that cannot be measured', () => {
+ test('a missing placement means not composed, never identity', async () => {
+ const report = await composeProjectModules(
+ project([
+ { id: 'wall', asset: pins.wall },
+ { id: 'throw', asset: pins.throw },
+ ]),
+ library,
+ );
+ expect(report.openSurfaces).toEqual([]);
+ expect(report.modules).toEqual([]);
+ expect(report.unmeasured).toEqual([]);
+ expect(report.notComposed).toEqual({ count: 2, ids: ['wall', 'throw'] });
+ expect(report.coverage).toBe('nothing-to-compare');
+ });
+
+ test('one composed module has nothing to compare', async () => {
+ const report = await composeProjectModules(project(composed('wall')), library);
+ expect(report.modules).toHaveLength(1);
+ expect(report.coverage).toBe('nothing-to-compare');
+ });
+
+ test('a placed item with no pin is unmeasured rather than clear', async () => {
+ const report = await composeProjectModules(
+ project([...composed('wall', 'throw'), { id: 'planned', placement: {} }]),
+ library,
+ );
+ expect(report.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'planned', reason: 'unpinned' }),
+ ]);
+ expect(report.coverage).toBe('partial');
+ expect(report.openSurfaces).toHaveLength(1);
+ });
+
+ test('a missing revision or an unregistered collection is unavailable and partial', async () => {
+ const report = await composeProjectModules(
+ project([
+ ...composed('seat', 'drape'),
+ {
+ id: 'gone',
+ asset: { collectionId: 'project', assetId: 'wall', revisionId: 'r_gone' },
+ placement: {},
+ },
+ {
+ id: 'elsewhere',
+ asset: { collectionId: 'nowhere', assetId: 'wall', revisionId: pins.wall.revisionId },
+ placement: {},
+ },
+ ]),
+ library,
+ );
+ expect(report.unmeasured.map(({ inventoryId, reason }) => [inventoryId, reason])).toEqual([
+ ['gone', 'unavailable'],
+ ['elsewhere', 'unavailable'],
+ ]);
+ expect(report.coverage).toBe('partial');
+ // The path to a user's collection stays out of a record that travels with the asset.
+ expect(JSON.stringify(report)).not.toContain(root);
+ });
+
+ test('an unreadable sibling is unmeasured rather than clear', async () => {
+ const dir = await mkdtemp(join(tmpdir(), 'kiln-composition-corrupt-'));
+ try {
+ const damaged = new FileAssetLibrary({ project: dir });
+ const manifest = await damaged.save('project', {
+ name: 'Broken',
+ assetId: 'broken',
+ glb: glbs.wall,
+ });
+ const revision = join(dir, 'broken', 'revisions', manifest.revisionId);
+ await writeFile(join(revision, 'asset.glb'), new Uint8Array([1, 2, 3]));
+ const healthy = await damaged.save('project', {
+ name: 'Throw',
+ assetId: 'throw',
+ glb: glbs.throw,
+ });
+ const report = await composeProjectModules(
+ project([
+ {
+ id: 'broken',
+ asset: { collectionId: 'project', assetId: 'broken', revisionId: manifest.revisionId },
+ placement: {},
+ },
+ {
+ id: 'throw',
+ asset: { collectionId: 'project', assetId: 'throw', revisionId: healthy.revisionId },
+ placement: {},
+ },
+ ]),
+ damaged,
+ );
+ expect(report.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'broken', reason: 'unreadable' }),
+ ]);
+ expect(report.coverage).toBe('partial');
+ expect(report.openSurfaces).toEqual([]);
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+ });
+
+ test('a stored asset with no GLB is unreadable', async () => {
+ const stub: AssetLibrary = {
+ collections: () => [{ id: 'project', label: 'Project' }],
+ list: async () => [],
+ save: async () => {
+ throw new Error('unused');
+ },
+ import: async () => [],
+ read: async (_collection, assetId) => {
+ const files: Record<string, Uint8Array> =
+ assetId === 'wall' ? { 'asset.glb': glbs.wall } : {};
+ return { manifest: {} as never, files };
+ },
+ };
+ const report = await composeProjectModules(
+ project([
+ { id: 'wall', asset: pins.wall, placement: {} },
+ { id: 'empty', asset: pins.throw, placement: {} },
+ ]),
+ stub,
+ );
+ expect(report.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'empty', reason: 'unreadable' }),
+ ]);
+ });
+});
+
+describe('budgets', () => {
+ test('modules past the module budget are named as unmeasured, and the report is truncated', async () => {
+ const report = await composeProjectModules(
+ project(composed('wall', 'throw', 'seat')),
+ library,
+ { limits: { maxModules: 2 } },
+ );
+ expect(report.modules.map((module) => module.inventoryId)).toEqual(['wall', 'throw']);
+ expect(report.unmeasured).toEqual([
+ expect.objectContaining({ inventoryId: 'seat', reason: 'budget' }),
+ ]);
+ expect(report.truncated).toBe(true);
+ expect(report.coverage).toBe('partial');
+ });
+
+ test('the byte budget stops loading further siblings', async () => {
+ const report = await composeProjectModules(project(composed('wall', 'throw')), library, {
+ limits: { maxBytes: glbs.wall.length },
+ });
+ expect(report.modules.map((module) => module.inventoryId)).toEqual(['wall']);
+ expect(report.unmeasured[0]).toMatchObject({ inventoryId: 'throw', reason: 'budget' });
+ expect(report.truncated).toBe(true);
+ });
+
+ test('the part budget stops composing further siblings', async () => {
+ const report = await composeProjectModules(project(composed('wall', 'many')), library, {
+ limits: { maxParts: 5 },
+ });
+ expect(report.modules.map((module) => module.inventoryId)).toEqual(['wall']);
+ expect(report.unmeasured[0]).toMatchObject({ inventoryId: 'many', reason: 'budget' });
+ });
+
+ test('pass budgets surface as truncation, never as a clean result', async () => {
+ const report = await composeProjectModules(project(composed('many', 'crowd')), library);
+ expect(report.overlaps).toHaveLength(64);
+ expect(report.solids.pairsNotReached).toBe(17);
+ expect(report.truncated).toBe(true);
+ expect(report.coverage).toBe('partial');
+ });
+
+ test('reported pairs and listed ids are capped with the remainder counted', async () => {
+ const report = await composeProjectModules(project(composed('many', 'crowd')), library, {
+ limits: { maxReportedPairs: 2 },
+ });
+ expect(report.overlaps).toHaveLength(2);
+ expect(report.overlapsOmitted).toBe(62);
+ const planned = await composeProjectModules(
+ project(Array.from({ length: 40 }, (_, i) => ({ id: `item${i}` }))),
+ library,
+ );
+ expect(planned.notComposed.count).toBe(40);
+ expect(planned.notComposed.ids).toHaveLength(32);
+ });
+});
+
+describe('a saved revision being measured', () => {
+ const subject = () => ({ collectionId: 'project', assetId: 'throw', glb: glbs.throw });
+
+ test('the revision being saved replaces the older pin, and is marked rather than named', async () => {
+ // The pin is the harmless drape; the bytes being saved are the throw through the wall.
+ const report = await composeProjectModules(
+ project([
+ { id: 'wall', asset: pins.wall, placement: {} },
+ { id: 'throw', asset: { ...pins.drape, assetId: 'throw' }, placement: {} },
+ ]),
+ library,
+ { subject: subject() },
+ );
+ expect(report.openSurfaces).toHaveLength(1);
+ expect(report.subject).toEqual(['throw']);
+ const saved = report.modules.find((module) => module.inventoryId === 'throw')!;
+ expect(saved.saved).toBe(true);
+ expect(saved.revisionId).toBeUndefined();
+ // Modules list the saved revision first so the budget always reaches it.
+ expect(report.modules[0]!.inventoryId).toBe('throw');
+ });
+
+ test('sibling pairs that do not involve it are left to the project check', async () => {
+ const report = await composeProjectModules(
+ project([
+ ...composed('post', 'beam'),
+ { id: 'throw', asset: { ...pins.throw }, placement: { translation: [0, 0, 8] } },
+ ]),
+ library,
+ { subject: subject() },
+ );
+ expect(report.overlaps).toEqual([]);
+ expect(report.openSurfaces).toEqual([]);
+ });
+
+ test('the same asset in another collection is a different item', async () => {
+ const report = await composeProjectModules(
+ project([
+ { id: 'wall', asset: pins.wall, placement: {} },
+ {
+ id: 'throw',
+ asset: { collectionId: 'other', assetId: 'throw', revisionId: pins.throw.revisionId },
+ placement: {},
+ },
+ ]),
+ library,
+ { subject: subject() },
+ );
+ expect(report.subject).toEqual([]);
+ expect(report.unmeasured[0]).toMatchObject({ inventoryId: 'throw', reason: 'unavailable' });
+ });
+});
+
+test('the report is deterministic and JSON-clean', async () => {
+ const items = composed('wall', 'throw', 'post', 'beam');
+ const a: ProjectCompositionReportV1 = await composeProjectModules(project(items), library);
+ const b = await composeProjectModules(project(items), library);
+ expect(a).toEqual(b);
+ expect(JSON.parse(JSON.stringify(a))).toEqual(a);
+ expect(a.schemaVersion).toBe(1);
+ expect(a.projectId).toBe('cove');
+});
+
+describe('the placement field on a stored record', () => {
+ // Written by the engine at 6bf1e5f, before placement existed.
+ const LEGACY = {
+ version: 'kiln.project.v1',
+ projectId: 'legacy',
+ revisionId: 'r_0000000001_cc09d2ab255e90625de5ff364294fb3874078a97a3bdb836ca09fb5a99f2ddde',
+ createdAt: '2026-11-06T09:18:56.835Z',
+ name: 'Legacy pack',
+ brief: '',
+ design: {
+ style: '',
+ scale: '',
+ palette: [],
+ materialRoles: [],
+ conventions: [],
+ exceptions: [],
+ },
+ inventory: [
+ {
+ id: 'bench',
+ name: 'Bench',
+ kind: 'asset',
+ brief: '',
+ references: [],
+ asset: { collectionId: 'project', assetId: 'bench', revisionId: 'r_0123' },
+ },
+ { id: 'planned', name: 'Planned', kind: 'environment', brief: '', references: [] },
+ ],
+ deliveryProfiles: [],
+ materialDependencies: [],
+ references: [],
+ reviews: [],
+ };
+
+ test('a revision stored before placement existed still loads under its own id', async () => {
+ const workspace = await mkdtemp(join(tmpdir(), 'kiln-placement-legacy-'));
+ try {
+ const directory = join(workspace, '.kiln', 'projects', 'legacy', 'revisions');
+ await mkdir(directory, { recursive: true });
+ await writeFile(join(directory, '0000000001.json'), JSON.stringify(LEGACY, null, 2));
+ const store = new FileProjectStore(workspace);
+ const read = await store.read('legacy');
+ expect(read.revisionId).toBe(LEGACY.revisionId);
+ expect(Object.keys(read.inventory[0]!)).not.toContain('placement');
+ } finally {
+ await rm(workspace, { recursive: true, force: true });
+ }
+ });
+
+ test('an absent placement is omitted, a stated one survives, and an empty one stays stated', async () => {
+ const parsed = projectDraftSchema.parse({
+ name: 'Pack',
+ inventory: [
+ { id: 'absent', name: 'Absent' },
+ { id: 'identity', name: 'Identity', placement: {} },
+ {
+ id: 'moved',
+ name: 'Moved',
+ placement: { translation: [1, 2, 3], rotation: [0, 90, 0], scale: [2, 2, 2] },
+ },
+ ],
+ });
+ expect('placement' in parsed.inventory[0]!).toBe(false);
+ expect(parsed.inventory[1]!.placement).toEqual({});
+ expect(parsed.inventory[2]!.placement).toEqual({
+ translation: [1, 2, 3],
+ rotation: [0, 90, 0],
+ scale: [2, 2, 2],
+ });
+ });
+
+ test('a stated placement survives an immutable update and a later read', async () => {
+ const workspace = await mkdtemp(join(tmpdir(), 'kiln-placement-store-'));
+ try {
+ const store = new FileProjectStore(workspace);
+ const first = await store.create({
+ projectId: 'pack',
+ name: 'Pack',
+ inventory: [{ id: 'a', name: 'A', placement: { translation: [1, 0, 0] } }],
+ });
+ const second = await store.update('pack', first.revisionId, { brief: 'Changed' });
+ expect((await store.read('pack', second.revisionId)).inventory[0]!.placement).toEqual({
+ translation: [1, 0, 0],
+ });
+ expect(
+ (await readdir(join(workspace, '.kiln', 'projects', 'pack', 'revisions'))).length,
+ ).toBe(2);
+ } finally {
+ await rm(workspace, { recursive: true, force: true });
+ }
+ });
+
+ test.each([
+ ['a zero scale, which collapses the module', { scale: [0, 1, 1] }],
+ ['a two-element translation', { translation: [1, 2] }],
+ ['a quaternion where Euler angles are expected', { rotation: [0, 0, 0, 1] }],
+ ['an unknown key', { position: [0, 0, 0] }],
+ ['an unbounded coordinate', { translation: [1e9, 0, 0] }],
+ ])('rejects %s', (_label, placement) => {
+ expect(() =>
+ projectDraftSchema.parse({
+ name: 'Pack',
+ inventory: [{ id: 'a', name: 'A', placement }],
+ }),
+ ).toThrow();
+ });
+});
diff --git a/src/project-composition.ts b/src/project-composition.ts
new file mode 100644
index 00000000..40bb4ddf
--- /dev/null
+++ b/src/project-composition.ts
@@ -0,0 +1,426 @@
+/**
+ * Project modules measured against each other where they actually sit — #277
+ *
+ * ## Why this runs on the host
+ *
+ * The pack this exists for shipped a cloth through a neighbouring module's wall. Each
+ * module passed its own QA because neither one contained both parts, and composing them
+ * needs the sibling GLBs. The evaluator is isolated and has no filesystem, and `QaContext`
+ * stays image-free, so this is not a QA rule: the host reads the exact pinned revisions a
+ * project declares, composes them, and runs the same two measurements over the result.
+ *
+ * ## Declared, never inferred
+ *
+ * Only an inventory item that states a `placement` takes part. A missing placement means
+ * "not composed", not identity: identity would report every unrelated prop in a pack as
+ * overlapping at the origin. Nothing here looks at nearby projects, names or collections.
+ *
+ * ## Only cross-module pairs
+ *
+ * Overlaps inside one module are already reported by that module's own QA, and a module
+ * can hold more of them than a pass has budget for. So within-module pairs are filtered
+ * before they spend any budget, rather than measured and discarded afterwards.
+ *
+ * ## Unmeasured is not clear
+ *
+ * A sibling that could not be read is named as unmeasured and makes coverage `partial`.
+ * A positive is a measurement rather than a verdict, exactly as in the two passes: a
+ * fitting socketed into a neighbour's shell is reported as a bolt in a hole is.
+ */
+
+import * as THREE from 'three';
+import type { AssetLibrary } from './assets';
+import type { InventoryPlacement, ProjectRevision } from './projects';
+import { lodLevel } from './qa/lod';
+import { analyzeOpenSurfacePenetration } from './qa/open-surface-penetration';
+import { analyzePartPenetration } from './qa/self-intersection';
+import { loadGlbReviewScene } from './views/glb';
+
+export const PROJECT_COMPOSITION_LIMITS = Object.freeze({
+ /** Items composed at once; further placed items are reported, not silently dropped. */
+ maxModules: 64,
+ /** GLB bytes loaded for one check, the same ceiling as a project bundle. */
+ maxBytes: 256 * 1024 * 1024,
+ /** Meshes composed at once, which bounds the pair filter's quadratic walk. */
+ maxParts: 4096,
+ /** Findings kept per measurement, so a report stays small enough to live in a manifest. */
+ maxReportedPairs: 100,
+ /** Item ids and unmeasured parts listed; the count covers the rest. */
+ maxListed: 32,
+});
+
+const COMPOSITION_NOTE =
+ 'A positive is a measurement, not a verdict: a fitting socketed into a neighbour is reported as a bolt in a hole is. Measured at rest over visible static parts; open surfaces are not measured against each other, and a solid thinner than a surface’s facet spacing can pass between its vertices. A clean result is not a fit audit.';
+
+export interface CompositionPartV1 {
+ inventoryId: string;
+ part: string;
+}
+
+export interface ProjectCompositionReportV1 {
+ schemaVersion: 1;
+ source: 'host-composed-scene';
+ projectId: string;
+ projectRevision: string;
+ /**
+ * `complete`: every placed item and pair in scope was measured. `partial`: something was
+ * not, and is named here. `nothing-to-compare`: fewer than two modules were composed.
+ * `failed`: the check itself could not run, which says nothing about the geometry.
+ */
+ coverage: 'complete' | 'partial' | 'nothing-to-compare' | 'failed';
+ /** Present on a save: the items holding the revision being saved. Only their pairs are measured. */
+ subject?: string[];
+ /** Items composed. `saved` marks the revision being saved, whose id does not exist yet. */
+ modules: {
+ inventoryId: string;
+ collectionId: string;
+ assetId: string;
+ revisionId?: string;
+ saved?: true;
+ parts: number;
+ }[];
+ /** Items with no placement: outside the composition by declaration, and not a problem. */
+ notComposed: { count: number; ids: string[] };
+ /** Placed items left out of the measurement. Their pairs are not certified clear. */
+ unmeasured: {
+ inventoryId: string;
+ reason: 'unpinned' | 'unavailable' | 'unreadable' | 'budget';
+ detail: string;
+ }[];
+ /** Closed solids in different modules sharing volume, worst first. */
+ overlaps: { a: CompositionPartV1; b: CompositionPartV1; volume: number; fraction: number }[];
+ overlapsOmitted: number;
+ /** Open surfaces reaching inside a closed solid in another module, deepest first. */
+ openSurfaces: {
+ open: CompositionPartV1;
+ solid: CompositionPartV1;
+ depth: number;
+ vertices: number;
+ tested: number;
+ }[];
+ openSurfacesOmitted: number;
+ /** Parts a pass could not measure, except open parts the surface pass sampled instead. */
+ unmeasuredParts: (CompositionPartV1 & { pass: 'solids' | 'surfaces'; reason: string })[];
+ unmeasuredPartsOmitted: number;
+ /** Meshes on LOD levels above 0: alternates of the level 0 part, left out of every pair. */
+ lodAlternatesExcluded: number;
+ solids: {
+ candidatePairs: number;
+ pairsTested: number;
+ pairsUnmeasurable: number;
+ pairsNotReached: number;
+ failed?: true;
+ };
+ surfaces: {
+ candidatePairs: number;
+ pairsTested: number;
+ pairsNotReached: number;
+ verticesUnresolved: number;
+ failed?: true;
+ };
+ /** True when a budget left a placed item, a pair or a finding out of this report. */
+ truncated: boolean;
+ /** Present with coverage `failed`. */
+ error?: string;
+ note: string;
+}
+
+/** Scale, then rotation (Euler XYZ degrees), then translation, each defaulting to identity. */
+export function placementMatrix(placement: InventoryPlacement): THREE.Matrix4 {
+ const [rx, ry, rz] = placement.rotation ?? [0, 0, 0];
+ return new THREE.Matrix4().compose(
+ new THREE.Vector3(...(placement.translation ?? [0, 0, 0])),
+ new THREE.Quaternion().setFromEuler(
+ new THREE.Euler(
+ THREE.MathUtils.degToRad(rx),
+ THREE.MathUtils.degToRad(ry),
+ THREE.MathUtils.degToRad(rz),
+ 'XYZ',
+ ),
+ ),
+ new THREE.Vector3(...(placement.scale ?? [1, 1, 1])),
+ );
+}
+
+/** Inventory ids cannot contain `/`, so a part's module survives the two passes in its name. */
+const moduleName = (inventoryId: string, part: string) => `${inventoryId}/${part}`;
+function nameParts(name: string): CompositionPartV1 {
+ const at = name.indexOf('/');
+ return { inventoryId: name.slice(0, at), part: name.slice(at + 1).slice(0, 200) };
+}
+
+type Listed = ProjectRevision['inventory'][number];
+
+/** The saved library's refusal, reduced to words that are safe in a record that travels. */
+function readFailure(
+ item: Listed,
+ error: unknown,
+): ProjectCompositionReportV1['unmeasured'][number] {
+ const code = (error as NodeJS.ErrnoException | undefined)?.code;
+ const message = error instanceof Error ? error.message : String(error);
+ const { collectionId, assetId, revisionId } = item.asset!;
+ const pin = `${collectionId}/${assetId} at ${revisionId}`;
+ if (code === 'ENOENT' || /Unknown collection/.test(message))
+ return {
+ inventoryId: item.id,
+ reason: 'unavailable',
+ detail: `The pinned revision ${pin} is not in the configured collections.`,
+ };
+ return {
+ inventoryId: item.id,
+ reason: 'unreadable',
+ detail: `The pinned revision ${pin} could not be read (${code ?? message}).`,
+ };
+}
+
+/**
+ * Load one module under its placement. Meshes are renamed in this private copy so each pass
+ * reports the module with the part, and LOD alternates are hidden so a neighbour's level 1 is
+ * not compared as though it stood beside level 0. Returns the mesh count.
+ */
+async function composeModule(
+ moduleOf: Map<THREE.Object3D, number>,
+ index: number,
+ item: Listed,
+ glb: Uint8Array,
+): Promise<{ parts: number; lodExcluded: number; group: THREE.Group }> {
+ const loaded = (await loadGlbReviewScene(glb)).root;
+ const group = new THREE.Group();
+ group.matrix.copy(placementMatrix(item.placement!));
+ group.matrixAutoUpdate = false;
+ group.add(loaded);
+ let parts = 0;
+ let lodExcluded = 0;
+ loaded.traverse((node) => {
+ const mesh = node as THREE.Mesh;
+ if (!mesh.isMesh) return;
+ if ((lodLevel(mesh) ?? 0) > 0) {
+ mesh.visible = false;
+ lodExcluded++;
+ }
+ moduleOf.set(mesh, index);
+ mesh.name = moduleName(item.id, mesh.name || '(unnamed mesh)');
+ parts++;
+ });
+ return { parts, lodExcluded, group };
+}
+
+export interface ComposeProjectOptions {
+ /** The revision being saved: it replaces the pin of every matching item, and scopes the pairs. */
+ subject?: { collectionId: string; assetId: string; glb: Uint8Array };
+ limits?: Partial<Record<keyof typeof PROJECT_COMPOSITION_LIMITS, number>>;
+}
+
+/** The report for a check that could not run; it claims nothing about the geometry. */
+export function failedCompositionReport(
+ project: Pick<ProjectRevision, 'projectId' | 'revisionId'>,
+ error: unknown,
+): ProjectCompositionReportV1 {
+ return {
+ ...emptyReport(project),
+ coverage: 'failed',
+ error: error instanceof Error ? error.message : String(error),
+ };
+}
+
+function emptyReport(
+ project: Pick<ProjectRevision, 'projectId' | 'revisionId'>,
+): ProjectCompositionReportV1 {
+ return {
+ schemaVersion: 1,
+ source: 'host-composed-scene',
+ projectId: project.projectId,
+ projectRevision: project.revisionId,
+ coverage: 'nothing-to-compare',
+ modules: [],
+ notComposed: { count: 0, ids: [] },
+ unmeasured: [],
+ overlaps: [],
+ overlapsOmitted: 0,
+ openSurfaces: [],
+ openSurfacesOmitted: 0,
+ unmeasuredParts: [],
+ unmeasuredPartsOmitted: 0,
+ lodAlternatesExcluded: 0,
+ solids: { candidatePairs: 0, pairsTested: 0, pairsUnmeasurable: 0, pairsNotReached: 0 },
+ surfaces: { candidatePairs: 0, pairsTested: 0, pairsNotReached: 0, verticesUnresolved: 0 },
+ truncated: false,
+ note: COMPOSITION_NOTE,
+ };
+}
+
+/** Compose an exact project revision and measure its modules against each other. */
+export async function composeProjectModules(
+ project: ProjectRevision,
+ library: Pick<AssetLibrary, 'read'>,
+ options: ComposeProjectOptions = {},
+): Promise<ProjectCompositionReportV1> {
+ const limits = { ...PROJECT_COMPOSITION_LIMITS, ...options.limits };
+ const report = emptyReport(project);
+ const { subject } = options;
+ const holdsSubject = (item: Listed) =>
+ subject !== undefined &&
+ item.asset?.collectionId === subject.collectionId &&
+ item.asset.assetId === subject.assetId;
+
+ const placed = project.inventory.filter((item) => item.placement);
+ const outside = project.inventory.filter((item) => !item.placement);
+ report.notComposed = {
+ count: outside.length,
+ ids: outside.slice(0, limits.maxListed).map((item) => item.id),
+ };
+ const held = placed.filter(holdsSubject);
+ if (subject) report.subject = held.map((item) => item.id);
+
+ // The saved revision goes first, so no budget can leave out the module this save is about.
+ const scene = new THREE.Group();
+ const moduleOf = new Map<THREE.Object3D, number>();
+ const subjectModules = new Set<number>();
+ let bytes = 0;
+ let parts = 0;
+ let exhausted = false;
+ const overBudget = (item: Listed, detail: string) => {
+ exhausted = true;
+ report.unmeasured.push({ inventoryId: item.id, reason: 'budget', detail });
+ };
+ for (const item of [...held, ...placed.filter((item) => !holdsSubject(item))]) {
+ if (!item.asset) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: 'unpinned',
+ detail: 'This item states a placement but links no saved revision.',
+ });
+ continue;
+ }
+ if (exhausted || report.modules.length >= limits.maxModules) {
+ overBudget(
+ item,
+ `Not loaded: the check composes at most ${limits.maxModules} modules, ${limits.maxBytes} bytes and ${limits.maxParts} parts.`,
+ );
+ continue;
+ }
+ const saved = holdsSubject(item);
+ let glb: Uint8Array | undefined;
+ if (saved) glb = subject!.glb;
+ else {
+ try {
+ const { collectionId, assetId, revisionId } = item.asset;
+ glb = (await library.read(collectionId, assetId, revisionId)).files['asset.glb'];
+ } catch (error) {
+ report.unmeasured.push(readFailure(item, error));
+ continue;
+ }
+ if (!glb) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: 'unreadable',
+ detail: 'The pinned revision has no asset.glb.',
+ });
+ continue;
+ }
+ }
+ if (bytes + glb.length > limits.maxBytes) {
+ overBudget(item, `Not loaded: the check loads at most ${limits.maxBytes} GLB bytes.`);
+ continue;
+ }
+ bytes += glb.length;
+ let module: Awaited<ReturnType<typeof composeModule>>;
+ try {
+ module = await composeModule(moduleOf, report.modules.length, item, glb);
+ } catch (error) {
+ report.unmeasured.push({
+ inventoryId: item.id,
+ reason: 'unreadable',
+ detail: `The GLB could not be loaded (${error instanceof Error ? error.message : String(error)}).`,
+ });
+ continue;
+ }
+ if (parts + module.parts > limits.maxParts) {
+ overBudget(item, `Not composed: the check composes at most ${limits.maxParts} parts.`);
+ continue;
+ }
+ parts += module.parts;
+ report.lodAlternatesExcluded += module.lodExcluded;
+ scene.add(module.group);
+ if (saved) subjectModules.add(report.modules.length);
+ report.modules.push({
+ inventoryId: item.id,
+ collectionId: item.asset.collectionId,
+ assetId: item.asset.assetId,
+ ...(saved ? { saved: true as const } : { revisionId: item.asset.revisionId }),
+ parts: module.parts,
+ });
+ }
+
+ let failed = false;
+ if (report.modules.length >= 2) {
+ const comparable = (a: THREE.Mesh, b: THREE.Mesh) => {
+ const left = moduleOf.get(a);
+ const right = moduleOf.get(b);
+ if (left === right) return false;
+ return !subject || subjectModules.has(left!) || subjectModules.has(right!);
+ };
+ const unmeasured: ProjectCompositionReportV1['unmeasuredParts'] = [];
+ let open = new Set<string>();
+ try {
+ const surfaces = analyzeOpenSurfacePenetration(scene, undefined, { comparable });
+ open = new Set(surfaces.openPartNames);
+ report.surfaces = {
+ candidatePairs: surfaces.candidatePairs,
+ pairsTested: surfaces.pairsTested,
+ pairsNotReached: surfaces.pairsNotReached,
+ verticesUnresolved: surfaces.verticesUnresolved,
+ };
+ report.truncated ||= surfaces.truncated;
+ report.openSurfaces = surfaces.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ open: nameParts(pair.open),
+ solid: nameParts(pair.solid),
+ depth: pair.depth,
+ vertices: pair.vertices,
+ tested: pair.tested,
+ }));
+ report.openSurfacesOmitted = surfaces.penetrations.length - report.openSurfaces.length;
+ for (const { part, reason } of surfaces.skipped)
+ unmeasured.push({ ...nameParts(part), pass: 'surfaces', reason });
+ } catch {
+ report.surfaces.failed = true;
+ failed = true;
+ }
+ try {
+ const solids = await analyzePartPenetration(scene, { comparable });
+ report.solids = {
+ candidatePairs: solids.candidatePairs,
+ pairsTested: solids.pairsTested,
+ pairsUnmeasurable: solids.pairsUnmeasurable,
+ pairsNotReached: solids.pairsNotReached,
+ };
+ report.truncated ||= solids.truncated;
+ report.overlaps = solids.penetrations.slice(0, limits.maxReportedPairs).map((pair) => ({
+ a: nameParts(pair.a),
+ b: nameParts(pair.b),
+ volume: pair.volume,
+ fraction: pair.fraction,
+ }));
+ report.overlapsOmitted = solids.penetrations.length - report.overlaps.length;
+ // An open part encloses no volume. The surface pass sampled it, so the volume pass
+ // failing to close it is expected and leaves nothing unmeasured.
+ for (const { part, reason } of [...solids.skipped, ...(solids.acknowledged ?? [])])
+ if (!open.has(part)) unmeasured.push({ ...nameParts(part), pass: 'solids', reason });
+ } catch {
+ report.solids.failed = true;
+ failed = true;
+ }
+ report.unmeasuredParts = unmeasured.slice(0, limits.maxListed);
+ report.unmeasuredPartsOmitted = unmeasured.length - report.unmeasuredParts.length;
+ report.truncated ||= report.overlapsOmitted > 0 || report.openSurfacesOmitted > 0;
+ failed ||= unmeasured.length > 0;
+ }
+ report.truncated ||= exhausted;
+ report.coverage =
+ failed || report.truncated || report.unmeasured.length > 0
+ ? 'partial'
+ : report.modules.length < 2
+ ? 'nothing-to-compare'
+ : 'complete';
+ return report;
+}
diff --git a/src/projects.ts b/src/projects.ts
index 0d4864de..6406ac3c 100644
--- a/src/projects.ts
+++ b/src/projects.ts
@@ -22,6 +22,29 @@ const assetReference = z
})
.strict();
+/** Metres or degrees; large enough for a world, small enough that a composed matrix stays finite. */
+const placementNumber = z.number().min(-1e6).max(1e6);
+const placementVector = z.tuple([placementNumber, placementNumber, placementNumber]);
+const placementScale = placementNumber
+ .min(-1e3)
+ .max(1e3)
+ .refine((value) => value !== 0, {
+ message: 'A zero scale collapses the module.',
+ });
+/**
+ * Where a module sits in the project's shared frame: scale, then rotation (Euler XYZ degrees, as
+ * Kiln's helpers), then translation, each defaulting to identity. Stating one, even empty, is what
+ * joins the composition; an item with none is not composed, never placed at the origin.
+ */
+export const inventoryPlacementSchema = z
+ .object({
+ translation: placementVector.optional(),
+ rotation: placementVector.optional(),
+ scale: z.tuple([placementScale, placementScale, placementScale]).optional(),
+ })
+ .strict();
+export type InventoryPlacement = z.infer<typeof inventoryPlacementSchema>;
+
export const projectDesignSchema = z
.object({
style: text.default(''),
@@ -80,6 +103,7 @@ const content = {
brief: text.default(''),
references: z.array(projectIdSchema).max(64).default([]),
asset: assetReference.optional(),
+ placement: inventoryPlacementSchema.optional(),
})
.strict(),
)
diff --git a/src/qa/open-surface-penetration.ts b/src/qa/open-surface-penetration.ts
index 3cee054b..995c5ca7 100644
--- a/src/qa/open-surface-penetration.ts
+++ b/src/qa/open-surface-penetration.ts
@@ -73,6 +73,7 @@
import * as THREE from 'three';
import { geometryDiagnostics } from '../geometry';
import { lodMembership } from './lod';
+import type { PartPairFilter } from './self-intersection';
import { KILN_ENGINE_QA_OWNER, type QaRule } from './registry';
import type { QaContext, QaFinding } from './types';
@@ -127,6 +128,8 @@ export interface OpenSurfacePenetrationEvidenceV1 {
openParts: number;
/** Eligible closed-solid parts collected. */
closedParts: number;
+ /** The open parts by name, for a caller reconciling this pass with the volume pass. */
+ openPartNames?: string[];
/**
* Open/closed pairs whose world boxes overlap, excluding LOD alternates; a
* lower bound when `broadPhaseTruncated` is true.
@@ -420,6 +423,7 @@ const round = (value: number): number => Number(value.toPrecision(9));
export function analyzeOpenSurfacePenetration(
root: unknown,
contactTolerance: number = OPEN_SURFACE_CONTACT_TOLERANCE,
+ options: { comparable?: PartPairFilter } = {},
): OpenSurfacePenetrationEvidenceV1 {
const evidence: OpenSurfacePenetrationEvidenceV1 = {
schemaVersion: 1,
@@ -442,6 +446,7 @@ export function analyzeOpenSurfacePenetration(
const closed = parts.filter((part) => part.closed);
evidence.openParts = open.length;
evidence.closedParts = closed.length;
+ if (options.comparable) evidence.openPartNames = open.map((part) => part.name);
const candidates: {
open: AnalyzedPart;
@@ -452,6 +457,7 @@ export function analyzeOpenSurfacePenetration(
let considered = 0;
broadPhase: for (const surface of open) {
for (const solid of closed) {
+ if (options.comparable && !options.comparable(surface.mesh, solid.mesh)) continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
evidence.broadPhaseTruncated = true;
break broadPhase;
diff --git a/src/qa/self-intersection.ts b/src/qa/self-intersection.ts
index ade4a075..0cb5d25a 100644
--- a/src/qa/self-intersection.ts
+++ b/src/qa/self-intersection.ts
@@ -263,6 +263,12 @@ function collectParts(
return parts;
}
+/**
+ * Which pairs a caller wants measured. Filtered pairs spend no budget, so a composition of
+ * modules is not starved by the overlaps inside each one, which normal QA already reported.
+ */
+export type PartPairFilter = (a: THREE.Mesh, b: THREE.Mesh) => boolean;
+
/**
* Normalized triangle soup for one static mesh, as manifold wants it.
*
@@ -329,6 +335,7 @@ function meshToArrays(
*/
export async function analyzePartPenetration(
root: THREE.Object3D,
+ options: { comparable?: PartPairFilter } = {},
): Promise<PartPenetrationEvidenceV1> {
const skipped: PartPenetrationEvidenceV1['skipped'] = [];
const parts = collectParts(root, skipped);
@@ -353,12 +360,13 @@ export async function analyzePartPenetration(
let considered = 0;
broadPhase: for (let i = 0; i < parts.length; i++) {
for (let j = i + 1; j < parts.length; j++) {
+ const a = parts[i]!;
+ const b = parts[j]!;
+ if (options.comparable && !options.comparable(a.mesh, b.mesh)) continue;
if (considered++ === MAX_BROAD_PHASE_PAIRS) {
base.broadPhaseTruncated = true;
break broadPhase;
}
- const a = parts[i]!;
- const b = parts[j]!;
if (!a.box.intersectsBox(b.box)) continue;
if (
a.lod &&
diff --git a/src/tools/projects.ts b/src/tools/projects.ts
index 3b9bb74a..f796f717 100644
--- a/src/tools/projects.ts
+++ b/src/tools/projects.ts
@@ -7,6 +7,7 @@ import {
projectRevisionIdSchema,
type ProjectStore,
} from '../projects';
+import type { AssetLibrary } from '../assets';
import { nestedRecordDescription, requireActionFields } from './actions';
import type { KilnToolDef } from './registry';
@@ -16,7 +17,7 @@ export type ProjectBundleReader = (
profile: 'editable' | 'runtime',
) => Promise<Uint8Array>;
-const PROJECT_ACTIONS = ['list', 'get', 'create', 'update', 'export'] as const;
+const PROJECT_ACTIONS = ['list', 'get', 'create', 'update', 'export', 'check'] as const;
type ProjectAction = (typeof PROJECT_ACTIONS)[number];
const REQUIREMENTS: Record<ProjectAction, Parameters<typeof requireActionFields>[3]> = {
list: { required: [] },
@@ -27,20 +28,21 @@ const REQUIREMENTS: Record<ProjectAction, Parameters<typeof requireActionFields>
shapes: { patch: 'shape:project-patch' },
},
export: { required: ['projectId'] },
+ check: { required: ['projectId'] },
};
/** The nested records stay opaque in the advertised schema and are validated when the action runs. */
const record = (description: string) =>
z.record(z.string(), z.unknown()).optional().describe(description);
-/** One flat object: `export` is offered only when the host can read project bundles. */
+/** One flat object: `export` and `check` are offered only when the host can back them. */
export function projectToolInput(actions: readonly ProjectAction[] = PROJECT_ACTIONS) {
return z.strictObject({
action: z.enum(actions as [ProjectAction, ...ProjectAction[]]),
- projectId: projectIdSchema.optional().describe('get, update, export.'),
+ projectId: projectIdSchema.optional().describe('get, update, export, check.'),
revisionId: projectRevisionIdSchema
.optional()
- .describe('get, export: an exact revision; omit for the current one.'),
+ .describe('get, export, check: an exact revision; omit for the current one.'),
expectedRevision: projectRevisionIdSchema
.optional()
.describe('update: the revision being replaced; a stale value is a conflict.'),
@@ -68,16 +70,22 @@ export function projectToolInput(actions: readonly ProjectAction[] = PROJECT_ACT
export function createKilnProjectDef(
store: ProjectStore,
bundleReader?: ProjectBundleReader,
+ assetLibrary?: Pick<AssetLibrary, 'read'>,
): KilnToolDef {
const schema = projectToolInput(
- bundleReader ? PROJECT_ACTIONS : PROJECT_ACTIONS.filter((action) => action !== 'export'),
+ PROJECT_ACTIONS.filter(
+ (action) => (action !== 'export' || bundleReader) && (action !== 'check' || assetLibrary),
+ ),
);
return {
name: 'kiln_project',
description:
- 'Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release. CLI and the local dashboard use the same records.' +
+ 'Manage optional shared workspace projects: list discovers IDs; get reads the current or an exact historical configuration; create adds a project; update needs the exact expectedRevision and replaces each supplied top-level field. Assets and materials are authored, saved and exported without a project, and creating one never binds unrelated authoring. Design preferences, inventory, references, delivery profiles and pinned material dependencies are versioned; review annotations do not change trusted QA or authorize a release.' +
(bundleReader
? ' export returns an MCP resource URI for an exact editable project ZIP with normalized material maps and recipes, or a runtime GLB/metadata ZIP; only inventory entries linked to saved revisions contribute assets, and referenced concept images and acquisition archives are not embedded.'
+ : '') +
+ (assetLibrary
+ ? ' check measures items that state a placement against each other at pinned revisions: shared volume, and open surfaces inside a neighbour. An unreadable pin is unmeasured, not clear; a positive is not a verdict.'
: ''),
inputSchema: schema,
annotations: {
@@ -118,6 +126,16 @@ export function createKilnProjectDef(
projectPatchSchema.parse(input.patch),
),
};
+ case 'check': {
+ const { composeProjectModules } = await import('../project-composition');
+ return {
+ ok: true,
+ composition: await composeProjectModules(
+ await store.read(input.projectId!, input.revisionId),
+ assetLibrary!,
+ ),
+ };
+ }
case 'export': {
const profile = input.profile ?? 'editable';
const project = await store.read(input.projectId!, input.revisionId);
diff --git a/src/tools/registry.ts b/src/tools/registry.ts
index 2dbee4e6..7605e5c7 100644
--- a/src/tools/registry.ts
+++ b/src/tools/registry.ts
@@ -2654,7 +2654,13 @@ function createProgramDefs(
].map((def) => withProgramReferences(def, store, context.readSourceFile)),
createKilnSourceDef(store),
...(context.projectStore
- ? [createKilnProjectDef(context.projectStore, context.projectBundleReader)]
+ ? [
+ createKilnProjectDef(
+ context.projectStore,
+ context.projectBundleReader,
+ context.assetLibrary,
+ ),
+ ]
: []),
...(context.materialLibrary
? [createKilnMaterialDef(context.materialLibrary, presentation)]
@@ -2892,6 +2898,37 @@ async function parentRevisionComparison(
}
}
+/**
+ * The save-time report (#277): the revision being saved against its declared neighbours. It runs
+ * only when the call's bound project pins this exact collection and asset at a stated placement,
+ * so standalone work pays nothing and hears nothing. A check that cannot run never fails a save.
+ */
+async function savedComposition(
+ context: KilnToolContext,
+ library: import('../assets').AssetLibrary,
+ { collection, assetId }: { collection: string; assetId?: string },
+ glb: Uint8Array,
+): Promise<import('../project-composition').ProjectCompositionReportV1 | undefined> {
+ const project = context.workspace?.current()?.project;
+ if (
+ !project ||
+ !assetId ||
+ !project.inventory.some(
+ ({ asset, placement }) =>
+ placement && asset?.collectionId === collection && asset.assetId === assetId,
+ )
+ )
+ return undefined;
+ const { composeProjectModules, failedCompositionReport } = await import('../project-composition');
+ try {
+ return await composeProjectModules(project, library, {
+ subject: { collectionId: collection, assetId, glb },
+ });
+ } catch (error) {
+ return failedCompositionReport(project, error);
+ }
+}
+
/**
* The evaluation `kiln_save` persists, without its preview and with nothing written: a destination
* audit reads these bytes before a save, not after one (#309).
@@ -3140,9 +3177,15 @@ export function createKilnAssetDefs(
}
const code = await context.programStore!.get(input.programRef);
const draft = await buildProgramAssetDraft(code, callContext, backdrop);
- const asset = await target.save(input.collection, { ...input, ...draft });
+ const composition = await savedComposition(context, target, input, draft.glb);
+ const asset = await target.save(input.collection, {
+ ...input,
+ ...draft,
+ ...(composition ? { build: { ...draft.build!, composition } } : {}),
+ });
return {
...(await links(input.collection, asset)),
+ ...(composition ? { composition } : {}),
...(parent
? { comparison: await parentRevisionComparison(parent.files['asset.glb'], draft.glb) }
: {}),
diff --git a/src/viewer/project-editor.test.ts b/src/viewer/project-editor.test.ts
index e529ccb5..055c1384 100644
--- a/src/viewer/project-editor.test.ts
+++ b/src/viewer/project-editor.test.ts
@@ -1,6 +1,6 @@
import { expect, test } from 'bun:test';
import { projectDraftSchema, projectRevisionSchema } from '../projects';
-import { editableProjectConfig, projectFormDraft } from './project-editor';
+import { editableProjectConfig, placementLabel, projectFormDraft } from './project-editor';
test('editing basic project fields preserves inventory, exact dependency lock and design governance', () => {
const draft = projectDraftSchema.parse({
@@ -44,3 +44,31 @@ test('editable configuration excludes immutable identity and rejects invalid pal
).toThrow();
expect(() => projectFormDraft('{"revisionId":"overwrite"}', fields)).toThrow();
});
+
+test('saving the form keeps a stated placement and leaves an absent one absent', () => {
+ const draft = projectDraftSchema.parse({
+ name: 'Cove',
+ inventory: [
+ { id: 'wall', name: 'Wall', placement: { translation: [1, 2, 3], rotation: [0, 90, 0] } },
+ { id: 'identity', name: 'Identity', placement: {} },
+ { id: 'plan', name: 'Plan' },
+ ],
+ });
+ const result = projectFormDraft(JSON.stringify(editableProjectConfig(draft)), {
+ name: 'Cove',
+ brief: '',
+ style: '',
+ scale: '',
+ });
+ expect(result.inventory[0]!.placement).toEqual({ translation: [1, 2, 3], rotation: [0, 90, 0] });
+ expect(result.inventory[1]!.placement).toEqual({});
+ expect('placement' in result.inventory[2]!).toBe(false);
+});
+
+test('placement reads as what the check does with the item', () => {
+ expect(placementLabel(undefined)).toBe('Not composed');
+ expect(placementLabel({})).toBe('At origin');
+ expect(placementLabel({ translation: [1, 2, 3], rotation: [0, 90, 0], scale: [2, 2, 2] })).toBe(
+ 'Move 1, 2, 3 · turn 0, 90, 0° · scale 2, 2, 2',
+ );
+});
diff --git a/src/viewer/project-editor.ts b/src/viewer/project-editor.ts
index 3717f565..7b626e20 100644
--- a/src/viewer/project-editor.ts
+++ b/src/viewer/project-editor.ts
@@ -1,4 +1,16 @@
-import { projectDraftSchema, type ProjectDraft } from '../projects';
+import { projectDraftSchema, type InventoryPlacement, type ProjectDraft } from '../projects';
+
+/** What the composed check does with an item: only a stated placement joins it. */
+export function placementLabel(placement: InventoryPlacement | undefined): string {
+ if (!placement) return 'Not composed';
+ const { translation, rotation, scale } = placement;
+ const parts = [
+ translation && `Move ${translation.join(', ')}`,
+ rotation && `turn ${rotation.join(', ')}°`,
+ scale && `scale ${scale.join(', ')}`,
+ ].filter(Boolean);
+ return parts.join(' · ') || 'At origin';
+}
export function editableProjectConfig(project: ProjectDraft) {
const { palette, materialRoles, conventions, exceptions } = project.design ?? {};
diff --git a/src/viewer/project-membership.test.ts b/src/viewer/project-membership.test.ts
index 43ad2a38..5bf498c8 100644
--- a/src/viewer/project-membership.test.ts
+++ b/src/viewer/project-membership.test.ts
@@ -35,3 +35,24 @@ test('a new membership creates an inventory item, while detach cannot invent one
});
expect(() => membershipPatch(project, 'missing', null, '')).toThrow('Inventory item not found');
});
+test('replacing or removing a link keeps the item in its declared place', () => {
+ const placement = { translation: [1, 0, 0] as [number, number, number] };
+ const project = {
+ inventory: projectDraftSchema.parse({
+ name: 'Cove',
+ inventory: [{ id: 'wall', name: 'Wall', placement }],
+ }).inventory,
+ } as unknown as ProjectRevision;
+ const asset = { collectionId: 'project', assetId: 'wall', revisionId: 'r_two' };
+ const linked = membershipPatch(project, 'wall', asset, '').inventory[0]!;
+ expect(linked.placement).toEqual(placement);
+ expect(linked.asset).toEqual(asset);
+ const removed = membershipPatch(
+ { inventory: [linked] } as unknown as ProjectRevision,
+ 'wall',
+ null,
+ '',
+ ).inventory[0]!;
+ expect(removed.placement).toEqual(placement);
+ expect(removed.asset).toBeUndefined();
+});
diff --git a/src/viewer/projects-panel.ts b/src/viewer/projects-panel.ts
index b8980121..da3d37f1 100644
--- a/src/viewer/projects-panel.ts
+++ b/src/viewer/projects-panel.ts
@@ -1,6 +1,6 @@
/// <reference lib="dom" />
import type { ProjectRevision } from '../projects';
-import { editableProjectConfig, projectFormDraft } from './project-editor';
+import { editableProjectConfig, placementLabel, projectFormDraft } from './project-editor';
import { el, node, notice, request, empty, remember, recall, shortId, recordDetails } from './dom';
type AssetLink = NonNullable<ProjectRevision['inventory'][number]['asset']>;
@@ -122,7 +122,7 @@ export function mountProjects(options: {
table = node('table'),
head = node('thead'),
tr = node('tr');
- for (const label of ['Item', 'Kind', 'Saved revision', 'Review'])
+ for (const label of ['Item', 'Kind', 'Saved revision', 'Placement', 'Review'])
tr.append(node('th', label));
head.append(tr);
table.append(head);
@@ -156,7 +156,8 @@ export function mountProjects(options: {
saved.textContent = 'Not linked';
review.textContent = 'No saved revision';
}
- row.append(name, node('td', item.kind), saved, review);
+ const placement = node('td', placementLabel(item.placement));
+ row.append(name, node('td', item.kind), saved, placement, review);
body.append(row);
}
table.append(body);