From f5d4f9e0df070f8c1eb3655ee02a39e92bff9a84 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 22:07:46 +0000 Subject: [PATCH 1/2] Preview: move the image at once on zoom and pan, and render slow views coarse first Zooming or panning a slow preview (a vanilla-sized density function, say) showed nothing until the pointer stopped, then several seconds more: - The viewer sends a render every frame of a drag, and the worker started each one, rebuilding its sampler (and re-registering every vanilla bundle) before finding it stale. It now lets queued requests arrive first and starts only the newest, skips re-registering when nothing changed, and keeps the last built noise, density function or random state. - The image on screen now follows the camera with a CSS transform (and its grid with it) until the new render replaces it. Hover readouts, the pinned point and clicks map through that transform to the image's own pixels. Pointer input moved to a layer over the whole box, so a drag can start where the moved image left a gap. - Noise, density and biome maps that will take over 200 ms render a quarter resolution pass first (and a half one when over 1.5 s), sent as partial frames with a step the viewer scales by. On a density function of overworld/sloped_cheese in headless Chromium, the first image after releasing a drag went from about 6 s to 0.2 s. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AX3Tsz7uWdGNhKdk7UdNga --- packages/preview/src/preview/Preview.svelte | 208 ++++++++++++------ .../preview/src/preview/preview.worker.ts | 75 ++++++- packages/preview/src/preview/protocol.ts | 8 +- web/tests/smoke.spec.ts | 35 ++- 4 files changed, 257 insertions(+), 69 deletions(-) diff --git a/packages/preview/src/preview/Preview.svelte b/packages/preview/src/preview/Preview.svelte index e602ace..f75cac9 100644 --- a/packages/preview/src/preview/Preview.svelte +++ b/packages/preview/src/preview/Preview.svelte @@ -108,10 +108,17 @@ * CSS pixels per render pixel. Kept per render in flight, so the grid * lines up with the image shown, not the camera that moved since. */ - type SentView = { view: PreviewView; flat: boolean; resolution: number }; + type SentView = { view: PreviewView; flat: boolean; resolution: number; mode: PreviewMode }; const sentViews = new Map(); - /** How the image on screen was rendered. */ - let shownView = $state.raw(null); + /** + * How the image on screen was rendered, and its size in world terms: + * for a 2D view the blocks a pixel spans (a coarse pass spans more), for + * the 3D view a block's size in pixels. + */ + type ShownView = SentView & { scale: number }; + let shownView = $state.raw(null); + /** The preview's box in CSS pixels, kept for the image's transform. */ + let boxSize = $state.raw({ w: 0, h: 0 }); let lastTarget: string | null = null; let mode = $state('density'); let biome = $state('minecraft:plains'); @@ -422,7 +429,8 @@ } error = ''; last = r; - shownView = sentViews.get(r.seq) ?? null; + const sent = sentViews.get(r.seq); + shownView = sent ? { ...sent, scale: sent.mode === 'iso' ? r.scale || sent.view.scale : sent.view.scale * (r.step ?? 1) } : null; for (const k of sentViews.keys()) if (k < r.seq) sentViews.delete(k); // The worker picks the default size and keeps zooming out within what fills the canvas. if (r.scale && (!isoView.scale || r.scale > isoView.scale)) isoView.scale = r.scale; @@ -477,7 +485,10 @@ onMount(() => { startWorker(); const watcher = setInterval(watch, 1000); - const ro = new ResizeObserver(() => request()); + const ro = new ResizeObserver(() => { + boxSize = { w: box.clientWidth, h: box.clientHeight }; + request(); + }); ro.observe(box); return () => { ro.disconnect(); @@ -569,12 +580,11 @@ requestAnimationFrame(() => { pending = false; if (!worker || !info || !box) return; - const width = Math.max(16, Math.floor(box.clientWidth / resolution)); - const height = Math.max(16, Math.floor(box.clientHeight / resolution)); + const { w: width, h: height } = frame(); setBusy(true); if (mode === 'iso' || topBlocks) startHelpers(); const sent: PreviewView = { ...$state.snapshot(view), down: lookDown && canDown, blocks: mode === 'density' && blockValues }; - sentViews.set(seq + 1, { view: sent, flat, resolution }); + sentViews.set(seq + 1, { view: mode === 'iso' ? $state.snapshot(isoView) : sent, flat, resolution, mode }); worker.postMessage({ type: 'render', seq: ++seq, @@ -619,8 +629,8 @@ } else { ctx.putImageData(new ImageData(last.pixels, last.width, last.height), 0, 0); } - if (last.seaLevel !== undefined && mode === 'density' && !flat) { - const py = (view.y - last.seaLevel) / view.scale + last.height / 2; + if (last.seaLevel !== undefined && mode === 'density' && !flat && shownView) { + const py = (shownView.view.y - last.seaLevel) / shownView.scale + last.height / 2; ctx.strokeStyle = 'rgba(30, 80, 160, 0.6)'; ctx.setLineDash([4, 3]); ctx.beginPath(); @@ -691,16 +701,16 @@ // The image is stretched over the whole box. const sx = W / w; const sy = H / h; - const { view: v, flat } = shown; + const { view: v, flat, scale } = shown; const a = screenAxes(v.facing); // The world plane at the image's centre: u to the right, and v down // the screen (top-down) or up it (a side view, where v is y). const cu = v.x * a.rx + v.z * a.rz; const cv = flat ? v.x * a.dx + v.z * a.dz : v.y; - const xOf = (u: number) => ((u - cu) / v.scale + w / 2) * sx; - const yOf = (t: number) => ((flat ? t - cv : cv - t) / v.scale + h / 2) * sy; - const halfU = (w / 2) * v.scale; - const halfV = (h / 2) * v.scale; + const xOf = (u: number) => ((u - cu) / scale + w / 2) * sx; + const yOf = (t: number) => ((flat ? t - cv : cv - t) / scale + h / 2) * sy; + const halfU = (w / 2) * scale; + const halfV = (h / 2) * scale; const r = (n: number) => Math.round(n * 2) / 2; gridSize = { w: W, h: H }; gridPaths = gridShown.map((step, k) => { @@ -717,10 +727,10 @@ * right and v down it (top-down) or up it (side views, where v is y). * These map the camera and world points into it and back. */ - function planeOf(c: { x: number; y: number; z: number }, facing = view.facing): [number, number] { + function planeOf(c: { x: number; y: number; z: number }, facing = view.facing, isFlat = flat): [number, number] { const a = screenAxes(facing); const u = c.x * a.rx + c.z * a.rz; - return [u, flat ? c.x * a.dx + c.z * a.dz : c.y]; + return [u, isFlat ? c.x * a.dx + c.z * a.dz : c.y]; } /** Moves the camera to plane point (u, v), keeping the slice's depth (or a top-down view's y). */ function setPlane(u: number, v: number) { @@ -734,33 +744,41 @@ view.y = v; } } - /** The world block under a canvas point. */ + /** How the image on screen was rendered, or the camera before the first one. */ + function onScreen(): ShownView { + return shownView ?? { view, flat, resolution, mode, scale: view.scale }; + } + /** The world block under a point of the image on screen, in its own pixels. */ function toWorld(px: number, py: number): Point { - const [u, v] = flatWorld(px, py, view.scale, ...planeOf(view)); - const a = screenAxes(view.facing); - if (flat) { + const { view: v, flat: isFlat, scale } = onScreen(); + const w = last?.width ?? 0; + const h = last?.height ?? 0; + const [cu, cv] = planeOf(v, v.facing, isFlat); + const u = cu + (px - w / 2) * scale; + const t = isFlat ? cv + (py - h / 2) * scale : cv - (py - h / 2) * scale; + const a = screenAxes(v.facing); + if (isFlat) { // Top-down terrain shows a block at its own height; maps are at the camera's. - const i = Math.floor(py) * (last?.width ?? 0) + Math.floor(px); - const y = last?.heights?.[i]; - return { x: Math.floor(u * a.rx + v * a.dx), y: y === undefined || Number.isNaN(y) ? Math.floor(view.y) : y, z: Math.floor(u * a.rz + v * a.dz) }; + const y = px >= 0 && px < w && py >= 0 && py < h ? last?.heights?.[Math.floor(py) * w + Math.floor(px)] : undefined; + return { x: Math.floor(u * a.rx + t * a.dx), y: y === undefined || Number.isNaN(y) ? Math.floor(v.y) : y, z: Math.floor(u * a.rz + t * a.dz) }; } - return a.rx - ? { x: Math.floor(u * a.rx), y: Math.floor(v), z: Math.floor(view.z) } - : { x: Math.floor(view.x), y: Math.floor(v), z: Math.floor(u * a.rz) }; + return a.rx ? { x: Math.floor(u * a.rx), y: Math.floor(t), z: Math.floor(v.z) } : { x: Math.floor(v.x), y: Math.floor(t), z: Math.floor(u * a.rz) }; } - /** The canvas point at the middle of a world block. */ + /** The point of the image on screen, in its own pixels, at the middle of a world block. */ function toPixel(p: Point): [number, number] { + const { view: v, flat: isFlat, scale } = onScreen(); const w = last?.width ?? 0; const h = last?.height ?? 0; - const [u, v] = planeOf({ x: p.x + 0.5, y: p.y + 0.5, z: p.z + 0.5 }); - const [cu, cv] = planeOf(view); - return [(u - cu) / view.scale + w / 2, flat ? (v - cv) / view.scale + h / 2 : (cv - v) / view.scale + h / 2]; + const [u, t] = planeOf({ x: p.x + 0.5, y: p.y + 0.5, z: p.z + 0.5 }, v.facing, isFlat); + const [cu, cv] = planeOf(v, v.facing, isFlat); + return [(u - cu) / scale + w / 2, isFlat ? (t - cv) / scale + h / 2 : (cv - t) / scale + h / 2]; } - /** Whether a world block is in the slice or map shown (a side view shows one depth, a map one y). */ + /** Whether a world block is in the slice or map on screen (a side view shows one depth, a map one y). */ function inView(p: Point): boolean { - const a = screenAxes(view.facing); - if (flat) return true; - return a.rx ? p.z === Math.floor(view.z) : p.x === Math.floor(view.x); + const { view: v, flat: isFlat } = onScreen(); + const a = screenAxes(v.facing); + if (isFlat) return true; + return a.rx ? p.z === Math.floor(v.z) : p.x === Math.floor(v.x); } function coords(p: Point): string { return flat && !topBlocks ? `x ${p.x}, z ${p.z}` : `x ${p.x}, y ${p.y}, z ${p.z}`; @@ -799,9 +817,61 @@ /** Whether this gesture pinched, so lifting a finger after it doesn't count as a tap. */ let pinched = false; + /** The size, in render pixels, of a render of a box this size. */ + function frameOf(b: { w: number; h: number }) { + return { w: Math.max(16, Math.floor(b.w / resolution)), h: Math.max(16, Math.floor(b.h / resolution)) }; + } + function frame() { + return frameOf({ w: box.clientWidth, h: box.clientHeight }); + } + /** + * Where the image on screen goes once the camera has moved since it was + * rendered, so a pan or zoom moves it at once rather than waiting for the + * new render: along each side, image pixel i lands on pixel + * k·(i − size/2) + t + frame/2 of a render of the current view. Null when + * the image can't follow the camera (it turned, or changed view). + */ + const imageMap = $derived.by((): { k: number; tx: number; ty: number } | null => { + const s = shownView; + if (!s || !last || s.mode !== mode) return null; + if (mode === 'iso') { + // Screen x = (x - z)·s and y = (x + z)·s/2 about the camera. + const s1 = isoView.scale || s.scale; + const dx = s.view.x - isoView.x; + const dz = s.view.y - isoView.y; + return { k: s1 / s.scale, tx: (dx - dz) * s1, ty: ((dx + dz) * s1) / 2 }; + } + if (s.flat !== flat || s.view.facing !== view.facing) return null; + const [cu0, cv0] = planeOf(s.view); + const [cu, cv] = planeOf(view); + return { k: s.scale / view.scale, tx: (cu0 - cu) / view.scale, ty: (flat ? cv0 - cv : cv - cv0) / view.scale }; + }); + /** The CSS transform that puts the image where imageMap says, over the box it is stretched across. */ + const imageTransform = $derived.by(() => { + const m = imageMap; + if (!m || !last || !boxSize.w || !boxSize.h) return ''; + const f = frameOf(boxSize); + const ax = (m.k * last.width) / f.w; + const ay = (m.k * last.height) / f.h; + const bx = (boxSize.w / f.w) * (m.tx + f.w / 2 - (m.k * last.width) / 2); + const by = (boxSize.h / f.h) * (m.ty + f.h / 2 - (m.k * last.height) / 2); + if (Math.abs(ax - 1) < 1e-6 && Math.abs(ay - 1) < 1e-6 && Math.abs(bx) < 0.01 && Math.abs(by) < 0.01) return ''; + return `matrix(${ax}, 0, 0, ${ay}, ${bx}, ${by})`; + }); + /** The image's own pixel under a point of the current view's frame. */ + function toImage(p: { px: number; py: number }): { px: number; py: number } { + const w = last?.width ?? 1; + const h = last?.height ?? 1; + const f = frameOf(boxSize); + const m = imageMap; + if (!m) return { px: (p.px * w) / f.w, py: (p.py * h) / f.h }; + return { px: (p.px - m.tx - f.w / 2) / m.k + w / 2, py: (p.py - m.ty - f.h / 2) / m.k + h / 2 }; + } + /** A pointer's position in the current view's frame, in render pixels. */ function pointer(e: { clientX: number; clientY: number }) { - const r = canvas.getBoundingClientRect(); - return { px: ((e.clientX - r.left) / r.width) * (last?.width ?? 1), py: ((e.clientY - r.top) / r.height) * (last?.height ?? 1) }; + const r = box.getBoundingClientRect(); + const f = frame(); + return { px: ((e.clientX - r.left) / r.width) * f.w, py: ((e.clientY - r.top) / r.height) * f.h }; } /** The current block size of the 3D view (before its first render, what the worker picked). */ function isoScale(): number { @@ -809,14 +879,16 @@ } /** The world x/z under a canvas point of the 3D view, at block size s (screen x = (x - z)·s, y = (x + z)·s/2). */ function isoWorld(px: number, py: number, s: number, vx: number, vz: number): [number, number] { - const dx = px - (last?.width ?? 0) / 2; - const dy = py - (last?.height ?? 0) / 2; + const f = frame(); + const dx = px - f.w / 2; + const dy = py - f.h / 2; return [vx + (dx / s + (2 * dy) / s) / 2, vz + ((2 * dy) / s - dx / s) / 2]; } /** The world point under a canvas point of a 2D view. */ function flatWorld(px: number, py: number, scale: number, vx: number, vy: number): [number, number] { - const dx = px - (last?.width ?? 0) / 2; - const dy = py - (last?.height ?? 0) / 2; + const f = frame(); + const dx = px - f.w / 2; + const dy = py - f.h / 2; return [vx + dx * scale, flat ? vy + dy * scale : vy - dy * scale]; } /** @@ -860,7 +932,7 @@ } function down(e: PointerEvent) { - canvas.setPointerCapture(e.pointerId); + (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId); if (pointers.size === 0) pinched = false; pointers.set(e.pointerId, { x: e.clientX, y: e.clientY }); if (pointers.size === 2) startPinch(); @@ -910,7 +982,7 @@ return; } if (e.type === 'pointerup' && drag && !drag.moved && !pinched && mode !== 'iso') { - const p = pointer(e); + const p = toImage(pointer(e)); const at = toWorld(p.px, p.py); lock = lock && lock.x === at.x && lock.y === at.y && lock.z === at.z ? null : at; draw(); @@ -933,7 +1005,7 @@ } const readout = $derived.by(() => { - const at = hover; + const at = hover && toImage(hover); if (!at || !last || mode === 'iso') return ''; const ix = Math.floor(at.px); const iy = Math.floor(at.py); @@ -947,7 +1019,7 @@ }); /** The value under the pointer, for the scale's marker. */ const hoverValue = $derived.by(() => { - const at = hover; + const at = hover && toImage(hover); if (!at || !last || (mode !== 'density' && !layerValues)) return NaN; const ix = Math.floor(at.px); const iy = Math.floor(at.py); @@ -964,7 +1036,10 @@ let ix: number; let iy: number; if (lock) [ix, iy] = toPixel(lock).map(Math.floor); - else if (hover) [ix, iy] = [Math.floor(hover.px), Math.floor(hover.py)]; + else if (hover) { + const at = toImage(hover); + [ix, iy] = [Math.floor(at.px), Math.floor(at.py)]; + } else return null; if (ix < 0 || iy < 0 || ix >= last.width || iy >= last.height) return null; const n = last.width * last.height; @@ -1187,28 +1262,37 @@ {hint} {/if} -
- + +
+ + {#if info && last && gridShown.length && gridPaths.length} + + + {/if} +
+ + {#if info && error}
Preview failed: {error} diff --git a/packages/preview/src/preview/preview.worker.ts b/packages/preview/src/preview/preview.worker.ts index b74950c..93e81b6 100644 --- a/packages/preview/src/preview/preview.worker.ts +++ b/packages/preview/src/preview/preview.worker.ts @@ -88,7 +88,14 @@ function register(kind: Folder, id: string, json: unknown) { r.register(Identifier.parse(id), () => r.parse(json)); } +/** The files and bundles the registries were last filled from. */ +let registered = ''; function registerAll() { + // Refilling is costly (every vanilla bundle is parsed again), and a pan + // asks for it on every render and strip: skip it when nothing changed. + const key = `${version}|${[...bundles.keys()].join(',')}`; + if (key === registered) return; + registered = key; biomeTags.clear(); for (const r of Object.values(registries)) { // Builtin entries (the surface noises) survive; everything else @@ -1426,6 +1433,20 @@ function sampler(width: number, values: Float32Array, blocks: boolean, scale: nu }; } +/** + * The last noise, density function or random state built for a 2D view, + * so panning and zooming sample the same one instead of building it again + * for every frame. + */ +let built: { key: string; value: unknown } | null = null; +async function buildOnce(req: RenderRequest, build: () => T): Promise { + const key = [version, req.seed, req.kind, req.mode, req.id].join('|'); + if (built?.key === key) return built.value as T; + const value = await withVanilla(build); + built = { key, value }; + return value; +} + async function render(req: RenderRequest): Promise { const { width, height, view } = req; const seed = seedOf(req.seed); @@ -1440,7 +1461,7 @@ async function render(req: RenderRequest): Promise { if (v > max) max = v; }; if (req.kind === 'dimension' && req.mode === 'biomes') { - const { dim, rs } = await withVanilla(() => { + const { dim, rs } = await buildOnce(req, () => { const dim = readDimension(req.id); const rs = new RandomState(dim.settings, seed); // Touch the climate router, so missing entries are fetched now. @@ -1468,7 +1489,7 @@ async function render(req: RenderRequest): Promise { if (req.kind === 'noise') { // Top-down, at the camera's y. - const noise = await withVanilla(() => { + const noise = await buildOnce(req, () => { const rs = new RandomState(NoiseGeneratorSettings.create({}), seed); return rs.getOrCreateNoise(id); }); @@ -1488,7 +1509,7 @@ async function render(req: RenderRequest): Promise { if (req.kind === 'density_function') { // Side view: the slice through the camera, y up (or top-down, at the camera's y). - const fn = await withVanilla(() => { + const fn = await buildOnce(req, () => { const rs = new RandomState(NoiseGeneratorSettings.create({}), seed); // A reference holder, so the visitor binds noises and caches by id. const df = new DensityFunction.HolderHolder(Holder.reference(WorldgenRegistries.DENSITY_FUNCTION, id)); @@ -1511,7 +1532,7 @@ async function render(req: RenderRequest): Promise { } // Noise settings, density mode: the terrain's final density. - const { settings, router } = await withVanilla(() => { + const { settings, router } = await buildOnce(req, () => { const settings = WorldgenRegistries.NOISE_SETTINGS.getOrThrow(id); const rs = speedUp(new RandomState(settings, seed)); return { settings, router: rs.router as NoiseRouter }; @@ -1564,6 +1585,45 @@ async function render(req: RenderRequest): Promise { return { type: 'rendered', seq: req.seq, width, height, pixels, values, min, max, seaLevel: sea, minY, maxY }; } +/** How much coarser a slow 2D view's first pass is, along each side. */ +const coarseStep = 4; +/** Shows a coarse pass when the full one will take longer than this, in ms. */ +const coarseWorth = 200; +/** Adds a half-resolution pass between them when the full one will take longer than this. */ +const halfWorth = 1500; + +/** + * Renders a sampled 2D view (noise, density, biome map) coarsely first + * when it is slow, so a zoom or pan shows the new view soon and sharpens + * as finer passes finish. Terrain views have their own caches and + * partial frames. + */ +async function progressive(req: RenderRequest): Promise { + const sampled = + req.kind === 'noise' || req.kind === 'density_function' || (req.kind === 'noise_settings' && req.mode === 'density') || (req.kind === 'dimension' && req.mode === 'biomes'); + if (!sampled || req.width < coarseStep * 8 || req.height < coarseStep * 8) return render(req); + const pass = (step: number): Promise => + render({ + ...req, + width: Math.ceil(req.width / step), + height: Math.ceil(req.height / step), + view: { ...req.view, scale: req.view.scale * step } + }); + const started = performance.now(); + const first = await pass(coarseStep); + current(req); + // The full pass samples coarseStep² as many pixels. + const full = (performance.now() - started) * coarseStep * coarseStep; + if (full < coarseWorth) return render(req); + post({ ...first, partial: true, step: coarseStep }); + if (full > halfWorth) { + const half = await pass(2); + current(req); + post({ ...half, partial: true, step: 2 }); + } + return render(req); +} + function post(res: Rendered) { const transfer: Transferable[] = [res.pixels.buffer, res.values.buffer]; if (res.bitmap) transfer.push(res.bitmap); @@ -1607,11 +1667,16 @@ self.onmessage = async (e: MessageEvent) => { return; } latest = req.seq; + // A drag or a wheel sends a render a frame. Let the ones already queued + // arrive first, so only the newest starts instead of each one building + // its sampler before finding it is stale. + await breathe(); + if (req.seq !== latest) return; // Said before any work, so a viewer that finds this worker stuck knows // which render it got to: newer ones never started. (self as unknown as Worker).postMessage({ type: 'started', seq: req.seq } satisfies PreviewResponse); try { - const res = await render(req); + const res = await progressive(req); if (res.seq !== latest) return; // superseded while fetching post(res); } catch (err) { diff --git a/packages/preview/src/preview/protocol.ts b/packages/preview/src/preview/protocol.ts index 790341a..e18dc1b 100644 --- a/packages/preview/src/preview/protocol.ts +++ b/packages/preview/src/preview/protocol.ts @@ -159,8 +159,14 @@ export type PreviewResponse = heights?: Float32Array; /** For the isometric view: the image itself, drawn in the worker (pixels is then empty). */ bitmap?: ImageBitmap; - /** More of this render follows (chunks are still being built). */ + /** More of this render follows (chunks are still being built, or this is a coarse first pass). */ partial?: boolean; + /** + * For a coarse first pass of a 2D view: how many of the asked-for + * pixels each of its pixels spans along a side (it was sampled at + * step times the view's scale). + */ + step?: number; /** Something to tell the viewer about an otherwise empty render. */ notice?: string; /** For terrain: the sea level and world height. */ diff --git a/web/tests/smoke.spec.ts b/web/tests/smoke.spec.ts index ad114b8..875e98c 100644 --- a/web/tests/smoke.spec.ts +++ b/web/tests/smoke.spec.ts @@ -236,6 +236,38 @@ test('the preview shows a grid, and per-block values when asked', async ({ page expect(errors).toEqual([]); }); +test('zooming and panning move the image on screen at once, before the new render lands', async ({ page }) => { + const errors: string[] = []; + page.on('pageerror', (e) => errors.push(e.message)); + await page.goto('./'); + await expect(status(page)).toHaveText(/No problems/, { timeout: 30_000 }); + await replaceText(page, 'DensityFunction grad = Gradient(axis = y, from_coordinate = 0, to_coordinate = 512, from_value = 0, to_value = 1)\n'); + await expect(status(page)).toHaveText(/No problems/); + await page.locator('.cm-line').first().click(); + await expect(page.getByLabel('Value scale')).toContainText(/in view/, { timeout: 20_000 }); + const image = page.locator('canvas').locator('..'); + await expect.poll(() => image.evaluate((e) => e.style.transform)).toBe(''); + + // A wheel zooms out about the pointer: the image shrinks towards it in + // the same frame, with no worker message in between. + const moved = await page.locator('[data-preview-input]').evaluate(async (input) => { + const r = input.getBoundingClientRect(); + input.dispatchEvent(new WheelEvent('wheel', { deltaY: 400, clientX: r.left + r.width / 4, clientY: r.top + r.height / 2, bubbles: true, cancelable: true })); + for (let i = 0; i < 10; i++) await Promise.resolve(); + return (input.previousElementSibling as HTMLElement).style.transform; + }); + const [a, , , d, e] = /matrix\((.*)\)/.exec(moved)![1].split(',').map(Number); + expect(a).toBeLessThan(1); + expect(d).toBeCloseTo(a, 5); + // The point under the pointer (a quarter of the way across) stays put. + const width = (await page.locator('[data-preview-input]').boundingBox())!.width; + expect(Math.abs(e + (a * width) / 4 - width / 4)).toBeLessThan(3); + + // The new render lands and replaces it. + await expect.poll(() => image.evaluate((e) => e.style.transform), { timeout: 20_000 }).toBe(''); + expect(errors).toEqual([]); +}); + test('dimensions, noise settings and surface rules preview as terrain', async ({ page }) => { const errors: string[] = []; page.on('pageerror', (e) => errors.push(e.message)); @@ -1064,7 +1096,8 @@ test.describe('on a phone', () => { const worldAt = async () => { const v = await view(); return canvas.evaluate((c: HTMLCanvasElement, [x, y, v]) => { - const r = c.getBoundingClientRect(); + // The preview's box: the image itself moves with the camera until its render lands. + const r = c.parentElement!.parentElement!.getBoundingClientRect(); const dx = ((x - r.left) / r.width) * c.width - c.width / 2; const dy = ((y - r.top) / r.height) * c.height - c.height / 2; return [v.x + (dx / v.scale + (2 * dy) / v.scale) / 2, v.y + ((2 * dy) / v.scale - dx / v.scale) / 2]; From cca0095afe1339fa51caed06677a84bb86a10f42 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 22:09:23 +0000 Subject: [PATCH 2/2] Rebuild the MCP server's preview bundle Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AX3Tsz7uWdGNhKdk7UdNga --- engine/mcp/preview/agent.mjs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/engine/mcp/preview/agent.mjs b/engine/mcp/preview/agent.mjs index 3a438e0..5c78d10 100644 --- a/engine/mcp/preview/agent.mjs +++ b/engine/mcp/preview/agent.mjs @@ -1,12 +1,12 @@ -var Xu=Object.create;var Ko=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var Vu=Object.getOwnPropertyNames;var Ku=Object.getPrototypeOf,Qu=Object.prototype.hasOwnProperty;var et=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ef=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Vu(t))!Qu.call(e,s)&&s!==r&&Ko(e,s,{get:()=>t[s],enumerable:!(n=Wu(t,s))||n.enumerable});return e};var mr=(e,t,r)=>(r=e!=null?Xu(Ku(e)):{},ef(t||!e||!e.__esModule?Ko(r,"default",{value:e,enumerable:!0}):r,e));var yt=et(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.RANDOM=We.EPSILON=We.ARRAY_TYPE=We.ANGLE_ORDER=void 0;We.equals=hm;We.round=om;We.setMatrixArrayType=am;We.toDegree=fm;We.toRadian=um;var im=We.EPSILON=1e-6,sm=We.ARRAY_TYPE=typeof Float32Array<"u"?Float32Array:Array,_b=We.RANDOM=Math.random,Mb=We.ANGLE_ORDER="zyx";function om(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}function am(e){We.ARRAY_TYPE=sm=e}var cm=Math.PI/180,lm=180/Math.PI;function um(e){return e*cm}function fm(e){return e*lm}function hm(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:im;return Math.abs(e-t)<=r*Math.max(1,Math.abs(e),Math.abs(t))}});var Wc=et(ve=>{"use strict";function Vs(e){"@babel/helpers - typeof";return Vs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vs(e)}Object.defineProperty(ve,"__esModule",{value:!0});ve.LDU=Nm;ve.add=Rm;ve.adjoint=bm;ve.clone=mm;ve.copy=pm;ve.create=dm;ve.determinant=_m;ve.equals=zm;ve.exactEquals=Tm;ve.frob=Am;ve.fromRotation=km;ve.fromScaling=Im;ve.fromValues=wm;ve.identity=gm;ve.invert=ym;ve.mul=void 0;ve.multiply=Hc;ve.multiplyScalar=Pm;ve.multiplyScalarAndAdd=Om;ve.rotate=Mm;ve.scale=Sm;ve.set=xm;ve.str=Em;ve.sub=void 0;ve.subtract=Xc;ve.transpose=vm;var lr=Zc(yt());function Zc(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Zc=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||Vs(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function dm(){var e=new lr.ARRAY_TYPE(4);return lr.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function mm(e){var t=new lr.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function pm(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function gm(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function wm(e,t,r,n){var s=new lr.ARRAY_TYPE(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=n,s}function xm(e,t,r,n,s){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e}function vm(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function ym(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*i-s*n;return o?(o=1/o,e[0]=i*o,e[1]=-n*o,e[2]=-s*o,e[3]=r*o,e):null}function bm(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e}function _m(e){return e[0]*e[3]-e[2]*e[1]}function Hc(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*a+i*l,e[1]=s*a+o*l,e[2]=n*c+i*u,e[3]=s*c+o*u,e}function Mm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*a,e[1]=s*l+o*a,e[2]=n*-a+i*l,e[3]=s*-a+o*l,e}function Sm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1];return e[0]=n*a,e[1]=s*a,e[2]=i*l,e[3]=o*l,e}function km(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=-r,e[3]=n,e}function Im(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function Em(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function Am(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3])}function Nm(e,t,r,n){return e[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-e[2]*r[1],[e,t,r]}function Rm(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Xc(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Tm(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function zm(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(r-o)<=lr.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=lr.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-l)<=lr.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(i-c)<=lr.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))}function Pm(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function Om(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}var kb=ve.mul=Hc,Ib=ve.sub=Xc});var el=et(be=>{"use strict";function Ks(e){"@babel/helpers - typeof";return Ks=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ks(e)}Object.defineProperty(be,"__esModule",{value:!0});be.add=Vm;be.clone=Lm;be.copy=Cm;be.create=Bm;be.determinant=Ym;be.equals=t0;be.exactEquals=e0;be.frob=Wm;be.fromRotation=Gm;be.fromScaling=Zm;be.fromTranslation=Hm;be.fromValues=$m;be.identity=Fm;be.invert=qm;be.mul=void 0;be.multiply=Kc;be.multiplyScalar=Km;be.multiplyScalarAndAdd=Qm;be.rotate=Jm;be.scale=Um;be.set=Dm;be.str=Xm;be.sub=void 0;be.subtract=Qc;be.translate=jm;var Lt=Vc(yt());function Vc(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Vc=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||Ks(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function Bm(){var e=new Lt.ARRAY_TYPE(6);return Lt.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function Lm(e){var t=new Lt.ARRAY_TYPE(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function Cm(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function Fm(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function $m(e,t,r,n,s,i){var o=new Lt.ARRAY_TYPE(6);return o[0]=e,o[1]=t,o[2]=r,o[3]=n,o[4]=s,o[5]=i,o}function Dm(e,t,r,n,s,i,o){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e}function qm(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=r*i-n*s;return l?(l=1/l,e[0]=i*l,e[1]=-n*l,e[2]=-s*l,e[3]=r*l,e[4]=(s*a-i*o)*l,e[5]=(n*o-r*a)*l,e):null}function Ym(e){return e[0]*e[3]-e[1]*e[2]}function Kc(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1],h=r[2],d=r[3],f=r[4],m=r[5];return e[0]=n*c+i*u,e[1]=s*c+o*u,e[2]=n*h+i*d,e[3]=s*h+o*d,e[4]=n*f+i*m+a,e[5]=s*f+o*m+l,e}function Jm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*c,e[1]=s*u+o*c,e[2]=n*-c+i*u,e[3]=s*-c+o*u,e[4]=a,e[5]=l,e}function Um(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1];return e[0]=n*c,e[1]=s*c,e[2]=i*u,e[3]=o*u,e[4]=a,e[5]=l,e}function jm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=n*c+i*u+a,e[5]=s*c+o*u+l,e}function Gm(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=-r,e[3]=n,e[4]=0,e[5]=0,e}function Zm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e}function Hm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function Xm(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"}function Wm(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+1)}function Vm(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e}function Qc(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}function Km(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e}function Qm(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e}function e0(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]}function t0(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=t[0],c=t[1],u=t[2],h=t[3],d=t[4],f=t[5];return Math.abs(r-l)<=Lt.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-c)<=Lt.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(s-u)<=Lt.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(i-h)<=Lt.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=Lt.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-f)<=Lt.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))}var Ab=be.mul=Kc,Nb=be.sub=Qc});var eo=et(fe=>{"use strict";function Qs(e){"@babel/helpers - typeof";return Qs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qs(e)}Object.defineProperty(fe,"__esModule",{value:!0});fe.add=k0;fe.adjoint=f0;fe.clone=i0;fe.copy=s0;fe.create=r0;fe.determinant=h0;fe.equals=N0;fe.exactEquals=A0;fe.frob=S0;fe.fromMat2d=v0;fe.fromMat4=n0;fe.fromQuat=y0;fe.fromRotation=w0;fe.fromScaling=x0;fe.fromTranslation=g0;fe.fromValues=o0;fe.identity=c0;fe.invert=u0;fe.mul=void 0;fe.multiply=rl;fe.multiplyScalar=I0;fe.multiplyScalarAndAdd=E0;fe.normalFromMat4=b0;fe.projection=_0;fe.rotate=m0;fe.scale=p0;fe.set=a0;fe.str=M0;fe.sub=void 0;fe.subtract=nl;fe.translate=d0;fe.transpose=l0;var ct=tl(yt());function tl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(tl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||Qs(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function r0(){var e=new ct.ARRAY_TYPE(9);return ct.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function n0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function i0(e){var t=new ct.ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function s0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function o0(e,t,r,n,s,i,o,a,l){var c=new ct.ARRAY_TYPE(9);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=s,c[5]=i,c[6]=o,c[7]=a,c[8]=l,c}function a0(e,t,r,n,s,i,o,a,l,c){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e[8]=c,e}function c0(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function l0(e,t){if(e===t){var r=t[1],n=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,e[7]=s}else 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];return e}function u0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=-u*i+a*l,f=c*i-o*l,m=r*h+n*d+s*f;return m?(m=1/m,e[0]=h*m,e[1]=(-u*n+s*c)*m,e[2]=(a*n-s*o)*m,e[3]=d*m,e[4]=(u*r-s*l)*m,e[5]=(-a*r+s*i)*m,e[6]=f*m,e[7]=(-c*r+n*l)*m,e[8]=(o*r-n*i)*m,e):null}function f0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=o*u-a*c,e[1]=s*c-n*u,e[2]=n*a-s*o,e[3]=a*l-i*u,e[4]=r*u-s*l,e[5]=s*i-r*a,e[6]=i*c-o*l,e[7]=n*l-r*c,e[8]=r*o-n*i,e}function h0(e){var t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*s+o*a)+n*(l*s-i*a)}function rl(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=r[0],f=r[1],m=r[2],p=r[3],g=r[4],w=r[5],x=r[6],v=r[7],y=r[8];return e[0]=d*n+f*o+m*c,e[1]=d*s+f*a+m*u,e[2]=d*i+f*l+m*h,e[3]=p*n+g*o+w*c,e[4]=p*s+g*a+w*u,e[5]=p*i+g*l+w*h,e[6]=x*n+v*o+y*c,e[7]=x*s+v*a+y*u,e[8]=x*i+v*l+y*h,e}function d0(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=r[0],f=r[1];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=a,e[5]=l,e[6]=d*n+f*o+c,e[7]=d*s+f*a+u,e[8]=d*i+f*l+h,e}function m0(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(r),f=Math.cos(r);return e[0]=f*n+d*o,e[1]=f*s+d*a,e[2]=f*i+d*l,e[3]=f*o-d*n,e[4]=f*a-d*s,e[5]=f*l-d*i,e[6]=c,e[7]=u,e[8]=h,e}function p0(e,t,r){var n=r[0],s=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function g0(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function w0(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=-r,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function x0(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function v0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function y0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,l=s+s,c=r*o,u=n*o,h=n*a,d=s*o,f=s*a,m=s*l,p=i*o,g=i*a,w=i*l;return e[0]=1-h-m,e[3]=u-w,e[6]=d+g,e[1]=u+w,e[4]=1-c-m,e[7]=f-p,e[2]=d-g,e[5]=f+p,e[8]=1-c-h,e}function b0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g,$=x*Y-v*F+y*z+I*N-b*A+k*E;return $?($=1/$,e[0]=(a*Y-l*F+c*z)*$,e[1]=(l*N-o*Y-c*A)*$,e[2]=(o*F-a*N+c*E)*$,e[3]=(s*F-n*Y-i*z)*$,e[4]=(r*Y-s*N+i*A)*$,e[5]=(n*N-r*F-i*E)*$,e[6]=(p*k-g*b+w*I)*$,e[7]=(g*y-m*k-w*v)*$,e[8]=(m*b-p*y+w*x)*$,e):null}function _0(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function M0(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function S0(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8])}function k0(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e}function nl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}function I0(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e}function E0(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e}function A0(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function N0(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=t[0],d=t[1],f=t[2],m=t[3],p=t[4],g=t[5],w=t[6],x=t[7],v=t[8];return Math.abs(r-h)<=ct.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-d)<=ct.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(s-f)<=ct.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(i-m)<=ct.EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(o-p)<=ct.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(a-g)<=ct.EPSILON*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(l-w)<=ct.EPSILON*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-x)<=ct.EPSILON*Math.max(1,Math.abs(c),Math.abs(x))&&Math.abs(u-v)<=ct.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))}var Tb=fe.mul=rl,zb=fe.sub=nl});var ro=et(H=>{"use strict";function to(e){"@babel/helpers - typeof";return to=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},to(e)}Object.defineProperty(H,"__esModule",{value:!0});H.add=hp;H.adjoint=C0;H.clone=T0;H.copy=z0;H.create=R0;H.decompose=ep;H.determinant=F0;H.equals=gp;H.exactEquals=pp;H.frob=fp;H.fromQuat=np;H.fromQuat2=V0;H.fromRotation=Z0;H.fromRotationTranslation=al;H.fromRotationTranslationScale=tp;H.fromRotationTranslationScaleOrigin=rp;H.fromScaling=G0;H.fromTranslation=j0;H.fromValues=P0;H.fromXRotation=H0;H.fromYRotation=X0;H.fromZRotation=W0;H.frustum=ip;H.getRotation=Q0;H.getScaling=cl;H.getTranslation=K0;H.identity=sl;H.invert=L0;H.lookAt=cp;H.mul=void 0;H.multiply=ol;H.multiplyScalar=dp;H.multiplyScalarAndAdd=mp;H.ortho=void 0;H.orthoNO=ul;H.orthoZO=ap;H.perspective=void 0;H.perspectiveFromFieldOfView=op;H.perspectiveNO=ll;H.perspectiveZO=sp;H.rotate=q0;H.rotateX=Y0;H.rotateY=J0;H.rotateZ=U0;H.scale=D0;H.set=O0;H.str=up;H.sub=void 0;H.subtract=fl;H.targetTo=lp;H.translate=$0;H.transpose=B0;var ke=il(yt());function il(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(il=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||to(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function R0(){var e=new ke.ARRAY_TYPE(16);return ke.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function T0(e){var t=new ke.ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function z0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function P0(e,t,r,n,s,i,o,a,l,c,u,h,d,f,m,p){var g=new ke.ARRAY_TYPE(16);return g[0]=e,g[1]=t,g[2]=r,g[3]=n,g[4]=s,g[5]=i,g[6]=o,g[7]=a,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=m,g[15]=p,g}function O0(e,t,r,n,s,i,o,a,l,c,u,h,d,f,m,p,g){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e[8]=c,e[9]=u,e[10]=h,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=g,e}function sl(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function B0(e,t){if(e===t){var r=t[1],n=t[2],s=t[3],i=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function L0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g,$=x*Y-v*F+y*z+I*N-b*A+k*E;return $?($=1/$,e[0]=(a*Y-l*F+c*z)*$,e[1]=(s*F-n*Y-i*z)*$,e[2]=(p*k-g*b+w*I)*$,e[3]=(d*b-h*k-f*I)*$,e[4]=(l*N-o*Y-c*A)*$,e[5]=(r*Y-s*N+i*A)*$,e[6]=(g*y-m*k-w*v)*$,e[7]=(u*k-d*y+f*v)*$,e[8]=(o*F-a*N+c*E)*$,e[9]=(n*N-r*F-i*E)*$,e[10]=(m*b-p*y+w*x)*$,e[11]=(h*y-u*b-f*x)*$,e[12]=(a*A-o*z-l*E)*$,e[13]=(r*z-n*A+s*E)*$,e[14]=(p*v-m*I-g*x)*$,e[15]=(u*I-h*v+d*x)*$,e):null}function C0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g;return e[0]=a*Y-l*F+c*z,e[1]=s*F-n*Y-i*z,e[2]=p*k-g*b+w*I,e[3]=d*b-h*k-f*I,e[4]=l*N-o*Y-c*A,e[5]=r*Y-s*N+i*A,e[6]=g*y-m*k-w*v,e[7]=u*k-d*y+f*v,e[8]=o*F-a*N+c*E,e[9]=n*N-r*F-i*E,e[10]=m*b-p*y+w*x,e[11]=h*y-u*b-f*x,e[12]=a*A-o*z-l*E,e[13]=r*z-n*A+s*E,e[14]=p*v-m*I-g*x,e[15]=u*I-h*v+d*x,e}function F0(e){var t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],p=e[14],g=e[15],w=t*o-r*i,x=t*a-n*i,v=r*a-n*o,y=c*m-u*f,I=c*p-h*f,b=u*p-h*m,k=t*b-r*I+n*y,E=i*b-o*I+a*y,A=c*v-u*x+h*w,N=f*v-m*x+p*w;return l*k-s*E+g*A-d*N}function ol(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],f=t[10],m=t[11],p=t[12],g=t[13],w=t[14],x=t[15],v=r[0],y=r[1],I=r[2],b=r[3];return e[0]=v*n+y*a+I*h+b*p,e[1]=v*s+y*l+I*d+b*g,e[2]=v*i+y*c+I*f+b*w,e[3]=v*o+y*u+I*m+b*x,v=r[4],y=r[5],I=r[6],b=r[7],e[4]=v*n+y*a+I*h+b*p,e[5]=v*s+y*l+I*d+b*g,e[6]=v*i+y*c+I*f+b*w,e[7]=v*o+y*u+I*m+b*x,v=r[8],y=r[9],I=r[10],b=r[11],e[8]=v*n+y*a+I*h+b*p,e[9]=v*s+y*l+I*d+b*g,e[10]=v*i+y*c+I*f+b*w,e[11]=v*o+y*u+I*m+b*x,v=r[12],y=r[13],I=r[14],b=r[15],e[12]=v*n+y*a+I*h+b*p,e[13]=v*s+y*l+I*d+b*g,e[14]=v*i+y*c+I*f+b*w,e[15]=v*o+y*u+I*m+b*x,e}function $0(e,t,r){var n=r[0],s=r[1],i=r[2],o,a,l,c,u,h,d,f,m,p,g,w;return t===e?(e[12]=t[0]*n+t[4]*s+t[8]*i+t[12],e[13]=t[1]*n+t[5]*s+t[9]*i+t[13],e[14]=t[2]*n+t[6]*s+t[10]*i+t[14],e[15]=t[3]*n+t[7]*s+t[11]*i+t[15]):(o=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],f=t[7],m=t[8],p=t[9],g=t[10],w=t[11],e[0]=o,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=f,e[8]=m,e[9]=p,e[10]=g,e[11]=w,e[12]=o*n+u*s+m*i+t[12],e[13]=a*n+h*s+p*i+t[13],e[14]=l*n+d*s+g*i+t[14],e[15]=c*n+f*s+w*i+t[15]),e}function D0(e,t,r){var n=r[0],s=r[1],i=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function q0(e,t,r,n){var s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),l,c,u,h,d,f,m,p,g,w,x,v,y,I,b,k,E,A,N,z,F,Y,$,V;return a0?(r[0]=(a*o+u*n+l*i-c*s)*2/h,r[1]=(l*o+u*s+c*n-a*i)*2/h,r[2]=(c*o+u*i+a*s-l*n)*2/h):(r[0]=(a*o+u*n+l*i-c*s)*2,r[1]=(l*o+u*s+c*n-a*i)*2,r[2]=(c*o+u*i+a*s-l*n)*2),al(e,t,r),e}function K0(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function cl(e,t){var r=t[0],n=t[1],s=t[2],i=t[4],o=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(r*r+n*n+s*s),e[1]=Math.sqrt(i*i+o*o+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}function Q0(e,t){var r=new ke.ARRAY_TYPE(3);cl(r,t);var n=1/r[0],s=1/r[1],i=1/r[2],o=t[0]*n,a=t[1]*s,l=t[2]*i,c=t[4]*n,u=t[5]*s,h=t[6]*i,d=t[8]*n,f=t[9]*s,m=t[10]*i,p=o+u+m,g=0;return p>0?(g=Math.sqrt(p+1)*2,e[3]=.25*g,e[0]=(h-f)/g,e[1]=(d-l)/g,e[2]=(a-c)/g):o>u&&o>m?(g=Math.sqrt(1+o-u-m)*2,e[3]=(h-f)/g,e[0]=.25*g,e[1]=(a+c)/g,e[2]=(d+l)/g):u>m?(g=Math.sqrt(1+u-o-m)*2,e[3]=(d-l)/g,e[0]=(a+c)/g,e[1]=.25*g,e[2]=(h+f)/g):(g=Math.sqrt(1+m-o-u)*2,e[3]=(a-c)/g,e[0]=(d+l)/g,e[1]=(h+f)/g,e[2]=.25*g),e}function ep(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var s=n[0],i=n[1],o=n[2],a=n[4],l=n[5],c=n[6],u=n[8],h=n[9],d=n[10];r[0]=Math.sqrt(s*s+i*i+o*o),r[1]=Math.sqrt(a*a+l*l+c*c),r[2]=Math.sqrt(u*u+h*h+d*d);var f=1/r[0],m=1/r[1],p=1/r[2],g=s*f,w=i*m,x=o*p,v=a*f,y=l*m,I=c*p,b=u*f,k=h*m,E=d*p,A=g+y+E,N=0;return A>0?(N=Math.sqrt(A+1)*2,e[3]=.25*N,e[0]=(I-k)/N,e[1]=(b-x)/N,e[2]=(w-v)/N):g>y&&g>E?(N=Math.sqrt(1+g-y-E)*2,e[3]=(I-k)/N,e[0]=.25*N,e[1]=(w+v)/N,e[2]=(b+x)/N):y>E?(N=Math.sqrt(1+y-g-E)*2,e[3]=(b-x)/N,e[0]=(w+v)/N,e[1]=.25*N,e[2]=(I+k)/N):(N=Math.sqrt(1+E-g-y)*2,e[3]=(w-v)/N,e[0]=(b+x)/N,e[1]=(I+k)/N,e[2]=.25*N),e}function tp(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3],l=s+s,c=i+i,u=o+o,h=s*l,d=s*c,f=s*u,m=i*c,p=i*u,g=o*u,w=a*l,x=a*c,v=a*u,y=n[0],I=n[1],b=n[2];return e[0]=(1-(m+g))*y,e[1]=(d+v)*y,e[2]=(f-x)*y,e[3]=0,e[4]=(d-v)*I,e[5]=(1-(h+g))*I,e[6]=(p+w)*I,e[7]=0,e[8]=(f+x)*b,e[9]=(p-w)*b,e[10]=(1-(h+m))*b,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function rp(e,t,r,n,s){var i=t[0],o=t[1],a=t[2],l=t[3],c=i+i,u=o+o,h=a+a,d=i*c,f=i*u,m=i*h,p=o*u,g=o*h,w=a*h,x=l*c,v=l*u,y=l*h,I=n[0],b=n[1],k=n[2],E=s[0],A=s[1],N=s[2],z=(1-(p+w))*I,F=(f+y)*I,Y=(m-v)*I,$=(f-y)*b,V=(1-(d+w))*b,ce=(g+x)*b,oe=(m+v)*k,T=(g-x)*k,B=(1-(d+p))*k;return e[0]=z,e[1]=F,e[2]=Y,e[3]=0,e[4]=$,e[5]=V,e[6]=ce,e[7]=0,e[8]=oe,e[9]=T,e[10]=B,e[11]=0,e[12]=r[0]+E-(z*E+$*A+oe*N),e[13]=r[1]+A-(F*E+V*A+T*N),e[14]=r[2]+N-(Y*E+ce*A+B*N),e[15]=1,e}function np(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,l=s+s,c=r*o,u=n*o,h=n*a,d=s*o,f=s*a,m=s*l,p=i*o,g=i*a,w=i*l;return e[0]=1-h-m,e[1]=u+w,e[2]=d-g,e[3]=0,e[4]=u-w,e[5]=1-c-m,e[6]=f+p,e[7]=0,e[8]=d+g,e[9]=f-p,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ip(e,t,r,n,s,i,o){var a=1/(r-t),l=1/(s-n),c=1/(i-o);return e[0]=i*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*l,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+n)*l,e[10]=(o+i)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*c,e[15]=0,e}function ll(e,t,r,n,s){var i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){var o=1/(n-s);e[10]=(s+n)*o,e[14]=2*s*n*o}else e[10]=-1,e[14]=-2*n;return e}var Ob=H.perspective=ll;function sp(e,t,r,n,s){var i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){var o=1/(n-s);e[10]=s*o,e[14]=s*n*o}else e[10]=-1,e[14]=-n;return e}function op(e,t,r,n){var s=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(o+a),c=2/(s+i);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-((o-a)*l*.5),e[9]=(s-i)*c*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function ul(e,t,r,n,s,i,o){var a=1/(t-r),l=1/(n-s),c=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*l,e[14]=(o+i)*c,e[15]=1,e}var Bb=H.ortho=ul;function ap(e,t,r,n,s,i,o){var a=1/(t-r),l=1/(n-s),c=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*l,e[14]=i*c,e[15]=1,e}function cp(e,t,r,n){var s,i,o,a,l,c,u,h,d,f,m=t[0],p=t[1],g=t[2],w=n[0],x=n[1],v=n[2],y=r[0],I=r[1],b=r[2];return Math.abs(m-y)0&&(f=1/Math.sqrt(f),u*=f,h*=f,d*=f);var m=l*d-c*h,p=c*u-a*d,g=a*h-l*u;return f=m*m+p*p+g*g,f>0&&(f=1/Math.sqrt(f),m*=f,p*=f,g*=f),e[0]=m,e[1]=p,e[2]=g,e[3]=0,e[4]=h*g-d*p,e[5]=d*m-u*g,e[6]=u*p-h*m,e[7]=0,e[8]=u,e[9]=h,e[10]=d,e[11]=0,e[12]=s,e[13]=i,e[14]=o,e[15]=1,e}function up(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function fp(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function hp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function fl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function dp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function mp(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function pp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function gp(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],w=e[15],x=t[0],v=t[1],y=t[2],I=t[3],b=t[4],k=t[5],E=t[6],A=t[7],N=t[8],z=t[9],F=t[10],Y=t[11],$=t[12],V=t[13],ce=t[14],oe=t[15];return Math.abs(r-x)<=ke.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=ke.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(s-y)<=ke.EPSILON*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(i-I)<=ke.EPSILON*Math.max(1,Math.abs(i),Math.abs(I))&&Math.abs(o-b)<=ke.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(a-k)<=ke.EPSILON*Math.max(1,Math.abs(a),Math.abs(k))&&Math.abs(l-E)<=ke.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-A)<=ke.EPSILON*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(u-N)<=ke.EPSILON*Math.max(1,Math.abs(u),Math.abs(N))&&Math.abs(h-z)<=ke.EPSILON*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(d-F)<=ke.EPSILON*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(f-Y)<=ke.EPSILON*Math.max(1,Math.abs(f),Math.abs(Y))&&Math.abs(m-$)<=ke.EPSILON*Math.max(1,Math.abs(m),Math.abs($))&&Math.abs(p-V)<=ke.EPSILON*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(g-ce)<=ke.EPSILON*Math.max(1,Math.abs(g),Math.abs(ce))&&Math.abs(w-oe)<=ke.EPSILON*Math.max(1,Math.abs(w),Math.abs(oe))}var Lb=H.mul=ol,Cb=H.sub=fl});var so=et(G=>{"use strict";function no(e){"@babel/helpers - typeof";return no=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},no(e)}Object.defineProperty(G,"__esModule",{value:!0});G.add=bp;G.angle=Up;G.bezier=Lp;G.ceil=_p;G.clone=wp;G.copy=vp;G.create=dl;G.cross=zp;G.dist=void 0;G.distance=xl;G.div=void 0;G.divide=wl;G.dot=io;G.equals=Hp;G.exactEquals=Zp;G.floor=Mp;G.forEach=void 0;G.fromValues=xp;G.hermite=Bp;G.inverse=Rp;G.len=void 0;G.length=ml;G.lerp=Pp;G.max=kp;G.min=Sp;G.mul=void 0;G.multiply=gl;G.negate=Np;G.normalize=Tp;G.random=Cp;G.rotateX=qp;G.rotateY=Yp;G.rotateZ=Jp;G.round=Ip;G.scale=Ep;G.scaleAndAdd=Ap;G.set=yp;G.slerp=Op;G.sqrLen=G.sqrDist=void 0;G.squaredDistance=vl;G.squaredLength=yl;G.str=Gp;G.sub=void 0;G.subtract=pl;G.transformMat3=$p;G.transformMat4=Fp;G.transformQuat=Dp;G.zero=jp;var gt=hl(yt());function hl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(hl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||no(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function dl(){var e=new gt.ARRAY_TYPE(3);return gt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function wp(e){var t=new gt.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function ml(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function xp(e,t,r){var n=new gt.ARRAY_TYPE(3);return n[0]=e,n[1]=t,n[2]=r,n}function vp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function yp(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function bp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function pl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function gl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function wl(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function _p(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Mp(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Sp(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function kp(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Ip(e,t){return e[0]=gt.round(t[0]),e[1]=gt.round(t[1]),e[2]=gt.round(t[2]),e}function Ep(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Ap(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function xl(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+n*n+s*s)}function vl(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return r*r+n*n+s*s}function yl(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Np(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Rp(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Tp(e,t){var r=t[0],n=t[1],s=t[2],i=r*r+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function io(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function zp(e,t,r){var n=t[0],s=t[1],i=t[2],o=r[0],a=r[1],l=r[2];return e[0]=s*l-i*a,e[1]=i*o-n*l,e[2]=n*a-s*o,e}function Pp(e,t,r,n){var s=t[0],i=t[1],o=t[2];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e}function Op(e,t,r,n){var s=Math.acos(Math.min(Math.max(io(t,r),-1),1)),i=Math.sin(s),o=Math.sin((1-n)*s)/i,a=Math.sin(n*s)/i;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function Bp(e,t,r,n,s,i){var o=i*i,a=o*(2*i-3)+1,l=o*(i-2)+i,c=o*(i-1),u=o*(3-2*i);return e[0]=t[0]*a+r[0]*l+n[0]*c+s[0]*u,e[1]=t[1]*a+r[1]*l+n[1]*c+s[1]*u,e[2]=t[2]*a+r[2]*l+n[2]*c+s[2]*u,e}function Lp(e,t,r,n,s,i){var o=1-i,a=o*o,l=i*i,c=a*o,u=3*i*a,h=3*l*o,d=l*i;return e[0]=t[0]*c+r[0]*u+n[0]*h+s[0]*d,e[1]=t[1]*c+r[1]*u+n[1]*h+s[1]*d,e[2]=t[2]*c+r[2]*u+n[2]*h+s[2]*d,e}function Cp(e,t){t=t===void 0?1:t;var r=gt.RANDOM()*2*Math.PI,n=gt.RANDOM()*2-1,s=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=n*t,e}function Fp(e,t,r){var n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*s+r[8]*i+r[12])/o,e[1]=(r[1]*n+r[5]*s+r[9]*i+r[13])/o,e[2]=(r[2]*n+r[6]*s+r[10]*i+r[14])/o,e}function $p(e,t,r){var n=t[0],s=t[1],i=t[2];return e[0]=n*r[0]+s*r[3]+i*r[6],e[1]=n*r[1]+s*r[4]+i*r[7],e[2]=n*r[2]+s*r[5]+i*r[8],e}function Dp(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=s*c-i*l,h=i*a-n*c,d=n*l-s*a;return u=u+u,h=h+h,d=d+d,e[0]=a+o*u+s*d-i*h,e[1]=l+o*h+i*u-n*d,e[2]=c+o*d+n*h-s*u,e}function qp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Yp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Jp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Up(e,t){var r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2],l=Math.sqrt((r*r+n*n+s*s)*(i*i+o*o+a*a)),c=l&&io(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function jp(e){return e[0]=0,e[1]=0,e[2]=0,e}function Gp(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Zp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Hp(e,t){var r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2];return Math.abs(r-i)<=gt.EPSILON*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-o)<=gt.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(s-a)<=gt.EPSILON*Math.max(1,Math.abs(s),Math.abs(a))}var $b=G.sub=pl,Db=G.mul=gl,qb=G.div=wl,Yb=G.dist=xl,Jb=G.sqrDist=vl,Ub=G.len=ml,jb=G.sqrLen=yl,Gb=G.forEach=(function(){var e=dl();return function(t,r,n,s,i,o){var a,l;for(r||(r=3),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function oo(e){"@babel/helpers - typeof";return oo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oo(e)}Object.defineProperty(W,"__esModule",{value:!0});W.add=Qp;W.ceil=e1;W.clone=Xp;W.copy=Vp;W.create=_l;W.cross=f1;W.dist=void 0;W.distance=Il;W.div=void 0;W.divide=kl;W.dot=u1;W.equals=v1;W.exactEquals=x1;W.floor=t1;W.forEach=void 0;W.fromValues=Wp;W.inverse=c1;W.len=void 0;W.length=Al;W.lerp=h1;W.max=n1;W.min=r1;W.mul=void 0;W.multiply=Sl;W.negate=a1;W.normalize=l1;W.random=d1;W.round=i1;W.scale=s1;W.scaleAndAdd=o1;W.set=Kp;W.sqrLen=W.sqrDist=void 0;W.squaredDistance=El;W.squaredLength=Nl;W.str=w1;W.sub=void 0;W.subtract=Ml;W.transformMat4=m1;W.transformQuat=p1;W.zero=g1;var Ve=bl(yt());function bl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(bl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||oo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function _l(){var e=new Ve.ARRAY_TYPE(4);return Ve.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Xp(e){var t=new Ve.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Wp(e,t,r,n){var s=new Ve.ARRAY_TYPE(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=n,s}function Vp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Kp(e,t,r,n,s){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e}function Qp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Ml(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Sl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function kl(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function e1(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function t1(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function r1(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function n1(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function i1(e,t){return e[0]=Ve.round(t[0]),e[1]=Ve.round(t[1]),e[2]=Ve.round(t[2]),e[3]=Ve.round(t[3]),e}function s1(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function o1(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}function Il(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return Math.sqrt(r*r+n*n+s*s+i*i)}function El(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return r*r+n*n+s*s+i*i}function Al(e){var t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function Nl(e){var t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function a1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function c1(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function l1(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=s*o,e[3]=i*o,e}function u1(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function f1(e,t,r,n){var s=r[0]*n[1]-r[1]*n[0],i=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],a=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],c=r[2]*n[3]-r[3]*n[2],u=t[0],h=t[1],d=t[2],f=t[3];return e[0]=h*c-d*l+f*a,e[1]=-(u*c)+d*o-f*i,e[2]=u*l-h*o+f*s,e[3]=-(u*a)+h*i-d*s,e}function h1(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function d1(e,t){t=t===void 0?1:t;var r,n,s,i,o,a,l;l=Ve.RANDOM(),r=l*2-1,n=(4*Ve.RANDOM()-2)*Math.sqrt(l*-l+l),o=r*r+n*n,l=Ve.RANDOM(),s=l*2-1,i=(4*Ve.RANDOM()-2)*Math.sqrt(l*-l+l),a=s*s+i*i;var c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*n,e[2]=t*s*c,e[3]=t*i*c,e}function m1(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*o,e[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*o,e[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*o,e[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*o,e}function p1(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=s*c-i*l,h=i*a-n*c,d=n*l-s*a;return u=u+u,h=h+h,d=d+d,e[0]=a+o*u+s*d-i*h,e[1]=l+o*h+i*u-n*d,e[2]=c+o*d+n*h-s*u,e[3]=t[3],e}function g1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function w1(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function x1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function v1(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(r-o)<=Ve.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=Ve.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-l)<=Ve.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(i-c)<=Ve.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))}var Hb=W.sub=Ml,Xb=W.mul=Sl,Wb=W.div=kl,Vb=W.dist=Il,Kb=W.sqrDist=El,Qb=W.len=Al,e5=W.sqrLen=Nl,t5=W.forEach=(function(){var e=_l();return function(t,r,n,s,i,o){var a,l;for(r||(r=4),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function co(e){"@babel/helpers - typeof";return co=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},co(e)}Object.defineProperty(Z,"__esModule",{value:!0});Z.add=void 0;Z.calculateW=E1;Z.clone=void 0;Z.conjugate=T1;Z.copy=void 0;Z.create=lo;Z.dot=void 0;Z.equals=F1;Z.exactEquals=void 0;Z.exp=zl;Z.fromEuler=z1;Z.fromMat3=Ol;Z.fromValues=void 0;Z.getAngle=M1;Z.getAxisAngle=_1;Z.identity=b1;Z.invert=R1;Z.lerp=Z.length=Z.len=void 0;Z.ln=Pl;Z.mul=void 0;Z.multiply=Tl;Z.normalize=void 0;Z.pow=A1;Z.random=N1;Z.rotateX=S1;Z.rotateY=k1;Z.rotateZ=I1;Z.setAxes=Z.set=Z.scale=Z.rotationTo=void 0;Z.setAxisAngle=Rl;Z.slerp=Di;Z.squaredLength=Z.sqrLen=Z.sqlerp=void 0;Z.str=P1;var Zt=Un(yt()),y1=Un(eo()),Gt=Un(so()),lt=Un(ao());function Un(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Un=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||co(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function lo(){var e=new Zt.ARRAY_TYPE(4);return Zt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function b1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Rl(e,t,r){r=r*.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function _1(e,t){var r=Math.acos(t[3])*2,n=Math.sin(r/2);return n>Zt.EPSILON?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0),r}function M1(e,t){var r=B1(e,t);return Math.acos(2*r*r-1)}function Tl(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*u+o*a+s*c-i*l,e[1]=s*u+o*l+i*a-n*c,e[2]=i*u+o*c+n*l-s*a,e[3]=o*u-n*a-s*l-i*c,e}function S1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+o*a,e[1]=s*l+i*a,e[2]=i*l-s*a,e[3]=o*l-n*a,e}function k1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l-i*a,e[1]=s*l+o*a,e[2]=i*l+n*a,e[3]=o*l-s*a,e}function I1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+s*a,e[1]=s*l-n*a,e[2]=i*l+o*a,e[3]=o*l-i*a,e}function E1(e,t){var r=t[0],n=t[1],s=t[2];return e[0]=r,e[1]=n,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),e}function zl(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=Math.sqrt(r*r+n*n+s*s),a=Math.exp(i),l=o>0?a*Math.sin(o)/o:0;return e[0]=r*l,e[1]=n*l,e[2]=s*l,e[3]=a*Math.cos(o),e}function Pl(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=Math.sqrt(r*r+n*n+s*s),a=o>0?Math.atan2(o,i)/o:0;return e[0]=r*a,e[1]=n*a,e[2]=s*a,e[3]=.5*Math.log(r*r+n*n+s*s+i*i),e}function A1(e,t,r){return Pl(e,t),O1(e,e,r),zl(e,e),e}function Di(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3],l=r[0],c=r[1],u=r[2],h=r[3],d,f,m,p,g;return f=s*l+i*c+o*u+a*h,f<0&&(f=-f,l=-l,c=-c,u=-u,h=-h),1-f>Zt.EPSILON?(d=Math.acos(f),m=Math.sin(d),p=Math.sin((1-n)*d)/m,g=Math.sin(n*d)/m):(p=1-n,g=n),e[0]=p*s+g*l,e[1]=p*i+g*c,e[2]=p*o+g*u,e[3]=p*a+g*h,e}function N1(e){var t=Zt.RANDOM(),r=Zt.RANDOM(),n=Zt.RANDOM(),s=Math.sqrt(1-t),i=Math.sqrt(t);return e[0]=s*Math.sin(2*Math.PI*r),e[1]=s*Math.cos(2*Math.PI*r),e[2]=i*Math.sin(2*Math.PI*n),e[3]=i*Math.cos(2*Math.PI*n),e}function R1(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i,a=o?1/o:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-s*a,e[3]=i*a,e}function T1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ol(e,t){var r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);var i=(s+1)%3,o=(s+2)%3;n=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*n,n=.5/n,e[3]=(t[i*3+o]-t[o*3+i])*n,e[i]=(t[i*3+s]+t[s*3+i])*n,e[o]=(t[o*3+s]+t[s*3+o])*n}return e}function z1(e,t,r,n){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:Zt.ANGLE_ORDER,i=Math.PI/360;t*=i,n*=i,r*=i;var o=Math.sin(t),a=Math.cos(t),l=Math.sin(r),c=Math.cos(r),u=Math.sin(n),h=Math.cos(n);switch(s){case"xyz":e[0]=o*c*h+a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h-o*l*u;break;case"xzy":e[0]=o*c*h-a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h+o*l*u;break;case"yxz":e[0]=o*c*h+a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h+o*l*u;break;case"yzx":e[0]=o*c*h+a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h-o*l*u;break;case"zxy":e[0]=o*c*h-a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h-o*l*u;break;case"zyx":e[0]=o*c*h-a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h+o*l*u;break;default:throw new Error("Unknown angle order "+s)}return e}function P1(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var n5=Z.clone=lt.clone,i5=Z.fromValues=lt.fromValues,s5=Z.copy=lt.copy,o5=Z.set=lt.set,a5=Z.add=lt.add,c5=Z.mul=Tl,O1=Z.scale=lt.scale,B1=Z.dot=lt.dot,l5=Z.lerp=lt.lerp,L1=Z.length=lt.length,u5=Z.len=L1,C1=Z.squaredLength=lt.squaredLength,f5=Z.sqrLen=C1,Bl=Z.normalize=lt.normalize,h5=Z.exactEquals=lt.exactEquals;function F1(e,t){return Math.abs(lt.dot(e,t))>=1-Zt.EPSILON}var d5=Z.rotationTo=(function(){var e=Gt.create(),t=Gt.fromValues(1,0,0),r=Gt.fromValues(0,1,0);return function(n,s,i){var o=Gt.dot(s,i);return o<-.999999?(Gt.cross(e,t,s),Gt.len(e)<1e-6&&Gt.cross(e,r,s),Gt.normalize(e,e),Rl(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Gt.cross(e,s,i),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,Bl(n,n))}})(),m5=Z.sqlerp=(function(){var e=lo(),t=lo();return function(r,n,s,i,o,a){return Di(e,n,o,a),Di(t,s,i,a),Di(r,e,t,2*a*(1-a)),r}})(),p5=Z.setAxes=(function(){var e=y1.create();return function(t,r,n,s){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],Bl(t,Ol(t,e))}})()});var Dl=et(K=>{"use strict";function fo(e){"@babel/helpers - typeof";return fo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fo(e)}Object.defineProperty(K,"__esModule",{value:!0});K.add=ig;K.clone=D1;K.conjugate=lg;K.copy=Fl;K.create=$1;K.dot=void 0;K.equals=mg;K.exactEquals=dg;K.fromMat4=j1;K.fromRotation=U1;K.fromRotationTranslation=Cl;K.fromRotationTranslationValues=Y1;K.fromTranslation=J1;K.fromValues=q1;K.getDual=H1;K.getReal=void 0;K.getTranslation=W1;K.identity=G1;K.invert=cg;K.length=K.len=void 0;K.lerp=ag;K.mul=void 0;K.multiply=$l;K.normalize=fg;K.rotateAroundAxis=ng;K.rotateByQuatAppend=tg;K.rotateByQuatPrepend=rg;K.rotateX=K1;K.rotateY=Q1;K.rotateZ=eg;K.scale=sg;K.set=Z1;K.setDual=X1;K.squaredLength=K.sqrLen=K.setReal=void 0;K.str=hg;K.translate=V1;var rt=qi(yt()),Ht=qi(uo()),Ll=qi(ro());function qi(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(qi=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||fo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function $1(){var e=new rt.ARRAY_TYPE(8);return rt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e}function D1(e){var t=new rt.ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function q1(e,t,r,n,s,i,o,a){var l=new rt.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=r,l[3]=n,l[4]=s,l[5]=i,l[6]=o,l[7]=a,l}function Y1(e,t,r,n,s,i,o){var a=new rt.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=r,a[3]=n;var l=s*.5,c=i*.5,u=o*.5;return a[4]=l*n+c*r-u*t,a[5]=c*n+u*e-l*r,a[6]=u*n+l*t-c*e,a[7]=-l*e-c*t-u*r,a}function Cl(e,t,r){var n=r[0]*.5,s=r[1]*.5,i=r[2]*.5,o=t[0],a=t[1],l=t[2],c=t[3];return e[0]=o,e[1]=a,e[2]=l,e[3]=c,e[4]=n*c+s*l-i*a,e[5]=s*c+i*o-n*l,e[6]=i*c+n*a-s*o,e[7]=-n*o-s*a-i*l,e}function J1(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0]*.5,e[5]=t[1]*.5,e[6]=t[2]*.5,e[7]=0,e}function U1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function j1(e,t){var r=Ht.create();Ll.getRotation(r,t);var n=new rt.ARRAY_TYPE(3);return Ll.getTranslation(n,t),Cl(e,r,n),e}function Fl(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function G1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function Z1(e,t,r,n,s,i,o,a,l){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e}var w5=K.getReal=Ht.copy;function H1(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e}var x5=K.setReal=Ht.copy;function X1(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e}function W1(e,t){var r=t[4],n=t[5],s=t[6],i=t[7],o=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=(r*c+i*o+n*l-s*a)*2,e[1]=(n*c+i*a+s*o-r*l)*2,e[2]=(s*c+i*l+r*a-n*o)*2,e}function V1(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0]*.5,l=r[1]*.5,c=r[2]*.5,u=t[4],h=t[5],d=t[6],f=t[7];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=o*a+s*c-i*l+u,e[5]=o*l+i*a-n*c+h,e[6]=o*c+n*l-s*a+d,e[7]=-n*a-s*l-i*c+f,e}function K1(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateX(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function Q1(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateY(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function eg(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateZ(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function tg(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=t[3];return e[0]=a*o+u*n+l*i-c*s,e[1]=l*o+u*s+c*n-a*i,e[2]=c*o+u*i+a*s-l*n,e[3]=u*o-a*n-l*s-c*i,a=t[4],l=t[5],c=t[6],u=t[7],e[4]=a*o+u*n+l*i-c*s,e[5]=l*o+u*s+c*n-a*i,e[6]=c*o+u*i+a*s-l*n,e[7]=u*o-a*n-l*s-c*i,e}function rg(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*u+o*a+s*c-i*l,e[1]=s*u+o*l+i*a-n*c,e[2]=i*u+o*c+n*l-s*a,e[3]=o*u-n*a-s*l-i*c,a=r[4],l=r[5],c=r[6],u=r[7],e[4]=n*u+o*a+s*c-i*l,e[5]=s*u+o*l+i*a-n*c,e[6]=i*u+o*c+n*l-s*a,e[7]=o*u-n*a-s*l-i*c,e}function ng(e,t,r,n){if(Math.abs(n)0){r=Math.sqrt(r);var n=t[0]/r,s=t[1]/r,i=t[2]/r,o=t[3]/r,a=t[4],l=t[5],c=t[6],u=t[7],h=n*a+s*l+i*c+o*u;e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=(a-n*h)/r,e[5]=(l-s*h)/r,e[6]=(c-i*h)/r,e[7]=(u-o*h)/r}return e}function hg(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"}function dg(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]}function mg(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=t[0],h=t[1],d=t[2],f=t[3],m=t[4],p=t[5],g=t[6],w=t[7];return Math.abs(r-u)<=rt.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-h)<=rt.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(s-d)<=rt.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(i-f)<=rt.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(o-m)<=rt.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(a-p)<=rt.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(l-g)<=rt.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-w)<=rt.EPSILON*Math.max(1,Math.abs(c),Math.abs(w))}});var Wl=et(X=>{"use strict";function mo(e){"@babel/helpers - typeof";return mo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mo(e)}Object.defineProperty(X,"__esModule",{value:!0});X.add=vg;X.angle=$g;X.ceil=yg;X.clone=pg;X.copy=wg;X.create=Yl;X.cross=Tg;X.dist=void 0;X.distance=Gl;X.div=void 0;X.divide=jl;X.dot=Rg;X.equals=Ug;X.exactEquals=Jg;X.floor=bg;X.forEach=void 0;X.fromValues=gg;X.inverse=Ag;X.len=void 0;X.length=Hl;X.lerp=zg;X.max=Mg;X.min=_g;X.mul=void 0;X.multiply=Ul;X.negate=Eg;X.normalize=Ng;X.random=Pg;X.rotate=Fg;X.round=Sg;X.scale=kg;X.scaleAndAdd=Ig;X.set=xg;X.signedAngle=Dg;X.sqrLen=X.sqrDist=void 0;X.squaredDistance=Zl;X.squaredLength=Xl;X.str=Yg;X.sub=void 0;X.subtract=Jl;X.transformMat2=Og;X.transformMat2d=Bg;X.transformMat3=Lg;X.transformMat4=Cg;X.zero=qg;var Xt=ql(yt());function ql(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(ql=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||mo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function Yl(){var e=new Xt.ARRAY_TYPE(2);return Xt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function pg(e){var t=new Xt.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t}function gg(e,t){var r=new Xt.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r}function wg(e,t){return e[0]=t[0],e[1]=t[1],e}function xg(e,t,r){return e[0]=t,e[1]=r,e}function vg(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Jl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function Ul(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function jl(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function yg(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function bg(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function _g(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function Mg(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function Sg(e,t){return e[0]=Xt.round(t[0]),e[1]=Xt.round(t[1]),e}function kg(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Ig(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function Gl(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function Zl(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function Hl(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Xl(e){var t=e[0],r=e[1];return t*t+r*r}function Eg(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Ag(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Ng(e,t){var r=t[0],n=t[1],s=r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function Rg(e,t){return e[0]*t[0]+e[1]*t[1]}function Tg(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e}function zg(e,t,r,n){var s=t[0],i=t[1];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e}function Pg(e,t){t=t===void 0?1:t;var r=Xt.RANDOM()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Og(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e}function Bg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s+r[4],e[1]=r[1]*n+r[3]*s+r[5],e}function Lg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[3]*s+r[6],e[1]=r[1]*n+r[4]*s+r[7],e}function Cg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[4]*s+r[12],e[1]=r[1]*n+r[5]*s+r[13],e}function Fg(e,t,r,n){var s=t[0]-r[0],i=t[1]-r[1],o=Math.sin(n),a=Math.cos(n);return e[0]=s*a-i*o+r[0],e[1]=s*o+i*a+r[1],e}function $g(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.abs(Math.atan2(n*s-r*i,r*s+n*i))}function Dg(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.atan2(r*i-n*s,r*s+n*i)}function qg(e){return e[0]=0,e[1]=0,e}function Yg(e){return"vec2("+e[0]+", "+e[1]+")"}function Jg(e,t){return e[0]===t[0]&&e[1]===t[1]}function Ug(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.abs(r-s)<=Xt.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=Xt.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))}var M5=X.len=Hl,S5=X.sub=Jl,k5=X.mul=Ul,I5=X.div=jl,E5=X.dist=Gl,A5=X.sqrDist=Zl,N5=X.sqrLen=Xl,R5=X.forEach=(function(){var e=Yl();return function(t,r,n,s,i,o){var a,l;for(r||(r=2),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function po(e){"@babel/helpers - typeof";return po=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(e)}Object.defineProperty(Pe,"__esModule",{value:!0});Pe.vec4=Pe.vec3=Pe.vec2=Pe.quat2=Pe.quat=Pe.mat4=Pe.mat3=Pe.mat2d=Pe.mat2=Pe.glMatrix=void 0;var jg=bt(yt());Pe.glMatrix=jg;var Gg=bt(Wc());Pe.mat2=Gg;var Zg=bt(el());Pe.mat2d=Zg;var Hg=bt(eo());Pe.mat3=Hg;var Xg=bt(ro());Pe.mat4=Xg;var Wg=bt(uo());Pe.quat=Wg;var Vg=bt(Dl());Pe.quat2=Vg;var Kg=bt(Wl());Pe.vec2=Kg;var Qg=bt(so());Pe.vec3=Qg;var e2=bt(ao());Pe.vec4=e2;function bt(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(bt=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||po(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}});var Kl=et((b_,Vl)=>{(function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(r,n){return r<>>32-n},rotr:function(r,n){return r<<32-n|r>>>n},endian:function(r){if(r.constructor==Number)return t.rotl(r,8)&16711935|t.rotl(r,24)&4278255360;for(var n=0;n0;r--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(r){for(var n=[],s=0,i=0;s>>5]|=r[s]<<24-i%32;return n},wordsToBytes:function(r){for(var n=[],s=0;s>>5]>>>24-s%32&255);return n},bytesToHex:function(r){for(var n=[],s=0;s>>4).toString(16)),n.push((r[s]&15).toString(16));return n.join("")},hexToBytes:function(r){for(var n=[],s=0;s>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(r){r=r.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],s=0,i=0;s>>6-i*2);return n}};Vl.exports=t})()});var xo=et((__,Ql)=>{var wo={utf8:{stringToBytes:function(e){return wo.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(wo.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r{tu.exports=function(e){return e!=null&&(eu(e)||r2(e)||!!e._isBuffer)};function eu(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function r2(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&eu(e.slice(0,0))}});var iu=et((S_,nu)=>{(function(){var e=Kl(),t=xo().utf8,r=ru(),n=xo().bin,s=function(i,o){i.constructor==String?o&&o.encoding==="binary"?i=n.stringToBytes(i):i=t.stringToBytes(i):r(i)?i=Array.prototype.slice.call(i,0):!Array.isArray(i)&&i.constructor!==Uint8Array&&(i=i.toString());for(var a=e.bytesToWords(i),l=i.length*8,c=1732584193,u=-271733879,h=-1732584194,d=271733878,f=0;f>>24)&16711935|(a[f]<<24|a[f]>>>8)&4278255360;a[l>>>5]|=128<>>9<<4)+14]=l;for(var m=s._ff,p=s._gg,g=s._hh,w=s._ii,f=0;f>>0,u=u+v>>>0,h=h+y>>>0,d=d+I>>>0}return e.endian([c,u,h,d])};s._ff=function(i,o,a,l,c,u,h){var d=i+(o&a|~o&l)+(c>>>0)+h;return(d<>>32-u)+o},s._gg=function(i,o,a,l,c,u,h){var d=i+(o&l|a&~l)+(c>>>0)+h;return(d<>>32-u)+o},s._hh=function(i,o,a,l,c,u,h){var d=i+(o^a^l)+(c>>>0)+h;return(d<>>32-u)+o},s._ii=function(i,o,a,l,c,u,h){var d=i+(a^(o|~l))+(c>>>0)+h;return(d<>>32-u)+o},s._blocksize=16,s._digestsize=16,nu.exports=function(i,o){if(i==null)throw new Error("Illegal argument "+i);var a=e.wordsToBytes(s(i,o));return o&&o.asBytes?a:o&&o.asString?n.bytesToString(a):e.bytesToHex(a)}})()});import ls from"node:process";var bn=["temperature","humidity","continentalness","erosion","depth","weirdness"];function Qo(e,t,r){return er?e-r:0}function jr(e,t,r){let n=e.params,s=t*13,i=0;for(let a=0;a<6;a++){let l=Qo(r[a],n[s+a*2],n[s+a*2+1]);i+=l*l}let o=n[s+12];return i+o*o}function ea(e,t,r){let n=e.params,s=t*13,i=bn.map((o,a)=>{let l=n[s+a*2],c=n[s+a*2+1];return{param:o,min:l,max:c,value:r[a],off:Qo(r[a],l,c)}});return{index:t,biome:e.biomes[t],distance:Math.sqrt(jr(e,t,r)),params:i,offset:n[s+12]}}function hs(e,t,r=5){let n=new Map;for(let s=0;ss.f-i.f||s.i-i.i).slice(0,r).map(({i:s})=>ea(e,s,t))}function ta(e,t,r){let n=-1,s=1/0;for(let i=0;i!r.has(n)).sort()}var tf=/^data\/([^/]+)\/(worldgen\/(?:noise|density_function|noise_settings|material_rule|material_condition)|dimension|tags\/worldgen\/biome)\/(.+)\.json$/;function ds(e){let t=tf.exec(e);return t?{kind:t[2]==="tags/worldgen/biome"?"tag/worldgen/biome":t[2].replace("worldgen/",""),id:`${t[1]}:${t[3]}`}:null}var Ie=class extends Error{};function ia(e){let t=[];for(let r of e){let n=ds(r.path);if(n)try{t.push({...n,json:JSON.parse(r.text)})}catch{}}return t}var sa=e=>e.includes(":")?e:`minecraft:${e}`;function pr(e,t,r){if(r.includes(t))return t;if(!t.includes(":")){let s=r.filter(i=>i.slice(i.indexOf(":")+1)===t);if(s.length===1)return s[0];if(s.length>1)throw new Ie(`${t} could be ${s.join(" or ")}; give the namespace.`);if(r.includes(`minecraft:${t}`))return`minecraft:${t}`}let n=r.length?`: ${r.slice(0,30).join(", ")}${r.length>30?", \u2026":""}`:"";throw new Ie(`No ${e} ${t}. The ${e}s there are${n||" none"}.`)}function Ce(e,t,r,n=-1/0,s=1/0){let i=e[t];if(i==null)return r;if(typeof i!="number"||!Number.isFinite(i))throw new Ie(`${t} must be a number.`);if(is)throw new Ie(`${t} must be between ${n} and ${s}.`);return i}function Yt(e,t){let r=e[t];if(!(r==null||r==="")){if(typeof r!="string")throw new Ie(`${t} must be a string.`);return r}}function pe(e,t=3){if(Number.isNaN(e))return"none";if(!Number.isFinite(e))return e>0?"\u221E":"-\u221E";let r=e.toFixed(t);return r.includes(".")?r.replace(/\.?0+$/,""):r}var Gr=(e,t)=>`${t?pe(100*e/t,1):"0"}%`;function gr(e){let t=[],r=[];for(let n of e)n.forEach((s,i)=>t[i]=Math.max(t[i]??0,s.length));return t.forEach((n,s)=>r[s]=e.slice(1).every(i=>/^(-?[\d.]|none$|-$)/.test(i[s]??""))),e.map(n=>n.map((s,i)=>r[i]?s.padStart(t[i]):s.padEnd(t[i])).join(" ").trimEnd()).join(` -`)}function oa(e){switch(e){case"north":return{rx:1,rz:0,dx:0,dz:1};case"east":return{rx:0,rz:1,dx:-1,dz:0};case"south":return{rx:-1,rz:0,dx:0,dz:-1};case"west":return{rx:0,rz:-1,dx:1,dz:0}}}var pi="https://raw.githubusercontent.com/misode/mcmeta/d96c75fec200c4580dd75e033a76341521165461/data";var ms=new Map,rf=1,ps={onmessage:null,postMessage(e){if(e.type!=="rendered"&&e.type!=="error"||e.type==="rendered"&&e.partial)return;let t=ms.get(e.seq);t&&(ms.delete(e.seq),e.type==="error"?t.reject(new Error(e.message)):t.resolve(e))}},aa={};async function nf(e){let t=String(e),r=`${pi}/`,n="/data.min.json";if(t.startsWith(r)&&t.endsWith(n)){let s=t.slice(r.length,-n.length),i=s.startsWith("tag/")?`tags/${s.slice(4)}`:s,o=aa[i];if(o)return{ok:!0,json:async()=>o}}return{ok:!1,json:async()=>null}}var ca=globalThis;ca.self=ps;ca.fetch=nf;function gs(e,t){aa=t,la({type:"setup",files:e})}function la(e){if(!ps.onmessage)throw new Error("the preview worker is not loaded");ps.onmessage({data:e})}function Jt(e){let t=rf++;return new Promise((r,n)=>{ms.set(t,{resolve:r,reject:n}),la({...e,type:"render",seq:t})})}function ua(e){var t=e.slice(0,2);return t.length===2&&t[0]===31&&t[1]===139}function fa(e){let t=e.slice(0,2);return t.length===2&&t[0]===120&&(t[1]===1||t[1]===94||t[1]===156||t[2]===218)}function ha(e){let t=e.slice(0,8),r=new DataView(t.buffer,t.byteOffset),n=r.getUint32(0,!0),s=r.getUint32(4,!0);if(t.length===8&&n>0&&n<100&&s===e.byteLength-8)return n}function da(e){var t=[],r,n;for(r=0;r>6),t.push(128|n&63)):n<65536?(t.push(224|n>>12),t.push(128|n>>6&63),t.push(128|n&63)):(t.push(240|n>>18&7),t.push(128|n>>12&63),t.push(128|n>>6&63),t.push(128|n&63));return t}function ma(e){var t=[],r;for(r=0;r=r)return;let n=this.buffer.byteLength;for(;nthis.buffer.byteLength&&i.fill(0,this.buffer.byteLength,this.offset),this.buffer=s,this.view=new DataView(s),this.array=i}writeNumber(t,r,n){this.accommodate(r),this.view[t](this.offset,n,this.littleEndian),this.offset+=r}writeByte=this.writeNumber.bind(this,"setInt8",1);writeShort=this.writeNumber.bind(this,"setInt16",2);writeInt=this.writeNumber.bind(this,"setInt32",4);writeFloat=this.writeNumber.bind(this,"setFloat32",4);writeDouble=this.writeNumber.bind(this,"setFloat64",8);writeBytes(t){this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}writeString(t){let r=da(t);this.writeShort(r.length),this.writeBytes(r)}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}};var M;(function(e){function t(h){return typeof h=="number"?h:void 0}e.readNumber=t;function r(h){return typeof h=="number"?Math.floor(h):void 0}e.readInt=r;function n(h){return typeof h=="string"?h:void 0}e.readString=n;function s(h){return typeof h=="boolean"?h:void 0}e.readBoolean=s;function i(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)?h:void 0}e.readObject=i;function o(h,d){if(Array.isArray(h))return d?h.map(f=>d(f)):h}e.readArray=o;function a(h,d){if(Array.isArray(h))return[0,1].map((f=>d(h[f])))}e.readPair=a;function l(h,d){let f=i(h)??{};return Object.fromEntries(Object.entries(f).map(([m,p])=>[m,d(p)]))}e.readMap=l;function c(h,d,f){let m=d(h);return m?f(m):void 0}e.compose=c;function u(h,d){return typeof h!="string"?d[0]:d.includes(h)?h:d[0]}e.readEnum=u})(M=M||(M={}));var re;(function(e){function t(s){let i=M.readNumber(s);if(i)return n(i);let o=M.readArray(s,a=>M.readNumber(a)??0);if(!(o===void 0||o.length!==3))return o}e.fromJson=t;function r(s){if(s.isNumber())return n(s.getAsNumber());if(!s.isListOrArray())return;let i=s.getItems();if(!(i.length<3))return i.map(o=>o.getAsNumber())}e.fromNbt=r;function n(s){let i=s>>16&255,o=s>>8&255,a=s&255;return[i/255,o/255,a/255]}e.intToRgb=n})(re=re||(re={}));var ht=class e{source;cursor;constructor(t){this.source=t,this.cursor=0}get remainingLength(){return this.source.length-this.cursor}get totalLength(){return this.source.length}getRead(t=0){return this.source.substring(t,this.cursor)}getRemaining(){return this.source.substring(this.cursor)}canRead(t=1){return this.cursor+t<=this.source.length}peek(t=0){return this.source.charAt(this.cursor+t)}read(){return this.source.charAt(this.cursor++)}skip(){this.cursor+=1}skipWhitespace(){for(;this.canRead()&&e.isWhitespace(this.peek());)this.skip()}expect(t,r=!1){if(r&&this.skipWhitespace(),!this.canRead()||this.peek()!==t)throw this.createError(`Expected '${t}'`);this.skip()}readInt(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInNumber(this.peek());)this.skip();let r=this.getRead(t);if(r.length===0)throw this.createError("Expected integer");try{let n=Number(r);if(isNaN(n)||!Number.isInteger(n))throw new Error;return n}catch{throw this.cursor=t,this.createError(`Invalid integer '${r}'`)}}readFloat(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInNumber(this.peek());)this.skip();let r=this.getRead(t);if(r.length===0)throw this.createError("Expected float");try{let n=Number(r);if(isNaN(n))throw new Error;return n}catch{throw this.cursor=t,this.createError(`Invalid float '${r}'`)}}readUnquotedString(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInUnquotedString(this.peek());)this.skip();return this.getRead(t)}readQuotedString(){if(!this.canRead())return"";let t=this.peek();if(!e.isQuotedStringStart(t))throw this.createError("Expected quote to start a string");return this.skip(),this.readStringUntil(t)}readString(){if(!this.canRead())return"";let t=this.peek();return e.isQuotedStringStart(t)?(this.skip(),this.readStringUntil(t)):this.readUnquotedString()}readStringUntil(t){let r=[],n=!1;for(;this.canRead();){let s=this.read();if(n)if(s===t||s==="\\")r.push(s),n=!1;else throw this.cursor-=1,this.createError(`Invalid escape sequence '${s}' in quoted string`);else if(s==="\\")n=!0;else{if(s===t)return r.join("");r.push(s)}}throw this.createError("Unclosed quoted string")}readBoolean(){let t=this.cursor,r=this.readUnquotedString();if(r.length===0)throw this.createError("Expected bool");if(r==="true")return!0;if(r==="false")return!1;throw this.cursor=t,this.createError(`Invalid bool, expected true or false but found '${r}'`)}static isAllowedInNumber(t){return t>="0"&&t<="9"||t==="."||t==="-"}static isAllowedInUnquotedString(t){return t>="0"&&t<="9"||t>="A"&&t<="Z"||t>="a"&&t<="z"||t==="_"||t==="-"||t==="."||t==="+"}static isQuotedStringStart(t){return t==="'"||t==='"'}static isWhitespace(t){return t===" "||t===" "||t===` -`||t==="\r"}createError(t){let r=Math.min(this.source.length,this.cursor),n=(r>10?"...":"")+this.source.substring(Math.max(0,r-10),r);return new Error(`${t} at position ${this.cursor}: ${n}<--[HERE]`)}};function It(e,t,r){let n=e.get(t);if(n!==void 0)return n;let s=r(t);return e.set(t,s),s}function Qr(e){let t=e.length;for(;--t>=0;)e[t]=0}var sf=0,tc=1,of=2,af=3,cf=258,Ds=29,Bn=256,An=Bn+1+Ds,Xr=30,qs=19,rc=2*An+1,wr=15,ws=16,lf=7,Ys=256,nc=16,ic=17,sc=18,Ts=new Uint8Array([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]),Mi=new Uint8Array([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]),uf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),oc=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ff=512,jt=new Array((An+2)*2);Qr(jt);var kn=new Array(Xr*2);Qr(kn);var Nn=new Array(ff);Qr(Nn);var Rn=new Array(cf-af+1);Qr(Rn);var Js=new Array(Ds);Qr(Js);var Si=new Array(Xr);Qr(Si);function xs(e,t,r,n,s){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=s,this.has_stree=e&&e.length}var ac,cc,lc;function vs(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var uc=e=>e<256?Nn[e]:Nn[256+(e>>>7)],Tn=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},it=(e,t,r)=>{e.bi_valid>ws-r?(e.bi_buf|=t<>ws-e.bi_valid,e.bi_valid+=r-ws):(e.bi_buf|=t<{it(e,r[t*2],r[t*2+1])},fc=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},hf=e=>{e.bi_valid===16?(Tn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},df=(e,t)=>{let r=t.dyn_tree,n=t.max_code,s=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,u,h,d,f,m,p=0;for(d=0;d<=wr;d++)e.bl_count[d]=0;for(r[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;cl&&(d=l,p++),r[u*2+1]=d,!(u>n)&&(e.bl_count[d]++,f=0,u>=a&&(f=o[u-a]),m=r[u*2],e.opt_len+=m*(d+f),i&&(e.static_len+=m*(s[u*2+1]+f)));if(p!==0){do{for(d=l-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(d=l;d!==0;d--)for(u=e.bl_count[d];u!==0;)h=e.heap[--c],!(h>n)&&(r[h*2+1]!==d&&(e.opt_len+=(d-r[h*2+1])*r[h*2],r[h*2+1]=d),u--)}},hc=(e,t,r)=>{let n=new Array(wr+1),s=0,i,o;for(i=1;i<=wr;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=t;o++){let a=e[o*2+1];a!==0&&(e[o*2]=fc(n[a]++,a))}},mf=()=>{let e,t,r,n,s,i=new Array(wr+1);for(r=0,n=0;n>=7;n{let t;for(t=0;t{e.bi_valid>8?Tn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},pa=(e,t,r,n)=>{let s=t*2,i=r*2;return e[s]{let n=e.heap[r],s=r<<1;for(;s<=e.heap_len&&(s{let n,s,i=0,o,a;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+i++]&255,n+=(e.pending_buf[e.sym_buf+i++]&255)<<8,s=e.pending_buf[e.sym_buf+i++],n===0?Nt(e,s,t):(o=Rn[s],Nt(e,o+Bn+1,t),a=Ts[o],a!==0&&(s-=Js[o],it(e,s,a)),n--,o=uc(n),Nt(e,o,r),a=Mi[o],a!==0&&(n-=Si[o],it(e,n,a)));while(i{let r=t.dyn_tree,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.elems,o,a,l=-1,c;for(e.heap_len=0,e.heap_max=rc,o=0;o>1;o>=1;o--)ys(e,r,o);c=i;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ys(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,r[c*2]=r[o*2]+r[a*2],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,r[o*2+1]=r[a*2+1]=c,e.heap[1]=c++,ys(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],df(e,t),hc(r,l,e.bl_count)},wa=(e,t,r)=>{let n,s=-1,i,o=t[1],a=0,l=7,c=4;for(o===0&&(l=138,c=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=o,o=t[(n+1)*2+1],!(++a{let n,s=-1,i,o=t[1],a=0,l=7,c=4;for(o===0&&(l=138,c=3),n=0;n<=r;n++)if(i=o,o=t[(n+1)*2+1],!(++a{let t;for(wa(e,e.dyn_ltree,e.l_desc.max_code),wa(e,e.dyn_dtree,e.d_desc.max_code),zs(e,e.bl_desc),t=qs-1;t>=3&&e.bl_tree[oc[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},gf=(e,t,r,n)=>{let s;for(it(e,t-257,5),it(e,r-1,5),it(e,n-4,4),s=0;s{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(r=32;r{va||(mf(),va=!0),e.l_desc=new vs(e.dyn_ltree,ac),e.d_desc=new vs(e.dyn_dtree,cc),e.bl_desc=new vs(e.bl_tree,lc),e.bi_buf=0,e.bi_valid=0,dc(e)},pc=(e,t,r,n)=>{it(e,(sf<<1)+(n?1:0),3),mc(e),Tn(e,r),Tn(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},vf=e=>{it(e,tc<<1,3),Nt(e,Ys,jt),hf(e)},yf=(e,t,r,n)=>{let s,i,o=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=wf(e)),zs(e,e.l_desc),zs(e,e.d_desc),o=pf(e),s=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=s&&(s=i)):s=i=r+5,r+4<=s&&t!==-1?pc(e,t,r,n):e.strategy===4||i===s?(it(e,(tc<<1)+(n?1:0),3),ga(e,jt,kn)):(it(e,(of<<1)+(n?1:0),3),gf(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),ga(e,e.dyn_ltree,e.dyn_dtree)),dc(e),n&&mc(e)},bf=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Rn[r]+Bn+1)*2]++,e.dyn_dtree[uc(t)*2]++),e.sym_next===e.sym_end),_f=xf,Mf=pc,Sf=yf,kf=bf,If=vf,Ef={_tr_init:_f,_tr_stored_block:Mf,_tr_flush_block:Sf,_tr_tally:kf,_tr_align:If},Af=(e,t,r,n)=>{let s=e&65535|0,i=e>>>16&65535|0,o=0;for(;r!==0;){o=r>2e3?2e3:r,r-=o;do s=s+t[n++]|0,i=i+s|0;while(--o);s%=65521,i%=65521}return s|i<<16|0},zn=Af,Nf=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},Rf=new Uint32Array(Nf()),Tf=(e,t,r,n)=>{let s=Rf,i=n+r;e^=-1;for(let o=n;o>>8^s[(e^t[o])&255];return e^-1},Ye=Tf,yr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Sr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:zf,_tr_stored_block:Ps,_tr_flush_block:Pf,_tr_tally:sr,_tr_align:Of}=Ef,{Z_NO_FLUSH:or,Z_PARTIAL_FLUSH:Bf,Z_FULL_FLUSH:Lf,Z_FINISH:dt,Z_BLOCK:ya,Z_OK:Ze,Z_STREAM_END:ba,Z_STREAM_ERROR:Rt,Z_DATA_ERROR:Cf,Z_BUF_ERROR:bs,Z_DEFAULT_COMPRESSION:Ff,Z_FILTERED:$f,Z_HUFFMAN_ONLY:xi,Z_RLE:Df,Z_FIXED:qf,Z_DEFAULT_STRATEGY:Yf,Z_UNKNOWN:Jf,Z_DEFLATED:Ei}=Sr,Uf=9,jf=15,Gf=8,Zf=29,Hf=256,Os=Hf+1+Zf,Xf=30,Wf=19,Vf=2*Os+1,Kf=15,me=3,ir=258,Tt=ir+me+1,Qf=32,Vr=42,Us=57,Bs=69,Ls=73,Cs=91,Fs=103,xr=113,Mn=666,tt=1,en=2,br=3,tn=4,eh=3,vr=(e,t)=>(e.msg=yr[t],t),_a=e=>e*2-(e>4?9:0),nr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},th=e=>{let t,r,n,s=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=s?r-s:0;while(--t);t=s,n=t;do r=e.prev[--n],e.prev[n]=r>=s?r-s:0;while(--t)},js=(e,t,r)=>(t<{let r;if(e.legacy_hash)r=e.ins_h=js(e,e.ins_h,e.window[t+me-1]);else{let s=e.window,i=s[t]|s[t+1]<<8|s[t+2]<<16|s[t+3]<<24;r=e.ins_h=Math.imul(i,66521)+66521>>>16&e.hash_mask}let n=e.prev[t&e.w_mask]=e.head[r];return e.head[r]=t,n},ot=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},at=(e,t)=>{Pf(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ot(e.strm)},ge=(e,t)=>{e.pending_buf[e.pending++]=t},_n=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},$s=(e,t,r,n)=>{let s=e.avail_in;return s>n&&(s=n),s===0?0:(e.avail_in-=s,t.set(e.input.subarray(e.next_in,e.next_in+s),r),e.state.wrap===1?e.adler=zn(e.adler,t,s,r):e.state.wrap===2&&(e.adler=Ye(e.adler,t,s,r)),e.next_in+=s,e.total_in+=s,s)},gc=(e,t)=>{let r=e.max_chain_length,n=e.strstart,s,i,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-Tt?e.strstart-(e.w_size-Tt):0,c=e.window,u=e.w_mask,h=e.prev,d=e.strstart+ir,f=c[n+o-1],m=c[n+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(s=t,!(c[s+o]!==m||c[s+o-1]!==f||c[s]!==c[n]||c[++s]!==c[n+1])){n+=2,s++;do;while(c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&no){if(e.match_start=t,o=i,i>=a)break;f=c[n+o-1],m=c[n+o]}}while((t=h[t&u])>l&&--r!==0);return o<=e.lookahead?o:e.lookahead},Kr=e=>{let t=e.w_size,r,n,s;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Tt)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),th(e),n+=t),e.strm.avail_in===0)break;if(r=$s(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.legacy_hash){if(e.lookahead+e.insert>=me)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=js(e,e.ins_h,e.window[s+1]);e.insert&&(_r(e,s),s++,e.insert--,!(e.lookahead+e.insertme)for(s=e.strstart-e.insert;e.insert&&(_r(e,s),s++,e.insert--,!(e.lookahead+e.insert<=me)););}while(e.lookahead{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,s,i,o=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outs+e.strm.avail_in&&(n=s+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,ot(e.strm),s&&(s>n&&(s=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,n-=s),n&&($s(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(o===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&($s(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,r=i>e.w_size?e.w_size:i,s=e.strstart-e.block_start,(s>=r||(s||t===dt)&&t!==or&&e.strm.avail_in===0&&s<=i)&&(n=s>i?i:s,o=t===dt&&e.strm.avail_in===0&&n===s?1:0,Ps(e,e.block_start,n,o),e.block_start+=n,ot(e.strm)),o?br:tt)},_s=(e,t)=>{let r,n;for(;;){if(e.lookahead=me&&(r=_r(e,e.strstart)),r!==0&&e.strstart-r<=e.w_size-Tt&&(e.match_length=gc(e,r)),e.match_length>=me)if(n=sr(e,e.strstart-e.match_start,e.match_length-me),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=me){e.match_length--;do e.strstart++,r=_r(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=js(e,e.ins_h,e.window[e.strstart+1]));else n=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=e.strstart{let r,n,s;for(;;){if(e.lookahead=me&&(r=_r(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=me-1,r!==0&&e.prev_length4096)&&(e.match_length=me-1)),e.prev_length>=me&&e.match_length<=e.prev_length){s=e.strstart+e.lookahead-me,n=sr(e,e.strstart-1-e.prev_match,e.prev_length-me),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=s&&(r=_r(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=me-1,e.strstart++,n&&(at(e,!1),e.strm.avail_out===0))return tt}else if(e.match_available){if(n=sr(e,0,e.window[e.strstart-1]),n&&at(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return tt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=sr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let r,n,s,i,o=e.window;for(;;){if(e.lookahead<=ir){if(Kr(e),e.lookahead<=ir&&t===or)return tt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=me&&e.strstart>0&&(s=e.strstart-1,n=o[s],n===o[++s]&&n===o[++s]&&n===o[++s])){i=e.strstart+ir;do;while(n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&se.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=me?(r=sr(e,1,e.match_length-me),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=0,t===dt?(at(e,!0),e.strm.avail_out===0?br:tn):e.sym_next&&(at(e,!1),e.strm.avail_out===0)?tt:en},nh=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(Kr(e),e.lookahead===0)){if(t===or)return tt;break}if(e.match_length=0,r=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=0,t===dt?(at(e,!0),e.strm.avail_out===0?br:tn):e.sym_next&&(at(e,!1),e.strm.avail_out===0)?tt:en};function Et(e,t,r,n,s){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=s}var Sn=[new Et(0,0,0,0,wc),new Et(4,4,8,4,_s),new Et(4,5,16,8,_s),new Et(4,6,32,32,_s),new Et(4,4,16,16,Zr),new Et(8,16,32,32,Zr),new Et(8,16,128,128,Zr),new Et(8,32,128,256,Zr),new Et(32,128,258,1024,Zr),new Et(32,258,258,4096,Zr)],ih=e=>{e.window_size=2*e.w_size,nr(e.head),e.max_lazy_match=Sn[e.level].max_lazy,e.good_match=Sn[e.level].good_length,e.nice_match=Sn[e.level].nice_length,e.max_chain_length=Sn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=me-1,e.match_available=0,e.ins_h=0};function sh(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ei,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Vf*2),this.dyn_dtree=new Uint16Array((2*Xf+1)*2),this.bl_tree=new Uint16Array((2*Wf+1)*2),nr(this.dyn_ltree),nr(this.dyn_dtree),nr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Kf+1),this.heap=new Uint16Array(2*Os+1),nr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Os+1),nr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ln=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==Vr&&t.status!==Us&&t.status!==Bs&&t.status!==Ls&&t.status!==Cs&&t.status!==Fs&&t.status!==xr&&t.status!==Mn?1:0},xc=e=>{if(Ln(e))return vr(e,Rt);e.total_in=e.total_out=0,e.data_type=Jf;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Us:t.wrap?Vr:xr,e.adler=t.wrap===2?0:1,t.last_flush=-2,zf(t),Ze},vc=e=>{let t=xc(e);return t===Ze&&ih(e.state),t},oh=(e,t)=>Ln(e)||e.state.wrap!==2?Rt:(e.state.gzhead=t,Ze),yc=(e,t,r,n,s,i,o)=>{if(!e)return Rt;let a=1;if(t===Ff&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),s<1||s>Uf||r!==Ei||n<8||n>15||t<0||t>9||i<0||i>qf||n===8&&a!==1)return vr(e,Rt);n===8&&(n=9);let l=new sh;return e.state=l,l.strm=e,l.status=Vr,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<yc(e,t,Ei,jf,Gf,Yf),ch=(e,t)=>{if(Ln(e)||t>ya||t<0)return e?vr(e,Rt):Rt;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===Mn&&t!==dt)return vr(e,e.avail_out===0?bs:Rt);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(ot(e),e.avail_out===0)return r.last_flush=-1,Ze}else if(e.avail_in===0&&_a(t)<=_a(n)&&t!==dt)return vr(e,bs);if(r.status===Mn&&e.avail_in!==0)return vr(e,bs);if(r.status===Vr&&r.wrap===0&&(r.status=xr),r.status===Vr){let s=Ei+(r.w_bits-8<<4)<<8,i=-1;if(r.strategy>=xi||r.level<2?i=0:r.level<6?i=1:r.level===6?i=2:i=3,s|=i<<6,r.strstart!==0&&(s|=Qf),s+=31-s%31,_n(r,s),r.strstart!==0&&(_n(r,e.adler>>>16),_n(r,e.adler&65535)),e.adler=1,r.status=xr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(r.status===Us){if(e.adler=0,ge(r,31),ge(r,139),ge(r,8),r.gzhead)ge(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ge(r,r.gzhead.time&255),ge(r,r.gzhead.time>>8&255),ge(r,r.gzhead.time>>16&255),ge(r,r.gzhead.time>>24&255),ge(r,r.level===9?2:r.strategy>=xi||r.level<2?4:0),ge(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(ge(r,r.gzhead.extra.length&255),ge(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ye(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Bs;else if(ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,r.level===9?2:r.strategy>=xi||r.level<2?4:0),ge(r,eh),r.status=xr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(r.status===Bs){if(r.gzhead.extra){let s=r.pending,i=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0,i-=a}let o=new Uint8Array(r.gzhead.extra);r.pending_buf.set(o.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=Ls}if(r.status===Ls){if(r.gzhead.name){let s=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0}r.gzindexs&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=Cs}if(r.status===Cs){if(r.gzhead.comment){let s=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0}r.gzindexs&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s))}r.status=Fs}if(r.status===Fs){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(ot(e),r.pending!==0))return r.last_flush=-1,Ze;ge(r,e.adler&255),ge(r,e.adler>>8&255),e.adler=0}if(r.status=xr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(e.avail_in!==0||r.lookahead!==0||t!==or&&r.status!==Mn){let s=r.level===0?wc(r,t):r.strategy===xi?nh(r,t):r.strategy===Df?rh(r,t):Sn[r.level].func(r,t);if((s===br||s===tn)&&(r.status=Mn),s===tt||s===br)return e.avail_out===0&&(r.last_flush=-1),Ze;if(s===en&&(t===Bf?Of(r):t!==ya&&(Ps(r,0,0,!1),t===Lf&&(nr(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),ot(e),e.avail_out===0))return r.last_flush=-1,Ze}return t!==dt?Ze:r.wrap<=0?ba:(r.wrap===2?(ge(r,e.adler&255),ge(r,e.adler>>8&255),ge(r,e.adler>>16&255),ge(r,e.adler>>24&255),ge(r,e.total_in&255),ge(r,e.total_in>>8&255),ge(r,e.total_in>>16&255),ge(r,e.total_in>>24&255)):(_n(r,e.adler>>>16),_n(r,e.adler&65535)),ot(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Ze:ba)},lh=e=>{if(Ln(e))return Rt;let t=e.state.status;return e.state=null,t===xr?vr(e,Cf):Ze},uh=(e,t)=>{let r=t.length;if(Ln(e))return Rt;let n=e.state,s=n.wrap;if(s===2||s===1&&n.status!==Vr||n.lookahead)return Rt;if(s===1&&(e.adler=zn(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){s===0&&(nr(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let i=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,Kr(n);n.lookahead>=me;){let l=n.strstart,c=n.lookahead-(me-1);do _r(n,l),l++;while(--c);n.strstart=l,n.lookahead=me-1,Kr(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=me-1,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=i,n.wrap=s,Ze},fh=ah,hh=yc,dh=vc,mh=xc,ph=oh,gh=ch,wh=lh,xh=uh,vh="pako deflate (from Nodeca project)",In={deflateInit:fh,deflateInit2:hh,deflateReset:dh,deflateResetKeep:mh,deflateSetHeader:ph,deflate:gh,deflateEnd:wh,deflateSetDictionary:xh,deflateInfo:vh},yh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bh=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)yh(r,n)&&(e[n]=r[n])}}return e},_h=e=>{let t=0;for(let n=0,s=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Pn[254]=Pn[255]=1;var Mh=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,s,i,o=e.length,a=0;for(s=0;s>>6,t[i++]=128|r&63):r<65536?(t[i++]=224|r>>>12,t[i++]=128|r>>>6&63,t[i++]=128|r&63):(t[i++]=240|r>>>18,t[i++]=128|r>>>12&63,t[i++]=128|r>>>6&63,t[i++]=128|r&63);return t},Sh=(e,t)=>{if(t<65534&&e.subarray&&bc)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,s,i=new Array(r*2);for(s=0,n=0;n4){i[s++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n1){i[s++]=65533;continue}o<65536?i[s++]=o:(o-=65536,i[s++]=55296|o>>10&1023,i[s++]=56320|o&1023)}return Sh(i,s)},Ih=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+Pn[e[r]]>t?r:t},On={string2buf:Mh,buf2string:kh,utf8border:Ih};function Eh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var _c=Eh,Mc=Object.prototype.toString,{Z_NO_FLUSH:Ah,Z_SYNC_FLUSH:Nh,Z_FULL_FLUSH:Rh,Z_FINISH:Th,Z_OK:ki,Z_STREAM_END:zh,Z_DEFAULT_COMPRESSION:Ph,Z_DEFAULT_STRATEGY:Oh,Z_DEFLATED:Bh}=Sr,Lh={level:Ph,method:Bh,chunkSize:16384,windowBits:15,memLevel:8,strategy:Oh,legacyHash:!0};function Cn(e){this.options=Ai.assign({},Lh,e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _c,this.strm.avail_out=0;let r=In.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(r!==ki)throw new Error(yr[r]);if(t.header&&In.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=On.string2buf(t.dictionary):Mc.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=In.deflateSetDictionary(this.strm,n),r!==ki)throw new Error(yr[r]);this._dict_set=!0}}Cn.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,s,i;if(this.ended)return!1;for(t===~~t?i=t:i=t===!0?Th:Ah,typeof e=="string"?r.input=On.string2buf(e):Mc.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(i===Nh||i===Rh)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(s=In.deflate(r,i),s===zh)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),s=In.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===ki;if(r.avail_out===0){this.onData(r.output);continue}if(i>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};Cn.prototype.onData=function(e){this.chunks.push(e)};Cn.prototype.onEnd=function(e){e===ki&&(this.result=Ai.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Gs(e,t){let r=new Cn(t);if(r.push(e,!0),r.err)throw r.msg||yr[r.err];return r.result}function Ch(e,t){return t=t||{},t.raw=!0,Gs(e,t)}function Fh(e,t){return t=t||{},t.gzip=!0,Gs(e,t)}var $h=Cn,Dh=Gs,qh=Ch,Yh=Fh,Jh=Sr,Uh={Deflate:$h,deflate:Dh,deflateRaw:qh,gzip:Yh,constants:Jh},vi=16209,jh=16191,Gh=function(t,r){let n,s,i,o,a,l,c,u,h,d,f,m,p,g,w,x,v,y,I,b,k,E,A,N,z=t.state;n=t.next_in,A=t.input,s=n+(t.avail_in-5),i=t.next_out,N=t.output,o=i-(r-t.avail_out),a=i+(t.avail_out-257),l=z.dmax,c=z.wsize,u=z.whave,h=z.wnext,d=z.window,f=z.hold,m=z.bits,p=z.lencode,g=z.distcode,w=(1<>>24,f>>>=y,m-=y,y=v>>>16&255,y===0)N[i++]=v&65535;else if(y&16){I=v&65535,y&=15,y&&(m>>=y,m-=y),m<15&&(f+=A[n++]<>>24,f>>>=y,m-=y,y=v>>>16&255,y&16){if(b=v&65535,y&=15,ml){t.msg="invalid distance too far back",z.mode=vi;break e}if(f>>>=y,m-=y,y=i-o,b>y){if(y=b-y,y>u&&z.sane){t.msg="invalid distance too far back",z.mode=vi;break e}if(k=0,E=d,h===0){if(k+=c-y,y2;)N[i++]=E[k++],N[i++]=E[k++],N[i++]=E[k++],I-=3;I&&(N[i++]=E[k++],I>1&&(N[i++]=E[k++]))}else{k=i-b;do N[i++]=N[k++],N[i++]=N[k++],N[i++]=N[k++],I-=3;while(I>2);I&&(N[i++]=N[k++],I>1&&(N[i++]=N[k++]))}}else if((y&64)===0){v=g[(v&65535)+(f&(1<>3,n-=I,m-=I<<3,f&=(1<{let l=a.bits,c=0,u=0,h=0,d=0,f=0,m=0,p=0,g=0,w=0,x=0,v,y,I,b,k,E=null,A,N=new Uint16Array(Hr+1),z=new Uint16Array(Hr+1),F=null,Y,$,V;for(c=0;c<=Hr;c++)N[c]=0;for(u=0;u=1&&N[d]===0;d--);if(f>d&&(f=d),d===0)return s[i++]=1<<24|64<<16|0,s[i++]=1<<24|64<<16|0,a.bits=1,0;for(h=1;h0&&(e===ka||d!==1))return-1;for(z[1]=0,c=1;cMa||e===Ia&&w>Sa)return 1;for(;;){Y=c-p,o[u]+1=A?($=F[o[u]-A],V=E[o[u]-A]):($=96,V=0),v=1<>p)+y]=Y<<24|$<<16|V|0;while(y!==0);for(v=1<>=1;if(v!==0?(x&=v-1,x+=v):x=0,u++,--N[c]===0){if(c===d)break;c=t[r+o[u]]}if(c>f&&(x&b)!==I){for(p===0&&(p=f),k+=h,m=c-p,g=1<Ma||e===Ia&&w>Sa)return 1;I=x&b,s[I]=f<<24|m<<16|k-i|0}}return x!==0&&(s[k+x]=c-p<<24|64<<16|0),a.bits=f,0},En=Vh,Kh=0,Sc=1,kc=2,{Z_FINISH:Ea,Z_BLOCK:Qh,Z_TREES:yi,Z_OK:Mr,Z_STREAM_END:ed,Z_NEED_DICT:td,Z_STREAM_ERROR:mt,Z_DATA_ERROR:Ic,Z_MEM_ERROR:Ec,Z_BUF_ERROR:rd,Z_DEFLATED:Aa}=Sr,Ni=16180,Na=16181,Ra=16182,Ta=16183,za=16184,Pa=16185,Oa=16186,Ba=16187,La=16188,Ca=16189,Ii=16190,Ut=16191,Ss=16192,Fa=16193,ks=16194,$a=16195,Da=16196,qa=16197,Ya=16198,bi=16199,_i=16200,Ja=16201,Ua=16202,ja=16203,Ga=16204,Za=16205,Is=16206,Ha=16207,Xa=16208,Ee=16209,Ac=16210,Nc=16211,nd=852,id=592,sd=15,od=sd,Wa=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function ad(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var kr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.modeNc?1:0},Rc=e=>{if(kr(e))return mt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ni,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(nd),t.distcode=t.distdyn=new Int32Array(id),t.sane=1,t.back=-1,Mr},Tc=e=>{if(kr(e))return mt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Rc(e)},zc=(e,t)=>{let r;if(kr(e))return mt;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?mt:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Tc(e))},Pc=(e,t)=>{if(!e)return mt;let r=new ad;e.state=r,r.strm=e,r.window=null,r.mode=Ni;let n=zc(e,t);return n!==Mr&&(e.state=null),n},cd=e=>Pc(e,od),Va=!0,Es,As,ld=e=>{if(Va){Es=new Int32Array(512),As=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(En(Sc,e.lens,0,288,Es,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;En(kc,e.lens,0,32,As,0,e.work,{bits:5}),Va=!1}e.lencode=Es,e.lenbits=9,e.distcode=As,e.distbits=5},Oc=(e,t,r,n)=>{let s,i=e.state;return i.window===null&&(i.window=new Uint8Array(1<=i.wsize?(i.window.set(t.subarray(r-i.wsize,r),0),i.wnext=0,i.whave=i.wsize):(s=i.wsize-i.wnext,s>n&&(s=n),i.window.set(t.subarray(r-n,r-n+s),i.wnext),n-=s,n?(i.window.set(t.subarray(r-n,r),0),i.wnext=n,i.whave=i.wsize):(i.wnext+=s,i.wnext===i.wsize&&(i.wnext=0),i.whave{let r,n,s,i,o,a,l,c,u,h,d,f,m,p,g=0,w,x,v,y,I,b,k,E,A=new Uint8Array(4),N,z,F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(kr(e)||!e.output||!e.input&&e.avail_in!==0)return mt;r=e.state,r.mode===Ut&&(r.mode=Ss),o=e.next_out,s=e.output,l=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,c=r.hold,u=r.bits,h=a,d=l,E=Mr;e:for(;;)switch(r.mode){case Ni:if(r.wrap===0){r.mode=Ss;break}for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>>8&255,r.check=Ye(r.check,A,2,0),c=0,u=0,r.mode=Na;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=Ee;break}if((c&15)!==Aa){e.msg="unknown compression method",r.mode=Ee;break}if(c>>>=4,u-=4,k=(c&15)+8,r.wbits===0&&(r.wbits=k),k>15||k>r.wbits){e.msg="invalid window size",r.mode=Ee;break}r.dmax=1<>8&1),r.flags&512&&r.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0,r.mode=Ra;case Ra:for(;u<32;){if(a===0)break e;a--,c+=n[i++]<>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,r.check=Ye(r.check,A,4,0)),c=0,u=0,r.mode=Ta;case Ta:for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>8),r.flags&512&&r.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0,r.mode=za;case za:if(r.flags&1024){for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=Pa;case Pa:if(r.flags&1024&&(f=r.length,f>a&&(f=a),f&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(i,i+f),k)),r.flags&512&&r.wrap&4&&(r.check=Ye(r.check,n,f,i)),a-=f,i+=f,r.length-=f),r.length))break e;r.length=0,r.mode=Oa;case Oa:if(r.flags&2048){if(a===0)break e;f=0;do k=n[i+f++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k));while(k&&f>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Ut;break;case Ca:for(;u<32;){if(a===0)break e;a--,c+=n[i++]<>>=u&7,u-=u&7,r.mode=Is;break}for(;u<3;){if(a===0)break e;a--,c+=n[i++]<>>=1,u-=1,c&3){case 0:r.mode=Fa;break;case 1:if(ld(r),r.mode=bi,t===yi){c>>>=2,u-=2;break e}break;case 2:r.mode=Da;break;case 3:e.msg="invalid block type",r.mode=Ee}c>>>=2,u-=2;break;case Fa:for(c>>>=u&7,u-=u&7;u<32;){if(a===0)break e;a--,c+=n[i++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ee;break}if(r.length=c&65535,c=0,u=0,r.mode=ks,t===yi)break e;case ks:r.mode=$a;case $a:if(f=r.length,f){if(f>a&&(f=a),f>l&&(f=l),f===0)break e;s.set(n.subarray(i,i+f),o),a-=f,i+=f,l-=f,o+=f,r.length-=f;break}r.mode=Ut;break;case Da:for(;u<14;){if(a===0)break e;a--,c+=n[i++]<>>=5,u-=5,r.ndist=(c&31)+1,c>>>=5,u-=5,r.ncode=(c&15)+4,c>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ee;break}r.have=0,r.mode=qa;case qa:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[F[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},E=En(Kh,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,E){e.msg="invalid code lengths set",r.mode=Ee;break}r.have=0,r.mode=Ya;case Ya:for(;r.have>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=w,u-=w,r.lens[r.have++]=v;else{if(v===16){for(z=w+2;u>>=w,u-=w,r.have===0){e.msg="invalid bit length repeat",r.mode=Ee;break}k=r.lens[r.have-1],f=3+(c&3),c>>>=2,u-=2}else if(v===17){for(z=w+3;u>>=w,u-=w,k=0,f=3+(c&7),c>>>=3,u-=3}else{for(z=w+7;u>>=w,u-=w,k=0,f=11+(c&127),c>>>=7,u-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ee;break}for(;f--;)r.lens[r.have++]=k}}if(r.mode===Ee)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=Ee;break}if(r.lenbits=9,N={bits:r.lenbits},E=En(Sc,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,E){e.msg="invalid literal/lengths set",r.mode=Ee;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},E=En(kc,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,E){e.msg="invalid distances set",r.mode=Ee;break}if(r.mode=bi,t===yi)break e;case bi:r.mode=_i;case _i:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=i,e.avail_in=a,r.hold=c,r.bits=u,Gh(e,d),o=e.next_out,s=e.output,l=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,c=r.hold,u=r.bits,r.mode===Ut&&(r.back=-1);break}for(r.back=0;g=r.lencode[c&(1<>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>y)],w=g>>>24,x=g>>>16&255,v=g&65535,!(y+w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=y,u-=y,r.back+=y}if(c>>>=w,u-=w,r.back+=w,r.length=v,x===0){r.mode=Za;break}if(x&32){r.back=-1,r.mode=Ut;break}if(x&64){e.msg="invalid literal/length code",r.mode=Ee;break}r.extra=x&15,r.mode=Ja;case Ja:if(r.extra){for(z=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Ua;case Ua:for(;g=r.distcode[c&(1<>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>y)],w=g>>>24,x=g>>>16&255,v=g&65535,!(y+w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=y,u-=y,r.back+=y}if(c>>>=w,u-=w,r.back+=w,x&64){e.msg="invalid distance code",r.mode=Ee;break}r.offset=v,r.extra=x&15,r.mode=ja;case ja:if(r.extra){for(z=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ee;break}r.mode=Ga;case Ga:if(l===0)break e;if(f=d-l,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ee;break}f>r.wnext?(f-=r.wnext,m=r.wsize-f):m=r.wnext-f,f>r.length&&(f=r.length),p=r.window}else p=s,m=o-r.offset,f=r.length;f>l&&(f=l),l-=f,r.length-=f;do s[o++]=p[m++];while(--f);r.length===0&&(r.mode=_i);break;case Za:if(l===0)break e;s[o++]=r.length,l--,r.mode=_i;break;case Is:if(r.wrap){for(;u<32;){if(a===0)break e;a--,c|=n[i++]<{if(kr(e))return mt;let t=e.state;return t.window&&(t.window=null),e.state=null,Mr},hd=(e,t)=>{if(kr(e))return mt;let r=e.state;return(r.wrap&2)===0?mt:(r.head=t,t.done=!1,Mr)},dd=(e,t)=>{let r=t.length,n,s,i;return kr(e)||(n=e.state,n.wrap!==0&&n.mode!==Ii)?mt:n.mode===Ii&&(s=1,s=zn(s,t,r,0),s!==n.check)?Ic:(i=Oc(e,t,r,r),i?(n.mode=Ac,Ec):(n.havedict=1,Mr))},md=Tc,pd=zc,gd=Rc,wd=cd,xd=Pc,vd=ud,yd=fd,bd=hd,_d=dd,Md="pako inflate (from Nodeca project)",At={inflateReset:md,inflateReset2:pd,inflateResetKeep:gd,inflateInit:wd,inflateInit2:xd,inflate:vd,inflateEnd:yd,inflateGetHeader:bd,inflateSetDictionary:_d,inflateInfo:Md};function Sd(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var kd=Sd,Bc=Object.prototype.toString,{Z_NO_FLUSH:Id,Z_FINISH:Ka,Z_OK:Wr,Z_STREAM_END:Ns,Z_NEED_DICT:Rs,Z_STREAM_ERROR:Ed,Z_DATA_ERROR:Qa,Z_MEM_ERROR:Ad,Z_BUF_ERROR:ec}=Sr,Nd={chunkSize:1024*64,windowBits:15,to:""};function Fn(e){this.options=Ai.assign({},Nd,e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _c,this.strm.avail_out=0;let r=At.inflateInit2(this.strm,t.windowBits);if(r!==Wr)throw new Error(yr[r]);if(this.header=new kd,At.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=On.string2buf(t.dictionary):Bc.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=At.inflateSetDictionary(this.strm,t.dictionary),r!==Wr)))throw new Error(yr[r])}Fn.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,s=this.options.dictionary,i,o,a;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?Ka:Id,Bc.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),i=At.inflate(r,o),i===Rs&&s&&(i=At.inflateSetDictionary(r,s),i===Wr?i=At.inflate(r,o):i===Qa&&(i=Rs));r.avail_in>0&&i===Ns&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)At.inflateReset(r),i=At.inflate(r,o);switch(i){case Ed:case Qa:case Rs:case Ad:return this.onEnd(i),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||i===Ns||o>0))if(this.options.to==="string"){let l=On.utf8border(r.output,r.next_out),c=r.next_out-l,u=On.buf2string(r.output,l);r.next_out=c,r.avail_out=n-c,c&&r.output.set(r.output.subarray(l,l+c),0),this.onData(u)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((i===Wr||i===ec)&&a===0)){if(i===Ns)return i=At.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(r.avail_in===0){if(o===Ka)return i=At.inflateEnd(this.strm),this.onEnd(i===Wr?ec:i),this.ended=!0,!1;break}}}return!0};Fn.prototype.onData=function(e){this.chunks.push(e)};Fn.prototype.onEnd=function(e){e===Wr&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ai.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Zs(e,t){let r=new Fn(t);if(r.push(e,!0),r.err)throw r.msg||yr[r.err];return r.result}function Rd(e,t){return t=t||{},t.raw=!0,Zs(e,t)}var Td=Fn,zd=Zs,Pd=Rd,Od=Zs,Bd=Sr,Ld={Inflate:Td,inflate:zd,inflateRaw:Pd,ungzip:Od,constants:Bd},{Deflate:Cd,deflate:Fd,deflateRaw:$d,gzip:Dd}=Uh,{Inflate:qd,inflate:Yd,inflateRaw:Jd,ungzip:Ud}=Ld,jd=Cd,Gd=Fd,Zd=$d,Hd=Dd,Xd=qd,Wd=Yd,Vd=Jd,Kd=Ud,Qd=Sr,Ri={Deflate:jd,deflate:Gd,deflateRaw:Zd,gzip:Hd,Inflate:Xd,inflate:Wd,inflateRaw:Vd,ungzip:Kd,constants:Qd};var C;(function(e){e[e.End=0]="End",e[e.Byte=1]="Byte",e[e.Short=2]="Short",e[e.Int=3]="Int",e[e.Long=4]="Long",e[e.Float=5]="Float",e[e.Double=6]="Double",e[e.ByteArray=7]="ByteArray",e[e.String=8]="String",e[e.List=9]="List",e[e.Compound=10]="Compound",e[e.IntArray=11]="IntArray",e[e.LongArray=12]="LongArray"})(C=C||(C={}));var ne=class e{static FACTORIES=new Map;static register(t,r){let n=r.create().getId();if(n!==t)throw new Error(`Registered factory ${C[n]} does not match type ${C[t]}`);e.FACTORIES.set(t,r)}isEnd(){return this.getId()===C.End}isByte(){return this.getId()===C.Byte}isShort(){return this.getId()===C.Short}isInt(){return this.getId()===C.Int}isLong(){return this.getId()===C.Long}isFloat(){return this.getId()===C.Float}isDouble(){return this.getId()===C.Double}isByteArray(){return this.getId()===C.ByteArray}isString(){return this.getId()===C.String}isList(){return this.getId()===C.List}isCompound(){return this.getId()===C.Compound}isIntArray(){return this.getId()===C.IntArray}isLongArray(){return this.getId()===C.LongArray}isNumber(){return this.isByte()||this.isShort()||this.isInt()||this.isLong()||this.isFloat()||this.isDouble()}isArray(){return this.isByteArray()||this.isIntArray()||this.isLongArray()}isListOrArray(){return this.isList()||this.isArray()}getAsNumber(){return 0}getAsString(){return""}toJsonWithId(){return{type:this.getId(),value:this.toJson()}}static getFactory(t){let r=this.FACTORIES.get(t);if(!r)throw new Error(`Invalid tag id ${t}`);return r}static create(t){return this.getFactory(t).create()}static fromString(t){let r=typeof t=="string"?new ht(t):t;return this.getFactory(C.Compound).fromString(r)}static fromJson(t,r=C.Compound){return this.getFactory(r).fromJson(t)}static fromJsonWithId(t){let r=M.readObject(t)??{},n=M.readInt(r.type)??0;return e.fromJson(r.value??{},n)}static fromBytes(t,r=C.Compound){return this.getFactory(r).fromBytes(t)}};var zt=class e extends ne{static ZERO=new e(0);static ONE=new e(1);value;constructor(t){super(),this.value=typeof t=="number"?t:t?1:0}getId(){return C.Byte}equals(t){return t.isByte()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()+"b"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeByte(this.value)}static create(){return e.ZERO}static fromJson(t){return new e(M.readInt(t)??0)}static fromBytes(t){let r=t.readByte();return new e(r)}};ne.register(C.Byte,zt);var Pt=class extends ne{items;constructor(t){super(),this.items=t}getItems(){return this.items.slice(0)}getAsTuple(t,r){return[...Array(t)].map((n,s)=>r(this.items[s]))}get(t){if(t=Math.floor(t),!(t<0||t>=this.items.length))return this.items[t]}get length(){return this.items.length}map(t){return this.items.map(t)}filter(t){return this.items.filter(t)}forEach(t){this.items.forEach(t)}set(t,r){this.items[t]=r}add(t){this.items.push(t)}insert(t,r){this.items.splice(t,0,r)}delete(t){this.items.splice(t,1)}clear(){this.items=[]}};var Ir=class e extends Pt{constructor(t){super(Array.from(t??[],r=>typeof r=="number"?new zt(r):r))}getId(){return C.ByteArray}equals(t){return t.isByteArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Byte}toString(){return"[B;"+this.items.map(r=>r.getAsNumber().toFixed()+"B").join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length),t.writeBytes(this.items.map(r=>r.getAsNumber()))}static create(){return new e([])}static fromJson(t){let r=M.readArray(t,n=>M.readNumber(n)??0)??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=t.readBytes(r);return new e(n)}};ne.register(C.ByteArray,Ir);var $n=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Float}equals(t){return t.isFloat()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toString()+"f"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeFloat(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readNumber(t)??0)}static fromBytes(t){let r=t.readFloat();return new e(r)}};ne.register(C.Float,$n);var pt=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Int}equals(t){return t.isInt()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeInt(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readInt(t)??0)}static fromBytes(t){let r=t.readInt();return new e(r)}};ne.register(C.Int,pt);var Er=class e extends Pt{constructor(t){super(Array.from(t??[],r=>typeof r=="number"?new pt(r):r))}getId(){return C.IntArray}equals(t){return t.isIntArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Int}get length(){return this.items.length}toString(){return"[I;"+this.items.map(r=>r.getAsNumber().toFixed()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length);for(let r of this.items)t.writeInt(r.getAsNumber())}static create(){return new e}static fromJson(t){let r=M.readArray(t,n=>M.readNumber(n)??0)??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=[];for(let s=0;snew t(n)))}getId(){return C.List}equals(t){return t.isList()&&this.type===t.type&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return this.type}getNumber(t){let r=this.get(t);return r?.isNumber()?r.getAsNumber():0}getString(t){let r=this.get(t);return r?.isString()?r.getAsString():""}getList(t,r){let n=this.get(t);return n?.isList()&&n.getType()===r?n:e.create()}getCompound(t){let r=this.get(t);return r?.isCompound()?r:Re.create()}set(t,r){this.updateType(r),super.set(t,r)}add(t){this.updateType(t),super.add(t)}insert(t,r){this.updateType(r),super.insert(t,r)}updateType(t){if(t.getId()!==C.End){if(this.type===C.End)this.type=t.getId();else if(this.type!==t.getId())throw new Error(`Trying to add tag of type ${C[t.getId()]} to list of ${C[this.type]}`)}}clear(){super.clear(),this.type=C.End}toString(){return"["+this.items.map(t=>t.toString()).join(",")+"]"}toPrettyString(t=" ",r=0){if(this.length===0)return"[]";let n=t.repeat(r),s=t.repeat(r+1);return`[ +var ef=Object.create;var na=Object.defineProperty;var tf=Object.getOwnPropertyDescriptor;var rf=Object.getOwnPropertyNames;var nf=Object.getPrototypeOf,sf=Object.prototype.hasOwnProperty;var et=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var of=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of rf(t))!sf.call(e,s)&&s!==r&&na(e,s,{get:()=>t[s],enumerable:!(n=tf(t,s))||n.enumerable});return e};var dr=(e,t,r)=>(r=e!=null?ef(nf(e)):{},of(t||!e||!e.__esModule?na(r,"default",{value:e,enumerable:!0}):r,e));var yt=et(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.RANDOM=Xe.EPSILON=Xe.ARRAY_TYPE=Xe.ANGLE_ORDER=void 0;Xe.equals=wm;Xe.round=fm;Xe.setMatrixArrayType=hm;Xe.toDegree=gm;Xe.toRadian=pm;var lm=Xe.EPSILON=1e-6,um=Xe.ARRAY_TYPE=typeof Float32Array<"u"?Float32Array:Array,Nb=Xe.RANDOM=Math.random,Rb=Xe.ANGLE_ORDER="zyx";function fm(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}function hm(e){Xe.ARRAY_TYPE=um=e}var dm=Math.PI/180,mm=180/Math.PI;function pm(e){return e*dm}function gm(e){return e*mm}function wm(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lm;return Math.abs(e-t)<=r*Math.max(1,Math.abs(e),Math.abs(t))}});var tl=et(ve=>{"use strict";function to(e){"@babel/helpers - typeof";return to=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},to(e)}Object.defineProperty(ve,"__esModule",{value:!0});ve.LDU=Om;ve.add=Bm;ve.adjoint=Im;ve.clone=vm;ve.copy=ym;ve.create=xm;ve.determinant=Em;ve.equals=Cm;ve.exactEquals=Lm;ve.frob=Pm;ve.fromRotation=Rm;ve.fromScaling=Tm;ve.fromValues=_m;ve.identity=bm;ve.invert=km;ve.mul=void 0;ve.multiply=Qc;ve.multiplyScalar=Fm;ve.multiplyScalarAndAdd=$m;ve.rotate=Am;ve.scale=Nm;ve.set=Mm;ve.str=zm;ve.sub=void 0;ve.subtract=el;ve.transpose=Sm;var lr=Kc(yt());function Kc(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Kc=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||to(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function xm(){var e=new lr.ARRAY_TYPE(4);return lr.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}function vm(e){var t=new lr.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function ym(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function bm(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function _m(e,t,r,n){var s=new lr.ARRAY_TYPE(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=n,s}function Mm(e,t,r,n,s){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e}function Sm(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e}function km(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*i-s*n;return o?(o=1/o,e[0]=i*o,e[1]=-n*o,e[2]=-s*o,e[3]=r*o,e):null}function Im(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e}function Em(e){return e[0]*e[3]-e[2]*e[1]}function Qc(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*a+i*l,e[1]=s*a+o*l,e[2]=n*c+i*u,e[3]=s*c+o*u,e}function Am(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*a,e[1]=s*l+o*a,e[2]=n*-a+i*l,e[3]=s*-a+o*l,e}function Nm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1];return e[0]=n*a,e[1]=s*a,e[2]=i*l,e[3]=o*l,e}function Rm(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=-r,e[3]=n,e}function Tm(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e}function zm(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function Pm(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3])}function Om(e,t,r,n){return e[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-e[2]*r[1],[e,t,r]}function Bm(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function el(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Lm(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Cm(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(r-o)<=lr.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=lr.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-l)<=lr.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(i-c)<=lr.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))}function Fm(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function $m(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}var zb=ve.mul=Qc,Pb=ve.sub=el});var sl=et(be=>{"use strict";function ro(e){"@babel/helpers - typeof";return ro=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(e)}Object.defineProperty(be,"__esModule",{value:!0});be.add=r0;be.clone=qm;be.copy=Ym;be.create=Dm;be.determinant=Zm;be.equals=o0;be.exactEquals=s0;be.frob=t0;be.fromRotation=Vm;be.fromScaling=Km;be.fromTranslation=Qm;be.fromValues=jm;be.identity=Jm;be.invert=Gm;be.mul=void 0;be.multiply=nl;be.multiplyScalar=n0;be.multiplyScalarAndAdd=i0;be.rotate=Hm;be.scale=Wm;be.set=Um;be.str=e0;be.sub=void 0;be.subtract=il;be.translate=Xm;var Ct=rl(yt());function rl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(rl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||ro(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function Dm(){var e=new Ct.ARRAY_TYPE(6);return Ct.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e}function qm(e){var t=new Ct.ARRAY_TYPE(6);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function Ym(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function Jm(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function jm(e,t,r,n,s,i){var o=new Ct.ARRAY_TYPE(6);return o[0]=e,o[1]=t,o[2]=r,o[3]=n,o[4]=s,o[5]=i,o}function Um(e,t,r,n,s,i,o){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e}function Gm(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=r*i-n*s;return l?(l=1/l,e[0]=i*l,e[1]=-n*l,e[2]=-s*l,e[3]=r*l,e[4]=(s*a-i*o)*l,e[5]=(n*o-r*a)*l,e):null}function Zm(e){return e[0]*e[3]-e[1]*e[2]}function nl(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1],h=r[2],d=r[3],f=r[4],m=r[5];return e[0]=n*c+i*u,e[1]=s*c+o*u,e[2]=n*h+i*d,e[3]=s*h+o*d,e[4]=n*f+i*m+a,e[5]=s*f+o*m+l,e}function Hm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*c,e[1]=s*u+o*c,e[2]=n*-c+i*u,e[3]=s*-c+o*u,e[4]=a,e[5]=l,e}function Wm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1];return e[0]=n*c,e[1]=s*c,e[2]=i*u,e[3]=o*u,e[4]=a,e[5]=l,e}function Xm(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=r[0],u=r[1];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=n*c+i*u+a,e[5]=s*c+o*u+l,e}function Vm(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=-r,e[3]=n,e[4]=0,e[5]=0,e}function Km(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e}function Qm(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e}function e0(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"}function t0(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+1)}function r0(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e}function il(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}function n0(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e}function i0(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e}function s0(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]}function o0(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=t[0],c=t[1],u=t[2],h=t[3],d=t[4],f=t[5];return Math.abs(r-l)<=Ct.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-c)<=Ct.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(s-u)<=Ct.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))&&Math.abs(i-h)<=Ct.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=Ct.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-f)<=Ct.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))}var Bb=be.mul=nl,Lb=be.sub=il});var io=et(fe=>{"use strict";function no(e){"@babel/helpers - typeof";return no=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},no(e)}Object.defineProperty(fe,"__esModule",{value:!0});fe.add=R0;fe.adjoint=g0;fe.clone=l0;fe.copy=u0;fe.create=a0;fe.determinant=w0;fe.equals=O0;fe.exactEquals=P0;fe.frob=N0;fe.fromMat2d=S0;fe.fromMat4=c0;fe.fromQuat=k0;fe.fromRotation=_0;fe.fromScaling=M0;fe.fromTranslation=b0;fe.fromValues=f0;fe.identity=d0;fe.invert=p0;fe.mul=void 0;fe.multiply=al;fe.multiplyScalar=T0;fe.multiplyScalarAndAdd=z0;fe.normalFromMat4=I0;fe.projection=E0;fe.rotate=v0;fe.scale=y0;fe.set=h0;fe.str=A0;fe.sub=void 0;fe.subtract=cl;fe.translate=x0;fe.transpose=m0;var ct=ol(yt());function ol(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(ol=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||no(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function a0(){var e=new ct.ARRAY_TYPE(9);return ct.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function c0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function l0(e){var t=new ct.ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function u0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function f0(e,t,r,n,s,i,o,a,l){var c=new ct.ARRAY_TYPE(9);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=s,c[5]=i,c[6]=o,c[7]=a,c[8]=l,c}function h0(e,t,r,n,s,i,o,a,l,c){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e[8]=c,e}function d0(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function m0(e,t){if(e===t){var r=t[1],n=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,e[7]=s}else 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];return e}function p0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=-u*i+a*l,f=c*i-o*l,m=r*h+n*d+s*f;return m?(m=1/m,e[0]=h*m,e[1]=(-u*n+s*c)*m,e[2]=(a*n-s*o)*m,e[3]=d*m,e[4]=(u*r-s*l)*m,e[5]=(-a*r+s*i)*m,e[6]=f*m,e[7]=(-c*r+n*l)*m,e[8]=(o*r-n*i)*m,e):null}function g0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=o*u-a*c,e[1]=s*c-n*u,e[2]=n*a-s*o,e[3]=a*l-i*u,e[4]=r*u-s*l,e[5]=s*i-r*a,e[6]=i*c-o*l,e[7]=n*l-r*c,e[8]=r*o-n*i,e}function w0(e){var t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*s+o*a)+n*(l*s-i*a)}function al(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=r[0],f=r[1],m=r[2],p=r[3],g=r[4],w=r[5],x=r[6],v=r[7],y=r[8];return e[0]=d*n+f*o+m*c,e[1]=d*s+f*a+m*u,e[2]=d*i+f*l+m*h,e[3]=p*n+g*o+w*c,e[4]=p*s+g*a+w*u,e[5]=p*i+g*l+w*h,e[6]=x*n+v*o+y*c,e[7]=x*s+v*a+y*u,e[8]=x*i+v*l+y*h,e}function x0(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=r[0],f=r[1];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=a,e[5]=l,e[6]=d*n+f*o+c,e[7]=d*s+f*a+u,e[8]=d*i+f*l+h,e}function v0(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(r),f=Math.cos(r);return e[0]=f*n+d*o,e[1]=f*s+d*a,e[2]=f*i+d*l,e[3]=f*o-d*n,e[4]=f*a-d*s,e[5]=f*l-d*i,e[6]=c,e[7]=u,e[8]=h,e}function y0(e,t,r){var n=r[0],s=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function b0(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function _0(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=-r,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function M0(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function S0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function k0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,l=s+s,c=r*o,u=n*o,h=n*a,d=s*o,f=s*a,m=s*l,p=i*o,g=i*a,w=i*l;return e[0]=1-h-m,e[3]=u-w,e[6]=d+g,e[1]=u+w,e[4]=1-c-m,e[7]=f-p,e[2]=d-g,e[5]=f+p,e[8]=1-c-h,e}function I0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g,$=x*Y-v*F+y*z+I*N-b*A+k*E;return $?($=1/$,e[0]=(a*Y-l*F+c*z)*$,e[1]=(l*N-o*Y-c*A)*$,e[2]=(o*F-a*N+c*E)*$,e[3]=(s*F-n*Y-i*z)*$,e[4]=(r*Y-s*N+i*A)*$,e[5]=(n*N-r*F-i*E)*$,e[6]=(p*k-g*b+w*I)*$,e[7]=(g*y-m*k-w*v)*$,e[8]=(m*b-p*y+w*x)*$,e):null}function E0(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function A0(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function N0(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8])}function R0(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e}function cl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}function T0(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e}function z0(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e}function P0(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function O0(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=t[0],d=t[1],f=t[2],m=t[3],p=t[4],g=t[5],w=t[6],x=t[7],v=t[8];return Math.abs(r-h)<=ct.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-d)<=ct.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(s-f)<=ct.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(i-m)<=ct.EPSILON*Math.max(1,Math.abs(i),Math.abs(m))&&Math.abs(o-p)<=ct.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(a-g)<=ct.EPSILON*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(l-w)<=ct.EPSILON*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(c-x)<=ct.EPSILON*Math.max(1,Math.abs(c),Math.abs(x))&&Math.abs(u-v)<=ct.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))}var Fb=fe.mul=al,$b=fe.sub=cl});var oo=et(H=>{"use strict";function so(e){"@babel/helpers - typeof";return so=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},so(e)}Object.defineProperty(H,"__esModule",{value:!0});H.add=wp;H.adjoint=Y0;H.clone=L0;H.copy=C0;H.create=B0;H.decompose=sp;H.determinant=J0;H.equals=bp;H.exactEquals=yp;H.frob=gp;H.fromQuat=cp;H.fromQuat2=rp;H.fromRotation=K0;H.fromRotationTranslation=hl;H.fromRotationTranslationScale=op;H.fromRotationTranslationScaleOrigin=ap;H.fromScaling=V0;H.fromTranslation=X0;H.fromValues=F0;H.fromXRotation=Q0;H.fromYRotation=ep;H.fromZRotation=tp;H.frustum=lp;H.getRotation=ip;H.getScaling=dl;H.getTranslation=np;H.identity=ul;H.invert=q0;H.lookAt=dp;H.mul=void 0;H.multiply=fl;H.multiplyScalar=xp;H.multiplyScalarAndAdd=vp;H.ortho=void 0;H.orthoNO=pl;H.orthoZO=hp;H.perspective=void 0;H.perspectiveFromFieldOfView=fp;H.perspectiveNO=ml;H.perspectiveZO=up;H.rotate=G0;H.rotateX=Z0;H.rotateY=H0;H.rotateZ=W0;H.scale=U0;H.set=$0;H.str=pp;H.sub=void 0;H.subtract=gl;H.targetTo=mp;H.translate=j0;H.transpose=D0;var ke=ll(yt());function ll(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(ll=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||so(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function B0(){var e=new ke.ARRAY_TYPE(16);return ke.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function L0(e){var t=new ke.ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function C0(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function F0(e,t,r,n,s,i,o,a,l,c,u,h,d,f,m,p){var g=new ke.ARRAY_TYPE(16);return g[0]=e,g[1]=t,g[2]=r,g[3]=n,g[4]=s,g[5]=i,g[6]=o,g[7]=a,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=m,g[15]=p,g}function $0(e,t,r,n,s,i,o,a,l,c,u,h,d,f,m,p,g){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e[8]=c,e[9]=u,e[10]=h,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=g,e}function ul(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function D0(e,t){if(e===t){var r=t[1],n=t[2],s=t[3],i=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function q0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g,$=x*Y-v*F+y*z+I*N-b*A+k*E;return $?($=1/$,e[0]=(a*Y-l*F+c*z)*$,e[1]=(s*F-n*Y-i*z)*$,e[2]=(p*k-g*b+w*I)*$,e[3]=(d*b-h*k-f*I)*$,e[4]=(l*N-o*Y-c*A)*$,e[5]=(r*Y-s*N+i*A)*$,e[6]=(g*y-m*k-w*v)*$,e[7]=(u*k-d*y+f*v)*$,e[8]=(o*F-a*N+c*E)*$,e[9]=(n*N-r*F-i*E)*$,e[10]=(m*b-p*y+w*x)*$,e[11]=(h*y-u*b-f*x)*$,e[12]=(a*A-o*z-l*E)*$,e[13]=(r*z-n*A+s*E)*$,e[14]=(p*v-m*I-g*x)*$,e[15]=(u*I-h*v+d*x)*$,e):null}function Y0(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],m=t[12],p=t[13],g=t[14],w=t[15],x=r*a-n*o,v=r*l-s*o,y=r*c-i*o,I=n*l-s*a,b=n*c-i*a,k=s*c-i*l,E=u*p-h*m,A=u*g-d*m,N=u*w-f*m,z=h*g-d*p,F=h*w-f*p,Y=d*w-f*g;return e[0]=a*Y-l*F+c*z,e[1]=s*F-n*Y-i*z,e[2]=p*k-g*b+w*I,e[3]=d*b-h*k-f*I,e[4]=l*N-o*Y-c*A,e[5]=r*Y-s*N+i*A,e[6]=g*y-m*k-w*v,e[7]=u*k-d*y+f*v,e[8]=o*F-a*N+c*E,e[9]=n*N-r*F-i*E,e[10]=m*b-p*y+w*x,e[11]=h*y-u*b-f*x,e[12]=a*A-o*z-l*E,e[13]=r*z-n*A+s*E,e[14]=p*v-m*I-g*x,e[15]=u*I-h*v+d*x,e}function J0(e){var t=e[0],r=e[1],n=e[2],s=e[3],i=e[4],o=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],f=e[12],m=e[13],p=e[14],g=e[15],w=t*o-r*i,x=t*a-n*i,v=r*a-n*o,y=c*m-u*f,I=c*p-h*f,b=u*p-h*m,k=t*b-r*I+n*y,E=i*b-o*I+a*y,A=c*v-u*x+h*w,N=f*v-m*x+p*w;return l*k-s*E+g*A-d*N}function fl(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],f=t[10],m=t[11],p=t[12],g=t[13],w=t[14],x=t[15],v=r[0],y=r[1],I=r[2],b=r[3];return e[0]=v*n+y*a+I*h+b*p,e[1]=v*s+y*l+I*d+b*g,e[2]=v*i+y*c+I*f+b*w,e[3]=v*o+y*u+I*m+b*x,v=r[4],y=r[5],I=r[6],b=r[7],e[4]=v*n+y*a+I*h+b*p,e[5]=v*s+y*l+I*d+b*g,e[6]=v*i+y*c+I*f+b*w,e[7]=v*o+y*u+I*m+b*x,v=r[8],y=r[9],I=r[10],b=r[11],e[8]=v*n+y*a+I*h+b*p,e[9]=v*s+y*l+I*d+b*g,e[10]=v*i+y*c+I*f+b*w,e[11]=v*o+y*u+I*m+b*x,v=r[12],y=r[13],I=r[14],b=r[15],e[12]=v*n+y*a+I*h+b*p,e[13]=v*s+y*l+I*d+b*g,e[14]=v*i+y*c+I*f+b*w,e[15]=v*o+y*u+I*m+b*x,e}function j0(e,t,r){var n=r[0],s=r[1],i=r[2],o,a,l,c,u,h,d,f,m,p,g,w;return t===e?(e[12]=t[0]*n+t[4]*s+t[8]*i+t[12],e[13]=t[1]*n+t[5]*s+t[9]*i+t[13],e[14]=t[2]*n+t[6]*s+t[10]*i+t[14],e[15]=t[3]*n+t[7]*s+t[11]*i+t[15]):(o=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],f=t[7],m=t[8],p=t[9],g=t[10],w=t[11],e[0]=o,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=f,e[8]=m,e[9]=p,e[10]=g,e[11]=w,e[12]=o*n+u*s+m*i+t[12],e[13]=a*n+h*s+p*i+t[13],e[14]=l*n+d*s+g*i+t[14],e[15]=c*n+f*s+w*i+t[15]),e}function U0(e,t,r){var n=r[0],s=r[1],i=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function G0(e,t,r,n){var s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),l,c,u,h,d,f,m,p,g,w,x,v,y,I,b,k,E,A,N,z,F,Y,$,V;return a0?(r[0]=(a*o+u*n+l*i-c*s)*2/h,r[1]=(l*o+u*s+c*n-a*i)*2/h,r[2]=(c*o+u*i+a*s-l*n)*2/h):(r[0]=(a*o+u*n+l*i-c*s)*2,r[1]=(l*o+u*s+c*n-a*i)*2,r[2]=(c*o+u*i+a*s-l*n)*2),hl(e,t,r),e}function np(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function dl(e,t){var r=t[0],n=t[1],s=t[2],i=t[4],o=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(r*r+n*n+s*s),e[1]=Math.sqrt(i*i+o*o+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}function ip(e,t){var r=new ke.ARRAY_TYPE(3);dl(r,t);var n=1/r[0],s=1/r[1],i=1/r[2],o=t[0]*n,a=t[1]*s,l=t[2]*i,c=t[4]*n,u=t[5]*s,h=t[6]*i,d=t[8]*n,f=t[9]*s,m=t[10]*i,p=o+u+m,g=0;return p>0?(g=Math.sqrt(p+1)*2,e[3]=.25*g,e[0]=(h-f)/g,e[1]=(d-l)/g,e[2]=(a-c)/g):o>u&&o>m?(g=Math.sqrt(1+o-u-m)*2,e[3]=(h-f)/g,e[0]=.25*g,e[1]=(a+c)/g,e[2]=(d+l)/g):u>m?(g=Math.sqrt(1+u-o-m)*2,e[3]=(d-l)/g,e[0]=(a+c)/g,e[1]=.25*g,e[2]=(h+f)/g):(g=Math.sqrt(1+m-o-u)*2,e[3]=(a-c)/g,e[0]=(d+l)/g,e[1]=(h+f)/g,e[2]=.25*g),e}function sp(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];var s=n[0],i=n[1],o=n[2],a=n[4],l=n[5],c=n[6],u=n[8],h=n[9],d=n[10];r[0]=Math.sqrt(s*s+i*i+o*o),r[1]=Math.sqrt(a*a+l*l+c*c),r[2]=Math.sqrt(u*u+h*h+d*d);var f=1/r[0],m=1/r[1],p=1/r[2],g=s*f,w=i*m,x=o*p,v=a*f,y=l*m,I=c*p,b=u*f,k=h*m,E=d*p,A=g+y+E,N=0;return A>0?(N=Math.sqrt(A+1)*2,e[3]=.25*N,e[0]=(I-k)/N,e[1]=(b-x)/N,e[2]=(w-v)/N):g>y&&g>E?(N=Math.sqrt(1+g-y-E)*2,e[3]=(I-k)/N,e[0]=.25*N,e[1]=(w+v)/N,e[2]=(b+x)/N):y>E?(N=Math.sqrt(1+y-g-E)*2,e[3]=(b-x)/N,e[0]=(w+v)/N,e[1]=.25*N,e[2]=(I+k)/N):(N=Math.sqrt(1+E-g-y)*2,e[3]=(w-v)/N,e[0]=(b+x)/N,e[1]=(I+k)/N,e[2]=.25*N),e}function op(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3],l=s+s,c=i+i,u=o+o,h=s*l,d=s*c,f=s*u,m=i*c,p=i*u,g=o*u,w=a*l,x=a*c,v=a*u,y=n[0],I=n[1],b=n[2];return e[0]=(1-(m+g))*y,e[1]=(d+v)*y,e[2]=(f-x)*y,e[3]=0,e[4]=(d-v)*I,e[5]=(1-(h+g))*I,e[6]=(p+w)*I,e[7]=0,e[8]=(f+x)*b,e[9]=(p-w)*b,e[10]=(1-(h+m))*b,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function ap(e,t,r,n,s){var i=t[0],o=t[1],a=t[2],l=t[3],c=i+i,u=o+o,h=a+a,d=i*c,f=i*u,m=i*h,p=o*u,g=o*h,w=a*h,x=l*c,v=l*u,y=l*h,I=n[0],b=n[1],k=n[2],E=s[0],A=s[1],N=s[2],z=(1-(p+w))*I,F=(f+y)*I,Y=(m-v)*I,$=(f-y)*b,V=(1-(d+w))*b,ce=(g+x)*b,oe=(m+v)*k,T=(g-x)*k,B=(1-(d+p))*k;return e[0]=z,e[1]=F,e[2]=Y,e[3]=0,e[4]=$,e[5]=V,e[6]=ce,e[7]=0,e[8]=oe,e[9]=T,e[10]=B,e[11]=0,e[12]=r[0]+E-(z*E+$*A+oe*N),e[13]=r[1]+A-(F*E+V*A+T*N),e[14]=r[2]+N-(Y*E+ce*A+B*N),e[15]=1,e}function cp(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r+r,a=n+n,l=s+s,c=r*o,u=n*o,h=n*a,d=s*o,f=s*a,m=s*l,p=i*o,g=i*a,w=i*l;return e[0]=1-h-m,e[1]=u+w,e[2]=d-g,e[3]=0,e[4]=u-w,e[5]=1-c-m,e[6]=f+p,e[7]=0,e[8]=d+g,e[9]=f-p,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function lp(e,t,r,n,s,i,o){var a=1/(r-t),l=1/(s-n),c=1/(i-o);return e[0]=i*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*l,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+n)*l,e[10]=(o+i)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*c,e[15]=0,e}function ml(e,t,r,n,s){var i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){var o=1/(n-s);e[10]=(s+n)*o,e[14]=2*s*n*o}else e[10]=-1,e[14]=-2*n;return e}var qb=H.perspective=ml;function up(e,t,r,n,s){var i=1/Math.tan(t/2);if(e[0]=i/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){var o=1/(n-s);e[10]=s*o,e[14]=s*n*o}else e[10]=-1,e[14]=-n;return e}function fp(e,t,r,n){var s=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(o+a),c=2/(s+i);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-((o-a)*l*.5),e[9]=(s-i)*c*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function pl(e,t,r,n,s,i,o){var a=1/(t-r),l=1/(n-s),c=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*l,e[14]=(o+i)*c,e[15]=1,e}var Yb=H.ortho=pl;function hp(e,t,r,n,s,i,o){var a=1/(t-r),l=1/(n-s),c=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*l,e[14]=i*c,e[15]=1,e}function dp(e,t,r,n){var s,i,o,a,l,c,u,h,d,f,m=t[0],p=t[1],g=t[2],w=n[0],x=n[1],v=n[2],y=r[0],I=r[1],b=r[2];return Math.abs(m-y)0&&(f=1/Math.sqrt(f),u*=f,h*=f,d*=f);var m=l*d-c*h,p=c*u-a*d,g=a*h-l*u;return f=m*m+p*p+g*g,f>0&&(f=1/Math.sqrt(f),m*=f,p*=f,g*=f),e[0]=m,e[1]=p,e[2]=g,e[3]=0,e[4]=h*g-d*p,e[5]=d*m-u*g,e[6]=u*p-h*m,e[7]=0,e[8]=u,e[9]=h,e[10]=d,e[11]=0,e[12]=s,e[13]=i,e[14]=o,e[15]=1,e}function pp(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function gp(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function wp(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function gl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function xp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function vp(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function yp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function bp(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],w=e[15],x=t[0],v=t[1],y=t[2],I=t[3],b=t[4],k=t[5],E=t[6],A=t[7],N=t[8],z=t[9],F=t[10],Y=t[11],$=t[12],V=t[13],ce=t[14],oe=t[15];return Math.abs(r-x)<=ke.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=ke.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(s-y)<=ke.EPSILON*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(i-I)<=ke.EPSILON*Math.max(1,Math.abs(i),Math.abs(I))&&Math.abs(o-b)<=ke.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(a-k)<=ke.EPSILON*Math.max(1,Math.abs(a),Math.abs(k))&&Math.abs(l-E)<=ke.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-A)<=ke.EPSILON*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(u-N)<=ke.EPSILON*Math.max(1,Math.abs(u),Math.abs(N))&&Math.abs(h-z)<=ke.EPSILON*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(d-F)<=ke.EPSILON*Math.max(1,Math.abs(d),Math.abs(F))&&Math.abs(f-Y)<=ke.EPSILON*Math.max(1,Math.abs(f),Math.abs(Y))&&Math.abs(m-$)<=ke.EPSILON*Math.max(1,Math.abs(m),Math.abs($))&&Math.abs(p-V)<=ke.EPSILON*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(g-ce)<=ke.EPSILON*Math.max(1,Math.abs(g),Math.abs(ce))&&Math.abs(w-oe)<=ke.EPSILON*Math.max(1,Math.abs(w),Math.abs(oe))}var Jb=H.mul=fl,jb=H.sub=gl});var lo=et(G=>{"use strict";function ao(e){"@babel/helpers - typeof";return ao=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ao(e)}Object.defineProperty(G,"__esModule",{value:!0});G.add=Ip;G.angle=Wp;G.bezier=qp;G.ceil=Ep;G.clone=_p;G.copy=Sp;G.create=xl;G.cross=Cp;G.dist=void 0;G.distance=Ml;G.div=void 0;G.divide=_l;G.dot=co;G.equals=Qp;G.exactEquals=Kp;G.floor=Ap;G.forEach=void 0;G.fromValues=Mp;G.hermite=Dp;G.inverse=Bp;G.len=void 0;G.length=vl;G.lerp=Fp;G.max=Rp;G.min=Np;G.mul=void 0;G.multiply=bl;G.negate=Op;G.normalize=Lp;G.random=Yp;G.rotateX=Gp;G.rotateY=Zp;G.rotateZ=Hp;G.round=Tp;G.scale=zp;G.scaleAndAdd=Pp;G.set=kp;G.slerp=$p;G.sqrLen=G.sqrDist=void 0;G.squaredDistance=Sl;G.squaredLength=kl;G.str=Vp;G.sub=void 0;G.subtract=yl;G.transformMat3=jp;G.transformMat4=Jp;G.transformQuat=Up;G.zero=Xp;var gt=wl(yt());function wl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(wl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||ao(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function xl(){var e=new gt.ARRAY_TYPE(3);return gt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function _p(e){var t=new gt.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function vl(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Mp(e,t,r){var n=new gt.ARRAY_TYPE(3);return n[0]=e,n[1]=t,n[2]=r,n}function Sp(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function kp(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function Ip(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function yl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function bl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function _l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function Ep(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Ap(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Np(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Rp(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Tp(e,t){return e[0]=gt.round(t[0]),e[1]=gt.round(t[1]),e[2]=gt.round(t[2]),e}function zp(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Pp(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function Ml(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+n*n+s*s)}function Sl(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return r*r+n*n+s*s}function kl(e){var t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Op(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Bp(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Lp(e,t){var r=t[0],n=t[1],s=t[2],i=r*r+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function co(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Cp(e,t,r){var n=t[0],s=t[1],i=t[2],o=r[0],a=r[1],l=r[2];return e[0]=s*l-i*a,e[1]=i*o-n*l,e[2]=n*a-s*o,e}function Fp(e,t,r,n){var s=t[0],i=t[1],o=t[2];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e}function $p(e,t,r,n){var s=Math.acos(Math.min(Math.max(co(t,r),-1),1)),i=Math.sin(s),o=Math.sin((1-n)*s)/i,a=Math.sin(n*s)/i;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function Dp(e,t,r,n,s,i){var o=i*i,a=o*(2*i-3)+1,l=o*(i-2)+i,c=o*(i-1),u=o*(3-2*i);return e[0]=t[0]*a+r[0]*l+n[0]*c+s[0]*u,e[1]=t[1]*a+r[1]*l+n[1]*c+s[1]*u,e[2]=t[2]*a+r[2]*l+n[2]*c+s[2]*u,e}function qp(e,t,r,n,s,i){var o=1-i,a=o*o,l=i*i,c=a*o,u=3*i*a,h=3*l*o,d=l*i;return e[0]=t[0]*c+r[0]*u+n[0]*h+s[0]*d,e[1]=t[1]*c+r[1]*u+n[1]*h+s[1]*d,e[2]=t[2]*c+r[2]*u+n[2]*h+s[2]*d,e}function Yp(e,t){t=t===void 0?1:t;var r=gt.RANDOM()*2*Math.PI,n=gt.RANDOM()*2-1,s=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=n*t,e}function Jp(e,t,r){var n=t[0],s=t[1],i=t[2],o=r[3]*n+r[7]*s+r[11]*i+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*s+r[8]*i+r[12])/o,e[1]=(r[1]*n+r[5]*s+r[9]*i+r[13])/o,e[2]=(r[2]*n+r[6]*s+r[10]*i+r[14])/o,e}function jp(e,t,r){var n=t[0],s=t[1],i=t[2];return e[0]=n*r[0]+s*r[3]+i*r[6],e[1]=n*r[1]+s*r[4]+i*r[7],e[2]=n*r[2]+s*r[5]+i*r[8],e}function Up(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=s*c-i*l,h=i*a-n*c,d=n*l-s*a;return u=u+u,h=h+h,d=d+d,e[0]=a+o*u+s*d-i*h,e[1]=l+o*h+i*u-n*d,e[2]=c+o*d+n*h-s*u,e}function Gp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Zp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Hp(e,t,r,n){var s=[],i=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],e[0]=i[0]+r[0],e[1]=i[1]+r[1],e[2]=i[2]+r[2],e}function Wp(e,t){var r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2],l=Math.sqrt((r*r+n*n+s*s)*(i*i+o*o+a*a)),c=l&&co(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Xp(e){return e[0]=0,e[1]=0,e[2]=0,e}function Vp(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function Kp(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Qp(e,t){var r=e[0],n=e[1],s=e[2],i=t[0],o=t[1],a=t[2];return Math.abs(r-i)<=gt.EPSILON*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-o)<=gt.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(s-a)<=gt.EPSILON*Math.max(1,Math.abs(s),Math.abs(a))}var Gb=G.sub=yl,Zb=G.mul=bl,Hb=G.div=_l,Wb=G.dist=Ml,Xb=G.sqrDist=Sl,Vb=G.len=vl,Kb=G.sqrLen=kl,Qb=G.forEach=(function(){var e=xl();return function(t,r,n,s,i,o){var a,l;for(r||(r=3),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function uo(e){"@babel/helpers - typeof";return uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uo(e)}Object.defineProperty(X,"__esModule",{value:!0});X.add=i1;X.ceil=s1;X.clone=e1;X.copy=r1;X.create=El;X.cross=g1;X.dist=void 0;X.distance=Tl;X.div=void 0;X.divide=Rl;X.dot=p1;X.equals=S1;X.exactEquals=M1;X.floor=o1;X.forEach=void 0;X.fromValues=t1;X.inverse=d1;X.len=void 0;X.length=Pl;X.lerp=w1;X.max=c1;X.min=a1;X.mul=void 0;X.multiply=Nl;X.negate=h1;X.normalize=m1;X.random=x1;X.round=l1;X.scale=u1;X.scaleAndAdd=f1;X.set=n1;X.sqrLen=X.sqrDist=void 0;X.squaredDistance=zl;X.squaredLength=Ol;X.str=_1;X.sub=void 0;X.subtract=Al;X.transformMat4=v1;X.transformQuat=y1;X.zero=b1;var Ve=Il(yt());function Il(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Il=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||uo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function El(){var e=new Ve.ARRAY_TYPE(4);return Ve.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function e1(e){var t=new Ve.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function t1(e,t,r,n){var s=new Ve.ARRAY_TYPE(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=n,s}function r1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function n1(e,t,r,n,s){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e}function i1(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Al(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Nl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function Rl(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function s1(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function o1(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function a1(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function c1(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function l1(e,t){return e[0]=Ve.round(t[0]),e[1]=Ve.round(t[1]),e[2]=Ve.round(t[2]),e[3]=Ve.round(t[3]),e}function u1(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function f1(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}function Tl(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return Math.sqrt(r*r+n*n+s*s+i*i)}function zl(e,t){var r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return r*r+n*n+s*s+i*i}function Pl(e){var t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function Ol(e){var t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function h1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function d1(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function m1(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=s*o,e[3]=i*o,e}function p1(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function g1(e,t,r,n){var s=r[0]*n[1]-r[1]*n[0],i=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],a=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],c=r[2]*n[3]-r[3]*n[2],u=t[0],h=t[1],d=t[2],f=t[3];return e[0]=h*c-d*l+f*a,e[1]=-(u*c)+d*o-f*i,e[2]=u*l-h*o+f*s,e[3]=-(u*a)+h*i-d*s,e}function w1(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function x1(e,t){t=t===void 0?1:t;var r,n,s,i,o,a,l;l=Ve.RANDOM(),r=l*2-1,n=(4*Ve.RANDOM()-2)*Math.sqrt(l*-l+l),o=r*r+n*n,l=Ve.RANDOM(),s=l*2-1,i=(4*Ve.RANDOM()-2)*Math.sqrt(l*-l+l),a=s*s+i*i;var c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*n,e[2]=t*s*c,e[3]=t*i*c,e}function v1(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*o,e[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*o,e[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*o,e[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*o,e}function y1(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=s*c-i*l,h=i*a-n*c,d=n*l-s*a;return u=u+u,h=h+h,d=d+d,e[0]=a+o*u+s*d-i*h,e[1]=l+o*h+i*u-n*d,e[2]=c+o*d+n*h-s*u,e[3]=t[3],e}function b1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function _1(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function M1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function S1(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(r-o)<=Ve.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=Ve.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-l)<=Ve.EPSILON*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(i-c)<=Ve.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))}var t5=X.sub=Al,r5=X.mul=Nl,n5=X.div=Rl,i5=X.dist=Tl,s5=X.sqrDist=zl,o5=X.len=Pl,a5=X.sqrLen=Ol,c5=X.forEach=(function(){var e=El();return function(t,r,n,s,i,o){var a,l;for(r||(r=4),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function ho(e){"@babel/helpers - typeof";return ho=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ho(e)}Object.defineProperty(Z,"__esModule",{value:!0});Z.add=void 0;Z.calculateW=z1;Z.clone=void 0;Z.conjugate=L1;Z.copy=void 0;Z.create=mo;Z.dot=void 0;Z.equals=J1;Z.exactEquals=void 0;Z.exp=Cl;Z.fromEuler=C1;Z.fromMat3=$l;Z.fromValues=void 0;Z.getAngle=A1;Z.getAxisAngle=E1;Z.identity=I1;Z.invert=B1;Z.lerp=Z.length=Z.len=void 0;Z.ln=Fl;Z.mul=void 0;Z.multiply=Ll;Z.normalize=void 0;Z.pow=P1;Z.random=O1;Z.rotateX=N1;Z.rotateY=R1;Z.rotateZ=T1;Z.setAxes=Z.set=Z.scale=Z.rotationTo=void 0;Z.setAxisAngle=Bl;Z.slerp=qi;Z.squaredLength=Z.sqrLen=Z.sqlerp=void 0;Z.str=F1;var Zt=Hn(yt()),k1=Hn(io()),Gt=Hn(lo()),lt=Hn(fo());function Hn(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Hn=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||ho(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function mo(){var e=new Zt.ARRAY_TYPE(4);return Zt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function I1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Bl(e,t,r){r=r*.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function E1(e,t){var r=Math.acos(t[3])*2,n=Math.sin(r/2);return n>Zt.EPSILON?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0),r}function A1(e,t){var r=D1(e,t);return Math.acos(2*r*r-1)}function Ll(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*u+o*a+s*c-i*l,e[1]=s*u+o*l+i*a-n*c,e[2]=i*u+o*c+n*l-s*a,e[3]=o*u-n*a-s*l-i*c,e}function N1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+o*a,e[1]=s*l+i*a,e[2]=i*l-s*a,e[3]=o*l-n*a,e}function R1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l-i*a,e[1]=s*l+o*a,e[2]=i*l+n*a,e[3]=o*l-s*a,e}function T1(e,t,r){r*=.5;var n=t[0],s=t[1],i=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+s*a,e[1]=s*l-n*a,e[2]=i*l+o*a,e[3]=o*l-i*a,e}function z1(e,t){var r=t[0],n=t[1],s=t[2];return e[0]=r,e[1]=n,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),e}function Cl(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=Math.sqrt(r*r+n*n+s*s),a=Math.exp(i),l=o>0?a*Math.sin(o)/o:0;return e[0]=r*l,e[1]=n*l,e[2]=s*l,e[3]=a*Math.cos(o),e}function Fl(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=Math.sqrt(r*r+n*n+s*s),a=o>0?Math.atan2(o,i)/o:0;return e[0]=r*a,e[1]=n*a,e[2]=s*a,e[3]=.5*Math.log(r*r+n*n+s*s+i*i),e}function P1(e,t,r){return Fl(e,t),$1(e,e,r),Cl(e,e),e}function qi(e,t,r,n){var s=t[0],i=t[1],o=t[2],a=t[3],l=r[0],c=r[1],u=r[2],h=r[3],d,f,m,p,g;return f=s*l+i*c+o*u+a*h,f<0&&(f=-f,l=-l,c=-c,u=-u,h=-h),1-f>Zt.EPSILON?(d=Math.acos(f),m=Math.sin(d),p=Math.sin((1-n)*d)/m,g=Math.sin(n*d)/m):(p=1-n,g=n),e[0]=p*s+g*l,e[1]=p*i+g*c,e[2]=p*o+g*u,e[3]=p*a+g*h,e}function O1(e){var t=Zt.RANDOM(),r=Zt.RANDOM(),n=Zt.RANDOM(),s=Math.sqrt(1-t),i=Math.sqrt(t);return e[0]=s*Math.sin(2*Math.PI*r),e[1]=s*Math.cos(2*Math.PI*r),e[2]=i*Math.sin(2*Math.PI*n),e[3]=i*Math.cos(2*Math.PI*n),e}function B1(e,t){var r=t[0],n=t[1],s=t[2],i=t[3],o=r*r+n*n+s*s+i*i,a=o?1/o:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-s*a,e[3]=i*a,e}function L1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function $l(e,t){var r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);var i=(s+1)%3,o=(s+2)%3;n=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*n,n=.5/n,e[3]=(t[i*3+o]-t[o*3+i])*n,e[i]=(t[i*3+s]+t[s*3+i])*n,e[o]=(t[o*3+s]+t[s*3+o])*n}return e}function C1(e,t,r,n){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:Zt.ANGLE_ORDER,i=Math.PI/360;t*=i,n*=i,r*=i;var o=Math.sin(t),a=Math.cos(t),l=Math.sin(r),c=Math.cos(r),u=Math.sin(n),h=Math.cos(n);switch(s){case"xyz":e[0]=o*c*h+a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h-o*l*u;break;case"xzy":e[0]=o*c*h-a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h+o*l*u;break;case"yxz":e[0]=o*c*h+a*l*u,e[1]=a*l*h-o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h+o*l*u;break;case"yzx":e[0]=o*c*h+a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h-o*l*u;break;case"zxy":e[0]=o*c*h-a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u+o*l*h,e[3]=a*c*h-o*l*u;break;case"zyx":e[0]=o*c*h-a*l*u,e[1]=a*l*h+o*c*u,e[2]=a*c*u-o*l*h,e[3]=a*c*h+o*l*u;break;default:throw new Error("Unknown angle order "+s)}return e}function F1(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}var u5=Z.clone=lt.clone,f5=Z.fromValues=lt.fromValues,h5=Z.copy=lt.copy,d5=Z.set=lt.set,m5=Z.add=lt.add,p5=Z.mul=Ll,$1=Z.scale=lt.scale,D1=Z.dot=lt.dot,g5=Z.lerp=lt.lerp,q1=Z.length=lt.length,w5=Z.len=q1,Y1=Z.squaredLength=lt.squaredLength,x5=Z.sqrLen=Y1,Dl=Z.normalize=lt.normalize,v5=Z.exactEquals=lt.exactEquals;function J1(e,t){return Math.abs(lt.dot(e,t))>=1-Zt.EPSILON}var y5=Z.rotationTo=(function(){var e=Gt.create(),t=Gt.fromValues(1,0,0),r=Gt.fromValues(0,1,0);return function(n,s,i){var o=Gt.dot(s,i);return o<-.999999?(Gt.cross(e,t,s),Gt.len(e)<1e-6&&Gt.cross(e,r,s),Gt.normalize(e,e),Bl(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Gt.cross(e,s,i),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,Dl(n,n))}})(),b5=Z.sqlerp=(function(){var e=mo(),t=mo();return function(r,n,s,i,o,a){return qi(e,n,o,a),qi(t,s,i,a),qi(r,e,t,2*a*(1-a)),r}})(),_5=Z.setAxes=(function(){var e=k1.create();return function(t,r,n,s){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],Dl(t,$l(t,e))}})()});var Ul=et(K=>{"use strict";function go(e){"@babel/helpers - typeof";return go=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},go(e)}Object.defineProperty(K,"__esModule",{value:!0});K.add=lg;K.clone=U1;K.conjugate=mg;K.copy=Jl;K.create=j1;K.dot=void 0;K.equals=vg;K.exactEquals=xg;K.fromMat4=X1;K.fromRotation=W1;K.fromRotationTranslation=Yl;K.fromRotationTranslationValues=Z1;K.fromTranslation=H1;K.fromValues=G1;K.getDual=Q1;K.getReal=void 0;K.getTranslation=tg;K.identity=V1;K.invert=dg;K.length=K.len=void 0;K.lerp=hg;K.mul=void 0;K.multiply=jl;K.normalize=gg;K.rotateAroundAxis=cg;K.rotateByQuatAppend=og;K.rotateByQuatPrepend=ag;K.rotateX=ng;K.rotateY=ig;K.rotateZ=sg;K.scale=ug;K.set=K1;K.setDual=eg;K.squaredLength=K.sqrLen=K.setReal=void 0;K.str=wg;K.translate=rg;var rt=Yi(yt()),Ht=Yi(po()),ql=Yi(oo());function Yi(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Yi=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||go(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function j1(){var e=new rt.ARRAY_TYPE(8);return rt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e}function U1(e){var t=new rt.ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function G1(e,t,r,n,s,i,o,a){var l=new rt.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=r,l[3]=n,l[4]=s,l[5]=i,l[6]=o,l[7]=a,l}function Z1(e,t,r,n,s,i,o){var a=new rt.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=r,a[3]=n;var l=s*.5,c=i*.5,u=o*.5;return a[4]=l*n+c*r-u*t,a[5]=c*n+u*e-l*r,a[6]=u*n+l*t-c*e,a[7]=-l*e-c*t-u*r,a}function Yl(e,t,r){var n=r[0]*.5,s=r[1]*.5,i=r[2]*.5,o=t[0],a=t[1],l=t[2],c=t[3];return e[0]=o,e[1]=a,e[2]=l,e[3]=c,e[4]=n*c+s*l-i*a,e[5]=s*c+i*o-n*l,e[6]=i*c+n*a-s*o,e[7]=-n*o-s*a-i*l,e}function H1(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0]*.5,e[5]=t[1]*.5,e[6]=t[2]*.5,e[7]=0,e}function W1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function X1(e,t){var r=Ht.create();ql.getRotation(r,t);var n=new rt.ARRAY_TYPE(3);return ql.getTranslation(n,t),Yl(e,r,n),e}function Jl(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function V1(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e}function K1(e,t,r,n,s,i,o,a,l){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=i,e[5]=o,e[6]=a,e[7]=l,e}var S5=K.getReal=Ht.copy;function Q1(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e}var k5=K.setReal=Ht.copy;function eg(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e}function tg(e,t){var r=t[4],n=t[5],s=t[6],i=t[7],o=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=(r*c+i*o+n*l-s*a)*2,e[1]=(n*c+i*a+s*o-r*l)*2,e[2]=(s*c+i*l+r*a-n*o)*2,e}function rg(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0]*.5,l=r[1]*.5,c=r[2]*.5,u=t[4],h=t[5],d=t[6],f=t[7];return e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=o*a+s*c-i*l+u,e[5]=o*l+i*a-n*c+h,e[6]=o*c+n*l-s*a+d,e[7]=-n*a-s*l-i*c+f,e}function ng(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateX(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function ig(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateY(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function sg(e,t,r){var n=-t[0],s=-t[1],i=-t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*o+u*n+l*i-c*s,d=l*o+u*s+c*n-a*i,f=c*o+u*i+a*s-l*n,m=u*o-a*n-l*s-c*i;return Ht.rotateZ(e,t,r),n=e[0],s=e[1],i=e[2],o=e[3],e[4]=h*o+m*n+d*i-f*s,e[5]=d*o+m*s+f*n-h*i,e[6]=f*o+m*i+h*s-d*n,e[7]=m*o-h*n-d*s-f*i,e}function og(e,t,r){var n=r[0],s=r[1],i=r[2],o=r[3],a=t[0],l=t[1],c=t[2],u=t[3];return e[0]=a*o+u*n+l*i-c*s,e[1]=l*o+u*s+c*n-a*i,e[2]=c*o+u*i+a*s-l*n,e[3]=u*o-a*n-l*s-c*i,a=t[4],l=t[5],c=t[6],u=t[7],e[4]=a*o+u*n+l*i-c*s,e[5]=l*o+u*s+c*n-a*i,e[6]=c*o+u*i+a*s-l*n,e[7]=u*o-a*n-l*s-c*i,e}function ag(e,t,r){var n=t[0],s=t[1],i=t[2],o=t[3],a=r[0],l=r[1],c=r[2],u=r[3];return e[0]=n*u+o*a+s*c-i*l,e[1]=s*u+o*l+i*a-n*c,e[2]=i*u+o*c+n*l-s*a,e[3]=o*u-n*a-s*l-i*c,a=r[4],l=r[5],c=r[6],u=r[7],e[4]=n*u+o*a+s*c-i*l,e[5]=s*u+o*l+i*a-n*c,e[6]=i*u+o*c+n*l-s*a,e[7]=o*u-n*a-s*l-i*c,e}function cg(e,t,r,n){if(Math.abs(n)0){r=Math.sqrt(r);var n=t[0]/r,s=t[1]/r,i=t[2]/r,o=t[3]/r,a=t[4],l=t[5],c=t[6],u=t[7],h=n*a+s*l+i*c+o*u;e[0]=n,e[1]=s,e[2]=i,e[3]=o,e[4]=(a-n*h)/r,e[5]=(l-s*h)/r,e[6]=(c-i*h)/r,e[7]=(u-o*h)/r}return e}function wg(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"}function xg(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]}function vg(e,t){var r=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=t[0],h=t[1],d=t[2],f=t[3],m=t[4],p=t[5],g=t[6],w=t[7];return Math.abs(r-u)<=rt.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-h)<=rt.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(s-d)<=rt.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(i-f)<=rt.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(o-m)<=rt.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(a-p)<=rt.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(l-g)<=rt.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-w)<=rt.EPSILON*Math.max(1,Math.abs(c),Math.abs(w))}});var tu=et(W=>{"use strict";function xo(e){"@babel/helpers - typeof";return xo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xo(e)}Object.defineProperty(W,"__esModule",{value:!0});W.add=Sg;W.angle=jg;W.ceil=kg;W.clone=yg;W.copy=_g;W.create=Zl;W.cross=Lg;W.dist=void 0;W.distance=Vl;W.div=void 0;W.divide=Xl;W.dot=Bg;W.equals=Wg;W.exactEquals=Hg;W.floor=Ig;W.forEach=void 0;W.fromValues=bg;W.inverse=Pg;W.len=void 0;W.length=Ql;W.lerp=Cg;W.max=Ag;W.min=Eg;W.mul=void 0;W.multiply=Wl;W.negate=zg;W.normalize=Og;W.random=Fg;W.rotate=Jg;W.round=Ng;W.scale=Rg;W.scaleAndAdd=Tg;W.set=Mg;W.signedAngle=Ug;W.sqrLen=W.sqrDist=void 0;W.squaredDistance=Kl;W.squaredLength=eu;W.str=Zg;W.sub=void 0;W.subtract=Hl;W.transformMat2=$g;W.transformMat2d=Dg;W.transformMat3=qg;W.transformMat4=Yg;W.zero=Gg;var Wt=Gl(yt());function Gl(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(Gl=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||xo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}function Zl(){var e=new Wt.ARRAY_TYPE(2);return Wt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function yg(e){var t=new Wt.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t}function bg(e,t){var r=new Wt.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r}function _g(e,t){return e[0]=t[0],e[1]=t[1],e}function Mg(e,t,r){return e[0]=t,e[1]=r,e}function Sg(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Hl(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function Wl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Xl(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function kg(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function Ig(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function Eg(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function Ag(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function Ng(e,t){return e[0]=Wt.round(t[0]),e[1]=Wt.round(t[1]),e}function Rg(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Tg(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function Vl(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function Kl(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function Ql(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function eu(e){var t=e[0],r=e[1];return t*t+r*r}function zg(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Pg(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Og(e,t){var r=t[0],n=t[1],s=r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function Bg(e,t){return e[0]*t[0]+e[1]*t[1]}function Lg(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e}function Cg(e,t,r,n){var s=t[0],i=t[1];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e}function Fg(e,t){t=t===void 0?1:t;var r=Wt.RANDOM()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function $g(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e}function Dg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s+r[4],e[1]=r[1]*n+r[3]*s+r[5],e}function qg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[3]*s+r[6],e[1]=r[1]*n+r[4]*s+r[7],e}function Yg(e,t,r){var n=t[0],s=t[1];return e[0]=r[0]*n+r[4]*s+r[12],e[1]=r[1]*n+r[5]*s+r[13],e}function Jg(e,t,r,n){var s=t[0]-r[0],i=t[1]-r[1],o=Math.sin(n),a=Math.cos(n);return e[0]=s*a-i*o+r[0],e[1]=s*o+i*a+r[1],e}function jg(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.abs(Math.atan2(n*s-r*i,r*s+n*i))}function Ug(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.atan2(r*i-n*s,r*s+n*i)}function Gg(e){return e[0]=0,e[1]=0,e}function Zg(e){return"vec2("+e[0]+", "+e[1]+")"}function Hg(e,t){return e[0]===t[0]&&e[1]===t[1]}function Wg(e,t){var r=e[0],n=e[1],s=t[0],i=t[1];return Math.abs(r-s)<=Wt.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-i)<=Wt.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))}var R5=W.len=Ql,T5=W.sub=Hl,z5=W.mul=Wl,P5=W.div=Xl,O5=W.dist=Vl,B5=W.sqrDist=Kl,L5=W.sqrLen=eu,C5=W.forEach=(function(){var e=Zl();return function(t,r,n,s,i,o){var a,l;for(r||(r=2),n||(n=0),s?l=Math.min(s*r+n,t.length):l=t.length,a=n;a{"use strict";function vo(e){"@babel/helpers - typeof";return vo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vo(e)}Object.defineProperty(Pe,"__esModule",{value:!0});Pe.vec4=Pe.vec3=Pe.vec2=Pe.quat2=Pe.quat=Pe.mat4=Pe.mat3=Pe.mat2d=Pe.mat2=Pe.glMatrix=void 0;var Xg=bt(yt());Pe.glMatrix=Xg;var Vg=bt(tl());Pe.mat2=Vg;var Kg=bt(sl());Pe.mat2d=Kg;var Qg=bt(io());Pe.mat3=Qg;var e2=bt(oo());Pe.mat4=e2;var t2=bt(po());Pe.quat=t2;var r2=bt(Ul());Pe.quat2=r2;var n2=bt(tu());Pe.vec2=n2;var i2=bt(lo());Pe.vec3=i2;var s2=bt(fo());Pe.vec4=s2;function bt(e,t){if(typeof WeakMap=="function")var r=new WeakMap,n=new WeakMap;return(bt=function(i,o){if(!o&&i&&i.__esModule)return i;var a,l,c={__proto__:null,default:i};if(i===null||vo(i)!="object"&&typeof i!="function")return c;if(a=o?n:r){if(a.has(i))return a.get(i);a.set(i,c)}for(var u in i)u!=="default"&&{}.hasOwnProperty.call(i,u)&&((l=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(i,u))&&(l.get||l.set)?a(c,u,l):c[u]=i[u]);return c})(e,t)}});var nu=et((A_,ru)=>{(function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(r,n){return r<>>32-n},rotr:function(r,n){return r<<32-n|r>>>n},endian:function(r){if(r.constructor==Number)return t.rotl(r,8)&16711935|t.rotl(r,24)&4278255360;for(var n=0;n0;r--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(r){for(var n=[],s=0,i=0;s>>5]|=r[s]<<24-i%32;return n},wordsToBytes:function(r){for(var n=[],s=0;s>>5]>>>24-s%32&255);return n},bytesToHex:function(r){for(var n=[],s=0;s>>4).toString(16)),n.push((r[s]&15).toString(16));return n.join("")},hexToBytes:function(r){for(var n=[],s=0;s>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(r){r=r.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],s=0,i=0;s>>6-i*2);return n}};ru.exports=t})()});var _o=et((N_,iu)=>{var bo={utf8:{stringToBytes:function(e){return bo.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(bo.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r{ou.exports=function(e){return e!=null&&(su(e)||a2(e)||!!e._isBuffer)};function su(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function a2(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&su(e.slice(0,0))}});var lu=et((T_,cu)=>{(function(){var e=nu(),t=_o().utf8,r=au(),n=_o().bin,s=function(i,o){i.constructor==String?o&&o.encoding==="binary"?i=n.stringToBytes(i):i=t.stringToBytes(i):r(i)?i=Array.prototype.slice.call(i,0):!Array.isArray(i)&&i.constructor!==Uint8Array&&(i=i.toString());for(var a=e.bytesToWords(i),l=i.length*8,c=1732584193,u=-271733879,h=-1732584194,d=271733878,f=0;f>>24)&16711935|(a[f]<<24|a[f]>>>8)&4278255360;a[l>>>5]|=128<>>9<<4)+14]=l;for(var m=s._ff,p=s._gg,g=s._hh,w=s._ii,f=0;f>>0,u=u+v>>>0,h=h+y>>>0,d=d+I>>>0}return e.endian([c,u,h,d])};s._ff=function(i,o,a,l,c,u,h){var d=i+(o&a|~o&l)+(c>>>0)+h;return(d<>>32-u)+o},s._gg=function(i,o,a,l,c,u,h){var d=i+(o&l|a&~l)+(c>>>0)+h;return(d<>>32-u)+o},s._hh=function(i,o,a,l,c,u,h){var d=i+(o^a^l)+(c>>>0)+h;return(d<>>32-u)+o},s._ii=function(i,o,a,l,c,u,h){var d=i+(a^(o|~l))+(c>>>0)+h;return(d<>>32-u)+o},s._blocksize=16,s._digestsize=16,cu.exports=function(i,o){if(i==null)throw new Error("Illegal argument "+i);var a=e.wordsToBytes(s(i,o));return o&&o.asBytes?a:o&&o.asString?n.bytesToString(a):e.bytesToHex(a)}})()});import ds from"node:process";var kn=["temperature","humidity","continentalness","erosion","depth","weirdness"];function ia(e,t,r){return er?e-r:0}function Gr(e,t,r){let n=e.params,s=t*13,i=0;for(let a=0;a<6;a++){let l=ia(r[a],n[s+a*2],n[s+a*2+1]);i+=l*l}let o=n[s+12];return i+o*o}function sa(e,t,r){let n=e.params,s=t*13,i=kn.map((o,a)=>{let l=n[s+a*2],c=n[s+a*2+1];return{param:o,min:l,max:c,value:r[a],off:ia(r[a],l,c)}});return{index:t,biome:e.biomes[t],distance:Math.sqrt(Gr(e,t,r)),params:i,offset:n[s+12]}}function gs(e,t,r=5){let n=new Map;for(let s=0;ss.f-i.f||s.i-i.i).slice(0,r).map(({i:s})=>sa(e,s,t))}function oa(e,t,r){let n=-1,s=1/0;for(let i=0;i!r.has(n)).sort()}var af=/^data\/([^/]+)\/(worldgen\/(?:noise|density_function|noise_settings|material_rule|material_condition)|dimension|tags\/worldgen\/biome)\/(.+)\.json$/;function ws(e){let t=af.exec(e);return t?{kind:t[2]==="tags/worldgen/biome"?"tag/worldgen/biome":t[2].replace("worldgen/",""),id:`${t[1]}:${t[3]}`}:null}var Ie=class extends Error{};function la(e){let t=[];for(let r of e){let n=ws(r.path);if(n)try{t.push({...n,json:JSON.parse(r.text)})}catch{}}return t}var ua=e=>e.includes(":")?e:`minecraft:${e}`;function mr(e,t,r){if(r.includes(t))return t;if(!t.includes(":")){let s=r.filter(i=>i.slice(i.indexOf(":")+1)===t);if(s.length===1)return s[0];if(s.length>1)throw new Ie(`${t} could be ${s.join(" or ")}; give the namespace.`);if(r.includes(`minecraft:${t}`))return`minecraft:${t}`}let n=r.length?`: ${r.slice(0,30).join(", ")}${r.length>30?", \u2026":""}`:"";throw new Ie(`No ${e} ${t}. The ${e}s there are${n||" none"}.`)}function Ce(e,t,r,n=-1/0,s=1/0){let i=e[t];if(i==null)return r;if(typeof i!="number"||!Number.isFinite(i))throw new Ie(`${t} must be a number.`);if(is)throw new Ie(`${t} must be between ${n} and ${s}.`);return i}function Yt(e,t){let r=e[t];if(!(r==null||r==="")){if(typeof r!="string")throw new Ie(`${t} must be a string.`);return r}}function pe(e,t=3){if(Number.isNaN(e))return"none";if(!Number.isFinite(e))return e>0?"\u221E":"-\u221E";let r=e.toFixed(t);return r.includes(".")?r.replace(/\.?0+$/,""):r}var Zr=(e,t)=>`${t?pe(100*e/t,1):"0"}%`;function pr(e){let t=[],r=[];for(let n of e)n.forEach((s,i)=>t[i]=Math.max(t[i]??0,s.length));return t.forEach((n,s)=>r[s]=e.slice(1).every(i=>/^(-?[\d.]|none$|-$)/.test(i[s]??""))),e.map(n=>n.map((s,i)=>r[i]?s.padStart(t[i]):s.padEnd(t[i])).join(" ").trimEnd()).join(` +`)}function fa(e){switch(e){case"north":return{rx:1,rz:0,dx:0,dz:1};case"east":return{rx:0,rz:1,dx:-1,dz:0};case"south":return{rx:-1,rz:0,dx:0,dz:-1};case"west":return{rx:0,rz:-1,dx:1,dz:0}}}var gi="https://raw.githubusercontent.com/misode/mcmeta/d96c75fec200c4580dd75e033a76341521165461/data";var xs=new Map,cf=1,vs={onmessage:null,postMessage(e){if(e.type!=="rendered"&&e.type!=="error"||e.type==="rendered"&&e.partial)return;let t=xs.get(e.seq);t&&(xs.delete(e.seq),e.type==="error"?t.reject(new Error(e.message)):t.resolve(e))}},ha={};async function lf(e){let t=String(e),r=`${gi}/`,n="/data.min.json";if(t.startsWith(r)&&t.endsWith(n)){let s=t.slice(r.length,-n.length),i=s.startsWith("tag/")?`tags/${s.slice(4)}`:s,o=ha[i];if(o)return{ok:!0,json:async()=>o}}return{ok:!1,json:async()=>null}}var da=globalThis;da.self=vs;da.fetch=lf;function ys(e,t){ha=t,ma({type:"setup",files:e})}function ma(e){if(!vs.onmessage)throw new Error("the preview worker is not loaded");vs.onmessage({data:e})}function Jt(e){let t=cf++;return new Promise((r,n)=>{xs.set(t,{resolve:r,reject:n}),ma({...e,type:"render",seq:t})})}function pa(e){var t=e.slice(0,2);return t.length===2&&t[0]===31&&t[1]===139}function ga(e){let t=e.slice(0,2);return t.length===2&&t[0]===120&&(t[1]===1||t[1]===94||t[1]===156||t[2]===218)}function wa(e){let t=e.slice(0,8),r=new DataView(t.buffer,t.byteOffset),n=r.getUint32(0,!0),s=r.getUint32(4,!0);if(t.length===8&&n>0&&n<100&&s===e.byteLength-8)return n}function xa(e){var t=[],r,n;for(r=0;r>6),t.push(128|n&63)):n<65536?(t.push(224|n>>12),t.push(128|n>>6&63),t.push(128|n&63)):(t.push(240|n>>18&7),t.push(128|n>>12&63),t.push(128|n>>6&63),t.push(128|n&63));return t}function va(e){var t=[],r;for(r=0;r=r)return;let n=this.buffer.byteLength;for(;nthis.buffer.byteLength&&i.fill(0,this.buffer.byteLength,this.offset),this.buffer=s,this.view=new DataView(s),this.array=i}writeNumber(t,r,n){this.accommodate(r),this.view[t](this.offset,n,this.littleEndian),this.offset+=r}writeByte=this.writeNumber.bind(this,"setInt8",1);writeShort=this.writeNumber.bind(this,"setInt16",2);writeInt=this.writeNumber.bind(this,"setInt32",4);writeFloat=this.writeNumber.bind(this,"setFloat32",4);writeDouble=this.writeNumber.bind(this,"setFloat64",8);writeBytes(t){this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}writeString(t){let r=xa(t);this.writeShort(r.length),this.writeBytes(r)}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}};var M;(function(e){function t(h){return typeof h=="number"?h:void 0}e.readNumber=t;function r(h){return typeof h=="number"?Math.floor(h):void 0}e.readInt=r;function n(h){return typeof h=="string"?h:void 0}e.readString=n;function s(h){return typeof h=="boolean"?h:void 0}e.readBoolean=s;function i(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)?h:void 0}e.readObject=i;function o(h,d){if(Array.isArray(h))return d?h.map(f=>d(f)):h}e.readArray=o;function a(h,d){if(Array.isArray(h))return[0,1].map((f=>d(h[f])))}e.readPair=a;function l(h,d){let f=i(h)??{};return Object.fromEntries(Object.entries(f).map(([m,p])=>[m,d(p)]))}e.readMap=l;function c(h,d,f){let m=d(h);return m?f(m):void 0}e.compose=c;function u(h,d){return typeof h!="string"?d[0]:d.includes(h)?h:d[0]}e.readEnum=u})(M=M||(M={}));var re;(function(e){function t(s){let i=M.readNumber(s);if(i)return n(i);let o=M.readArray(s,a=>M.readNumber(a)??0);if(!(o===void 0||o.length!==3))return o}e.fromJson=t;function r(s){if(s.isNumber())return n(s.getAsNumber());if(!s.isListOrArray())return;let i=s.getItems();if(!(i.length<3))return i.map(o=>o.getAsNumber())}e.fromNbt=r;function n(s){let i=s>>16&255,o=s>>8&255,a=s&255;return[i/255,o/255,a/255]}e.intToRgb=n})(re=re||(re={}));var ht=class e{source;cursor;constructor(t){this.source=t,this.cursor=0}get remainingLength(){return this.source.length-this.cursor}get totalLength(){return this.source.length}getRead(t=0){return this.source.substring(t,this.cursor)}getRemaining(){return this.source.substring(this.cursor)}canRead(t=1){return this.cursor+t<=this.source.length}peek(t=0){return this.source.charAt(this.cursor+t)}read(){return this.source.charAt(this.cursor++)}skip(){this.cursor+=1}skipWhitespace(){for(;this.canRead()&&e.isWhitespace(this.peek());)this.skip()}expect(t,r=!1){if(r&&this.skipWhitespace(),!this.canRead()||this.peek()!==t)throw this.createError(`Expected '${t}'`);this.skip()}readInt(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInNumber(this.peek());)this.skip();let r=this.getRead(t);if(r.length===0)throw this.createError("Expected integer");try{let n=Number(r);if(isNaN(n)||!Number.isInteger(n))throw new Error;return n}catch{throw this.cursor=t,this.createError(`Invalid integer '${r}'`)}}readFloat(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInNumber(this.peek());)this.skip();let r=this.getRead(t);if(r.length===0)throw this.createError("Expected float");try{let n=Number(r);if(isNaN(n))throw new Error;return n}catch{throw this.cursor=t,this.createError(`Invalid float '${r}'`)}}readUnquotedString(){let t=this.cursor;for(;this.canRead()&&e.isAllowedInUnquotedString(this.peek());)this.skip();return this.getRead(t)}readQuotedString(){if(!this.canRead())return"";let t=this.peek();if(!e.isQuotedStringStart(t))throw this.createError("Expected quote to start a string");return this.skip(),this.readStringUntil(t)}readString(){if(!this.canRead())return"";let t=this.peek();return e.isQuotedStringStart(t)?(this.skip(),this.readStringUntil(t)):this.readUnquotedString()}readStringUntil(t){let r=[],n=!1;for(;this.canRead();){let s=this.read();if(n)if(s===t||s==="\\")r.push(s),n=!1;else throw this.cursor-=1,this.createError(`Invalid escape sequence '${s}' in quoted string`);else if(s==="\\")n=!0;else{if(s===t)return r.join("");r.push(s)}}throw this.createError("Unclosed quoted string")}readBoolean(){let t=this.cursor,r=this.readUnquotedString();if(r.length===0)throw this.createError("Expected bool");if(r==="true")return!0;if(r==="false")return!1;throw this.cursor=t,this.createError(`Invalid bool, expected true or false but found '${r}'`)}static isAllowedInNumber(t){return t>="0"&&t<="9"||t==="."||t==="-"}static isAllowedInUnquotedString(t){return t>="0"&&t<="9"||t>="A"&&t<="Z"||t>="a"&&t<="z"||t==="_"||t==="-"||t==="."||t==="+"}static isQuotedStringStart(t){return t==="'"||t==='"'}static isWhitespace(t){return t===" "||t===" "||t===` +`||t==="\r"}createError(t){let r=Math.min(this.source.length,this.cursor),n=(r>10?"...":"")+this.source.substring(Math.max(0,r-10),r);return new Error(`${t} at position ${this.cursor}: ${n}<--[HERE]`)}};function Et(e,t,r){let n=e.get(t);if(n!==void 0)return n;let s=r(t);return e.set(t,s),s}function en(e){let t=e.length;for(;--t>=0;)e[t]=0}var uf=0,oc=1,ff=2,hf=3,df=258,js=29,$n=256,zn=$n+1+js,Xr=30,Us=19,ac=2*zn+1,gr=15,bs=16,mf=7,Gs=256,cc=16,lc=17,uc=18,Bs=new Uint8Array([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]),Si=new Uint8Array([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]),pf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),fc=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gf=512,Ut=new Array((zn+2)*2);en(Ut);var Nn=new Array(Xr*2);en(Nn);var Pn=new Array(gf);en(Pn);var On=new Array(df-hf+1);en(On);var Zs=new Array(js);en(Zs);var ki=new Array(Xr);en(ki);function _s(e,t,r,n,s){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=s,this.has_stree=e&&e.length}var hc,dc,mc;function Ms(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var pc=e=>e<256?Pn[e]:Pn[256+(e>>>7)],Bn=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},it=(e,t,r)=>{e.bi_valid>bs-r?(e.bi_buf|=t<>bs-e.bi_valid,e.bi_valid+=r-bs):(e.bi_buf|=t<{it(e,r[t*2],r[t*2+1])},gc=(e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},wf=e=>{e.bi_valid===16?(Bn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},xf=(e,t)=>{let r=t.dyn_tree,n=t.max_code,s=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,u,h,d,f,m,p=0;for(d=0;d<=gr;d++)e.bl_count[d]=0;for(r[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;cl&&(d=l,p++),r[u*2+1]=d,!(u>n)&&(e.bl_count[d]++,f=0,u>=a&&(f=o[u-a]),m=r[u*2],e.opt_len+=m*(d+f),i&&(e.static_len+=m*(s[u*2+1]+f)));if(p!==0){do{for(d=l-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(d=l;d!==0;d--)for(u=e.bl_count[d];u!==0;)h=e.heap[--c],!(h>n)&&(r[h*2+1]!==d&&(e.opt_len+=(d-r[h*2+1])*r[h*2],r[h*2+1]=d),u--)}},wc=(e,t,r)=>{let n=new Array(gr+1),s=0,i,o;for(i=1;i<=gr;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=t;o++){let a=e[o*2+1];a!==0&&(e[o*2]=gc(n[a]++,a))}},vf=()=>{let e,t,r,n,s,i=new Array(gr+1);for(r=0,n=0;n>=7;n{let t;for(t=0;t{e.bi_valid>8?Bn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ya=(e,t,r,n)=>{let s=t*2,i=r*2;return e[s]{let n=e.heap[r],s=r<<1;for(;s<=e.heap_len&&(s{let n,s,i=0,o,a;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+i++]&255,n+=(e.pending_buf[e.sym_buf+i++]&255)<<8,s=e.pending_buf[e.sym_buf+i++],n===0?Rt(e,s,t):(o=On[s],Rt(e,o+$n+1,t),a=Bs[o],a!==0&&(s-=Zs[o],it(e,s,a)),n--,o=pc(n),Rt(e,o,r),a=Si[o],a!==0&&(n-=ki[o],it(e,n,a)));while(i{let r=t.dyn_tree,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.elems,o,a,l=-1,c;for(e.heap_len=0,e.heap_max=ac,o=0;o>1;o>=1;o--)Ss(e,r,o);c=i;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ss(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,r[c*2]=r[o*2]+r[a*2],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,r[o*2+1]=r[a*2+1]=c,e.heap[1]=c++,Ss(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],xf(e,t),wc(r,l,e.bl_count)},_a=(e,t,r)=>{let n,s=-1,i,o=t[1],a=0,l=7,c=4;for(o===0&&(l=138,c=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=o,o=t[(n+1)*2+1],!(++a{let n,s=-1,i,o=t[1],a=0,l=7,c=4;for(o===0&&(l=138,c=3),n=0;n<=r;n++)if(i=o,o=t[(n+1)*2+1],!(++a{let t;for(_a(e,e.dyn_ltree,e.l_desc.max_code),_a(e,e.dyn_dtree,e.d_desc.max_code),Ls(e,e.bl_desc),t=Us-1;t>=3&&e.bl_tree[fc[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},bf=(e,t,r,n)=>{let s;for(it(e,t-257,5),it(e,r-1,5),it(e,n-4,4),s=0;s{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(r=32;r<$n;r++)if(e.dyn_ltree[r*2]!==0)return 1;return 0},Sa=!1,Mf=e=>{Sa||(vf(),Sa=!0),e.l_desc=new Ms(e.dyn_ltree,hc),e.d_desc=new Ms(e.dyn_dtree,dc),e.bl_desc=new Ms(e.bl_tree,mc),e.bi_buf=0,e.bi_valid=0,xc(e)},yc=(e,t,r,n)=>{it(e,(uf<<1)+(n?1:0),3),vc(e),Bn(e,r),Bn(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},Sf=e=>{it(e,oc<<1,3),Rt(e,Gs,Ut),wf(e)},kf=(e,t,r,n)=>{let s,i,o=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=_f(e)),Ls(e,e.l_desc),Ls(e,e.d_desc),o=yf(e),s=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=s&&(s=i)):s=i=r+5,r+4<=s&&t!==-1?yc(e,t,r,n):e.strategy===4||i===s?(it(e,(oc<<1)+(n?1:0),3),ba(e,Ut,Nn)):(it(e,(ff<<1)+(n?1:0),3),bf(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),ba(e,e.dyn_ltree,e.dyn_dtree)),xc(e),n&&vc(e)},If=(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(On[r]+$n+1)*2]++,e.dyn_dtree[pc(t)*2]++),e.sym_next===e.sym_end),Ef=Mf,Af=yc,Nf=kf,Rf=If,Tf=Sf,zf={_tr_init:Ef,_tr_stored_block:Af,_tr_flush_block:Nf,_tr_tally:Rf,_tr_align:Tf},Pf=(e,t,r,n)=>{let s=e&65535|0,i=e>>>16&65535|0,o=0;for(;r!==0;){o=r>2e3?2e3:r,r-=o;do s=s+t[n++]|0,i=i+s|0;while(--o);s%=65521,i%=65521}return s|i<<16|0},Ln=Pf,Of=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},Bf=new Uint32Array(Of()),Lf=(e,t,r,n)=>{let s=Bf,i=n+r;e^=-1;for(let o=n;o>>8^s[(e^t[o])&255];return e^-1},Ye=Lf,vr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Mr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Cf,_tr_stored_block:Cs,_tr_flush_block:Ff,_tr_tally:sr,_tr_align:$f}=zf,{Z_NO_FLUSH:or,Z_PARTIAL_FLUSH:Df,Z_FULL_FLUSH:qf,Z_FINISH:dt,Z_BLOCK:ka,Z_OK:Ze,Z_STREAM_END:Ia,Z_STREAM_ERROR:Tt,Z_DATA_ERROR:Yf,Z_BUF_ERROR:ks,Z_DEFAULT_COMPRESSION:Jf,Z_FILTERED:jf,Z_HUFFMAN_ONLY:vi,Z_RLE:Uf,Z_FIXED:Gf,Z_DEFAULT_STRATEGY:Zf,Z_UNKNOWN:Hf,Z_DEFLATED:Ai}=Mr,Wf=9,Xf=15,Vf=8,Kf=29,Qf=256,Fs=Qf+1+Kf,eh=30,th=19,rh=2*Fs+1,nh=15,me=3,ir=258,zt=ir+me+1,ih=32,Kr=42,Hs=57,$s=69,Ds=73,qs=91,Ys=103,wr=113,En=666,tt=1,tn=2,yr=3,rn=4,sh=3,xr=(e,t)=>(e.msg=vr[t],t),Ea=e=>e*2-(e>4?9:0),nr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},oh=e=>{let t,r,n,s=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=s?r-s:0;while(--t);t=s,n=t;do r=e.prev[--n],e.prev[n]=r>=s?r-s:0;while(--t)},Ws=(e,t,r)=>(t<{let r;if(e.legacy_hash)r=e.ins_h=Ws(e,e.ins_h,e.window[t+me-1]);else{let s=e.window,i=s[t]|s[t+1]<<8|s[t+2]<<16|s[t+3]<<24;r=e.ins_h=Math.imul(i,66521)+66521>>>16&e.hash_mask}let n=e.prev[t&e.w_mask]=e.head[r];return e.head[r]=t,n},ot=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},at=(e,t)=>{Ff(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ot(e.strm)},ge=(e,t)=>{e.pending_buf[e.pending++]=t},In=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Js=(e,t,r,n)=>{let s=e.avail_in;return s>n&&(s=n),s===0?0:(e.avail_in-=s,t.set(e.input.subarray(e.next_in,e.next_in+s),r),e.state.wrap===1?e.adler=Ln(e.adler,t,s,r):e.state.wrap===2&&(e.adler=Ye(e.adler,t,s,r)),e.next_in+=s,e.total_in+=s,s)},bc=(e,t)=>{let r=e.max_chain_length,n=e.strstart,s,i,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-zt?e.strstart-(e.w_size-zt):0,c=e.window,u=e.w_mask,h=e.prev,d=e.strstart+ir,f=c[n+o-1],m=c[n+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do if(s=t,!(c[s+o]!==m||c[s+o-1]!==f||c[s]!==c[n]||c[++s]!==c[n+1])){n+=2,s++;do;while(c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&c[++n]===c[++s]&&no){if(e.match_start=t,o=i,i>=a)break;f=c[n+o-1],m=c[n+o]}}while((t=h[t&u])>l&&--r!==0);return o<=e.lookahead?o:e.lookahead},Qr=e=>{let t=e.w_size,r,n,s;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-zt)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),oh(e),n+=t),e.strm.avail_in===0)break;if(r=Js(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.legacy_hash){if(e.lookahead+e.insert>=me)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=Ws(e,e.ins_h,e.window[s+1]);e.insert&&(br(e,s),s++,e.insert--,!(e.lookahead+e.insertme)for(s=e.strstart-e.insert;e.insert&&(br(e,s),s++,e.insert--,!(e.lookahead+e.insert<=me)););}while(e.lookahead{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,s,i,o=0,a=e.strm.avail_in;do{if(n=65535,i=e.bi_valid+42>>3,e.strm.avail_outs+e.strm.avail_in&&(n=s+e.strm.avail_in),n>i&&(n=i),n>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,ot(e.strm),s&&(s>n&&(s=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,n-=s),n&&(Js(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(o===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_wateri&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(Js(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,r=i>e.w_size?e.w_size:i,s=e.strstart-e.block_start,(s>=r||(s||t===dt)&&t!==or&&e.strm.avail_in===0&&s<=i)&&(n=s>i?i:s,o=t===dt&&e.strm.avail_in===0&&n===s?1:0,Cs(e,e.block_start,n,o),e.block_start+=n,ot(e.strm)),o?yr:tt)},Is=(e,t)=>{let r,n;for(;;){if(e.lookahead=me&&(r=br(e,e.strstart)),r!==0&&e.strstart-r<=e.w_size-zt&&(e.match_length=bc(e,r)),e.match_length>=me)if(n=sr(e,e.strstart-e.match_start,e.match_length-me),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=me){e.match_length--;do e.strstart++,r=br(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=Ws(e,e.ins_h,e.window[e.strstart+1]));else n=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=e.strstart{let r,n,s;for(;;){if(e.lookahead=me&&(r=br(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=me-1,r!==0&&e.prev_length4096)&&(e.match_length=me-1)),e.prev_length>=me&&e.match_length<=e.prev_length){s=e.strstart+e.lookahead-me,n=sr(e,e.strstart-1-e.prev_match,e.prev_length-me),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=s&&(r=br(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=me-1,e.strstart++,n&&(at(e,!1),e.strm.avail_out===0))return tt}else if(e.match_available){if(n=sr(e,0,e.window[e.strstart-1]),n&&at(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return tt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=sr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let r,n,s,i,o=e.window;for(;;){if(e.lookahead<=ir){if(Qr(e),e.lookahead<=ir&&t===or)return tt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=me&&e.strstart>0&&(s=e.strstart-1,n=o[s],n===o[++s]&&n===o[++s]&&n===o[++s])){i=e.strstart+ir;do;while(n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&n===o[++s]&&se.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=me?(r=sr(e,1,e.match_length-me),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=0,t===dt?(at(e,!0),e.strm.avail_out===0?yr:rn):e.sym_next&&(at(e,!1),e.strm.avail_out===0)?tt:tn},ch=(e,t)=>{let r;for(;;){if(e.lookahead===0&&(Qr(e),e.lookahead===0)){if(t===or)return tt;break}if(e.match_length=0,r=sr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),e.strm.avail_out===0))return tt}return e.insert=0,t===dt?(at(e,!0),e.strm.avail_out===0?yr:rn):e.sym_next&&(at(e,!1),e.strm.avail_out===0)?tt:tn};function At(e,t,r,n,s){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=s}var An=[new At(0,0,0,0,_c),new At(4,4,8,4,Is),new At(4,5,16,8,Is),new At(4,6,32,32,Is),new At(4,4,16,16,Hr),new At(8,16,32,32,Hr),new At(8,16,128,128,Hr),new At(8,32,128,256,Hr),new At(32,128,258,1024,Hr),new At(32,258,258,4096,Hr)],lh=e=>{e.window_size=2*e.w_size,nr(e.head),e.max_lazy_match=An[e.level].max_lazy,e.good_match=An[e.level].good_length,e.nice_match=An[e.level].nice_length,e.max_chain_length=An[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=me-1,e.match_available=0,e.ins_h=0};function uh(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ai,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(rh*2),this.dyn_dtree=new Uint16Array((2*eh+1)*2),this.bl_tree=new Uint16Array((2*th+1)*2),nr(this.dyn_ltree),nr(this.dyn_dtree),nr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(nh+1),this.heap=new Uint16Array(2*Fs+1),nr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Fs+1),nr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Dn=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==Kr&&t.status!==Hs&&t.status!==$s&&t.status!==Ds&&t.status!==qs&&t.status!==Ys&&t.status!==wr&&t.status!==En?1:0},Mc=e=>{if(Dn(e))return xr(e,Tt);e.total_in=e.total_out=0,e.data_type=Hf;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Hs:t.wrap?Kr:wr,e.adler=t.wrap===2?0:1,t.last_flush=-2,Cf(t),Ze},Sc=e=>{let t=Mc(e);return t===Ze&&lh(e.state),t},fh=(e,t)=>Dn(e)||e.state.wrap!==2?Tt:(e.state.gzhead=t,Ze),kc=(e,t,r,n,s,i,o)=>{if(!e)return Tt;let a=1;if(t===Jf&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),s<1||s>Wf||r!==Ai||n<8||n>15||t<0||t>9||i<0||i>Gf||n===8&&a!==1)return xr(e,Tt);n===8&&(n=9);let l=new uh;return e.state=l,l.strm=e,l.status=Kr,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<kc(e,t,Ai,Xf,Vf,Zf),dh=(e,t)=>{if(Dn(e)||t>ka||t<0)return e?xr(e,Tt):Tt;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===En&&t!==dt)return xr(e,e.avail_out===0?ks:Tt);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(ot(e),e.avail_out===0)return r.last_flush=-1,Ze}else if(e.avail_in===0&&Ea(t)<=Ea(n)&&t!==dt)return xr(e,ks);if(r.status===En&&e.avail_in!==0)return xr(e,ks);if(r.status===Kr&&r.wrap===0&&(r.status=wr),r.status===Kr){let s=Ai+(r.w_bits-8<<4)<<8,i=-1;if(r.strategy>=vi||r.level<2?i=0:r.level<6?i=1:r.level===6?i=2:i=3,s|=i<<6,r.strstart!==0&&(s|=ih),s+=31-s%31,In(r,s),r.strstart!==0&&(In(r,e.adler>>>16),In(r,e.adler&65535)),e.adler=1,r.status=wr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(r.status===Hs){if(e.adler=0,ge(r,31),ge(r,139),ge(r,8),r.gzhead)ge(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ge(r,r.gzhead.time&255),ge(r,r.gzhead.time>>8&255),ge(r,r.gzhead.time>>16&255),ge(r,r.gzhead.time>>24&255),ge(r,r.level===9?2:r.strategy>=vi||r.level<2?4:0),ge(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(ge(r,r.gzhead.extra.length&255),ge(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ye(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=$s;else if(ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,r.level===9?2:r.strategy>=vi||r.level<2?4:0),ge(r,sh),r.status=wr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(r.status===$s){if(r.gzhead.extra){let s=r.pending,i=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex+=a,ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0,i-=a}let o=new Uint8Array(r.gzhead.extra);r.pending_buf.set(o.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=Ds}if(r.status===Ds){if(r.gzhead.name){let s=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0}r.gzindexs&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),r.gzindex=0}r.status=qs}if(r.status===qs){if(r.gzhead.comment){let s=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>s&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s)),ot(e),r.pending!==0)return r.last_flush=-1,Ze;s=0}r.gzindexs&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-s,s))}r.status=Ys}if(r.status===Ys){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(ot(e),r.pending!==0))return r.last_flush=-1,Ze;ge(r,e.adler&255),ge(r,e.adler>>8&255),e.adler=0}if(r.status=wr,ot(e),r.pending!==0)return r.last_flush=-1,Ze}if(e.avail_in!==0||r.lookahead!==0||t!==or&&r.status!==En){let s=r.level===0?_c(r,t):r.strategy===vi?ch(r,t):r.strategy===Uf?ah(r,t):An[r.level].func(r,t);if((s===yr||s===rn)&&(r.status=En),s===tt||s===yr)return e.avail_out===0&&(r.last_flush=-1),Ze;if(s===tn&&(t===Df?$f(r):t!==ka&&(Cs(r,0,0,!1),t===qf&&(nr(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),ot(e),e.avail_out===0))return r.last_flush=-1,Ze}return t!==dt?Ze:r.wrap<=0?Ia:(r.wrap===2?(ge(r,e.adler&255),ge(r,e.adler>>8&255),ge(r,e.adler>>16&255),ge(r,e.adler>>24&255),ge(r,e.total_in&255),ge(r,e.total_in>>8&255),ge(r,e.total_in>>16&255),ge(r,e.total_in>>24&255)):(In(r,e.adler>>>16),In(r,e.adler&65535)),ot(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Ze:Ia)},mh=e=>{if(Dn(e))return Tt;let t=e.state.status;return e.state=null,t===wr?xr(e,Yf):Ze},ph=(e,t)=>{let r=t.length;if(Dn(e))return Tt;let n=e.state,s=n.wrap;if(s===2||s===1&&n.status!==Kr||n.lookahead)return Tt;if(s===1&&(e.adler=Ln(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){s===0&&(nr(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let i=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,Qr(n);n.lookahead>=me;){let l=n.strstart,c=n.lookahead-(me-1);do br(n,l),l++;while(--c);n.strstart=l,n.lookahead=me-1,Qr(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=me-1,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=i,n.wrap=s,Ze},gh=hh,wh=kc,xh=Sc,vh=Mc,yh=fh,bh=dh,_h=mh,Mh=ph,Sh="pako deflate (from Nodeca project)",Rn={deflateInit:gh,deflateInit2:wh,deflateReset:xh,deflateResetKeep:vh,deflateSetHeader:yh,deflate:bh,deflateEnd:_h,deflateSetDictionary:Mh,deflateInfo:Sh},kh=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ih=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)kh(r,n)&&(e[n]=r[n])}}return e},Eh=e=>{let t=0;for(let n=0,s=e.length;n=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Cn[254]=Cn[255]=1;var Ah=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,s,i,o=e.length,a=0;for(s=0;s>>6,t[i++]=128|r&63):r<65536?(t[i++]=224|r>>>12,t[i++]=128|r>>>6&63,t[i++]=128|r&63):(t[i++]=240|r>>>18,t[i++]=128|r>>>12&63,t[i++]=128|r>>>6&63,t[i++]=128|r&63);return t},Nh=(e,t)=>{if(t<65534&&e.subarray&&Ic)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,s,i=new Array(r*2);for(s=0,n=0;n4){i[s++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n1){i[s++]=65533;continue}o<65536?i[s++]=o:(o-=65536,i[s++]=55296|o>>10&1023,i[s++]=56320|o&1023)}return Nh(i,s)},Th=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+Cn[e[r]]>t?r:t},Fn={string2buf:Ah,buf2string:Rh,utf8border:Th};function zh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Ec=zh,Ac=Object.prototype.toString,{Z_NO_FLUSH:Ph,Z_SYNC_FLUSH:Oh,Z_FULL_FLUSH:Bh,Z_FINISH:Lh,Z_OK:Ii,Z_STREAM_END:Ch,Z_DEFAULT_COMPRESSION:Fh,Z_DEFAULT_STRATEGY:$h,Z_DEFLATED:Dh}=Mr,qh={level:Fh,method:Dh,chunkSize:16384,windowBits:15,memLevel:8,strategy:$h,legacyHash:!0};function qn(e){this.options=Ni.assign({},qh,e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ec,this.strm.avail_out=0;let r=Rn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(r!==Ii)throw new Error(vr[r]);if(t.header&&Rn.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=Fn.string2buf(t.dictionary):Ac.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=Rn.deflateSetDictionary(this.strm,n),r!==Ii)throw new Error(vr[r]);this._dict_set=!0}}qn.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,s,i;if(this.ended)return!1;for(t===~~t?i=t:i=t===!0?Lh:Ph,typeof e=="string"?r.input=Fn.string2buf(e):Ac.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(i===Oh||i===Bh)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(s=Rn.deflate(r,i),s===Ch)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),s=Rn.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Ii;if(r.avail_out===0){this.onData(r.output);continue}if(i>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};qn.prototype.onData=function(e){this.chunks.push(e)};qn.prototype.onEnd=function(e){e===Ii&&(this.result=Ni.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Xs(e,t){let r=new qn(t);if(r.push(e,!0),r.err)throw r.msg||vr[r.err];return r.result}function Yh(e,t){return t=t||{},t.raw=!0,Xs(e,t)}function Jh(e,t){return t=t||{},t.gzip=!0,Xs(e,t)}var jh=qn,Uh=Xs,Gh=Yh,Zh=Jh,Hh=Mr,Wh={Deflate:jh,deflate:Uh,deflateRaw:Gh,gzip:Zh,constants:Hh},yi=16209,Xh=16191,Vh=function(t,r){let n,s,i,o,a,l,c,u,h,d,f,m,p,g,w,x,v,y,I,b,k,E,A,N,z=t.state;n=t.next_in,A=t.input,s=n+(t.avail_in-5),i=t.next_out,N=t.output,o=i-(r-t.avail_out),a=i+(t.avail_out-257),l=z.dmax,c=z.wsize,u=z.whave,h=z.wnext,d=z.window,f=z.hold,m=z.bits,p=z.lencode,g=z.distcode,w=(1<>>24,f>>>=y,m-=y,y=v>>>16&255,y===0)N[i++]=v&65535;else if(y&16){I=v&65535,y&=15,y&&(m>>=y,m-=y),m<15&&(f+=A[n++]<>>24,f>>>=y,m-=y,y=v>>>16&255,y&16){if(b=v&65535,y&=15,ml){t.msg="invalid distance too far back",z.mode=yi;break e}if(f>>>=y,m-=y,y=i-o,b>y){if(y=b-y,y>u&&z.sane){t.msg="invalid distance too far back",z.mode=yi;break e}if(k=0,E=d,h===0){if(k+=c-y,y2;)N[i++]=E[k++],N[i++]=E[k++],N[i++]=E[k++],I-=3;I&&(N[i++]=E[k++],I>1&&(N[i++]=E[k++]))}else{k=i-b;do N[i++]=N[k++],N[i++]=N[k++],N[i++]=N[k++],I-=3;while(I>2);I&&(N[i++]=N[k++],I>1&&(N[i++]=N[k++]))}}else if((y&64)===0){v=g[(v&65535)+(f&(1<>3,n-=I,m-=I<<3,f&=(1<{let l=a.bits,c=0,u=0,h=0,d=0,f=0,m=0,p=0,g=0,w=0,x=0,v,y,I,b,k,E=null,A,N=new Uint16Array(Wr+1),z=new Uint16Array(Wr+1),F=null,Y,$,V;for(c=0;c<=Wr;c++)N[c]=0;for(u=0;u=1&&N[d]===0;d--);if(f>d&&(f=d),d===0)return s[i++]=1<<24|64<<16|0,s[i++]=1<<24|64<<16|0,a.bits=1,0;for(h=1;h0&&(e===Ra||d!==1))return-1;for(z[1]=0,c=1;cAa||e===Ta&&w>Na)return 1;for(;;){Y=c-p,o[u]+1=A?($=F[o[u]-A],V=E[o[u]-A]):($=96,V=0),v=1<>p)+y]=Y<<24|$<<16|V|0;while(y!==0);for(v=1<>=1;if(v!==0?(x&=v-1,x+=v):x=0,u++,--N[c]===0){if(c===d)break;c=t[r+o[u]]}if(c>f&&(x&b)!==I){for(p===0&&(p=f),k+=h,m=c-p,g=1<Aa||e===Ta&&w>Na)return 1;I=x&b,s[I]=f<<24|m<<16|k-i|0}}return x!==0&&(s[k+x]=c-p<<24|64<<16|0),a.bits=f,0},Tn=rd,nd=0,Nc=1,Rc=2,{Z_FINISH:za,Z_BLOCK:id,Z_TREES:bi,Z_OK:_r,Z_STREAM_END:sd,Z_NEED_DICT:od,Z_STREAM_ERROR:mt,Z_DATA_ERROR:Tc,Z_MEM_ERROR:zc,Z_BUF_ERROR:ad,Z_DEFLATED:Pa}=Mr,Ri=16180,Oa=16181,Ba=16182,La=16183,Ca=16184,Fa=16185,$a=16186,Da=16187,qa=16188,Ya=16189,Ei=16190,jt=16191,As=16192,Ja=16193,Ns=16194,ja=16195,Ua=16196,Ga=16197,Za=16198,_i=16199,Mi=16200,Ha=16201,Wa=16202,Xa=16203,Va=16204,Ka=16205,Rs=16206,Qa=16207,ec=16208,Ee=16209,Pc=16210,Oc=16211,cd=852,ld=592,ud=15,fd=ud,tc=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function hd(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Sr=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.modeOc?1:0},Bc=e=>{if(Sr(e))return mt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ri,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(cd),t.distcode=t.distdyn=new Int32Array(ld),t.sane=1,t.back=-1,_r},Lc=e=>{if(Sr(e))return mt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Bc(e)},Cc=(e,t)=>{let r;if(Sr(e))return mt;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?mt:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Lc(e))},Fc=(e,t)=>{if(!e)return mt;let r=new hd;e.state=r,r.strm=e,r.window=null,r.mode=Ri;let n=Cc(e,t);return n!==_r&&(e.state=null),n},dd=e=>Fc(e,fd),rc=!0,Ts,zs,md=e=>{if(rc){Ts=new Int32Array(512),zs=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Tn(Nc,e.lens,0,288,Ts,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Tn(Rc,e.lens,0,32,zs,0,e.work,{bits:5}),rc=!1}e.lencode=Ts,e.lenbits=9,e.distcode=zs,e.distbits=5},$c=(e,t,r,n)=>{let s,i=e.state;return i.window===null&&(i.window=new Uint8Array(1<=i.wsize?(i.window.set(t.subarray(r-i.wsize,r),0),i.wnext=0,i.whave=i.wsize):(s=i.wsize-i.wnext,s>n&&(s=n),i.window.set(t.subarray(r-n,r-n+s),i.wnext),n-=s,n?(i.window.set(t.subarray(r-n,r),0),i.wnext=n,i.whave=i.wsize):(i.wnext+=s,i.wnext===i.wsize&&(i.wnext=0),i.whave{let r,n,s,i,o,a,l,c,u,h,d,f,m,p,g=0,w,x,v,y,I,b,k,E,A=new Uint8Array(4),N,z,F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Sr(e)||!e.output||!e.input&&e.avail_in!==0)return mt;r=e.state,r.mode===jt&&(r.mode=As),o=e.next_out,s=e.output,l=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,c=r.hold,u=r.bits,h=a,d=l,E=_r;e:for(;;)switch(r.mode){case Ri:if(r.wrap===0){r.mode=As;break}for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>>8&255,r.check=Ye(r.check,A,2,0),c=0,u=0,r.mode=Oa;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=Ee;break}if((c&15)!==Pa){e.msg="unknown compression method",r.mode=Ee;break}if(c>>>=4,u-=4,k=(c&15)+8,r.wbits===0&&(r.wbits=k),k>15||k>r.wbits){e.msg="invalid window size",r.mode=Ee;break}r.dmax=1<>8&1),r.flags&512&&r.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0,r.mode=Ba;case Ba:for(;u<32;){if(a===0)break e;a--,c+=n[i++]<>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,r.check=Ye(r.check,A,4,0)),c=0,u=0,r.mode=La;case La:for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>8),r.flags&512&&r.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0,r.mode=Ca;case Ca:if(r.flags&1024){for(;u<16;){if(a===0)break e;a--,c+=n[i++]<>>8&255,r.check=Ye(r.check,A,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=Fa;case Fa:if(r.flags&1024&&(f=r.length,f>a&&(f=a),f&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(i,i+f),k)),r.flags&512&&r.wrap&4&&(r.check=Ye(r.check,n,f,i)),a-=f,i+=f,r.length-=f),r.length))break e;r.length=0,r.mode=$a;case $a:if(r.flags&2048){if(a===0)break e;f=0;do k=n[i+f++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k));while(k&&f>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=jt;break;case Ya:for(;u<32;){if(a===0)break e;a--,c+=n[i++]<>>=u&7,u-=u&7,r.mode=Rs;break}for(;u<3;){if(a===0)break e;a--,c+=n[i++]<>>=1,u-=1,c&3){case 0:r.mode=Ja;break;case 1:if(md(r),r.mode=_i,t===bi){c>>>=2,u-=2;break e}break;case 2:r.mode=Ua;break;case 3:e.msg="invalid block type",r.mode=Ee}c>>>=2,u-=2;break;case Ja:for(c>>>=u&7,u-=u&7;u<32;){if(a===0)break e;a--,c+=n[i++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ee;break}if(r.length=c&65535,c=0,u=0,r.mode=Ns,t===bi)break e;case Ns:r.mode=ja;case ja:if(f=r.length,f){if(f>a&&(f=a),f>l&&(f=l),f===0)break e;s.set(n.subarray(i,i+f),o),a-=f,i+=f,l-=f,o+=f,r.length-=f;break}r.mode=jt;break;case Ua:for(;u<14;){if(a===0)break e;a--,c+=n[i++]<>>=5,u-=5,r.ndist=(c&31)+1,c>>>=5,u-=5,r.ncode=(c&15)+4,c>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ee;break}r.have=0,r.mode=Ga;case Ga:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[F[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},E=Tn(nd,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,E){e.msg="invalid code lengths set",r.mode=Ee;break}r.have=0,r.mode=Za;case Za:for(;r.have>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=w,u-=w,r.lens[r.have++]=v;else{if(v===16){for(z=w+2;u>>=w,u-=w,r.have===0){e.msg="invalid bit length repeat",r.mode=Ee;break}k=r.lens[r.have-1],f=3+(c&3),c>>>=2,u-=2}else if(v===17){for(z=w+3;u>>=w,u-=w,k=0,f=3+(c&7),c>>>=3,u-=3}else{for(z=w+7;u>>=w,u-=w,k=0,f=11+(c&127),c>>>=7,u-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ee;break}for(;f--;)r.lens[r.have++]=k}}if(r.mode===Ee)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=Ee;break}if(r.lenbits=9,N={bits:r.lenbits},E=Tn(Nc,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,E){e.msg="invalid literal/lengths set",r.mode=Ee;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},E=Tn(Rc,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,E){e.msg="invalid distances set",r.mode=Ee;break}if(r.mode=_i,t===bi)break e;case _i:r.mode=Mi;case Mi:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=i,e.avail_in=a,r.hold=c,r.bits=u,Vh(e,d),o=e.next_out,s=e.output,l=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,c=r.hold,u=r.bits,r.mode===jt&&(r.back=-1);break}for(r.back=0;g=r.lencode[c&(1<>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>y)],w=g>>>24,x=g>>>16&255,v=g&65535,!(y+w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=y,u-=y,r.back+=y}if(c>>>=w,u-=w,r.back+=w,r.length=v,x===0){r.mode=Ka;break}if(x&32){r.back=-1,r.mode=jt;break}if(x&64){e.msg="invalid literal/length code",r.mode=Ee;break}r.extra=x&15,r.mode=Ha;case Ha:if(r.extra){for(z=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Wa;case Wa:for(;g=r.distcode[c&(1<>>24,x=g>>>16&255,v=g&65535,!(w<=u);){if(a===0)break e;a--,c+=n[i++]<>y)],w=g>>>24,x=g>>>16&255,v=g&65535,!(y+w<=u);){if(a===0)break e;a--,c+=n[i++]<>>=y,u-=y,r.back+=y}if(c>>>=w,u-=w,r.back+=w,x&64){e.msg="invalid distance code",r.mode=Ee;break}r.offset=v,r.extra=x&15,r.mode=Xa;case Xa:if(r.extra){for(z=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ee;break}r.mode=Va;case Va:if(l===0)break e;if(f=d-l,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ee;break}f>r.wnext?(f-=r.wnext,m=r.wsize-f):m=r.wnext-f,f>r.length&&(f=r.length),p=r.window}else p=s,m=o-r.offset,f=r.length;f>l&&(f=l),l-=f,r.length-=f;do s[o++]=p[m++];while(--f);r.length===0&&(r.mode=Mi);break;case Ka:if(l===0)break e;s[o++]=r.length,l--,r.mode=Mi;break;case Rs:if(r.wrap){for(;u<32;){if(a===0)break e;a--,c|=n[i++]<{if(Sr(e))return mt;let t=e.state;return t.window&&(t.window=null),e.state=null,_r},wd=(e,t)=>{if(Sr(e))return mt;let r=e.state;return(r.wrap&2)===0?mt:(r.head=t,t.done=!1,_r)},xd=(e,t)=>{let r=t.length,n,s,i;return Sr(e)||(n=e.state,n.wrap!==0&&n.mode!==Ei)?mt:n.mode===Ei&&(s=1,s=Ln(s,t,r,0),s!==n.check)?Tc:(i=$c(e,t,r,r),i?(n.mode=Pc,zc):(n.havedict=1,_r))},vd=Lc,yd=Cc,bd=Bc,_d=dd,Md=Fc,Sd=pd,kd=gd,Id=wd,Ed=xd,Ad="pako inflate (from Nodeca project)",Nt={inflateReset:vd,inflateReset2:yd,inflateResetKeep:bd,inflateInit:_d,inflateInit2:Md,inflate:Sd,inflateEnd:kd,inflateGetHeader:Id,inflateSetDictionary:Ed,inflateInfo:Ad};function Nd(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Rd=Nd,Dc=Object.prototype.toString,{Z_NO_FLUSH:Td,Z_FINISH:nc,Z_OK:Vr,Z_STREAM_END:Ps,Z_NEED_DICT:Os,Z_STREAM_ERROR:zd,Z_DATA_ERROR:ic,Z_MEM_ERROR:Pd,Z_BUF_ERROR:sc}=Mr,Od={chunkSize:1024*64,windowBits:15,to:""};function Yn(e){this.options=Ni.assign({},Od,e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ec,this.strm.avail_out=0;let r=Nt.inflateInit2(this.strm,t.windowBits);if(r!==Vr)throw new Error(vr[r]);if(this.header=new Rd,Nt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Fn.string2buf(t.dictionary):Dc.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Nt.inflateSetDictionary(this.strm,t.dictionary),r!==Vr)))throw new Error(vr[r])}Yn.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,s=this.options.dictionary,i,o,a;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?nc:Td,Dc.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),i=Nt.inflate(r,o),i===Os&&s&&(i=Nt.inflateSetDictionary(r,s),i===Vr?i=Nt.inflate(r,o):i===ic&&(i=Os));r.avail_in>0&&i===Ps&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)Nt.inflateReset(r),i=Nt.inflate(r,o);switch(i){case zd:case ic:case Os:case Pd:return this.onEnd(i),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||i===Ps||o>0))if(this.options.to==="string"){let l=Fn.utf8border(r.output,r.next_out),c=r.next_out-l,u=Fn.buf2string(r.output,l);r.next_out=c,r.avail_out=n-c,c&&r.output.set(r.output.subarray(l,l+c),0),this.onData(u)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((i===Vr||i===sc)&&a===0)){if(i===Ps)return i=Nt.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(r.avail_in===0){if(o===nc)return i=Nt.inflateEnd(this.strm),this.onEnd(i===Vr?sc:i),this.ended=!0,!1;break}}}return!0};Yn.prototype.onData=function(e){this.chunks.push(e)};Yn.prototype.onEnd=function(e){e===Vr&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ni.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Vs(e,t){let r=new Yn(t);if(r.push(e,!0),r.err)throw r.msg||vr[r.err];return r.result}function Bd(e,t){return t=t||{},t.raw=!0,Vs(e,t)}var Ld=Yn,Cd=Vs,Fd=Bd,$d=Vs,Dd=Mr,qd={Inflate:Ld,inflate:Cd,inflateRaw:Fd,ungzip:$d,constants:Dd},{Deflate:Yd,deflate:Jd,deflateRaw:jd,gzip:Ud}=Wh,{Inflate:Gd,inflate:Zd,inflateRaw:Hd,ungzip:Wd}=qd,Xd=Yd,Vd=Jd,Kd=jd,Qd=Ud,em=Gd,tm=Zd,rm=Hd,nm=Wd,im=Mr,Ti={Deflate:Xd,deflate:Vd,deflateRaw:Kd,gzip:Qd,Inflate:em,inflate:tm,inflateRaw:rm,ungzip:nm,constants:im};var C;(function(e){e[e.End=0]="End",e[e.Byte=1]="Byte",e[e.Short=2]="Short",e[e.Int=3]="Int",e[e.Long=4]="Long",e[e.Float=5]="Float",e[e.Double=6]="Double",e[e.ByteArray=7]="ByteArray",e[e.String=8]="String",e[e.List=9]="List",e[e.Compound=10]="Compound",e[e.IntArray=11]="IntArray",e[e.LongArray=12]="LongArray"})(C=C||(C={}));var ne=class e{static FACTORIES=new Map;static register(t,r){let n=r.create().getId();if(n!==t)throw new Error(`Registered factory ${C[n]} does not match type ${C[t]}`);e.FACTORIES.set(t,r)}isEnd(){return this.getId()===C.End}isByte(){return this.getId()===C.Byte}isShort(){return this.getId()===C.Short}isInt(){return this.getId()===C.Int}isLong(){return this.getId()===C.Long}isFloat(){return this.getId()===C.Float}isDouble(){return this.getId()===C.Double}isByteArray(){return this.getId()===C.ByteArray}isString(){return this.getId()===C.String}isList(){return this.getId()===C.List}isCompound(){return this.getId()===C.Compound}isIntArray(){return this.getId()===C.IntArray}isLongArray(){return this.getId()===C.LongArray}isNumber(){return this.isByte()||this.isShort()||this.isInt()||this.isLong()||this.isFloat()||this.isDouble()}isArray(){return this.isByteArray()||this.isIntArray()||this.isLongArray()}isListOrArray(){return this.isList()||this.isArray()}getAsNumber(){return 0}getAsString(){return""}toJsonWithId(){return{type:this.getId(),value:this.toJson()}}static getFactory(t){let r=this.FACTORIES.get(t);if(!r)throw new Error(`Invalid tag id ${t}`);return r}static create(t){return this.getFactory(t).create()}static fromString(t){let r=typeof t=="string"?new ht(t):t;return this.getFactory(C.Compound).fromString(r)}static fromJson(t,r=C.Compound){return this.getFactory(r).fromJson(t)}static fromJsonWithId(t){let r=M.readObject(t)??{},n=M.readInt(r.type)??0;return e.fromJson(r.value??{},n)}static fromBytes(t,r=C.Compound){return this.getFactory(r).fromBytes(t)}};var Pt=class e extends ne{static ZERO=new e(0);static ONE=new e(1);value;constructor(t){super(),this.value=typeof t=="number"?t:t?1:0}getId(){return C.Byte}equals(t){return t.isByte()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()+"b"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeByte(this.value)}static create(){return e.ZERO}static fromJson(t){return new e(M.readInt(t)??0)}static fromBytes(t){let r=t.readByte();return new e(r)}};ne.register(C.Byte,Pt);var Ot=class extends ne{items;constructor(t){super(),this.items=t}getItems(){return this.items.slice(0)}getAsTuple(t,r){return[...Array(t)].map((n,s)=>r(this.items[s]))}get(t){if(t=Math.floor(t),!(t<0||t>=this.items.length))return this.items[t]}get length(){return this.items.length}map(t){return this.items.map(t)}filter(t){return this.items.filter(t)}forEach(t){this.items.forEach(t)}set(t,r){this.items[t]=r}add(t){this.items.push(t)}insert(t,r){this.items.splice(t,0,r)}delete(t){this.items.splice(t,1)}clear(){this.items=[]}};var kr=class e extends Ot{constructor(t){super(Array.from(t??[],r=>typeof r=="number"?new Pt(r):r))}getId(){return C.ByteArray}equals(t){return t.isByteArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Byte}toString(){return"[B;"+this.items.map(r=>r.getAsNumber().toFixed()+"B").join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length),t.writeBytes(this.items.map(r=>r.getAsNumber()))}static create(){return new e([])}static fromJson(t){let r=M.readArray(t,n=>M.readNumber(n)??0)??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=t.readBytes(r);return new e(n)}};ne.register(C.ByteArray,kr);var Jn=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Float}equals(t){return t.isFloat()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toString()+"f"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeFloat(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readNumber(t)??0)}static fromBytes(t){let r=t.readFloat();return new e(r)}};ne.register(C.Float,Jn);var pt=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Int}equals(t){return t.isInt()&&this.value===t.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeInt(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readInt(t)??0)}static fromBytes(t){let r=t.readInt();return new e(r)}};ne.register(C.Int,pt);var Ir=class e extends Ot{constructor(t){super(Array.from(t??[],r=>typeof r=="number"?new pt(r):r))}getId(){return C.IntArray}equals(t){return t.isIntArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Int}get length(){return this.items.length}toString(){return"[I;"+this.items.map(r=>r.getAsNumber().toFixed()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length);for(let r of this.items)t.writeInt(r.getAsNumber())}static create(){return new e}static fromJson(t){let r=M.readArray(t,n=>M.readNumber(n)??0)??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=[];for(let s=0;snew t(n)))}getId(){return C.List}equals(t){return t.isList()&&this.type===t.type&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return this.type}getNumber(t){let r=this.get(t);return r?.isNumber()?r.getAsNumber():0}getString(t){let r=this.get(t);return r?.isString()?r.getAsString():""}getList(t,r){let n=this.get(t);return n?.isList()&&n.getType()===r?n:e.create()}getCompound(t){let r=this.get(t);return r?.isCompound()?r:Re.create()}set(t,r){this.updateType(r),super.set(t,r)}add(t){this.updateType(t),super.add(t)}insert(t,r){this.updateType(r),super.insert(t,r)}updateType(t){if(t.getId()!==C.End){if(this.type===C.End)this.type=t.getId();else if(this.type!==t.getId())throw new Error(`Trying to add tag of type ${C[t.getId()]} to list of ${C[this.type]}`)}}clear(){super.clear(),this.type=C.End}toString(){return"["+this.items.map(t=>t.toString()).join(",")+"]"}toPrettyString(t=" ",r=0){if(this.length===0)return"[]";let n=t.repeat(r),s=t.repeat(r+1);return`[ `+this.map(i=>s+i.toPrettyString(t,r+1)).join(`, `)+` -`+n+"]"}toSimplifiedJson(){return this.map(t=>t.toSimplifiedJson())}toJson(){return{type:this.type,items:this.items.map(t=>t.toJson())}}toBytes(t){this.items.length===0?this.type=C.End:this.type=this.items[0].getId(),t.writeByte(this.type),t.writeInt(this.items.length);for(let r of this.items)r.toBytes(t)}static create(){return new e}static fromJson(t){let r=M.readObject(t)??{},n=M.readNumber(r.type)??C.Compound,s=(M.readArray(r.items)??[]).flatMap(i=>i!==void 0?[ne.fromJson(i,n)]:[]);return new e(s,n)}static fromBytes(t){let r=t.readByte(),n=t.readInt();if(r===C.End&&n>0)throw new Error(`Missing type on ListTag but length is ${n}`);let s=[];for(let i=0;itypeof r=="number"?r:0):[0,0])}static fromBytes(t){let r=t.readInt(),n=t.readInt();return new e([r,n])}};ne.register(C.Long,Ar);var Nr=class e extends Pt{constructor(t){super(Array.from(t??[],r=>typeof r=="bigint"||Array.isArray(r)?new Ar(r):r))}getId(){return C.LongArray}equals(t){return t.isLongArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Long}get length(){return this.items.length}toString(){return"[I;"+this.items.map(r=>r.toString()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsPair())}toJson(){return this.items.map(t=>t.getAsPair())}toBytes(t){t.writeInt(this.items.length);for(let r of this.items){let[n,s]=r.getAsPair();t.writeInt(n),t.writeInt(s)}}static create(){return new e}static fromJson(t){let r=M.readArray(t,n=>M.readPair(n,s=>M.readNumber(s)??0)??[0,0])??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=[];for(let s=0;s{let s=t.properties.get(r);return s!==void 0&&n.equals(s)})}has(t){return this.properties.has(t)}hasNumber(t){return this.get(t)?.isNumber()??!1}hasString(t){return this.get(t)?.isString()??!1}hasList(t,r,n){let s=this.get(t);return(s?.isList()&&(r===void 0||s.getType()===r)&&(n===void 0||s.length===n))??!1}hasCompound(t){return this.get(t)?.isCompound()??!1}get(t){return this.properties.get(t)}getString(t){return this.get(t)?.getAsString()??""}getNumber(t){return this.get(t)?.getAsNumber()??0}getBoolean(t){return this.getNumber(t)!==0}getList(t,r){let n=this.get(t);return n?.isList()&&(r===void 0||n.getType()===r)?n:Ot.create()}getCompound(t){let r=this.get(t);return r?.isCompound()?r:e.create()}getByteArray(t){let r=this.get(t);return r?.isByteArray()?r:Ir.create()}getIntArray(t){let r=this.get(t);return r?.isIntArray()?r:Er.create()}getLongArray(t){let r=this.get(t);return r?.isLongArray()?r:Nr.create()}keys(){return this.properties.keys()}get size(){return this.properties.size}map(t){return Object.fromEntries([...this.properties.entries()].map(([r,n])=>t(r,n,this)))}forEach(t){[...this.properties.entries()].forEach(([r,n])=>t(r,n,this))}set(t,r){return this.properties.set(t,r),this}delete(t){return this.properties.delete(t)}clear(){return this.properties.clear(),this}toString(){let t=[];for(let[r,n]of this.properties.entries()){let s=r.split("").some(i=>!ht.isAllowedInUnquotedString(i));t.push((s?JSON.stringify(r):r)+":"+n.toString())}return"{"+t.join(",")+"}"}toPrettyString(t=" ",r=0){if(this.size===0)return"{}";let n=t.repeat(r),s=t.repeat(r+1),i=[];for(let[o,a]of this.properties.entries()){let l=o.split("").some(c=>!ht.isAllowedInUnquotedString(c));i.push((l?JSON.stringify(o):o)+": "+a.toPrettyString(t,r+1))}return`{ +`+n+"]"}toSimplifiedJson(){return this.map(t=>t.toSimplifiedJson())}toJson(){return{type:this.type,items:this.items.map(t=>t.toJson())}}toBytes(t){this.items.length===0?this.type=C.End:this.type=this.items[0].getId(),t.writeByte(this.type),t.writeInt(this.items.length);for(let r of this.items)r.toBytes(t)}static create(){return new e}static fromJson(t){let r=M.readObject(t)??{},n=M.readNumber(r.type)??C.Compound,s=(M.readArray(r.items)??[]).flatMap(i=>i!==void 0?[ne.fromJson(i,n)]:[]);return new e(s,n)}static fromBytes(t){let r=t.readByte(),n=t.readInt();if(r===C.End&&n>0)throw new Error(`Missing type on ListTag but length is ${n}`);let s=[];for(let i=0;itypeof r=="number"?r:0):[0,0])}static fromBytes(t){let r=t.readInt(),n=t.readInt();return new e([r,n])}};ne.register(C.Long,Er);var Ar=class e extends Ot{constructor(t){super(Array.from(t??[],r=>typeof r=="bigint"||Array.isArray(r)?new Er(r):r))}getId(){return C.LongArray}equals(t){return t.isLongArray()&&this.length===t.length&&this.items.every((r,n)=>r.equals(t.items[n]))}getType(){return C.Long}get length(){return this.items.length}toString(){return"[I;"+this.items.map(r=>r.toString()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsPair())}toJson(){return this.items.map(t=>t.getAsPair())}toBytes(t){t.writeInt(this.items.length);for(let r of this.items){let[n,s]=r.getAsPair();t.writeInt(n),t.writeInt(s)}}static create(){return new e}static fromJson(t){let r=M.readArray(t,n=>M.readPair(n,s=>M.readNumber(s)??0)??[0,0])??[];return new e(r)}static fromBytes(t){let r=t.readInt(),n=[];for(let s=0;s{let s=t.properties.get(r);return s!==void 0&&n.equals(s)})}has(t){return this.properties.has(t)}hasNumber(t){return this.get(t)?.isNumber()??!1}hasString(t){return this.get(t)?.isString()??!1}hasList(t,r,n){let s=this.get(t);return(s?.isList()&&(r===void 0||s.getType()===r)&&(n===void 0||s.length===n))??!1}hasCompound(t){return this.get(t)?.isCompound()??!1}get(t){return this.properties.get(t)}getString(t){return this.get(t)?.getAsString()??""}getNumber(t){return this.get(t)?.getAsNumber()??0}getBoolean(t){return this.getNumber(t)!==0}getList(t,r){let n=this.get(t);return n?.isList()&&(r===void 0||n.getType()===r)?n:Bt.create()}getCompound(t){let r=this.get(t);return r?.isCompound()?r:e.create()}getByteArray(t){let r=this.get(t);return r?.isByteArray()?r:kr.create()}getIntArray(t){let r=this.get(t);return r?.isIntArray()?r:Ir.create()}getLongArray(t){let r=this.get(t);return r?.isLongArray()?r:Ar.create()}keys(){return this.properties.keys()}get size(){return this.properties.size}map(t){return Object.fromEntries([...this.properties.entries()].map(([r,n])=>t(r,n,this)))}forEach(t){[...this.properties.entries()].forEach(([r,n])=>t(r,n,this))}set(t,r){return this.properties.set(t,r),this}delete(t){return this.properties.delete(t)}clear(){return this.properties.clear(),this}toString(){let t=[];for(let[r,n]of this.properties.entries()){let s=r.split("").some(i=>!ht.isAllowedInUnquotedString(i));t.push((s?JSON.stringify(r):r)+":"+n.toString())}return"{"+t.join(",")+"}"}toPrettyString(t=" ",r=0){if(this.size===0)return"{}";let n=t.repeat(r),s=t.repeat(r+1),i=[];for(let[o,a]of this.properties.entries()){let l=o.split("").some(c=>!ht.isAllowedInUnquotedString(c));i.push((l?JSON.stringify(o):o)+": "+a.toPrettyString(t,r+1))}return`{ `+i.map(o=>s+o).join(`, `)+` -`+n+"}"}toSimplifiedJson(){return this.map((t,r)=>[t,r.toSimplifiedJson()])}toJson(){return this.map((t,r)=>[t,{type:r.getId(),value:r.toJson()}])}toBytes(t){for(let[r,n]of this.properties.entries()){let s=n.getId();t.writeByte(s),t.writeString(r),n.toBytes(t)}t.writeByte(C.End)}static create(){return new e}static fromString(t){return Rr.readTag(t)}static fromJson(t){let r=M.readMap(t,n=>{let{type:s,value:i}=M.readObject(n)??{},o=M.readNumber(s);return ne.fromJson(i??{},o)});return new e(new Map(Object.entries(r)))}static fromBytes(t){let r=new Map;for(;;){let n=t.readByte();if(n===C.End)break;let s=t.readString(),i=ne.fromBytes(t,n);r.set(s,i)}return new e(r)}};ne.register(C.Compound,Re);var ar=class e{name;root;compression;littleEndian;bedrockHeader;static DEFAULT_NAME="";static DEFAULT_BEDROCK_HEADER=4;constructor(t,r,n,s,i){this.name=t,this.root=r,this.compression=n,this.littleEndian=s,this.bedrockHeader=i}writeNamedTag(t){t.writeByte(C.Compound),t.writeString(this.name),this.root.toBytes(t)}write(){let t=this.littleEndian===!0||this.bedrockHeader!==void 0,r=new wi({littleEndian:t,offset:this.bedrockHeader&&8});if(this.writeNamedTag(r),this.bedrockHeader!==void 0){let s=r.offset;r.offset=0,r.writeInt(this.bedrockHeader),r.writeInt(s-8),r.offset=s}let n=r.getData();return this.compression==="gzip"?Ri.gzip(n):this.compression==="zlib"?Ri.deflate(n):n}static readNamedTag(t){if(t.readByte()!==C.Compound)throw new Error("Top tag should be a compound");return{name:t.readString(),root:Re.fromBytes(t)}}static create(t={}){let r=t.name??e.DEFAULT_NAME,n=Re.create(),s=t.compression??"none",i=typeof t.bedrockHeader=="boolean"?e.DEFAULT_BEDROCK_HEADER:t.bedrockHeader,o=t.littleEndian??t.bedrockHeader!==void 0;return new e(r,n,s,o,i)}static read(t,r={}){let n=typeof r.bedrockHeader=="number"?r.bedrockHeader:r.bedrockHeader?ha(t):void 0,s=r.compression==="gzip"||!n&&r.compression===void 0&&ua(t),i=r.compression==="zlib"||!n&&r.compression===void 0&&fa(t),o=i||s?Ri.inflate(t):t,a=r.littleEndian||n!==void 0,l=s?"gzip":i?"zlib":"none",c=new gi(o,{littleEndian:a,offset:n&&8}),{name:u,root:h}=e.readNamedTag(c);return new e(r.name??u,h,l,a,n)}toJson(){return{name:this.name,root:this.root.toJson(),compression:this.compression,littleEndian:this.littleEndian,bedrockHeader:this.bedrockHeader??null}}static fromJson(t){let r=M.readObject(t)??{},n=M.readString(r.name)??"",s=Re.fromJson(r.root??{}),i=M.readString(r.compression)??"none",o=M.readBoolean(r.littleEndian)??!1,a=M.readNumber(r.bedrockHeader);return new e(n,s,i,o,a)}};var cr=class e{x;z;compression;timestamp;raw;file;dirty;constructor(t,r,n,s,i){this.x=t,this.z=r,this.compression=n,this.timestamp=s,this.raw=i,this.dirty=!1}getCompression(){switch(this.compression){case 1:return"gzip";case 2:return"zlib";case 3:return"none";default:throw new Error(`Invalid compression mode ${this.compression}`)}}setCompression(t){switch(t){case"gzip":this.compression=1;break;case"zlib":this.compression=2;break;case"none":this.compression=3;break;default:throw new Error(`Invalid compression mode ${t}`)}}getFile(){return this.file===void 0&&(this.file=ar.read(this.raw,{compression:this.getCompression()})),this.file}getRoot(){return this.getFile().root}setRoot(t){this.file===void 0&&(this.file=ar.create({compression:this.getCompression()})),this.file.root=t,this.markDirty()}markDirty(){this.dirty=!0}getRaw(){if(this.file===void 0||this.dirty===!1)return this.raw;this.file.compression=this.getCompression();let t=this.file.write();return this.raw=t,this.dirty=!1,t}toJson(){return{x:this.x,z:this.z,compression:this.compression,timestamp:this.timestamp,size:this.raw.byteLength}}toRef(t){return new e.Ref(this.x,this.z,this.compression,this.timestamp,this.raw.byteLength,t)}static create(t,r,n,s){let i=new e(t,r,0,s??0,n.write());return i.setCompression(n.compression),i}static fromJson(t,r){let n=M.readObject(t)??{},s=M.readInt(n.x)??0,i=M.readInt(n.z)??0,o=M.readNumber(n.compression)??2,a=M.readInt(n.timestamp)??0,l=M.readInt(n.size)??0;return new e.Ref(s,i,o,a,l,r)}};(function(e){class t{x;z;compression;timestamp;size;resolver;file;constructor(n,s,i,o,a,l){this.x=n,this.z=s,this.compression=i,this.timestamp=o,this.size=a,this.resolver=l}getFile(){if(this.file instanceof ar)return this.file}getRoot(){if(this.file instanceof ar)return this.file.root}async getFileAsync(){return this.file?this.file:(this.file=(async()=>{let n=await this.resolver(this.x,this.z);return this.file=n,n})(),this.file)}async getRootAsync(){return(await this.getFileAsync()).root}isResolved(){return this.file instanceof ar}}e.Ref=t})(cr=cr||(cr={}));var Ti=class{chunks;constructor(t){this.chunks=Array(1024).fill(void 0);for(let r of t){let n=zr.getIndex(r.x,r.z);this.chunks[n]=r}}getChunkPositions(){return this.chunks.flatMap(t=>t?[[t.x,t.z]]:[])}getChunk(t){if(!(t<0||t>=1024))return this.chunks[t]}findChunk(t,r){return this.getChunk(zr.getIndex(t,r))}getFirstChunk(){return this.chunks.filter(t=>t!==void 0)[0]}filter(t){return this.chunks.filter(r=>r!==void 0&&t(r))}map(t){return this.chunks.flatMap(r=>r!==void 0?[t(r)]:[])}},zr=class e extends Ti{constructor(t){super(t)}write(){let t=0;for(let i of this.chunks)i!==void 0&&(t+=Math.ceil(i.getRaw().length/4096));let r=new Uint8Array(8192+t*4096),n=new DataView(r.buffer),s=2;for(let i of this.chunks){if(i===void 0)continue;let o=i.getRaw(),a=4*((i.x&31)+(i.z&31)*32),l=Math.ceil(o.length/4096);n.setInt8(a,s>>16),n.setInt16(a+1,s&65535),n.setInt8(a+3,l),n.setInt32(a+4096,i.timestamp);let c=s*4096;n.setInt32(c,o.length+1),n.setInt8(c+4,i.compression),r.set(o,c+5),s+=l}return r}static read(t){let r=[];for(let n=0;n<32;n+=1)for(let s=0;s<32;s+=1){let i=4*((n&31)+(s&31)*32);if(t[i+3]===0)continue;let a=(t[i]<<16)+(t[i+1]<<8)+t[i+2],l=(t[i+4096]<<24)+(t[i+4097]<<16)+(t[i+4098]<<8)+t[i+4099],c=a*4096,u=(t[c]<<24)+(t[c+1]<<16)+(t[c+2]<<8)+t[c+3],h=t[c+4],d=t.slice(c+5,c+4+u);r.push(new cr(n,s,h,l,d))}return new e(r)}static getIndex(t,r){return(t&31)+(r&31)*32}toJson(){return{chunks:this.map(t=>t.toJson())}}static fromJson(t,r){let n=M.readObject(t)??{},i=(M.readArray(n.chunks)??[]).flatMap(o=>o!==void 0?[cr.fromJson(o,r)]:[]);return new e.Ref(i)}};(function(e){class t extends Ti{}e.Ref=t})(zr=zr||(zr={}));var Tr=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Double}equals(t){return t.isDouble()&&this.value===t.value}getAsNumber(){return this.value}toString(){return Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeDouble(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readNumber(t)??0)}static fromBytes(t){let r=t.readDouble();return new e(r)}};ne.register(C.Double,Tr);var Hs=class e extends ne{static INSTANCE=new e;constructor(){super()}getId(){return C.End}equals(t){return t.isEnd()}toString(){return"END"}toPrettyString(){return this.toString()}toSimplifiedJson(){return null}toJson(){return null}toBytes(){}static create(){return e.INSTANCE}static fromJson(){return e.INSTANCE}static fromBytes(){return e.INSTANCE}};ne.register(C.End,Hs);var ze;(function(e){e.UP="up",e.DOWN="down",e.NORTH="north",e.EAST="east",e.SOUTH="south",e.WEST="west"})(ze=ze||(ze={}));var em={[ze.UP]:[0,1,0],[ze.DOWN]:[0,-1,0],[ze.NORTH]:[0,0,-1],[ze.EAST]:[1,0,0],[ze.SOUTH]:[0,0,1],[ze.WEST]:[-1,0,0]};(function(e){e.ALL=[e.UP,e.DOWN,e.NORTH,e.EAST,e.SOUTH,e.WEST];function t(r){return em[r]}e.normal=t})(ze=ze||(ze={}));var te;(function(e){function t(h,d,f){return[h,d,f]}e.create=t,e.ZERO=e.create(0,0,0);function r(h,d,f,m){return[h[0]+d,h[1]+f,h[2]+m]}e.offset=r;function n(h,d){return[h[0]-d[0],h[1]-d[1],h[2]-d[2]]}e.subtract=n;function s(h,d){return[h[0]+d[0],h[1]+d[1],h[2]+d[2]]}e.add=s;function i(h,d){return e.offset(h,...ze.normal(d))}e.towards=i;function o(h,d){return h===d?!0:h[0]===d[0]&&h[1]===d[1]&&h[2]===d[2]}e.equals=o;function a(h){return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]}e.magnitude=a;function l(h){return new Ot(h.map(d=>new pt(d)))}e.toNbt=l;function c(h){return h.getAsTuple(3,d=>d?.isInt()?d.getAsNumber():0)}e.fromNbt=c;function u(h){let d=M.readArray(h,f=>M.readInt(f)??0)??[0,0,0];return t(d[0],d[1],d[2])}e.fromJson=u})(te=te||(te={}));var R=class e{namespace;path;static DEFAULT_NAMESPACE="minecraft";static SEPARATOR=":";constructor(t,r){this.namespace=t,this.path=r}is(t){return this.equals(e.parse(t))}equals(t){return this===t?!0:t instanceof e?this.namespace===t.namespace&&this.path===t.path:!1}toString(){return this.namespace+e.SEPARATOR+this.path}withPrefix(t){return new e(this.namespace,t+this.path)}static create(t){return new e(this.DEFAULT_NAMESPACE,t)}static parse(t){let r=t.indexOf(this.SEPARATOR);if(r>=0){let n=r>=1?t.substring(0,r):this.DEFAULT_NAMESPACE,s=t.substring(r+1);return new e(n,s)}return new e(this.DEFAULT_NAMESPACE,t)}};var se=class e{properties;static AIR=new e(R.create("air"));static STONE=new e(R.create("stone"));static WATER=new e(R.create("water"),{level:"0"});static LAVA=new e(R.create("lava"),{level:"0"});name;constructor(t,r={}){this.properties=r,this.name=typeof t=="string"?R.parse(t):t}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isFluid(){return this.is(e.WATER)||this.is(e.LAVA)}isWaterlogged(){return this.is(e.WATER)||this.is(e.LAVA)||this.is("bubble_column")||this.is("kelp")||this.is("kelp_plant")||this.is("seagrass")||this.is("tall_seagrass")||this.properties.waterlogged==="true"}equals(t){return!this.name.equals(t.name)||Object.keys(this.properties).length!==Object.keys(t.properties).length?!1:Object.keys(this.properties).every(r=>t.properties[r]===this.properties[r])}is(t){return typeof t=="string"?this.name.equals(R.parse(t)):t instanceof R?this.name.equals(t):this.name.equals(t.name)}toString(){return Object.keys(this.properties).length===0?this.name.toString():`${this.name.toString()}[${Object.entries(this.properties).map(([t,r])=>t+"="+r).join(",")}]`}static parse(t){let r=t.indexOf("[");if(r===-1)return new e(t);{let n=t.substring(0,r),s=t.substring(r+1,t.length-1).split(","),i=Object.fromEntries(s.map(o=>o.split("=")));return new e(n,i)}}static fromNbt(t){if(t.isString())return new e(t.getAsString());let r=t.isCompound()?t:new Re,n=R.parse(r.hasString("id")?r.getString("id"):r.getString("Name")),s=(r.hasCompound("properties")?r.getCompound("properties"):r.getCompound("Properties")).map((i,o)=>[i,o.getAsString()]);return new e(n,s)}static fromJson(t){if(typeof t=="string")return new e(t);let r=M.readObject(t)??{},n=R.parse(M.readString(r.id??r.Name)??""),s=M.readMap(r.properties??r.Properties,i=>M.readString(i)??"");return new e(n,s)}};var zi=class{size;defaultValue;storage;palette;constructor(t,r){this.size=t,this.defaultValue=r,this.storage=Array(t).fill(0),this.palette=[r]}index(t,r,n){return(t<<8)+(r<<4)+n}get(t,r,n){let s=this.storage[this.index(t,r,n)];return this.palette[s]}set(t,r,n,s){let i=this.palette.findIndex(o=>o.equals(s));i===-1&&(i=this.palette.length,this.palette.push(s)),this.storage[this.index(t,r,n)]=i}};var Pi=class e{minY;static WIDTH=16;static SIZE=e.WIDTH*e.WIDTH*e.WIDTH;states;constructor(t){this.minY=t,this.states=new zi(e.SIZE,se.AIR)}get minBlockY(){return this.minY<<4}getBlockState(t,r,n){return this.states.get(t,r,n)}setBlockState(t,r,n,s){this.states.set(t,r,n,s)}};var qn=class{minY;height;pos;sections;constructor(t,r,n){this.minY=t,this.height=r,this.pos=n,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return(this.maxY-1>>4)+1}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(t){return(t>>4)-this.minSection}getBlockState(t){let[r,n,s]=t;return this.sections[this.getSectionIndex(n)]?.getBlockState(r&15,n&15,s&15)??se.AIR}setBlockState(t,r){let[n,s,i]=t,o=this.getSectionIndex(s),a=this.sections[o];if(a===null){if(r.equals(se.AIR))return;a=this.getOrCreateSection(o)}a.setBlockState(n&15,s&15,i&15,r)}getOrCreateSection(t){return this.sections[t]==null&&(this.sections[t]=new Pi(this.minSection+t)),this.sections[t]}};var Je;(function(e){function t(u,h){return[u,h]}e.create=t;function r(u){return[u[0]>>4,u[2]>>4]}e.fromBlockPos=r;function n(u){return[Number(u)&4294967295,Number(u>>BigInt(32))]}e.fromLong=n;function s(u){return i(u[0],u[1])}e.toLong=s;function i(u,h){return BigInt(u&4294967295)|BigInt(h&4294967295)<typeof o=="string"?n(s,R.parse(o)):r(i(o))}e.parser=t;function r(s,i){return{value:()=>s,key:()=>i}}e.direct=r;function n(s,i,o=!0){return o?{value:()=>s.getOrThrow(i),key:()=>i}:{value:()=>s.get(i),key:()=>i}}e.reference=n})(he=he||(he={}));var Bt=class e{entries;constructor(t){this.entries=t}static parser(t,r){let n=r??(s=>he.reference(t,R.parse(M.readString(s)??"")));return s=>typeof s=="string"?s.startsWith("#")?he.reference(t.getTagRegistry(),R.parse(s.substring(1))):he.direct(new e([he.reference(t,R.parse(s))])):he.direct(new e(M.readArray(s,n)??[])??[])}static fromJson(t,r,n){let s=M.readObject(r)??{},i=M.readBoolean(s.replace)??!1,o=M.readArray(s.values,a=>{var l=!0,c="";if(typeof a=="string")c=a;else{let u=M.readObject(a)??{};l=M.readBoolean(u.required)??!1,c=M.readString(u.id)??""}return c.startsWith("#")?he.reference(t.getTagRegistry(),R.parse(c.substring(1)),l):he.reference(t,R.parse(c),l)})??[];return n&&!i&&t.getTagRegistry().has(n)&&o?.push(he.direct(t.getTagRegistry().get(n))),new e(o)}*getEntries(){for(let t of this.entries){let r=t.value();r!==void 0&&(r instanceof e?yield*r.getEntries():yield t)}}};var Yn=class e{id;count;components;constructor(t,r,n=new Map){this.id=t,this.count=r,this.components=n}getComponent(t,r){if(typeof t=="string"&&(t=R.parse(t)),this.components.has("!"+t.toString()))return;let n=this.components.get(t.toString());if(n)return n;if(r)return r.getItemComponents(this.id)?.get(t.toString())}hasComponent(t,r){return typeof t=="string"&&(t=R.parse(t)),this.components.has("!"+t.toString())?!1:this.components.has(t.toString())?!0:r?r.getItemComponents(this.id)?.has(t.toString()):!1}clone(){let t=new Map(this.components);return new e(this.id,this.count,t)}is(t){return typeof t=="string"?this.id.equals(R.parse(t)):t instanceof R?this.id.equals(t):this.id.equals(t.id)}equals(t){return this===t?!0:t instanceof e?this.count===t.count&&this.isSameItemSameComponents(t):!1}isSameItemSameComponents(t){if(!this.id.equals(t.id)||this.components.size!==t.components.size)return!1;for(let[r,n]of this.components){let s=t.components.get(r);if(n.toString()!==s?.toString())return!1}return!0}toString(){let t=this.id.toString();return this.components.size>0&&(t+=`[${[...this.components.entries()].map(([r,n])=>r.startsWith("!")?r:`${r}=${n.toString()}`).join(",")}]`),this.count>1&&(t+=` ${this.count}`),t}static fromString(t){let r=new ht(t);for(;r.canRead()&&r.peek()!=="[";)r.skip();let n=R.parse(r.getRead());if(!r.canRead())return new e(n,1);let s=new Map;if(r.skip(),r.peek()==="]")return new e(n,1,s);do{if(r.peek()==="!"){r.skip(),r.skipWhitespace();let i=r.cursor;for(;r.canRead()&&r.peek()!=="]"&&r.peek()!==",";)r.skip();s.set("!"+R.parse(r.getRead(i).trim()).toString(),new Re)}else{r.skipWhitespace();let i=r.cursor;for(;r.canRead()&&r.peek()!=="=";)r.skip();let o=R.parse(r.getRead(i).trim()).toString();if(!r.canRead())break;r.skip(),r.skipWhitespace();let a=Rr.readTag(r);s.set(o,a)}if(r.skipWhitespace(),!r.canRead())break;if(r.peek()==="]")return new e(n,1,s);if(r.peek()!==",")throw new Error("Expected , or ]");r.skip()}while(r.canRead());throw new Error("Missing closing ]")}toNbt(){let t=new Re().set("id",new Xe(this.id.toString()));return this.count>1&&t.set("count",new pt(this.count)),this.components.size>0&&t.set("components",new Re(this.components)),t}static fromNbt(t){let r=R.parse(t.getString("id")),n=t.hasNumber("count")?t.getNumber("count"):1,s=new Map(Object.entries(t.getCompound("components").map((i,o)=>i.startsWith("!")?["!"+R.parse(i).toString(),new Re]:[R.parse(i).toString(),o])));return new e(r,n,s)}};var $e=class e{key;parser;static REGISTRY=new e(R.create("root"));storage=new Map;builtin=new Map;tags=void 0;constructor(t,r){this.key=t,this.parser=r}static createAndRegister(t,r){let n=new e(R.create(t),r);return e.REGISTRY.register(n.key,n),n}register(t,r,n){return this.storage.set(t.toString(),r),n&&this.builtin.set(t.toString(),r),he.reference(this,t)}delete(t){let r=this.storage.delete(t.toString());return this.builtin.delete(t.toString()),r}keys(){return[...this.storage.keys()].map(t=>R.parse(t))}has(t){return this.storage.has(t.toString())}get(t){var r=this.storage.get(t.toString());return r instanceof Function&&(r=r(),this.storage.set(t.toString(),r)),r}getOrThrow(t){let r=this.get(t);if(r===void 0)throw new Error(`Missing key in ${this.key.toString()}: ${t.toString()}`);return r}parse(t){if(!this.parser)throw new Error(`No parser exists for ${this.key.toString()}`);return this.parser(t)}clear(){this.storage.clear();for(let[t,r]of this.builtin.entries())this.storage.set(t,r);return this.tags&&this.tags.clear(),this}assign(t){if(!this.key.equals(t.key))throw new Error(`Cannot assign registry of type ${t.key.toString()} to registry of type ${this.key.toString()}`);for(let r of t.keys())this.storage.set(r.toString(),t.getOrThrow(r));return this}cloneEmpty(){return new e(this.key,this.parser)}forEach(t){for(let[r,n]of this.storage.entries())t(R.parse(r),n instanceof Function?n():n,this)}map(t){return[...this.storage.entries()].map(([r,n])=>t(R.parse(r),n instanceof Function?n():n,this))}getTagRegistry(){return this.tags===void 0&&(this.tags=new e(new R(this.key.namespace,`tags/${this.key.path}`))),this.tags}};var He;(function(e){e.NONE="none",e.CLOCKWISE_90="clockwise_90",e.CLOCKWISE_180="180",e.COUNTERCLOCKWISE_90="counterclockwise_90"})(He=He||(He={}));(function(e){function t(r){return[e.NONE,e.CLOCKWISE_90,e.CLOCKWISE_180,e.COUNTERCLOCKWISE_90][r.nextInt(4)]}e.getRandom=t})(He=He||(He={}));var Pr=class e{size;palette;blocks;static REGISTRY=$e.createAndRegister("structures");static EMPTY=new e(te.ZERO);blocksMap=[];constructor(t,r=[],n=[]){this.size=t,this.palette=r,this.blocks=n,n.forEach(s=>{if(!this.isInside(s.pos))throw new Error(`Found block at ${s.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[s.pos[0]*t[1]*t[2]+s.pos[1]*t[2]+s.pos[2]]=s})}getSize(){return this.size}addBlock(t,r,n,s){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);let i=new se(r,n),o=this.palette.findIndex(a=>a.equals(i));return o===-1&&(o=this.palette.length,this.palette.push(i)),this.blocks.push({pos:t,state:o,nbt:s}),this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]]={pos:t,state:o,nbt:s},this}getBlocks(){return this.blocks.map(t=>this.toPlacedBlock(t))}getBlock(t){if(!this.isInside(t))return null;let r=this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]];return r?this.toPlacedBlock(r):null}toPlacedBlock(t){let r=this.palette[t.state];if(!r)throw new Error(`Block at ${t.pos.join(" ")} in structure references invalid palette index ${t.state}`);return{pos:t.pos,state:r,nbt:t.nbt}}isInside(t){return t[0]>=0&&t[0]=0&&t[1]=0&&t[2]se.fromNbt(i)),s=t.getList("blocks",C.Compound).map(i=>{let o=te.fromNbt(i.getList("pos")),a=i.getNumber("state"),l=i.getCompound("nbt");return{pos:o,state:a,nbt:l.size>0?l:void 0}});return new e(r,n,s)}static transform(t,r,n){switch(r){case He.COUNTERCLOCKWISE_90:return te.create(n[0]-n[2]+t[2],t[1],n[0]+n[2]-t[0]);case He.CLOCKWISE_90:return te.create(n[0]+n[2]-t[2],t[1],n[2]-n[0]+t[0]);case He.CLOCKWISE_180:return te.create(n[0]+n[0]-t[0],t[1],n[2]+n[2]-t[2]);default:return t}}};var J=class e{min;max;static NaI=new e(NaN,NaN);static INFINITE=new e(-1/0,1/0);constructor(t,r){this.min=t,this.max=r}static of(t,r){return rn||t.isNaI()?e.NaI:t.min>=n?e.ofExact(n):t.max<=r?e.ofExact(r):e.of(Math.max(t.min,r),Math.min(t.max,n))}static abs(t){if(t.isNaI())return e.NaI;let r=Math.max(Math.abs(t.min),Math.abs(t.max));if(t.contains(0))return e.of(0,r);{let n=Math.min(Math.abs(t.min),Math.abs(t.max));return e.of(n,r)}}static square(t){if(t.isNaI())return e.NaI;let r=Math.max(t.min*t.min,t.max*t.max);if(t.contains(0))return e.of(0,r);{let n=Math.min(t.min*t.min,t.max*t.max);return e.of(n,r)}}static pow(t,r){if(t.isNaI()||r.isNaI())return e.NaI;if(t.min==t.max)return e.powNum(t.min,r);let n=e.encapsulating(e.powNum(t.min,r),e.powNum(t.max,r));return t.contains(0)&&(t.max>0&&(n=e.encapsulating(n,e.powNum(0,r))),t.min<0&&(n=e.encapsulating(n,e.powNum(-0,r)))),n}static powNum(t,r){return e.INFINITE}static log(t){if(t.max<0)return e.NaI;let r=e.max(t,e.ofExact(0));return e.mapMonotonic(r,Math.log)}static mapMonotonic(t,r){if(t.isNaI())return e.NaI;let n=r(t.min),s=r(t.max);return e.of(Math.min(n,s),Math.max(n,s))}static lerp(t,r,n){return t.isNaI()||r.isNaI()||n.isNaI()?e.NaI:e.encapsulating(e.lerpNums(t,r.min,n.min),e.lerpNums(t,r.max,n.min),e.lerpNums(t,r.min,n.max),e.lerpNums(t,r.max,n.max))}static lerpNums(t,r,n){if(t.isNaI()||isNaN(r)||isNaN(n))return e.NaI;if(isFinite(r)&&isFinite(n))return e.between(e.lerpFiniteBound(t.min,r,n),e.lerpFiniteBound(t.max,r,n));if(r===n)return e.ofExact(r);let s=e.lerpInfiniteBound(t.min,r,n),i=e.lerpInfiniteBound(t.max,r,n);return isNaN(s)||isNaN(i)?e.NaI:e.between(s,i)}static lerpFiniteBound(t,r,n){return r+e.mulBound(t,n-r)}static lerpInfiniteBound(t,r,n){let s=e.mulBound(1-t,r),i=e.mulBound(t,n);return isFinite(s)||isFinite(i)?s+i:t<=0?n>r?-1/0:1/0:t>=1?n>r?1/0:-1/0:NaN}static sign(t){return t.isNaI()?e.NaI:t.min===t.max?e.ofExact(Math.sign(t.min)):t.contains(0)?t.min===0?e.of(0,1):t.max===0?e.of(-1,0):e.of(-1,1):e.ofExact(t.min>0?1:-1)}contains(t){return this.min<=t&&t<=this.max}intersects(t){return this.min<=t.max&&t.min<=this.max}isNaI(){return this===e.NaI}};var nm=9223372036854776e3;function vt(e){return e*e}function Fe(e,t,r){return Math.max(t,Math.min(r,e))}function nn(e,t,r){return t+e*(r-t)}function Or(e,t,r){return Math.fround(t+Math.fround(e*Math.fround(r-t)))}function Lc(e,t,r,n,s,i){return nn(t,nn(e,r,n),nn(e,s,i))}function Fc(e,t,r,n,s,i,o,a,l,c,u){return nn(r,Lc(e,t,n,s,i,o),Lc(e,t,a,l,c,u))}function Bi(e,t,r){return e===0?t():e===1?r():t()+e*(r()-t())}function Cc(e,t,r,n,s,i){return Bi(t,()=>Bi(e,r,n),()=>Bi(e,s,i))}function $c(e,t,r,n,s,i,o,a,l,c,u){return Bi(r,()=>Cc(e,t,n,s,i,o),()=>Cc(e,t,a,l,c,u))}function Xs(e,t,r){return e<0?t:e>1?r:nn(e,t,r)}function Dc(e,t,r){return(e-t)/(r-t)}function Li(e){return e*e*e*(e*(e*6-15)+10)}function sn(e,t,r,n,s){return nn(Dc(e,t,r),n,s)}function qc(e,t,r,n,s){return Xs(Dc(e,t,r),n,s)}function Ue(e){return Fe(Math.floor(e),-2147483648,2147483647)}function Yc(e){return Fe(Math.floor(e),-9223372036854776e3,nm)}function Jc(e,t){return Ue(e/t)*t}function Uc(e,t,r){let n=t-e;for(;n>0;){let s=Math.floor(n/2),i=e+s;if(r(i)){n=s;continue}e=i+1,n-=s+1}return e}function Ci(e,t,r){let n=BigInt.asIntN(64,BigInt(e)*BigInt(3129871)^BigInt(r)*BigInt(116129781)^BigInt(t));return n=BigInt.asIntN(64,BigInt.asIntN(64,n*n*BigInt(42317861))+BigInt.asIntN(64,n*BigInt(11))),n>>BigInt(16)}function Ws(e,t,r,n,s,i,o,a){return BigInt(e)<=r?t:e.nextInt(r-t+1)+t}function jc(e,t){for(var r=e.length;r>1;r--){let n=t.nextInt(r),s=e[n];e[n]=e[r-1],e[r-1]=s}}function Gc(e){for(var t=0,r=0;tM.readObject(c)??{})??[];if(l.length===0)return new r(0);for(let c of l){let u=M.readNumber(c.location)??0,h=t(c.value,i),d=M.readNumber(c.derivative)??0;a.addPoint(u,h,d)}return a}e.fromJson=t;class r{value;constructor(i){this.value=i}compute(){return this.value}range(){return J.of(this.value,this.value)}mapCoordinates(){return this}}e.Constant=r;class n{coordinate;locations;values;derivatives;constructor(i,o=[],a=[],l=[]){this.coordinate=i,this.locations=o,this.values=a,this.derivatives=l}compute(i){let o=this.coordinate.compute(i),a=Uc(0,this.locations.length,v=>oo.mapCoordinates(i)),this.derivatives)}addPoint(i,o,a=0){return this.locations.push(Math.fround(i)),this.values.push(typeof o=="number"?new e.Constant(Math.fround(o)):o),this.derivatives.push(Math.fround(a)),this}range(){let i=this.locations.length-1;var o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;let l=this.coordinate.range();if(l.isNaI())return l;if(l.minthis.locations[i]){let h=this.values[i].range(),d=n.linearExtend(h.max,this.locations,h.min,this.derivatives,i),f=n.linearExtend(h.max,this.locations,h.max,this.derivatives,i);o=Math.min(o,Math.min(d,f)),a=Math.max(a,Math.max(d,f))}let c=this.values.map(h=>h.range());for(let h of c)o=Math.min(o,h.min),a=Math.max(a,h.max);for(var u=0;u=0&&t=0;l-=1)a.push({noise:new Yi(t,n*o),frequency:o,amplitude:s}),o/=2,s*=2;return new Lr(a)}range(){return J.lerp(J.of(0,1),this.minLimitNoise.range(),this.maxLimitNoise.range())}sample(t,r,n){let s=t*this.xzMultiplier,i=r*this.yMultiplier,o=n*this.xzMultiplier,a=this.mainNoise.get3D(s/this.xzFactor,i/this.yFactor,o/this.xzFactor);return a=Fe(a+.5,0,1),a===0?this.minLimitNoise.get3D(s,i,o):a===1?this.maxLimitNoise.get3D(s,i,o):Or(a,this.minLimitNoise.get3D(s,i,o),this.maxLimitNoise.get3D(s,i,o))}};var t2=["disabled","enabled","legacy"],Cr=class e{baseAmplitude;baseOctave;octaveCount;normalize;amplitudeModifiers;static INPUT_FACTOR=1.0181268882175227;static TARGET_DEVIATION=.3333333333333333;octaves;normalizationFactor;range;constructor(t,r,n,s,i){this.baseAmplitude=t,this.baseOctave=r,this.octaveCount=n,this.normalize=s,this.amplitudeModifiers=i,this.octaves=e.buildOctaves(t,r,n,s!="disabled",i);let o=this.octaves.reduce((l,c)=>l+Math.abs(c.amplitude),0),a=e.computeNormalizationFactor(o,this.octaves);if(s=="legacy"&&a!=0){let l=e.computeParityNormalizationFactor(t,n,i);o*=l/a,a=l}this.normalizationFactor=a,this.range=J.ofSymmetric(o*e.TARGET_DEVIATION*6)}create(t){let r=t.forkPositional(),n=t.forkPositional(),s=[];for(let i of this.octaves){let o=`octave_${i.index}`,a=new Wt(r.fromHashOf(o)),l=new Wt(n.fromHashOf(o)),c=this.normalizationFactor*i.amplitude;s.push({noise:a,frequency:i.frequency,amplitude:c}),s.push({noise:l,frequency:i.frequency*e.INPUT_FACTOR,amplitude:c})}return new Lr(s)}createForLegacyNetherBiome(t){let r=this.amplitudeModifiers;r.length===0&&(r=Array(this.octaveCount).fill(1));let n=e.createLegacyNoiseLayers(t,this.baseOctave,r),s=e.createLegacyNoiseLayers(t,this.baseOctave,r),i=this.normalizationFactor*this.baseAmplitude;return new Lr([...n.map(o=>({...o,amplitude:o.amplitude*i})),...s.map(o=>({...o,frequency:o.frequency*e.INPUT_FACTOR,amplitudes:o.amplitude*i}))])}static createLegacyNoiseLayers(t,r,n){let s=n.length,i=-r,o=Array(s).fill(void 0),a=new Wt(t);i>=0&&i=0;h-=1)hM.readNumber(s)??0)??[])}};var Ui=class e extends Te{static RANGE=J.ofSymmetric(2);static STANDARD_DEVIATION=.42544;static F2=.5*(Math.sqrt(3)-1);static G2=(3-Math.sqrt(3))/6;constructor(t,r){super(t,r?0:void 0)}range(){return e.RANGE}get2D(t,r){let n=t+this.offsetX,s=r+this.offsetY,i=(n+s)*e.F2,o=Ue(n+i),a=Ue(s+i),l=(o+a)*e.G2,c=n-(o-l),u=s-(a-l),h,d;c>u?(h=1,d=0):(h=0,d=1);let f=c-h+e.G2,m=u-d+e.G2,p=c-1+2*e.G2,g=u-1+2*e.G2,w=o&255,x=a&255,v=this.permute(w+this.permute(x))%12,y=this.permute(w+h+this.permute(x+d))%12,I=this.permute(w+1+this.permute(x+1))%12,b=this.getCornerNoise3D(v,c,u,0,.5),k=this.getCornerNoise3D(y,f,m,0,.5),E=this.getCornerNoise3D(I,p,g,0,.5);return 70*(b+k+E)}get3D(t,r,n){let s=t+this.offsetX,i=r+this.offsetY,o=n+this.offsetZ,a=(s+i+o)*.3333333333333333,l=Ue(s+a),c=Ue(i+a),u=Ue(o+a),h=(l+c+u)*.16666666666666666,d=s-(l-h),f=i-(c-h),m=o-(u-h),p,g,w,x,v,y;d>=f?f>=m?(p=1,g=0,w=0,x=1,v=1,y=0):d>=m?(p=1,g=0,w=0,x=1,v=0,y=1):(p=0,g=0,w=1,x=1,v=0,y=1):f>BigInt(e.MODULUS_BITS-t));return r>2147483647?r-4294967296:r}nextInt(t){if(t===void 0)return this.next(32);if((t&t-1)==0)return Number(BigInt(t)*BigInt(this.next(31))>>BigInt(31));let r,n;for(;(r=this.next(31))-(n=r%t)+(t-1)<0;);return n}nextLong(){return(BigInt(this.next(32))<>e.BIGINT_30)*e.STAFFORD_1&e.MAX_ULONG,t=(t^t>>e.BIGINT_27)*e.STAFFORD_2&e.MAX_ULONG,(t^t>>e.BIGINT_31)&e.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=e.POW2_60);let r=t^e.SILVER_RATIO_64,n=r+e.GOLDEN_RATIO_64&e.MAX_ULONG;return[e.mixStafford13(r),e.mixStafford13(n)]}static rotateLeft(t,r){return t<>e.BIGINT_64-r}setSeed(t){this.seed=e.upgradeSeedTo128bit(t)}fork(){return new e([this.next(),this.next()])}forkPositional(){return new vo(this.next(),this.next())}next(){let t=this.seed[0],r=this.seed[1],n=e.rotateLeft(t+r&e.MAX_ULONG,e.BIGINT_17)+t&e.MAX_ULONG;return r^=t,this.seed=[e.rotateLeft(t,e.BIGINT_49)^r^r<e.POW2_63&&(t-=e.POW2_60),t}consume(t){let r=this.seed[0],n=this.seed[1];for(let s=0;s>BigInt(64-t)}nextInt(t){let r=this.next()&e.MAX_UINT;if(t){let n=BigInt(t),s=r*n,i=s&e.MAX_UINT;if(i>e.BIGINT_32;return Number(o)}else{let n=Number(r);return n>=2147483648&&(n-=4294967296),n}}nextFloat(){return Number(this.nextBits(24))*e.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*e.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}},vo=class{seedLo;seedHi;constructor(t,r){this.seedLo=t,this.seedHi=r}at(t,r,n){let i=Ci(t,r,n)^this.seedLo;return new on([i,this.seedHi])}fromHashOf(t){let r=(0,su.default)(t,{asBytes:!0}),n=Ws(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7]),s=Ws(r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15]);return new on([n^this.seedLo,s^this.seedHi])}seedKey(){return[this.seedLo,this.seedHi]}};var _t=[124/255,189/255,107/255],n2=re.intToRgb(6396257),i2=re.intToRgb(8431445),an=re.intToRgb(4764952),ji=re.intToRgb(4159204),s2=re.intToRgb(2129968),o2=e=>{let t=e/15,r=t*.6+(t>0?.4:.3),n=Fe(t*t*.7-.5,0,1),s=Fe(t*t*.6-.7,0,1);return[r,n,s]},Gi=e=>[e/8,1-e/32,e/64],yo={large_fern:()=>_t,tall_grass:()=>_t,grass_block:()=>_t,fern:()=>_t,grass:()=>_t,short_grass:()=>_t,potted_fern:()=>_t,pink_petals:()=>_t,wildflowers:()=>_t,bush:()=>_t,spruce_leaves:()=>n2,birch_leaves:()=>i2,oak_leaves:()=>an,jungle_leaves:()=>an,acacia_leaves:()=>an,dark_oak_leaves:()=>an,vine:()=>an,mangrove_leaves:()=>an,water:()=>ji,bubble_column:()=>ji,cauldron:()=>ji,water_cauldron:()=>ji,redstone_wire:e=>o2(parseInt(e.power??"0")),sugar_cane:()=>_t,attached_melon_stem:()=>Gi(7),attached_pumpkin_stem:()=>Gi(7),melon_stem:e=>Gi(parseInt(e.age??"0")),pumpkin_stem:e=>Gi(parseInt(e.age??"0")),lily_pad:()=>s2};var we;(function(e){function t(n,s,i){let{up:o,down:a,north:l,east:c,south:u,west:h}=n;switch(i){case 90:[l,c,u,h]=[c,u,h,l];break;case 180:[l,c,u,h]=[u,h,l,c];break;case 270:[l,c,u,h]=[h,l,c,u]}switch(s){case 90:[o,l,a,u]=[l,a,u,o];break;case 180:[o,l,a,u]=[a,u,o,l];break;case 270:[o,l,a,u]=[u,o,l,a]}return{up:o,down:a,north:l,east:c,south:u,west:h}}e.rotate=t;function r(){return Object.create(null)}e.none=r})(we=we||(we={}));var bo=mr(Br(),1);var ut=class e{pos;color;texture;textureLimit;normal;blockPos;static VEC=bo.vec3.create();constructor(t,r,n,s,i,o){this.pos=t,this.color=r,this.texture=n,this.textureLimit=s,this.normal=i,this.blockPos=o}transform(t){return e.VEC[0]=this.pos.x,e.VEC[1]=this.pos.y,e.VEC[2]=this.pos.z,bo.vec3.transformMat4(e.VEC,e.VEC,t),this.pos=new je(e.VEC[0],e.VEC[1],e.VEC[2]),this}static fromPos(t){return new e(t,[0,0,0],[0,0],[0,0,0,0],void 0,void 0)}};var Zi=class e{v1;v2;constructor(t,r){this.v1=t,this.v2=r}vertices(){return[this.v1,this.v2]}forEach(t){return t(this.v1),t(this.v2),this}transform(t){return this.forEach(r=>r.transform(t)),this}setColor(t){return this.forEach(r=>r.color=t),this}toString(){return`Line(${this.v1.pos.toString()}, ${this.v2.pos.toString()})`}static fromPoints(t,r){return new e(ut.fromPos(t),ut.fromPos(r))}};var _e=class{quads;lines;posBuffer;colorBuffer;textureBuffer;textureLimitBuffer;normalBuffer;blockPosBuffer;indexBuffer;linePosBuffer;lineColorBuffer;constructor(t=[],r=[]){this.quads=t,this.lines=r}clear(){return this.quads=[],this.lines=[],this}isEmpty(){return this.quads.length===0&&this.lines.length===0}quadVertices(){return this.quads.length*4}quadIndices(){return this.quads.length*6}lineVertices(){return this.lines.length*2}merge(t){return this.quads=this.quads.concat(t.quads),this.lines=this.lines.concat(t.lines),this}addLine(t,r,n,s,i,o,a){let l=new Zi(ut.fromPos(new je(t,r,n)),ut.fromPos(new je(s,i,o))).setColor(a);return this.lines.push(l),this}addLineCube(t,r,n,s,i,o,a){return this.addLine(t,r,n,t,r,o,a),this.addLine(s,r,n,s,r,o,a),this.addLine(t,r,n,s,r,n,a),this.addLine(t,r,o,s,r,o,a),this.addLine(t,r,n,t,i,n,a),this.addLine(s,r,n,s,i,n,a),this.addLine(t,r,o,t,i,o,a),this.addLine(s,r,o,s,i,o,a),this.addLine(t,i,n,t,i,o,a),this.addLine(s,i,n,s,i,o,a),this.addLine(t,i,n,s,i,n,a),this.addLine(t,i,o,s,i,o,a),this}transform(t){for(let r of this.quads)r.transform(t);return this}computeNormals(){for(let t of this.quads){let r=t.normal();t.forEach(n=>n.normal=r)}}rebuild(t,r){let n=(i,o,a)=>{if(i||(i=t.createBuffer()??void 0),!i)throw new Error("Cannot create new buffer");return t.bindBuffer(o,i),t.bufferData(o,a,t.DYNAMIC_DRAW),i},s=(i,o,a)=>{if(i.length===0){o&&t.deleteBuffer(o);return}let l=i.flatMap(c=>c.vertices().flatMap(u=>{let h=a(u);if(!h)throw new Error("Missing vertex component");return h}));return n(o,t.ARRAY_BUFFER,new Float32Array(l))};return r.pos&&(this.posBuffer=s(this.quads,this.posBuffer,i=>i.pos.components()),this.linePosBuffer=s(this.lines,this.linePosBuffer,i=>i.pos.components())),r.color&&(this.colorBuffer=s(this.quads,this.colorBuffer,i=>i.color),this.lineColorBuffer=s(this.lines,this.lineColorBuffer,i=>i.color)),r.texture&&(this.textureBuffer=s(this.quads,this.textureBuffer,i=>i.texture),this.textureLimitBuffer=s(this.quads,this.textureLimitBuffer,i=>i.textureLimit)),r.normal&&(this.normalBuffer=s(this.quads,this.normalBuffer,i=>i.normal?.components())),r.blockPos&&(this.blockPosBuffer=s(this.quads,this.blockPosBuffer,i=>i.blockPos?.components())),this.quads.length===0?(this.indexBuffer&&t.deleteBuffer(this.indexBuffer),this.indexBuffer=void 0):this.indexBuffer=n(this.indexBuffer,t.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.quads.flatMap((i,o)=>[4*o,4*o+1,4*o+2,o*4,4*o+2,4*o+3],!0))),this}};var De=mr(Br(),1);var jn=class e{v1;v2;v3;v4;constructor(t,r,n,s){this.v1=t,this.v2=r,this.v3=n,this.v4=s}vertices(){return[this.v1,this.v2,this.v3,this.v4]}forEach(t){return t(this.v1),t(this.v2),t(this.v3),t(this.v4),this}transform(t){return this.forEach(r=>r.transform(t)),this}normal(){let t=this.v2.pos.sub(this.v1.pos),r=this.v3.pos.sub(this.v1.pos);return t.cross(r).normalize()}reverse(){return[this.v1,this.v2,this.v3,this.v4]=[this.v4,this.v3,this.v2,this.v1],this}setColor(t){return this.forEach(r=>r.color=t),this}setTexture(t,r){return this.v1.textureLimit=r,this.v2.textureLimit=r,this.v3.textureLimit=r,this.v4.textureLimit=r,this.v1.texture=[t[0],t[1]],this.v2.texture=[t[2],t[3]],this.v3.texture=[t[4],t[5]],this.v4.texture=[t[6],t[7]],this}toString(){return`Quad(${this.v1.pos.toString()}, ${this.v2.pos.toString()}, ${this.v3.pos.toString()}, ${this.v4.pos.toString()})`}static fromPoints(t,r,n,s){return new e(ut.fromPos(t),ut.fromPos(r),ut.fromPos(n),ut.fromPos(s))}};var a2={0:[0,3,2,3,2,1,0,1],90:[2,3,2,1,0,1,0,3],180:[2,1,0,1,0,3,2,3],270:[0,1,0,3,2,3,2,1]},c2={x:[1,0,0],y:[0,1,0],z:[0,0,1]},cn=1.41421356237,l2={x:[1,cn,cn],y:[cn,1,cn],z:[cn,cn,1]},Me=class e{parent;textures;elements;display;guiLight;static BUILTIN_GENERATED=R.create("builtin/generated");static GENERATED_LAYERS=["layer0","layer1","layer2","layer3","layer4"];generationMarker=!1;constructor(t,r,n,s,i){this.parent=t,this.textures=r,this.elements=n,this.display=s,this.guiLight=i}getDisplayTransform(t){let r=this.display?.[t],n=De.mat4.create();return De.mat4.translate(n,n,[8,8,8]),r?.translation&&De.mat4.translate(n,n,r.translation),r?.rotation&&(De.mat4.rotateX(n,n,r.rotation[0]*Math.PI/180),De.mat4.rotateY(n,n,r.rotation[1]*Math.PI/180),De.mat4.rotateZ(n,n,-r.rotation[2]*Math.PI/180)),r?.scale&&De.mat4.scale(n,n,r.scale),De.mat4.translate(n,n,[-8,-8,-8]),n}getMesh(t,r,n){let s=new _e,i=o=>n===void 0?[1,1,1]:o===void 0||o<0?[1,1,1]:typeof n=="function"?n(o):n;for(let o of this.elements??[])s.merge(this.getElementMesh(o,t,r,i));return s}getElementMesh(t,r,n,s){let i=new _e,[o,a,l]=t.from,[c,u,h]=t.to,d=(m,p,g)=>{let w=jn.fromPoints(new je(g[0],g[1],g[2]),new je(g[3],g[4],g[5]),new je(g[6],g[7],g[8]),new je(g[9],g[10],g[11])),x=s(m.tintindex);w.setColor(x);let[v,y,I,b]=r.getTextureUV(this.getTexture(m.texture)),k=(I-v)/16,E=(b-y)/16;p[0]=(m.uv?.[0]??p[0])*k,p[1]=(m.uv?.[1]??p[1])*E,p[2]=(m.uv?.[2]??p[2])*k,p[3]=(m.uv?.[3]??p[3])*E;let A=a2[m.rotation??0];w.setTexture([v+p[A[0]],y+p[A[1]],v+p[A[2]],y+p[A[3]],v+p[A[4]],y+p[A[5]],v+p[A[6]],y+p[A[7]]],[v+Math.min(p[0],p[2]),y+Math.min(p[1],p[3]),v+Math.max(p[0],p[2]),y+Math.max(p[1],p[3])]),i.quads.push(w)};t.faces?.up?.texture&&(!t.faces.up.cullface||!n[t.faces.up.cullface])&&d(t.faces.up,[o,16-h,c,16-l],[o,u,h,c,u,h,c,u,l,o,u,l]),t.faces?.down?.texture&&(!t.faces.down.cullface||!n[t.faces.down.cullface])&&d(t.faces.down,[16-h,16-c,16-l,16-o],[o,a,l,c,a,l,c,a,h,o,a,h]),t.faces?.south?.texture&&(!t.faces.south.cullface||!n[t.faces.south.cullface])&&d(t.faces.south,[o,16-u,c,16-a],[o,a,h,c,a,h,c,u,h,o,u,h]),t.faces?.north?.texture&&(!t.faces.north.cullface||!n[t.faces.north.cullface])&&d(t.faces.north,[16-c,16-u,16-o,16-a],[c,a,l,o,a,l,o,u,l,c,u,l]),t.faces?.east?.texture&&(!t.faces.east.cullface||!n[t.faces.east.cullface])&&d(t.faces.east,[16-h,16-u,16-l,16-a],[c,a,h,c,a,l,c,u,l,c,u,h]),t.faces?.west?.texture&&(!t.faces.west.cullface||!n[t.faces.west.cullface])&&d(t.faces.west,[l,16-u,h,16-a],[o,a,l,o,a,h,o,u,h,o,u,l]);let f=De.mat4.create();if(t.rotation){let m=De.vec3.fromValues(...t.rotation.origin);De.mat4.translate(f,f,m),De.mat4.rotate(f,f,De.glMatrix.toRadian(t.rotation.angle),c2[t.rotation.axis]),t.rotation.rescale&&De.mat4.scale(f,f,l2[t.rotation.axis]),De.vec3.negate(m,m),De.mat4.translate(f,f,m)}return i.transform(f)}getTexture(t){for(t=t.startsWith("#")?t.slice(1):t,t=this.resolveTextureRef(t);t.startsWith("#");)t=this.resolveTextureRef(t.slice(1));return R.parse(t)}resolveTextureRef(t){let r=this.textures?.[t];return typeof r=="object"&&r!==null?r.sprite:r??""}flatten(t){if(!this.parent)return;if(this.parent.equals(e.BUILTIN_GENERATED)){this.generationMarker=!0;return}let r=this.getParent(t);if(!r){console.warn(`parent ${this.parent} does not exist!`),this.parent=void 0;return}if(r.flatten(t),this.elements||(this.elements=r.elements),this.textures||(this.textures={}),Object.keys(r.textures??{}).forEach(n=>{this.textures[n]||(this.textures[n]=r.textures[n])}),this.display||(this.display={}),Object.keys(r.display??{}).forEach(n=>{let s=n;this.display[s]?Object.keys(r.display[s]??{}).forEach(i=>{let o=i;this.display[s][o]||(this.display[s][o]=r.display[s][o])}):this.display[s]=r.display[s]}),this.guiLight||(this.guiLight=r.guiLight),r.generationMarker&&(this.generationMarker=!0),this.generationMarker&&(this.elements?.length??0)===0)for(let n=0;nnew Me(void 0,{0:T.withPrefix("entity/chest/").toString()},[{from:[1,0,1],to:[15,10,15],faces:{north:{uv:[10.5,8.25,14,10.75],rotation:180,texture:"#0"},east:{uv:[7,8.25,10.5,10.75],rotation:180,texture:"#0"},south:{uv:[3.5,8.25,7,10.75],rotation:180,texture:"#0"},west:{uv:[0,8.25,3.5,10.75],rotation:180,texture:"#0"},up:{uv:[7,4.75,10.5,8.25],texture:"#0"},down:{uv:[3.5,4.75,7,8.25],texture:"#0"}}},{from:[1,10,1],to:[15,14,15],faces:{north:{uv:[10.5,3.75,14,4.75],rotation:180,texture:"#0"},east:{uv:[7,3.75,10.5,4.75],rotation:180,texture:"#0"},south:{uv:[3.5,3.75,7,4.75],rotation:180,texture:"#0"},west:{uv:[0,3.75,3.5,4.75],rotation:180,texture:"#0"},up:{uv:[7,0,10.5,3.5],texture:"#0"},down:{uv:[3.5,0,7,3.5],texture:"#0"}}},{from:[7,7,0],to:[9,11,2],faces:{north:{uv:[.25,.25,.75,1.25],rotation:180,texture:"#0"},east:{uv:[0,.25,.25,1.25],rotation:180,texture:"#0"},south:{uv:[1,.25,1.5,1.25],rotation:180,texture:"#0"},west:{uv:[.75,.25,1,1.25],rotation:180,texture:"#0"},up:{uv:[.25,0,.75,.25],rotation:180,texture:"#0"},down:{uv:[.75,0,1.25,.25],rotation:180,texture:"#0"}}}]).getMesh(B,we.none())}e.chestRenderer=t;function r(T){return new Me(void 0,{0:"entity/decorated_pot/decorated_pot_side",1:"entity/decorated_pot/decorated_pot_base"},[{from:[1,0,1],to:[15,16,15],faces:{north:{uv:[1,0,15,16],texture:"#0"},east:{uv:[1,0,15,16],texture:"#0"},south:{uv:[1,0,15,16],texture:"#0"},west:{uv:[1,0,15,16],texture:"#0"},up:{uv:[0,6.5,7,13.5],texture:"#1"},down:{uv:[7,6.5,14,13.5],texture:"#1"}}},{from:[5,16,5],to:[11,17,11],faces:{north:{uv:[0,5.5,3,6],texture:"#1"},east:{uv:[3,5.5,6,6],texture:"#1"},south:{uv:[6,5.5,9,6],texture:"#1"},west:{uv:[9,5.5,12,6],texture:"#1"}}},{from:[4,17,4],to:[12,20,12],faces:{north:{uv:[0,4,4,5.5],texture:"#1"},east:{uv:[4,4,8,5.5],texture:"#1"},south:{uv:[8,4,12,5.5],texture:"#1"},west:{uv:[12,4,16,5.5],texture:"#1"},up:{uv:[4,0,8,4],texture:"#1"},down:{uv:[8,0,12,4],texture:"#1"}}}]).getMesh(T,we.none())}e.decoratedPotRenderer=r;let n=T=>({south:{uv:[.5,.5,3,5.5],texture:`#${T}`,tintindex:T}});function s(T,B){let D=Q=>({from:[-5,-10,-.99],to:[5,10,-.99],faces:n(Q)}),ie={0:"entity/shield/shield_base_nopattern"},ee=[{from:[-6,-11,-2],to:[6,11,-1],faces:{north:{uv:[3.5,.25,6.5,5.75],texture:"#0"},east:{uv:[3.25,.25,3.5,5.75],texture:"#0"},south:{uv:[.25,.25,3.25,5.75],texture:"#0"},west:{uv:[0,.25,.25,5.75],texture:"#0"},up:{uv:[.25,0,3.25,.25],texture:"#0"},down:{uv:[3.25,0,6.25,.25],texture:"#0"}}}],de=[""];return B?.forEach((Q,_)=>{ie[_+1]=`entity/shield/${Q.pattern}`,ee.push(D(_+1)),de.push(Q.color)}),new Me(void 0,ie,ee).getMesh(T,we.none(),Q=>ln[de[Q]??""]??[1,1,1])}e.shieldRenderer=s;function i(T,B){return D=>new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[4,0,4],to:[12,8,12],faces:{north:{uv:[6,2*B,8,4*B],texture:"#0"},east:{uv:[2,2*B,0,4*B],texture:"#0"},south:{uv:[2,2*B,4,4*B],texture:"#0"},west:{uv:[6,2*B,4,4*B],texture:"#0"},up:{uv:[2,0*B,4,2*B],texture:"#0"},down:{uv:[4,0*B,6,2*B],texture:"#0"}}}]).getMesh(D,we.none())}e.headRenderer=i;function o(T=R.create("enderdragon/dragon")){return B=>{let D=P.mat4.create();return P.mat4.translate(D,D,[8,8,8]),P.mat4.scale(D,D,[.75,.75,.75]),P.mat4.rotateY(D,D,Math.PI),P.mat4.translate(D,D,[-8,-11.2,-8]),new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[2,4,-16],to:[14,9,0],faces:{north:{uv:[12,3.75,12.75,4.0625],texture:"#0"},east:{uv:[11,3.75,12,4.0625],texture:"#0"},south:{uv:[13.75,3.75,14.5,4.0625],texture:"#0"},west:{uv:[12.75,3.75,13.75,4.0625],texture:"#0"},up:{uv:[12.75,3.75,12,2.75],texture:"#0"},down:{uv:[13.5,2.75,12.75,3.75],texture:"#0"}}},{from:[0,0,-2],to:[16,16,14],faces:{north:{uv:[8,2.875,9,3.875],texture:"#0"},east:{uv:[7,2.875,8,3.875],texture:"#0"},south:{uv:[10,2.875,11,3.875],texture:"#0"},west:{uv:[9,2.875,10,3.875],texture:"#0"},up:{uv:[9,2.875,8,1.875],texture:"#0"},down:{uv:[10,1.875,9,2.875],texture:"#0"}}},{from:[2,0,-16],to:[14,4,0],rotation:{angle:-.2*180/Math.PI,axis:"x",origin:[8,4,-2]},faces:{north:{uv:[12,5.0625,12.75,5.3125],texture:"#0"},east:{uv:[11,5.0625,12,5.3125],texture:"#0"},south:{uv:[13.75,5.0625,14.5,5.3125],texture:"#0"},west:{uv:[12.75,5.0625,13.75,5.3125],texture:"#0"},up:{uv:[12.75,5.0625,12,4.0625],texture:"#0"},down:{uv:[13.5,4.0625,12.75,5.0625],texture:"#0"}}},{from:[3,16,4],to:[5,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[11,16,4],to:[13,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[3,9,-14],to:[5,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}},{from:[11,9,-14],to:[13,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}}]).getMesh(B,we.none()).transform(D)}}e.dragonHeadRenderer=o;function a(T=R.create("piglin/piglin")){return B=>new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[3,0,4],to:[13,8,12],faces:{north:{uv:[6.5,2,9,4],texture:"#0"},east:{uv:[2,2,0,4],texture:"#0"},south:{uv:[2,2,4.5,4],texture:"#0"},west:{uv:[6.5,2,4.5,4],texture:"#0"},up:{uv:[2,0,4.5,2],texture:"#0"},down:{uv:[4.5,0,7,2],texture:"#0"}}},{from:[6,0,12],to:[10,4,13],faces:{north:{uv:[9.25,.5,10.25,1.5],texture:"#0"},east:{uv:[7.75,.5,8,1.5],texture:"#0"},south:{uv:[8,.5,9,1.5],texture:"#0"},west:{uv:[9,.5,9.25,1.5],texture:"#0"},up:{uv:[8,.25,9,.5],texture:"#0"},down:{uv:[9,.25,10,.5],texture:"#0"}}},{from:[5,0,12],to:[6,2,13],faces:{north:{uv:[1.25,.25,1.5,.75],texture:"#0"},east:{uv:[.5,.25,.75,.75],texture:"#0"},south:{uv:[.75,.25,1,.75],texture:"#0"},west:{uv:[1,.25,1.25,.75],texture:"#0"},up:{uv:[.75,0,1,.25],texture:"#0"},down:{uv:[1,0,1.25,.25],texture:"#0"}}},{from:[10,0,12],to:[11,2,13],faces:{north:{uv:[1.25,1.25,1.5,1.75],texture:"#0"},east:{uv:[.5,1.25,.75,1.75],texture:"#0"},south:{uv:[.75,1.25,1,1.75],texture:"#0"},west:{uv:[1,1.25,1.25,1.75],texture:"#0"},up:{uv:[.75,1,1,1.25],texture:"#0"},down:{uv:[1,1,1.25,1.25],texture:"#0"}}},{from:[2.5,1.5,6],to:[3.5,6.5,10],rotation:{angle:-30,axis:"z",origin:[3,7,8]},faces:{north:{uv:[12,2.5,12.25,3.75],texture:"#0"},east:{uv:[9.75,2.5,10.75,3.75],texture:"#0"},south:{uv:[10.75,2.5,11,3.75],texture:"#0"},west:{uv:[11,2.5,12,3.75],texture:"#0"},up:{uv:[10.75,1.5,11,2.5],texture:"#0"},down:{uv:[11,1.5,11.25,2.5],texture:"#0"}}},{from:[12.5,1.5,6],to:[13.5,6.5,10],rotation:{angle:30,axis:"z",origin:[13,7,8]},faces:{north:{uv:[15.25,2.5,15,3.75],texture:"#0"},east:{uv:[15,2.5,14,3.75],texture:"#0"},south:{uv:[14,2.5,13.75,3.75],texture:"#0"},west:{uv:[13.75,2.5,12.75,3.75],texture:"#0"},up:{uv:[14,1.5,13.75,2.5],texture:"#0"},down:{uv:[14.25,1.5,14,2.5],texture:"#0"}}}]).getMesh(B,we.none())}e.piglinHeadRenderer=a;function l(T){return B=>new Me(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,8,7],to:[20,20,9],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}},{from:[7,-6,7],to:[9,8,9],faces:{north:{uv:[.5,8,1,15],texture:"#0"},east:{uv:[0,8,.5,15],texture:"#0"},south:{uv:[1.5,8,2,15],texture:"#0"},west:{uv:[1,8,1.5,15],texture:"#0"},up:{uv:[1,8,.5,7],texture:"#0"},down:{uv:[1.5,7,1,8],texture:"#0"}}}]).getMesh(B,we.none())}e.signRenderer=l;function c(T){return B=>new Me(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,4,17],to:[20,16,19],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}}]).getMesh(B,we.none())}e.wallSignRenderer=c;function u(T){return(B,D)=>B?new Me(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[2,10,8],to:[14,16,8],faces:{north:{uv:[3.5,3,6.5,6],texture:"#0"},south:{uv:[3.5,3,6.5,6],texture:"#0"}}}]).getMesh(D,we.none()):new Me(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).getMesh(D,we.none())}e.hangingSignRenderer=u;function h(T){return B=>new Me(void 0,{0:`entity/signs/hanging/${T}`},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[0,14,6],to:[16,16,10],faces:{north:{uv:[1,2,5,3],texture:"#0"},east:{uv:[0,2,1,3],texture:"#0"},south:{uv:[6,2,10,3],texture:"#0"},west:{uv:[5,2,6,3],texture:"#0"},up:{uv:[5,2,1,0],texture:"#0"},down:{uv:[9,0,5,2],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).getMesh(B,we.none())}e.wallHangingSignRenderer=h;function d(T){return new Me(void 0,{0:"entity/conduit/base"},[{from:[5,5,5],to:[11,11,11],faces:{north:{uv:[3,6,6,12],texture:"#0"},east:{uv:[0,6,3,12],texture:"#0"},south:{uv:[9,6,12,12],texture:"#0"},west:{uv:[6,6,9,12],texture:"#0"},up:{uv:[6,6,3,0],texture:"#0"},down:{uv:[9,0,6,6],texture:"#0"}}}]).getMesh(T,we.none())}e.conduitRenderer=d;function f(T){return B=>new Me(void 0,{0:T.withPrefix("entity/shulker/").toString()},[{from:[0,0,0],to:[16,8,16],faces:{north:{uv:[4,11,8,13],texture:"#0"},east:{uv:[0,11,4,13],texture:"#0"},south:{uv:[12,11,16,13],texture:"#0"},west:{uv:[8,11,12,13],texture:"#0"},up:{uv:[8,11,4,7],texture:"#0"},down:{uv:[12,7,8,11],texture:"#0"}}},{from:[0,4,0],to:[16,16,16],faces:{north:{uv:[4,4,8,7],texture:"#0"},east:{uv:[0,4,4,7],texture:"#0"},south:{uv:[12,4,16,7],texture:"#0"},west:{uv:[8,4,12,7],texture:"#0"},up:{uv:[8,4,4,0],texture:"#0"},down:{uv:[12,0,8,4],texture:"#0"}}}]).getMesh(B,we.none())}e.shulkerBoxRenderer=f;let m=T=>({north:{uv:[.25,.25,5.25,10.25],texture:`#${T}`,tintindex:T},east:{uv:[0,.25,.25,10.25],texture:`#${T}`,tintindex:T},south:{uv:[5.5,.25,10.5,10.25],texture:`#${T}`,tintindex:T},west:{uv:[5.25,.25,5.5,10.25],texture:`#${T}`,tintindex:T},up:{uv:[5.25,.25,.25,0],texture:`#${T}`,tintindex:T},down:{uv:[10.25,0,5.25,.25],texture:`#${T}`,tintindex:T}});function p(T,B){return(D,ie)=>{let ee={0:"entity/banner/banner_base"},de=[...B.base],Q=[T];return ie?.forEach((_,S)=>{let O=R.parse(_.getString("pattern")).path,j=_.getString("color");S++,ee[S]=`entity/banner/${O}`,de.push(B.pattern(S)),Q.push(j)}),new Me(void 0,ee,de).getMesh(D,we.none(),_=>ln[Q[_]])}}e.bannerRenderer=T=>p(T,{base:[{from:[-2,-8,6],to:[18,32,7],faces:m(0)},{from:[7,-12,7],to:[9,30,9],faces:{north:{uv:[11.5,.5,12,11],texture:"#0"},east:{uv:[11,.5,11.5,11],texture:"#0"},south:{uv:[12.5,.5,13,11],texture:"#0"},west:{uv:[12,.5,12.5,11],texture:"#0"},up:{uv:[12,.5,11.5,0],texture:"#0"},down:{uv:[12.5,0,12,.5],texture:"#0"}}},{from:[-2,30,7],to:[18,32,9],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}],pattern:B=>({from:[-2,-8,6],to:[18,32,7],faces:m(B)})}),e.wallBannerRenderer=T=>p(T,{base:[{from:[-2,-8,-1.5],to:[18,32,-.5],faces:m(0)},{from:[-2,30,-3.5],to:[18,32,-1.5],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}],pattern:B=>({from:[-2,-8,-1.5],to:[18,32,-.5],faces:m(B)})});function g(T){return new Me(void 0,{0:"entity/bell/bell_body"},[{from:[5,3,5],to:[11,10,11],faces:{north:{uv:[3,3,6,6.5],texture:"#0"},east:{uv:[0,3,3,6.5],texture:"#0"},south:{uv:[9,3,12,6.5],texture:"#0"},west:{uv:[6,3,9,6.5],texture:"#0"},up:{uv:[6,3,3,0],texture:"#0"},down:{uv:[9,0,6,3],texture:"#0"}}},{from:[4,10,4],to:[12,12,12],faces:{north:{uv:[4,10.5,8,11.5],texture:"#0"},east:{uv:[0,10.5,4,11.5],texture:"#0"},south:{uv:[12,10.5,16,11.5],texture:"#0"},west:{uv:[8,10.5,12,11.5],texture:"#0"},up:{uv:[8,10.5,4,6.5],texture:"#0"},down:{uv:[12,6.5,8,10.5],texture:"#0"}}}]).getMesh(T,we.none())}e.bellRenderer=g;function w(T){return(B,D)=>B==="foot"?new Me(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{north:{uv:[5.5,5.5,9.5,7],rotation:180,texture:"#0"},east:{uv:[0,7,1.5,11],rotation:270,texture:"#0"},west:{uv:[5.5,7,7,11],rotation:90,texture:"#0"},up:{uv:[5.5,11,1.5,7],texture:"#0"},down:{uv:[11,7,7,11],texture:"#0"}}},{from:[0,0,0],to:[3,3,3],faces:{north:{uv:[12.5,5.25,13.25,6],texture:"#0"},east:{uv:[14.75,5.25,15.5,6],texture:"#0"},south:{uv:[14,5.25,14.75,6],texture:"#0"},west:{uv:[13.25,5.25,14,6],texture:"#0"},up:{uv:[13.25,4.5,14,5.25],texture:"#0"},down:{uv:[14,4.5,14.75,5.25],texture:"#0"}}},{from:[13,0,0],to:[16,3,3],faces:{north:{uv:[13.25,3.75,14,4.5],texture:"#0"},east:{uv:[12.5,3.75,13.25,4.5],texture:"#0"},south:{uv:[14.75,3.75,15.5,4.5],texture:"#0"},west:{uv:[14,3.75,14.75,4.5],texture:"#0"},up:{uv:[13.25,3,14,3.75],texture:"#0"},down:{uv:[14,3,14.75,3.75],texture:"#0"}}}]).getMesh(D,we.none()):new Me(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{east:{uv:[0,1.5,1.5,5.5],rotation:270,texture:"#0"},south:{uv:[1.5,0,5.5,1.5],rotation:180,texture:"#0"},west:{uv:[5.5,1.5,7,5.5],rotation:90,texture:"#0"},up:{uv:[5.5,5.5,1.5,1.5],texture:"#0"},down:{uv:[11,1.5,7,5.5],texture:"#0"}}},{from:[0,0,13],to:[3,3,16],faces:{north:{uv:[14.75,.75,15.5,1.5],texture:"#0"},east:{uv:[14,.75,14.75,1.5],texture:"#0"},south:{uv:[13.25,.75,14,1.5],texture:"#0"},west:{uv:[12.5,.75,13.25,1.5],texture:"#0"},up:{uv:[13.25,0,14,.75],texture:"#0"},down:{uv:[14,0,14.75,.75],texture:"#0"}}},{from:[13,0,13],to:[16,3,16],faces:{north:{uv:[14,2.25,14.75,3],texture:"#0"},east:{uv:[13.25,2.25,14,3],texture:"#0"},south:{uv:[12.5,2.25,13.25,3],texture:"#0"},west:{uv:[14.75,2.25,15.5,3],texture:"#0"},up:{uv:[13.25,1.5,14,2.25],texture:"#0"},down:{uv:[14,1.5,14.75,2.25],texture:"#0"}}}]).getMesh(D,we.none())}e.bedRenderer=w;function x(T){return(B,D)=>{let ie=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,11,3],to:[12,16,13],faces:{east:{uv:[0,2.5,2.5,3.75],texture:"#0"},north:{uv:[2.5,2.5,4.5,3.75],texture:"#0"},west:{uv:[4.5,2.5,6.5,3.75],texture:"#0"},south:{uv:[7,2.5,9,3.75],texture:"#0"},up:{uv:[2.5,0,4.5,2.5],rotation:180,texture:"#0"},down:{uv:[4.5,0,6.5,2.5],rotation:180,texture:"#0"}}},{from:[7,10,2],to:[9,13,4],faces:{east:{uv:[14,.5,14.5,1.25],texture:"#0"},north:{uv:[14.5,.5,15,1.25],texture:"#0"},west:{uv:[15,.5,15.5,1.25],texture:"#0"},south:{uv:[15.5,.5,16,1.25],texture:"#0"},up:{uv:[14.5,0,15,.5],rotation:180,texture:"#0"},down:{uv:[15,0,15.5,.5],rotation:180,texture:"#0"}}},{from:[7,16,7],to:[9,20,9],faces:{east:{uv:[9.25,2.5,9.75,3.5],texture:"#0"},north:{uv:[9.75,2.5,10.25,3.5],texture:"#0"},west:{uv:[10.25,2.5,10.75,3.5],texture:"#0"},south:{uv:[10.75,2.5,11.25,3.5],texture:"#0"},up:{uv:[9.75,2,10.25,2.5],texture:"#0"},down:{uv:[10.25,2,10.75,2.5],texture:"#0"}}},{from:[6,20,6],to:[10,24,10],faces:{east:{uv:[9.25,1,10.25,2],texture:"#0"},north:{uv:[10.25,1,11.25,2],texture:"#0"},west:{uv:[11.25,1,12.25,2],texture:"#0"},south:{uv:[12.25,1,13.25,2],texture:"#0"},up:{uv:[10.25,0,11.25,1],rotation:180,texture:"#0"},down:{uv:[11.25,0,12.25,1],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),ee=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,5,5],to:[12,11,11],faces:{east:{uv:[0,5.25,1.5,6.75],texture:"#0"},north:{uv:[1.5,5.25,3.5,6.75],texture:"#0"},west:{uv:[3.5,5.25,5,6.75],texture:"#0"},south:{uv:[5,5.25,7,6.75],texture:"#0"},up:{uv:[1.5,3.75,3.5,5.25],texture:"#0"},down:{uv:[3.5,3.75,5.5,5.25],texture:"#0"}}}]).getMesh(B,we.none()),de=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[12,2,6],to:[15,12,10],faces:{east:{uv:[9,5,10,7.5],texture:"#0"},north:{uv:[10,5,10.75,7.5],texture:"#0"},west:{uv:[10.75,5,11.75,7.5],texture:"#0"},south:{uv:[11.75,5,12.5,7.5],texture:"#0"},up:{uv:[10,4,10.75,5],rotation:180,texture:"#0"},down:{uv:[10.75,4,11.5,5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),Q=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[1,2,6],to:[4,12,10],faces:{east:{uv:[12.5,5,13.5,7.5],texture:"#0"},north:{uv:[13.5,5,14.25,7.5],texture:"#0"},west:{uv:[14.25,5,15.25,7.5],texture:"#0"},south:{uv:[15.25,5,16,7.5],texture:"#0"},up:{uv:[13.5,4,14.25,5],rotation:180,texture:"#0"},down:{uv:[14.25,4,15,5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),_=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[8,0,6],to:[12,5,10],faces:{east:{uv:[0,7.75,1,9],texture:"#0"},north:{uv:[1,7.75,2,9],texture:"#0"},west:{uv:[2,7.75,3,9],texture:"#0"},south:{uv:[3,7.75,4,9],texture:"#0"},up:{uv:[1,6.75,2,7.75],texture:"#0"},down:{uv:[2,6.75,3,7.75],texture:"#0"}}}]).getMesh(B,we.none()),S=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,0,6],to:[8,5,10],faces:{east:{uv:[4,7.75,5,9],texture:"#0"},north:{uv:[5,7.75,6,9],texture:"#0"},west:{uv:[6,7.75,7,9],texture:"#0"},south:{uv:[7,7.75,8,9],texture:"#0"},up:{uv:[5,6.75,6,7.75],texture:"#0"},down:{uv:[6,6.75,7,7.75],texture:"#0"}}}]).getMesh(B,we.none()),O=new _e;switch(D){case"sitting":let j=P.mat4.create();P.mat4.translate(j,j,[0,-5,2]),O.merge(ee.transform(j));let ue=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[5,6,6],to:[11,7,12],faces:{east:{uv:[.75,6.25,2.25,6.5],texture:"#0"},north:{uv:[2.25,6.25,3.75,6.5],texture:"#0"},west:{uv:[3.75,6.25,5.25,6.5],texture:"#0"},south:{uv:[5.25,6.25,6.75,6.5],texture:"#0"},up:{uv:[2.25,4.75,3.75,6.25],texture:"#0"},down:{uv:[3.75,4.75,5.25,6.25],texture:"#0"}}},{from:[4,1,4],to:[12,7,7],faces:{east:{uv:[.75,5.25,1.5,6.75],rotation:180,texture:"#0"},north:{uv:[1.5,5.25,3.5,6.75],rotation:180,texture:"#0"},west:{uv:[3.5,5.25,4.25,6.75],rotation:180,texture:"#0"},south:{uv:[4.25,5.25,6.25,6.75],rotation:180,texture:"#0"},up:{uv:[1.5,4.5,3.5,5.25],rotation:180,texture:"#0"},down:{uv:[3.5,4.75,5.5,5.5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none());O.merge(ue);let qe=P.mat4.create();P.mat4.translate(qe,qe,[0,-4,0]),O.merge(ie.transform(qe));let Ae=P.mat4.create();P.mat4.translate(Ae,Ae,[0,5.5,6.5]),P.mat4.rotateX(Ae,Ae,.61086524),P.mat4.translate(Ae,Ae,[0,-7,-8]),O.merge(de.transform(Ae)),O.merge(Q.transform(Ae));let Ne=P.mat4.create();P.mat4.translate(Ne,Ne,[2.5,2.5,2]),P.mat4.rotateX(Ne,Ne,Math.PI/2),P.mat4.translate(Ne,Ne,[-2.5,-1,-7.5]),O.merge(_.transform(Ne)),O.merge(S.transform(Ne));break;case"running":let ye=P.mat4.create();P.mat4.translate(ye,ye,[0,0,-2]),O.merge(ie.transform(ye));let le=P.mat4.create();P.mat4.translate(le,le,[0,0,-2]),P.mat4.translate(le,le,[-8,-8,-6]),P.mat4.rotateX(le,le,-.120399),P.mat4.rotateY(le,le,.0064),P.mat4.rotateZ(le,le,-.0779),P.mat4.translate(le,le,[6.4,7.5,9.5]),O.merge(ee.transform(le));let q=P.mat4.create();P.mat4.translate(q,q,[0,7,8]),P.mat4.rotateX(q,q,-1.003564),P.mat4.translate(q,q,[0,-7,-5]),O.merge(de.transform(q));let L=P.mat4.create();P.mat4.translate(L,L,[0,7,8]),P.mat4.rotateX(L,L,.872665),P.mat4.rotateY(L,L,.0535),P.mat4.rotateZ(L,L,-.0449),P.mat4.translate(L,L,[0,-7,-10.25]),O.merge(Q.transform(L));let ae=P.mat4.create();P.mat4.translate(ae,ae,[10,2.5,4.6]),P.mat4.rotateX(ae,ae,.872665),P.mat4.translate(ae,ae,[-10.6,-1.5,-7.5]),O.merge(_.transform(ae));let Se=P.mat4.create();P.mat4.translate(Se,Se,[6,2.5,10]),P.mat4.rotateX(Se,Se,-.7854),P.mat4.translate(Se,Se,[-6.4,-1.5,-8]),O.merge(S.transform(Se));break;case"star":O.merge(ie),O.merge(ee);let ft=P.mat4.create();P.mat4.translate(ft,ft,[11,10,8]),P.mat4.rotateZ(ft,ft,1.91986),P.mat4.translate(ft,ft,[-13.5,-7,-8]),O.merge(de.transform(ft));let Qe=P.mat4.create();P.mat4.translate(Qe,Qe,[5,10,8]),P.mat4.rotateZ(Qe,Qe,-1.91986),P.mat4.translate(Qe,Qe,[-2.5,-7,-8]),O.merge(Q.transform(Qe));let kt=P.mat4.create();P.mat4.translate(kt,kt,[10.75,3,8]),P.mat4.rotateZ(kt,kt,.2618),P.mat4.translate(kt,kt,[-10,-2.5,-8]),O.merge(_.transform(kt));let nt=P.mat4.create();P.mat4.translate(nt,nt,[5.25,3,8]),P.mat4.rotateZ(nt,nt,-.2618),P.mat4.translate(nt,nt,[-6,-2.5,-8]),O.merge(S.transform(nt));break;default:O.merge(ee),O.merge(ie),O.merge(de),O.merge(Q),O.merge(_),O.merge(S);break}return O}}e.copperGolemStatueRenderer=x;function v(T,B,D=""){return T.getProperty(B)??D}function y(T,B,D="0"){return parseInt(T.getProperty(B)??D)}let I=new Map(Object.entries({"minecraft:chest":e.chestRenderer(R.create("normal")),"minecraft:ender_chest":e.chestRenderer(R.create("ender")),"minecraft:trapped_chest":e.chestRenderer(R.create("trapped")),"minecraft:copper_chest":e.chestRenderer(R.create("copper")),"minecraft:exposed_copper_chest":e.chestRenderer(R.create("copper_exposed")),"minecraft:weathered_copper_chest":e.chestRenderer(R.create("copper_weathered")),"minecraft:oxidized_copper_chest":e.chestRenderer(R.create("copper_oxidized")),"minecraft:waxed_copper_chest":e.chestRenderer(R.create("copper")),"minecraft:waxed_exposed_copper_chest":e.chestRenderer(R.create("copper_exposed")),"minecraft:waxed_weathered_copper_chest":e.chestRenderer(R.create("copper_weathered")),"minecraft:waxed_oxidized_copper_chest":e.chestRenderer(R.create("copper_oxidized"))})),b=new Map(Object.entries({"minecraft:skeleton_skull":e.headRenderer(R.create("skeleton/skeleton"),2),"minecraft:wither_skeleton_skull":e.headRenderer(R.create("skeleton/wither_skeleton"),2),"minecraft:zombie_head":e.headRenderer(R.create("zombie/zombie"),1),"minecraft:creeper_head":e.headRenderer(R.create("creeper/creeper"),2),"minecraft:dragon_head":e.dragonHeadRenderer(),"minecraft:piglin_head":e.piglinHeadRenderer(),"minecraft:player_head":e.headRenderer(R.create("player/wide/steve"),1)})),k=["oak","spruce","birch","jungle","acacia","dark_oak","mangrove","cherry","pale_oak","bamboo","crimson","warped"],E=new Map(k.map(T=>[`minecraft:${T}_sign`,e.signRenderer(R.create(T))])),A=new Map(k.map(T=>[`minecraft:${T}_wall_sign`,e.wallSignRenderer(R.create(T))])),N=new Map(k.map(T=>[`minecraft:${T}_hanging_sign`,e.hangingSignRenderer(R.create(T))])),z=new Map(k.map(T=>[`minecraft:${T}_wall_hanging_sign`,e.wallHangingSignRenderer(T)])),F=new Map(Object.keys(ln).map(T=>[`minecraft:${T}_shulker_box`,e.shulkerBoxRenderer(R.create(`shulker_${T}`))])),Y=new Map(Object.keys(ln).map(T=>[`minecraft:${T}_bed`,e.bedRenderer(R.create(T))])),$=new Map(Object.keys(ln).map(T=>[`minecraft:${T}_banner`,e.bannerRenderer(T)])),V=new Map(Object.keys(ln).map(T=>[`minecraft:${T}_wall_banner`,e.wallBannerRenderer(T)])),ce=new Map(Object.entries({"minecraft:copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem")),"minecraft:exposed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_exposed")),"minecraft:weathered_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_weathered")),"minecraft:oxidized_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_oxidized")),"minecraft:waxed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem")),"minecraft:waxed_exposed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_exposed")),"minecraft:waxed_weathered_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_weathered")),"minecraft:waxed_oxidized_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_oxidized"))}));function oe(T,B,D,ie){let ee=new _e;T.is("water")&&ee.merge(_o("water",y(T,"level"),D,ie,0)),T.is("lava")&&ee.merge(_o("lava",y(T,"level"),D,ie));let de=I.get(T.getName().toString());if(de!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(de(D).transform(L))}T.is("decorated_pot")&&ee.merge(r(D));let Q=b.get(T.getName().toString());if(Q!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(Q(D).transform(L))}let _=E.get(T.getName().toString());if(_!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(_(D).transform(L))}let S=A.get(T.getName().toString());if(S!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(S(D).transform(L))}let O=N.get(T.getName().toString());if(O!==void 0){let q=v(T,"attached","false")==="true",L=y(T,"rotation")/16*Math.PI*2,ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,L),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(O(q,D).transform(ae))}let j=z.get(T.getName().toString());if(j!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(j(D).transform(L))}T.is("conduit")&&ee.merge(d(D));let ue=F.get(T.getName().toString());if(ue!==void 0){let q=v(T,"facing","up"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),q==="down"?P.mat4.rotateX(L,L,Math.PI):q!=="up"&&(P.mat4.rotateY(L,L,q==="east"?Math.PI/2:q==="north"?Math.PI:q==="west"?Math.PI*3/2:0),P.mat4.rotateX(L,L,Math.PI/2)),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(ue(D).transform(L))}if(T.is("bell")){let q=P.mat4.create();P.mat4.translate(q,q,[8,8,8]),P.mat4.scale(q,q,[1,-1,-1]),P.mat4.translate(q,q,[-8,-8,-8]),ee.merge(g(D).transform(q))}let qe=Y.get(T.getName().toString());if(qe!==void 0){let q=v(T,"part","head"),L=v(T,"facing","south"),ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,L==="east"?Math.PI/2:L==="north"?Math.PI:L==="west"?Math.PI*3/2:0),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(qe(q,D).transform(ae))}let Ae=$.get(T.getName().toString());if(Ae!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,24,8]),P.mat4.rotateY(L,L,q),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-24,-8]),ee.merge(Ae(D,B?.getList("patterns",C.Compound)).transform(L))}let Ne=V.get(T.getName().toString());if(Ne!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="east"?Math.PI/2:q==="north"?Math.PI:q==="west"?Math.PI*3/2:0),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-23.2,-8]),ee.merge(Ne(D,B?.getList("patterns",C.Compound)).transform(L))}let ye=ce.get(T.getName().toString());if(ye!==void 0){let q=v(T,"facing","south"),L=v(T,"copper_golem_pose","standing"),ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(ye(D,L).transform(ae))}!T.is("water")&&!T.is("lava")&&T.isWaterlogged()&&ee.merge(_o("water",0,D,ie,0));let le=P.mat4.create();return P.mat4.scale(le,le,[.0625,.0625,.0625]),ee.transform(le)}e.getBlockMesh=oe})(Be=Be||(Be={}));var Gn=mr(Br(),1);var Mo=mr(Br(),1);var un=class{gl;program;constructor(t,r,n){this.gl=t,this.program=this.initShaderProgram(r,n)}getProgram(){return this.program}initShaderProgram(t,r){let n=this.loadShader(this.gl.VERTEX_SHADER,t),s=this.loadShader(this.gl.FRAGMENT_SHADER,r),i=this.gl.createProgram();if(this.gl.attachShader(i,n),this.gl.attachShader(i,s),this.gl.linkProgram(i),!this.gl.getProgramParameter(i,this.gl.LINK_STATUS))throw new Error(`Unable to link shader program: ${this.gl.getProgramInfoLog(i)}`);return i}loadShader(t,r){let n=this.gl.createShader(t);if(this.gl.shaderSource(n,r),this.gl.compileShader(n),!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)){let s=new Error(`Compiling ${t===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(n)}`);throw this.gl.deleteShader(n),s}return n}};var u2=` +`+n+"}"}toSimplifiedJson(){return this.map((t,r)=>[t,r.toSimplifiedJson()])}toJson(){return this.map((t,r)=>[t,{type:r.getId(),value:r.toJson()}])}toBytes(t){for(let[r,n]of this.properties.entries()){let s=n.getId();t.writeByte(s),t.writeString(r),n.toBytes(t)}t.writeByte(C.End)}static create(){return new e}static fromString(t){return Nr.readTag(t)}static fromJson(t){let r=M.readMap(t,n=>{let{type:s,value:i}=M.readObject(n)??{},o=M.readNumber(s);return ne.fromJson(i??{},o)});return new e(new Map(Object.entries(r)))}static fromBytes(t){let r=new Map;for(;;){let n=t.readByte();if(n===C.End)break;let s=t.readString(),i=ne.fromBytes(t,n);r.set(s,i)}return new e(r)}};ne.register(C.Compound,Re);var ar=class e{name;root;compression;littleEndian;bedrockHeader;static DEFAULT_NAME="";static DEFAULT_BEDROCK_HEADER=4;constructor(t,r,n,s,i){this.name=t,this.root=r,this.compression=n,this.littleEndian=s,this.bedrockHeader=i}writeNamedTag(t){t.writeByte(C.Compound),t.writeString(this.name),this.root.toBytes(t)}write(){let t=this.littleEndian===!0||this.bedrockHeader!==void 0,r=new xi({littleEndian:t,offset:this.bedrockHeader&&8});if(this.writeNamedTag(r),this.bedrockHeader!==void 0){let s=r.offset;r.offset=0,r.writeInt(this.bedrockHeader),r.writeInt(s-8),r.offset=s}let n=r.getData();return this.compression==="gzip"?Ti.gzip(n):this.compression==="zlib"?Ti.deflate(n):n}static readNamedTag(t){if(t.readByte()!==C.Compound)throw new Error("Top tag should be a compound");return{name:t.readString(),root:Re.fromBytes(t)}}static create(t={}){let r=t.name??e.DEFAULT_NAME,n=Re.create(),s=t.compression??"none",i=typeof t.bedrockHeader=="boolean"?e.DEFAULT_BEDROCK_HEADER:t.bedrockHeader,o=t.littleEndian??t.bedrockHeader!==void 0;return new e(r,n,s,o,i)}static read(t,r={}){let n=typeof r.bedrockHeader=="number"?r.bedrockHeader:r.bedrockHeader?wa(t):void 0,s=r.compression==="gzip"||!n&&r.compression===void 0&&pa(t),i=r.compression==="zlib"||!n&&r.compression===void 0&&ga(t),o=i||s?Ti.inflate(t):t,a=r.littleEndian||n!==void 0,l=s?"gzip":i?"zlib":"none",c=new wi(o,{littleEndian:a,offset:n&&8}),{name:u,root:h}=e.readNamedTag(c);return new e(r.name??u,h,l,a,n)}toJson(){return{name:this.name,root:this.root.toJson(),compression:this.compression,littleEndian:this.littleEndian,bedrockHeader:this.bedrockHeader??null}}static fromJson(t){let r=M.readObject(t)??{},n=M.readString(r.name)??"",s=Re.fromJson(r.root??{}),i=M.readString(r.compression)??"none",o=M.readBoolean(r.littleEndian)??!1,a=M.readNumber(r.bedrockHeader);return new e(n,s,i,o,a)}};var cr=class e{x;z;compression;timestamp;raw;file;dirty;constructor(t,r,n,s,i){this.x=t,this.z=r,this.compression=n,this.timestamp=s,this.raw=i,this.dirty=!1}getCompression(){switch(this.compression){case 1:return"gzip";case 2:return"zlib";case 3:return"none";default:throw new Error(`Invalid compression mode ${this.compression}`)}}setCompression(t){switch(t){case"gzip":this.compression=1;break;case"zlib":this.compression=2;break;case"none":this.compression=3;break;default:throw new Error(`Invalid compression mode ${t}`)}}getFile(){return this.file===void 0&&(this.file=ar.read(this.raw,{compression:this.getCompression()})),this.file}getRoot(){return this.getFile().root}setRoot(t){this.file===void 0&&(this.file=ar.create({compression:this.getCompression()})),this.file.root=t,this.markDirty()}markDirty(){this.dirty=!0}getRaw(){if(this.file===void 0||this.dirty===!1)return this.raw;this.file.compression=this.getCompression();let t=this.file.write();return this.raw=t,this.dirty=!1,t}toJson(){return{x:this.x,z:this.z,compression:this.compression,timestamp:this.timestamp,size:this.raw.byteLength}}toRef(t){return new e.Ref(this.x,this.z,this.compression,this.timestamp,this.raw.byteLength,t)}static create(t,r,n,s){let i=new e(t,r,0,s??0,n.write());return i.setCompression(n.compression),i}static fromJson(t,r){let n=M.readObject(t)??{},s=M.readInt(n.x)??0,i=M.readInt(n.z)??0,o=M.readNumber(n.compression)??2,a=M.readInt(n.timestamp)??0,l=M.readInt(n.size)??0;return new e.Ref(s,i,o,a,l,r)}};(function(e){class t{x;z;compression;timestamp;size;resolver;file;constructor(n,s,i,o,a,l){this.x=n,this.z=s,this.compression=i,this.timestamp=o,this.size=a,this.resolver=l}getFile(){if(this.file instanceof ar)return this.file}getRoot(){if(this.file instanceof ar)return this.file.root}async getFileAsync(){return this.file?this.file:(this.file=(async()=>{let n=await this.resolver(this.x,this.z);return this.file=n,n})(),this.file)}async getRootAsync(){return(await this.getFileAsync()).root}isResolved(){return this.file instanceof ar}}e.Ref=t})(cr=cr||(cr={}));var zi=class{chunks;constructor(t){this.chunks=Array(1024).fill(void 0);for(let r of t){let n=Tr.getIndex(r.x,r.z);this.chunks[n]=r}}getChunkPositions(){return this.chunks.flatMap(t=>t?[[t.x,t.z]]:[])}getChunk(t){if(!(t<0||t>=1024))return this.chunks[t]}findChunk(t,r){return this.getChunk(Tr.getIndex(t,r))}getFirstChunk(){return this.chunks.filter(t=>t!==void 0)[0]}filter(t){return this.chunks.filter(r=>r!==void 0&&t(r))}map(t){return this.chunks.flatMap(r=>r!==void 0?[t(r)]:[])}},Tr=class e extends zi{constructor(t){super(t)}write(){let t=0;for(let i of this.chunks)i!==void 0&&(t+=Math.ceil(i.getRaw().length/4096));let r=new Uint8Array(8192+t*4096),n=new DataView(r.buffer),s=2;for(let i of this.chunks){if(i===void 0)continue;let o=i.getRaw(),a=4*((i.x&31)+(i.z&31)*32),l=Math.ceil(o.length/4096);n.setInt8(a,s>>16),n.setInt16(a+1,s&65535),n.setInt8(a+3,l),n.setInt32(a+4096,i.timestamp);let c=s*4096;n.setInt32(c,o.length+1),n.setInt8(c+4,i.compression),r.set(o,c+5),s+=l}return r}static read(t){let r=[];for(let n=0;n<32;n+=1)for(let s=0;s<32;s+=1){let i=4*((n&31)+(s&31)*32);if(t[i+3]===0)continue;let a=(t[i]<<16)+(t[i+1]<<8)+t[i+2],l=(t[i+4096]<<24)+(t[i+4097]<<16)+(t[i+4098]<<8)+t[i+4099],c=a*4096,u=(t[c]<<24)+(t[c+1]<<16)+(t[c+2]<<8)+t[c+3],h=t[c+4],d=t.slice(c+5,c+4+u);r.push(new cr(n,s,h,l,d))}return new e(r)}static getIndex(t,r){return(t&31)+(r&31)*32}toJson(){return{chunks:this.map(t=>t.toJson())}}static fromJson(t,r){let n=M.readObject(t)??{},i=(M.readArray(n.chunks)??[]).flatMap(o=>o!==void 0?[cr.fromJson(o,r)]:[]);return new e.Ref(i)}};(function(e){class t extends zi{}e.Ref=t})(Tr=Tr||(Tr={}));var Rr=class e extends ne{value;constructor(t){super(),this.value=t}getId(){return C.Double}equals(t){return t.isDouble()&&this.value===t.value}getAsNumber(){return this.value}toString(){return Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(t){t.writeDouble(this.value)}static create(){return new e(0)}static fromJson(t){return new e(M.readNumber(t)??0)}static fromBytes(t){let r=t.readDouble();return new e(r)}};ne.register(C.Double,Rr);var Ks=class e extends ne{static INSTANCE=new e;constructor(){super()}getId(){return C.End}equals(t){return t.isEnd()}toString(){return"END"}toPrettyString(){return this.toString()}toSimplifiedJson(){return null}toJson(){return null}toBytes(){}static create(){return e.INSTANCE}static fromJson(){return e.INSTANCE}static fromBytes(){return e.INSTANCE}};ne.register(C.End,Ks);var ze;(function(e){e.UP="up",e.DOWN="down",e.NORTH="north",e.EAST="east",e.SOUTH="south",e.WEST="west"})(ze=ze||(ze={}));var sm={[ze.UP]:[0,1,0],[ze.DOWN]:[0,-1,0],[ze.NORTH]:[0,0,-1],[ze.EAST]:[1,0,0],[ze.SOUTH]:[0,0,1],[ze.WEST]:[-1,0,0]};(function(e){e.ALL=[e.UP,e.DOWN,e.NORTH,e.EAST,e.SOUTH,e.WEST];function t(r){return sm[r]}e.normal=t})(ze=ze||(ze={}));var te;(function(e){function t(h,d,f){return[h,d,f]}e.create=t,e.ZERO=e.create(0,0,0);function r(h,d,f,m){return[h[0]+d,h[1]+f,h[2]+m]}e.offset=r;function n(h,d){return[h[0]-d[0],h[1]-d[1],h[2]-d[2]]}e.subtract=n;function s(h,d){return[h[0]+d[0],h[1]+d[1],h[2]+d[2]]}e.add=s;function i(h,d){return e.offset(h,...ze.normal(d))}e.towards=i;function o(h,d){return h===d?!0:h[0]===d[0]&&h[1]===d[1]&&h[2]===d[2]}e.equals=o;function a(h){return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]}e.magnitude=a;function l(h){return new Bt(h.map(d=>new pt(d)))}e.toNbt=l;function c(h){return h.getAsTuple(3,d=>d?.isInt()?d.getAsNumber():0)}e.fromNbt=c;function u(h){let d=M.readArray(h,f=>M.readInt(f)??0)??[0,0,0];return t(d[0],d[1],d[2])}e.fromJson=u})(te=te||(te={}));var R=class e{namespace;path;static DEFAULT_NAMESPACE="minecraft";static SEPARATOR=":";constructor(t,r){this.namespace=t,this.path=r}is(t){return this.equals(e.parse(t))}equals(t){return this===t?!0:t instanceof e?this.namespace===t.namespace&&this.path===t.path:!1}toString(){return this.namespace+e.SEPARATOR+this.path}withPrefix(t){return new e(this.namespace,t+this.path)}static create(t){return new e(this.DEFAULT_NAMESPACE,t)}static parse(t){let r=t.indexOf(this.SEPARATOR);if(r>=0){let n=r>=1?t.substring(0,r):this.DEFAULT_NAMESPACE,s=t.substring(r+1);return new e(n,s)}return new e(this.DEFAULT_NAMESPACE,t)}};var se=class e{properties;static AIR=new e(R.create("air"));static STONE=new e(R.create("stone"));static WATER=new e(R.create("water"),{level:"0"});static LAVA=new e(R.create("lava"),{level:"0"});name;constructor(t,r={}){this.properties=r,this.name=typeof t=="string"?R.parse(t):t}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isFluid(){return this.is(e.WATER)||this.is(e.LAVA)}isWaterlogged(){return this.is(e.WATER)||this.is(e.LAVA)||this.is("bubble_column")||this.is("kelp")||this.is("kelp_plant")||this.is("seagrass")||this.is("tall_seagrass")||this.properties.waterlogged==="true"}equals(t){return!this.name.equals(t.name)||Object.keys(this.properties).length!==Object.keys(t.properties).length?!1:Object.keys(this.properties).every(r=>t.properties[r]===this.properties[r])}is(t){return typeof t=="string"?this.name.equals(R.parse(t)):t instanceof R?this.name.equals(t):this.name.equals(t.name)}toString(){return Object.keys(this.properties).length===0?this.name.toString():`${this.name.toString()}[${Object.entries(this.properties).map(([t,r])=>t+"="+r).join(",")}]`}static parse(t){let r=t.indexOf("[");if(r===-1)return new e(t);{let n=t.substring(0,r),s=t.substring(r+1,t.length-1).split(","),i=Object.fromEntries(s.map(o=>o.split("=")));return new e(n,i)}}static fromNbt(t){if(t.isString())return new e(t.getAsString());let r=t.isCompound()?t:new Re,n=R.parse(r.hasString("id")?r.getString("id"):r.getString("Name")),s=(r.hasCompound("properties")?r.getCompound("properties"):r.getCompound("Properties")).map((i,o)=>[i,o.getAsString()]);return new e(n,s)}static fromJson(t){if(typeof t=="string")return new e(t);let r=M.readObject(t)??{},n=R.parse(M.readString(r.id??r.Name)??""),s=M.readMap(r.properties??r.Properties,i=>M.readString(i)??"");return new e(n,s)}};var Pi=class{size;defaultValue;storage;palette;constructor(t,r){this.size=t,this.defaultValue=r,this.storage=Array(t).fill(0),this.palette=[r]}index(t,r,n){return(t<<8)+(r<<4)+n}get(t,r,n){let s=this.storage[this.index(t,r,n)];return this.palette[s]}set(t,r,n,s){let i=this.palette.findIndex(o=>o.equals(s));i===-1&&(i=this.palette.length,this.palette.push(s)),this.storage[this.index(t,r,n)]=i}};var Oi=class e{minY;static WIDTH=16;static SIZE=e.WIDTH*e.WIDTH*e.WIDTH;states;constructor(t){this.minY=t,this.states=new Pi(e.SIZE,se.AIR)}get minBlockY(){return this.minY<<4}getBlockState(t,r,n){return this.states.get(t,r,n)}setBlockState(t,r,n,s){this.states.set(t,r,n,s)}};var Un=class{minY;height;pos;sections;constructor(t,r,n){this.minY=t,this.height=r,this.pos=n,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return(this.maxY-1>>4)+1}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(t){return(t>>4)-this.minSection}getBlockState(t){let[r,n,s]=t;return this.sections[this.getSectionIndex(n)]?.getBlockState(r&15,n&15,s&15)??se.AIR}setBlockState(t,r){let[n,s,i]=t,o=this.getSectionIndex(s),a=this.sections[o];if(a===null){if(r.equals(se.AIR))return;a=this.getOrCreateSection(o)}a.setBlockState(n&15,s&15,i&15,r)}getOrCreateSection(t){return this.sections[t]==null&&(this.sections[t]=new Oi(this.minSection+t)),this.sections[t]}};var Je;(function(e){function t(u,h){return[u,h]}e.create=t;function r(u){return[u[0]>>4,u[2]>>4]}e.fromBlockPos=r;function n(u){return[Number(u)&4294967295,Number(u>>BigInt(32))]}e.fromLong=n;function s(u){return i(u[0],u[1])}e.toLong=s;function i(u,h){return BigInt(u&4294967295)|BigInt(h&4294967295)<typeof o=="string"?n(s,R.parse(o)):r(i(o))}e.parser=t;function r(s,i){return{value:()=>s,key:()=>i}}e.direct=r;function n(s,i,o=!0){return o?{value:()=>s.getOrThrow(i),key:()=>i}:{value:()=>s.get(i),key:()=>i}}e.reference=n})(he=he||(he={}));var Lt=class e{entries;constructor(t){this.entries=t}static parser(t,r){let n=r??(s=>he.reference(t,R.parse(M.readString(s)??"")));return s=>typeof s=="string"?s.startsWith("#")?he.reference(t.getTagRegistry(),R.parse(s.substring(1))):he.direct(new e([he.reference(t,R.parse(s))])):he.direct(new e(M.readArray(s,n)??[])??[])}static fromJson(t,r,n){let s=M.readObject(r)??{},i=M.readBoolean(s.replace)??!1,o=M.readArray(s.values,a=>{var l=!0,c="";if(typeof a=="string")c=a;else{let u=M.readObject(a)??{};l=M.readBoolean(u.required)??!1,c=M.readString(u.id)??""}return c.startsWith("#")?he.reference(t.getTagRegistry(),R.parse(c.substring(1)),l):he.reference(t,R.parse(c),l)})??[];return n&&!i&&t.getTagRegistry().has(n)&&o?.push(he.direct(t.getTagRegistry().get(n))),new e(o)}*getEntries(){for(let t of this.entries){let r=t.value();r!==void 0&&(r instanceof e?yield*r.getEntries():yield t)}}};var Gn=class e{id;count;components;constructor(t,r,n=new Map){this.id=t,this.count=r,this.components=n}getComponent(t,r){if(typeof t=="string"&&(t=R.parse(t)),this.components.has("!"+t.toString()))return;let n=this.components.get(t.toString());if(n)return n;if(r)return r.getItemComponents(this.id)?.get(t.toString())}hasComponent(t,r){return typeof t=="string"&&(t=R.parse(t)),this.components.has("!"+t.toString())?!1:this.components.has(t.toString())?!0:r?r.getItemComponents(this.id)?.has(t.toString()):!1}clone(){let t=new Map(this.components);return new e(this.id,this.count,t)}is(t){return typeof t=="string"?this.id.equals(R.parse(t)):t instanceof R?this.id.equals(t):this.id.equals(t.id)}equals(t){return this===t?!0:t instanceof e?this.count===t.count&&this.isSameItemSameComponents(t):!1}isSameItemSameComponents(t){if(!this.id.equals(t.id)||this.components.size!==t.components.size)return!1;for(let[r,n]of this.components){let s=t.components.get(r);if(n.toString()!==s?.toString())return!1}return!0}toString(){let t=this.id.toString();return this.components.size>0&&(t+=`[${[...this.components.entries()].map(([r,n])=>r.startsWith("!")?r:`${r}=${n.toString()}`).join(",")}]`),this.count>1&&(t+=` ${this.count}`),t}static fromString(t){let r=new ht(t);for(;r.canRead()&&r.peek()!=="[";)r.skip();let n=R.parse(r.getRead());if(!r.canRead())return new e(n,1);let s=new Map;if(r.skip(),r.peek()==="]")return new e(n,1,s);do{if(r.peek()==="!"){r.skip(),r.skipWhitespace();let i=r.cursor;for(;r.canRead()&&r.peek()!=="]"&&r.peek()!==",";)r.skip();s.set("!"+R.parse(r.getRead(i).trim()).toString(),new Re)}else{r.skipWhitespace();let i=r.cursor;for(;r.canRead()&&r.peek()!=="=";)r.skip();let o=R.parse(r.getRead(i).trim()).toString();if(!r.canRead())break;r.skip(),r.skipWhitespace();let a=Nr.readTag(r);s.set(o,a)}if(r.skipWhitespace(),!r.canRead())break;if(r.peek()==="]")return new e(n,1,s);if(r.peek()!==",")throw new Error("Expected , or ]");r.skip()}while(r.canRead());throw new Error("Missing closing ]")}toNbt(){let t=new Re().set("id",new We(this.id.toString()));return this.count>1&&t.set("count",new pt(this.count)),this.components.size>0&&t.set("components",new Re(this.components)),t}static fromNbt(t){let r=R.parse(t.getString("id")),n=t.hasNumber("count")?t.getNumber("count"):1,s=new Map(Object.entries(t.getCompound("components").map((i,o)=>i.startsWith("!")?["!"+R.parse(i).toString(),new Re]:[R.parse(i).toString(),o])));return new e(r,n,s)}};var $e=class e{key;parser;static REGISTRY=new e(R.create("root"));storage=new Map;builtin=new Map;tags=void 0;constructor(t,r){this.key=t,this.parser=r}static createAndRegister(t,r){let n=new e(R.create(t),r);return e.REGISTRY.register(n.key,n),n}register(t,r,n){return this.storage.set(t.toString(),r),n&&this.builtin.set(t.toString(),r),he.reference(this,t)}delete(t){let r=this.storage.delete(t.toString());return this.builtin.delete(t.toString()),r}keys(){return[...this.storage.keys()].map(t=>R.parse(t))}has(t){return this.storage.has(t.toString())}get(t){var r=this.storage.get(t.toString());return r instanceof Function&&(r=r(),this.storage.set(t.toString(),r)),r}getOrThrow(t){let r=this.get(t);if(r===void 0)throw new Error(`Missing key in ${this.key.toString()}: ${t.toString()}`);return r}parse(t){if(!this.parser)throw new Error(`No parser exists for ${this.key.toString()}`);return this.parser(t)}clear(){this.storage.clear();for(let[t,r]of this.builtin.entries())this.storage.set(t,r);return this.tags&&this.tags.clear(),this}assign(t){if(!this.key.equals(t.key))throw new Error(`Cannot assign registry of type ${t.key.toString()} to registry of type ${this.key.toString()}`);for(let r of t.keys())this.storage.set(r.toString(),t.getOrThrow(r));return this}cloneEmpty(){return new e(this.key,this.parser)}forEach(t){for(let[r,n]of this.storage.entries())t(R.parse(r),n instanceof Function?n():n,this)}map(t){return[...this.storage.entries()].map(([r,n])=>t(R.parse(r),n instanceof Function?n():n,this))}getTagRegistry(){return this.tags===void 0&&(this.tags=new e(new R(this.key.namespace,`tags/${this.key.path}`))),this.tags}};var He;(function(e){e.NONE="none",e.CLOCKWISE_90="clockwise_90",e.CLOCKWISE_180="180",e.COUNTERCLOCKWISE_90="counterclockwise_90"})(He=He||(He={}));(function(e){function t(r){return[e.NONE,e.CLOCKWISE_90,e.CLOCKWISE_180,e.COUNTERCLOCKWISE_90][r.nextInt(4)]}e.getRandom=t})(He=He||(He={}));var zr=class e{size;palette;blocks;static REGISTRY=$e.createAndRegister("structures");static EMPTY=new e(te.ZERO);blocksMap=[];constructor(t,r=[],n=[]){this.size=t,this.palette=r,this.blocks=n,n.forEach(s=>{if(!this.isInside(s.pos))throw new Error(`Found block at ${s.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[s.pos[0]*t[1]*t[2]+s.pos[1]*t[2]+s.pos[2]]=s})}getSize(){return this.size}addBlock(t,r,n,s){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);let i=new se(r,n),o=this.palette.findIndex(a=>a.equals(i));return o===-1&&(o=this.palette.length,this.palette.push(i)),this.blocks.push({pos:t,state:o,nbt:s}),this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]]={pos:t,state:o,nbt:s},this}getBlocks(){return this.blocks.map(t=>this.toPlacedBlock(t))}getBlock(t){if(!this.isInside(t))return null;let r=this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]];return r?this.toPlacedBlock(r):null}toPlacedBlock(t){let r=this.palette[t.state];if(!r)throw new Error(`Block at ${t.pos.join(" ")} in structure references invalid palette index ${t.state}`);return{pos:t.pos,state:r,nbt:t.nbt}}isInside(t){return t[0]>=0&&t[0]=0&&t[1]=0&&t[2]se.fromNbt(i)),s=t.getList("blocks",C.Compound).map(i=>{let o=te.fromNbt(i.getList("pos")),a=i.getNumber("state"),l=i.getCompound("nbt");return{pos:o,state:a,nbt:l.size>0?l:void 0}});return new e(r,n,s)}static transform(t,r,n){switch(r){case He.COUNTERCLOCKWISE_90:return te.create(n[0]-n[2]+t[2],t[1],n[0]+n[2]-t[0]);case He.CLOCKWISE_90:return te.create(n[0]+n[2]-t[2],t[1],n[2]-n[0]+t[0]);case He.CLOCKWISE_180:return te.create(n[0]+n[0]-t[0],t[1],n[2]+n[2]-t[2]);default:return t}}};var J=class e{min;max;static NaI=new e(NaN,NaN);static INFINITE=new e(-1/0,1/0);constructor(t,r){this.min=t,this.max=r}static of(t,r){return rn||t.isNaI()?e.NaI:t.min>=n?e.ofExact(n):t.max<=r?e.ofExact(r):e.of(Math.max(t.min,r),Math.min(t.max,n))}static abs(t){if(t.isNaI())return e.NaI;let r=Math.max(Math.abs(t.min),Math.abs(t.max));if(t.contains(0))return e.of(0,r);{let n=Math.min(Math.abs(t.min),Math.abs(t.max));return e.of(n,r)}}static square(t){if(t.isNaI())return e.NaI;let r=Math.max(t.min*t.min,t.max*t.max);if(t.contains(0))return e.of(0,r);{let n=Math.min(t.min*t.min,t.max*t.max);return e.of(n,r)}}static pow(t,r){if(t.isNaI()||r.isNaI())return e.NaI;if(t.min==t.max)return e.powNum(t.min,r);let n=e.encapsulating(e.powNum(t.min,r),e.powNum(t.max,r));return t.contains(0)&&(t.max>0&&(n=e.encapsulating(n,e.powNum(0,r))),t.min<0&&(n=e.encapsulating(n,e.powNum(-0,r)))),n}static powNum(t,r){return e.INFINITE}static log(t){if(t.max<0)return e.NaI;let r=e.max(t,e.ofExact(0));return e.mapMonotonic(r,Math.log)}static mapMonotonic(t,r){if(t.isNaI())return e.NaI;let n=r(t.min),s=r(t.max);return e.of(Math.min(n,s),Math.max(n,s))}static lerp(t,r,n){return t.isNaI()||r.isNaI()||n.isNaI()?e.NaI:e.encapsulating(e.lerpNums(t,r.min,n.min),e.lerpNums(t,r.max,n.min),e.lerpNums(t,r.min,n.max),e.lerpNums(t,r.max,n.max))}static lerpNums(t,r,n){if(t.isNaI()||isNaN(r)||isNaN(n))return e.NaI;if(isFinite(r)&&isFinite(n))return e.between(e.lerpFiniteBound(t.min,r,n),e.lerpFiniteBound(t.max,r,n));if(r===n)return e.ofExact(r);let s=e.lerpInfiniteBound(t.min,r,n),i=e.lerpInfiniteBound(t.max,r,n);return isNaN(s)||isNaN(i)?e.NaI:e.between(s,i)}static lerpFiniteBound(t,r,n){return r+e.mulBound(t,n-r)}static lerpInfiniteBound(t,r,n){let s=e.mulBound(1-t,r),i=e.mulBound(t,n);return isFinite(s)||isFinite(i)?s+i:t<=0?n>r?-1/0:1/0:t>=1?n>r?1/0:-1/0:NaN}static sign(t){return t.isNaI()?e.NaI:t.min===t.max?e.ofExact(Math.sign(t.min)):t.contains(0)?t.min===0?e.of(0,1):t.max===0?e.of(-1,0):e.of(-1,1):e.ofExact(t.min>0?1:-1)}contains(t){return this.min<=t&&t<=this.max}intersects(t){return this.min<=t.max&&t.min<=this.max}isNaI(){return this===e.NaI}};var cm=9223372036854776e3;function vt(e){return e*e}function Fe(e,t,r){return Math.max(t,Math.min(r,e))}function sn(e,t,r){return t+e*(r-t)}function Pr(e,t,r){return Math.fround(t+Math.fround(e*Math.fround(r-t)))}function qc(e,t,r,n,s,i){return sn(t,sn(e,r,n),sn(e,s,i))}function Jc(e,t,r,n,s,i,o,a,l,c,u){return sn(r,qc(e,t,n,s,i,o),qc(e,t,a,l,c,u))}function Li(e,t,r){return e===0?t():e===1?r():t()+e*(r()-t())}function Yc(e,t,r,n,s,i){return Li(t,()=>Li(e,r,n),()=>Li(e,s,i))}function jc(e,t,r,n,s,i,o,a,l,c,u){return Li(r,()=>Yc(e,t,n,s,i,o),()=>Yc(e,t,a,l,c,u))}function Qs(e,t,r){return e<0?t:e>1?r:sn(e,t,r)}function Uc(e,t,r){return(e-t)/(r-t)}function Ci(e){return e*e*e*(e*(e*6-15)+10)}function on(e,t,r,n,s){return sn(Uc(e,t,r),n,s)}function Gc(e,t,r,n,s){return Qs(Uc(e,t,r),n,s)}function je(e){return Fe(Math.floor(e),-2147483648,2147483647)}function Zc(e){return Fe(Math.floor(e),-9223372036854776e3,cm)}function Hc(e,t){return je(e/t)*t}function Wc(e,t,r){let n=t-e;for(;n>0;){let s=Math.floor(n/2),i=e+s;if(r(i)){n=s;continue}e=i+1,n-=s+1}return e}function Fi(e,t,r){let n=BigInt.asIntN(64,BigInt(e)*BigInt(3129871)^BigInt(r)*BigInt(116129781)^BigInt(t));return n=BigInt.asIntN(64,BigInt.asIntN(64,n*n*BigInt(42317861))+BigInt.asIntN(64,n*BigInt(11))),n>>BigInt(16)}function eo(e,t,r,n,s,i,o,a){return BigInt(e)<=r?t:e.nextInt(r-t+1)+t}function Xc(e,t){for(var r=e.length;r>1;r--){let n=t.nextInt(r),s=e[n];e[n]=e[r-1],e[r-1]=s}}function Vc(e){for(var t=0,r=0;tM.readObject(c)??{})??[];if(l.length===0)return new r(0);for(let c of l){let u=M.readNumber(c.location)??0,h=t(c.value,i),d=M.readNumber(c.derivative)??0;a.addPoint(u,h,d)}return a}e.fromJson=t;class r{value;constructor(i){this.value=i}compute(){return this.value}range(){return J.of(this.value,this.value)}mapCoordinates(){return this}}e.Constant=r;class n{coordinate;locations;values;derivatives;constructor(i,o=[],a=[],l=[]){this.coordinate=i,this.locations=o,this.values=a,this.derivatives=l}compute(i){let o=this.coordinate.compute(i),a=Wc(0,this.locations.length,v=>oo.mapCoordinates(i)),this.derivatives)}addPoint(i,o,a=0){return this.locations.push(Math.fround(i)),this.values.push(typeof o=="number"?new e.Constant(Math.fround(o)):o),this.derivatives.push(Math.fround(a)),this}range(){let i=this.locations.length-1;var o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;let l=this.coordinate.range();if(l.isNaI())return l;if(l.minthis.locations[i]){let h=this.values[i].range(),d=n.linearExtend(h.max,this.locations,h.min,this.derivatives,i),f=n.linearExtend(h.max,this.locations,h.max,this.derivatives,i);o=Math.min(o,Math.min(d,f)),a=Math.max(a,Math.max(d,f))}let c=this.values.map(h=>h.range());for(let h of c)o=Math.min(o,h.min),a=Math.max(a,h.max);for(var u=0;u=0&&t=0;l-=1)a.push({noise:new Ji(t,n*o),frequency:o,amplitude:s}),o/=2,s*=2;return new Br(a)}range(){return J.lerp(J.of(0,1),this.minLimitNoise.range(),this.maxLimitNoise.range())}sample(t,r,n){let s=t*this.xzMultiplier,i=r*this.yMultiplier,o=n*this.xzMultiplier,a=this.mainNoise.get3D(s/this.xzFactor,i/this.yFactor,o/this.xzFactor);return a=Fe(a+.5,0,1),a===0?this.minLimitNoise.get3D(s,i,o):a===1?this.maxLimitNoise.get3D(s,i,o):Pr(a,this.minLimitNoise.get3D(s,i,o),this.maxLimitNoise.get3D(s,i,o))}};var o2=["disabled","enabled","legacy"],Lr=class e{baseAmplitude;baseOctave;octaveCount;normalize;amplitudeModifiers;static INPUT_FACTOR=1.0181268882175227;static TARGET_DEVIATION=.3333333333333333;octaves;normalizationFactor;range;constructor(t,r,n,s,i){this.baseAmplitude=t,this.baseOctave=r,this.octaveCount=n,this.normalize=s,this.amplitudeModifiers=i,this.octaves=e.buildOctaves(t,r,n,s!="disabled",i);let o=this.octaves.reduce((l,c)=>l+Math.abs(c.amplitude),0),a=e.computeNormalizationFactor(o,this.octaves);if(s=="legacy"&&a!=0){let l=e.computeParityNormalizationFactor(t,n,i);o*=l/a,a=l}this.normalizationFactor=a,this.range=J.ofSymmetric(o*e.TARGET_DEVIATION*6)}create(t){let r=t.forkPositional(),n=t.forkPositional(),s=[];for(let i of this.octaves){let o=`octave_${i.index}`,a=new Xt(r.fromHashOf(o)),l=new Xt(n.fromHashOf(o)),c=this.normalizationFactor*i.amplitude;s.push({noise:a,frequency:i.frequency,amplitude:c}),s.push({noise:l,frequency:i.frequency*e.INPUT_FACTOR,amplitude:c})}return new Br(s)}createForLegacyNetherBiome(t){let r=this.amplitudeModifiers;r.length===0&&(r=Array(this.octaveCount).fill(1));let n=e.createLegacyNoiseLayers(t,this.baseOctave,r),s=e.createLegacyNoiseLayers(t,this.baseOctave,r),i=this.normalizationFactor*this.baseAmplitude;return new Br([...n.map(o=>({...o,amplitude:o.amplitude*i})),...s.map(o=>({...o,frequency:o.frequency*e.INPUT_FACTOR,amplitudes:o.amplitude*i}))])}static createLegacyNoiseLayers(t,r,n){let s=n.length,i=-r,o=Array(s).fill(void 0),a=new Xt(t);i>=0&&i=0;h-=1)hM.readNumber(s)??0)??[])}};var Ui=class e extends Te{static RANGE=J.ofSymmetric(2);static STANDARD_DEVIATION=.42544;static F2=.5*(Math.sqrt(3)-1);static G2=(3-Math.sqrt(3))/6;constructor(t,r){super(t,r?0:void 0)}range(){return e.RANGE}get2D(t,r){let n=t+this.offsetX,s=r+this.offsetY,i=(n+s)*e.F2,o=je(n+i),a=je(s+i),l=(o+a)*e.G2,c=n-(o-l),u=s-(a-l),h,d;c>u?(h=1,d=0):(h=0,d=1);let f=c-h+e.G2,m=u-d+e.G2,p=c-1+2*e.G2,g=u-1+2*e.G2,w=o&255,x=a&255,v=this.permute(w+this.permute(x))%12,y=this.permute(w+h+this.permute(x+d))%12,I=this.permute(w+1+this.permute(x+1))%12,b=this.getCornerNoise3D(v,c,u,0,.5),k=this.getCornerNoise3D(y,f,m,0,.5),E=this.getCornerNoise3D(I,p,g,0,.5);return 70*(b+k+E)}get3D(t,r,n){let s=t+this.offsetX,i=r+this.offsetY,o=n+this.offsetZ,a=(s+i+o)*.3333333333333333,l=je(s+a),c=je(i+a),u=je(o+a),h=(l+c+u)*.16666666666666666,d=s-(l-h),f=i-(c-h),m=o-(u-h),p,g,w,x,v,y;d>=f?f>=m?(p=1,g=0,w=0,x=1,v=1,y=0):d>=m?(p=1,g=0,w=0,x=1,v=0,y=1):(p=0,g=0,w=1,x=1,v=0,y=1):f>BigInt(e.MODULUS_BITS-t));return r>2147483647?r-4294967296:r}nextInt(t){if(t===void 0)return this.next(32);if((t&t-1)==0)return Number(BigInt(t)*BigInt(this.next(31))>>BigInt(31));let r,n;for(;(r=this.next(31))-(n=r%t)+(t-1)<0;);return n}nextLong(){return(BigInt(this.next(32))<>e.BIGINT_30)*e.STAFFORD_1&e.MAX_ULONG,t=(t^t>>e.BIGINT_27)*e.STAFFORD_2&e.MAX_ULONG,(t^t>>e.BIGINT_31)&e.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=e.POW2_60);let r=t^e.SILVER_RATIO_64,n=r+e.GOLDEN_RATIO_64&e.MAX_ULONG;return[e.mixStafford13(r),e.mixStafford13(n)]}static rotateLeft(t,r){return t<>e.BIGINT_64-r}setSeed(t){this.seed=e.upgradeSeedTo128bit(t)}fork(){return new e([this.next(),this.next()])}forkPositional(){return new Mo(this.next(),this.next())}next(){let t=this.seed[0],r=this.seed[1],n=e.rotateLeft(t+r&e.MAX_ULONG,e.BIGINT_17)+t&e.MAX_ULONG;return r^=t,this.seed=[e.rotateLeft(t,e.BIGINT_49)^r^r<e.POW2_63&&(t-=e.POW2_60),t}consume(t){let r=this.seed[0],n=this.seed[1];for(let s=0;s>BigInt(64-t)}nextInt(t){let r=this.next()&e.MAX_UINT;if(t){let n=BigInt(t),s=r*n,i=s&e.MAX_UINT;if(i>e.BIGINT_32;return Number(o)}else{let n=Number(r);return n>=2147483648&&(n-=4294967296),n}}nextFloat(){return Number(this.nextBits(24))*e.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*e.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}},Mo=class{seedLo;seedHi;constructor(t,r){this.seedLo=t,this.seedHi=r}at(t,r,n){let i=Fi(t,r,n)^this.seedLo;return new an([i,this.seedHi])}fromHashOf(t){let r=(0,uu.default)(t,{asBytes:!0}),n=eo(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7]),s=eo(r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15]);return new an([n^this.seedLo,s^this.seedHi])}seedKey(){return[this.seedLo,this.seedHi]}};var _t=[124/255,189/255,107/255],c2=re.intToRgb(6396257),l2=re.intToRgb(8431445),cn=re.intToRgb(4764952),Gi=re.intToRgb(4159204),u2=re.intToRgb(2129968),f2=e=>{let t=e/15,r=t*.6+(t>0?.4:.3),n=Fe(t*t*.7-.5,0,1),s=Fe(t*t*.6-.7,0,1);return[r,n,s]},Zi=e=>[e/8,1-e/32,e/64],So={large_fern:()=>_t,tall_grass:()=>_t,grass_block:()=>_t,fern:()=>_t,grass:()=>_t,short_grass:()=>_t,potted_fern:()=>_t,pink_petals:()=>_t,wildflowers:()=>_t,bush:()=>_t,spruce_leaves:()=>c2,birch_leaves:()=>l2,oak_leaves:()=>cn,jungle_leaves:()=>cn,acacia_leaves:()=>cn,dark_oak_leaves:()=>cn,vine:()=>cn,mangrove_leaves:()=>cn,water:()=>Gi,bubble_column:()=>Gi,cauldron:()=>Gi,water_cauldron:()=>Gi,redstone_wire:e=>f2(parseInt(e.power??"0")),sugar_cane:()=>_t,attached_melon_stem:()=>Zi(7),attached_pumpkin_stem:()=>Zi(7),melon_stem:e=>Zi(parseInt(e.age??"0")),pumpkin_stem:e=>Zi(parseInt(e.age??"0")),lily_pad:()=>u2};var we;(function(e){function t(n,s,i){let{up:o,down:a,north:l,east:c,south:u,west:h}=n;switch(i){case 90:[l,c,u,h]=[c,u,h,l];break;case 180:[l,c,u,h]=[u,h,l,c];break;case 270:[l,c,u,h]=[h,l,c,u]}switch(s){case 90:[o,l,a,u]=[l,a,u,o];break;case 180:[o,l,a,u]=[a,u,o,l];break;case 270:[o,l,a,u]=[u,o,l,a]}return{up:o,down:a,north:l,east:c,south:u,west:h}}e.rotate=t;function r(){return Object.create(null)}e.none=r})(we=we||(we={}));var ko=dr(Or(),1);var ut=class e{pos;color;texture;textureLimit;normal;blockPos;static VEC=ko.vec3.create();constructor(t,r,n,s,i,o){this.pos=t,this.color=r,this.texture=n,this.textureLimit=s,this.normal=i,this.blockPos=o}transform(t){return e.VEC[0]=this.pos.x,e.VEC[1]=this.pos.y,e.VEC[2]=this.pos.z,ko.vec3.transformMat4(e.VEC,e.VEC,t),this.pos=new Ue(e.VEC[0],e.VEC[1],e.VEC[2]),this}static fromPos(t){return new e(t,[0,0,0],[0,0],[0,0,0,0],void 0,void 0)}};var Hi=class e{v1;v2;constructor(t,r){this.v1=t,this.v2=r}vertices(){return[this.v1,this.v2]}forEach(t){return t(this.v1),t(this.v2),this}transform(t){return this.forEach(r=>r.transform(t)),this}setColor(t){return this.forEach(r=>r.color=t),this}toString(){return`Line(${this.v1.pos.toString()}, ${this.v2.pos.toString()})`}static fromPoints(t,r){return new e(ut.fromPos(t),ut.fromPos(r))}};var _e=class{quads;lines;posBuffer;colorBuffer;textureBuffer;textureLimitBuffer;normalBuffer;blockPosBuffer;indexBuffer;linePosBuffer;lineColorBuffer;constructor(t=[],r=[]){this.quads=t,this.lines=r}clear(){return this.quads=[],this.lines=[],this}isEmpty(){return this.quads.length===0&&this.lines.length===0}quadVertices(){return this.quads.length*4}quadIndices(){return this.quads.length*6}lineVertices(){return this.lines.length*2}merge(t){return this.quads=this.quads.concat(t.quads),this.lines=this.lines.concat(t.lines),this}addLine(t,r,n,s,i,o,a){let l=new Hi(ut.fromPos(new Ue(t,r,n)),ut.fromPos(new Ue(s,i,o))).setColor(a);return this.lines.push(l),this}addLineCube(t,r,n,s,i,o,a){return this.addLine(t,r,n,t,r,o,a),this.addLine(s,r,n,s,r,o,a),this.addLine(t,r,n,s,r,n,a),this.addLine(t,r,o,s,r,o,a),this.addLine(t,r,n,t,i,n,a),this.addLine(s,r,n,s,i,n,a),this.addLine(t,r,o,t,i,o,a),this.addLine(s,r,o,s,i,o,a),this.addLine(t,i,n,t,i,o,a),this.addLine(s,i,n,s,i,o,a),this.addLine(t,i,n,s,i,n,a),this.addLine(t,i,o,s,i,o,a),this}transform(t){for(let r of this.quads)r.transform(t);return this}computeNormals(){for(let t of this.quads){let r=t.normal();t.forEach(n=>n.normal=r)}}rebuild(t,r){let n=(i,o,a)=>{if(i||(i=t.createBuffer()??void 0),!i)throw new Error("Cannot create new buffer");return t.bindBuffer(o,i),t.bufferData(o,a,t.DYNAMIC_DRAW),i},s=(i,o,a)=>{if(i.length===0){o&&t.deleteBuffer(o);return}let l=i.flatMap(c=>c.vertices().flatMap(u=>{let h=a(u);if(!h)throw new Error("Missing vertex component");return h}));return n(o,t.ARRAY_BUFFER,new Float32Array(l))};return r.pos&&(this.posBuffer=s(this.quads,this.posBuffer,i=>i.pos.components()),this.linePosBuffer=s(this.lines,this.linePosBuffer,i=>i.pos.components())),r.color&&(this.colorBuffer=s(this.quads,this.colorBuffer,i=>i.color),this.lineColorBuffer=s(this.lines,this.lineColorBuffer,i=>i.color)),r.texture&&(this.textureBuffer=s(this.quads,this.textureBuffer,i=>i.texture),this.textureLimitBuffer=s(this.quads,this.textureLimitBuffer,i=>i.textureLimit)),r.normal&&(this.normalBuffer=s(this.quads,this.normalBuffer,i=>i.normal?.components())),r.blockPos&&(this.blockPosBuffer=s(this.quads,this.blockPosBuffer,i=>i.blockPos?.components())),this.quads.length===0?(this.indexBuffer&&t.deleteBuffer(this.indexBuffer),this.indexBuffer=void 0):this.indexBuffer=n(this.indexBuffer,t.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.quads.flatMap((i,o)=>[4*o,4*o+1,4*o+2,o*4,4*o+2,4*o+3],!0))),this}};var De=dr(Or(),1);var Wn=class e{v1;v2;v3;v4;constructor(t,r,n,s){this.v1=t,this.v2=r,this.v3=n,this.v4=s}vertices(){return[this.v1,this.v2,this.v3,this.v4]}forEach(t){return t(this.v1),t(this.v2),t(this.v3),t(this.v4),this}transform(t){return this.forEach(r=>r.transform(t)),this}normal(){let t=this.v2.pos.sub(this.v1.pos),r=this.v3.pos.sub(this.v1.pos);return t.cross(r).normalize()}reverse(){return[this.v1,this.v2,this.v3,this.v4]=[this.v4,this.v3,this.v2,this.v1],this}setColor(t){return this.forEach(r=>r.color=t),this}setTexture(t,r){return this.v1.textureLimit=r,this.v2.textureLimit=r,this.v3.textureLimit=r,this.v4.textureLimit=r,this.v1.texture=[t[0],t[1]],this.v2.texture=[t[2],t[3]],this.v3.texture=[t[4],t[5]],this.v4.texture=[t[6],t[7]],this}toString(){return`Quad(${this.v1.pos.toString()}, ${this.v2.pos.toString()}, ${this.v3.pos.toString()}, ${this.v4.pos.toString()})`}static fromPoints(t,r,n,s){return new e(ut.fromPos(t),ut.fromPos(r),ut.fromPos(n),ut.fromPos(s))}};var h2={0:[0,3,2,3,2,1,0,1],90:[2,3,2,1,0,1,0,3],180:[2,1,0,1,0,3,2,3],270:[0,1,0,3,2,3,2,1]},d2={x:[1,0,0],y:[0,1,0],z:[0,0,1]},ln=1.41421356237,m2={x:[1,ln,ln],y:[ln,1,ln],z:[ln,ln,1]},Me=class e{parent;textures;elements;display;guiLight;static BUILTIN_GENERATED=R.create("builtin/generated");static GENERATED_LAYERS=["layer0","layer1","layer2","layer3","layer4"];generationMarker=!1;constructor(t,r,n,s,i){this.parent=t,this.textures=r,this.elements=n,this.display=s,this.guiLight=i}getDisplayTransform(t){let r=this.display?.[t],n=De.mat4.create();return De.mat4.translate(n,n,[8,8,8]),r?.translation&&De.mat4.translate(n,n,r.translation),r?.rotation&&(De.mat4.rotateX(n,n,r.rotation[0]*Math.PI/180),De.mat4.rotateY(n,n,r.rotation[1]*Math.PI/180),De.mat4.rotateZ(n,n,-r.rotation[2]*Math.PI/180)),r?.scale&&De.mat4.scale(n,n,r.scale),De.mat4.translate(n,n,[-8,-8,-8]),n}getMesh(t,r,n){let s=new _e,i=o=>n===void 0?[1,1,1]:o===void 0||o<0?[1,1,1]:typeof n=="function"?n(o):n;for(let o of this.elements??[])s.merge(this.getElementMesh(o,t,r,i));return s}getElementMesh(t,r,n,s){let i=new _e,[o,a,l]=t.from,[c,u,h]=t.to,d=(m,p,g)=>{let w=Wn.fromPoints(new Ue(g[0],g[1],g[2]),new Ue(g[3],g[4],g[5]),new Ue(g[6],g[7],g[8]),new Ue(g[9],g[10],g[11])),x=s(m.tintindex);w.setColor(x);let[v,y,I,b]=r.getTextureUV(this.getTexture(m.texture)),k=(I-v)/16,E=(b-y)/16;p[0]=(m.uv?.[0]??p[0])*k,p[1]=(m.uv?.[1]??p[1])*E,p[2]=(m.uv?.[2]??p[2])*k,p[3]=(m.uv?.[3]??p[3])*E;let A=h2[m.rotation??0];w.setTexture([v+p[A[0]],y+p[A[1]],v+p[A[2]],y+p[A[3]],v+p[A[4]],y+p[A[5]],v+p[A[6]],y+p[A[7]]],[v+Math.min(p[0],p[2]),y+Math.min(p[1],p[3]),v+Math.max(p[0],p[2]),y+Math.max(p[1],p[3])]),i.quads.push(w)};t.faces?.up?.texture&&(!t.faces.up.cullface||!n[t.faces.up.cullface])&&d(t.faces.up,[o,16-h,c,16-l],[o,u,h,c,u,h,c,u,l,o,u,l]),t.faces?.down?.texture&&(!t.faces.down.cullface||!n[t.faces.down.cullface])&&d(t.faces.down,[16-h,16-c,16-l,16-o],[o,a,l,c,a,l,c,a,h,o,a,h]),t.faces?.south?.texture&&(!t.faces.south.cullface||!n[t.faces.south.cullface])&&d(t.faces.south,[o,16-u,c,16-a],[o,a,h,c,a,h,c,u,h,o,u,h]),t.faces?.north?.texture&&(!t.faces.north.cullface||!n[t.faces.north.cullface])&&d(t.faces.north,[16-c,16-u,16-o,16-a],[c,a,l,o,a,l,o,u,l,c,u,l]),t.faces?.east?.texture&&(!t.faces.east.cullface||!n[t.faces.east.cullface])&&d(t.faces.east,[16-h,16-u,16-l,16-a],[c,a,h,c,a,l,c,u,l,c,u,h]),t.faces?.west?.texture&&(!t.faces.west.cullface||!n[t.faces.west.cullface])&&d(t.faces.west,[l,16-u,h,16-a],[o,a,l,o,a,h,o,u,h,o,u,l]);let f=De.mat4.create();if(t.rotation){let m=De.vec3.fromValues(...t.rotation.origin);De.mat4.translate(f,f,m),De.mat4.rotate(f,f,De.glMatrix.toRadian(t.rotation.angle),d2[t.rotation.axis]),t.rotation.rescale&&De.mat4.scale(f,f,m2[t.rotation.axis]),De.vec3.negate(m,m),De.mat4.translate(f,f,m)}return i.transform(f)}getTexture(t){for(t=t.startsWith("#")?t.slice(1):t,t=this.resolveTextureRef(t);t.startsWith("#");)t=this.resolveTextureRef(t.slice(1));return R.parse(t)}resolveTextureRef(t){let r=this.textures?.[t];return typeof r=="object"&&r!==null?r.sprite:r??""}flatten(t){if(!this.parent)return;if(this.parent.equals(e.BUILTIN_GENERATED)){this.generationMarker=!0;return}let r=this.getParent(t);if(!r){console.warn(`parent ${this.parent} does not exist!`),this.parent=void 0;return}if(r.flatten(t),this.elements||(this.elements=r.elements),this.textures||(this.textures={}),Object.keys(r.textures??{}).forEach(n=>{this.textures[n]||(this.textures[n]=r.textures[n])}),this.display||(this.display={}),Object.keys(r.display??{}).forEach(n=>{let s=n;this.display[s]?Object.keys(r.display[s]??{}).forEach(i=>{let o=i;this.display[s][o]||(this.display[s][o]=r.display[s][o])}):this.display[s]=r.display[s]}),this.guiLight||(this.guiLight=r.guiLight),r.generationMarker&&(this.generationMarker=!0),this.generationMarker&&(this.elements?.length??0)===0)for(let n=0;nnew Me(void 0,{0:T.withPrefix("entity/chest/").toString()},[{from:[1,0,1],to:[15,10,15],faces:{north:{uv:[10.5,8.25,14,10.75],rotation:180,texture:"#0"},east:{uv:[7,8.25,10.5,10.75],rotation:180,texture:"#0"},south:{uv:[3.5,8.25,7,10.75],rotation:180,texture:"#0"},west:{uv:[0,8.25,3.5,10.75],rotation:180,texture:"#0"},up:{uv:[7,4.75,10.5,8.25],texture:"#0"},down:{uv:[3.5,4.75,7,8.25],texture:"#0"}}},{from:[1,10,1],to:[15,14,15],faces:{north:{uv:[10.5,3.75,14,4.75],rotation:180,texture:"#0"},east:{uv:[7,3.75,10.5,4.75],rotation:180,texture:"#0"},south:{uv:[3.5,3.75,7,4.75],rotation:180,texture:"#0"},west:{uv:[0,3.75,3.5,4.75],rotation:180,texture:"#0"},up:{uv:[7,0,10.5,3.5],texture:"#0"},down:{uv:[3.5,0,7,3.5],texture:"#0"}}},{from:[7,7,0],to:[9,11,2],faces:{north:{uv:[.25,.25,.75,1.25],rotation:180,texture:"#0"},east:{uv:[0,.25,.25,1.25],rotation:180,texture:"#0"},south:{uv:[1,.25,1.5,1.25],rotation:180,texture:"#0"},west:{uv:[.75,.25,1,1.25],rotation:180,texture:"#0"},up:{uv:[.25,0,.75,.25],rotation:180,texture:"#0"},down:{uv:[.75,0,1.25,.25],rotation:180,texture:"#0"}}}]).getMesh(B,we.none())}e.chestRenderer=t;function r(T){return new Me(void 0,{0:"entity/decorated_pot/decorated_pot_side",1:"entity/decorated_pot/decorated_pot_base"},[{from:[1,0,1],to:[15,16,15],faces:{north:{uv:[1,0,15,16],texture:"#0"},east:{uv:[1,0,15,16],texture:"#0"},south:{uv:[1,0,15,16],texture:"#0"},west:{uv:[1,0,15,16],texture:"#0"},up:{uv:[0,6.5,7,13.5],texture:"#1"},down:{uv:[7,6.5,14,13.5],texture:"#1"}}},{from:[5,16,5],to:[11,17,11],faces:{north:{uv:[0,5.5,3,6],texture:"#1"},east:{uv:[3,5.5,6,6],texture:"#1"},south:{uv:[6,5.5,9,6],texture:"#1"},west:{uv:[9,5.5,12,6],texture:"#1"}}},{from:[4,17,4],to:[12,20,12],faces:{north:{uv:[0,4,4,5.5],texture:"#1"},east:{uv:[4,4,8,5.5],texture:"#1"},south:{uv:[8,4,12,5.5],texture:"#1"},west:{uv:[12,4,16,5.5],texture:"#1"},up:{uv:[4,0,8,4],texture:"#1"},down:{uv:[8,0,12,4],texture:"#1"}}}]).getMesh(T,we.none())}e.decoratedPotRenderer=r;let n=T=>({south:{uv:[.5,.5,3,5.5],texture:`#${T}`,tintindex:T}});function s(T,B){let D=Q=>({from:[-5,-10,-.99],to:[5,10,-.99],faces:n(Q)}),ie={0:"entity/shield/shield_base_nopattern"},ee=[{from:[-6,-11,-2],to:[6,11,-1],faces:{north:{uv:[3.5,.25,6.5,5.75],texture:"#0"},east:{uv:[3.25,.25,3.5,5.75],texture:"#0"},south:{uv:[.25,.25,3.25,5.75],texture:"#0"},west:{uv:[0,.25,.25,5.75],texture:"#0"},up:{uv:[.25,0,3.25,.25],texture:"#0"},down:{uv:[3.25,0,6.25,.25],texture:"#0"}}}],de=[""];return B?.forEach((Q,_)=>{ie[_+1]=`entity/shield/${Q.pattern}`,ee.push(D(_+1)),de.push(Q.color)}),new Me(void 0,ie,ee).getMesh(T,we.none(),Q=>un[de[Q]??""]??[1,1,1])}e.shieldRenderer=s;function i(T,B){return D=>new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[4,0,4],to:[12,8,12],faces:{north:{uv:[6,2*B,8,4*B],texture:"#0"},east:{uv:[2,2*B,0,4*B],texture:"#0"},south:{uv:[2,2*B,4,4*B],texture:"#0"},west:{uv:[6,2*B,4,4*B],texture:"#0"},up:{uv:[2,0*B,4,2*B],texture:"#0"},down:{uv:[4,0*B,6,2*B],texture:"#0"}}}]).getMesh(D,we.none())}e.headRenderer=i;function o(T=R.create("enderdragon/dragon")){return B=>{let D=P.mat4.create();return P.mat4.translate(D,D,[8,8,8]),P.mat4.scale(D,D,[.75,.75,.75]),P.mat4.rotateY(D,D,Math.PI),P.mat4.translate(D,D,[-8,-11.2,-8]),new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[2,4,-16],to:[14,9,0],faces:{north:{uv:[12,3.75,12.75,4.0625],texture:"#0"},east:{uv:[11,3.75,12,4.0625],texture:"#0"},south:{uv:[13.75,3.75,14.5,4.0625],texture:"#0"},west:{uv:[12.75,3.75,13.75,4.0625],texture:"#0"},up:{uv:[12.75,3.75,12,2.75],texture:"#0"},down:{uv:[13.5,2.75,12.75,3.75],texture:"#0"}}},{from:[0,0,-2],to:[16,16,14],faces:{north:{uv:[8,2.875,9,3.875],texture:"#0"},east:{uv:[7,2.875,8,3.875],texture:"#0"},south:{uv:[10,2.875,11,3.875],texture:"#0"},west:{uv:[9,2.875,10,3.875],texture:"#0"},up:{uv:[9,2.875,8,1.875],texture:"#0"},down:{uv:[10,1.875,9,2.875],texture:"#0"}}},{from:[2,0,-16],to:[14,4,0],rotation:{angle:-.2*180/Math.PI,axis:"x",origin:[8,4,-2]},faces:{north:{uv:[12,5.0625,12.75,5.3125],texture:"#0"},east:{uv:[11,5.0625,12,5.3125],texture:"#0"},south:{uv:[13.75,5.0625,14.5,5.3125],texture:"#0"},west:{uv:[12.75,5.0625,13.75,5.3125],texture:"#0"},up:{uv:[12.75,5.0625,12,4.0625],texture:"#0"},down:{uv:[13.5,4.0625,12.75,5.0625],texture:"#0"}}},{from:[3,16,4],to:[5,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[11,16,4],to:[13,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[3,9,-14],to:[5,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}},{from:[11,9,-14],to:[13,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}}]).getMesh(B,we.none()).transform(D)}}e.dragonHeadRenderer=o;function a(T=R.create("piglin/piglin")){return B=>new Me(void 0,{0:T.withPrefix("entity/").toString()},[{from:[3,0,4],to:[13,8,12],faces:{north:{uv:[6.5,2,9,4],texture:"#0"},east:{uv:[2,2,0,4],texture:"#0"},south:{uv:[2,2,4.5,4],texture:"#0"},west:{uv:[6.5,2,4.5,4],texture:"#0"},up:{uv:[2,0,4.5,2],texture:"#0"},down:{uv:[4.5,0,7,2],texture:"#0"}}},{from:[6,0,12],to:[10,4,13],faces:{north:{uv:[9.25,.5,10.25,1.5],texture:"#0"},east:{uv:[7.75,.5,8,1.5],texture:"#0"},south:{uv:[8,.5,9,1.5],texture:"#0"},west:{uv:[9,.5,9.25,1.5],texture:"#0"},up:{uv:[8,.25,9,.5],texture:"#0"},down:{uv:[9,.25,10,.5],texture:"#0"}}},{from:[5,0,12],to:[6,2,13],faces:{north:{uv:[1.25,.25,1.5,.75],texture:"#0"},east:{uv:[.5,.25,.75,.75],texture:"#0"},south:{uv:[.75,.25,1,.75],texture:"#0"},west:{uv:[1,.25,1.25,.75],texture:"#0"},up:{uv:[.75,0,1,.25],texture:"#0"},down:{uv:[1,0,1.25,.25],texture:"#0"}}},{from:[10,0,12],to:[11,2,13],faces:{north:{uv:[1.25,1.25,1.5,1.75],texture:"#0"},east:{uv:[.5,1.25,.75,1.75],texture:"#0"},south:{uv:[.75,1.25,1,1.75],texture:"#0"},west:{uv:[1,1.25,1.25,1.75],texture:"#0"},up:{uv:[.75,1,1,1.25],texture:"#0"},down:{uv:[1,1,1.25,1.25],texture:"#0"}}},{from:[2.5,1.5,6],to:[3.5,6.5,10],rotation:{angle:-30,axis:"z",origin:[3,7,8]},faces:{north:{uv:[12,2.5,12.25,3.75],texture:"#0"},east:{uv:[9.75,2.5,10.75,3.75],texture:"#0"},south:{uv:[10.75,2.5,11,3.75],texture:"#0"},west:{uv:[11,2.5,12,3.75],texture:"#0"},up:{uv:[10.75,1.5,11,2.5],texture:"#0"},down:{uv:[11,1.5,11.25,2.5],texture:"#0"}}},{from:[12.5,1.5,6],to:[13.5,6.5,10],rotation:{angle:30,axis:"z",origin:[13,7,8]},faces:{north:{uv:[15.25,2.5,15,3.75],texture:"#0"},east:{uv:[15,2.5,14,3.75],texture:"#0"},south:{uv:[14,2.5,13.75,3.75],texture:"#0"},west:{uv:[13.75,2.5,12.75,3.75],texture:"#0"},up:{uv:[14,1.5,13.75,2.5],texture:"#0"},down:{uv:[14.25,1.5,14,2.5],texture:"#0"}}}]).getMesh(B,we.none())}e.piglinHeadRenderer=a;function l(T){return B=>new Me(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,8,7],to:[20,20,9],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}},{from:[7,-6,7],to:[9,8,9],faces:{north:{uv:[.5,8,1,15],texture:"#0"},east:{uv:[0,8,.5,15],texture:"#0"},south:{uv:[1.5,8,2,15],texture:"#0"},west:{uv:[1,8,1.5,15],texture:"#0"},up:{uv:[1,8,.5,7],texture:"#0"},down:{uv:[1.5,7,1,8],texture:"#0"}}}]).getMesh(B,we.none())}e.signRenderer=l;function c(T){return B=>new Me(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,4,17],to:[20,16,19],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}}]).getMesh(B,we.none())}e.wallSignRenderer=c;function u(T){return(B,D)=>B?new Me(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[2,10,8],to:[14,16,8],faces:{north:{uv:[3.5,3,6.5,6],texture:"#0"},south:{uv:[3.5,3,6.5,6],texture:"#0"}}}]).getMesh(D,we.none()):new Me(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).getMesh(D,we.none())}e.hangingSignRenderer=u;function h(T){return B=>new Me(void 0,{0:`entity/signs/hanging/${T}`},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[0,14,6],to:[16,16,10],faces:{north:{uv:[1,2,5,3],texture:"#0"},east:{uv:[0,2,1,3],texture:"#0"},south:{uv:[6,2,10,3],texture:"#0"},west:{uv:[5,2,6,3],texture:"#0"},up:{uv:[5,2,1,0],texture:"#0"},down:{uv:[9,0,5,2],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).getMesh(B,we.none())}e.wallHangingSignRenderer=h;function d(T){return new Me(void 0,{0:"entity/conduit/base"},[{from:[5,5,5],to:[11,11,11],faces:{north:{uv:[3,6,6,12],texture:"#0"},east:{uv:[0,6,3,12],texture:"#0"},south:{uv:[9,6,12,12],texture:"#0"},west:{uv:[6,6,9,12],texture:"#0"},up:{uv:[6,6,3,0],texture:"#0"},down:{uv:[9,0,6,6],texture:"#0"}}}]).getMesh(T,we.none())}e.conduitRenderer=d;function f(T){return B=>new Me(void 0,{0:T.withPrefix("entity/shulker/").toString()},[{from:[0,0,0],to:[16,8,16],faces:{north:{uv:[4,11,8,13],texture:"#0"},east:{uv:[0,11,4,13],texture:"#0"},south:{uv:[12,11,16,13],texture:"#0"},west:{uv:[8,11,12,13],texture:"#0"},up:{uv:[8,11,4,7],texture:"#0"},down:{uv:[12,7,8,11],texture:"#0"}}},{from:[0,4,0],to:[16,16,16],faces:{north:{uv:[4,4,8,7],texture:"#0"},east:{uv:[0,4,4,7],texture:"#0"},south:{uv:[12,4,16,7],texture:"#0"},west:{uv:[8,4,12,7],texture:"#0"},up:{uv:[8,4,4,0],texture:"#0"},down:{uv:[12,0,8,4],texture:"#0"}}}]).getMesh(B,we.none())}e.shulkerBoxRenderer=f;let m=T=>({north:{uv:[.25,.25,5.25,10.25],texture:`#${T}`,tintindex:T},east:{uv:[0,.25,.25,10.25],texture:`#${T}`,tintindex:T},south:{uv:[5.5,.25,10.5,10.25],texture:`#${T}`,tintindex:T},west:{uv:[5.25,.25,5.5,10.25],texture:`#${T}`,tintindex:T},up:{uv:[5.25,.25,.25,0],texture:`#${T}`,tintindex:T},down:{uv:[10.25,0,5.25,.25],texture:`#${T}`,tintindex:T}});function p(T,B){return(D,ie)=>{let ee={0:"entity/banner/banner_base"},de=[...B.base],Q=[T];return ie?.forEach((_,S)=>{let O=R.parse(_.getString("pattern")).path,U=_.getString("color");S++,ee[S]=`entity/banner/${O}`,de.push(B.pattern(S)),Q.push(U)}),new Me(void 0,ee,de).getMesh(D,we.none(),_=>un[Q[_]])}}e.bannerRenderer=T=>p(T,{base:[{from:[-2,-8,6],to:[18,32,7],faces:m(0)},{from:[7,-12,7],to:[9,30,9],faces:{north:{uv:[11.5,.5,12,11],texture:"#0"},east:{uv:[11,.5,11.5,11],texture:"#0"},south:{uv:[12.5,.5,13,11],texture:"#0"},west:{uv:[12,.5,12.5,11],texture:"#0"},up:{uv:[12,.5,11.5,0],texture:"#0"},down:{uv:[12.5,0,12,.5],texture:"#0"}}},{from:[-2,30,7],to:[18,32,9],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}],pattern:B=>({from:[-2,-8,6],to:[18,32,7],faces:m(B)})}),e.wallBannerRenderer=T=>p(T,{base:[{from:[-2,-8,-1.5],to:[18,32,-.5],faces:m(0)},{from:[-2,30,-3.5],to:[18,32,-1.5],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}],pattern:B=>({from:[-2,-8,-1.5],to:[18,32,-.5],faces:m(B)})});function g(T){return new Me(void 0,{0:"entity/bell/bell_body"},[{from:[5,3,5],to:[11,10,11],faces:{north:{uv:[3,3,6,6.5],texture:"#0"},east:{uv:[0,3,3,6.5],texture:"#0"},south:{uv:[9,3,12,6.5],texture:"#0"},west:{uv:[6,3,9,6.5],texture:"#0"},up:{uv:[6,3,3,0],texture:"#0"},down:{uv:[9,0,6,3],texture:"#0"}}},{from:[4,10,4],to:[12,12,12],faces:{north:{uv:[4,10.5,8,11.5],texture:"#0"},east:{uv:[0,10.5,4,11.5],texture:"#0"},south:{uv:[12,10.5,16,11.5],texture:"#0"},west:{uv:[8,10.5,12,11.5],texture:"#0"},up:{uv:[8,10.5,4,6.5],texture:"#0"},down:{uv:[12,6.5,8,10.5],texture:"#0"}}}]).getMesh(T,we.none())}e.bellRenderer=g;function w(T){return(B,D)=>B==="foot"?new Me(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{north:{uv:[5.5,5.5,9.5,7],rotation:180,texture:"#0"},east:{uv:[0,7,1.5,11],rotation:270,texture:"#0"},west:{uv:[5.5,7,7,11],rotation:90,texture:"#0"},up:{uv:[5.5,11,1.5,7],texture:"#0"},down:{uv:[11,7,7,11],texture:"#0"}}},{from:[0,0,0],to:[3,3,3],faces:{north:{uv:[12.5,5.25,13.25,6],texture:"#0"},east:{uv:[14.75,5.25,15.5,6],texture:"#0"},south:{uv:[14,5.25,14.75,6],texture:"#0"},west:{uv:[13.25,5.25,14,6],texture:"#0"},up:{uv:[13.25,4.5,14,5.25],texture:"#0"},down:{uv:[14,4.5,14.75,5.25],texture:"#0"}}},{from:[13,0,0],to:[16,3,3],faces:{north:{uv:[13.25,3.75,14,4.5],texture:"#0"},east:{uv:[12.5,3.75,13.25,4.5],texture:"#0"},south:{uv:[14.75,3.75,15.5,4.5],texture:"#0"},west:{uv:[14,3.75,14.75,4.5],texture:"#0"},up:{uv:[13.25,3,14,3.75],texture:"#0"},down:{uv:[14,3,14.75,3.75],texture:"#0"}}}]).getMesh(D,we.none()):new Me(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{east:{uv:[0,1.5,1.5,5.5],rotation:270,texture:"#0"},south:{uv:[1.5,0,5.5,1.5],rotation:180,texture:"#0"},west:{uv:[5.5,1.5,7,5.5],rotation:90,texture:"#0"},up:{uv:[5.5,5.5,1.5,1.5],texture:"#0"},down:{uv:[11,1.5,7,5.5],texture:"#0"}}},{from:[0,0,13],to:[3,3,16],faces:{north:{uv:[14.75,.75,15.5,1.5],texture:"#0"},east:{uv:[14,.75,14.75,1.5],texture:"#0"},south:{uv:[13.25,.75,14,1.5],texture:"#0"},west:{uv:[12.5,.75,13.25,1.5],texture:"#0"},up:{uv:[13.25,0,14,.75],texture:"#0"},down:{uv:[14,0,14.75,.75],texture:"#0"}}},{from:[13,0,13],to:[16,3,16],faces:{north:{uv:[14,2.25,14.75,3],texture:"#0"},east:{uv:[13.25,2.25,14,3],texture:"#0"},south:{uv:[12.5,2.25,13.25,3],texture:"#0"},west:{uv:[14.75,2.25,15.5,3],texture:"#0"},up:{uv:[13.25,1.5,14,2.25],texture:"#0"},down:{uv:[14,1.5,14.75,2.25],texture:"#0"}}}]).getMesh(D,we.none())}e.bedRenderer=w;function x(T){return(B,D)=>{let ie=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,11,3],to:[12,16,13],faces:{east:{uv:[0,2.5,2.5,3.75],texture:"#0"},north:{uv:[2.5,2.5,4.5,3.75],texture:"#0"},west:{uv:[4.5,2.5,6.5,3.75],texture:"#0"},south:{uv:[7,2.5,9,3.75],texture:"#0"},up:{uv:[2.5,0,4.5,2.5],rotation:180,texture:"#0"},down:{uv:[4.5,0,6.5,2.5],rotation:180,texture:"#0"}}},{from:[7,10,2],to:[9,13,4],faces:{east:{uv:[14,.5,14.5,1.25],texture:"#0"},north:{uv:[14.5,.5,15,1.25],texture:"#0"},west:{uv:[15,.5,15.5,1.25],texture:"#0"},south:{uv:[15.5,.5,16,1.25],texture:"#0"},up:{uv:[14.5,0,15,.5],rotation:180,texture:"#0"},down:{uv:[15,0,15.5,.5],rotation:180,texture:"#0"}}},{from:[7,16,7],to:[9,20,9],faces:{east:{uv:[9.25,2.5,9.75,3.5],texture:"#0"},north:{uv:[9.75,2.5,10.25,3.5],texture:"#0"},west:{uv:[10.25,2.5,10.75,3.5],texture:"#0"},south:{uv:[10.75,2.5,11.25,3.5],texture:"#0"},up:{uv:[9.75,2,10.25,2.5],texture:"#0"},down:{uv:[10.25,2,10.75,2.5],texture:"#0"}}},{from:[6,20,6],to:[10,24,10],faces:{east:{uv:[9.25,1,10.25,2],texture:"#0"},north:{uv:[10.25,1,11.25,2],texture:"#0"},west:{uv:[11.25,1,12.25,2],texture:"#0"},south:{uv:[12.25,1,13.25,2],texture:"#0"},up:{uv:[10.25,0,11.25,1],rotation:180,texture:"#0"},down:{uv:[11.25,0,12.25,1],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),ee=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,5,5],to:[12,11,11],faces:{east:{uv:[0,5.25,1.5,6.75],texture:"#0"},north:{uv:[1.5,5.25,3.5,6.75],texture:"#0"},west:{uv:[3.5,5.25,5,6.75],texture:"#0"},south:{uv:[5,5.25,7,6.75],texture:"#0"},up:{uv:[1.5,3.75,3.5,5.25],texture:"#0"},down:{uv:[3.5,3.75,5.5,5.25],texture:"#0"}}}]).getMesh(B,we.none()),de=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[12,2,6],to:[15,12,10],faces:{east:{uv:[9,5,10,7.5],texture:"#0"},north:{uv:[10,5,10.75,7.5],texture:"#0"},west:{uv:[10.75,5,11.75,7.5],texture:"#0"},south:{uv:[11.75,5,12.5,7.5],texture:"#0"},up:{uv:[10,4,10.75,5],rotation:180,texture:"#0"},down:{uv:[10.75,4,11.5,5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),Q=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[1,2,6],to:[4,12,10],faces:{east:{uv:[12.5,5,13.5,7.5],texture:"#0"},north:{uv:[13.5,5,14.25,7.5],texture:"#0"},west:{uv:[14.25,5,15.25,7.5],texture:"#0"},south:{uv:[15.25,5,16,7.5],texture:"#0"},up:{uv:[13.5,4,14.25,5],rotation:180,texture:"#0"},down:{uv:[14.25,4,15,5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none()),_=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[8,0,6],to:[12,5,10],faces:{east:{uv:[0,7.75,1,9],texture:"#0"},north:{uv:[1,7.75,2,9],texture:"#0"},west:{uv:[2,7.75,3,9],texture:"#0"},south:{uv:[3,7.75,4,9],texture:"#0"},up:{uv:[1,6.75,2,7.75],texture:"#0"},down:{uv:[2,6.75,3,7.75],texture:"#0"}}}]).getMesh(B,we.none()),S=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[4,0,6],to:[8,5,10],faces:{east:{uv:[4,7.75,5,9],texture:"#0"},north:{uv:[5,7.75,6,9],texture:"#0"},west:{uv:[6,7.75,7,9],texture:"#0"},south:{uv:[7,7.75,8,9],texture:"#0"},up:{uv:[5,6.75,6,7.75],texture:"#0"},down:{uv:[6,6.75,7,7.75],texture:"#0"}}}]).getMesh(B,we.none()),O=new _e;switch(D){case"sitting":let U=P.mat4.create();P.mat4.translate(U,U,[0,-5,2]),O.merge(ee.transform(U));let ue=new Me(void 0,{0:T.withPrefix("entity/copper_golem/").toString()},[{from:[5,6,6],to:[11,7,12],faces:{east:{uv:[.75,6.25,2.25,6.5],texture:"#0"},north:{uv:[2.25,6.25,3.75,6.5],texture:"#0"},west:{uv:[3.75,6.25,5.25,6.5],texture:"#0"},south:{uv:[5.25,6.25,6.75,6.5],texture:"#0"},up:{uv:[2.25,4.75,3.75,6.25],texture:"#0"},down:{uv:[3.75,4.75,5.25,6.25],texture:"#0"}}},{from:[4,1,4],to:[12,7,7],faces:{east:{uv:[.75,5.25,1.5,6.75],rotation:180,texture:"#0"},north:{uv:[1.5,5.25,3.5,6.75],rotation:180,texture:"#0"},west:{uv:[3.5,5.25,4.25,6.75],rotation:180,texture:"#0"},south:{uv:[4.25,5.25,6.25,6.75],rotation:180,texture:"#0"},up:{uv:[1.5,4.5,3.5,5.25],rotation:180,texture:"#0"},down:{uv:[3.5,4.75,5.5,5.5],rotation:180,texture:"#0"}}}]).getMesh(B,we.none());O.merge(ue);let qe=P.mat4.create();P.mat4.translate(qe,qe,[0,-4,0]),O.merge(ie.transform(qe));let Ae=P.mat4.create();P.mat4.translate(Ae,Ae,[0,5.5,6.5]),P.mat4.rotateX(Ae,Ae,.61086524),P.mat4.translate(Ae,Ae,[0,-7,-8]),O.merge(de.transform(Ae)),O.merge(Q.transform(Ae));let Ne=P.mat4.create();P.mat4.translate(Ne,Ne,[2.5,2.5,2]),P.mat4.rotateX(Ne,Ne,Math.PI/2),P.mat4.translate(Ne,Ne,[-2.5,-1,-7.5]),O.merge(_.transform(Ne)),O.merge(S.transform(Ne));break;case"running":let ye=P.mat4.create();P.mat4.translate(ye,ye,[0,0,-2]),O.merge(ie.transform(ye));let le=P.mat4.create();P.mat4.translate(le,le,[0,0,-2]),P.mat4.translate(le,le,[-8,-8,-6]),P.mat4.rotateX(le,le,-.120399),P.mat4.rotateY(le,le,.0064),P.mat4.rotateZ(le,le,-.0779),P.mat4.translate(le,le,[6.4,7.5,9.5]),O.merge(ee.transform(le));let q=P.mat4.create();P.mat4.translate(q,q,[0,7,8]),P.mat4.rotateX(q,q,-1.003564),P.mat4.translate(q,q,[0,-7,-5]),O.merge(de.transform(q));let L=P.mat4.create();P.mat4.translate(L,L,[0,7,8]),P.mat4.rotateX(L,L,.872665),P.mat4.rotateY(L,L,.0535),P.mat4.rotateZ(L,L,-.0449),P.mat4.translate(L,L,[0,-7,-10.25]),O.merge(Q.transform(L));let ae=P.mat4.create();P.mat4.translate(ae,ae,[10,2.5,4.6]),P.mat4.rotateX(ae,ae,.872665),P.mat4.translate(ae,ae,[-10.6,-1.5,-7.5]),O.merge(_.transform(ae));let Se=P.mat4.create();P.mat4.translate(Se,Se,[6,2.5,10]),P.mat4.rotateX(Se,Se,-.7854),P.mat4.translate(Se,Se,[-6.4,-1.5,-8]),O.merge(S.transform(Se));break;case"star":O.merge(ie),O.merge(ee);let ft=P.mat4.create();P.mat4.translate(ft,ft,[11,10,8]),P.mat4.rotateZ(ft,ft,1.91986),P.mat4.translate(ft,ft,[-13.5,-7,-8]),O.merge(de.transform(ft));let Qe=P.mat4.create();P.mat4.translate(Qe,Qe,[5,10,8]),P.mat4.rotateZ(Qe,Qe,-1.91986),P.mat4.translate(Qe,Qe,[-2.5,-7,-8]),O.merge(Q.transform(Qe));let It=P.mat4.create();P.mat4.translate(It,It,[10.75,3,8]),P.mat4.rotateZ(It,It,.2618),P.mat4.translate(It,It,[-10,-2.5,-8]),O.merge(_.transform(It));let nt=P.mat4.create();P.mat4.translate(nt,nt,[5.25,3,8]),P.mat4.rotateZ(nt,nt,-.2618),P.mat4.translate(nt,nt,[-6,-2.5,-8]),O.merge(S.transform(nt));break;default:O.merge(ee),O.merge(ie),O.merge(de),O.merge(Q),O.merge(_),O.merge(S);break}return O}}e.copperGolemStatueRenderer=x;function v(T,B,D=""){return T.getProperty(B)??D}function y(T,B,D="0"){return parseInt(T.getProperty(B)??D)}let I=new Map(Object.entries({"minecraft:chest":e.chestRenderer(R.create("normal")),"minecraft:ender_chest":e.chestRenderer(R.create("ender")),"minecraft:trapped_chest":e.chestRenderer(R.create("trapped")),"minecraft:copper_chest":e.chestRenderer(R.create("copper")),"minecraft:exposed_copper_chest":e.chestRenderer(R.create("copper_exposed")),"minecraft:weathered_copper_chest":e.chestRenderer(R.create("copper_weathered")),"minecraft:oxidized_copper_chest":e.chestRenderer(R.create("copper_oxidized")),"minecraft:waxed_copper_chest":e.chestRenderer(R.create("copper")),"minecraft:waxed_exposed_copper_chest":e.chestRenderer(R.create("copper_exposed")),"minecraft:waxed_weathered_copper_chest":e.chestRenderer(R.create("copper_weathered")),"minecraft:waxed_oxidized_copper_chest":e.chestRenderer(R.create("copper_oxidized"))})),b=new Map(Object.entries({"minecraft:skeleton_skull":e.headRenderer(R.create("skeleton/skeleton"),2),"minecraft:wither_skeleton_skull":e.headRenderer(R.create("skeleton/wither_skeleton"),2),"minecraft:zombie_head":e.headRenderer(R.create("zombie/zombie"),1),"minecraft:creeper_head":e.headRenderer(R.create("creeper/creeper"),2),"minecraft:dragon_head":e.dragonHeadRenderer(),"minecraft:piglin_head":e.piglinHeadRenderer(),"minecraft:player_head":e.headRenderer(R.create("player/wide/steve"),1)})),k=["oak","spruce","birch","jungle","acacia","dark_oak","mangrove","cherry","pale_oak","bamboo","crimson","warped"],E=new Map(k.map(T=>[`minecraft:${T}_sign`,e.signRenderer(R.create(T))])),A=new Map(k.map(T=>[`minecraft:${T}_wall_sign`,e.wallSignRenderer(R.create(T))])),N=new Map(k.map(T=>[`minecraft:${T}_hanging_sign`,e.hangingSignRenderer(R.create(T))])),z=new Map(k.map(T=>[`minecraft:${T}_wall_hanging_sign`,e.wallHangingSignRenderer(T)])),F=new Map(Object.keys(un).map(T=>[`minecraft:${T}_shulker_box`,e.shulkerBoxRenderer(R.create(`shulker_${T}`))])),Y=new Map(Object.keys(un).map(T=>[`minecraft:${T}_bed`,e.bedRenderer(R.create(T))])),$=new Map(Object.keys(un).map(T=>[`minecraft:${T}_banner`,e.bannerRenderer(T)])),V=new Map(Object.keys(un).map(T=>[`minecraft:${T}_wall_banner`,e.wallBannerRenderer(T)])),ce=new Map(Object.entries({"minecraft:copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem")),"minecraft:exposed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_exposed")),"minecraft:weathered_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_weathered")),"minecraft:oxidized_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_oxidized")),"minecraft:waxed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem")),"minecraft:waxed_exposed_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_exposed")),"minecraft:waxed_weathered_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_weathered")),"minecraft:waxed_oxidized_copper_golem_statue":e.copperGolemStatueRenderer(R.create("copper_golem_oxidized"))}));function oe(T,B,D,ie){let ee=new _e;T.is("water")&&ee.merge(Io("water",y(T,"level"),D,ie,0)),T.is("lava")&&ee.merge(Io("lava",y(T,"level"),D,ie));let de=I.get(T.getName().toString());if(de!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(de(D).transform(L))}T.is("decorated_pot")&&ee.merge(r(D));let Q=b.get(T.getName().toString());if(Q!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(Q(D).transform(L))}let _=E.get(T.getName().toString());if(_!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(_(D).transform(L))}let S=A.get(T.getName().toString());if(S!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(S(D).transform(L))}let O=N.get(T.getName().toString());if(O!==void 0){let q=v(T,"attached","false")==="true",L=y(T,"rotation")/16*Math.PI*2,ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,L),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(O(q,D).transform(ae))}let U=z.get(T.getName().toString());if(U!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(U(D).transform(L))}T.is("conduit")&&ee.merge(d(D));let ue=F.get(T.getName().toString());if(ue!==void 0){let q=v(T,"facing","up"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),q==="down"?P.mat4.rotateX(L,L,Math.PI):q!=="up"&&(P.mat4.rotateY(L,L,q==="east"?Math.PI/2:q==="north"?Math.PI:q==="west"?Math.PI*3/2:0),P.mat4.rotateX(L,L,Math.PI/2)),P.mat4.translate(L,L,[-8,-8,-8]),ee.merge(ue(D).transform(L))}if(T.is("bell")){let q=P.mat4.create();P.mat4.translate(q,q,[8,8,8]),P.mat4.scale(q,q,[1,-1,-1]),P.mat4.translate(q,q,[-8,-8,-8]),ee.merge(g(D).transform(q))}let qe=Y.get(T.getName().toString());if(qe!==void 0){let q=v(T,"part","head"),L=v(T,"facing","south"),ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,L==="east"?Math.PI/2:L==="north"?Math.PI:L==="west"?Math.PI*3/2:0),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(qe(q,D).transform(ae))}let Ae=$.get(T.getName().toString());if(Ae!==void 0){let q=y(T,"rotation")/16*Math.PI*2,L=P.mat4.create();P.mat4.translate(L,L,[8,24,8]),P.mat4.rotateY(L,L,q),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-24,-8]),ee.merge(Ae(D,B?.getList("patterns",C.Compound)).transform(L))}let Ne=V.get(T.getName().toString());if(Ne!==void 0){let q=v(T,"facing","south"),L=P.mat4.create();P.mat4.translate(L,L,[8,8,8]),P.mat4.rotateY(L,L,q==="east"?Math.PI/2:q==="north"?Math.PI:q==="west"?Math.PI*3/2:0),P.mat4.scale(L,L,[2/3,2/3,2/3]),P.mat4.translate(L,L,[-8,-23.2,-8]),ee.merge(Ne(D,B?.getList("patterns",C.Compound)).transform(L))}let ye=ce.get(T.getName().toString());if(ye!==void 0){let q=v(T,"facing","south"),L=v(T,"copper_golem_pose","standing"),ae=P.mat4.create();P.mat4.translate(ae,ae,[8,8,8]),P.mat4.rotateY(ae,ae,q==="west"?Math.PI/2:q==="south"?Math.PI:q==="east"?Math.PI*3/2:0),P.mat4.translate(ae,ae,[-8,-8,-8]),ee.merge(ye(D,L).transform(ae))}!T.is("water")&&!T.is("lava")&&T.isWaterlogged()&&ee.merge(Io("water",0,D,ie,0));let le=P.mat4.create();return P.mat4.scale(le,le,[.0625,.0625,.0625]),ee.transform(le)}e.getBlockMesh=oe})(Be=Be||(Be={}));var Xn=dr(Or(),1);var Eo=dr(Or(),1);var fn=class{gl;program;constructor(t,r,n){this.gl=t,this.program=this.initShaderProgram(r,n)}getProgram(){return this.program}initShaderProgram(t,r){let n=this.loadShader(this.gl.VERTEX_SHADER,t),s=this.loadShader(this.gl.FRAGMENT_SHADER,r),i=this.gl.createProgram();if(this.gl.attachShader(i,n),this.gl.attachShader(i,s),this.gl.linkProgram(i),!this.gl.getProgramParameter(i,this.gl.LINK_STATUS))throw new Error(`Unable to link shader program: ${this.gl.getProgramInfoLog(i)}`);return i}loadShader(t,r){let n=this.gl.createShader(t);if(this.gl.shaderSource(n,r),this.gl.compileShader(n),!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)){let s=new Error(`Compiling ${t===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(n)}`);throw this.gl.deleteShader(n),s}return n}};var p2=` attribute vec4 vertPos; attribute vec2 texCoord; attribute vec4 texLimit; @@ -28,7 +28,7 @@ var Xu=Object.create;var Ko=Object.defineProperty;var Wu=Object.getOwnPropertyDe vTintColor = vertColor; vLighting = normal.y * 0.2 + abs(normal.z) * 0.1 + 0.8; } -`,f2=` +`,g2=` precision highp float; varying highp vec2 vTexCoord; varying highp vec4 vTexLimit; @@ -46,15 +46,15 @@ var Xu=Object.create;var Ko=Object.defineProperty;var Wu=Object.getOwnPropertyDe if(texColor.a < 0.01) discard; gl_FragColor = vec4(texColor.xyz * vTintColor * vLighting, texColor.a); } -`,fn=class{gl;shaderProgram;projMatrix;activeShader;pixelSize=0;constructor(t){this.gl=t,this.shaderProgram=new un(t,u2,f2).getProgram(),this.activeShader=this.shaderProgram,this.projMatrix=this.getPerspective(),this.initialize()}setViewport(t,r,n,s){this.gl.viewport(t,r,n,s),this.projMatrix=this.getPerspective()}getPerspective(){let t=70*Math.PI/180,r=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,n=Mo.mat4.create();return Mo.mat4.perspective(n,t,r,.1,500),n}initialize(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(this.gl.BACK)}setShader(t){this.gl.useProgram(t),this.activeShader=t}setVertexAttr(t,r,n){if(n===void 0)throw new Error(`Expected buffer for ${t}`);let s=this.gl.getAttribLocation(this.activeShader,t);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.vertexAttribPointer(s,r,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(s)}setUniform(t,r){let n=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(n,!1,r)}setTexture(t,r){this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.pixelSize=r??0}createAtlasTexture(t){let r=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),r}prepareDraw(t){this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix);let r=this.gl.getUniformLocation(this.activeShader,"pixelSize");this.gl.uniform1f(r,this.pixelSize)}drawMesh(t,r){if(t.quadVertices()>0){if(r.pos&&this.setVertexAttr("vertPos",3,t.posBuffer),r.color&&this.setVertexAttr("vertColor",3,t.colorBuffer),r.texture&&(this.setVertexAttr("texCoord",2,t.textureBuffer),this.setVertexAttr("texLimit",4,t.textureLimitBuffer)),r.normal&&this.setVertexAttr("normal",3,t.normalBuffer),r.blockPos&&this.setVertexAttr("blockPos",3,t.blockPosBuffer),!t.indexBuffer)throw new Error("Expected index buffer");this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),this.gl.drawElements(this.gl.TRIANGLES,t.quadIndices(),this.gl.UNSIGNED_SHORT,0)}t.lineVertices()>0&&(r.pos&&this.setVertexAttr("vertPos",3,t.linePosBuffer),r.color&&this.setVertexAttr("vertColor",3,t.lineColorBuffer),this.gl.drawArrays(this.gl.LINES,0,t.lineVertices()))}};var Hi=class e extends fn{item;resources;mesh;atlasTexture;constructor(t,r,n,s={}){super(t),this.item=r,this.resources=n,this.updateMesh(s),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setItem(t,r={}){this.item=t,this.updateMesh(r)}updateMesh(t={}){this.mesh=e.getItemMesh(this.item,this.resources,t),this.mesh.computeNormals(),this.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0})}static getItemMesh(t,r,n){let s=t.getComponent("item_model",r)?.getAsString();if(s===void 0)return new _e;let i=r.getItemModel(R.parse(s));if(!i)throw new Error(`Item model ${s} does not exist (defined by item ${t.toString()})`);return i.getMesh(t,r,n)}getPerspective(){let t=Gn.mat4.create();return Gn.mat4.ortho(t,0,16,0,16,.1,500),t}drawItem(){let t=Gn.mat4.create();Gn.mat4.translate(t,t,[0,0,-32]),this.setShader(this.shaderProgram),this.setTexture(this.atlasTexture,this.resources.getPixelSize?.()),this.prepareDraw(t),this.drawMesh(this.mesh,{pos:!0,color:!0,texture:!0,normal:!0})}};var Fr=[0,0,0],Zn;(function(e){function t(u){let h=M.readObject(u)??{},d=M.readString(h.type)?.replace(/^minecraft:/,"");switch(d){case"constant":return new r(re.fromJson(h.value)??Fr);case"dye":return new n(re.fromJson(h.default)??Fr);case"grass":return new s(M.readNumber(h.temperature)??0,M.readNumber(h.downfall)??0);case"firework":return new i(re.fromJson(h.default)??Fr);case"potion":return new o(re.fromJson(h.default)??Fr);case"map_color":return new a(re.fromJson(h.default)??Fr);case"custom_model_data":return new l(M.readInt(h.index)??0,re.fromJson(h.default)??Fr);case"team":return new c(re.fromJson(h.default)??Fr);default:throw new Error(`Invalid item tint type ${d}`)}}e.fromJson=t;class r{value;constructor(h){this.value=h}getTint(h){return this.value}}e.Constant=r;class n{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("dyed_color",d);return f?f.isCompound()?re.intToRgb(f.getNumber("rgb")):re.intToRgb(f.getAsNumber()):this.default_color}}e.Dye=n;class s{temperature;downfall;constructor(h,d){this.temperature=h,this.downfall=d}getTint(h){return[124/255,189/255,107/255]}}e.Grass=s;class i{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("firework_explosion",d);if(!f?.isCompound())return this.default_color;let m=f.get("colors");return!m||!m.isListOrArray()?this.default_color:(()=>{if(m.length===1)return re.intToRgb(m.get(0).getAsNumber());let[g,w,x]=[0,0,0];for(let v of m.getItems())g+=(v.getAsNumber()&16711680)>>16,w+=(v.getAsNumber()&65280)>>8,x+=(v.getAsNumber()&255)>>0;return g/=m.length,w/=m.length,x/=m.length,[g/255,w/255,x/255]})()}}e.Firework=i;class o{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("potion_contents",d);if(!f)return this.default_color;let m=rn.fromNbt(f);return rn.getColor(m)}}e.Potion=o;class a{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("map_color",d);return f?re.intToRgb(f.getAsNumber()):this.default_color}}e.MapColor=a;class l{index;default_color;constructor(h,d){this.index=h,this.default_color=d}getTint(h,d){let f=h.getComponent("custom_model_data",d);if(!f?.isCompound())return this.default_color;let m=f.getList("colors").get(this.index);return m?re.fromNbt(m)??this.default_color:this.default_color}}e.CustomModelData=l;class c{default_color;constructor(h){this.default_color=h}getTint(h,d,f){return f.context_entity_team_color??this.default_color}}e.Team=c})(Zn=Zn||(Zn={}));var Le=mr(Br(),1);var Hn;(function(e){function t(m){let p=M.readObject(m)??{},g=M.readString(p.type)?.replace(/^minecraft:/,"");switch(g){case"bed":return new r(R.parse(M.readString(p.texture)??""));case"banner":return new n(M.readString(p.color)??"");case"conduit":return new s;case"chest":return new i(R.parse(M.readString(p.texture)??""),M.readNumber(p.openness)??0);case"head":return new o(M.readString(p.kind)??"",typeof p.texture=="string"?R.parse(p.texture):void 0,M.readNumber(p.animation)??0);case"player_head":return new o("player",void 0,0);case"shulker_box":return new a(R.parse(M.readString(p.texture)??""),M.readNumber(p.openness)??0,M.readString(p.orientation)??"up");case"shield":return new l;case"trident":return new c;case"decorated_pot":return new u;case"standing_sign":return new h(M.readString(p.wood_type)??"",typeof p.texture=="string"?R.parse(p.texture):void 0);case"hanging_sign":return new d(M.readString(p.wood_type)??"",typeof p.texture=="string"?R.parse(p.texture):void 0);case"copper_golem_statue":{let w=M.readString(p.texture)??"",x=w.substring(w.lastIndexOf("/")+1),v=x.endsWith(".png")?x.slice(0,-4):x;return new f(R.parse(v))}default:return console.warn(`[deepslate]: Unknown special model ${g}`),{getMesh:()=>new _e}}}e.fromJson=t;class r{renderer;constructor(p){this.renderer=Be.bedRenderer(p)}getMesh(p,g){let w=this.renderer("head",g),x=this.renderer("foot",g),v=Le.mat4.create();return Le.mat4.translate(v,v,[0,0,-16]),w.merge(x.transform(v))}}class n{renderer;constructor(p){this.renderer=Be.bannerRenderer(p)}getMesh(p,g){let w=p.getComponent("banner_patterns",void 0),x=w?.isList()&&w.getType()===C.Compound?w:void 0,v=Le.mat4.create();return Le.mat4.translate(v,v,[8,24,8]),Le.mat4.rotateY(v,v,Math.PI),Le.mat4.scale(v,v,[2/3,2/3,2/3]),Le.mat4.translate(v,v,[-8,-24,-8]),this.renderer(g,x).transform(v)}}class s{getMesh(p,g){return Be.conduitRenderer(g)}}class i{renderer;constructor(p,g){this.renderer=Be.chestRenderer(p)}getMesh(p,g){let w=Le.mat4.create();return Le.mat4.translate(w,w,[8,8,8]),Le.mat4.rotateY(w,w,Math.PI),Le.mat4.translate(w,w,[-8,-8,-8]),this.renderer(g).transform(w)}}class o{renderer;constructor(p,g,w){this.renderer=({skeleton:()=>Be.headRenderer(g??R.create("skeleton/skeleton"),2),wither_skeleton:()=>Be.headRenderer(g??R.create("skeleton/wither_skeleton"),2),zombie:()=>Be.headRenderer(g??R.create("zombie/zombie"),1),creeper:()=>Be.headRenderer(g??R.create("creeper/creeper"),2),dragon:()=>Be.dragonHeadRenderer(g),piglin:()=>Be.piglinHeadRenderer(g),player:()=>Be.headRenderer(g??R.create("player/wide/steve"),1)}[p]??(()=>()=>new _e))()}getMesh(p,g){return this.renderer(g)}}class a{renderer;constructor(p,g,w){this.renderer=Be.shulkerBoxRenderer(p)}getMesh(p,g){return this.renderer(g)}}class l{getMesh(p,g){let w=[],x=p.getComponent("banner_patterns",void 0),v=x?.isList()&&x.getType()===C.Compound?x:void 0,y=p.getComponent("base_color",void 0)?.getAsString();!y&&(v?.length??0)>0&&(y="white"),y&&(w.push({color:y,pattern:"base"}),v?.forEach(k=>{w.push({pattern:R.parse(k.getString("pattern")).path,color:k.getString("color")})}));let I=Be.shieldRenderer(g,w),b=Le.mat4.create();return Le.mat4.translate(b,b,[-3,1,0]),Le.mat4.rotateX(b,b,-10*Math.PI/180),Le.mat4.rotateY(b,b,-10*Math.PI/180),Le.mat4.rotateZ(b,b,-5*Math.PI/180),I.transform(b)}}class c{getMesh(p,g){return new _e}}class u{getMesh(p,g){return Be.decoratedPotRenderer(g)}}class h{renderer;constructor(p,g){this.renderer=Be.signRenderer(g??R.create(p))}getMesh(p,g){return this.renderer(g)}}class d{renderer;constructor(p,g){this.renderer=Be.hangingSignRenderer(g??R.create(p))}getMesh(p,g){return this.renderer(!1,g)}}class f{renderer;constructor(p){this.renderer=Be.copperGolemStatueRenderer(p)}getMesh(p,g){let w=p.getComponent("block_state",void 0),x="standing";w instanceof Re&&(x=w.getString("copper_golem_pose")||x);let v=Le.mat4.create();return Le.mat4.translate(v,v,[8,12,8]),Le.mat4.rotateY(v,v,Math.PI),Le.mat4.rotateZ(v,v,Math.PI),Le.mat4.translate(v,v,[-8,-12,-8]),this.renderer(g,x).transform(v)}}})(Hn=Hn||(Hn={}));var ou=new _e,So;(function(e){function t(u){let h=M.readObject(u)??{},d=M.readString(h.type)?.replace(/^minecraft:/,"");switch(d){case"empty":return new r;case"model":return new n(R.parse(M.readString(h.model)??""),M.readArray(h.tints,Zn.fromJson)??[]);case"composite":return new s(M.readArray(h.models,e.fromJson)??[]);case"condition":return new i(i.propertyFromJson(h),e.fromJson(h.on_true),e.fromJson(h.on_false));case"select":return new o(o.propertyFromJson(h),new Map(M.readArray(h.cases,f=>M.readObject(f)??{})?.flatMap(f=>{let m=e.fromJson(f.model);return Array.isArray(f.when)?f.when.map(p=>[M.readString(p)??"",m]):[[M.readString(f.when)??"",m]]})),h.fallback?e.fromJson(h.fallback):void 0);case"range_dispatch":return new a(a.propertyFromJson(h),M.readNumber(h.scale)??1,M.readArray(h.entries,f=>{let m=M.readObject(f)??{};return{threshold:M.readNumber(m.threshold)??0,model:e.fromJson(m.model)}})??[],h.fallback?e.fromJson(h.fallback):void 0);case"special":return new l(Hn.fromJson(h.model),R.parse(M.readString(h.base)??""));case"bundle/selected_item":return new c;default:return console.warn(`[deepslate]: Unknown item model type '${d}'`),{getMesh:()=>new _e}}}e.fromJson=t;class r{getMesh(h,d,f){return new _e}}e.Empty=r;class n{modelId;tints;constructor(h,d){this.modelId=h,this.tints=d}getMesh(h,d,f){let m=d.getBlockModel(this.modelId);if(!m)return console.warn(`[deepslate]: Model '${this.modelId}' does not exist`),new _e;let p=w=>wm.merge(p.getMesh(h,d,f))),m}}e.Composite=s;class i{property;onTrue;onFalse;constructor(h,d,f){this.property=h,this.onTrue=d,this.onFalse=f}getMesh(h,d,f){return(this.property(h,d,f)?this.onTrue:this.onFalse).getMesh(h,d,f)}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"fishing_rod/cast":case"selected":case"carried":case"extended_view":return(w,x,v)=>v[d]??!1;case"view_entity":return(w,x,v)=>v.context_entity_is_view_entity??!1;case"using_item":return(w,x,v)=>(v.use_duration??-1)>=0;case"bundle/has_selected_item":return(w,x,v)=>(v["bundle/selected_item"]??-1)>=0;case"broken":return(w,x,v)=>{let y=w.getComponent("damage",x)?.getAsNumber(),I=w.getComponent("max_damage",x)?.getAsNumber();return y!==void 0&&I!==void 0&&y>=I-1};case"damaged":return(w,x,v)=>{let y=w.getComponent("damage",x)?.getAsNumber(),I=w.getComponent("max_damage",x)?.getAsNumber();return y!==void 0&&I!==void 0&&y>=1};case"has_component":let f=R.parse(M.readString(h.component)??""),m=M.readBoolean(h.ignore_default)??!1;return(w,x,v)=>w.hasComponent(f,m?void 0:x);case"keybind_down":let p=M.readString(h.keybind)??"";return(w,x,v)=>v.keybind_down?.includes(p)??!1;case"custom_model_data":let g=M.readInt(h.index)??0;return(w,x,v)=>{let y=w.getComponent("custom_model_data",x);if(!y?.isCompound())return!1;let I=y.getList("flags").getNumber(g);return I!==void 0&&I!==0};default:return console.warn(`[deepslate]: Unknown condition property '${d}'`),()=>!1}}}e.Condition=i;class o{property;cases;fallback;constructor(h,d,f){this.property=h,this.cases=d,this.fallback=f}getMesh(h,d,f){let m=this.property(h,d,f);return((m!==null?this.cases.get(m):void 0)??this.fallback)?.getMesh(h,d,f)??ou}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"main_hand":return(g,w,x)=>x.main_hand??"right";case"display_context":return(g,w,x)=>x.display_context??"gui";case"context_dimension":return(g,w,x)=>x.context_dimension?.toString()??null;case"charge_type":let f=R.create("firework_rocket");return(g,w,x)=>{let v=g.getComponent("charged_projectiles",w);return!v?.isList()||v.length===0?"none":v.filter(y=>y.isCompound()?R.parse(y.getString("id")).equals(f):!1).length>0?"rocket":"arrow"};case"trim_material":return(g,w,x)=>{let v=g.getComponent("trim",w);return v?.isCompound()?R.parse(v.getString("material")).toString():null};case"block_state":let m=M.readString(h.block_state_property)??"";return(g,w,x)=>{let v=g.getComponent("block_state",w);return v?.isCompound()?v.getString(m):null};case"local_time":return(g,w,x)=>"NOT IMPLEMENTED";case"context_entity_type":return(g,w,x)=>x.context_entity_type?.toString()??null;case"custom_model_data":let p=M.readInt(h.index)??0;return(g,w,x)=>{let v=g.getComponent("custom_model_data",w);if(!v?.isCompound())return null;let y=v.getList("strings");return y.length<=p?null:y.getString(p)};default:return console.warn(`[deepslate]: Unknown select property '${d}'`),()=>null}}}e.Select=o;class a{property;scale;fallback;entries;constructor(h,d,f,m){this.property=h,this.scale=d,this.fallback=m,this.entries=f.sort((p,g)=>p.threshold-g.threshold)}getMesh(h,d,f){let m=this.property(h,d,f)*this.scale,p=this.fallback;for(let g of this.entries)if(g.threshold<=m)p=g.model;else break;return p?.getMesh(h,d,f)??ou}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"bundle/fullness":let f=function(x,v){let y=x.getComponent("bundle_contents",v);return y?.isListOrArray()?y.map(b=>b.isCompound()?Yn.fromNbt(b):void 0).reduce((b,k)=>{if(k===void 0)return b;if(k.hasComponent("bundle_contents",v))return b+f(k,v)+1/16;let E=k.getComponent("bees",v);if(E?.isListOrArray()&&E.length>0)return b+1;let A=k.getComponent("max_stack_size",v)?.getAsNumber()??1;return b+k.count/A},0):0};return(x,v,y)=>f(x,v);case"damage":{let x=M.readBoolean(h.normalize)??!0;return(v,y,I)=>{let b=v.getComponent("max_damage",y)?.getAsNumber()??0,k=Fe(v.getComponent("damage",y)?.getAsNumber()??0,0,b);return x?Fe(k/b,0,1):Fe(k,0,b)}}case"count":{let x=M.readBoolean(h.normalize)??!0;return(v,y,I)=>{let b=v.getComponent("max_stack_size",y)?.getAsNumber()??1;return x?Fe(v.count/b,0,1):Fe(v.count,0,b)}}case"cooldown":return(x,v,y)=>{let I=x.getComponent("use_cooldown",v),b=I?.isCompound()?R.parse(I.getString("cooldown_group")??x.id):x.id;return y.cooldown_percentage?.[b.toString()]??0};case"time":switch(M.readString(h.source)??"daytime"){case"moon_phase":return(x,v,y)=>(y.game_time??0)/24e3%8/8;case"random":return(x,v,y)=>Math.random();default:return(x,v,y)=>{let b=(y.game_time??0)/24e3%1-.25,k=.5-Math.cos(b*Math.PI)/2;return(b*2+k)/3}}case"compass":return(x,v,y)=>y.compass_angle??0;case"crossbow/pull":return(x,v,y)=>y["crossbow/pull"]??0;case"use_duration":let p=M.readBoolean(h.remaining)??!0;return(x,v,y)=>y.use_duration===void 0||y.use_duration<0?0:p?Math.max((y.max_use_duration??0)-y.use_duration,0):y.use_duration;case"use_cycle":let g=M.readNumber(h.period)??1;return(x,v,y)=>y.use_duration===void 0||y.use_duration<0?0:Math.max((y.max_use_duration??0)-(y.use_duration??0),0)%g;case"custom_model_data":let w=M.readInt(h.index)??0;return(x,v,y)=>{let I=x.getComponent("custom_model_data",v);return I?.isCompound()?I.getList("floats").getNumber(w):0};default:return console.warn(`[deepslate]: Unknown range dispatch property '${d}'`),()=>0}}}e.RangeDispatch=a;class l{specialModel;base;constructor(h,d){this.specialModel=h,this.base=d}getMesh(h,d,f){let m=this.specialModel.getMesh(h,d),p=d.getBlockModel(this.base);return p?(m.transform(p.getDisplayTransform(f.display_context??"gui")),m):(console.warn(`[deepslate]: Special model base '${this.base}' does not exist`),new _e)}}e.Special=l;class c{getMesh(h,d,f){let m=f["bundle/selected_item"];if(m===void 0||m<0)return new _e;let p=h.getComponent("bundle_contents",d);if(!p?.isListOrArray())return new _e;let g=p.get(m);if(g===void 0||!g.isCompound())return new _e;let w=Yn.fromNbt(g);return Hi.getItemMesh(w,d,{...f,"bundle/selected_item":-1,selected:!1,carried:!1,use_duration:-1})}}e.BundleSelectedItem=c})(So=So||(So={}));var Ge;(function(e){function t(o){let a=M.readObject(o)??{};return a.absolute!==void 0?r(M.readNumber(a.absolute)??0):a.above_bottom!==void 0?n(M.readNumber(a.above_bottom)??0):a.below_top!==void 0?s(M.readNumber(a.below_top)??0):a.relative_to_sea_level!==void 0?i(M.readNumber(a.relative_to_sea_level)??0):()=>0}e.fromJson=t;function r(o){return()=>o}e.absolute=r;function n(o){return a=>a.minY+o}e.aboveBottom=n;function s(o){return a=>a.minY+a.height-1-o}e.belowTop=s;function i(o){return a=>a.seaLevel+o}e.relativeToSeaLevel=i})(Ge=Ge||(Ge={}));var Xi=class{randomState;defaultBlock;seaLevel;preliminarySurface;random;surfaceNoise;surfaceSecondaryNoise;constructor(t,r,n,s,i){this.randomState=t,this.defaultBlock=r,this.seaLevel=n,this.preliminarySurface=s,this.random=i,this.surfaceNoise=t.getOrCreateNoise(R.create("surface")),this.surfaceSecondaryNoise=t.getOrCreateNoise(R.create("surface_secondary"))}buildSurface(t,r,n,s,i){let o=Je.minBlockX(t.pos),a=Je.minBlockZ(t.pos),l=new Xn(this,this.randomState,t,r,s,i),c=n.compile(l);for(let u=0;u<16;u+=1){let h=o+u;for(let d=0;d<1;d+=1){let f=a+d;l.updateXZ(h,f);let m=0,p=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER;for(let w=t.maxY;w>=t.minY;w-=1){let x=te.create(h,w,f),v=t.getBlockState(x);if(v.equals(se.AIR)){m=0,p=Number.MIN_SAFE_INTEGER;continue}if(v.isFluid()){p===Number.MIN_SAFE_INTEGER&&(p=w+1);continue}if(g>=w){g=Number.MIN_SAFE_INTEGER;for(let b=w-1;b>=t.minY;b-=1){let k=t.getBlockState(te.create(h,b,f));if(k.equals(se.AIR)||k.isFluid()){g=b+1;break}}}m+=1;let y=w-g+1;l.updateY(m,y,p,w);let I=c(h,w,f);I&&t.setBlockState(x,I)}}}}getSurfaceDepth(t,r){let n=this.surfaceNoise.get3D(t,0,r),s=this.random.at(t,0,r).nextDouble()*.25;return n*2.75+3+s}getSurfaceSecondary(t,r){return this.surfaceSecondaryNoise.get3D(t,0,r)}getOrCreateRandom(t){return this.randomState.getOrCreateRandom(t)}},Xn=class{system;randomState;chunk;noiseChunk;context;biomeGetter;blockX=0;blockY=0;blockZ=0;stoneDepthAbove=0;stoneDepthBelow=0;surfaceDepth=0;waterHeight=0;lastUpdateXZ=Number.MIN_SAFE_INTEGER;lastUpdateY=Number.MIN_SAFE_INTEGER;lastSurfaceDepth2Update=Number.MIN_SAFE_INTEGER;surfaceSecondary=0;lastMinSurfaceLevelUpdate=Number.MIN_SAFE_INTEGER;minSurfaceLevel=0;biome;noiseSamplers2d=new Map;noiseSamplers3d=new Map;constructor(t,r,n,s,i,o){this.system=t,this.randomState=r,this.chunk=n,this.noiseChunk=s,this.context=i,this.biomeGetter=o}updateXZ(t,r){this.lastUpdateXZ+=1,this.lastUpdateY+=1,this.blockX=t,this.blockZ=r,this.surfaceDepth=this.system.getSurfaceDepth(t,r)}updateY(t,r,n,s){this.lastUpdateY+=1,this.biome=void 0,this.blockY=s,this.stoneDepthAbove=t,this.stoneDepthBelow=r,this.waterHeight=n}getSurfaceSecondary(){return this.lastSurfaceDepth2Update!==this.lastUpdateXZ&&(this.lastSurfaceDepth2Update=this.lastUpdateXZ,this.surfaceSecondary=this.system.getSurfaceSecondary(this.blockX,this.blockZ)),this.surfaceSecondary}getMinSurfaceLevel(){if(this.lastMinSurfaceLevelUpdate!==this.lastUpdateXZ){this.lastMinSurfaceLevelUpdate=this.lastUpdateXZ;let t=this.noiseChunk.randomState.router.chunkSurfaceLevel.compute(U.context(this.blockX,0,this.blockZ));this.minSurfaceLevel=Math.floor(t)+this.surfaceDepth-8}return this.minSurfaceLevel}getBiome(){return this.biome===void 0&&(this.biome=this.biomeGetter(te.create(this.blockX,this.blockY,this.blockZ))),this.biome}resolveAnchorY(t){return t(this.context)}getNoiseSampler(t,r){return r?It(this.noiseSamplers2d,t.toString(),()=>this.createNoiseSampler3d(t)):It(this.noiseSamplers3d,t.toString(),()=>this.createNoiseSampler2d(t))}createNoiseSampler2d(t){let r=this.randomState.getOrCreateNoise(t),n=this.lastUpdateXZ-1,s=0;return()=>(n!==this.lastUpdateXZ&&(s=r.get3D(this.blockX,0,this.blockZ),n=this.lastUpdateXZ),s)}createNoiseSampler3d(t){let r=this.randomState.getOrCreateNoise(t),n=this.lastUpdateY-1,s=0;return()=>(n!==this.lastUpdateY&&(s=r.get3D(this.blockX,this.blockY,this.blockZ),n=this.lastUpdateY),s)}},Ct=class{};(function(e){e.NOOP={compile:()=>()=>{}};function t(o){if(typeof o=="string")return new r(he.reference(xe.MATERIAL_RULE,R.parse(o)));let a=M.readObject(o)??{};switch(M.readString(a.type)?.replace(/^minecraft:/,"")){case"block":return new n(se.fromJson(a.result_state));case"sequence":return new s(M.readArray(a.sequence,e.fromJson)??[]);case"condition":return new i(ur.fromJson(a.if_true),e.fromJson(a.then_run));default:return e.NOOP}}e.fromJson=t;class r extends e{holder;constructor(a){super(),this.holder=a}compile(a){return this.holder.value().compile(a)}}e.HolderHolder=r;class n extends e{resultState;constructor(a){super(),this.resultState=a}compile(a){return()=>this.resultState}}e.Block=n;class s extends e{sequence;constructor(a){super(),this.sequence=a}compile(a){if(this.sequence.length===0)return()=>{};if(this.sequence.length===1)return this.sequence[0].compile(a);let l=this.sequence.map(c=>c.compile(a));return(c,u,h)=>{for(let d of l){let f=d(c,u,h);if(f)return f}}}}e.Sequence=s;class i extends e{ifTrue;thenRun;constructor(a,l){super(),this.ifTrue=a,this.thenRun=l}compile(a){let l=this.ifTrue.compile(a),c=this.thenRun.compile(a);return(u,h,d)=>{if(l())return c(u,h,d)}}}e.Condition=i})(Ct=Ct||(Ct={}));var ur=class{};(function(e){e.ALWAYS_FALSE={compile:()=>()=>!1},e.ALWAYS_TRUE={compile:()=>()=>!0};function t(d){if(typeof d=="string")return new n(he.reference(xe.MATERIAL_CONDITION,R.parse(d)));let f=M.readObject(d)??{};switch(M.readString(f.type)?.replace(/^minecraft:/,"")){case"above_preliminary_surface":return new s;case"biome":return new i(Bt.parser(xe.BIOME)(f.biome_is));case"noise_threshold":return new o(R.parse(M.readString(f.noise)??""),M.readNumber(f.min_threshold)??0,M.readNumber(f.max_threshold)??0,M.readBoolean(f.is_3d)??!1);case"not":return new a(e.fromJson(f.invert));case"stone_depth":return new l(M.readInt(f.offset)??0,M.readBoolean(f.add_surface_depth)??!1,M.readInt(f.secondary_depth_range)??0,M.readString(f.surface_type)==="ceiling");case"vertical_gradient":return new c(R.parse(M.readString(f.random_name)??""),Ge.fromJson(f.true_at_and_below),Ge.fromJson(f.false_at_and_above));case"water":return new u(M.readInt(f.offset)??0,M.readInt(f.surface_depth_multiplier)??0,M.readBoolean(f.add_surface_depth)??!1);case"y_above":return new h(Ge.fromJson(f.anchor),M.readInt(f.surface_depth_multiplier)??0,M.readBoolean(f.add_surface_depth)??!1)}return e.ALWAYS_FALSE}e.fromJson=t;function r(d,f){let m=d.lastUpdateY-1,p=!1;return()=>(d.lastUpdateY!==m&&(m=d.lastUpdateY,p=f()),p)}class n extends e{holder;constructor(f){super(),this.holder=f}compile(f){return this.holder.value().compile(f)}}e.HolderHolder=n;class s extends e{compile(f){return()=>f.blockY>=f.getMinSurfaceLevel()}}e.AbovePreliminarySurface=s;class i extends e{biomes;constructor(f){super(),this.biomes=f}compile(f){let m=new Set(Array(...this.biomes.value().getEntries()).map(p=>p.key().toString()));return r(f,()=>m.has(f.getBiome().toString()))}}e.Biome=i;class o extends e{noise;minThreshold;maxThreshold;is3d;constructor(f,m,p,g){super(),this.noise=f,this.minThreshold=m,this.maxThreshold=p,this.is3d=g}compile(f){let m=f.getNoiseSampler(this.noise,this.is3d);return()=>{let p=m();return this.minThreshold<=p&&p<=this.maxThreshold}}}e.NoiseThreshold=o;class a extends e{invert;constructor(f){super(),this.invert=f}compile(f){let m=this.invert.compile(f);return()=>!m()}}e.Not=a;class l extends e{offset;addSurfaceDepth;secondaryDepthRange;ceiling;constructor(f,m,p,g){super(),this.offset=f,this.addSurfaceDepth=m,this.secondaryDepthRange=p,this.ceiling=g}compile(f){return r(f,()=>{let m=this.ceiling?f.stoneDepthBelow:f.stoneDepthAbove,p=this.addSurfaceDepth?f.surfaceDepth:0,g=this.secondaryDepthRange===0?0:sn(f.getSurfaceSecondary(),-1,1,0,this.secondaryDepthRange);return m<=1+this.offset+p+g})}}e.StoneDepth=l;class c extends e{randomName;trueAtAndBelow;falseAtAndAbove;constructor(f,m,p){super(),this.randomName=f,this.trueAtAndBelow=m,this.falseAtAndAbove=p}compile(f){let m=f.resolveAnchorY(this.trueAtAndBelow),p=f.resolveAnchorY(this.falseAtAndAbove),g=f.system.getOrCreateRandom(this.randomName);return r(f,()=>{if(f.blockY<=m)return!0;if(f.blockY>=p)return!1;let w=sn(f.blockY,m,p,1,0);return g.at(f.blockX,f.blockY,f.blockZ).nextFloat(){if(f.waterHeight===Number.MIN_SAFE_INTEGER)return!0;let m=this.addStoneDepth?f.stoneDepthAbove:0;return f.blockY+m>=f.waterHeight+this.offset+f.surfaceDepth*this.surfaceDepthMultiplier})}}e.Water=u;class h extends e{anchor;surfaceDepthMultiplier;addStoneDepth;constructor(f,m,p){super(),this.anchor=f,this.surfaceDepthMultiplier=m,this.addStoneDepth=p}compile(f){return r(f,()=>{let m=this.addStoneDepth?f.stoneDepthAbove:0;return f.blockY+m>=f.resolveAnchorY(this.anchor)+f.surfaceDepth*this.surfaceDepthMultiplier})}}e.YAbove=h})(ur=ur||(ur={}));var Ft;(function(e){let t=i=>new U.HolderHolder(he.parser(xe.DENSITY_FUNCTION,U.fromJson)(i));function r(i){let o=M.readObject(i)??{};return{temperature:t(o.temperature),vegetation:t(o.vegetation),continents:t(o.continents),erosion:t(o.erosion),depth:t(o.depth),ridges:t(o.ridges),chunkSurfaceLevel:t(o.preliminary_surface_level),finalDensity:t(o.final_density)}}e.fromJson=r;function n(i){return{temperature:U.Constant.ZERO,vegetation:U.Constant.ZERO,continents:U.Constant.ZERO,erosion:U.Constant.ZERO,depth:U.Constant.ZERO,ridges:U.Constant.ZERO,chunkSurfaceLevel:U.Constant.ZERO,finalDensity:U.Constant.ZERO,...i}}e.create=n;function s(i,o){return{temperature:i.temperature.mapAll(o),vegetation:i.vegetation.mapAll(o),continents:i.continents.mapAll(o),erosion:i.erosion.mapAll(o),depth:i.depth.mapAll(o),ridges:i.ridges.mapAll(o),chunkSurfaceLevel:i.chunkSurfaceLevel.mapAll(o),finalDensity:i.finalDensity.mapAll(o)}}e.mapAll=s})(Ft=Ft||(Ft={}));var hn;(function(e){function t(n){let s=M.readObject(n)??{};return{minY:M.readInt(s.min_y)??0,height:M.readInt(s.height)??256}}e.fromJson=t;function r(n){return{minY:0,height:256,...n}}e.create=r})(hn=hn||(hn={}));var Vt;(function(e){function t(n){let s=M.readObject(n)??{};return{noise:hn.fromJson(s.noise),defaultBlock:se.fromJson(s.default_block),defaultFluid:se.fromJson(s.default_fluid),noiseRouter:Ft.fromJson(s.noise_router),materialRule:Ct.fromJson(s.material_rule),seaLevel:M.readInt(s.sea_level)??0,aquifers:s.aquifers?Wn.fromJson(s.aquifers):void 0,legacyRandomSource:M.readBoolean(s.legacy_random_source)??!1}}e.fromJson=t;function r(n){return{noise:hn.create({}),defaultBlock:se.STONE,defaultFluid:se.WATER,noiseRouter:Ft.create({}),materialRule:Ct.NOOP,seaLevel:0,aquifers:void 0,legacyRandomSource:!1,...n}}e.create=r})(Vt=Vt||(Vt={}));var xe=class e{static NOISE=$e.createAndRegister("worldgen/noise",Cr.fromJson);static DENSITY_FUNCTION=$e.createAndRegister("worldgen/density_function",t=>U.fromJson(t));static NOISE_SETTINGS=$e.createAndRegister("worldgen/noise_settings",Vt.fromJson);static MATERIAL_RULE=$e.createAndRegister("worldgen/material_rule",Ct.fromJson);static MATERIAL_CONDITION=$e.createAndRegister("worldgen/material_condition",ur.fromJson);static BIOME=$e.createAndRegister("worldgen/biome");static SURFACE_NOISE=e.createNoise("surface",.9381732587751008,-6,[1,1,1]);static SURFACE_SECONDARY_NOISE=e.createNoise("surface_secondary",1.0582769165096106,-6,[1,1,0,1]);static createNoise(t,r,n,s){return e.NOISE.register(R.create(t),new Cr(r,n,s.length,"enabled",s),!0)}};var U=class{computeVolume(t){let r=0,n=Array(t.size());for(let s=0;s{let _=M.readArray(Q,S=>M.readNumber(S)??0)??[];return new je(_[0]??0,_[1]??0,_[2]??0)};function i(Q,_=i){if(typeof Q=="string")return new a(he.reference(xe.DENSITY_FUNCTION,R.parse(Q)));if(typeof Q=="number")return new o(Q);let S=M.readObject(Q)??{},O=M.readString(S.type)?.replace(/^minecraft:/,"");switch(O){case"blend_alpha":return new l(1,0,1);case"blend_offset":return new l(0,-1/0,1/0);case"beardifier":return new l(0,-1/0,1/0);case"old_blended_noise":return new c(M.readNumber(S.xz_scale)??1,M.readNumber(S.y_scale)??1,M.readNumber(S.xz_factor)??80,M.readNumber(S.y_factor)??160,M.readNumber(S.smear_scale_multiplier)??8);case"interpolated":return new h(_(S.input??S.argument),M.readInt(S.cell_size_xz)??4,M.readInt(S.cell_size_y)??4);case"cache":return new u(_(S.input??S.argument));case"noise":return new d(n(S.noise),M.readNumber(S.xz_scale)??1,M.readNumber(S.y_scale)??1,S.shift_x?_(S.shift_x):e.Constant.ZERO,S.shift_y?_(S.shift_y):e.Constant.ZERO,S.shift_z?_(S.shift_z):e.Constant.ZERO);case"end_outer_islands":return new f;case"find_top_surface":return new m(_(S.density),_(S.upper_bound),M.readInt(S.lower_bound)??0,M.readInt(S.cell_height)??1);case"range_choice":return new p(_(S.input),M.readNumber(S.min_inclusive)??0,M.readNumber(S.max_exclusive)??1,_(S.when_in_range),_(S.when_out_of_range));case"shift_a":return new w(n(S.noise??S.argument));case"shift_b":return new x(n(S.noise??S.argument));case"shift":return new v(n(S.noise??S.argument));case"blend_density":return new y(_(S.input??S.argument));case"clamp":return new I(_(S.input),M.readNumber(S.min)??0,M.readNumber(S.max)??1);case"interval_select":return new b(_(S.input),M.readArray(S.thresholds,j=>M.readNumber(j)??0)??[],M.readArray(S.functions,_)??[]);case"abs":case"square":case"cube":case"sqrt":case"half_negative":case"quarter_negative":case"squeeze":case"reciprocal":case"negate":case"log":case"sign":return new E(O,_(S.input??S.argument));case"add":case"sub":case"mul":case"div":case"min":case"max":return new N(M.readEnum(O,A),_(S.left??S.argument1),_(S.right??S.argument2));case"spline":return new Y(Jn.fromJson(S.spline,_));case"constant":return new o(M.readNumber(S.value??S.argument)??0);case"gradient":return new ce(M.readEnum(S.axis,$),M.readEnum(S.tiling,V),M.readInt(S.from_coordinate)??0,M.readInt(S.to_coordinate)??1,M.readNumber(S.from_value)??0,M.readNumber(S.to_value)??1);case"lerp":return new oe(_(S.alpha),_(S.first),_(S.second));case"floor":case"round":case"ceil":case"truncate":return new B(O,_(S.input),_(S.multiple));case"pow":return new D(_(S.base),_(S.exponent));case"distance_to_point":return new ee(s(S.point),M.readEnum(S.metric,ie));case"slice":return new de(M.readEnum(S.axis,$),M.readInt(S.coordinate)??0,_(S.input))}return o.ZERO}e.fromJson=i;class o extends e{value;static ZERO=new o(0);static ONE=new o(1);constructor(_){super(),this.value=_}compute(){return this.value}mapChildren(_){return this}range(){return J.ofExact(this.value)}}e.Constant=o;class a extends e{holder;constructor(_){super(),this.holder=_}compute(_){return this.holder.value().compute(_)}mapChildren(_){return new a(he.direct(_.apply(this.holder.value())))}range(){return this.holder.value().range()}}e.HolderHolder=a;class l extends e.Constant{min;max;constructor(_,S,O){super(_),this.min=S,this.max=O}range(){return J.of(this.min,this.max)}}e.ConstantMinMax=l;class c extends e{xzScale;yScale;xzFactor;yFactor;smearScaleMultiplier;blendedNoise;constructor(_,S,O,j,ue,qe){super(),this.xzScale=_,this.yScale=S,this.xzFactor=O,this.yFactor=j,this.smearScaleMultiplier=ue,this.blendedNoise=qe}compute(_){return this.blendedNoise?.sample(_.x,_.y,_.z)??0}mapChildren(_){return this}range(){return this.blendedNoise?this.blendedNoise.range():J.INFINITE}}e.OldBlendedNoise=c;class u extends e{input;constructor(_){super(),this.input=_}compute(_){return this.input.compute(_)}mapChildren(_){return new u(_.apply(this.input))}range(){return this.input.range()}}e.Cache=u;class h extends e{input;cellSizeXz;cellSizeY;values;constructor(_,S,O){super(),this.input=_,this.cellSizeXz=S,this.cellSizeY=O,this.values=new Map}compute({x:_,y:S,z:O}){let j=this.cellSizeXz,ue=this.cellSizeY,qe=(_%j+j)%j/j,Ae=(S%ue+ue)%ue/ue,Ne=(O%j+j)%j/j,ye=Math.floor(_/j)*j,le=Math.floor(S/ue)*ue,q=Math.floor(O/j)*j;return $c(qe,Ae,Ne,()=>this.computeCorner(ye,le,q),()=>this.computeCorner(ye+j,le,q),()=>this.computeCorner(ye,le+ue,q),()=>this.computeCorner(ye+j,le+ue,q),()=>this.computeCorner(ye,le,q+j),()=>this.computeCorner(ye+j,le,q+j),()=>this.computeCorner(ye,le+ue,q+j),()=>this.computeCorner(ye+j,le+ue,q+j))}computeCorner(_,S,O){return It(this.values,`${_} ${S} ${O}`,()=>this.input.compute(e.context(_,S,O)))}mapChildren(_){return new h(_.apply(this.input),this.cellSizeXz,this.cellSizeY)}range(){return this.input.range()}}e.Interpolated=h;class d extends e{noise;xzScale;yScale;shiftX;shiftY;shiftZ;noiseSampler;constructor(_,S,O,j,ue,qe,Ae){super(),this.noise=_,this.xzScale=S,this.yScale=O,this.shiftX=j,this.shiftY=ue,this.shiftZ=qe,this.noiseSampler=Ae}compute(_){let S=_.x*this.xzScale+this.shiftX.compute(_),O=_.y*this.yScale+this.shiftY.compute(_),j=_.z*this.xzScale+this.shiftZ.compute(_);return this.noiseSampler?.get3D(S,O,j)??0}mapChildren(_){return new d(this.noise,this.xzScale,this.yScale,_.apply(this.shiftX),_.apply(this.shiftY),_.apply(this.shiftZ),this.noiseSampler)}range(){return this.noiseSampler?this.noiseSampler.range():J.INFINITE}}e.NoiseFunction=d;class f extends e{islandNoise;constructor(_){super();let S=new Oe(_??BigInt(0));S.consume(17292),this.islandNoise=new Ui(S)}getHeightValue(_,S){let O=Math.floor(_/2),j=Math.floor(S/2),ue=_%2,qe=S%2,Ae=Fe(100-Math.sqrt(_*_+S*S)*8,-100,80);for(let Ne=-12;Ne<=12;Ne+=1)for(let ye=-12;ye<=12;ye+=1){let le=O+Ne,q=j+ye;if(le*le+q*q<=4096||this.islandNoise.get2D(le,q)>=-.9)continue;let L=(Math.abs(le)*3439+Math.abs(q)*147)%13+9,ae=ue+Ne*2,Se=qe+ye*2,ft=100-Math.sqrt(ae*ae+Se*Se)*L,Qe=Fe(ft,-100,80);Ae=Math.max(Ae,Qe)}return Ae}compute({x:_,y:S,z:O}){return(this.getHeightValue(Math.floor(_/8),Math.floor(O/8))-8)/128}mapChildren(_){return this}range(){return J.of(-.84375,.5625)}}e.EndOuterIslands=f;class m extends e{density;upperBound;lowerBound;cellHeight;constructor(_,S,O,j){super(),this.density=_,this.upperBound=S,this.lowerBound=O,this.cellHeight=j}compute(_){let S=Math.floor(this.upperBound.compute(_)/this.cellHeight)*this.cellHeight;if(S=this.lowerBound;O-=this.cellHeight)if(this.density.compute(e.context(_.x,O,_.z))>0)return O;return this.lowerBound}mapChildren(_){return new m(_.apply(this.density),_.apply(this.upperBound),this.lowerBound,this.cellHeight)}range(){return J.of(this.lowerBound,Math.max(this.lowerBound,this.upperBound.range().max))}}e.FindTopSurface=m;class p extends e{input;minInclusive;maxExclusive;whenInRange;whenOutOfRange;constructor(_,S,O,j,ue){super(),this.input=_,this.minInclusive=S,this.maxExclusive=O,this.whenInRange=j,this.whenOutOfRange=ue}compute(_){let S=this.input.compute(_);return this.minInclusive<=S&&S_.apply(S)))}range(){return J.encapsulating(...this.functions.map(_=>_.range()))}}e.IntervalSelect=b;let k=["abs","square","cube","sqrt","half_negative","quarter_negative","squeeze","reciprocal","negate","log","sign"];class E extends r{type;constructor(_,S){super(S),this.type=_}transform(_,S){return E.transform(this.type,S)}static transform(_,S){switch(_){case"abs":return Math.abs(S);case"square":return S*S;case"cube":return S*S*S;case"half_negative":return S>0?S:S*.5;case"quarter_negative":return S>0?S:S*.25;case"squeeze":let O=Fe(S,-1,1);return O/2-O*O*O/24;case"reciprocal":return 1/S;case"negate":return-S;case"sqrt":return Math.sqrt(S);case"log":return Math.log(S);case"sign":return Math.sign(S)}}mapChildren(_){return new E(this.type,_.apply(this.input))}range(){let _=this.input.range();switch(this.type){case"abs":return J.abs(_);case"square":return J.square(_);case"cube":case"half_negative":case"quarter_negative":case"squeeze":return J.mapMonotonic(_,S=>E.transform(this.type,S));case"reciprocal":return J.reciprocal(_);case"negate":return J.sub(J.ofExact(0),_);case"sqrt":return J.pow(_,J.ofExact(.5));case"log":return J.log(_);case"sign":return J.sign(_)}}}e.Unary=E;let A=["add","sub","mul","div","min","max"];class N extends e{type;left;right;rightRange=J.INFINITE;constructor(_,S,O){super(),this.type=_,this.left=S,this.right=O}compute(_){let S=this.left.compute(_);switch(this.type){case"add":return S+this.right.compute(_);case"sub":return S-this.right.compute(_);case"mul":return S===0?0:S*this.right.compute(_);case"div":return S===0?0:S/this.right.compute(_);case"min":return Sthis.rightRange.max?S:Math.max(S,this.right.compute(_))}}mapChildren(_){return new N(this.type,_.apply(this.left),_.apply(this.right))}range(){let _=this.left.range(),S=this.right.range();switch(this.type){case"add":return J.add(_,S);case"sub":return J.sub(_,S);case"mul":return J.mul(_,S);case"div":return J.div(_,S);case"min":return J.min(_,S);case"max":return J.max(_,S)}}trySimplify(){if(this.type==="mul"||this.type==="add"){if(this.left instanceof o)return new F(this.type,this.right,this.left.value);if(this.right instanceof o)return new F(this.type,this.left,this.right.value)}return this.rightRange=this.right.range(),this}}e.Binary=N;let z=["add","mul"];class F extends r{type;value;constructor(_,S,O){super(S),this.type=_,this.value=O}transform(_,S){switch(this.type){case"mul":return S*this.value;case"add":return S+this.value}}mapChildren(_){return new F(this.type,_.apply(this.input),this.value)}range(){switch(this.type){case"mul":return J.mul(this.input.range(),J.ofExact(this.value));case"add":return J.add(this.input.range(),J.ofExact(this.value))}}}e.MulOrAdd=F;class Y extends e{spline;constructor(_){super(),this.spline=_}compute(_){return this.spline.compute(_)}mapChildren(_){return new Y(this.spline.mapCoordinates(S=>S instanceof e?_.apply(S):S))}range(){return this.spline.range()}}e.Spline=Y;let $=["x","y","z"],V=["clamp_to_edge","repeat","mirrored_repeat"];class ce extends e{axis;tiling;fromCoordinate;toCoordinate;fromValue;toValue;constructor(_,S,O,j,ue,qe){super(),this.axis=_,this.tiling=S,this.fromCoordinate=O,this.toCoordinate=j,this.fromValue=ue,this.toValue=qe}compute(_){let S=this.toCoordinate-this.fromCoordinate,O=_[this.axis]-this.fromCoordinate;switch(this.tiling){case"clamp_to_edge":break;case"repeat":O=(O%S+S)%S;break;case"mirrored_repeat":let j=Math.floor(O/S),ue=O-j*S;O=(j&1)==0?ue:S-ue;break}return Xs(O/S,this.fromValue,this.toValue)}mapChildren(_){return this}range(){return J.between(this.fromValue,this.toValue)}}e.Gradient=ce;class oe extends e{alpha;first;second;constructor(_,S,O){super(),this.alpha=_,this.first=S,this.second=O}compute(_){let S=this.alpha.compute(_);return S===0?this.first.compute(_):S===1?this.second.compute(_):Or(S,this.first.compute(_),this.second.compute(_))}mapChildren(_){return new oe(_.apply(this.alpha),_.apply(this.first),_.apply(this.second))}range(){return J.lerp(this.alpha.range(),this.first.range(),this.second.range())}}e.Lerp=oe;let T=["floor","round","ceil","truncate"];class B extends e{type;input;multiple;constructor(_,S,O){super(),this.type=_,this.input=S,this.multiple=O}compute(_){let S=this.input.compute(_),O=this.multiple.compute(_);return O===0?S:this.roundToInteger(S/O)*O}roundToInteger(_){switch(this.type){case"floor":return Math.floor(_);case"round":return Math.round(_);case"ceil":return Math.ceil(_);case"truncate":return Math.trunc(_)}}mapChildren(_){return new B(this.type,_.apply(this.input),_.apply(this.multiple))}range(){let _=this.multiple.range();return J.mul(J.mapMonotonic(J.div(this.input.range(),_),S=>this.roundToInteger(S)),_)}}e.Round=B;class D extends e{base;exponent;constructor(_,S){super(),this.base=_,this.exponent=S}compute(_){return Math.pow(this.base.compute(_),this.exponent.compute(_))}mapChildren(_){return new D(_.apply(this.base),_.apply(this.exponent))}range(){return J.pow(this.base.range(),this.exponent.range())}}e.Pow=D;let ie=["euclidean","euclidean_squared","manhattan","chebyshev"];class ee extends e{point;metric;constructor(_,S){super(),this.point=_,this.metric=S}compute(_){let S=this.point.sub(new je(_.x,_.y,_.z));switch(this.metric){case"euclidean":return S.length();case"euclidean_squared":return S.lengthSquared();case"manhattan":return Math.abs(S.x)+Math.abs(S.y)+Math.abs(S.z);case"chebyshev":return Math.max(Math.abs(S.x),Math.abs(S.y),Math.abs(S.z))}}mapChildren(_){return this}range(){return J.of(0,1/0)}}e.DistanceToPoint=ee;class de extends e{axis;coordinate;input;constructor(_,S,O){super(),this.axis=_,this.coordinate=S,this.input=O}compute(_){switch(this.axis){case"x":return this.input.compute({x:0,y:_.y,z:_.z});case"y":return this.input.compute({x:0,y:_.y,z:_.z});case"z":return this.input.compute({x:0,y:_.y,z:_.z})}}mapChildren(_){return new de(this.axis,this.coordinate,_.apply(this.input))}range(){return this.input.range()}}e.Slice=de})(U=U||(U={}));var Mt=class{sizeX;sizeY;sizeZ;minBlockX;minBlockY;minBlockZ;stepBlockX;stepBlockY;stepBlockZ;constructor(t,r,n,s,i,o,a=1,l=1,c=1){this.sizeX=t,this.sizeY=r,this.sizeZ=n,this.minBlockX=s,this.minBlockY=i,this.minBlockZ=o,this.stepBlockX=a,this.stepBlockY=l,this.stepBlockZ=c}indexUnchecked(t,r,n){return r+(t+n*this.sizeX)*this.sizeY}blockX(t){return this.minBlockX+t*this.stepBlockX}blockY(t){return this.minBlockY+t*this.stepBlockY}blockZ(t){return this.minBlockZ+t*this.stepBlockZ}maxBlockX(){return this.minBlockX+this.sizeX*this.stepBlockX-1}maxBlockY(){return this.minBlockY+this.sizeY*this.stepBlockY-1}maxBlockZ(){return this.minBlockZ+this.sizeZ*this.stepBlockZ-1}size(){return this.sizeX*this.sizeY*this.sizeZ}};var Wn;(function(e){let t=s=>new U.HolderHolder(he.parser(xe.DENSITY_FUNCTION,U.fromJson)(s));function r(s){let i=M.readObject(s)??{};return{barrier:t(i.barrier),fluidLevelFloodedness:t(i.fluid_level_floodedness),fluidLevelSpread:t(i.fluid_level_spread),lava:t(i.lava),exclusion:t(i.exclusion),surfaceLevel:t(i.surface_level)}}e.fromJson=r;function n(s,i){return{barrier:s.barrier.mapAll(i),fluidLevelFloodedness:s.fluidLevelFloodedness.mapAll(i),fluidLevelSpread:s.fluidLevelSpread.mapAll(i),lava:s.lava.mapAll(i),exclusion:s.exclusion.mapAll(i),surfaceLevel:s.surfaceLevel.mapAll(i)}}e.mapAll=n})(Wn=Wn||(Wn={}));var dn=class{level;type;constructor(t,r){this.level=t,this.type=r}at(t){return t0))return r(n,s,i).at(s)}}}e.createDisabled=t})(Vn=Vn||(Vn={}));var Wi=class e{config;random;volume;globalFluidPicker;static X_SPACING=16;static Y_SPACING=12;static Z_SPACING=16;static SURFACE_SAMPLING=[[-2,-1],[-1,-1],[0,-1],[1,-1],[-3,0],[-2,0],[-1,0],[0,0],[1,0],[-2,1],[-1,1],[0,1],[1,1]];minGridX;minGridY;minGridZ;maxGridX;maxGridY;maxGridZ;gridSizeX;gridSizeY;gridSizeZ;aquiferCache;aquiferLocationCache;surfaceLevelCache;skipSamplingAboveY;constructor(t,r,n,s){this.config=t,this.random=r,this.volume=n,this.globalFluidPicker=s,this.minGridX=this.gridX(n.minBlockX-5)+0,this.maxGridX=this.gridX(n.maxBlockX()-5)+1,this.gridSizeX=this.maxGridX-this.minGridX+1,this.minGridY=this.gridY(n.minBlockY+1)-1,this.maxGridY=this.gridY(n.maxBlockY()+1)+1,this.gridSizeY=this.maxGridY-this.minGridY+1,this.minGridZ=this.gridZ(n.minBlockZ-5)+0,this.maxGridZ=this.gridZ(n.maxBlockZ()-5)+1,this.gridSizeZ=this.maxGridZ-this.minGridZ+1;let i=this.gridSizeX*this.gridSizeY*this.gridSizeZ;this.aquiferCache=Array(i).fill(void 0),this.aquiferLocationCache=Array(i).fill(void 0),this.surfaceLevelCache=new Map;let o=this.adjustSurfaceLevel(this.maxSurfaceLevel(this.fromGridX(this.minGridX,0),this.fromGridZ(this.minGridZ,0),this.fromGridX(this.maxGridX,9),this.fromGridZ(this.maxGridZ,9)));this.skipSamplingAboveY=this.fromGridY(this.gridY(o+12)+1,11)}computeSubstance(t,r,n,s){if(s>0)return;let i=this.globalFluidPicker(t,r,n);if(r>this.skipSamplingAboveY)return i.at(r);if(i.at(r).is(se.LAVA))return se.LAVA;let o=this.gridX(t-5),a=this.gridY(r+1),l=this.gridZ(n-5),c=Number.MAX_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=0,f=0,m=0;for(let E=0;E<=1;E+=1)for(let A=-1;A<=1;A+=1)for(let N=0;N<=1;N+=1){let z=o+E,F=a+A,Y=l+N,$=this.getIndex(z,F,Y),V=this.aquiferLocationCache[$];if(V===void 0){let D=this.random.at(z,F,Y);V=te.create(this.fromGridX(z,D.nextInt(10)),this.fromGridY(F,D.nextInt(10)),this.fromGridZ(Y,D.nextInt(10))),this.aquiferLocationCache[$]=V}let ce=V[0]-t,oe=V[1]-r,T=V[2]-n,B=ce*ce+oe*oe+T*T;c>=B?(m=f,f=d,d=$,h=u,u=c,c=B):u>=B?(m=f,f=$,h=u,u=B):h>=B&&(m=$,h=B)}let p=this.getAquiferStatus(d),g=e.similarity(c,u),w=p.at(r);if(g<=0||w.is(se.WATER)&&this.globalFluidPicker(t,r-1,n).at(r-1).is(se.LAVA))return w;let x={value:void 0},v=this.getAquiferStatus(f),y=g*this.calculatePressure(t,r,n,x,p,v);if(s+y>0)return;let I=this.getAquiferStatus(m),b=e.similarity(c,h);if(b>0){let E=g*b*this.calculatePressure(t,r,n,x,p,I);if(s+E>0)return}let k=e.similarity(u,h);if(k>0){let E=g*k*this.calculatePressure(t,r,n,x,v,I);if(s+E>0)return}return w}static similarity(t,r){return 1-Math.abs(r-t)/25}calculatePressure(t,r,n,s,i,o){let a=i.at(r),l=o.at(r);if(a.is(se.LAVA)&&l.is(se.WATER)||a.is(se.WATER)&&l.is(se.LAVA))return 2;let c=Math.abs(i.level-o.level);if(c===0)return 0;let u=(i.level+o.level)/2,h=r+.5-u,d=c/2-Math.abs(h),f=h>0?d>0?d/1.5:d/2.5:d+3>0?(d+3)/3:(d+3)/10;return f<-2||f>2?2*f:(s.value===void 0&&(s.value=this.config.barrier.compute(U.context(t,r,n))),2*(f+s.value))}getAquiferStatus(t){let r=this.aquiferCache[t];if(r!==void 0)return r;let n=this.aquiferLocationCache[t];if(n===void 0)throw new Error(`Missing aquifer location cache at index ${t}`);let[s,i,o]=n,a=this.computeFluid(s,i,o);return this.aquiferCache[t]=a,a}computeFluid(t,r,n){let s=this.globalFluidPicker(t,r,n),i=Number.MAX_SAFE_INTEGER,o=!1;for(let[l,c]of e.SURFACE_SAMPLING){let u=t+(c<<4),h=n+(c<<4),d=this.surfaceLevel(u,h),f=this.adjustSurfaceLevel(d),m=l===0&&c===0;if(m&&r-12>f)return s;if(m||r+12>f){let p=this.globalFluidPicker(u,f,h);if(!p.at(f).is(se.AIR))if(m)o=!0;else return p}i=Math.min(i,d)}let a=this.computeSurfaceLevel(t,r,n,s,i,o);return new dn(a,this.computeFluidType(t,r,n,s,a))}surfaceLevel(t,r){let n=t>>2<<2,s=r>>2<<2;return It(this.surfaceLevelCache,Je.asLong(n,s),()=>Ue(this.config.surfaceLevel.compute(U.context(n,0,s))))}maxSurfaceLevel(t,r,n,s){let i=t>>2,o=n>>2,a=r>>2,l=s>>2,c=new Mt(o-i+1,1,l-a+1,i<<2,0,a<<2,4,1,4),u=this.config.surfaceLevel.computeVolume(c),h=-1/0;for(let d=0;dh&&(h=m)}return h}adjustSurfaceLevel(t){return t+8}computeSurfaceLevel(t,r,n,s,i,o){let a,l;if(this.config.exclusion.compute(U.context(t,r,n))>0)a=-1,l=-1;else{let c=this.adjustSurfaceLevel(i)-r,u=o?qc(c,0,64,1,0):0,h=Fe(this.config.fluidLevelFloodedness.compute(U.context(t,r,n)),-1,1),d=sn(u,1,0,-.3,.8),f=sn(u,1,0,-.8,.4);a=h-f,l=h-d}return l>0?s.level:a>0?this.computeRandomizedFluidSurfaceLevel(t,r,n,i):Number.MIN_SAFE_INTEGER}computeRandomizedFluidSurfaceLevel(t,r,n,s){let i=Math.floor(t/16),o=Math.floor(r/40),a=Math.floor(n/40),l=o*40+20,c=this.config.fluidLevelSpread.compute(U.context(i,o,a)),u=Jc(c,3);return Math.min(s,l+u)}computeFluidType(t,r,n,s,i){if(i<=-10&&!s.type.is(se.LAVA)){let o=this.config.lava.compute(U.context(Math.floor(t/64),Math.floor(r/40),Math.floor(n/64)));if(Math.abs(o)>.3)return se.LAVA}return s.type}getIndex(t,r,n){let s=t-this.minGridX,i=r-this.minGridY,o=n-this.minGridZ;return(i*this.gridSizeZ+o)*this.gridSizeX+s}gridX(t){return Math.floor(t/e.X_SPACING)}fromGridX(t,r){return t*e.X_SPACING+r}gridY(t){return Math.floor(t/e.Y_SPACING)}fromGridY(t,r){return t*e.Y_SPACING+r}gridZ(t){return Math.floor(t/e.Z_SPACING)}fromGridZ(t,r){return t*e.Z_SPACING+r}};var Vi=class e{shift;biomes;n;constructor(t,r){if(this.shift=t,this.biomes=r,r.length===0)throw new Error("Cannot create checkerboard biome source without biomes");this.n=r.length}getBiome(t,r,n){let s=(((t>>this.shift)+(n>>this.shift))%this.n+this.n)%this.n;return R.parse(this.biomes[s].toString())}static fromJson(t){let r=M.readObject(t)??{},n=M.readInt(r.scale)??2,s;return typeof r.biomes=="string"?s=[R.parse(r.biomes)]:s=M.readArray(r.biomes,i=>R.parse(M.readString(i)??""))??[],new e(n+2,s)}};var Kt=class e{biome;constructor(t){this.biome=t}getBiome(){return this.biome}static fromJson(t){let r=M.readObject(t)??{},n=R.parse(M.readString(r.biome)??"plains");return new e(n)}};var St;(function(e){function r(m,p,g,w,x,v){return new a(m,p,g,w,x,v)}e.target=r;function n(m,p,g,w,x,v,y){return new o(s(m),s(p),s(g),s(w),s(x),s(v),y)}e.parameters=n;function s(m,p){return typeof m=="number"?new i(m,p??m):m}e.param=s;class i{min;max;constructor(p,g){this.min=p,this.max=g}distance(p){let g=(typeof p=="number"?p:p.min)-this.max,w=this.min-(typeof p=="number"?p:p.max);return g>0?g:Math.max(w,0)}union(p){return new i(Math.min(this.min,p.min),Math.max(this.max,p.max))}static fromJson(p){if(typeof p=="number")return new i(p,p);let[g,w]=M.readArray(p,x=>M.readNumber(x))??[];return new i(g??0,w??0)}}e.Param=i;class o{temperature;humidity;continentalness;erosion;depth;weirdness;offset;constructor(p,g,w,x,v,y,I){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y,this.offset=I}fittness(p){return vt(this.temperature.distance(p.temperature))+vt(this.humidity.distance(p.humidity))+vt(this.continentalness.distance(p.continentalness))+vt(this.erosion.distance(p.erosion))+vt(this.depth.distance(p.depth))+vt(this.weirdness.distance(p.weirdness))+vt(this.offset-p.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new i(this.offset,this.offset)]}static fromJson(p){let g=M.readObject(p)??{};return new o(i.fromJson(g.temperature),i.fromJson(g.humidity),i.fromJson(g.continentalness),i.fromJson(g.erosion),i.fromJson(g.depth),i.fromJson(g.weirdness),M.readNumber(g.offset)??0)}}e.ParamPoint=o;class a{temperature;humidity;continentalness;erosion;depth;weirdness;constructor(p,g,w,x,v,y){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}e.TargetPoint=a;class l{things;index;constructor(p){this.things=p,this.index=new u(p)}find(p){return this.index.search(p,(g,w)=>g.distance(w))}}e.Parameters=l;class c{temperature;humidity;continentalness;erosion;depth;weirdness;constructor(p,g,w,x,v,y){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y}static fromRouter(p){return new e.Sampler(p.temperature,p.vegetation,p.continents,p.erosion,p.depth,p.ridges)}sample(p,g,w){let x=U.context(p<<2,g<<2,w<<2);return e.target(this.temperature.compute(x),this.humidity.compute(x),this.continentalness.compute(x),this.erosion.compute(x),this.depth.compute(x),this.weirdness.compute(x))}}e.Sampler=c;class u{static CHILDREN_PER_NODE=10;root;last_leaf=null;constructor(p){if(p.length===0)throw new Error("At least one point is required to build search tree");this.root=u.build(p.map(([g,w])=>new f(g,w)))}static build(p){if(p.length===1)return p[0];if(p.length<=u.CHILDREN_PER_NODE){let v=p.map(y=>{let I=0;for(let b=0;b<7;b+=1){let k=y.space[b];I+=Math.abs((k.min+k.max)/2)}return{key:I,node:y}}).sort((y,I)=>y.key-I.key).map(({node:y})=>y);return new d(v)}let g=1/0,w=-1,x=[];for(let v=0;v<7;++v){p=u.sort(p,v,!1),x=u.bucketize(p);let y=0;for(let I of x)y+=u.area(I.space);g>y&&(g=y,w=v)}return p=u.sort(p,w,!1),x=u.bucketize(p),x=u.sort(x,w,!0),new d(x.map(v=>u.build(v.children)))}static sort(p,g,w){return p.map(x=>{let v=x.space[g],y=(v.min+v.max)/2;return{key:w?Math.abs(y):y,node:x}}).sort((x,v)=>x.key-v.key).map(({node:x})=>x)}static bucketize(p){let g=[],w=[],x=Math.pow(10,Math.floor(Math.log(p.length-.01)/Math.log(10)));for(let v of p)w.push(v),!(w.lengthnew i(1/0,-1/0));for(let w of p)g=[...Array(7)].map((x,v)=>g[v].union(w.space[v]));return g}search(p,g,w){let x=g?w(g,p):1/0,v=g;for(let y of this.children){let I=w(y,p);if(x<=I)continue;let b=y.search(p,v,w);if(b===null)continue;let k=y==b?I:w(b,p);if(k===0)return b;x<=k||(x=k,v=b)}return v}}e.RSubTree=d;class f extends h{thing;constructor(p,g){super(p.space()),this.thing=g}search(){return this}}e.RLeaf=f})(St=St||(St={}));var Ki=class e{parameters;constructor(t){this.parameters=new St.Parameters(t)}getBiome(t,r,n,s){let i=s.sample(t,r,n);return this.parameters.find(i)}static fromJson(t){let r=M.readObject(t)??{},s=(M.readArray(r.biomes,i=>(o=>({biome:R.parse(M.readString(o.biome)??"plains"),parameters:St.ParamPoint.fromJson(o.parameters)}))(M.readObject(i)??{}))??[]).map(i=>[i.parameters,()=>i.biome]);return new e(s)}};var Qi=class e{static END=R.create("the_end");static HIGHLANDS=R.create("end_highlands");static MIDLANDS=R.create("end_midlands");static ISLANDS=R.create("small_end_islands");static BARRENS=R.create("end_barrens");getBiome(t,r,n,s){let i=t<<2,o=r<<2,a=n<<2,l=i>>4,c=a>>4;if(l*l+c*c<=4096)return e.END;let u=U.context((l*2+1)*8,o,(c*2+1)*8),h=s.erosion.compute(u);return h>.25?e.HIGHLANDS:h>=-.0625?e.MIDLANDS:h>=-.21875?e.BARRENS:e.ISLANDS}static fromJson(t){return new e}};var $r;(function(e){function t(n){let s=M.readObject(n)??{};switch(M.readString(s.type)?.replace(/^minecraft:/,"")){case"fixed":return Kt.fromJson(n);case"checkerboard":return Vi.fromJson(n);case"multi_noise":return Ki.fromJson(n);case"the_end":return Qi.fromJson(n);default:return new Kt(R.create("plains"))}}e.fromJson=t;function r(n,s,i,o,a,l,c,u,h=1,d=!1){if(n instanceof Kt)return l(n.getBiome())?d?{pos:te.create(s,i,o),biome:n.getBiome()}:{pos:te.create(s-a+c.nextInt(a*2+1),i,o-a+c.nextInt(a*2+1)),biome:n.getBiome()}:void 0;let f=s>>2,m=o>>2,p=a>>2,g=i>>2;for(var w=void 0,x=0,v=d?0:p,y=v;y<=p;y+=h)for(var I=-y;I<=y;I+=h){let k=Math.abs(I)===y;for(var b=-y;b<=y;b+=h){if(d&&!(Math.abs(b)===y)&&!k)continue;let E=f+b,A=m+I,N=n.getBiome(E,g,A,u);if(l(N)){if((w===void 0||c.nextInt(x+1)<=.5)&&(w={pos:te.create(E<<2,i,A<<2),biome:N},d))return w;x++}}}return w}e.findBiomeHorizontal=r})($r=$r||($r={}));var Kn;(function(e){function t(r){if(typeof r=="string"&&(r==="WORLD_SURFACE_WG"||r==="WORLD_SURFACE"||r==="OCEAN_FLOOR_WG"||r==="OCEAN_FLOOR"||r==="MOTION_BLOCKING"||r==="MOTION_BLOCKING_NO_LEAVES"))return r}e.fromJson=t})(Kn=Kn||(Kn={}));var Qn;(function(e){function t(l){let c=M.readObject(l)??{};switch(M.readString(c.type)?.replace(/^minecraft:/,"")){case void 0:return r(Ge.fromJson(l));case"constant":return r(Ge.fromJson(c.value));case"uniform":return n(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive));case"biased_to_bottom":return s(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.inner));case"very_biased_to_bottom":return i(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.inner));case"trapezoid":return o(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.plateau));case"weighted_list":return a(M.readArray(c.distribution,h=>{let d=M.readObject(h)??{};return{weight:M.readInt(d.weight)??1,data:t(d.data)}})??[])}return()=>0}e.fromJson=t;function r(l){return(c,u)=>l(u)}e.constant=r;function n(l,c){return(u,h)=>{let d=l(h),f=c(h);return d>f?d:u.nextInt(f-d+1)+d}}e.uniform=n;function s(l,c,u=1){return(h,d)=>{let f=l(d),m=c(d);if(m-f-u+1<=0)return f;{let p=h.nextInt(m-f-u+1);return h.nextInt(p+u)+f}}}e.biased_to_bottom=s;function i(l,c,u=1){return(h,d)=>{let f=l(d),m=c(d);if(m-f-u+1<=0)return f;{let p=$i(h,f+u,m),g=$i(h,f,p-1);return $i(h,f,g-1+u)}}}e.very_biased_to_bottom=i;function o(l,c,u=0){return(h,d)=>{let f=l(d),m=c(d);if(f>m)return f;{let p=m-f;if(u>=p)return Fi(h,f,m);{let g=(p-u)/2,w=p-g;return f+Fi(h,0,w)+Fi(h,0,g)}}}}e.trapezoid=o;function a(l){let c=l.reduce((u,h,d)=>u+h.weight,0);return(u,h)=>{let d=u.nextInt(c);for(let f of l)if(d-=f.weight,d<=0)return f.data(u,h);return 0}}e.weighted_list=a})(Qn=Qn||(Qn={}));var Dr=class{randomState;settings;globalFluidPicker;volume;aquifer;constructor(t,r,n,s){if(this.randomState=t,this.settings=r,this.globalFluidPicker=n,this.volume=s,!r.aquifers)this.aquifer=Vn.createDisabled(n);else{let i=this.randomState.getOrCreateRandom(R.create("aquifer"));this.aquifer=new Wi(r.aquifers,i,s,n)}}};var ei=class{biomeSource;settings;globalFluidPicker;constructor(t,r){this.biomeSource=t,this.settings=r;let n=new dn(-54,se.LAVA),s=new dn(r.seaLevel,r.defaultFluid);this.globalFluidPicker=(i,o,a)=>o!o.equals(se.AIR)&&!o.isFluid():i=o=>!o.equals(se.AIR),this.iterateNoiseColumn(s,t,r,void 0,i)??this.settings.noise.minY}iterateNoiseColumn(t,r,n,s,i){if(this.settings.noise.height<=0)return;let o=new Mt(1,this.settings.noise.height,1,r,this.settings.noise.minY,n),a=new Dr(t,this.settings,this.globalFluidPicker,o),c=t.router.finalDensity.computeVolume(o);for(let u=o.sizeY-1;u>=0;u-=1){let h=c[o.indexUnchecked(0,u,0)],d=o.blockY(u),f=a.aquifer.computeSubstance(r,d,n,h)??this.settings.defaultBlock;if(s!==void 0&&(s[u]=f),i!==void 0&&i(f))return d+1}}buildTerrain(t,r,n,s){let i=this.createNoiseChunk(t,r,n);this.doFill(r,i),this.buildSurface(r,i,s)}doFill(t,r){let n=r.volume,i=r.randomState.router.finalDensity.computeVolume(n);for(let o=0;o=0;u-=1){let h=n.blockY(u),d=t.getOrCreateSection(t.getSectionIndex(h)),f=i[n.indexUnchecked(l,u,o)],m=r.aquifer.computeSubstance(c,h,a,f)??this.settings.defaultBlock;d.setBlockState(l,h&15,o,m)}}}}buildSurface(t,r,n){let s=n??R.create("plains"),i={minY:this.settings.noise.minY,height:this.settings.noise.height,seaLevel:this.settings.seaLevel};r.randomState.surfaceSystem.buildSurface(t,r,this.settings.materialRule,i,()=>s)}computeBiome(t,r,n,s){return this.biomeSource.getBiome(r,n,s,t.sampler)}createNoiseChunk(t,r,n){let s=new Mt(16,this.settings.noise.height,n?1:16,Je.minBlockX(r.pos),this.settings.noise.minY,Je.minBlockZ(r.pos));return new Dr(t,this.settings,this.globalFluidPicker,s)}getWorldgenContext(){return{minY:this.settings.noise.minY,height:this.settings.noise.height,seaLevel:this.settings.seaLevel}}};var Qt=class{seed;noiseInstances;positionalRandoms;random;surfaceSystem;router;sampler;constructor(t,r){this.seed=r,this.noiseInstances=new Map,this.positionalRandoms=new Map,this.random=(t.legacyRandomSource?new Oe(r):on.create(r)).forkPositional(),this.router=Ft.mapAll(t.noiseRouter,this.createVisitor(t.legacyRandomSource));let n=this.router.chunkSurfaceLevel;this.surfaceSystem=new Xi(this,t.defaultBlock,t.seaLevel,n,this.random),this.sampler=St.Sampler.fromRouter(this.router)}createVisitor(t){let r=new Map,n=i=>{let o=i.key();if(o===void 0)throw new Error("Cannot create noise without key");if(t){if(o.equals(R.create("temperature")))return i.value().createForLegacyNetherBiome(new Oe(this.seed+BigInt(0)));if(o.equals(R.create("vegetation")))return i.value().createForLegacyNetherBiome(new Oe(this.seed+BigInt(1)))}return this.getOrCreateNoise(o)},s={apply:i=>{if(i instanceof U.HolderHolder){let o=i.holder.key();if(o!==void 0&&r.has(o.toString()))return r.get(o.toString());{let a=i.holder.value().mapAll(s);return o!==void 0&&r.set(o.toString(),a),a}}if(i instanceof U.NoiseFunction)return new U.NoiseFunction(i.noise,i.xzScale,i.yScale,i.shiftX,i.shiftY,i.shiftZ,n(i.noise));if(i instanceof U.ShiftNoise)return i.withNewNoise(n(i.noise));if(i instanceof U.OldBlendedNoise){let o=t?new Oe(this.seed+BigInt(0)):this.random.fromHashOf(R.create("terrain").toString());return new U.OldBlendedNoise(i.xzScale,i.yScale,i.xzFactor,i.yFactor,i.smearScaleMultiplier,new Ji(o,i.xzScale,i.yScale,i.xzFactor,i.yFactor,i.smearScaleMultiplier))}return i instanceof U.EndOuterIslands?new U.EndOuterIslands(this.seed):i instanceof U.Binary?i.trySimplify():i}};return s}getOrCreateNoise(t){let r=$e.REGISTRY.getOrThrow(R.create("worldgen/noise"));return It(this.noiseInstances,t.toString(),n=>r.getOrThrow(t).create(this.random.fromHashOf(n)))}getOrCreateRandom(t){return It(this.positionalRandoms,t.toString(),r=>this.random.fromHashOf(r).forkPositional())}};var er=class e{static fromJson(t){let r=M.readObject(t)??{};switch(M.readString(r.element_type)?.replace(/^minecraft:/,"")){case"single_pool_element":case"legacy_single_pool_element":let n=R.parse(M.readString(r.location)??""),s={key:()=>n,value:()=>Pr.REGISTRY.get(n)??Pr.EMPTY};return new e.SinlgePoolElement(s);case"list_pool_element":let i=M.readArray("elements",e.fromJson)??[];return new e.ListPoolElement(i);case"feature_pool_element":return new e.FeaturePoolElement;default:return new e.EmptyPoolElement}}};(function(e){class t extends e{getBoundingBox(o,a){throw new Error("Invalid call of EmptyPoolElement")}getShuffledJigsawBlocks(o,a){return[]}toString(){return"[Empty Pool Element]"}}e.EmptyPoolElement=t;class r extends e{defaultJigsawNBT;constructor(){super();let o=new Map;o.set("name",new Xe("minecraft:bottom")),o.set("final_state",new Xe("minecraft:air")),o.set("pool",new Xe("minecraft:empty")),o.set("target",new Xe("minecraft:empty")),o.set("joint",new Xe("rollable")),this.defaultJigsawNBT=new Re(o)}getBoundingBox(o,a){return[o,o]}getShuffledJigsawBlocks(o,a){return[{pos:[0,0,0],state:new se(R.create("jigsaw"),{orientation:"down_south"}),nbt:this.defaultJigsawNBT}]}toString(){return"[Feature Pool Element]"}}e.FeaturePoolElement=r;class n extends e{template;static JIGSAW_ID=R.parse("jigsaw");constructor(o){super(),this.template=o}getBoundingBox(o,a){let l=te.offset(this.template.value().getSize(),-1,-1,-1),c=o,u=te.add(Pr.transform(l,a,te.ZERO),o),h=te.create(Math.min(c[0],u[0]),c[1],Math.min(c[2],u[2])),d=te.create(Math.max(c[0],u[0]),u[1],Math.max(c[2],u[2]));return[h,d]}getShuffledJigsawBlocks(o,a){let l=this.template.value().getBlocks().filter(c=>c.state.getName().equals(n.JIGSAW_ID));return l.forEach(c=>c.pos=Pr.transform(c.pos,o,te.ZERO)),jc(l,a),l}toString(){return`[Single Pool Element: ${this.template.key()}]`}}e.SinlgePoolElement=n;class s extends e{elements;constructor(o){super(),this.elements=o}getBoundingBox(o,a){var l=void 0,c=void 0;for(let u of this.elements){let h=u.getBoundingBox(o,a);!l||!c?(l=h[0],c=h[1]):(l[0]=Math.min(l[0],h[0][0]),l[1]=Math.min(l[1],h[0][1]),l[2]=Math.min(l[2],h[0][2]),c[0]=Math.min(l[0],h[1][0]),c[1]=Math.min(l[1],h[1][1]),c[2]=Math.min(l[2],h[1][2]))}return[l,c]}getShuffledJigsawBlocks(o,a){return this.elements[0].getShuffledJigsawBlocks(o,a)}toString(){return`[List Pool Element: ${"; ".concat(...this.elements.map(o=>o.toString()))}]`}}e.ListPoolElement=s})(er=er||(er={}));var ti=class e{rawTemplates;fallback;static REGISTRY=$e.createAndRegister("worldgen/template_pool",e.fromJson);totalWeight;constructor(t,r){this.rawTemplates=t,this.fallback=r,this.totalWeight=t.reduce((n,s)=>n+s.weight,0)}static structurePoolParser=he.parser(e.REGISTRY,e.fromJson);static fromJson(t){let r=M.readObject(t)??{},n=e.structurePoolParser(r.fallback??""),s=M.readArray(r.elements,i=>{let o=M.readObject(i)??{},a=er.fromJson(o.element),l=M.readInt(o.weight)??1;return{element:a,weight:l}})??[];return new e(s,n)}getRandomTemplate(t){var r=t.nextInt(this.totalWeight);for(let n of this.rawTemplates)if(r-=n.weight,r<0)return n.element;return this.rawTemplates[this.rawTemplates.length-1].element}};var qr=class{settings;constructor(t){this.settings=t}onTopOfChunkCenter(t,r,n,s="WORLD_SURFACE_WG"){let i=(r<<4)+8,o=(n<<4)+8;return[i,t.chunkGenerator.getBaseHeight(i,o,s,t.randomState)-1,o]}getLowestY(t,r,n,s,i){return Math.min(t.chunkGenerator.getBaseHeight(r,n,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r,n+i,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r+s,n,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r+s,n+i,"WORLD_SURFACE_WG",t.randomState)-1)}getLowestYIn5by5BoxOffset7Blocks(t,r,n,s){let i=5,o=5;s===He.CLOCKWISE_90?i=-5:s===He.CLOCKWISE_180?(i=-5,o=-5):s===He.COUNTERCLOCKWISE_90&&(o=-5);let a=(r<<4)+7,l=(n<<4)+7;return te.create(a,this.getLowestY(t,a,l,i,o),l)}tryGenerate(t,r,n){let s=Oe.fromLargeFeatureSeed(n.seed,t,r),i=this.findGenerationPoint(t,r,s,n);if(i===void 0)return;let o=n.biomeSource.getBiome(i[0]>>2,i[1]>>2,i[2]>>2,n.randomState.sampler);return[...this.settings.validBiomes.getEntries()].findIndex(a=>a.key()?.equals(o))>=0?i:void 0}};(function(e){e.REGISTRY=$e.createAndRegister("worldgen/structure",n);class t{validBiomes;constructor(b){this.validBiomes=b}}e.StructureSettings=t;let r=he.parser(ti.REGISTRY,ti.fromJson);function n(I){let b=Bt.parser(xe.BIOME),k=M.readObject(I)??{},E=b(k.biomes),A=new t(E.value());switch(M.readString(k.type)?.replace(/^minecraft:/,"")){case"buried_treasure":return new i(A);case"desert_pyramid":return new a(A);case"end_city":return new l(A);case"fortress":return new c(A);case"igloo":return new u(A);case"jigsaw":let N=Qn.fromJson(k.start_height),z=r(k.start_pool),F=M.readString(k.start_jigsaw_name),Y=F?R.parse(F):void 0,$=Kn.fromJson(k.project_start_to_heightmap),V=s.DimensionPadding.fromJson(k.dimension_padding);return new s(A,z,N,$,Y,V);case"jungle_temple":return new h(A);case"mineshaft":let ce=M.readString(k.mineshaft_type)==="mesa"?"mesa":"normal";return new d(A,ce);case"nether_fossil":return new c(A);case"ocean_monument":return new m(A);case"ocean_ruin":return new p(A);case"ruined_portal":return new g(A);case"shipwreck":let oe=M.readBoolean(k.is_beached)??!1;return new w(A,oe);case"stronghold":return new x(A);case"swamp_hut":return new v(A);case"woodland_mansion":return new y(A)}return new i(A)}e.fromJson=n;class s extends e{startingPoolHolder;startHeight;projectStartToHeightmap;startJigsawName;dimensionPadding;constructor(b,k,E,A,N,z){super(b),this.startingPoolHolder=k,this.startHeight=E,this.projectStartToHeightmap=A,this.startJigsawName=N,this.dimensionPadding=z}findGenerationPoint(b,k,E,A){let N=this.startHeight(E,A.chunkGenerator.getWorldgenContext()),z=te.create(b<<4,N,k<<4),F=He.getRandom(E),$=this.startingPoolHolder.value().getRandomTemplate(E);if(!($ instanceof er.EmptyPoolElement)){let V;if(this.startJigsawName){let ee=s.getRandomNamedJigsaw($,this.startJigsawName,F,E);if(ee===void 0)return;V=ee}else V=te.ZERO;let ce=te.subtract(z,V),oe=$.getBoundingBox(ce,F),T=(oe[1][0]+oe[0][0])/2^0,B=(oe[1][2]+oe[0][2])/2^0,D;return this.projectStartToHeightmap?D=z[1]+A.chunkGenerator.getBaseHeight(T,B,this.projectStartToHeightmap,A.randomState):D=ce[1],oe.forEach(ee=>ee[1]+=D-oe[0][1]-1),s.isStartTooCloseToWorldHeightLimits(this.dimensionPadding,oe,A.levelHeight)?void 0:te.create(T,D+V[1],B)}}static isStartTooCloseToWorldHeightLimits(b,k,E){if(b===s.DimensionPadding.ZERO)return!1;let A=E.minY+b.bottom,N=E.minY+E.height-b.top;return k[0][1]N}static getRandomNamedJigsaw(b,k,E,A){let N=b.getShuffledJigsawBlocks(E,A);for(let z of N)if(R.parse(z.nbt?.getString("name")??"minecraft:empty").equals(k))return z.pos}}e.JigsawStructure=s,(function(I){class b{top;bottom;static ZERO=new b(0,0);constructor(E,A){this.top=E,this.bottom=A}static fromJson(E){if(E===void 0)return b.ZERO;if(typeof E=="number")return new b(E,E);let A=M.readObject(E)??{};return new b(M.readInt(A.top)??0,M.readInt(A.bottom)??0)}}I.DimensionPadding=b})(s=e.JigsawStructure||(e.JigsawStructure={}));class i extends e{findGenerationPoint(b,k,E,A){return this.onTopOfChunkCenter(A,b,k,"OCEAN_FLOOR_WG")}}e.BuriedTreasureStructure=i;class o extends e{width;depth;constructor(b,k,E){super(b),this.width=k,this.depth=E}findGenerationPoint(b,k,E,A){if(!(this.getLowestY(A,b<<4,k<<4,this.width,this.depth)a+l.weight,0);for(;i.length>0;){let a=s.nextInt(o),l,c;for([l,c]of i.entries())if(a-=c.weight,a<0)break;let u=c.structure.value().tryGenerate(t,r,n);if(u!==void 0)return{id:c.structure.key(),pos:u};i.splice(l,1),o-=c.weight}}}};(function(e){class t{structure;weight;constructor(n,s){this.structure=n,this.weight=s}static fromJson(n){let s=M.readObject(n)??{};return new t(he.reference(qr.REGISTRY,R.parse(M.readString(s.structure)??"minecraft:empty")),M.readInt(s.weight)??1)}}e.StructureSelectionEntry=t})(Yr=Yr||(Yr={}));var Jr=class e{locateOffset;frequencyReductionMethod;frequency;salt;exclusionZone;constructor(t,r,n,s,i){this.locateOffset=t,this.frequencyReductionMethod=r,this.frequency=n,this.salt=s,this.exclusionZone=i}static fromJson(t){let r=M.readObject(t)??{},n=M.readString(r.type)?.replace(/^minecraft:/,""),s=te.fromJson(r.locate_offset),i=e.FrequencyReducer.fromType(M.readString(r.frequency_reduction_method)??"default"),o=M.readNumber(r.frequency)??1,a=M.readInt(r.salt)??0,l="exclusion_zone"in r?e.ExclusionZone.fromJson(r.exclusion_zone):void 0;switch(n){case"random_spread":let c=M.readInt(r.spacing)??1,u=M.readInt(r.separation)??1,h=e.SpreadType.fromJson(r.spread_type);return new e.RandomSpreadStructurePlacement(s,i,o,a,l,c,u,h);case"concentric_rings":let d=M.readInt(r.distance)??1,f=M.readInt(r.spread)??1,m=M.readInt(r.count)??1,p=Bt.parser(xe.BIOME)(r.preferred_biomes);return new e.ConcentricRingsStructurePlacement(s,i,o,a,l,d,f,m,p)}return new e.RandomSpreadStructurePlacement([0,0,0],e.FrequencyReducer.ProbabilityReducer,1,0,void 0,1,1,"linear")}isStructureChunk(t,r,n){return this.isPlacementChunk(t,r,n)?this.frequency<1&&!this.frequencyReductionMethod(t,this.salt,r,n,this.frequency)?!1:!(this.exclusionZone&&this.exclusionZone.isPlacementForbidden(t,r,n)):!1}prepare(t,r,n){}};(function(e){let t;(function(a){function l(f){switch(f){case"legacy_type_1":return d;case"legacy_type_2":return h;case"legacy_type_3":return u;default:return c}}a.fromType=l;function c(f,m,p,g,w){return Oe.fromLargeFeatureWithSalt(f,m,p,g).nextFloat()>4,v=g>>4,y=new Oe(BigInt(x^v<<4)^f);return y.nextInt(),y.nextInt(Math.floor(1/w))===0}a.LegacyPillagerOutpostReducer=d})(t=e.FrequencyReducer||(e.FrequencyReducer={}));class r{otherSet;chunkCount;constructor(l,c){this.otherSet=l,this.chunkCount=c}static fromJson(l){let c=M.readObject(l)??{};return new r(he.reference(Yr.REGISTRY,R.parse(M.readString(c.other_set)??"")),M.readInt(c.chunk_count)??1)}isPlacementForbidden(l,c,u){let h=this.otherSet.value().placement;return h.getPotentialStructureChunks(l,c-this.chunkCount,u-this.chunkCount,c+this.chunkCount,u+this.chunkCount).findIndex(d=>Math.abs(d[0]-c)<=this.chunkCount&&Math.abs(d[1]-u)<=this.chunkCount&&h.isStructureChunk(l,d[0],d[1]))>=0}}e.ExclusionZone=r;let n;(function(a){function l(c){return(M.readString(c)??"linear")==="triangular"?"triangular":"linear"}a.fromJson=l})(n=e.SpreadType||(e.SpreadType={}));class s extends e{spacing;separation;spreadType;constructor(l,c,u,h,d,f,m,p){super(l,c,u,h,d),this.spacing=f,this.separation=m,this.spreadType=p}evaluateSpread(l,c){switch(this.spreadType){case"linear":return l.nextInt(c);case"triangular":return Math.floor((l.nextInt(c)+l.nextInt(c))/2)}}getPotentialStructureChunk(l,c,u){let h=Math.floor(c/this.spacing),d=Math.floor(u/this.spacing),f=Oe.fromLargeFeatureWithSalt(l,h,d,this.salt),m=this.spacing-this.separation,p=this.evaluateSpread(f,m),g=this.evaluateSpread(f,m);return[h*this.spacing+p,d*this.spacing+g]}isPlacementChunk(l,c,u){let[h,d]=this.getPotentialStructureChunk(l,c,u);return h===c&&d===u}getPotentialStructureChunks(l,c,u,h,d){let f=[];for(let m=Math.floor(c/this.spacing)*this.spacing;m<=h;m+=this.spacing)for(let p=Math.floor(u/this.spacing)*this.spacing;p<=d;p+=this.spacing)f.push(this.getPotentialStructureChunk(l,m,p));return f}}e.RandomSpreadStructurePlacement=s;let i=112;class o extends e{distance;spread;count;preferredBiomes;positions;constructor(l,c,u,h,d,f,m,p,g){super(l,c,u,h,d),this.distance=f,this.spread=m,this.count=p,this.preferredBiomes=g}prepare(l,c,u){if(this.positions!==void 0||(this.positions=[],this.count===0))return;let h=new Oe(u);var d=h.nextDouble()*Math.PI*2,f=this.spread,m=0,p=0;let g=[...this.preferredBiomes.value().getEntries()].flatMap(x=>x.key()??[]);for(var w=0;w{let A=$r.findBiomeHorizontal(l,I,0,b,i,N=>g.findIndex(z=>z.equals(N))>=0,k,c);return A?[A.pos[0]>>4,A.pos[2]>>4]:[v,y]};this.positions.push({center:[v,y],real:E}),d+=Math.PI*2/f,p++,p==f&&(m++,p=0,f+=2*f/(m+1),f=Math.min(f,this.count-w),d+=h.nextDouble()*Math.PI*2)}}isPlacementChunk(l,c,u){return this.positions===void 0?(console.warn("trying to access concentric rings placement before position calculation"),!1):this.getPotentialStructureChunks(l,c,u,c,u).findIndex(h=>h[0]===c&&h[1]===u)>=0}getPotentialStructureChunks(l,c,u,h,d){if(this.positions===void 0)return console.warn("trying to access concentric rings placement before position calculation"),[];let f=[];for(let m of this.positions)m.center[0]>4)||m.center[0]>h+(i>>4)||m.center[1]>4)||m.center[1]>d+(i>>4)||(m.real instanceof Function&&(m.real=m.real()),f.push(m.real));return f}}e.ConcentricRingsStructurePlacement=o})(Jr=Jr||(Jr={}));var ri=[186,218,247],ni=[30,30,36],ko=[62,58,66],es={air:ri,cave_air:[120,120,130],void_air:ni,stone:[125,125,125],deepslate:[80,80,86],cobblestone:[116,116,116],cobbled_deepslate:[76,76,80],bedrock:[55,55,55],tuff:[108,109,102],calcite:[223,224,220],granite:[149,103,85],diorite:[188,188,188],andesite:[136,136,136],dirt:[134,96,67],coarse_dirt:[119,85,59],rooted_dirt:[144,103,76],grass_block:[109,153,48],podzol:[91,63,24],mycelium:[111,99,105],mud:[60,57,60],moss_block:[89,109,45],sand:[219,207,163],sandstone:[216,203,155],red_sand:[190,102,33],red_sandstone:[186,99,29],gravel:[131,127,126],clay:[160,166,179],snow:[249,254,254],snow_block:[249,254,254],powder_snow:[248,253,253],ice:[145,183,253],packed_ice:[141,180,250],blue_ice:[116,167,253],water:[52,104,196],lava:[207,92,15],obsidian:[15,10,24],netherrack:[97,38,38],soul_sand:[81,62,50],soul_soil:[75,57,46],basalt:[80,81,86],blackstone:[42,36,41],crimson_nylium:[130,31,31],warped_nylium:[43,114,101],nether_wart_block:[114,2,2],warped_wart_block:[22,119,121],end_stone:[219,222,158],terracotta:[152,94,67],white_terracotta:[209,178,161],orange_terracotta:[161,83,37],yellow_terracotta:[186,133,35],brown_terracotta:[77,51,35],red_terracotta:[143,61,46],light_gray_terracotta:[135,106,97],honey_block:[251,185,52],slime_block:[111,192,91],magma_block:[142,63,31],glowstone:[171,131,84],prismarine:[99,156,151],dripstone_block:[134,107,92],sculk:[12,29,36],amethyst_block:[133,97,191]},h2={the_void:[0,0,0],plains:[141,179,96],sunflower_plains:[181,219,136],snowy_plains:[255,255,255],ice_spikes:[180,220,220],desert:[250,148,24],swamp:[7,249,178],mangrove_swamp:[44,204,142],forest:[5,102,33],flower_forest:[45,142,73],birch_forest:[48,116,68],dark_forest:[64,81,26],pale_garden:[178,184,178],old_growth_birch_forest:[88,156,108],old_growth_pine_taiga:[89,102,81],old_growth_spruce_taiga:[129,142,121],taiga:[11,102,89],snowy_taiga:[49,85,74],savanna:[189,178,95],savanna_plateau:[167,157,100],windswept_hills:[96,96,96],windswept_gravelly_hills:[136,136,136],windswept_forest:[80,112,80],windswept_savanna:[229,218,135],jungle:[83,123,9],sparse_jungle:[98,139,23],bamboo_jungle:[118,142,20],badlands:[217,69,21],eroded_badlands:[255,109,61],wooded_badlands:[176,151,101],meadow:[96,164,69],cherry_grove:[255,145,200],grove:[71,114,108],snowy_slopes:[196,196,196],frozen_peaks:[160,160,160],jagged_peaks:[220,220,200],stony_peaks:[123,143,116],river:[0,0,255],frozen_river:[160,160,255],beach:[250,222,85],snowy_beach:[250,240,192],stony_shore:[162,162,132],warm_ocean:[0,0,172],lukewarm_ocean:[0,0,144],deep_lukewarm_ocean:[0,0,64],ocean:[0,0,112],deep_ocean:[0,0,48],cold_ocean:[32,32,112],deep_cold_ocean:[32,32,56],frozen_ocean:[112,112,214],deep_frozen_ocean:[64,64,144],mushroom_fields:[255,0,255],dripstone_caves:[134,96,67],lush_caves:[0,255,0],deep_dark:[3,31,41],nether_wastes:[191,59,59],warped_forest:[73,144,123],crimson_forest:[221,8,8],soul_sand_valley:[94,56,48],basalt_deltas:[64,54,54],the_end:[128,128,255],end_highlands:[181,181,54],end_midlands:[255,255,153],small_end_islands:[144,144,223],end_barrens:[112,112,204]};function au(e,t){let r=2166136261;for(let l=0;l>>0)%360/360,s=.55,i=t<.5?t*(1+s):t+s-t*s,o=2*t-i,a=l=>{l=(l+1)%1;let c=l<1/6?o+(i-o)*6*l:l<1/2?i:l<2/3?o+(i-o)*(2/3-l)*6:o;return Math.round(c*255)};return[a(n+1/3),a(n),a(n-1/3)]}function cu(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)==="minecraft"?e.slice(t+1):null}function ts(e){let t=cu(e);if(t!==null){let r=es[t];if(r)return r;if(t.endsWith("_ore"))return t.startsWith("deepslate")?es.deepslate:es.stone;if(t.includes("terracotta"))return es.terracotta}return au(e,.55)}function Io(e){let t=cu(e);return t!==null&&h2[t]||au(e,.5)}var lu=1<<18;function Eo(e,t,r){return((e+1048576)*2097152+(r+1048576))*2048+(t+1024)}function Ur(e,t,r){return e===0?t:t+e*(r-t)}var Ao=class e extends U{constructor(r,n,s){super();this.input=r;this.cellSizeXz=n;this.cellSizeY=s}input;cellSizeXz;cellSizeY;corners=new Map;corner(r,n,s){let i=Eo(r,n,s),o=this.corners.get(i);if(o===void 0){this.corners.size>=lu&&this.corners.clear();let a=this.cellSizeXz;o=this.input.compute(U.context(r*a,n*this.cellSizeY,s*a)),this.corners.set(i,o)}return o}cell=NaN;c000=0;c100=0;c010=0;c110=0;c001=0;c101=0;c011=0;c111=0;compute({x:r,y:n,z:s}){let i=this.cellSizeXz,o=this.cellSizeY,a=Math.floor(r/i),l=Math.floor(n/o),c=Math.floor(s/i),u=Eo(a,l,c);u!==this.cell&&(this.cell=u,this.c000=this.corner(a,l,c),this.c100=this.corner(a+1,l,c),this.c010=this.corner(a,l+1,c),this.c110=this.corner(a+1,l+1,c),this.c001=this.corner(a,l,c+1),this.c101=this.corner(a+1,l,c+1),this.c011=this.corner(a,l+1,c+1),this.c111=this.corner(a+1,l+1,c+1));let h=(r-a*i)/i,d=(n-l*o)/o,f=(s-c*i)/i,m=Ur(d,Ur(h,this.c000,this.c100),Ur(h,this.c010,this.c110));return f===0?m:Ur(f,m,Ur(d,Ur(h,this.c001,this.c101),Ur(h,this.c011,this.c111)))}mapChildren(r){return new e(r.apply(this.input),this.cellSizeXz,this.cellSizeY)}range(){return this.input.range()}},No=class e extends U{constructor(r){super();this.input=r}input;values=new Map;compute(r){if(!Number.isInteger(r.x)||!Number.isInteger(r.z))return this.input.compute(r);let n=Eo(r.x,0,r.z),s=this.values.get(n);return s===void 0&&(this.values.size>=lu&&this.values.clear(),s=this.input.compute(r),this.values.set(n,s)),s}mapChildren(r){return new e(r.apply(this.input))}range(){return this.input.range()}},Ro=class e extends U{constructor(r){super();this.input=r}input;x=NaN;y=NaN;z=NaN;value=0;compute(r){return(r.x!==this.x||r.y!==this.y||r.z!==this.z)&&(this.value=this.input.compute(r),this.x=r.x,this.y=r.y,this.z=r.z),this.value}mapChildren(r){return new e(r.apply(this.input))}range(){return this.input.range()}};function To(e,t){let r=t.get(e);if(r!==void 0)return r;let n;if(e instanceof U.Constant)n=!1;else if(e instanceof U.Gradient)n=e.axis==="y";else if(e instanceof U.ShiftA||e instanceof U.ShiftB)n=!1;else if(e instanceof U.NoiseFunction)n=e.yScale!==0||[e.shiftX,e.shiftY,e.shiftZ].some(s=>To(s,t));else if(e instanceof U.EndOuterIslands)n=!1;else{let s=[];e.mapChildren({apply:o=>(s.push(o),o)});let i=[U.HolderHolder].some(o=>e instanceof o);n=s.length===0||i?!0:s.some(o=>To(o,t))}return t.set(e,n),n}function rs(e){let t=new WeakMap,r={apply(n){return n instanceof U.Interpolated?new Ao(n.input,n.cellSizeXz,n.cellSizeY):n instanceof U.Cache?To(n.input,t)?new Ro(n.input):new No(n.input):n}};return e.router=Ft.mapAll(e.router,r),e}var Do={noise:xe.NOISE,density_function:xe.DENSITY_FUNCTION,noise_settings:xe.NOISE_SETTINGS,material_rule:xe.MATERIAL_RULE,material_condition:xe.MATERIAL_CONDITION},uu=xe.BIOME;uu.get=uu.getOrThrow=()=>({});var xu=xe.BIOME.getTagRegistry(),vu=[],yu=new Map,bu=0,Lo=0,fu="";function d2(e){let t=e.filter(r=>["noise","density_function","noise_settings","dimension"].includes(r.kind));return JSON.stringify(t,(r,n)=>r==="surface_rule"?void 0:n)}var ii=new Map;async function m2(e){if(!ii.has(e)){let t=null;try{let r=e.startsWith("tag/")?`tag/${e.slice(4)}`:`worldgen/${e}`,n=await fetch(`${pi}/${r}/data.min.json`);n.ok&&(t=await n.json())}catch{t=null}ii.set(e,t)}return ii.get(e)!=null}function hu(e,t,r){if(e==="tag/worldgen/biome"){xu.register(R.parse(t),()=>Bt.fromJson(xe.BIOME,r));return}let n=Do[e];n.register(R.parse(t),()=>n.parse(r))}function p2(){xu.clear();for(let e of Object.values(Do))for(let t of e.keys())t.equals(R.create("surface"))||t.equals(R.create("surface_secondary"))||e.delete(t);for(let[e,t]of ii)if(t)for(let[r,n]of Object.entries(t))hu(e,`minecraft:${r}`,n);for(let e of vu)e.kind!=="dimension"&&hu(e.kind,e.id,e.json)}async function fr(e){for(;;){p2();try{return e()}catch(t){let r=/Missing key in (?:minecraft:)?(worldgen\/[a-z_]+|tags\/worldgen\/biome): minecraft:/.exec(String(t)),n=r?.[1]==="tags/worldgen/biome"?"tag/worldgen/biome":r?.[1].replace("worldgen/","");if(!n||!(n in Do||n==="tag/worldgen/biome")||ii.has(n)||!await m2(n))throw t}}}function _u(e){try{return BigInt(e)}catch{let t=0n;for(let r of e)t=t*31n+BigInt(r.codePointAt(0))&0xffffffffffffffffn;return BigInt.asIntN(64,t)}}function hr(e,t,r,n=1){e[t]=r[0]*n,e[t+1]=r[1]*n,e[t+2]=r[2]*n,e[t+3]=255}var ci=()=>new Promise(e=>setTimeout(e,0)),xt=class extends Error{};function si(e){if(e.seq!==qt)throw new xt}function zo(e){let t=performance.now();return async()=>{performance.now()-t<40||(await ci(),si(e),t=performance.now())}}function g2(e){let t=[],r=new Float32Array(e.length*13),n=[];return e.forEach((s,i)=>{let o=s??{},a=St.ParamPoint.fromJson(o.parameters);t.push(R.parse(typeof o.biome=="string"?o.biome:"plains").toString()),a.space().forEach((l,c)=>{c<6&&(r[i*13+c*2]=l.min,r[i*13+c*2+1]=l.max)}),r[i*13+12]=a.offset,n.push([a,()=>i])}),{entries:{biomes:t,params:r},lookup:new St.Parameters(n)}}function Mu(e){let t=yu.get(e);if(!t)throw new Error(`Missing dimension ${e}`);let r=t.generator??{},n=String(r.type??"").replace(/^minecraft:/,"");if(n!=="noise")throw new Error(`Only noise generators have a preview; this one is ${n||"missing"}.`);let s=typeof r.settings=="string"?xe.NOISE_SETTINGS.getOrThrow(R.parse(r.settings)):Vt.fromJson(r.settings),i=r.biome_source??{},o=String(i.type??"").replace(/^minecraft:/,"");if(o==="multi_noise"&&(i.preset!==void 0||typeof i.biomes=="string"))throw new Error("Multi-noise presets have no preview: their parameters are built into the game. List the biomes inline to map them.");let a=$r.fromJson(i);return o==="multi_noise"&&Array.isArray(i.biomes)&&i.biomes.length>0?{settings:s,biomes:a,...g2(i.biomes)}:{settings:s,biomes:a}}var wt=[],du=new Map;function xn(e){let t=du.get(e);return t===void 0&&(t=wt.length,wt.push(e),du.set(e,t)),t}var ss="",tr=new Map;function Su(e,t,r){return`${e?"x":"z"}|${t}|${r}`}function ku(e,t,r,n){let{settings:s}=e,i=s.noise.minY,o=s.noise.height,a=n*16,l=t?Je.create(n,Math.floor(r/16)):Je.create(Math.floor(r/16),n),c=new qn(i,o,l),u=new ei(new Kt(R.create("plains")),s),h=t?new Mt(16,o,1,a,i,r):new Mt(1,o,16,r,i,a),d=new Mt(16,o,16,Je.minBlockX(l),i,Je.minBlockZ(l)),f=new Dr(e.rs,s,u.globalFluidPicker,d),m=e.rs.router.finalDensity.computeVolume(h);for(let w=0;w<16;w++){let[x,v]=t?[w,0]:[0,w],y=h.blockX(x),I=h.blockZ(v);for(let b=0;be.biomeAt(u[0],u[1],u[2])),c=e.rule.compile(l);for(let[u,h]of s){l.updateXZ(u,h);let d=0,f=Number.MIN_SAFE_INTEGER,m=Number.MAX_SAFE_INTEGER;for(let p=a;p>=o;p--){let g=te.create(u,p,h),w=t.getBlockState(g);if(w.equals(se.AIR)){d=0,f=Number.MIN_SAFE_INTEGER;continue}if(w.isFluid()){f===Number.MIN_SAFE_INTEGER&&(f=p+1);continue}if(m>=p){m=Number.MIN_SAFE_INTEGER;for(let v=p-1;v>=o;v--){let y=t.getBlockState(te.create(u,v,h));if(y.equals(se.AIR)||y.isFluid()){m=v+1;break}}}d+=1,l.updateY(d,p-m+1,f,p);let x=c(u,p,h);x&&(i?.push([g,w]),t.setBlockState(g,x))}}}var is=new Map;function Eu(e){let t=is.get(e);return t===void 0&&(is.size>4096&&is.clear(),t=xn(e.getName().toString()),is.set(e,t)),t}var mn=new Map,w2=64;function mu(e,t,r){let{settings:n}=e,s=n.noise.minY,i=n.noise.height,o=new ei(new Kt(R.create("plains")),n),a=`${e.shape}|${t},${r}`,l=mn.get(a);if(l)mn.delete(a);else{let d=new qn(s,i,Je.create(t,r)),f=o.createNoiseChunk(e.rs,d,!1);o.doFill(d,f),l={chunk:d,noiseChunk:f}}mn.set(a,l),mn.size>w2&&mn.delete(mn.keys().next().value);let{chunk:c,noiseChunk:u}=l,h=[];try{let d=t*16,f=r*16,m=[];for(let g=0;g<16;g++)for(let w=0;w<16;w++)m.push([d+g,f+w]);Iu(e,c,u,o.getWorldgenContext(),m,h);let p=new Uint16Array(256*i);for(let g=0;g<16;g++)for(let w=0;w<16;w++){let x=(g*16+w)*i;for(let v=0;v`rgb(${Math.round(r[0]*n)} ${Math.round(r[1]*n)} ${Math.round(r[2]*n)})`),pu.set(e,t)}return t}var Po=-1,gu=-1;function pn(e){return Po<0&&(Po=xn("minecraft:air"),gu=xn("minecraft:cave_air")),e===Po||e===gu}function qo(e,t){let r=t,n=-1;for(let s=0;s<256;s++){let i=s*t,o=t-1;for(;o>=0&&pn(e[i+o]);)o--;o<0||(on&&(n=o))}return{data:e,lowest:r,highest:n,faces:new Map}}function b2(e,t,r,n,s){let i=`${n}|${t?1:0}|${r?1:0}`,o=e.faces.get(i);if(o)return o;let{data:a}=e,l=[],c=[];for(let h=0;h<16;h++)for(let d=0;d<16;d++){let f=(h*16+d)*s,m=h<15?f+16*s:d*s,p=h<15?a:t?.data,g=d<15?f+s:h*16*s,w=d<15?a:r?.data;for(let x=n;x<=e.highest;x++){let v=a[f+x];if(pn(v))continue;let y=y2(wt[v]);(x===s-1||pn(a[f+x+1]))&&(l.push(h,x,d,0),c.push(y[0])),(!p||pn(p[m+x]))&&(l.push(h,x,d,1),c.push(y[1])),(!w||pn(w[g+x]))&&(l.push(h,x,d,2),c.push(y[2]))}}let u={faces:Int16Array.from(l),fills:c};return e.faces.size>=4&&e.faces.delete(e.faces.keys().next().value),e.faces.set(i,u),u}function _2(e,t,r,n){let s=n,i=-1;for(let f of t)for(let m of f)!m||m.highest<0||(s=Math.min(s,m.lowest),i=Math.max(i,m.highest));let o=Math.max(0,s-16),a=[],l=[],c=0;for(let f=0;f{let[p,g]=l[m],w=f.faces;for(let x=0;x{c&&(e.fill(),e.stroke())};for(let h=0,d=0;hi||x+2*r<0||x>o||(l[d]!==c&&(u(),c=l[d],e.fillStyle=e.strokeStyle=c,e.beginPath()),g===0?(e.moveTo(w,x),e.lineTo(w+r,x+r/2),e.lineTo(w,x+r),e.lineTo(w-r,x+r/2)):g===1?(e.moveTo(w+r,x+r/2),e.lineTo(w,x+r),e.lineTo(w,x+2*r),e.lineTo(w+r,x+1.5*r)):(e.moveTo(w-r,x+r/2),e.lineTo(w,x+r),e.lineTo(w,x+2*r),e.lineTo(w-r,x+1.5*r)),e.closePath())}u()}var S2=4096*4096,vn=[],os=null,gn=[],wn=new Map,k2=0;function I2(e){for(let t of e){let r={port:t,job:null};t.onmessage=n=>E2(r,n.data),os&&t.postMessage(os),vn.push(r)}Jo()}function E2(e,t){let r=e.job;if(e.job=null,r&&r.id===t.job){wn.get(`${r.cx},${r.cz}`)===r&&wn.delete(`${r.cx},${r.cz}`);try{A2(r,t)}catch(n){r.reject(n)}}Jo()}function A2(e,t){if("error"in t)e.reject(new Error(t.error));else if(e.key!==Dt)e.reject(new xt);else{let r=Uint16Array.from(t.ids,xn),n=t.data;for(let i=0;ix2&&Ke.delete(Ke.keys().next().value),t}function N2(e,t){let r=vn.length;return((e*31+t)%r+r)%r}function Jo(){vn.forEach((e,t)=>{if(e.job)return;let r=gn.findIndex(s=>N2(s.cx,s.cz)===t);if(r<0)return;let n=gn.splice(r,1)[0];e.job=n,e.port.postMessage({type:"chunk",job:n.id,req:n.req,cx:n.cx,cz:n.cz})})}function Au(e,t,r){let n=new Map;for(let[i,o]of t)n.set(`${i},${o}`,!1);for(let[i,o]of r)n.has(`${i},${o}`)||n.set(`${i},${o}`,!0);gn=gn.filter(i=>{let o=`${i.cx},${i.cz}`;return i.key===Dt&&n.has(o)?!0:(wn.get(o)===i&&wn.delete(o),i.reject(new xt),!1)});let s=new Map;for(let[i,o]of n){if(Ke.has(i))continue;let a=wn.get(i);if(a&&a.key!==Dt&&(a=void 0),!a){let[l,c]=i.split(",").map(Number),u,h,d=new Promise((f,m)=>(u=f,h=m));d.catch(()=>{}),a={id:k2++,key:Dt,cx:l,cz:c,req:e,prefetch:o,promise:d,resolve:u,reject:h},wn.set(i,a),gn.push(a)}a.prefetch=o,o||s.set(i,a.promise)}return gn.sort((i,o)=>Number(i.prefetch)-Number(o.prefetch)),Jo(),s}async function Uo(e,t,r){try{return mu(e,t,r)}catch(n){if(!String(n).includes("Missing key"))throw n;return fr(()=>mu(e,t,r))}}async function R2(e,t){if(t.type==="setup"){Tu(t.files);return}try{let{terrain:r}=await $o(t.req),n=await Uo(r,t.cx,t.cz);e.postMessage({type:"chunk",job:t.job,data:n,ids:wt.slice()},[n.buffer])}catch(r){e.postMessage({type:"chunk",job:t.job,error:String(r instanceof Error?r.message:r)})}}var Nu=e=>new Promise(t=>setTimeout(t,e));async function T2(e,t,r){let{width:n,height:s}=e,i=t.settings.noise.height;r!==Dt&&(Dt=r,Ke.clear(),oi=null,st=null),$t?.shape!==t.shape&&($t={shape:t.shape,y:t.settings.seaLevel-t.settings.noise.minY,fixed:!1});let o=O2(n,s),a=Math.max(o,e.view.scale>0?e.view.scale:n/72),l=e.view.x,c=e.view.y,u={x0:(l-c)*a-n/2,y0:(l+c)*a/2-s/2,x1:0,y1:0};u.x1=u.x0+n,u.y1=u.y0+s;let h=Math.min(n/4,32*a),d=Math.min(s/4,32*a),f={x0:u.x0-h,y0:u.y0-d,x1:u.x1+h,y1:u.y1+d},m=(I,b)=>Math.hypot(I[0]*16+8-l,I[1]*16+8-c)-Math.hypot(b[0]*16+8-l,b[1]*16+8-c),p=()=>{let I=Co(u,a,i).sort(m),b=I.filter(([k,E])=>!Ru(`${k},${E}`));return{shown:I,missing:b}},{shown:g,missing:w}=p(),x=()=>{let I=new OffscreenCanvas(n,s),b=I.getContext("2d");b.fillStyle=`rgb(${ri.join(" ")})`,b.fillRect(0,0,n,s);let k=Fo(u,f,a,i);k&&b.drawImage(k.image,Math.round(k.x0-u.x0),Math.round(k.y0-u.y0));let A=(!k||k.empty)&&w.length===0?"No blocks here. Drag to pan to some terrain.":void 0,N=I.transferToImageBitmap();return{type:"rendered",seq:e.seq,width:n,height:s,pixels:new Uint8ClampedArray(0),values:new Float32Array(0),min:1/0,max:-1/0,scale:a,minScale:o,bitmap:N,notice:A}};jo=()=>Fo(u,f,a,i);let v=-1,y=g.length-w.length;for(;w.length>0;){if(vn.length===0)for(let[I,b]of w){if(y>0&&ai({...x(),partial:!0}),await ci(),e.seq!==qt)throw new xt;Yo(`${I},${b}`,qo(await Uo(t,I,b),i)),y++}else{let I=Co(f,a,i).filter(([A,N])=>!g.some(z=>z[0]===A&&z[1]===N)).sort(m),b=Au(e,w,I),k=w.length,E=Promise.all(w.map(([A,N])=>b.get(`${A},${N}`).then(()=>(k--,void y++))));for(E.catch(()=>{});k>0;)if(y!==v&&y>0&&ai({...x(),partial:!0}),v=y,await Promise.race([E,Nu(150)]),e.seq!==qt)throw new xt;await E}({shown:g,missing:w}=p())}return x()}async function z2(e,t,r){let{width:n,height:s,view:i}=e,o=t.settings.noise.height,a=t.settings.noise.minY;r!==Dt&&(Dt=r,Ke.clear(),oi=null,st=null),jo=null;let l=li(n,s,i),c=Math.min(o-1,Math.floor(i.y)-a),u=[l.x(0,0),l.x(n-1,s-1)],h=[l.z(0,0),l.z(n-1,s-1)],d=Math.floor(Math.min(...u)/16),f=Math.floor(Math.max(...u)/16),m=Math.floor(Math.min(...h)/16),p=Math.floor(Math.max(...h)/16),g=(E,A)=>Math.hypot(E[0]*16+8-i.x,E[1]*16+8-i.z)-Math.hypot(A[0]*16+8-i.x,A[1]*16+8-i.z),w=[],x=[];for(let E=d-1;E<=f+1;E++)for(let A=m-1;A<=p+1;A++)(Ef||Ap?x:w).push([E,A]);w.sort(g),x.sort(g);let v=new Map,y=(E,A)=>{let N=Ke.get(`${E>>4},${A>>4}`);if(!N)return-2;let z=v.get(N);z||v.set(N,z=new Int16Array(256).fill(-3));let F=(E&15)*16+(A&15);if(z[F]===-3){let Y=c,$=F*o;for(;Y>=0&&pn(N.data[$+Y]);)Y--;z[F]=Y}return z[F]},I=()=>{v.clear();let E=new Uint8ClampedArray(n*s*4),A=new Float32Array(n*s).fill(NaN),N=new Float32Array(n*s).fill(NaN),z=1/0,F=-1/0;for(let ce=0;ceF&&(F=T))}let Y=Math.max(16,F-z),$=!1;for(let ce=0;ce>4},${D>>4}`).data[((B&15)*16+(D&15))*o+ie],Q=y(B-l.dx,D-l.dz),_=Q<0||Q===ie?1:Q>ie?.82:1.1;A[T]=de,N[T]=a+ie,hr(E,T*4,ts(wt[de]),_*(.8+.3*(ie-z)/Y)),$=!0}let V=!$&&b.length===0?`No blocks at or below y ${Math.floor(i.y)} here.`:void 0;return{type:"rendered",seq:e.seq,width:n,height:s,pixels:E,values:A,heights:N,min:1/0,max:-1/0,labels:wt.slice(),notice:V,seaLevel:t.settings.seaLevel,minY:a,maxY:a+o}},b=w.filter(([E,A])=>!Ru(`${E},${A}`)),k=w.length-b.length;if(b.length>0&&vn.length===0)for(let[E,A]of b){if(k>0&&ai({...I(),partial:!0}),await ci(),e.seq!==qt)throw new xt;Yo(`${E},${A}`,qo(await Uo(t,E,A),o)),k++}else if(b.length>0){let E=Au(e,b,x),A=b.length,N=Promise.all(b.map(([F,Y])=>E.get(`${F},${Y}`).then(()=>(A--,void k++))));N.catch(()=>{});let z=-1;for(;A>0;)if(k!==z&&k>0&&ai({...I(),partial:!0}),z=k,await Promise.race([N,Nu(150)]),e.seq!==qt)throw new xt;await N}return b=[],I()}function Ru(e){let t=Ke.get(e);return t?(Ke.delete(e),Ke.set(e,t),!0):!1}var P2=100;function O2(e,t){let r=s=>(e/s+32)*(2*t/s+64)/2/256,n=1;for(;r(n)>P2&&n<64;)n*=1.05;return n}var $t=null;function B2(e,t,r,n,s){let i=$t.y,o=e*16,a=t*16;return{x0:(o-a-16)*s-s,x1:(o+16-a)*s+s,y0:(o+a)*s/2-(n+1-i)*s,y1:(o+a+32)*s/2-(r-i)*s+s}}var L2=(e,t)=>e.x0=0)return[s,i];let o=$t.y;return[Math.max(0,o-16),Math.min(r-1,o+16)]}function Co(e,t,r){let n=$t.y,s=e.x0/t-2,i=e.x1/t+2,o=2*(e.y0/t-n)-2,a=2*(e.y1/t+r-n)+2,l=Math.floor((s+o)/32)-1,c=Math.floor((i+a)/32)+1,u=Math.floor((o-i)/32)-1,h=Math.floor((a-s)/32)+1,d=[];for(let f=l;f<=c;f++)for(let m=Math.max(u,Math.floor((f*16-i)/16)-1);m<=Math.min(h,Math.floor((f*16+16-s)/16)+1);m++){let[p,g]=C2(f,m,r);g>=p&&L2(B2(f,m,p,g,t),e)&&d.push([f,m])}return d}function F2(e){e.highest<0||$t&&!$t.fixed&&($t.y=Math.round((e.lowest+e.highest)/2),$t.fixed=!0)}var jo=null,wu;function $2(){clearTimeout(wu),wu=setTimeout(()=>jo?.(),200)}function Fo(e,t,r,n){let s=st&&st.s===r&&st.key.startsWith(Dt+"#")&&e.x0>=st.x0&&e.y0>=st.y0&&e.x1<=st.x1&&e.y1<=st.y1,i=s?st:t,o=Co(i,r,n).filter(([x,v])=>Ke.has(`${x},${v}`)),a=`${Dt}#${r}#${o.map(x=>x.join(",")).sort().join(";")}`;if(s&&st.key===a)return st;let l=Math.ceil(i.x1-i.x0),c=Math.ceil(i.y1-i.y0);if(l*c>S2)return i===e?null:Fo(e,e,r,n);let u=1/0,h=1/0,d=-1/0,f=-1/0;for(let[x,v]of o)u=Math.min(u,x),h=Math.min(h,v),d=Math.max(d,x),f=Math.max(f,v);let m=[];for(let x=u;x<=d;x++){let v=[];for(let y=h;y<=f;y++)v.push(Ke.get(`${x},${y}`));m.push(v)}oi?.key!==a&&(oi=_2(a,m,0,n));let p=oi,g=new OffscreenCanvas(l,c),w=o.length===0||p.bottom>p.top;if(!w){let x=$t.y,v=(u*16-h*16)*r-i.x0,y=(u*16+h*16)*r/2+x*r-i.y0;M2(g.getContext("2d"),p,r,v,y,l,c)}return st={key:a,s:r,x0:i.x0,y0:i.y0,x1:i.x1,y1:i.y1,image:g,empty:w},st}function li(e,t,r){let n=oa(r.facing),s=n.rx!==0,i=s?n.rx:n.rz,o=l=>(l+.5-e/2)*r.scale,a=l=>(l+.5-t/2)*r.scale;return{...n,alongX:s,depth:Math.floor(s?r.z:r.x),along:l=>(s?r.x:r.z)+i*o(l),y:l=>r.y-a(l),x:(l,c)=>r.x+n.rx*o(l)+n.dx*a(c),z:(l,c)=>r.z+n.rz*o(l)+n.dz*a(c),at:l=>s?[l,r.z]:[r.x,l]}}async function D2(e,t,r){r!==ss&&(ss=r,tr.clear());let n=li(e.width,e.height,e.view),s=Math.floor(Math.floor(n.along(e.width/2))/16),i=Su(n.alongX,n.depth,s);if(!tr.has(i)){let o=await fr(()=>ku(t,n.alongX,n.depth,s));si(e),tr.set(i,o)}return t}async function q2(e,t,r){let{width:n,height:s,view:i}=e,o=t.settings.noise.minY,a=o+t.settings.noise.height,l=t.settings.seaLevel;r!==ss&&(ss=r,tr.clear());let c=li(n,s,i),u=new Float32Array(n*s).fill(NaN),h=new Uint8ClampedArray(n*s*4),d=t.settings.noise.height,f=new Set,m=performance.now();for(let p=0;p40){if(await ci(),e.seq!==qt)throw new xt;m=performance.now()}v=ku(t,c.alongX,c.depth,w),tr.set(x,v)}let y=g-w*16,[I,b]=c.at(g),k=t.rs.router.chunkSurfaceLevel.compute(U.context(I,0,b));for(let E=0;E=a){hr(h,N*4,ni);continue}let z=v[y*d+(A-o)],F=wt[z];u[N]=z,F==="minecraft:air"?hr(h,N*4,A512)for(let p of tr.keys())f.has(p)||tr.delete(p);return{type:"rendered",seq:e.seq,width:n,height:s,pixels:h,values:u,min:1/0,max:-1/0,labels:wt.slice(),seaLevel:l,minY:o,maxY:a}}async function Y2(e,t,r){let{width:n,height:s,view:i}=e,o=n*s,a=new Float32Array(o),l=new Uint8ClampedArray(o*4),c=new Float32Array(o*6),u=new Float32Array(o).fill(NaN),h=li(n,s,i),d=Math.floor(i.y)>>2,f=new Map,m=new Map,{entries:p,lookup:g}=t,w=performance.now();for(let v=0;v40){if(await ci(),e.seq!==qt)throw new xt;w=performance.now()}for(let y=0;y>2,b=Math.floor(h.z(y,v))>>2,k=`${I},${b}`,E=m.get(k);if(E===void 0){let z=r.sampler.sample(I,d,b);if(p&&g){let F=g.find(z);E={b:xn(p.biomes[F]),t:z,f:jr(p,F,z.toArray())}}else E={b:xn(t.biomes.getBiome(I,d,b,r.sampler).toString()),t:z,f:NaN};m.set(k,E)}let A=v*n+y,N=E.b;a[A]=N,c[A]=E.t.temperature,c[o+A]=E.t.humidity,c[2*o+A]=E.t.continentalness,c[3*o+A]=E.t.erosion,c[4*o+A]=E.t.depth,c[5*o+A]=E.t.weirdness,u[A]=E.f,f.set(N,(f.get(N)??0)+1),hr(l,A*4,Io(wt[N]))}}for(let v=0;vy[1]-v[1]).map(([v])=>({id:wt[v],color:`rgb(${Io(wt[v]).join(" ")})`}));return{type:"rendered",seq:e.seq,width:n,height:s,pixels:l,values:a,min:1/0,max:-1/0,labels:wt.slice(),legend:x,climate:c,fit:p?u:void 0,entries:p}}var Oo=null;async function $o(e){let t=_u(e.seed),r=R.parse(e.id),n=R.parse(e.options.biome||"minecraft:plains"),s=e.kind==="dimension"?"":`${e.options.terrain}|${n}`,i=[bu,e.seed,e.kind,e.id,e.mode,s].join("|");if(Oo?.key===i)return{terrain:Oo.t,key:i};let o=e.kind==="dimension"?await fr(()=>{let a=Mu(e.id),l=rs(new Qt(a.settings,t));return{settings:a.settings,rule:a.settings.materialRule,rs:l,biomeAt:(c,u,h)=>a.biomes.getBiome(c>>2,u>>2,h>>2,l.sampler),shape:[Lo,e.seed,"dimension",e.id].join("|")}}):await fr(()=>{let a=e.kind==="material_rule"?R.parse(e.options.terrain||"minecraft:overworld"):r,l=xe.NOISE_SETTINGS.getOrThrow(a),c=e.kind==="material_rule"?xe.MATERIAL_RULE.getOrThrow(r):l.materialRule,u=rs(new Qt(l,t)),h=[Lo,e.seed,"noise_settings",a].join("|");return{settings:l,rule:c,rs:u,biomeAt:()=>n,shape:h}});return Oo={key:i,t:o},{terrain:o,key:i}}function Bo(e,t,r,n){let s=-1,i=[],o=[],a=n<1;return(l,c,u,h,d,f)=>{if(!r)return f(u,h,d);let m=Math.floor(u),p=Math.floor(h),g=Math.floor(d);if(!a)return f(m,p,g);c!==s&&(o=s===c-1?i:[],i=new Array(e),s=c);let w=`${m} ${p} ${g}`;i[l]=w;let x=c*e+l;return l>0&&i[l-1]===w?t[x-1]:o[l]===w?t[x-e]:f(m,p,g)}}async function J2(e){let{width:t,height:r,view:n}=e,s=_u(e.seed),i=R.parse(e.id),o=new Float32Array(t*r),a=new Uint8ClampedArray(t*r*4),l=li(t,r,n),c=1/0,u=-1/0,h=b=>{bu&&(u=b)};if(e.kind==="dimension"&&e.mode==="biomes"){let{dim:b,rs:k}=await fr(()=>{let E=Mu(e.id),A=new Qt(E.settings,s);return A.sampler.sample(0,0,0),{dim:E,rs:A}});return Y2(e,b,k)}if(e.kind==="dimension"||e.kind==="material_rule"||e.kind==="noise_settings"&&e.mode!=="density"){if(e.mode==="blocks"&&n.down){let E={...e,mode:"iso"},{terrain:A,key:N}=await $o(E);return si(e),z2(E,A,N)}let{terrain:b,key:k}=await $o(e);return si(e),e.mode==="iso"?T2(e,b,k):(await D2(e,b,k),si(e),q2(e,b,k))}if(e.kind==="noise"){let b=await fr(()=>new Qt(Vt.create({}),s).getOrCreateNoise(i)),k=zo(e),E=Bo(t,o,!!n.blocks,n.scale);for(let A=0;Ab.get3D(F,Y,$));o[A*t+N]=z,h(z)}return{type:"rendered",seq:e.seq,width:t,height:r,pixels:a,values:o,min:c,max:u}}if(e.kind==="density_function"){let b=await fr(()=>{let N=new Qt(Vt.create({}),s);return new U.HolderHolder(he.reference(xe.DENSITY_FUNCTION,i)).mapAll(N.createVisitor(!1))}),k=zo(e),E=Bo(t,o,!!n.blocks,n.scale),A=(N,z,F)=>b.compute(U.context(N,z,F));for(let N=0;N{let b=xe.NOISE_SETTINGS.getOrThrow(i),k=rs(new Qt(b,s));return{settings:b,router:k.router}}),m=d.noise.minY,p=m+d.noise.height,g=d.seaLevel,w=b=>n.down?n.y:l.y(b),x=zo(e),v=Bo(t,o,!!n.blocks,n.scale),y=(b,k,E)=>f.finalDensity.compute(U.context(b,k,E));for(let b=0;b=m&&k0){let F=110+Math.min(1,z/I)*70;a[N]=F,a[N+1]=F,a[N+2]=F+6}else kr.kind==="dimension").map(r=>[r.id,r.json])),bu++;let t=d2(e);t!==fu&&(fu=t,Lo++),os={type:"setup",files:e};for(let r of vn)r.port.postMessage(os)}var qt=0;self.onmessage=async e=>{let t=e.data;if(t.type==="ping"){self.postMessage({type:"pong"});return}if(t.type==="setup"){Tu(t.files);return}if(t.type==="helpers"){I2(t.ports);return}if(t.type==="serve"){let{port:r}=t;r.onmessage=n=>R2(r,n.data);return}qt=t.seq,self.postMessage({type:"started",seq:t.seq});try{let r=await J2(t);if(r.seq!==qt)return;ai(r)}catch(r){if(r instanceof xt||t.seq!==qt)return;self.postMessage({type:"error",seq:t.seq,message:String(r instanceof Error?r.message:r)})}};var U2={biome:"minecraft:plains",terrain:"minecraft:overworld"};function zu(e,t,r,n,s,i,o){return Jt({kind:"dimension",mode:"biomes",id:e,width:i,height:i,view:{x:r,y:n,z:s,facing:"north",scale:o},seed:t,options:U2})}function Go(e,t){let r=e.params.filter(s=>s.off>0).map(s=>`${s.param} ${pe(s.value)} is outside ${pe(s.min)}..${pe(s.max)} by ${pe(s.off)}`);e.offset&&r.push(`offset ${pe(e.offset)}`);let n=r.length?`: ${r.join("; ")}`:": every parameter in range";return`${e.biome} (entry ${e.index}), distance ${pe(e.distance)}${t?", wins":""}${n}`}function Pu(e,t){let r=e.width*e.height;return bn.map((n,s)=>e.climate[s*r+t])}async function Ou(e,t){let r=t.filter(b=>b.kind==="dimension").map(b=>b.id),n=Yt(e,"dimension");if(!n&&r.length!==1)throw new Ie(r.length?`Give dimension: one of ${r.join(", ")}.`:"The project has no Dimension with a noise generator to map.");let s=n?pr("dimension",n,r):r[0],i=String(e.seed??"0"),o=Math.floor(Ce(e,"x",0)),a=Math.floor(Ce(e,"z",0)),l=Math.floor(Ce(e,"y",64,-2048,2048)),c=Math.floor(Ce(e,"radius",2048,16,32768)),u=128,h=c*2/u,d=Yt(e,"biome"),f=await zu(s,i,o,l,a,u,h),m=f.entries,p=f.labels??[],g=u*u,w=new Map;for(let b=0;bA[1]-E[1]))x.push(`- ${b} ${Gr(k,g)}`);let v=na(m,w.keys());v.length&&x.push(`Listed by the source but not in the area: ${v.join(", ")}.`);let y=await zu(s,i,o,l,a,1,1),I=Pu(y,0);return x.push("",`At x ${o}, z ${a} (y ${l}): ${y.labels?.[y.values[0]]??"no biome"}.`),x.push(`Climate: ${bn.map((b,k)=>`${b} ${pe(I[k])}`).join(", ")}.`),m&&(x.push("Nearest entries (the lowest distance wins; at most one per biome):"),hs(m,I,5).forEach((b,k)=>x.push(`${k+1}. ${Go(b,k===0)}`))),d&&x.push("",...G2(j2(d,[...w.keys(),...m?.biomes??[]]),f,m,w,g,o,a,h)),x.join(` -`)}function j2(e,t){if(e.includes(":"))return e;let r=[...new Set(t)].filter(n=>n.slice(n.indexOf(":")+1)===e);if(r.length>1)throw new Ie(`${e} could be ${r.join(" or ")}; give the namespace.`);return r[0]??sa(e)}function G2(e,t,r,n,s,i,o,a){let l=t.width,c=t.labels??[],u=w=>{let x=w%l,v=Math.floor(w/l);return{x:Math.floor(i+(x+.5-l/2)*a),z:Math.floor(o+(v+.5-l/2)*a)}},h=n.get(e)??0;if(h>0){let w=-1,x=1/0;for(let y=0;y=0){let w=Pu(t,m),x=ta(r,e,w),v=hs(r,w,1)[0],y=u(m);d.push(`It comes closest at x ${y.x}, z ${y.z}, losing to ${v.biome} by ${pe(f[m])}.`),d.push(`There: ${Go(x,!1)}.`),d.push(`The winner: ${Go(v,!0)}.`)}let p=[];r.biomes.forEach((w,x)=>w===e&&p.push(x)),d.push("",`Climate in the area against what ${e}'s entries ask for:`);let g=!1;return bn.forEach((w,x)=>{let v=1/0,y=-1/0;for(let k=0;ky&&(y=E)}let I=p.map(k=>`${pe(r.params[k*13+x*2])}..${pe(r.params[k*13+x*2+1])}`),b=p.some(k=>r.params[k*13+x*2]<=y&&r.params[k*13+x*2+1]>=v);d.push(`- ${w}: area ${pe(v)}..${pe(y)}; asks ${[...new Set(I)].join(" or ")}${b?"":" (never in range here)"}`),!b&&w==="depth"&&(g=!0)}),g&&d.push("Depth changes with y (it is 0 at the surface and grows downwards), so try another y."),d}var Zo=["noise","density_function","noise_settings","dimension"],Z2={noise:"worldgen/noise",density_function:"worldgen/density_function",noise_settings:"worldgen/noise_settings"},ui={biome:"minecraft:plains",terrain:"minecraft:overworld"};function H2(e,t,r,n){let s=a=>{let l=r.filter(h=>h.kind===a).map(h=>h.id),c=Z2[a],u=c?Object.keys(n[c]??{}).map(h=>`minecraft:${h}`):[];return{own:l,all:[...new Set([...l,...u])]}},i=a=>{let{own:l,all:c}=s(a);if(!e.includes(":"))try{return pr(a.replace("_"," "),e,l)}catch{}return pr(a.replace("_"," "),e,c)};if(t)return{kind:t,id:i(t)};let o=[];for(let a of Zo)try{o.push({kind:a,id:i(a)})}catch{}if(o.length===1)return o[0];throw o.length>1?new Ie(`${e} names more than one thing: give kind, one of ${o.map(a=>a.kind).join(", ")}.`):new Ie(`No noise, density function, noise settings or dimension is called ${e}.`)}async function Bu(e,t,r){let n=Yt(e,"id");if(!n)throw new Ie("Give id: the noise, density function, noise settings or dimension to sample.");let s=Yt(e,"kind");if(s&&!Zo.includes(s))throw new Ie(`kind must be one of ${Zo.join(", ")}.`);let{kind:i,id:o}=H2(n,s,t,r),a=String(e.seed??"0"),l=Yt(e,"mode")??(i==="dimension"?"surface":"area");if(!["area","column","surface"].includes(l))throw new Ie("mode must be area, column or surface.");let c=Math.floor(Ce(e,"x",0)),u=Math.floor(Ce(e,"z",0)),h=`${i.replace("_"," ")} ${o}, seed ${a}`;if(l==="surface"){if(i!=="noise_settings"&&i!=="dimension")throw new Ie("mode surface needs noise settings or a dimension: it builds the terrain.");return V2(h,i,o,a,c,u,e)}if(i==="dimension")throw new Ie("A dimension has no density of its own: use mode surface, or sample its noise settings' final density.");if(l==="column"){if(i==="noise")throw new Ie("A noise is sampled top-down at one y; use mode area, with y.");return W2(h,i,o,a,c,u,e)}return X2(h,i,o,a,c,u,e)}async function X2(e,t,r,n,s,i,o){let a=Ce(o,"y",64),l=Math.floor(Ce(o,"radius",256,1,32768)),c=Math.floor(Ce(o,"size",8,2,32)),u=64,h=await Jt({kind:t,mode:"density",id:r,width:u,height:u,view:{x:s,y:a,z:i,facing:"north",scale:2*l/u,down:!0},seed:n,options:ui}),d=await Jt({kind:t,mode:"density",id:r,width:c,height:c,view:{x:s,y:a,z:i,facing:"north",scale:2*l/c,down:!0},seed:n,options:ui}),f=[`${e}, at y ${pe(a)}, x ${s-l}..${s+l}, z ${i-l}..${i+l}.`];f.push(Lu(h)),f.push("",`Values on a ${c}\xD7${c} grid, ${pe(2*l/c)} blocks apart (rows run north to south, columns west to east; coordinates rounded to 3 decimals):`);let m=2*l/c,p=Array.from({length:c},(w,x)=>s+(x+.5-c/2)*m),g=[["z \\ x",...p.map(w=>pe(w))]];for(let w=0;wpe(d.values[w*c+y],2))])}return f.push(gr(g)),f.join(` -`)}function Lu(e){let t=0,r=0,n=0;for(let s of e.values)Number.isNaN(s)||(t+=s,r++,s>0&&n++);return r?`Min ${pe(e.min)}, max ${pe(e.max)}, mean ${pe(t/r)}; above 0 at ${Gr(n,r)} of ${r} samples.`:"No values: the area is outside the world height."}async function W2(e,t,r,n,s,i,o){let a=Math.floor(Ce(o,"from",-64,-2048,2048)),l=Math.floor(Ce(o,"to",320,-2048,2048));if(l<=a)throw new Ie("to must be above from.");let c=Math.max(Math.floor(Ce(o,"step",8,1,512)),Math.ceil((l-a)/511)),u=Math.floor((l-a)/c)+1,h=await Jt({kind:t,mode:"density",id:r,width:1,height:u,view:{x:s,y:a+(u/2-.5)*c,z:i,facing:"north",scale:c},seed:n,options:ui}),d=Array.from({length:u},(p,g)=>a+(u-1-g)*c),f=[`${e}, the column at x ${s}, z ${i}, y ${a}..${d[0]} every ${c}.`,Lu(h)],m=[];for(let p=1;p0==w>0||m.push(`between y ${d[p]} and ${d[p-1]} (${w>0?"positive below":"positive above"})`)}return f.push(m.length?`Crosses 0 ${m.join("; ")}.`:"Never crosses 0 in this range."),f.push("",gr([["y","value"],...d.map((p,g)=>[String(p),pe(h.values[g])])])),f.join(` -`)}async function V2(e,t,r,n,s,i,o){let a=Math.floor(Ce(o,"radius",32,1,64)),l=Math.floor(Ce(o,"size",8,2,32)),c=Ce(o,"y",2032),u=Math.min(2*a,64),h=N=>({x:s,y:c,z:i,facing:"north",scale:2*a/N,down:!0}),d=await Jt({kind:t,mode:"blocks",id:r,width:u,height:u,view:h(u),seed:n,options:ui}),f=await Jt({kind:t,mode:"blocks",id:r,width:l,height:l,view:h(l),seed:n,options:ui}),m=[`${e}, the top block of each column${c<2032?` at or below y ${pe(c)}`:""}, x ${s-a}..${s+a}, z ${i-a}..${i+a}. Sea level is ${d.seaLevel}.`],p=d.labels??[],g=new Map,w=1/0,x=-1/0,v=0,y=0;for(let N=0;Nz[1]-N[1]).map(([N,z])=>`${N} ${Gr(z,y)}`).join(", ")}.`),d.notice&&m.push(d.notice);let I=2*a/l,b=Array.from({length:l},(N,z)=>Math.floor(s+(z+.5-l/2)*I)),k=f.labels??[],E=N=>N?N.replace(/^minecraft:/,""):"-";m.push("",`Height and top block on a ${l}\xD7${l} grid, ${pe(I)} blocks apart (rows run north to south):`);let A=[["z \\ x",...b.map(String)]];for(let N=0;N{let $=N*l+Y,V=f.heights?.[$]??NaN;return Number.isNaN(V)?"-":`${V} ${E(k[f.values[$]])}`})])}return m.push(gr(A)),m.join(` -`)}var dr=e=>e.includes(":")?e:`minecraft:${e}`;var as=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rr="minecraft:empty",Ho=class{hi=0;lo=0;constructor(t){let r=(BigInt.asUintN(64,BigInt(t))^0x5deece66dn)&(1n<<48n)-1n;this.hi=Number(r>>24n),this.lo=Number(r&0xffffffn)}next(t){let r=this.lo*15525485+11,n=r%16777216,s=Math.floor(r/16777216),i=(this.hi*15525485+this.lo*1502+s)%16777216;this.hi=i,this.lo=n;let o=Math.floor((i*16777216+n)/2**(48-t));return o>=2**(t-1)&&t===32?o-2**32:o}nextInt(t){if((t&-t)===t)return Number(BigInt(t)*BigInt(this.next(31))>>31n);for(;;){let r=this.next(31),n=r%t;if(r-n+(t-1)<2**31)return n}}};function fi(e,t){for(let r=e.length;r>1;r--){let n=t.nextInt(r);[e[r-1],e[n]]=[e[n],e[r-1]]}return e}var Cu=["north","east","south","west"],K2={north:"south",south:"north",east:"west",west:"east",up:"down",down:"up"},Q2={north:[0,0,-1],south:[0,0,1],east:[1,0,0],west:[-1,0,0],up:[0,1,0],down:[0,-1,0]};function Fu(e,t){let r=Cu.indexOf(e);return r<0?e:Cu[(r+(t===3?3:t))%4]}function ew(e,t){let[r,n]=e.split("_");return`${Fu(r,t)}_${Fu(n??"up",t)}`}function Xo([e,t,r],n){switch(n){case 1:return[-r,t,e];case 2:return[-e,t,-r];case 3:return[r,t,-e];default:return[e,t,r]}}function tw(e,t,r){let n=Xo([0,0,0],t),s=Xo([e[0]-1,e[1]-1,e[2]-1],t);return[[Math.min(n[0],s[0])+r[0],Math.min(n[1],s[1])+r[1],Math.min(n[2],s[2])+r[2]],[Math.max(n[0],s[0])+r[0],Math.max(n[1],s[1])+r[1],Math.max(n[2],s[2])+r[2]]]}var rw=(e,t)=>t.every((r,n)=>r>=e[0][n]&&r<=e[1][n]),nw=(e,t)=>e[0].every((r,n)=>r>=t[0][n])&&e[1].every((r,n)=>r<=t[1][n]),iw=(e,t)=>e[0].every((r,n)=>r<=t[1][n])&&e[1].every((r,n)=>r>=t[0][n]),sw=(e,t)=>[e[0].map((r,n)=>r+t[n]),e[1].map((r,n)=>r+t[n])],ow=(e,t)=>nw(t,e.box)&&!e.taken.some(r=>iw(r,t)),cs=e=>e.split("_")[0],$u=e=>e.split("_")[1]??"up";function aw(e){let t=e.orientation??"north_up",r=cs(t);return{pos:[...e.pos],orientation:t,pool:dr(e.pool),name:dr(e.name),target:dr(e.target),joint:e.joint??(r==="up"||r==="down"?"rollable":"aligned"),finalState:e.final_state??"minecraft:air",selection:e.selection_priority??0,placement:e.placement_priority??0}}var cw=(e,t)=>({...e,pos:Xo(e.pos,t),orientation:ew(e.orientation,t)}),lw=(e,t)=>cs(e.orientation)===K2[cs(t.orientation)]&&(e.joint==="rollable"||$u(e.orientation)===$u(t.orientation))&&e.target===t.name,uw={pos:[0,0,0],orientation:"down_south",pool:rr,name:"minecraft:bottom",target:rr,joint:"rollable",finalState:"minecraft:air",selection:0,placement:0},fw=/^data\/([^/]+)\/structures?\/(.+)\.nbt$/;function hw(e){let t=new Map;for(let r of e){let n=fw.exec(r.path);n&&t.set(`${n[1]}:${n[2]}`,r)}return t}function Yu(e,t){let r=s=>({kind:"unknown",id:s,box:i=>[[...i],[...i]],jigsaws:()=>[]});if(!as(e))return r("?");let n=String(e.element_type??"").replace(/^minecraft:/,"");switch(n){case"single_pool_element":case"legacy_single_pool_element":{let s=dr(String(e.location??"?")),i=t.get(s);if(!i?.size||!i.jigsaws)return r(s);let o=i.size,a=i.jigsaws.map(aw);return{kind:"single",id:s,box:(l,c)=>tw(o,c,l),jigsaws:l=>a.map(c=>cw(c,l))}}case"list_pool_element":{let s=(Array.isArray(e.elements)?e.elements:[]).map(o=>Yu(o,t));if(!s.length)return{kind:"empty",id:"empty list",box:o=>[[...o],[...o]],jigsaws:()=>[]};let i=s.find(o=>o.kind==="unknown");return i?r(i.id):{kind:"list",id:s.map(o=>o.id).join(" + "),parts:s.map(o=>o.id),box:(o,a)=>{let l=s.map(c=>c.box(o,a));return[[0,1,2].map(c=>Math.min(...l.map(u=>u[0][c]))),[0,1,2].map(c=>Math.max(...l.map(u=>u[1][c])))]},jigsaws:o=>s[0].jigsaws(o)}}case"feature_pool_element":return{kind:"feature",id:`feature ${String(e.feature??"?").replace(/^minecraft:/,"")}`,box:i=>[[...i],[...i]],jigsaws:()=>[uw]};case"empty_pool_element":return{kind:"empty",id:"empty",box:s=>[[...s],[...s]],jigsaws:()=>[]};default:return r(n||"?")}}function Du(e){if(e!==void 0)try{return JSON.parse(e)}catch{return}}var Wo=20;function Ju(e,t,r=[],n={}){let s=new Map(t.map(B=>[B.path,B])),i=Du(s.get(e)?.text);if(!as(i)||String(i.type??"").replace(/^minecraft:/,"")!=="jigsaw"||typeof i.start_pool!="string")return null;let o=n.seed??0,a=n.limit??4096,l=typeof i.size=="number"?i.size:7,c=Math.max(0,Math.min(Wo,Math.floor(n.depth??l))),u=typeof i.max_distance_from_center=="number"?i.max_distance_from_center:80,h=typeof i.start_jigsaw_name=="string"?dr(i.start_jigsaw_name):void 0,d=hw(r),f=new Set,m={seed:o,pieces:[],bounds:[[0,0,0],[0,0,0]],depth:c,size:l,reached:0,notes:[]},p=B=>{f.has(B)||(f.add(B),m.notes.push(B))};i.use_expansion_hack===!0&&p("The expansion hack is not simulated."),Array.isArray(i.pool_aliases)&&i.pool_aliases.length&&p("Pool aliases are not simulated; jigsaw blocks draw from the pools they name.");let g=new Map,w=B=>{if(g.has(B))return g.get(B);let D=null;if(B===rr)D={id:B,templates:[],fallback:rr};else{let[ie,ee]=B.split(":",2),de=Du(s.get(`data/${ie}/worldgen/template_pool/${ee}.json`)?.text);if(as(de)){let Q=[];for(let _ of Array.isArray(de.elements)?de.elements:[]){if(!as(_))continue;let S=Yu(_.element,d);S.kind==="unknown"&&p(`${S.id} is not one of this project's structure files, so it is never placed here.`);let O=typeof _.weight=="number"?_.weight:1;for(let j=0;jD.name===h);if(!B)return m.failed=`The start piece ${I.id} has no jigsaw block named ${h}.`,m;b=B.pos}let k=[-b[0],-b[1],-b[2]],E=I.box(k,v),A=Math.trunc((E[1][0]+E[0][0])/2),N=Math.trunc((E[1][2]+E[0][2])/2),z=k[1]-(E[0][1]+1);E=sw(E,[0,z,0]);let F=[k[0],k[1]+z,k[2]],Y=k[1]+b[1];m.bounds=[[A-u,Y-u,N-u],[A+u,Y+u,N+u]];let $=[],V=0,ce=(B,D)=>(B.jigsaws=D.map(ie=>({pos:ie.pos,orientation:ie.orientation,pool:ie.pool,name:ie.name,target:ie.target,finalState:ie.finalState})),m.pieces.push(B),m.reached=Math.max(m.reached,B.depth),m.pieces.length-1),oe=I.jigsaws(v).map(B=>({...B,pos:B.pos.map((D,ie)=>D+F[ie])}));ce({id:I.id,kind:I.kind,...I.parts?{parts:I.parts}:{},pool:y.id,depth:0,rotation:v,origin:F,box:E,jigsaws:[]},oe);let T=[I];for(c>0&&$.push({piece:0,free:{box:m.bounds,taken:[E]},depth:0,priority:0,order:V++});$.length;){let B=0;for(let S=1;S<$.length;S++)$[S].priority>$[B].priority&&(B=S);let D=$.splice(B,1)[0],ie=m.pieces[D.piece],ee=T[D.piece],de=ie.box,Q,_=ee.jigsaws(ie.rotation).map((S,O)=>({j:{...S,pos:S.pos.map((j,ue)=>j+ie.origin[ue])},i:O}));fi(_,x),_.sort((S,O)=>O.j.selection-S.j.selection);e:for(let{j:S,i:O}of _){let j=ie.jigsaws[O],ue=Se=>{j.joined||(j.result=Se)},qe=cs(S.orientation),Ae=Q2[qe]??[0,0,0],Ne=[S.pos[0]+Ae[0],S.pos[1]+Ae[1],S.pos[2]+Ae[2]],ye=w(S.pool);if(!ye||!ye.templates.length&&ye.id!==rr){ue({none:S.pool===rr?"empty":"unknown-pool"}),!ye&&!S.pool.startsWith("minecraft:")?p(`No TemplatePool declares ${S.pool}.`):ye||p(`${S.pool} is a vanilla pool, which the simulation does not have.`);continue}let le=w(ye.fallback);if(!le||!le.templates.length&&le.id!==rr){ue({none:"unknown-pool"});continue}if(S.pool===rr){ue({none:"empty"});continue}let q;rw(de,Ne)?q=Q??={box:de,taken:[]}:q=D.free;let L=[];if(D.depth!==c)for(let Se of fi([...ye.templates],x))L.push({c:Se,from:ye.id});for(let Se of fi([...le.templates],x))L.push({c:Se,from:le.id});let ae=D.depth===c?"depth":"no-fit";for(let{c:Se,from:ft}of L){if(Se.kind==="empty"){ae="empty-piece";break}for(let Qe of fi([0,1,2,3],x)){let kt=qu(Se,Qe,x);for(let nt of kt){if(!lw(S,nt))continue;let yn=[Ne[0]-nt.pos[0],Ne[1]-nt.pos[1],Ne[2]-nt.pos[2]],us=Se.box(yn,Qe);if(!ow(q,us))continue;if(q.taken.push(us),m.pieces.length>=a){p(`The simulation stops at ${a} pieces.`);break e}let Hu=Se.jigsaws(Qe).map(di=>({...di,pos:di.pos.map((fs,mi)=>fs+yn[mi])})),hi=ce({id:Se.id,kind:Se.kind,...Se.parts?{parts:Se.parts}:{},pool:ft,depth:D.depth+1,rotation:Qe,origin:yn,box:us,jigsaws:[],parent:{piece:D.piece,jigsaw:O}},Hu);T.push(Se);let Vo=m.pieces[hi].jigsaws.findIndex(di=>di.pos.every((fs,mi)=>fs===nt.pos[mi]+yn[mi]));Vo>=0&&(m.pieces[hi].jigsaws[Vo].joined=!0),ue({piece:hi}),D.depth+1<=c&&$.push({piece:hi,free:q,depth:D.depth+1,priority:S.placement,order:V++});continue e}}}ue({none:ae})}}return m}function qu(e,t,r){return fi(e.jigsaws(t),r).sort((s,i)=>i.selection-s.selection)}var Uu={empty:"its pool is minecraft:empty","unknown-pool":"its pool is not in the pack",depth:"the structure was at its last depth and the fallback had nothing that fit","no-fit":"no piece could join or fit the free space","empty-piece":"the pool drew its empty piece"},dw=/^data\/([^/]+)\/worldgen\/structure\/(.+)\.json$/;function ju(e,t,r){let n=[];for(let f of t){let m=dw.exec(f.path);m&&/"type"\s*:\s*"(minecraft:)?jigsaw"/.test(f.text)&&n.push(`${m[1]}:${m[2]}`)}let s=Yt(e,"structure");if(!s&&n.length!==1)throw new Ie(n.length?`Give structure: one of ${n.join(", ")}.`:"The project has no jigsaw structure.");let i=s?pr("jigsaw structure",s,n):n[0],[o,a]=i.split(":",2),l=`data/${o}/worldgen/structure/${a}.json`,c=Math.floor(Ce(e,"seed",0,-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER-200)),u=Math.floor(Ce(e,"runs",1,1,200)),h=e.depth===void 0?void 0:Math.floor(Ce(e,"depth",0,0,Wo)),d=[];for(let f=c;fa.path===`data/${s}/worldgen/template_pool/${i}.json`);if(o)try{let a=JSON.parse(o.text),l=new Set;for(let c of a.elements??[])for(let u of[c.element,...c.element?.elements??[]]){let h=u?.location;typeof h=="string"&&l.add(h.includes(":")?h:`minecraft:${h}`)}r.set(n,[...l])}catch{}}return r}var pw=e=>`${e[0].join(" ")} to ${e[1].join(" ")}`;function Gu(e,t){let r=[`Jigsaw structure ${e}: depth ${t.depth}${t.depth!==t.size?` (its size is ${t.size})`:""}.`];return t.notes.length&&r.push(...t.notes.map(n=>`Note: ${n}`)),r}function gw(e,t,r){let n=Gu(e,t);if(n.push(`Seed ${t.seed}.`),t.failed)return[...n,`Nothing is placed: ${t.failed}`].join(` -`);n.push(`${t.pieces.length} pieces, ${t.reached} deep. Bounds (max_distance_from_center): ${pw(t.bounds)}.`),n.push("","Pieces (index, depth, structure, pool, rotation, origin, joined onto piece):");let s=[["#","depth","piece","pool","rot","origin","parent"]];t.pieces.forEach((o,a)=>{s.push([String(a),String(o.depth),o.id,o.pool,`${o.rotation*90}\xB0`,o.origin.join(" "),o.parent?String(o.parent.piece):"-"])}),n.push(gr(s));let i=[];return t.pieces.forEach((o,a)=>o.jigsaws.forEach(l=>{l.result&&"none"in l.result&&l.result.none!=="empty"&&i.push(`- piece ${a} (${o.id}) at ${l.pos.join(" ")}, pool ${l.pool}, target ${l.target}: ${Uu[l.result.none]}`)})),i.length&&n.push("","Jigsaw blocks that placed nothing (minecraft:empty pools left out):",...i),n.push(...Zu(r,[t])),n.join(` -`)}function ww(e,t,r){let n=Gu(e,t[0]);n.push(`Seeds ${t[0].seed}..${t[t.length-1].seed} (${t.length} runs).`);let s=t.filter(o=>o.failed);if(s.length){let o=new Map;for(let a of s)o.set(a.failed,(o.get(a.failed)??0)+1);n.push(`${s.length} runs placed nothing:`,...[...o].map(([a,l])=>`- ${l}\xD7: ${a}`))}let i=t.filter(o=>!o.failed);if(i.length){let o=t.map(d=>d.pieces.length),a=i.map(d=>d.reached);n.push(`Pieces per run: ${Math.min(...o)}..${Math.max(...o)}, mean ${pe(o.reduce((d,f)=>d+f,0)/t.length,1)}. Depth reached: ${Math.min(...a)}..${Math.max(...a)}.`);let l=new Map,c=new Map;for(let d of i){let f=new Set;for(let m of d.pieces)c.set(m.id,(c.get(m.id)??0)+1),f.add(m.id);for(let m of f)l.set(m,(l.get(m)??0)+1)}n.push("","Pieces (runs that place it, mean count per run):");let u=[["piece","runs","mean"]];for(let[d,f]of[...l].sort((m,p)=>p[1]-m[1]||m[0].localeCompare(p[0])))u.push([d,`${f}/${t.length}`,pe(c.get(d)/t.length,2)]);n.push(gr(u));let h=new Map;for(let d of i)for(let f of d.pieces)for(let m of f.jigsaws)if(m.result&&"none"in m.result&&m.result.none!=="empty"){let p=`${f.id}: pool ${m.pool}, target ${m.target}: ${Uu[m.result.none]}`;h.set(p,(h.get(p)??0)+1)}if(h.size){n.push("","Jigsaw blocks that placed nothing, over all runs (minecraft:empty pools left out):");for(let[d,f]of[...h].sort((m,p)=>p[1]-m[1]))n.push(`- ${f}\xD7 ${d}`)}}return n.push(...Zu(r,i)),n.join(` -`)}function Zu(e,t){let r=new Set,n=new Set;for(let i of t)for(let o of i.pieces){r.add(o.id),n.add(o.pool);for(let a of o.jigsaws)n.add(a.pool.includes(":")?a.pool:`minecraft:${a.pool}`)}let s=[];for(let[i,o]of mw(e,n)){let a=o.filter(l=>!r.has(l));a.length&&s.push(`- ${i}: ${a.join(", ")}`)}return s.length?["",`Pieces their pools list that ${t.length>1?"no run":"this run"} placed:`,...s]:[]}async function xw(e){try{let t=ia(e.files);gs(t,e.vanilla??{});let r=e.args??{};switch(e.tool){case"biomes":return{text:await Ou(r,t)};case"density":return{text:await Bu(r,t,e.vanilla??{})};case"jigsaw":return{text:ju(r,e.files,e.assets??[])}}return{error:`unknown tool ${String(e.tool)}`}}catch(t){return ls.env.MMS_JS_DEBUG&&console.error(t),{error:t instanceof Error?t.message:String(t),args:t instanceof Ie}}}async function vw(){let e=[];for await(let t of ls.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}var yw=await xw(JSON.parse(await vw()));ls.stdout.write(JSON.stringify(yw));ls.exit(0);export{xw as run}; +`,hn=class{gl;shaderProgram;projMatrix;activeShader;pixelSize=0;constructor(t){this.gl=t,this.shaderProgram=new fn(t,p2,g2).getProgram(),this.activeShader=this.shaderProgram,this.projMatrix=this.getPerspective(),this.initialize()}setViewport(t,r,n,s){this.gl.viewport(t,r,n,s),this.projMatrix=this.getPerspective()}getPerspective(){let t=70*Math.PI/180,r=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,n=Eo.mat4.create();return Eo.mat4.perspective(n,t,r,.1,500),n}initialize(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(this.gl.BACK)}setShader(t){this.gl.useProgram(t),this.activeShader=t}setVertexAttr(t,r,n){if(n===void 0)throw new Error(`Expected buffer for ${t}`);let s=this.gl.getAttribLocation(this.activeShader,t);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.vertexAttribPointer(s,r,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(s)}setUniform(t,r){let n=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(n,!1,r)}setTexture(t,r){this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.pixelSize=r??0}createAtlasTexture(t){let r=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),r}prepareDraw(t){this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix);let r=this.gl.getUniformLocation(this.activeShader,"pixelSize");this.gl.uniform1f(r,this.pixelSize)}drawMesh(t,r){if(t.quadVertices()>0){if(r.pos&&this.setVertexAttr("vertPos",3,t.posBuffer),r.color&&this.setVertexAttr("vertColor",3,t.colorBuffer),r.texture&&(this.setVertexAttr("texCoord",2,t.textureBuffer),this.setVertexAttr("texLimit",4,t.textureLimitBuffer)),r.normal&&this.setVertexAttr("normal",3,t.normalBuffer),r.blockPos&&this.setVertexAttr("blockPos",3,t.blockPosBuffer),!t.indexBuffer)throw new Error("Expected index buffer");this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),this.gl.drawElements(this.gl.TRIANGLES,t.quadIndices(),this.gl.UNSIGNED_SHORT,0)}t.lineVertices()>0&&(r.pos&&this.setVertexAttr("vertPos",3,t.linePosBuffer),r.color&&this.setVertexAttr("vertColor",3,t.lineColorBuffer),this.gl.drawArrays(this.gl.LINES,0,t.lineVertices()))}};var Wi=class e extends hn{item;resources;mesh;atlasTexture;constructor(t,r,n,s={}){super(t),this.item=r,this.resources=n,this.updateMesh(s),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setItem(t,r={}){this.item=t,this.updateMesh(r)}updateMesh(t={}){this.mesh=e.getItemMesh(this.item,this.resources,t),this.mesh.computeNormals(),this.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0})}static getItemMesh(t,r,n){let s=t.getComponent("item_model",r)?.getAsString();if(s===void 0)return new _e;let i=r.getItemModel(R.parse(s));if(!i)throw new Error(`Item model ${s} does not exist (defined by item ${t.toString()})`);return i.getMesh(t,r,n)}getPerspective(){let t=Xn.mat4.create();return Xn.mat4.ortho(t,0,16,0,16,.1,500),t}drawItem(){let t=Xn.mat4.create();Xn.mat4.translate(t,t,[0,0,-32]),this.setShader(this.shaderProgram),this.setTexture(this.atlasTexture,this.resources.getPixelSize?.()),this.prepareDraw(t),this.drawMesh(this.mesh,{pos:!0,color:!0,texture:!0,normal:!0})}};var Cr=[0,0,0],Vn;(function(e){function t(u){let h=M.readObject(u)??{},d=M.readString(h.type)?.replace(/^minecraft:/,"");switch(d){case"constant":return new r(re.fromJson(h.value)??Cr);case"dye":return new n(re.fromJson(h.default)??Cr);case"grass":return new s(M.readNumber(h.temperature)??0,M.readNumber(h.downfall)??0);case"firework":return new i(re.fromJson(h.default)??Cr);case"potion":return new o(re.fromJson(h.default)??Cr);case"map_color":return new a(re.fromJson(h.default)??Cr);case"custom_model_data":return new l(M.readInt(h.index)??0,re.fromJson(h.default)??Cr);case"team":return new c(re.fromJson(h.default)??Cr);default:throw new Error(`Invalid item tint type ${d}`)}}e.fromJson=t;class r{value;constructor(h){this.value=h}getTint(h){return this.value}}e.Constant=r;class n{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("dyed_color",d);return f?f.isCompound()?re.intToRgb(f.getNumber("rgb")):re.intToRgb(f.getAsNumber()):this.default_color}}e.Dye=n;class s{temperature;downfall;constructor(h,d){this.temperature=h,this.downfall=d}getTint(h){return[124/255,189/255,107/255]}}e.Grass=s;class i{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("firework_explosion",d);if(!f?.isCompound())return this.default_color;let m=f.get("colors");return!m||!m.isListOrArray()?this.default_color:(()=>{if(m.length===1)return re.intToRgb(m.get(0).getAsNumber());let[g,w,x]=[0,0,0];for(let v of m.getItems())g+=(v.getAsNumber()&16711680)>>16,w+=(v.getAsNumber()&65280)>>8,x+=(v.getAsNumber()&255)>>0;return g/=m.length,w/=m.length,x/=m.length,[g/255,w/255,x/255]})()}}e.Firework=i;class o{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("potion_contents",d);if(!f)return this.default_color;let m=nn.fromNbt(f);return nn.getColor(m)}}e.Potion=o;class a{default_color;constructor(h){this.default_color=h}getTint(h,d){let f=h.getComponent("map_color",d);return f?re.intToRgb(f.getAsNumber()):this.default_color}}e.MapColor=a;class l{index;default_color;constructor(h,d){this.index=h,this.default_color=d}getTint(h,d){let f=h.getComponent("custom_model_data",d);if(!f?.isCompound())return this.default_color;let m=f.getList("colors").get(this.index);return m?re.fromNbt(m)??this.default_color:this.default_color}}e.CustomModelData=l;class c{default_color;constructor(h){this.default_color=h}getTint(h,d,f){return f.context_entity_team_color??this.default_color}}e.Team=c})(Vn=Vn||(Vn={}));var Le=dr(Or(),1);var Kn;(function(e){function t(m){let p=M.readObject(m)??{},g=M.readString(p.type)?.replace(/^minecraft:/,"");switch(g){case"bed":return new r(R.parse(M.readString(p.texture)??""));case"banner":return new n(M.readString(p.color)??"");case"conduit":return new s;case"chest":return new i(R.parse(M.readString(p.texture)??""),M.readNumber(p.openness)??0);case"head":return new o(M.readString(p.kind)??"",typeof p.texture=="string"?R.parse(p.texture):void 0,M.readNumber(p.animation)??0);case"player_head":return new o("player",void 0,0);case"shulker_box":return new a(R.parse(M.readString(p.texture)??""),M.readNumber(p.openness)??0,M.readString(p.orientation)??"up");case"shield":return new l;case"trident":return new c;case"decorated_pot":return new u;case"standing_sign":return new h(M.readString(p.wood_type)??"",typeof p.texture=="string"?R.parse(p.texture):void 0);case"hanging_sign":return new d(M.readString(p.wood_type)??"",typeof p.texture=="string"?R.parse(p.texture):void 0);case"copper_golem_statue":{let w=M.readString(p.texture)??"",x=w.substring(w.lastIndexOf("/")+1),v=x.endsWith(".png")?x.slice(0,-4):x;return new f(R.parse(v))}default:return console.warn(`[deepslate]: Unknown special model ${g}`),{getMesh:()=>new _e}}}e.fromJson=t;class r{renderer;constructor(p){this.renderer=Be.bedRenderer(p)}getMesh(p,g){let w=this.renderer("head",g),x=this.renderer("foot",g),v=Le.mat4.create();return Le.mat4.translate(v,v,[0,0,-16]),w.merge(x.transform(v))}}class n{renderer;constructor(p){this.renderer=Be.bannerRenderer(p)}getMesh(p,g){let w=p.getComponent("banner_patterns",void 0),x=w?.isList()&&w.getType()===C.Compound?w:void 0,v=Le.mat4.create();return Le.mat4.translate(v,v,[8,24,8]),Le.mat4.rotateY(v,v,Math.PI),Le.mat4.scale(v,v,[2/3,2/3,2/3]),Le.mat4.translate(v,v,[-8,-24,-8]),this.renderer(g,x).transform(v)}}class s{getMesh(p,g){return Be.conduitRenderer(g)}}class i{renderer;constructor(p,g){this.renderer=Be.chestRenderer(p)}getMesh(p,g){let w=Le.mat4.create();return Le.mat4.translate(w,w,[8,8,8]),Le.mat4.rotateY(w,w,Math.PI),Le.mat4.translate(w,w,[-8,-8,-8]),this.renderer(g).transform(w)}}class o{renderer;constructor(p,g,w){this.renderer=({skeleton:()=>Be.headRenderer(g??R.create("skeleton/skeleton"),2),wither_skeleton:()=>Be.headRenderer(g??R.create("skeleton/wither_skeleton"),2),zombie:()=>Be.headRenderer(g??R.create("zombie/zombie"),1),creeper:()=>Be.headRenderer(g??R.create("creeper/creeper"),2),dragon:()=>Be.dragonHeadRenderer(g),piglin:()=>Be.piglinHeadRenderer(g),player:()=>Be.headRenderer(g??R.create("player/wide/steve"),1)}[p]??(()=>()=>new _e))()}getMesh(p,g){return this.renderer(g)}}class a{renderer;constructor(p,g,w){this.renderer=Be.shulkerBoxRenderer(p)}getMesh(p,g){return this.renderer(g)}}class l{getMesh(p,g){let w=[],x=p.getComponent("banner_patterns",void 0),v=x?.isList()&&x.getType()===C.Compound?x:void 0,y=p.getComponent("base_color",void 0)?.getAsString();!y&&(v?.length??0)>0&&(y="white"),y&&(w.push({color:y,pattern:"base"}),v?.forEach(k=>{w.push({pattern:R.parse(k.getString("pattern")).path,color:k.getString("color")})}));let I=Be.shieldRenderer(g,w),b=Le.mat4.create();return Le.mat4.translate(b,b,[-3,1,0]),Le.mat4.rotateX(b,b,-10*Math.PI/180),Le.mat4.rotateY(b,b,-10*Math.PI/180),Le.mat4.rotateZ(b,b,-5*Math.PI/180),I.transform(b)}}class c{getMesh(p,g){return new _e}}class u{getMesh(p,g){return Be.decoratedPotRenderer(g)}}class h{renderer;constructor(p,g){this.renderer=Be.signRenderer(g??R.create(p))}getMesh(p,g){return this.renderer(g)}}class d{renderer;constructor(p,g){this.renderer=Be.hangingSignRenderer(g??R.create(p))}getMesh(p,g){return this.renderer(!1,g)}}class f{renderer;constructor(p){this.renderer=Be.copperGolemStatueRenderer(p)}getMesh(p,g){let w=p.getComponent("block_state",void 0),x="standing";w instanceof Re&&(x=w.getString("copper_golem_pose")||x);let v=Le.mat4.create();return Le.mat4.translate(v,v,[8,12,8]),Le.mat4.rotateY(v,v,Math.PI),Le.mat4.rotateZ(v,v,Math.PI),Le.mat4.translate(v,v,[-8,-12,-8]),this.renderer(g,x).transform(v)}}})(Kn=Kn||(Kn={}));var fu=new _e,Ao;(function(e){function t(u){let h=M.readObject(u)??{},d=M.readString(h.type)?.replace(/^minecraft:/,"");switch(d){case"empty":return new r;case"model":return new n(R.parse(M.readString(h.model)??""),M.readArray(h.tints,Vn.fromJson)??[]);case"composite":return new s(M.readArray(h.models,e.fromJson)??[]);case"condition":return new i(i.propertyFromJson(h),e.fromJson(h.on_true),e.fromJson(h.on_false));case"select":return new o(o.propertyFromJson(h),new Map(M.readArray(h.cases,f=>M.readObject(f)??{})?.flatMap(f=>{let m=e.fromJson(f.model);return Array.isArray(f.when)?f.when.map(p=>[M.readString(p)??"",m]):[[M.readString(f.when)??"",m]]})),h.fallback?e.fromJson(h.fallback):void 0);case"range_dispatch":return new a(a.propertyFromJson(h),M.readNumber(h.scale)??1,M.readArray(h.entries,f=>{let m=M.readObject(f)??{};return{threshold:M.readNumber(m.threshold)??0,model:e.fromJson(m.model)}})??[],h.fallback?e.fromJson(h.fallback):void 0);case"special":return new l(Kn.fromJson(h.model),R.parse(M.readString(h.base)??""));case"bundle/selected_item":return new c;default:return console.warn(`[deepslate]: Unknown item model type '${d}'`),{getMesh:()=>new _e}}}e.fromJson=t;class r{getMesh(h,d,f){return new _e}}e.Empty=r;class n{modelId;tints;constructor(h,d){this.modelId=h,this.tints=d}getMesh(h,d,f){let m=d.getBlockModel(this.modelId);if(!m)return console.warn(`[deepslate]: Model '${this.modelId}' does not exist`),new _e;let p=w=>wm.merge(p.getMesh(h,d,f))),m}}e.Composite=s;class i{property;onTrue;onFalse;constructor(h,d,f){this.property=h,this.onTrue=d,this.onFalse=f}getMesh(h,d,f){return(this.property(h,d,f)?this.onTrue:this.onFalse).getMesh(h,d,f)}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"fishing_rod/cast":case"selected":case"carried":case"extended_view":return(w,x,v)=>v[d]??!1;case"view_entity":return(w,x,v)=>v.context_entity_is_view_entity??!1;case"using_item":return(w,x,v)=>(v.use_duration??-1)>=0;case"bundle/has_selected_item":return(w,x,v)=>(v["bundle/selected_item"]??-1)>=0;case"broken":return(w,x,v)=>{let y=w.getComponent("damage",x)?.getAsNumber(),I=w.getComponent("max_damage",x)?.getAsNumber();return y!==void 0&&I!==void 0&&y>=I-1};case"damaged":return(w,x,v)=>{let y=w.getComponent("damage",x)?.getAsNumber(),I=w.getComponent("max_damage",x)?.getAsNumber();return y!==void 0&&I!==void 0&&y>=1};case"has_component":let f=R.parse(M.readString(h.component)??""),m=M.readBoolean(h.ignore_default)??!1;return(w,x,v)=>w.hasComponent(f,m?void 0:x);case"keybind_down":let p=M.readString(h.keybind)??"";return(w,x,v)=>v.keybind_down?.includes(p)??!1;case"custom_model_data":let g=M.readInt(h.index)??0;return(w,x,v)=>{let y=w.getComponent("custom_model_data",x);if(!y?.isCompound())return!1;let I=y.getList("flags").getNumber(g);return I!==void 0&&I!==0};default:return console.warn(`[deepslate]: Unknown condition property '${d}'`),()=>!1}}}e.Condition=i;class o{property;cases;fallback;constructor(h,d,f){this.property=h,this.cases=d,this.fallback=f}getMesh(h,d,f){let m=this.property(h,d,f);return((m!==null?this.cases.get(m):void 0)??this.fallback)?.getMesh(h,d,f)??fu}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"main_hand":return(g,w,x)=>x.main_hand??"right";case"display_context":return(g,w,x)=>x.display_context??"gui";case"context_dimension":return(g,w,x)=>x.context_dimension?.toString()??null;case"charge_type":let f=R.create("firework_rocket");return(g,w,x)=>{let v=g.getComponent("charged_projectiles",w);return!v?.isList()||v.length===0?"none":v.filter(y=>y.isCompound()?R.parse(y.getString("id")).equals(f):!1).length>0?"rocket":"arrow"};case"trim_material":return(g,w,x)=>{let v=g.getComponent("trim",w);return v?.isCompound()?R.parse(v.getString("material")).toString():null};case"block_state":let m=M.readString(h.block_state_property)??"";return(g,w,x)=>{let v=g.getComponent("block_state",w);return v?.isCompound()?v.getString(m):null};case"local_time":return(g,w,x)=>"NOT IMPLEMENTED";case"context_entity_type":return(g,w,x)=>x.context_entity_type?.toString()??null;case"custom_model_data":let p=M.readInt(h.index)??0;return(g,w,x)=>{let v=g.getComponent("custom_model_data",w);if(!v?.isCompound())return null;let y=v.getList("strings");return y.length<=p?null:y.getString(p)};default:return console.warn(`[deepslate]: Unknown select property '${d}'`),()=>null}}}e.Select=o;class a{property;scale;fallback;entries;constructor(h,d,f,m){this.property=h,this.scale=d,this.fallback=m,this.entries=f.sort((p,g)=>p.threshold-g.threshold)}getMesh(h,d,f){let m=this.property(h,d,f)*this.scale,p=this.fallback;for(let g of this.entries)if(g.threshold<=m)p=g.model;else break;return p?.getMesh(h,d,f)??fu}static propertyFromJson(h){let d=M.readString(h.property)?.replace(/^minecraft:/,"");switch(d){case"bundle/fullness":let f=function(x,v){let y=x.getComponent("bundle_contents",v);return y?.isListOrArray()?y.map(b=>b.isCompound()?Gn.fromNbt(b):void 0).reduce((b,k)=>{if(k===void 0)return b;if(k.hasComponent("bundle_contents",v))return b+f(k,v)+1/16;let E=k.getComponent("bees",v);if(E?.isListOrArray()&&E.length>0)return b+1;let A=k.getComponent("max_stack_size",v)?.getAsNumber()??1;return b+k.count/A},0):0};return(x,v,y)=>f(x,v);case"damage":{let x=M.readBoolean(h.normalize)??!0;return(v,y,I)=>{let b=v.getComponent("max_damage",y)?.getAsNumber()??0,k=Fe(v.getComponent("damage",y)?.getAsNumber()??0,0,b);return x?Fe(k/b,0,1):Fe(k,0,b)}}case"count":{let x=M.readBoolean(h.normalize)??!0;return(v,y,I)=>{let b=v.getComponent("max_stack_size",y)?.getAsNumber()??1;return x?Fe(v.count/b,0,1):Fe(v.count,0,b)}}case"cooldown":return(x,v,y)=>{let I=x.getComponent("use_cooldown",v),b=I?.isCompound()?R.parse(I.getString("cooldown_group")??x.id):x.id;return y.cooldown_percentage?.[b.toString()]??0};case"time":switch(M.readString(h.source)??"daytime"){case"moon_phase":return(x,v,y)=>(y.game_time??0)/24e3%8/8;case"random":return(x,v,y)=>Math.random();default:return(x,v,y)=>{let b=(y.game_time??0)/24e3%1-.25,k=.5-Math.cos(b*Math.PI)/2;return(b*2+k)/3}}case"compass":return(x,v,y)=>y.compass_angle??0;case"crossbow/pull":return(x,v,y)=>y["crossbow/pull"]??0;case"use_duration":let p=M.readBoolean(h.remaining)??!0;return(x,v,y)=>y.use_duration===void 0||y.use_duration<0?0:p?Math.max((y.max_use_duration??0)-y.use_duration,0):y.use_duration;case"use_cycle":let g=M.readNumber(h.period)??1;return(x,v,y)=>y.use_duration===void 0||y.use_duration<0?0:Math.max((y.max_use_duration??0)-(y.use_duration??0),0)%g;case"custom_model_data":let w=M.readInt(h.index)??0;return(x,v,y)=>{let I=x.getComponent("custom_model_data",v);return I?.isCompound()?I.getList("floats").getNumber(w):0};default:return console.warn(`[deepslate]: Unknown range dispatch property '${d}'`),()=>0}}}e.RangeDispatch=a;class l{specialModel;base;constructor(h,d){this.specialModel=h,this.base=d}getMesh(h,d,f){let m=this.specialModel.getMesh(h,d),p=d.getBlockModel(this.base);return p?(m.transform(p.getDisplayTransform(f.display_context??"gui")),m):(console.warn(`[deepslate]: Special model base '${this.base}' does not exist`),new _e)}}e.Special=l;class c{getMesh(h,d,f){let m=f["bundle/selected_item"];if(m===void 0||m<0)return new _e;let p=h.getComponent("bundle_contents",d);if(!p?.isListOrArray())return new _e;let g=p.get(m);if(g===void 0||!g.isCompound())return new _e;let w=Gn.fromNbt(g);return Wi.getItemMesh(w,d,{...f,"bundle/selected_item":-1,selected:!1,carried:!1,use_duration:-1})}}e.BundleSelectedItem=c})(Ao=Ao||(Ao={}));var Ge;(function(e){function t(o){let a=M.readObject(o)??{};return a.absolute!==void 0?r(M.readNumber(a.absolute)??0):a.above_bottom!==void 0?n(M.readNumber(a.above_bottom)??0):a.below_top!==void 0?s(M.readNumber(a.below_top)??0):a.relative_to_sea_level!==void 0?i(M.readNumber(a.relative_to_sea_level)??0):()=>0}e.fromJson=t;function r(o){return()=>o}e.absolute=r;function n(o){return a=>a.minY+o}e.aboveBottom=n;function s(o){return a=>a.minY+a.height-1-o}e.belowTop=s;function i(o){return a=>a.seaLevel+o}e.relativeToSeaLevel=i})(Ge=Ge||(Ge={}));var Xi=class{randomState;defaultBlock;seaLevel;preliminarySurface;random;surfaceNoise;surfaceSecondaryNoise;constructor(t,r,n,s,i){this.randomState=t,this.defaultBlock=r,this.seaLevel=n,this.preliminarySurface=s,this.random=i,this.surfaceNoise=t.getOrCreateNoise(R.create("surface")),this.surfaceSecondaryNoise=t.getOrCreateNoise(R.create("surface_secondary"))}buildSurface(t,r,n,s,i){let o=Je.minBlockX(t.pos),a=Je.minBlockZ(t.pos),l=new Qn(this,this.randomState,t,r,s,i),c=n.compile(l);for(let u=0;u<16;u+=1){let h=o+u;for(let d=0;d<1;d+=1){let f=a+d;l.updateXZ(h,f);let m=0,p=Number.MIN_SAFE_INTEGER,g=Number.MAX_SAFE_INTEGER;for(let w=t.maxY;w>=t.minY;w-=1){let x=te.create(h,w,f),v=t.getBlockState(x);if(v.equals(se.AIR)){m=0,p=Number.MIN_SAFE_INTEGER;continue}if(v.isFluid()){p===Number.MIN_SAFE_INTEGER&&(p=w+1);continue}if(g>=w){g=Number.MIN_SAFE_INTEGER;for(let b=w-1;b>=t.minY;b-=1){let k=t.getBlockState(te.create(h,b,f));if(k.equals(se.AIR)||k.isFluid()){g=b+1;break}}}m+=1;let y=w-g+1;l.updateY(m,y,p,w);let I=c(h,w,f);I&&t.setBlockState(x,I)}}}}getSurfaceDepth(t,r){let n=this.surfaceNoise.get3D(t,0,r),s=this.random.at(t,0,r).nextDouble()*.25;return n*2.75+3+s}getSurfaceSecondary(t,r){return this.surfaceSecondaryNoise.get3D(t,0,r)}getOrCreateRandom(t){return this.randomState.getOrCreateRandom(t)}},Qn=class{system;randomState;chunk;noiseChunk;context;biomeGetter;blockX=0;blockY=0;blockZ=0;stoneDepthAbove=0;stoneDepthBelow=0;surfaceDepth=0;waterHeight=0;lastUpdateXZ=Number.MIN_SAFE_INTEGER;lastUpdateY=Number.MIN_SAFE_INTEGER;lastSurfaceDepth2Update=Number.MIN_SAFE_INTEGER;surfaceSecondary=0;lastMinSurfaceLevelUpdate=Number.MIN_SAFE_INTEGER;minSurfaceLevel=0;biome;noiseSamplers2d=new Map;noiseSamplers3d=new Map;constructor(t,r,n,s,i,o){this.system=t,this.randomState=r,this.chunk=n,this.noiseChunk=s,this.context=i,this.biomeGetter=o}updateXZ(t,r){this.lastUpdateXZ+=1,this.lastUpdateY+=1,this.blockX=t,this.blockZ=r,this.surfaceDepth=this.system.getSurfaceDepth(t,r)}updateY(t,r,n,s){this.lastUpdateY+=1,this.biome=void 0,this.blockY=s,this.stoneDepthAbove=t,this.stoneDepthBelow=r,this.waterHeight=n}getSurfaceSecondary(){return this.lastSurfaceDepth2Update!==this.lastUpdateXZ&&(this.lastSurfaceDepth2Update=this.lastUpdateXZ,this.surfaceSecondary=this.system.getSurfaceSecondary(this.blockX,this.blockZ)),this.surfaceSecondary}getMinSurfaceLevel(){if(this.lastMinSurfaceLevelUpdate!==this.lastUpdateXZ){this.lastMinSurfaceLevelUpdate=this.lastUpdateXZ;let t=this.noiseChunk.randomState.router.chunkSurfaceLevel.compute(j.context(this.blockX,0,this.blockZ));this.minSurfaceLevel=Math.floor(t)+this.surfaceDepth-8}return this.minSurfaceLevel}getBiome(){return this.biome===void 0&&(this.biome=this.biomeGetter(te.create(this.blockX,this.blockY,this.blockZ))),this.biome}resolveAnchorY(t){return t(this.context)}getNoiseSampler(t,r){return r?Et(this.noiseSamplers2d,t.toString(),()=>this.createNoiseSampler3d(t)):Et(this.noiseSamplers3d,t.toString(),()=>this.createNoiseSampler2d(t))}createNoiseSampler2d(t){let r=this.randomState.getOrCreateNoise(t),n=this.lastUpdateXZ-1,s=0;return()=>(n!==this.lastUpdateXZ&&(s=r.get3D(this.blockX,0,this.blockZ),n=this.lastUpdateXZ),s)}createNoiseSampler3d(t){let r=this.randomState.getOrCreateNoise(t),n=this.lastUpdateY-1,s=0;return()=>(n!==this.lastUpdateY&&(s=r.get3D(this.blockX,this.blockY,this.blockZ),n=this.lastUpdateY),s)}},Ft=class{};(function(e){e.NOOP={compile:()=>()=>{}};function t(o){if(typeof o=="string")return new r(he.reference(xe.MATERIAL_RULE,R.parse(o)));let a=M.readObject(o)??{};switch(M.readString(a.type)?.replace(/^minecraft:/,"")){case"block":return new n(se.fromJson(a.result_state));case"sequence":return new s(M.readArray(a.sequence,e.fromJson)??[]);case"condition":return new i(ur.fromJson(a.if_true),e.fromJson(a.then_run));default:return e.NOOP}}e.fromJson=t;class r extends e{holder;constructor(a){super(),this.holder=a}compile(a){return this.holder.value().compile(a)}}e.HolderHolder=r;class n extends e{resultState;constructor(a){super(),this.resultState=a}compile(a){return()=>this.resultState}}e.Block=n;class s extends e{sequence;constructor(a){super(),this.sequence=a}compile(a){if(this.sequence.length===0)return()=>{};if(this.sequence.length===1)return this.sequence[0].compile(a);let l=this.sequence.map(c=>c.compile(a));return(c,u,h)=>{for(let d of l){let f=d(c,u,h);if(f)return f}}}}e.Sequence=s;class i extends e{ifTrue;thenRun;constructor(a,l){super(),this.ifTrue=a,this.thenRun=l}compile(a){let l=this.ifTrue.compile(a),c=this.thenRun.compile(a);return(u,h,d)=>{if(l())return c(u,h,d)}}}e.Condition=i})(Ft=Ft||(Ft={}));var ur=class{};(function(e){e.ALWAYS_FALSE={compile:()=>()=>!1},e.ALWAYS_TRUE={compile:()=>()=>!0};function t(d){if(typeof d=="string")return new n(he.reference(xe.MATERIAL_CONDITION,R.parse(d)));let f=M.readObject(d)??{};switch(M.readString(f.type)?.replace(/^minecraft:/,"")){case"above_preliminary_surface":return new s;case"biome":return new i(Lt.parser(xe.BIOME)(f.biome_is));case"noise_threshold":return new o(R.parse(M.readString(f.noise)??""),M.readNumber(f.min_threshold)??0,M.readNumber(f.max_threshold)??0,M.readBoolean(f.is_3d)??!1);case"not":return new a(e.fromJson(f.invert));case"stone_depth":return new l(M.readInt(f.offset)??0,M.readBoolean(f.add_surface_depth)??!1,M.readInt(f.secondary_depth_range)??0,M.readString(f.surface_type)==="ceiling");case"vertical_gradient":return new c(R.parse(M.readString(f.random_name)??""),Ge.fromJson(f.true_at_and_below),Ge.fromJson(f.false_at_and_above));case"water":return new u(M.readInt(f.offset)??0,M.readInt(f.surface_depth_multiplier)??0,M.readBoolean(f.add_surface_depth)??!1);case"y_above":return new h(Ge.fromJson(f.anchor),M.readInt(f.surface_depth_multiplier)??0,M.readBoolean(f.add_surface_depth)??!1)}return e.ALWAYS_FALSE}e.fromJson=t;function r(d,f){let m=d.lastUpdateY-1,p=!1;return()=>(d.lastUpdateY!==m&&(m=d.lastUpdateY,p=f()),p)}class n extends e{holder;constructor(f){super(),this.holder=f}compile(f){return this.holder.value().compile(f)}}e.HolderHolder=n;class s extends e{compile(f){return()=>f.blockY>=f.getMinSurfaceLevel()}}e.AbovePreliminarySurface=s;class i extends e{biomes;constructor(f){super(),this.biomes=f}compile(f){let m=new Set(Array(...this.biomes.value().getEntries()).map(p=>p.key().toString()));return r(f,()=>m.has(f.getBiome().toString()))}}e.Biome=i;class o extends e{noise;minThreshold;maxThreshold;is3d;constructor(f,m,p,g){super(),this.noise=f,this.minThreshold=m,this.maxThreshold=p,this.is3d=g}compile(f){let m=f.getNoiseSampler(this.noise,this.is3d);return()=>{let p=m();return this.minThreshold<=p&&p<=this.maxThreshold}}}e.NoiseThreshold=o;class a extends e{invert;constructor(f){super(),this.invert=f}compile(f){let m=this.invert.compile(f);return()=>!m()}}e.Not=a;class l extends e{offset;addSurfaceDepth;secondaryDepthRange;ceiling;constructor(f,m,p,g){super(),this.offset=f,this.addSurfaceDepth=m,this.secondaryDepthRange=p,this.ceiling=g}compile(f){return r(f,()=>{let m=this.ceiling?f.stoneDepthBelow:f.stoneDepthAbove,p=this.addSurfaceDepth?f.surfaceDepth:0,g=this.secondaryDepthRange===0?0:on(f.getSurfaceSecondary(),-1,1,0,this.secondaryDepthRange);return m<=1+this.offset+p+g})}}e.StoneDepth=l;class c extends e{randomName;trueAtAndBelow;falseAtAndAbove;constructor(f,m,p){super(),this.randomName=f,this.trueAtAndBelow=m,this.falseAtAndAbove=p}compile(f){let m=f.resolveAnchorY(this.trueAtAndBelow),p=f.resolveAnchorY(this.falseAtAndAbove),g=f.system.getOrCreateRandom(this.randomName);return r(f,()=>{if(f.blockY<=m)return!0;if(f.blockY>=p)return!1;let w=on(f.blockY,m,p,1,0);return g.at(f.blockX,f.blockY,f.blockZ).nextFloat(){if(f.waterHeight===Number.MIN_SAFE_INTEGER)return!0;let m=this.addStoneDepth?f.stoneDepthAbove:0;return f.blockY+m>=f.waterHeight+this.offset+f.surfaceDepth*this.surfaceDepthMultiplier})}}e.Water=u;class h extends e{anchor;surfaceDepthMultiplier;addStoneDepth;constructor(f,m,p){super(),this.anchor=f,this.surfaceDepthMultiplier=m,this.addStoneDepth=p}compile(f){return r(f,()=>{let m=this.addStoneDepth?f.stoneDepthAbove:0;return f.blockY+m>=f.resolveAnchorY(this.anchor)+f.surfaceDepth*this.surfaceDepthMultiplier})}}e.YAbove=h})(ur=ur||(ur={}));var $t;(function(e){let t=i=>new j.HolderHolder(he.parser(xe.DENSITY_FUNCTION,j.fromJson)(i));function r(i){let o=M.readObject(i)??{};return{temperature:t(o.temperature),vegetation:t(o.vegetation),continents:t(o.continents),erosion:t(o.erosion),depth:t(o.depth),ridges:t(o.ridges),chunkSurfaceLevel:t(o.preliminary_surface_level),finalDensity:t(o.final_density)}}e.fromJson=r;function n(i){return{temperature:j.Constant.ZERO,vegetation:j.Constant.ZERO,continents:j.Constant.ZERO,erosion:j.Constant.ZERO,depth:j.Constant.ZERO,ridges:j.Constant.ZERO,chunkSurfaceLevel:j.Constant.ZERO,finalDensity:j.Constant.ZERO,...i}}e.create=n;function s(i,o){return{temperature:i.temperature.mapAll(o),vegetation:i.vegetation.mapAll(o),continents:i.continents.mapAll(o),erosion:i.erosion.mapAll(o),depth:i.depth.mapAll(o),ridges:i.ridges.mapAll(o),chunkSurfaceLevel:i.chunkSurfaceLevel.mapAll(o),finalDensity:i.finalDensity.mapAll(o)}}e.mapAll=s})($t=$t||($t={}));var dn;(function(e){function t(n){let s=M.readObject(n)??{};return{minY:M.readInt(s.min_y)??0,height:M.readInt(s.height)??256}}e.fromJson=t;function r(n){return{minY:0,height:256,...n}}e.create=r})(dn=dn||(dn={}));var Vt;(function(e){function t(n){let s=M.readObject(n)??{};return{noise:dn.fromJson(s.noise),defaultBlock:se.fromJson(s.default_block),defaultFluid:se.fromJson(s.default_fluid),noiseRouter:$t.fromJson(s.noise_router),materialRule:Ft.fromJson(s.material_rule),seaLevel:M.readInt(s.sea_level)??0,aquifers:s.aquifers?ei.fromJson(s.aquifers):void 0,legacyRandomSource:M.readBoolean(s.legacy_random_source)??!1}}e.fromJson=t;function r(n){return{noise:dn.create({}),defaultBlock:se.STONE,defaultFluid:se.WATER,noiseRouter:$t.create({}),materialRule:Ft.NOOP,seaLevel:0,aquifers:void 0,legacyRandomSource:!1,...n}}e.create=r})(Vt=Vt||(Vt={}));var xe=class e{static NOISE=$e.createAndRegister("worldgen/noise",Lr.fromJson);static DENSITY_FUNCTION=$e.createAndRegister("worldgen/density_function",t=>j.fromJson(t));static NOISE_SETTINGS=$e.createAndRegister("worldgen/noise_settings",Vt.fromJson);static MATERIAL_RULE=$e.createAndRegister("worldgen/material_rule",Ft.fromJson);static MATERIAL_CONDITION=$e.createAndRegister("worldgen/material_condition",ur.fromJson);static BIOME=$e.createAndRegister("worldgen/biome");static SURFACE_NOISE=e.createNoise("surface",.9381732587751008,-6,[1,1,1]);static SURFACE_SECONDARY_NOISE=e.createNoise("surface_secondary",1.0582769165096106,-6,[1,1,0,1]);static createNoise(t,r,n,s){return e.NOISE.register(R.create(t),new Lr(r,n,s.length,"enabled",s),!0)}};var j=class{computeVolume(t){let r=0,n=Array(t.size());for(let s=0;s{let _=M.readArray(Q,S=>M.readNumber(S)??0)??[];return new Ue(_[0]??0,_[1]??0,_[2]??0)};function i(Q,_=i){if(typeof Q=="string")return new a(he.reference(xe.DENSITY_FUNCTION,R.parse(Q)));if(typeof Q=="number")return new o(Q);let S=M.readObject(Q)??{},O=M.readString(S.type)?.replace(/^minecraft:/,"");switch(O){case"blend_alpha":return new l(1,0,1);case"blend_offset":return new l(0,-1/0,1/0);case"beardifier":return new l(0,-1/0,1/0);case"old_blended_noise":return new c(M.readNumber(S.xz_scale)??1,M.readNumber(S.y_scale)??1,M.readNumber(S.xz_factor)??80,M.readNumber(S.y_factor)??160,M.readNumber(S.smear_scale_multiplier)??8);case"interpolated":return new h(_(S.input??S.argument),M.readInt(S.cell_size_xz)??4,M.readInt(S.cell_size_y)??4);case"cache":return new u(_(S.input??S.argument));case"noise":return new d(n(S.noise),M.readNumber(S.xz_scale)??1,M.readNumber(S.y_scale)??1,S.shift_x?_(S.shift_x):e.Constant.ZERO,S.shift_y?_(S.shift_y):e.Constant.ZERO,S.shift_z?_(S.shift_z):e.Constant.ZERO);case"end_outer_islands":return new f;case"find_top_surface":return new m(_(S.density),_(S.upper_bound),M.readInt(S.lower_bound)??0,M.readInt(S.cell_height)??1);case"range_choice":return new p(_(S.input),M.readNumber(S.min_inclusive)??0,M.readNumber(S.max_exclusive)??1,_(S.when_in_range),_(S.when_out_of_range));case"shift_a":return new w(n(S.noise??S.argument));case"shift_b":return new x(n(S.noise??S.argument));case"shift":return new v(n(S.noise??S.argument));case"blend_density":return new y(_(S.input??S.argument));case"clamp":return new I(_(S.input),M.readNumber(S.min)??0,M.readNumber(S.max)??1);case"interval_select":return new b(_(S.input),M.readArray(S.thresholds,U=>M.readNumber(U)??0)??[],M.readArray(S.functions,_)??[]);case"abs":case"square":case"cube":case"sqrt":case"half_negative":case"quarter_negative":case"squeeze":case"reciprocal":case"negate":case"log":case"sign":return new E(O,_(S.input??S.argument));case"add":case"sub":case"mul":case"div":case"min":case"max":return new N(M.readEnum(O,A),_(S.left??S.argument1),_(S.right??S.argument2));case"spline":return new Y(Zn.fromJson(S.spline,_));case"constant":return new o(M.readNumber(S.value??S.argument)??0);case"gradient":return new ce(M.readEnum(S.axis,$),M.readEnum(S.tiling,V),M.readInt(S.from_coordinate)??0,M.readInt(S.to_coordinate)??1,M.readNumber(S.from_value)??0,M.readNumber(S.to_value)??1);case"lerp":return new oe(_(S.alpha),_(S.first),_(S.second));case"floor":case"round":case"ceil":case"truncate":return new B(O,_(S.input),_(S.multiple));case"pow":return new D(_(S.base),_(S.exponent));case"distance_to_point":return new ee(s(S.point),M.readEnum(S.metric,ie));case"slice":return new de(M.readEnum(S.axis,$),M.readInt(S.coordinate)??0,_(S.input))}return o.ZERO}e.fromJson=i;class o extends e{value;static ZERO=new o(0);static ONE=new o(1);constructor(_){super(),this.value=_}compute(){return this.value}mapChildren(_){return this}range(){return J.ofExact(this.value)}}e.Constant=o;class a extends e{holder;constructor(_){super(),this.holder=_}compute(_){return this.holder.value().compute(_)}mapChildren(_){return new a(he.direct(_.apply(this.holder.value())))}range(){return this.holder.value().range()}}e.HolderHolder=a;class l extends e.Constant{min;max;constructor(_,S,O){super(_),this.min=S,this.max=O}range(){return J.of(this.min,this.max)}}e.ConstantMinMax=l;class c extends e{xzScale;yScale;xzFactor;yFactor;smearScaleMultiplier;blendedNoise;constructor(_,S,O,U,ue,qe){super(),this.xzScale=_,this.yScale=S,this.xzFactor=O,this.yFactor=U,this.smearScaleMultiplier=ue,this.blendedNoise=qe}compute(_){return this.blendedNoise?.sample(_.x,_.y,_.z)??0}mapChildren(_){return this}range(){return this.blendedNoise?this.blendedNoise.range():J.INFINITE}}e.OldBlendedNoise=c;class u extends e{input;constructor(_){super(),this.input=_}compute(_){return this.input.compute(_)}mapChildren(_){return new u(_.apply(this.input))}range(){return this.input.range()}}e.Cache=u;class h extends e{input;cellSizeXz;cellSizeY;values;constructor(_,S,O){super(),this.input=_,this.cellSizeXz=S,this.cellSizeY=O,this.values=new Map}compute({x:_,y:S,z:O}){let U=this.cellSizeXz,ue=this.cellSizeY,qe=(_%U+U)%U/U,Ae=(S%ue+ue)%ue/ue,Ne=(O%U+U)%U/U,ye=Math.floor(_/U)*U,le=Math.floor(S/ue)*ue,q=Math.floor(O/U)*U;return jc(qe,Ae,Ne,()=>this.computeCorner(ye,le,q),()=>this.computeCorner(ye+U,le,q),()=>this.computeCorner(ye,le+ue,q),()=>this.computeCorner(ye+U,le+ue,q),()=>this.computeCorner(ye,le,q+U),()=>this.computeCorner(ye+U,le,q+U),()=>this.computeCorner(ye,le+ue,q+U),()=>this.computeCorner(ye+U,le+ue,q+U))}computeCorner(_,S,O){return Et(this.values,`${_} ${S} ${O}`,()=>this.input.compute(e.context(_,S,O)))}mapChildren(_){return new h(_.apply(this.input),this.cellSizeXz,this.cellSizeY)}range(){return this.input.range()}}e.Interpolated=h;class d extends e{noise;xzScale;yScale;shiftX;shiftY;shiftZ;noiseSampler;constructor(_,S,O,U,ue,qe,Ae){super(),this.noise=_,this.xzScale=S,this.yScale=O,this.shiftX=U,this.shiftY=ue,this.shiftZ=qe,this.noiseSampler=Ae}compute(_){let S=_.x*this.xzScale+this.shiftX.compute(_),O=_.y*this.yScale+this.shiftY.compute(_),U=_.z*this.xzScale+this.shiftZ.compute(_);return this.noiseSampler?.get3D(S,O,U)??0}mapChildren(_){return new d(this.noise,this.xzScale,this.yScale,_.apply(this.shiftX),_.apply(this.shiftY),_.apply(this.shiftZ),this.noiseSampler)}range(){return this.noiseSampler?this.noiseSampler.range():J.INFINITE}}e.NoiseFunction=d;class f extends e{islandNoise;constructor(_){super();let S=new Oe(_??BigInt(0));S.consume(17292),this.islandNoise=new Ui(S)}getHeightValue(_,S){let O=Math.floor(_/2),U=Math.floor(S/2),ue=_%2,qe=S%2,Ae=Fe(100-Math.sqrt(_*_+S*S)*8,-100,80);for(let Ne=-12;Ne<=12;Ne+=1)for(let ye=-12;ye<=12;ye+=1){let le=O+Ne,q=U+ye;if(le*le+q*q<=4096||this.islandNoise.get2D(le,q)>=-.9)continue;let L=(Math.abs(le)*3439+Math.abs(q)*147)%13+9,ae=ue+Ne*2,Se=qe+ye*2,ft=100-Math.sqrt(ae*ae+Se*Se)*L,Qe=Fe(ft,-100,80);Ae=Math.max(Ae,Qe)}return Ae}compute({x:_,y:S,z:O}){return(this.getHeightValue(Math.floor(_/8),Math.floor(O/8))-8)/128}mapChildren(_){return this}range(){return J.of(-.84375,.5625)}}e.EndOuterIslands=f;class m extends e{density;upperBound;lowerBound;cellHeight;constructor(_,S,O,U){super(),this.density=_,this.upperBound=S,this.lowerBound=O,this.cellHeight=U}compute(_){let S=Math.floor(this.upperBound.compute(_)/this.cellHeight)*this.cellHeight;if(S=this.lowerBound;O-=this.cellHeight)if(this.density.compute(e.context(_.x,O,_.z))>0)return O;return this.lowerBound}mapChildren(_){return new m(_.apply(this.density),_.apply(this.upperBound),this.lowerBound,this.cellHeight)}range(){return J.of(this.lowerBound,Math.max(this.lowerBound,this.upperBound.range().max))}}e.FindTopSurface=m;class p extends e{input;minInclusive;maxExclusive;whenInRange;whenOutOfRange;constructor(_,S,O,U,ue){super(),this.input=_,this.minInclusive=S,this.maxExclusive=O,this.whenInRange=U,this.whenOutOfRange=ue}compute(_){let S=this.input.compute(_);return this.minInclusive<=S&&S_.apply(S)))}range(){return J.encapsulating(...this.functions.map(_=>_.range()))}}e.IntervalSelect=b;let k=["abs","square","cube","sqrt","half_negative","quarter_negative","squeeze","reciprocal","negate","log","sign"];class E extends r{type;constructor(_,S){super(S),this.type=_}transform(_,S){return E.transform(this.type,S)}static transform(_,S){switch(_){case"abs":return Math.abs(S);case"square":return S*S;case"cube":return S*S*S;case"half_negative":return S>0?S:S*.5;case"quarter_negative":return S>0?S:S*.25;case"squeeze":let O=Fe(S,-1,1);return O/2-O*O*O/24;case"reciprocal":return 1/S;case"negate":return-S;case"sqrt":return Math.sqrt(S);case"log":return Math.log(S);case"sign":return Math.sign(S)}}mapChildren(_){return new E(this.type,_.apply(this.input))}range(){let _=this.input.range();switch(this.type){case"abs":return J.abs(_);case"square":return J.square(_);case"cube":case"half_negative":case"quarter_negative":case"squeeze":return J.mapMonotonic(_,S=>E.transform(this.type,S));case"reciprocal":return J.reciprocal(_);case"negate":return J.sub(J.ofExact(0),_);case"sqrt":return J.pow(_,J.ofExact(.5));case"log":return J.log(_);case"sign":return J.sign(_)}}}e.Unary=E;let A=["add","sub","mul","div","min","max"];class N extends e{type;left;right;rightRange=J.INFINITE;constructor(_,S,O){super(),this.type=_,this.left=S,this.right=O}compute(_){let S=this.left.compute(_);switch(this.type){case"add":return S+this.right.compute(_);case"sub":return S-this.right.compute(_);case"mul":return S===0?0:S*this.right.compute(_);case"div":return S===0?0:S/this.right.compute(_);case"min":return Sthis.rightRange.max?S:Math.max(S,this.right.compute(_))}}mapChildren(_){return new N(this.type,_.apply(this.left),_.apply(this.right))}range(){let _=this.left.range(),S=this.right.range();switch(this.type){case"add":return J.add(_,S);case"sub":return J.sub(_,S);case"mul":return J.mul(_,S);case"div":return J.div(_,S);case"min":return J.min(_,S);case"max":return J.max(_,S)}}trySimplify(){if(this.type==="mul"||this.type==="add"){if(this.left instanceof o)return new F(this.type,this.right,this.left.value);if(this.right instanceof o)return new F(this.type,this.left,this.right.value)}return this.rightRange=this.right.range(),this}}e.Binary=N;let z=["add","mul"];class F extends r{type;value;constructor(_,S,O){super(S),this.type=_,this.value=O}transform(_,S){switch(this.type){case"mul":return S*this.value;case"add":return S+this.value}}mapChildren(_){return new F(this.type,_.apply(this.input),this.value)}range(){switch(this.type){case"mul":return J.mul(this.input.range(),J.ofExact(this.value));case"add":return J.add(this.input.range(),J.ofExact(this.value))}}}e.MulOrAdd=F;class Y extends e{spline;constructor(_){super(),this.spline=_}compute(_){return this.spline.compute(_)}mapChildren(_){return new Y(this.spline.mapCoordinates(S=>S instanceof e?_.apply(S):S))}range(){return this.spline.range()}}e.Spline=Y;let $=["x","y","z"],V=["clamp_to_edge","repeat","mirrored_repeat"];class ce extends e{axis;tiling;fromCoordinate;toCoordinate;fromValue;toValue;constructor(_,S,O,U,ue,qe){super(),this.axis=_,this.tiling=S,this.fromCoordinate=O,this.toCoordinate=U,this.fromValue=ue,this.toValue=qe}compute(_){let S=this.toCoordinate-this.fromCoordinate,O=_[this.axis]-this.fromCoordinate;switch(this.tiling){case"clamp_to_edge":break;case"repeat":O=(O%S+S)%S;break;case"mirrored_repeat":let U=Math.floor(O/S),ue=O-U*S;O=(U&1)==0?ue:S-ue;break}return Qs(O/S,this.fromValue,this.toValue)}mapChildren(_){return this}range(){return J.between(this.fromValue,this.toValue)}}e.Gradient=ce;class oe extends e{alpha;first;second;constructor(_,S,O){super(),this.alpha=_,this.first=S,this.second=O}compute(_){let S=this.alpha.compute(_);return S===0?this.first.compute(_):S===1?this.second.compute(_):Pr(S,this.first.compute(_),this.second.compute(_))}mapChildren(_){return new oe(_.apply(this.alpha),_.apply(this.first),_.apply(this.second))}range(){return J.lerp(this.alpha.range(),this.first.range(),this.second.range())}}e.Lerp=oe;let T=["floor","round","ceil","truncate"];class B extends e{type;input;multiple;constructor(_,S,O){super(),this.type=_,this.input=S,this.multiple=O}compute(_){let S=this.input.compute(_),O=this.multiple.compute(_);return O===0?S:this.roundToInteger(S/O)*O}roundToInteger(_){switch(this.type){case"floor":return Math.floor(_);case"round":return Math.round(_);case"ceil":return Math.ceil(_);case"truncate":return Math.trunc(_)}}mapChildren(_){return new B(this.type,_.apply(this.input),_.apply(this.multiple))}range(){let _=this.multiple.range();return J.mul(J.mapMonotonic(J.div(this.input.range(),_),S=>this.roundToInteger(S)),_)}}e.Round=B;class D extends e{base;exponent;constructor(_,S){super(),this.base=_,this.exponent=S}compute(_){return Math.pow(this.base.compute(_),this.exponent.compute(_))}mapChildren(_){return new D(_.apply(this.base),_.apply(this.exponent))}range(){return J.pow(this.base.range(),this.exponent.range())}}e.Pow=D;let ie=["euclidean","euclidean_squared","manhattan","chebyshev"];class ee extends e{point;metric;constructor(_,S){super(),this.point=_,this.metric=S}compute(_){let S=this.point.sub(new Ue(_.x,_.y,_.z));switch(this.metric){case"euclidean":return S.length();case"euclidean_squared":return S.lengthSquared();case"manhattan":return Math.abs(S.x)+Math.abs(S.y)+Math.abs(S.z);case"chebyshev":return Math.max(Math.abs(S.x),Math.abs(S.y),Math.abs(S.z))}}mapChildren(_){return this}range(){return J.of(0,1/0)}}e.DistanceToPoint=ee;class de extends e{axis;coordinate;input;constructor(_,S,O){super(),this.axis=_,this.coordinate=S,this.input=O}compute(_){switch(this.axis){case"x":return this.input.compute({x:0,y:_.y,z:_.z});case"y":return this.input.compute({x:0,y:_.y,z:_.z});case"z":return this.input.compute({x:0,y:_.y,z:_.z})}}mapChildren(_){return new de(this.axis,this.coordinate,_.apply(this.input))}range(){return this.input.range()}}e.Slice=de})(j=j||(j={}));var Mt=class{sizeX;sizeY;sizeZ;minBlockX;minBlockY;minBlockZ;stepBlockX;stepBlockY;stepBlockZ;constructor(t,r,n,s,i,o,a=1,l=1,c=1){this.sizeX=t,this.sizeY=r,this.sizeZ=n,this.minBlockX=s,this.minBlockY=i,this.minBlockZ=o,this.stepBlockX=a,this.stepBlockY=l,this.stepBlockZ=c}indexUnchecked(t,r,n){return r+(t+n*this.sizeX)*this.sizeY}blockX(t){return this.minBlockX+t*this.stepBlockX}blockY(t){return this.minBlockY+t*this.stepBlockY}blockZ(t){return this.minBlockZ+t*this.stepBlockZ}maxBlockX(){return this.minBlockX+this.sizeX*this.stepBlockX-1}maxBlockY(){return this.minBlockY+this.sizeY*this.stepBlockY-1}maxBlockZ(){return this.minBlockZ+this.sizeZ*this.stepBlockZ-1}size(){return this.sizeX*this.sizeY*this.sizeZ}};var ei;(function(e){let t=s=>new j.HolderHolder(he.parser(xe.DENSITY_FUNCTION,j.fromJson)(s));function r(s){let i=M.readObject(s)??{};return{barrier:t(i.barrier),fluidLevelFloodedness:t(i.fluid_level_floodedness),fluidLevelSpread:t(i.fluid_level_spread),lava:t(i.lava),exclusion:t(i.exclusion),surfaceLevel:t(i.surface_level)}}e.fromJson=r;function n(s,i){return{barrier:s.barrier.mapAll(i),fluidLevelFloodedness:s.fluidLevelFloodedness.mapAll(i),fluidLevelSpread:s.fluidLevelSpread.mapAll(i),lava:s.lava.mapAll(i),exclusion:s.exclusion.mapAll(i),surfaceLevel:s.surfaceLevel.mapAll(i)}}e.mapAll=n})(ei=ei||(ei={}));var mn=class{level;type;constructor(t,r){this.level=t,this.type=r}at(t){return t0))return r(n,s,i).at(s)}}}e.createDisabled=t})(ti=ti||(ti={}));var Vi=class e{config;random;volume;globalFluidPicker;static X_SPACING=16;static Y_SPACING=12;static Z_SPACING=16;static SURFACE_SAMPLING=[[-2,-1],[-1,-1],[0,-1],[1,-1],[-3,0],[-2,0],[-1,0],[0,0],[1,0],[-2,1],[-1,1],[0,1],[1,1]];minGridX;minGridY;minGridZ;maxGridX;maxGridY;maxGridZ;gridSizeX;gridSizeY;gridSizeZ;aquiferCache;aquiferLocationCache;surfaceLevelCache;skipSamplingAboveY;constructor(t,r,n,s){this.config=t,this.random=r,this.volume=n,this.globalFluidPicker=s,this.minGridX=this.gridX(n.minBlockX-5)+0,this.maxGridX=this.gridX(n.maxBlockX()-5)+1,this.gridSizeX=this.maxGridX-this.minGridX+1,this.minGridY=this.gridY(n.minBlockY+1)-1,this.maxGridY=this.gridY(n.maxBlockY()+1)+1,this.gridSizeY=this.maxGridY-this.minGridY+1,this.minGridZ=this.gridZ(n.minBlockZ-5)+0,this.maxGridZ=this.gridZ(n.maxBlockZ()-5)+1,this.gridSizeZ=this.maxGridZ-this.minGridZ+1;let i=this.gridSizeX*this.gridSizeY*this.gridSizeZ;this.aquiferCache=Array(i).fill(void 0),this.aquiferLocationCache=Array(i).fill(void 0),this.surfaceLevelCache=new Map;let o=this.adjustSurfaceLevel(this.maxSurfaceLevel(this.fromGridX(this.minGridX,0),this.fromGridZ(this.minGridZ,0),this.fromGridX(this.maxGridX,9),this.fromGridZ(this.maxGridZ,9)));this.skipSamplingAboveY=this.fromGridY(this.gridY(o+12)+1,11)}computeSubstance(t,r,n,s){if(s>0)return;let i=this.globalFluidPicker(t,r,n);if(r>this.skipSamplingAboveY)return i.at(r);if(i.at(r).is(se.LAVA))return se.LAVA;let o=this.gridX(t-5),a=this.gridY(r+1),l=this.gridZ(n-5),c=Number.MAX_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=0,f=0,m=0;for(let E=0;E<=1;E+=1)for(let A=-1;A<=1;A+=1)for(let N=0;N<=1;N+=1){let z=o+E,F=a+A,Y=l+N,$=this.getIndex(z,F,Y),V=this.aquiferLocationCache[$];if(V===void 0){let D=this.random.at(z,F,Y);V=te.create(this.fromGridX(z,D.nextInt(10)),this.fromGridY(F,D.nextInt(10)),this.fromGridZ(Y,D.nextInt(10))),this.aquiferLocationCache[$]=V}let ce=V[0]-t,oe=V[1]-r,T=V[2]-n,B=ce*ce+oe*oe+T*T;c>=B?(m=f,f=d,d=$,h=u,u=c,c=B):u>=B?(m=f,f=$,h=u,u=B):h>=B&&(m=$,h=B)}let p=this.getAquiferStatus(d),g=e.similarity(c,u),w=p.at(r);if(g<=0||w.is(se.WATER)&&this.globalFluidPicker(t,r-1,n).at(r-1).is(se.LAVA))return w;let x={value:void 0},v=this.getAquiferStatus(f),y=g*this.calculatePressure(t,r,n,x,p,v);if(s+y>0)return;let I=this.getAquiferStatus(m),b=e.similarity(c,h);if(b>0){let E=g*b*this.calculatePressure(t,r,n,x,p,I);if(s+E>0)return}let k=e.similarity(u,h);if(k>0){let E=g*k*this.calculatePressure(t,r,n,x,v,I);if(s+E>0)return}return w}static similarity(t,r){return 1-Math.abs(r-t)/25}calculatePressure(t,r,n,s,i,o){let a=i.at(r),l=o.at(r);if(a.is(se.LAVA)&&l.is(se.WATER)||a.is(se.WATER)&&l.is(se.LAVA))return 2;let c=Math.abs(i.level-o.level);if(c===0)return 0;let u=(i.level+o.level)/2,h=r+.5-u,d=c/2-Math.abs(h),f=h>0?d>0?d/1.5:d/2.5:d+3>0?(d+3)/3:(d+3)/10;return f<-2||f>2?2*f:(s.value===void 0&&(s.value=this.config.barrier.compute(j.context(t,r,n))),2*(f+s.value))}getAquiferStatus(t){let r=this.aquiferCache[t];if(r!==void 0)return r;let n=this.aquiferLocationCache[t];if(n===void 0)throw new Error(`Missing aquifer location cache at index ${t}`);let[s,i,o]=n,a=this.computeFluid(s,i,o);return this.aquiferCache[t]=a,a}computeFluid(t,r,n){let s=this.globalFluidPicker(t,r,n),i=Number.MAX_SAFE_INTEGER,o=!1;for(let[l,c]of e.SURFACE_SAMPLING){let u=t+(c<<4),h=n+(c<<4),d=this.surfaceLevel(u,h),f=this.adjustSurfaceLevel(d),m=l===0&&c===0;if(m&&r-12>f)return s;if(m||r+12>f){let p=this.globalFluidPicker(u,f,h);if(!p.at(f).is(se.AIR))if(m)o=!0;else return p}i=Math.min(i,d)}let a=this.computeSurfaceLevel(t,r,n,s,i,o);return new mn(a,this.computeFluidType(t,r,n,s,a))}surfaceLevel(t,r){let n=t>>2<<2,s=r>>2<<2;return Et(this.surfaceLevelCache,Je.asLong(n,s),()=>je(this.config.surfaceLevel.compute(j.context(n,0,s))))}maxSurfaceLevel(t,r,n,s){let i=t>>2,o=n>>2,a=r>>2,l=s>>2,c=new Mt(o-i+1,1,l-a+1,i<<2,0,a<<2,4,1,4),u=this.config.surfaceLevel.computeVolume(c),h=-1/0;for(let d=0;dh&&(h=m)}return h}adjustSurfaceLevel(t){return t+8}computeSurfaceLevel(t,r,n,s,i,o){let a,l;if(this.config.exclusion.compute(j.context(t,r,n))>0)a=-1,l=-1;else{let c=this.adjustSurfaceLevel(i)-r,u=o?Gc(c,0,64,1,0):0,h=Fe(this.config.fluidLevelFloodedness.compute(j.context(t,r,n)),-1,1),d=on(u,1,0,-.3,.8),f=on(u,1,0,-.8,.4);a=h-f,l=h-d}return l>0?s.level:a>0?this.computeRandomizedFluidSurfaceLevel(t,r,n,i):Number.MIN_SAFE_INTEGER}computeRandomizedFluidSurfaceLevel(t,r,n,s){let i=Math.floor(t/16),o=Math.floor(r/40),a=Math.floor(n/40),l=o*40+20,c=this.config.fluidLevelSpread.compute(j.context(i,o,a)),u=Hc(c,3);return Math.min(s,l+u)}computeFluidType(t,r,n,s,i){if(i<=-10&&!s.type.is(se.LAVA)){let o=this.config.lava.compute(j.context(Math.floor(t/64),Math.floor(r/40),Math.floor(n/64)));if(Math.abs(o)>.3)return se.LAVA}return s.type}getIndex(t,r,n){let s=t-this.minGridX,i=r-this.minGridY,o=n-this.minGridZ;return(i*this.gridSizeZ+o)*this.gridSizeX+s}gridX(t){return Math.floor(t/e.X_SPACING)}fromGridX(t,r){return t*e.X_SPACING+r}gridY(t){return Math.floor(t/e.Y_SPACING)}fromGridY(t,r){return t*e.Y_SPACING+r}gridZ(t){return Math.floor(t/e.Z_SPACING)}fromGridZ(t,r){return t*e.Z_SPACING+r}};var Ki=class e{shift;biomes;n;constructor(t,r){if(this.shift=t,this.biomes=r,r.length===0)throw new Error("Cannot create checkerboard biome source without biomes");this.n=r.length}getBiome(t,r,n){let s=(((t>>this.shift)+(n>>this.shift))%this.n+this.n)%this.n;return R.parse(this.biomes[s].toString())}static fromJson(t){let r=M.readObject(t)??{},n=M.readInt(r.scale)??2,s;return typeof r.biomes=="string"?s=[R.parse(r.biomes)]:s=M.readArray(r.biomes,i=>R.parse(M.readString(i)??""))??[],new e(n+2,s)}};var Kt=class e{biome;constructor(t){this.biome=t}getBiome(){return this.biome}static fromJson(t){let r=M.readObject(t)??{},n=R.parse(M.readString(r.biome)??"plains");return new e(n)}};var St;(function(e){function r(m,p,g,w,x,v){return new a(m,p,g,w,x,v)}e.target=r;function n(m,p,g,w,x,v,y){return new o(s(m),s(p),s(g),s(w),s(x),s(v),y)}e.parameters=n;function s(m,p){return typeof m=="number"?new i(m,p??m):m}e.param=s;class i{min;max;constructor(p,g){this.min=p,this.max=g}distance(p){let g=(typeof p=="number"?p:p.min)-this.max,w=this.min-(typeof p=="number"?p:p.max);return g>0?g:Math.max(w,0)}union(p){return new i(Math.min(this.min,p.min),Math.max(this.max,p.max))}static fromJson(p){if(typeof p=="number")return new i(p,p);let[g,w]=M.readArray(p,x=>M.readNumber(x))??[];return new i(g??0,w??0)}}e.Param=i;class o{temperature;humidity;continentalness;erosion;depth;weirdness;offset;constructor(p,g,w,x,v,y,I){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y,this.offset=I}fittness(p){return vt(this.temperature.distance(p.temperature))+vt(this.humidity.distance(p.humidity))+vt(this.continentalness.distance(p.continentalness))+vt(this.erosion.distance(p.erosion))+vt(this.depth.distance(p.depth))+vt(this.weirdness.distance(p.weirdness))+vt(this.offset-p.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new i(this.offset,this.offset)]}static fromJson(p){let g=M.readObject(p)??{};return new o(i.fromJson(g.temperature),i.fromJson(g.humidity),i.fromJson(g.continentalness),i.fromJson(g.erosion),i.fromJson(g.depth),i.fromJson(g.weirdness),M.readNumber(g.offset)??0)}}e.ParamPoint=o;class a{temperature;humidity;continentalness;erosion;depth;weirdness;constructor(p,g,w,x,v,y){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}e.TargetPoint=a;class l{things;index;constructor(p){this.things=p,this.index=new u(p)}find(p){return this.index.search(p,(g,w)=>g.distance(w))}}e.Parameters=l;class c{temperature;humidity;continentalness;erosion;depth;weirdness;constructor(p,g,w,x,v,y){this.temperature=p,this.humidity=g,this.continentalness=w,this.erosion=x,this.depth=v,this.weirdness=y}static fromRouter(p){return new e.Sampler(p.temperature,p.vegetation,p.continents,p.erosion,p.depth,p.ridges)}sample(p,g,w){let x=j.context(p<<2,g<<2,w<<2);return e.target(this.temperature.compute(x),this.humidity.compute(x),this.continentalness.compute(x),this.erosion.compute(x),this.depth.compute(x),this.weirdness.compute(x))}}e.Sampler=c;class u{static CHILDREN_PER_NODE=10;root;last_leaf=null;constructor(p){if(p.length===0)throw new Error("At least one point is required to build search tree");this.root=u.build(p.map(([g,w])=>new f(g,w)))}static build(p){if(p.length===1)return p[0];if(p.length<=u.CHILDREN_PER_NODE){let v=p.map(y=>{let I=0;for(let b=0;b<7;b+=1){let k=y.space[b];I+=Math.abs((k.min+k.max)/2)}return{key:I,node:y}}).sort((y,I)=>y.key-I.key).map(({node:y})=>y);return new d(v)}let g=1/0,w=-1,x=[];for(let v=0;v<7;++v){p=u.sort(p,v,!1),x=u.bucketize(p);let y=0;for(let I of x)y+=u.area(I.space);g>y&&(g=y,w=v)}return p=u.sort(p,w,!1),x=u.bucketize(p),x=u.sort(x,w,!0),new d(x.map(v=>u.build(v.children)))}static sort(p,g,w){return p.map(x=>{let v=x.space[g],y=(v.min+v.max)/2;return{key:w?Math.abs(y):y,node:x}}).sort((x,v)=>x.key-v.key).map(({node:x})=>x)}static bucketize(p){let g=[],w=[],x=Math.pow(10,Math.floor(Math.log(p.length-.01)/Math.log(10)));for(let v of p)w.push(v),!(w.lengthnew i(1/0,-1/0));for(let w of p)g=[...Array(7)].map((x,v)=>g[v].union(w.space[v]));return g}search(p,g,w){let x=g?w(g,p):1/0,v=g;for(let y of this.children){let I=w(y,p);if(x<=I)continue;let b=y.search(p,v,w);if(b===null)continue;let k=y==b?I:w(b,p);if(k===0)return b;x<=k||(x=k,v=b)}return v}}e.RSubTree=d;class f extends h{thing;constructor(p,g){super(p.space()),this.thing=g}search(){return this}}e.RLeaf=f})(St=St||(St={}));var Qi=class e{parameters;constructor(t){this.parameters=new St.Parameters(t)}getBiome(t,r,n,s){let i=s.sample(t,r,n);return this.parameters.find(i)}static fromJson(t){let r=M.readObject(t)??{},s=(M.readArray(r.biomes,i=>(o=>({biome:R.parse(M.readString(o.biome)??"plains"),parameters:St.ParamPoint.fromJson(o.parameters)}))(M.readObject(i)??{}))??[]).map(i=>[i.parameters,()=>i.biome]);return new e(s)}};var es=class e{static END=R.create("the_end");static HIGHLANDS=R.create("end_highlands");static MIDLANDS=R.create("end_midlands");static ISLANDS=R.create("small_end_islands");static BARRENS=R.create("end_barrens");getBiome(t,r,n,s){let i=t<<2,o=r<<2,a=n<<2,l=i>>4,c=a>>4;if(l*l+c*c<=4096)return e.END;let u=j.context((l*2+1)*8,o,(c*2+1)*8),h=s.erosion.compute(u);return h>.25?e.HIGHLANDS:h>=-.0625?e.MIDLANDS:h>=-.21875?e.BARRENS:e.ISLANDS}static fromJson(t){return new e}};var Fr;(function(e){function t(n){let s=M.readObject(n)??{};switch(M.readString(s.type)?.replace(/^minecraft:/,"")){case"fixed":return Kt.fromJson(n);case"checkerboard":return Ki.fromJson(n);case"multi_noise":return Qi.fromJson(n);case"the_end":return es.fromJson(n);default:return new Kt(R.create("plains"))}}e.fromJson=t;function r(n,s,i,o,a,l,c,u,h=1,d=!1){if(n instanceof Kt)return l(n.getBiome())?d?{pos:te.create(s,i,o),biome:n.getBiome()}:{pos:te.create(s-a+c.nextInt(a*2+1),i,o-a+c.nextInt(a*2+1)),biome:n.getBiome()}:void 0;let f=s>>2,m=o>>2,p=a>>2,g=i>>2;for(var w=void 0,x=0,v=d?0:p,y=v;y<=p;y+=h)for(var I=-y;I<=y;I+=h){let k=Math.abs(I)===y;for(var b=-y;b<=y;b+=h){if(d&&!(Math.abs(b)===y)&&!k)continue;let E=f+b,A=m+I,N=n.getBiome(E,g,A,u);if(l(N)){if((w===void 0||c.nextInt(x+1)<=.5)&&(w={pos:te.create(E<<2,i,A<<2),biome:N},d))return w;x++}}}return w}e.findBiomeHorizontal=r})(Fr=Fr||(Fr={}));var ri;(function(e){function t(r){if(typeof r=="string"&&(r==="WORLD_SURFACE_WG"||r==="WORLD_SURFACE"||r==="OCEAN_FLOOR_WG"||r==="OCEAN_FLOOR"||r==="MOTION_BLOCKING"||r==="MOTION_BLOCKING_NO_LEAVES"))return r}e.fromJson=t})(ri=ri||(ri={}));var ni;(function(e){function t(l){let c=M.readObject(l)??{};switch(M.readString(c.type)?.replace(/^minecraft:/,"")){case void 0:return r(Ge.fromJson(l));case"constant":return r(Ge.fromJson(c.value));case"uniform":return n(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive));case"biased_to_bottom":return s(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.inner));case"very_biased_to_bottom":return i(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.inner));case"trapezoid":return o(Ge.fromJson(c.min_inclusive),Ge.fromJson(c.max_inclusive),M.readInt(c.plateau));case"weighted_list":return a(M.readArray(c.distribution,h=>{let d=M.readObject(h)??{};return{weight:M.readInt(d.weight)??1,data:t(d.data)}})??[])}return()=>0}e.fromJson=t;function r(l){return(c,u)=>l(u)}e.constant=r;function n(l,c){return(u,h)=>{let d=l(h),f=c(h);return d>f?d:u.nextInt(f-d+1)+d}}e.uniform=n;function s(l,c,u=1){return(h,d)=>{let f=l(d),m=c(d);if(m-f-u+1<=0)return f;{let p=h.nextInt(m-f-u+1);return h.nextInt(p+u)+f}}}e.biased_to_bottom=s;function i(l,c,u=1){return(h,d)=>{let f=l(d),m=c(d);if(m-f-u+1<=0)return f;{let p=Di(h,f+u,m),g=Di(h,f,p-1);return Di(h,f,g-1+u)}}}e.very_biased_to_bottom=i;function o(l,c,u=0){return(h,d)=>{let f=l(d),m=c(d);if(f>m)return f;{let p=m-f;if(u>=p)return $i(h,f,m);{let g=(p-u)/2,w=p-g;return f+$i(h,0,w)+$i(h,0,g)}}}}e.trapezoid=o;function a(l){let c=l.reduce((u,h,d)=>u+h.weight,0);return(u,h)=>{let d=u.nextInt(c);for(let f of l)if(d-=f.weight,d<=0)return f.data(u,h);return 0}}e.weighted_list=a})(ni=ni||(ni={}));var $r=class{randomState;settings;globalFluidPicker;volume;aquifer;constructor(t,r,n,s){if(this.randomState=t,this.settings=r,this.globalFluidPicker=n,this.volume=s,!r.aquifers)this.aquifer=ti.createDisabled(n);else{let i=this.randomState.getOrCreateRandom(R.create("aquifer"));this.aquifer=new Vi(r.aquifers,i,s,n)}}};var ii=class{biomeSource;settings;globalFluidPicker;constructor(t,r){this.biomeSource=t,this.settings=r;let n=new mn(-54,se.LAVA),s=new mn(r.seaLevel,r.defaultFluid);this.globalFluidPicker=(i,o,a)=>o!o.equals(se.AIR)&&!o.isFluid():i=o=>!o.equals(se.AIR),this.iterateNoiseColumn(s,t,r,void 0,i)??this.settings.noise.minY}iterateNoiseColumn(t,r,n,s,i){if(this.settings.noise.height<=0)return;let o=new Mt(1,this.settings.noise.height,1,r,this.settings.noise.minY,n),a=new $r(t,this.settings,this.globalFluidPicker,o),c=t.router.finalDensity.computeVolume(o);for(let u=o.sizeY-1;u>=0;u-=1){let h=c[o.indexUnchecked(0,u,0)],d=o.blockY(u),f=a.aquifer.computeSubstance(r,d,n,h)??this.settings.defaultBlock;if(s!==void 0&&(s[u]=f),i!==void 0&&i(f))return d+1}}buildTerrain(t,r,n,s){let i=this.createNoiseChunk(t,r,n);this.doFill(r,i),this.buildSurface(r,i,s)}doFill(t,r){let n=r.volume,i=r.randomState.router.finalDensity.computeVolume(n);for(let o=0;o=0;u-=1){let h=n.blockY(u),d=t.getOrCreateSection(t.getSectionIndex(h)),f=i[n.indexUnchecked(l,u,o)],m=r.aquifer.computeSubstance(c,h,a,f)??this.settings.defaultBlock;d.setBlockState(l,h&15,o,m)}}}}buildSurface(t,r,n){let s=n??R.create("plains"),i={minY:this.settings.noise.minY,height:this.settings.noise.height,seaLevel:this.settings.seaLevel};r.randomState.surfaceSystem.buildSurface(t,r,this.settings.materialRule,i,()=>s)}computeBiome(t,r,n,s){return this.biomeSource.getBiome(r,n,s,t.sampler)}createNoiseChunk(t,r,n){let s=new Mt(16,this.settings.noise.height,n?1:16,Je.minBlockX(r.pos),this.settings.noise.minY,Je.minBlockZ(r.pos));return new $r(t,this.settings,this.globalFluidPicker,s)}getWorldgenContext(){return{minY:this.settings.noise.minY,height:this.settings.noise.height,seaLevel:this.settings.seaLevel}}};var Qt=class{seed;noiseInstances;positionalRandoms;random;surfaceSystem;router;sampler;constructor(t,r){this.seed=r,this.noiseInstances=new Map,this.positionalRandoms=new Map,this.random=(t.legacyRandomSource?new Oe(r):an.create(r)).forkPositional(),this.router=$t.mapAll(t.noiseRouter,this.createVisitor(t.legacyRandomSource));let n=this.router.chunkSurfaceLevel;this.surfaceSystem=new Xi(this,t.defaultBlock,t.seaLevel,n,this.random),this.sampler=St.Sampler.fromRouter(this.router)}createVisitor(t){let r=new Map,n=i=>{let o=i.key();if(o===void 0)throw new Error("Cannot create noise without key");if(t){if(o.equals(R.create("temperature")))return i.value().createForLegacyNetherBiome(new Oe(this.seed+BigInt(0)));if(o.equals(R.create("vegetation")))return i.value().createForLegacyNetherBiome(new Oe(this.seed+BigInt(1)))}return this.getOrCreateNoise(o)},s={apply:i=>{if(i instanceof j.HolderHolder){let o=i.holder.key();if(o!==void 0&&r.has(o.toString()))return r.get(o.toString());{let a=i.holder.value().mapAll(s);return o!==void 0&&r.set(o.toString(),a),a}}if(i instanceof j.NoiseFunction)return new j.NoiseFunction(i.noise,i.xzScale,i.yScale,i.shiftX,i.shiftY,i.shiftZ,n(i.noise));if(i instanceof j.ShiftNoise)return i.withNewNoise(n(i.noise));if(i instanceof j.OldBlendedNoise){let o=t?new Oe(this.seed+BigInt(0)):this.random.fromHashOf(R.create("terrain").toString());return new j.OldBlendedNoise(i.xzScale,i.yScale,i.xzFactor,i.yFactor,i.smearScaleMultiplier,new ji(o,i.xzScale,i.yScale,i.xzFactor,i.yFactor,i.smearScaleMultiplier))}return i instanceof j.EndOuterIslands?new j.EndOuterIslands(this.seed):i instanceof j.Binary?i.trySimplify():i}};return s}getOrCreateNoise(t){let r=$e.REGISTRY.getOrThrow(R.create("worldgen/noise"));return Et(this.noiseInstances,t.toString(),n=>r.getOrThrow(t).create(this.random.fromHashOf(n)))}getOrCreateRandom(t){return Et(this.positionalRandoms,t.toString(),r=>this.random.fromHashOf(r).forkPositional())}};var er=class e{static fromJson(t){let r=M.readObject(t)??{};switch(M.readString(r.element_type)?.replace(/^minecraft:/,"")){case"single_pool_element":case"legacy_single_pool_element":let n=R.parse(M.readString(r.location)??""),s={key:()=>n,value:()=>zr.REGISTRY.get(n)??zr.EMPTY};return new e.SinlgePoolElement(s);case"list_pool_element":let i=M.readArray("elements",e.fromJson)??[];return new e.ListPoolElement(i);case"feature_pool_element":return new e.FeaturePoolElement;default:return new e.EmptyPoolElement}}};(function(e){class t extends e{getBoundingBox(o,a){throw new Error("Invalid call of EmptyPoolElement")}getShuffledJigsawBlocks(o,a){return[]}toString(){return"[Empty Pool Element]"}}e.EmptyPoolElement=t;class r extends e{defaultJigsawNBT;constructor(){super();let o=new Map;o.set("name",new We("minecraft:bottom")),o.set("final_state",new We("minecraft:air")),o.set("pool",new We("minecraft:empty")),o.set("target",new We("minecraft:empty")),o.set("joint",new We("rollable")),this.defaultJigsawNBT=new Re(o)}getBoundingBox(o,a){return[o,o]}getShuffledJigsawBlocks(o,a){return[{pos:[0,0,0],state:new se(R.create("jigsaw"),{orientation:"down_south"}),nbt:this.defaultJigsawNBT}]}toString(){return"[Feature Pool Element]"}}e.FeaturePoolElement=r;class n extends e{template;static JIGSAW_ID=R.parse("jigsaw");constructor(o){super(),this.template=o}getBoundingBox(o,a){let l=te.offset(this.template.value().getSize(),-1,-1,-1),c=o,u=te.add(zr.transform(l,a,te.ZERO),o),h=te.create(Math.min(c[0],u[0]),c[1],Math.min(c[2],u[2])),d=te.create(Math.max(c[0],u[0]),u[1],Math.max(c[2],u[2]));return[h,d]}getShuffledJigsawBlocks(o,a){let l=this.template.value().getBlocks().filter(c=>c.state.getName().equals(n.JIGSAW_ID));return l.forEach(c=>c.pos=zr.transform(c.pos,o,te.ZERO)),Xc(l,a),l}toString(){return`[Single Pool Element: ${this.template.key()}]`}}e.SinlgePoolElement=n;class s extends e{elements;constructor(o){super(),this.elements=o}getBoundingBox(o,a){var l=void 0,c=void 0;for(let u of this.elements){let h=u.getBoundingBox(o,a);!l||!c?(l=h[0],c=h[1]):(l[0]=Math.min(l[0],h[0][0]),l[1]=Math.min(l[1],h[0][1]),l[2]=Math.min(l[2],h[0][2]),c[0]=Math.min(l[0],h[1][0]),c[1]=Math.min(l[1],h[1][1]),c[2]=Math.min(l[2],h[1][2]))}return[l,c]}getShuffledJigsawBlocks(o,a){return this.elements[0].getShuffledJigsawBlocks(o,a)}toString(){return`[List Pool Element: ${"; ".concat(...this.elements.map(o=>o.toString()))}]`}}e.ListPoolElement=s})(er=er||(er={}));var si=class e{rawTemplates;fallback;static REGISTRY=$e.createAndRegister("worldgen/template_pool",e.fromJson);totalWeight;constructor(t,r){this.rawTemplates=t,this.fallback=r,this.totalWeight=t.reduce((n,s)=>n+s.weight,0)}static structurePoolParser=he.parser(e.REGISTRY,e.fromJson);static fromJson(t){let r=M.readObject(t)??{},n=e.structurePoolParser(r.fallback??""),s=M.readArray(r.elements,i=>{let o=M.readObject(i)??{},a=er.fromJson(o.element),l=M.readInt(o.weight)??1;return{element:a,weight:l}})??[];return new e(s,n)}getRandomTemplate(t){var r=t.nextInt(this.totalWeight);for(let n of this.rawTemplates)if(r-=n.weight,r<0)return n.element;return this.rawTemplates[this.rawTemplates.length-1].element}};var Dr=class{settings;constructor(t){this.settings=t}onTopOfChunkCenter(t,r,n,s="WORLD_SURFACE_WG"){let i=(r<<4)+8,o=(n<<4)+8;return[i,t.chunkGenerator.getBaseHeight(i,o,s,t.randomState)-1,o]}getLowestY(t,r,n,s,i){return Math.min(t.chunkGenerator.getBaseHeight(r,n,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r,n+i,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r+s,n,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(r+s,n+i,"WORLD_SURFACE_WG",t.randomState)-1)}getLowestYIn5by5BoxOffset7Blocks(t,r,n,s){let i=5,o=5;s===He.CLOCKWISE_90?i=-5:s===He.CLOCKWISE_180?(i=-5,o=-5):s===He.COUNTERCLOCKWISE_90&&(o=-5);let a=(r<<4)+7,l=(n<<4)+7;return te.create(a,this.getLowestY(t,a,l,i,o),l)}tryGenerate(t,r,n){let s=Oe.fromLargeFeatureSeed(n.seed,t,r),i=this.findGenerationPoint(t,r,s,n);if(i===void 0)return;let o=n.biomeSource.getBiome(i[0]>>2,i[1]>>2,i[2]>>2,n.randomState.sampler);return[...this.settings.validBiomes.getEntries()].findIndex(a=>a.key()?.equals(o))>=0?i:void 0}};(function(e){e.REGISTRY=$e.createAndRegister("worldgen/structure",n);class t{validBiomes;constructor(b){this.validBiomes=b}}e.StructureSettings=t;let r=he.parser(si.REGISTRY,si.fromJson);function n(I){let b=Lt.parser(xe.BIOME),k=M.readObject(I)??{},E=b(k.biomes),A=new t(E.value());switch(M.readString(k.type)?.replace(/^minecraft:/,"")){case"buried_treasure":return new i(A);case"desert_pyramid":return new a(A);case"end_city":return new l(A);case"fortress":return new c(A);case"igloo":return new u(A);case"jigsaw":let N=ni.fromJson(k.start_height),z=r(k.start_pool),F=M.readString(k.start_jigsaw_name),Y=F?R.parse(F):void 0,$=ri.fromJson(k.project_start_to_heightmap),V=s.DimensionPadding.fromJson(k.dimension_padding);return new s(A,z,N,$,Y,V);case"jungle_temple":return new h(A);case"mineshaft":let ce=M.readString(k.mineshaft_type)==="mesa"?"mesa":"normal";return new d(A,ce);case"nether_fossil":return new c(A);case"ocean_monument":return new m(A);case"ocean_ruin":return new p(A);case"ruined_portal":return new g(A);case"shipwreck":let oe=M.readBoolean(k.is_beached)??!1;return new w(A,oe);case"stronghold":return new x(A);case"swamp_hut":return new v(A);case"woodland_mansion":return new y(A)}return new i(A)}e.fromJson=n;class s extends e{startingPoolHolder;startHeight;projectStartToHeightmap;startJigsawName;dimensionPadding;constructor(b,k,E,A,N,z){super(b),this.startingPoolHolder=k,this.startHeight=E,this.projectStartToHeightmap=A,this.startJigsawName=N,this.dimensionPadding=z}findGenerationPoint(b,k,E,A){let N=this.startHeight(E,A.chunkGenerator.getWorldgenContext()),z=te.create(b<<4,N,k<<4),F=He.getRandom(E),$=this.startingPoolHolder.value().getRandomTemplate(E);if(!($ instanceof er.EmptyPoolElement)){let V;if(this.startJigsawName){let ee=s.getRandomNamedJigsaw($,this.startJigsawName,F,E);if(ee===void 0)return;V=ee}else V=te.ZERO;let ce=te.subtract(z,V),oe=$.getBoundingBox(ce,F),T=(oe[1][0]+oe[0][0])/2^0,B=(oe[1][2]+oe[0][2])/2^0,D;return this.projectStartToHeightmap?D=z[1]+A.chunkGenerator.getBaseHeight(T,B,this.projectStartToHeightmap,A.randomState):D=ce[1],oe.forEach(ee=>ee[1]+=D-oe[0][1]-1),s.isStartTooCloseToWorldHeightLimits(this.dimensionPadding,oe,A.levelHeight)?void 0:te.create(T,D+V[1],B)}}static isStartTooCloseToWorldHeightLimits(b,k,E){if(b===s.DimensionPadding.ZERO)return!1;let A=E.minY+b.bottom,N=E.minY+E.height-b.top;return k[0][1]N}static getRandomNamedJigsaw(b,k,E,A){let N=b.getShuffledJigsawBlocks(E,A);for(let z of N)if(R.parse(z.nbt?.getString("name")??"minecraft:empty").equals(k))return z.pos}}e.JigsawStructure=s,(function(I){class b{top;bottom;static ZERO=new b(0,0);constructor(E,A){this.top=E,this.bottom=A}static fromJson(E){if(E===void 0)return b.ZERO;if(typeof E=="number")return new b(E,E);let A=M.readObject(E)??{};return new b(M.readInt(A.top)??0,M.readInt(A.bottom)??0)}}I.DimensionPadding=b})(s=e.JigsawStructure||(e.JigsawStructure={}));class i extends e{findGenerationPoint(b,k,E,A){return this.onTopOfChunkCenter(A,b,k,"OCEAN_FLOOR_WG")}}e.BuriedTreasureStructure=i;class o extends e{width;depth;constructor(b,k,E){super(b),this.width=k,this.depth=E}findGenerationPoint(b,k,E,A){if(!(this.getLowestY(A,b<<4,k<<4,this.width,this.depth)a+l.weight,0);for(;i.length>0;){let a=s.nextInt(o),l,c;for([l,c]of i.entries())if(a-=c.weight,a<0)break;let u=c.structure.value().tryGenerate(t,r,n);if(u!==void 0)return{id:c.structure.key(),pos:u};i.splice(l,1),o-=c.weight}}}};(function(e){class t{structure;weight;constructor(n,s){this.structure=n,this.weight=s}static fromJson(n){let s=M.readObject(n)??{};return new t(he.reference(Dr.REGISTRY,R.parse(M.readString(s.structure)??"minecraft:empty")),M.readInt(s.weight)??1)}}e.StructureSelectionEntry=t})(qr=qr||(qr={}));var Yr=class e{locateOffset;frequencyReductionMethod;frequency;salt;exclusionZone;constructor(t,r,n,s,i){this.locateOffset=t,this.frequencyReductionMethod=r,this.frequency=n,this.salt=s,this.exclusionZone=i}static fromJson(t){let r=M.readObject(t)??{},n=M.readString(r.type)?.replace(/^minecraft:/,""),s=te.fromJson(r.locate_offset),i=e.FrequencyReducer.fromType(M.readString(r.frequency_reduction_method)??"default"),o=M.readNumber(r.frequency)??1,a=M.readInt(r.salt)??0,l="exclusion_zone"in r?e.ExclusionZone.fromJson(r.exclusion_zone):void 0;switch(n){case"random_spread":let c=M.readInt(r.spacing)??1,u=M.readInt(r.separation)??1,h=e.SpreadType.fromJson(r.spread_type);return new e.RandomSpreadStructurePlacement(s,i,o,a,l,c,u,h);case"concentric_rings":let d=M.readInt(r.distance)??1,f=M.readInt(r.spread)??1,m=M.readInt(r.count)??1,p=Lt.parser(xe.BIOME)(r.preferred_biomes);return new e.ConcentricRingsStructurePlacement(s,i,o,a,l,d,f,m,p)}return new e.RandomSpreadStructurePlacement([0,0,0],e.FrequencyReducer.ProbabilityReducer,1,0,void 0,1,1,"linear")}isStructureChunk(t,r,n){return this.isPlacementChunk(t,r,n)?this.frequency<1&&!this.frequencyReductionMethod(t,this.salt,r,n,this.frequency)?!1:!(this.exclusionZone&&this.exclusionZone.isPlacementForbidden(t,r,n)):!1}prepare(t,r,n){}};(function(e){let t;(function(a){function l(f){switch(f){case"legacy_type_1":return d;case"legacy_type_2":return h;case"legacy_type_3":return u;default:return c}}a.fromType=l;function c(f,m,p,g,w){return Oe.fromLargeFeatureWithSalt(f,m,p,g).nextFloat()>4,v=g>>4,y=new Oe(BigInt(x^v<<4)^f);return y.nextInt(),y.nextInt(Math.floor(1/w))===0}a.LegacyPillagerOutpostReducer=d})(t=e.FrequencyReducer||(e.FrequencyReducer={}));class r{otherSet;chunkCount;constructor(l,c){this.otherSet=l,this.chunkCount=c}static fromJson(l){let c=M.readObject(l)??{};return new r(he.reference(qr.REGISTRY,R.parse(M.readString(c.other_set)??"")),M.readInt(c.chunk_count)??1)}isPlacementForbidden(l,c,u){let h=this.otherSet.value().placement;return h.getPotentialStructureChunks(l,c-this.chunkCount,u-this.chunkCount,c+this.chunkCount,u+this.chunkCount).findIndex(d=>Math.abs(d[0]-c)<=this.chunkCount&&Math.abs(d[1]-u)<=this.chunkCount&&h.isStructureChunk(l,d[0],d[1]))>=0}}e.ExclusionZone=r;let n;(function(a){function l(c){return(M.readString(c)??"linear")==="triangular"?"triangular":"linear"}a.fromJson=l})(n=e.SpreadType||(e.SpreadType={}));class s extends e{spacing;separation;spreadType;constructor(l,c,u,h,d,f,m,p){super(l,c,u,h,d),this.spacing=f,this.separation=m,this.spreadType=p}evaluateSpread(l,c){switch(this.spreadType){case"linear":return l.nextInt(c);case"triangular":return Math.floor((l.nextInt(c)+l.nextInt(c))/2)}}getPotentialStructureChunk(l,c,u){let h=Math.floor(c/this.spacing),d=Math.floor(u/this.spacing),f=Oe.fromLargeFeatureWithSalt(l,h,d,this.salt),m=this.spacing-this.separation,p=this.evaluateSpread(f,m),g=this.evaluateSpread(f,m);return[h*this.spacing+p,d*this.spacing+g]}isPlacementChunk(l,c,u){let[h,d]=this.getPotentialStructureChunk(l,c,u);return h===c&&d===u}getPotentialStructureChunks(l,c,u,h,d){let f=[];for(let m=Math.floor(c/this.spacing)*this.spacing;m<=h;m+=this.spacing)for(let p=Math.floor(u/this.spacing)*this.spacing;p<=d;p+=this.spacing)f.push(this.getPotentialStructureChunk(l,m,p));return f}}e.RandomSpreadStructurePlacement=s;let i=112;class o extends e{distance;spread;count;preferredBiomes;positions;constructor(l,c,u,h,d,f,m,p,g){super(l,c,u,h,d),this.distance=f,this.spread=m,this.count=p,this.preferredBiomes=g}prepare(l,c,u){if(this.positions!==void 0||(this.positions=[],this.count===0))return;let h=new Oe(u);var d=h.nextDouble()*Math.PI*2,f=this.spread,m=0,p=0;let g=[...this.preferredBiomes.value().getEntries()].flatMap(x=>x.key()??[]);for(var w=0;w{let A=Fr.findBiomeHorizontal(l,I,0,b,i,N=>g.findIndex(z=>z.equals(N))>=0,k,c);return A?[A.pos[0]>>4,A.pos[2]>>4]:[v,y]};this.positions.push({center:[v,y],real:E}),d+=Math.PI*2/f,p++,p==f&&(m++,p=0,f+=2*f/(m+1),f=Math.min(f,this.count-w),d+=h.nextDouble()*Math.PI*2)}}isPlacementChunk(l,c,u){return this.positions===void 0?(console.warn("trying to access concentric rings placement before position calculation"),!1):this.getPotentialStructureChunks(l,c,u,c,u).findIndex(h=>h[0]===c&&h[1]===u)>=0}getPotentialStructureChunks(l,c,u,h,d){if(this.positions===void 0)return console.warn("trying to access concentric rings placement before position calculation"),[];let f=[];for(let m of this.positions)m.center[0]>4)||m.center[0]>h+(i>>4)||m.center[1]>4)||m.center[1]>d+(i>>4)||(m.real instanceof Function&&(m.real=m.real()),f.push(m.real));return f}}e.ConcentricRingsStructurePlacement=o})(Yr=Yr||(Yr={}));var oi=[186,218,247],ai=[30,30,36],No=[62,58,66],ts={air:oi,cave_air:[120,120,130],void_air:ai,stone:[125,125,125],deepslate:[80,80,86],cobblestone:[116,116,116],cobbled_deepslate:[76,76,80],bedrock:[55,55,55],tuff:[108,109,102],calcite:[223,224,220],granite:[149,103,85],diorite:[188,188,188],andesite:[136,136,136],dirt:[134,96,67],coarse_dirt:[119,85,59],rooted_dirt:[144,103,76],grass_block:[109,153,48],podzol:[91,63,24],mycelium:[111,99,105],mud:[60,57,60],moss_block:[89,109,45],sand:[219,207,163],sandstone:[216,203,155],red_sand:[190,102,33],red_sandstone:[186,99,29],gravel:[131,127,126],clay:[160,166,179],snow:[249,254,254],snow_block:[249,254,254],powder_snow:[248,253,253],ice:[145,183,253],packed_ice:[141,180,250],blue_ice:[116,167,253],water:[52,104,196],lava:[207,92,15],obsidian:[15,10,24],netherrack:[97,38,38],soul_sand:[81,62,50],soul_soil:[75,57,46],basalt:[80,81,86],blackstone:[42,36,41],crimson_nylium:[130,31,31],warped_nylium:[43,114,101],nether_wart_block:[114,2,2],warped_wart_block:[22,119,121],end_stone:[219,222,158],terracotta:[152,94,67],white_terracotta:[209,178,161],orange_terracotta:[161,83,37],yellow_terracotta:[186,133,35],brown_terracotta:[77,51,35],red_terracotta:[143,61,46],light_gray_terracotta:[135,106,97],honey_block:[251,185,52],slime_block:[111,192,91],magma_block:[142,63,31],glowstone:[171,131,84],prismarine:[99,156,151],dripstone_block:[134,107,92],sculk:[12,29,36],amethyst_block:[133,97,191]},w2={the_void:[0,0,0],plains:[141,179,96],sunflower_plains:[181,219,136],snowy_plains:[255,255,255],ice_spikes:[180,220,220],desert:[250,148,24],swamp:[7,249,178],mangrove_swamp:[44,204,142],forest:[5,102,33],flower_forest:[45,142,73],birch_forest:[48,116,68],dark_forest:[64,81,26],pale_garden:[178,184,178],old_growth_birch_forest:[88,156,108],old_growth_pine_taiga:[89,102,81],old_growth_spruce_taiga:[129,142,121],taiga:[11,102,89],snowy_taiga:[49,85,74],savanna:[189,178,95],savanna_plateau:[167,157,100],windswept_hills:[96,96,96],windswept_gravelly_hills:[136,136,136],windswept_forest:[80,112,80],windswept_savanna:[229,218,135],jungle:[83,123,9],sparse_jungle:[98,139,23],bamboo_jungle:[118,142,20],badlands:[217,69,21],eroded_badlands:[255,109,61],wooded_badlands:[176,151,101],meadow:[96,164,69],cherry_grove:[255,145,200],grove:[71,114,108],snowy_slopes:[196,196,196],frozen_peaks:[160,160,160],jagged_peaks:[220,220,200],stony_peaks:[123,143,116],river:[0,0,255],frozen_river:[160,160,255],beach:[250,222,85],snowy_beach:[250,240,192],stony_shore:[162,162,132],warm_ocean:[0,0,172],lukewarm_ocean:[0,0,144],deep_lukewarm_ocean:[0,0,64],ocean:[0,0,112],deep_ocean:[0,0,48],cold_ocean:[32,32,112],deep_cold_ocean:[32,32,56],frozen_ocean:[112,112,214],deep_frozen_ocean:[64,64,144],mushroom_fields:[255,0,255],dripstone_caves:[134,96,67],lush_caves:[0,255,0],deep_dark:[3,31,41],nether_wastes:[191,59,59],warped_forest:[73,144,123],crimson_forest:[221,8,8],soul_sand_valley:[94,56,48],basalt_deltas:[64,54,54],the_end:[128,128,255],end_highlands:[181,181,54],end_midlands:[255,255,153],small_end_islands:[144,144,223],end_barrens:[112,112,204]};function hu(e,t){let r=2166136261;for(let l=0;l>>0)%360/360,s=.55,i=t<.5?t*(1+s):t+s-t*s,o=2*t-i,a=l=>{l=(l+1)%1;let c=l<1/6?o+(i-o)*6*l:l<1/2?i:l<2/3?o+(i-o)*(2/3-l)*6:o;return Math.round(c*255)};return[a(n+1/3),a(n),a(n-1/3)]}function du(e){let t=e.indexOf(":");return t<0?e:e.slice(0,t)==="minecraft"?e.slice(t+1):null}function rs(e){let t=du(e);if(t!==null){let r=ts[t];if(r)return r;if(t.endsWith("_ore"))return t.startsWith("deepslate")?ts.deepslate:ts.stone;if(t.includes("terracotta"))return ts.terracotta}return hu(e,.55)}function Ro(e){let t=du(e);return t!==null&&w2[t]||hu(e,.5)}var mu=1<<18;function To(e,t,r){return((e+1048576)*2097152+(r+1048576))*2048+(t+1024)}function Jr(e,t,r){return e===0?t:t+e*(r-t)}var zo=class e extends j{constructor(r,n,s){super();this.input=r;this.cellSizeXz=n;this.cellSizeY=s}input;cellSizeXz;cellSizeY;corners=new Map;corner(r,n,s){let i=To(r,n,s),o=this.corners.get(i);if(o===void 0){this.corners.size>=mu&&this.corners.clear();let a=this.cellSizeXz;o=this.input.compute(j.context(r*a,n*this.cellSizeY,s*a)),this.corners.set(i,o)}return o}cell=NaN;c000=0;c100=0;c010=0;c110=0;c001=0;c101=0;c011=0;c111=0;compute({x:r,y:n,z:s}){let i=this.cellSizeXz,o=this.cellSizeY,a=Math.floor(r/i),l=Math.floor(n/o),c=Math.floor(s/i),u=To(a,l,c);u!==this.cell&&(this.cell=u,this.c000=this.corner(a,l,c),this.c100=this.corner(a+1,l,c),this.c010=this.corner(a,l+1,c),this.c110=this.corner(a+1,l+1,c),this.c001=this.corner(a,l,c+1),this.c101=this.corner(a+1,l,c+1),this.c011=this.corner(a,l+1,c+1),this.c111=this.corner(a+1,l+1,c+1));let h=(r-a*i)/i,d=(n-l*o)/o,f=(s-c*i)/i,m=Jr(d,Jr(h,this.c000,this.c100),Jr(h,this.c010,this.c110));return f===0?m:Jr(f,m,Jr(d,Jr(h,this.c001,this.c101),Jr(h,this.c011,this.c111)))}mapChildren(r){return new e(r.apply(this.input),this.cellSizeXz,this.cellSizeY)}range(){return this.input.range()}},Po=class e extends j{constructor(r){super();this.input=r}input;values=new Map;compute(r){if(!Number.isInteger(r.x)||!Number.isInteger(r.z))return this.input.compute(r);let n=To(r.x,0,r.z),s=this.values.get(n);return s===void 0&&(this.values.size>=mu&&this.values.clear(),s=this.input.compute(r),this.values.set(n,s)),s}mapChildren(r){return new e(r.apply(this.input))}range(){return this.input.range()}},Oo=class e extends j{constructor(r){super();this.input=r}input;x=NaN;y=NaN;z=NaN;value=0;compute(r){return(r.x!==this.x||r.y!==this.y||r.z!==this.z)&&(this.value=this.input.compute(r),this.x=r.x,this.y=r.y,this.z=r.z),this.value}mapChildren(r){return new e(r.apply(this.input))}range(){return this.input.range()}};function Bo(e,t){let r=t.get(e);if(r!==void 0)return r;let n;if(e instanceof j.Constant)n=!1;else if(e instanceof j.Gradient)n=e.axis==="y";else if(e instanceof j.ShiftA||e instanceof j.ShiftB)n=!1;else if(e instanceof j.NoiseFunction)n=e.yScale!==0||[e.shiftX,e.shiftY,e.shiftZ].some(s=>Bo(s,t));else if(e instanceof j.EndOuterIslands)n=!1;else{let s=[];e.mapChildren({apply:o=>(s.push(o),o)});let i=[j.HolderHolder].some(o=>e instanceof o);n=s.length===0||i?!0:s.some(o=>Bo(o,t))}return t.set(e,n),n}function ns(e){let t=new WeakMap,r={apply(n){return n instanceof j.Interpolated?new zo(n.input,n.cellSizeXz,n.cellSizeY):n instanceof j.Cache?Bo(n.input,t)?new Oo(n.input):new Po(n.input):n}};return e.router=$t.mapAll(e.router,r),e}var Uo={noise:xe.NOISE,density_function:xe.DENSITY_FUNCTION,noise_settings:xe.NOISE_SETTINGS,material_rule:xe.MATERIAL_RULE,material_condition:xe.MATERIAL_CONDITION},pu=xe.BIOME;pu.get=pu.getOrThrow=()=>({});var Su=xe.BIOME.getTagRegistry(),ku=[],Iu=new Map,us=0,qo=0,gu="";function x2(e){let t=e.filter(r=>["noise","density_function","noise_settings","dimension"].includes(r.kind));return JSON.stringify(t,(r,n)=>r==="surface_rule"?void 0:n)}var yn=new Map;async function v2(e){if(!yn.has(e)){let t=null;try{let r=e.startsWith("tag/")?`tag/${e.slice(4)}`:`worldgen/${e}`,n=await fetch(`${gi}/${r}/data.min.json`);n.ok&&(t=await n.json())}catch{t=null}yn.set(e,t)}return yn.get(e)!=null}function wu(e,t,r){if(e==="tag/worldgen/biome"){Su.register(R.parse(t),()=>Lt.fromJson(xe.BIOME,r));return}let n=Uo[e];n.register(R.parse(t),()=>n.parse(r))}var xu="";function y2(){let e=`${us}|${[...yn.keys()].join(",")}`;if(e!==xu){xu=e,Su.clear();for(let t of Object.values(Uo))for(let r of t.keys())r.equals(R.create("surface"))||r.equals(R.create("surface_secondary"))||t.delete(r);for(let[t,r]of yn)if(r)for(let[n,s]of Object.entries(r))wu(t,`minecraft:${n}`,s);for(let t of ku)t.kind!=="dimension"&&wu(t.kind,t.id,t.json)}}async function li(e){for(;;){y2();try{return e()}catch(t){let r=/Missing key in (?:minecraft:)?(worldgen\/[a-z_]+|tags\/worldgen\/biome): minecraft:/.exec(String(t)),n=r?.[1]==="tags/worldgen/biome"?"tag/worldgen/biome":r?.[1].replace("worldgen/","");if(!n||!(n in Uo||n==="tag/worldgen/biome")||yn.has(n)||!await v2(n))throw t}}}function Eu(e){try{return BigInt(e)}catch{let t=0n;for(let r of e)t=t*31n+BigInt(r.codePointAt(0))&0xffffffffffffffffn;return BigInt.asIntN(64,t)}}function fr(e,t,r,n=1){e[t]=r[0]*n,e[t+1]=r[1]*n,e[t+2]=r[2]*n,e[t+3]=255}var _n=()=>new Promise(e=>setTimeout(e,0)),xt=class extends Error{};function jr(e){if(e.seq!==kt)throw new xt}function Lo(e){let t=performance.now();return async()=>{performance.now()-t<40||(await _n(),jr(e),t=performance.now())}}function b2(e){let t=[],r=new Float32Array(e.length*13),n=[];return e.forEach((s,i)=>{let o=s??{},a=St.ParamPoint.fromJson(o.parameters);t.push(R.parse(typeof o.biome=="string"?o.biome:"plains").toString()),a.space().forEach((l,c)=>{c<6&&(r[i*13+c*2]=l.min,r[i*13+c*2+1]=l.max)}),r[i*13+12]=a.offset,n.push([a,()=>i])}),{entries:{biomes:t,params:r},lookup:new St.Parameters(n)}}function Au(e){let t=Iu.get(e);if(!t)throw new Error(`Missing dimension ${e}`);let r=t.generator??{},n=String(r.type??"").replace(/^minecraft:/,"");if(n!=="noise")throw new Error(`Only noise generators have a preview; this one is ${n||"missing"}.`);let s=typeof r.settings=="string"?xe.NOISE_SETTINGS.getOrThrow(R.parse(r.settings)):Vt.fromJson(r.settings),i=r.biome_source??{},o=String(i.type??"").replace(/^minecraft:/,"");if(o==="multi_noise"&&(i.preset!==void 0||typeof i.biomes=="string"))throw new Error("Multi-noise presets have no preview: their parameters are built into the game. List the biomes inline to map them.");let a=Fr.fromJson(i);return o==="multi_noise"&&Array.isArray(i.biomes)&&i.biomes.length>0?{settings:s,biomes:a,...b2(i.biomes)}:{settings:s,biomes:a}}var wt=[],vu=new Map;function bn(e){let t=vu.get(e);return t===void 0&&(t=wt.length,wt.push(e),vu.set(e,t)),t}var cs="",tr=new Map;function Nu(e,t,r){return`${e?"x":"z"}|${t}|${r}`}function Ru(e,t,r,n){let{settings:s}=e,i=s.noise.minY,o=s.noise.height,a=n*16,l=t?Je.create(n,Math.floor(r/16)):Je.create(Math.floor(r/16),n),c=new Un(i,o,l),u=new ii(new Kt(R.create("plains")),s),h=t?new Mt(16,o,1,a,i,r):new Mt(1,o,16,r,i,a),d=new Mt(16,o,16,Je.minBlockX(l),i,Je.minBlockZ(l)),f=new $r(e.rs,s,u.globalFluidPicker,d),m=e.rs.router.finalDensity.computeVolume(h);for(let w=0;w<16;w++){let[x,v]=t?[w,0]:[0,w],y=h.blockX(x),I=h.blockZ(v);for(let b=0;be.biomeAt(u[0],u[1],u[2])),c=e.rule.compile(l);for(let[u,h]of s){l.updateXZ(u,h);let d=0,f=Number.MIN_SAFE_INTEGER,m=Number.MAX_SAFE_INTEGER;for(let p=a;p>=o;p--){let g=te.create(u,p,h),w=t.getBlockState(g);if(w.equals(se.AIR)){d=0,f=Number.MIN_SAFE_INTEGER;continue}if(w.isFluid()){f===Number.MIN_SAFE_INTEGER&&(f=p+1);continue}if(m>=p){m=Number.MIN_SAFE_INTEGER;for(let v=p-1;v>=o;v--){let y=t.getBlockState(te.create(u,v,h));if(y.equals(se.AIR)||y.isFluid()){m=v+1;break}}}d+=1,l.updateY(d,p-m+1,f,p);let x=c(u,p,h);x&&(i?.push([g,w]),t.setBlockState(g,x))}}}var ss=new Map;function zu(e){let t=ss.get(e);return t===void 0&&(ss.size>4096&&ss.clear(),t=bn(e.getName().toString()),ss.set(e,t)),t}var pn=new Map,_2=64;function yu(e,t,r){let{settings:n}=e,s=n.noise.minY,i=n.noise.height,o=new ii(new Kt(R.create("plains")),n),a=`${e.shape}|${t},${r}`,l=pn.get(a);if(l)pn.delete(a);else{let d=new Un(s,i,Je.create(t,r)),f=o.createNoiseChunk(e.rs,d,!1);o.doFill(d,f),l={chunk:d,noiseChunk:f}}pn.set(a,l),pn.size>_2&&pn.delete(pn.keys().next().value);let{chunk:c,noiseChunk:u}=l,h=[];try{let d=t*16,f=r*16,m=[];for(let g=0;g<16;g++)for(let w=0;w<16;w++)m.push([d+g,f+w]);Tu(e,c,u,o.getWorldgenContext(),m,h);let p=new Uint16Array(256*i);for(let g=0;g<16;g++)for(let w=0;w<16;w++){let x=(g*16+w)*i;for(let v=0;v`rgb(${Math.round(r[0]*n)} ${Math.round(r[1]*n)} ${Math.round(r[2]*n)})`),bu.set(e,t)}return t}var Co=-1,_u=-1;function wn(e){return Co<0&&(Co=bn("minecraft:air"),_u=bn("minecraft:cave_air")),e===Co||e===_u}function Go(e,t){let r=t,n=-1;for(let s=0;s<256;s++){let i=s*t,o=t-1;for(;o>=0&&wn(e[i+o]);)o--;o<0||(on&&(n=o))}return{data:e,lowest:r,highest:n,faces:new Map}}function I2(e,t,r,n,s){let i=`${n}|${t?1:0}|${r?1:0}`,o=e.faces.get(i);if(o)return o;let{data:a}=e,l=[],c=[];for(let h=0;h<16;h++)for(let d=0;d<16;d++){let f=(h*16+d)*s,m=h<15?f+16*s:d*s,p=h<15?a:t?.data,g=d<15?f+s:h*16*s,w=d<15?a:r?.data;for(let x=n;x<=e.highest;x++){let v=a[f+x];if(wn(v))continue;let y=k2(wt[v]);(x===s-1||wn(a[f+x+1]))&&(l.push(h,x,d,0),c.push(y[0])),(!p||wn(p[m+x]))&&(l.push(h,x,d,1),c.push(y[1])),(!w||wn(w[g+x]))&&(l.push(h,x,d,2),c.push(y[2]))}}let u={faces:Int16Array.from(l),fills:c};return e.faces.size>=4&&e.faces.delete(e.faces.keys().next().value),e.faces.set(i,u),u}function E2(e,t,r,n){let s=n,i=-1;for(let f of t)for(let m of f)!m||m.highest<0||(s=Math.min(s,m.lowest),i=Math.max(i,m.highest));let o=Math.max(0,s-16),a=[],l=[],c=0;for(let f=0;f{let[p,g]=l[m],w=f.faces;for(let x=0;x{c&&(e.fill(),e.stroke())};for(let h=0,d=0;hi||x+2*r<0||x>o||(l[d]!==c&&(u(),c=l[d],e.fillStyle=e.strokeStyle=c,e.beginPath()),g===0?(e.moveTo(w,x),e.lineTo(w+r,x+r/2),e.lineTo(w,x+r),e.lineTo(w-r,x+r/2)):g===1?(e.moveTo(w+r,x+r/2),e.lineTo(w,x+r),e.lineTo(w,x+2*r),e.lineTo(w+r,x+1.5*r)):(e.moveTo(w-r,x+r/2),e.lineTo(w,x+r),e.lineTo(w,x+2*r),e.lineTo(w-r,x+1.5*r)),e.closePath())}u()}var N2=4096*4096,Mn=[],ls=null,xn=[],vn=new Map,R2=0;function T2(e){for(let t of e){let r={port:t,job:null};t.onmessage=n=>z2(r,n.data),ls&&t.postMessage(ls),Mn.push(r)}Ho()}function z2(e,t){let r=e.job;if(e.job=null,r&&r.id===t.job){vn.get(`${r.cx},${r.cz}`)===r&&vn.delete(`${r.cx},${r.cz}`);try{P2(r,t)}catch(n){r.reject(n)}}Ho()}function P2(e,t){if("error"in t)e.reject(new Error(t.error));else if(e.key!==qt)e.reject(new xt);else{let r=Uint16Array.from(t.ids,bn),n=t.data;for(let i=0;iM2&&Ke.delete(Ke.keys().next().value),t}function O2(e,t){let r=Mn.length;return((e*31+t)%r+r)%r}function Ho(){Mn.forEach((e,t)=>{if(e.job)return;let r=xn.findIndex(s=>O2(s.cx,s.cz)===t);if(r<0)return;let n=xn.splice(r,1)[0];e.job=n,e.port.postMessage({type:"chunk",job:n.id,req:n.req,cx:n.cx,cz:n.cz})})}function Pu(e,t,r){let n=new Map;for(let[i,o]of t)n.set(`${i},${o}`,!1);for(let[i,o]of r)n.has(`${i},${o}`)||n.set(`${i},${o}`,!0);xn=xn.filter(i=>{let o=`${i.cx},${i.cz}`;return i.key===qt&&n.has(o)?!0:(vn.get(o)===i&&vn.delete(o),i.reject(new xt),!1)});let s=new Map;for(let[i,o]of n){if(Ke.has(i))continue;let a=vn.get(i);if(a&&a.key!==qt&&(a=void 0),!a){let[l,c]=i.split(",").map(Number),u,h,d=new Promise((f,m)=>(u=f,h=m));d.catch(()=>{}),a={id:R2++,key:qt,cx:l,cz:c,req:e,prefetch:o,promise:d,resolve:u,reject:h},vn.set(i,a),xn.push(a)}a.prefetch=o,o||s.set(i,a.promise)}return xn.sort((i,o)=>Number(i.prefetch)-Number(o.prefetch)),Ho(),s}async function Wo(e,t,r){try{return yu(e,t,r)}catch(n){if(!String(n).includes("Missing key"))throw n;return li(()=>yu(e,t,r))}}async function B2(e,t){if(t.type==="setup"){Lu(t.files);return}try{let{terrain:r}=await jo(t.req),n=await Wo(r,t.cx,t.cz);e.postMessage({type:"chunk",job:t.job,data:n,ids:wt.slice()},[n.buffer])}catch(r){e.postMessage({type:"chunk",job:t.job,error:String(r instanceof Error?r.message:r)})}}var Ou=e=>new Promise(t=>setTimeout(t,e));async function L2(e,t,r){let{width:n,height:s}=e,i=t.settings.noise.height;r!==qt&&(qt=r,Ke.clear(),ci=null,st=null),Dt?.shape!==t.shape&&(Dt={shape:t.shape,y:t.settings.seaLevel-t.settings.noise.minY,fixed:!1});let o=$2(n,s),a=Math.max(o,e.view.scale>0?e.view.scale:n/72),l=e.view.x,c=e.view.y,u={x0:(l-c)*a-n/2,y0:(l+c)*a/2-s/2,x1:0,y1:0};u.x1=u.x0+n,u.y1=u.y0+s;let h=Math.min(n/4,32*a),d=Math.min(s/4,32*a),f={x0:u.x0-h,y0:u.y0-d,x1:u.x1+h,y1:u.y1+d},m=(I,b)=>Math.hypot(I[0]*16+8-l,I[1]*16+8-c)-Math.hypot(b[0]*16+8-l,b[1]*16+8-c),p=()=>{let I=Yo(u,a,i).sort(m),b=I.filter(([k,E])=>!Bu(`${k},${E}`));return{shown:I,missing:b}},{shown:g,missing:w}=p(),x=()=>{let I=new OffscreenCanvas(n,s),b=I.getContext("2d");b.fillStyle=`rgb(${oi.join(" ")})`,b.fillRect(0,0,n,s);let k=Jo(u,f,a,i);k&&b.drawImage(k.image,Math.round(k.x0-u.x0),Math.round(k.y0-u.y0));let A=(!k||k.empty)&&w.length===0?"No blocks here. Drag to pan to some terrain.":void 0,N=I.transferToImageBitmap();return{type:"rendered",seq:e.seq,width:n,height:s,pixels:new Uint8ClampedArray(0),values:new Float32Array(0),min:1/0,max:-1/0,scale:a,minScale:o,bitmap:N,notice:A}};Xo=()=>Jo(u,f,a,i);let v=-1,y=g.length-w.length;for(;w.length>0;){if(Mn.length===0)for(let[I,b]of w){if(y>0&&Ur({...x(),partial:!0}),await _n(),e.seq!==kt)throw new xt;Zo(`${I},${b}`,Go(await Wo(t,I,b),i)),y++}else{let I=Yo(f,a,i).filter(([A,N])=>!g.some(z=>z[0]===A&&z[1]===N)).sort(m),b=Pu(e,w,I),k=w.length,E=Promise.all(w.map(([A,N])=>b.get(`${A},${N}`).then(()=>(k--,void y++))));for(E.catch(()=>{});k>0;)if(y!==v&&y>0&&Ur({...x(),partial:!0}),v=y,await Promise.race([E,Ou(150)]),e.seq!==kt)throw new xt;await E}({shown:g,missing:w}=p())}return x()}async function C2(e,t,r){let{width:n,height:s,view:i}=e,o=t.settings.noise.height,a=t.settings.noise.minY;r!==qt&&(qt=r,Ke.clear(),ci=null,st=null),Xo=null;let l=ui(n,s,i),c=Math.min(o-1,Math.floor(i.y)-a),u=[l.x(0,0),l.x(n-1,s-1)],h=[l.z(0,0),l.z(n-1,s-1)],d=Math.floor(Math.min(...u)/16),f=Math.floor(Math.max(...u)/16),m=Math.floor(Math.min(...h)/16),p=Math.floor(Math.max(...h)/16),g=(E,A)=>Math.hypot(E[0]*16+8-i.x,E[1]*16+8-i.z)-Math.hypot(A[0]*16+8-i.x,A[1]*16+8-i.z),w=[],x=[];for(let E=d-1;E<=f+1;E++)for(let A=m-1;A<=p+1;A++)(Ef||Ap?x:w).push([E,A]);w.sort(g),x.sort(g);let v=new Map,y=(E,A)=>{let N=Ke.get(`${E>>4},${A>>4}`);if(!N)return-2;let z=v.get(N);z||v.set(N,z=new Int16Array(256).fill(-3));let F=(E&15)*16+(A&15);if(z[F]===-3){let Y=c,$=F*o;for(;Y>=0&&wn(N.data[$+Y]);)Y--;z[F]=Y}return z[F]},I=()=>{v.clear();let E=new Uint8ClampedArray(n*s*4),A=new Float32Array(n*s).fill(NaN),N=new Float32Array(n*s).fill(NaN),z=1/0,F=-1/0;for(let ce=0;ceF&&(F=T))}let Y=Math.max(16,F-z),$=!1;for(let ce=0;ce>4},${D>>4}`).data[((B&15)*16+(D&15))*o+ie],Q=y(B-l.dx,D-l.dz),_=Q<0||Q===ie?1:Q>ie?.82:1.1;A[T]=de,N[T]=a+ie,fr(E,T*4,rs(wt[de]),_*(.8+.3*(ie-z)/Y)),$=!0}let V=!$&&b.length===0?`No blocks at or below y ${Math.floor(i.y)} here.`:void 0;return{type:"rendered",seq:e.seq,width:n,height:s,pixels:E,values:A,heights:N,min:1/0,max:-1/0,labels:wt.slice(),notice:V,seaLevel:t.settings.seaLevel,minY:a,maxY:a+o}},b=w.filter(([E,A])=>!Bu(`${E},${A}`)),k=w.length-b.length;if(b.length>0&&Mn.length===0)for(let[E,A]of b){if(k>0&&Ur({...I(),partial:!0}),await _n(),e.seq!==kt)throw new xt;Zo(`${E},${A}`,Go(await Wo(t,E,A),o)),k++}else if(b.length>0){let E=Pu(e,b,x),A=b.length,N=Promise.all(b.map(([F,Y])=>E.get(`${F},${Y}`).then(()=>(A--,void k++))));N.catch(()=>{});let z=-1;for(;A>0;)if(k!==z&&k>0&&Ur({...I(),partial:!0}),z=k,await Promise.race([N,Ou(150)]),e.seq!==kt)throw new xt;await N}return b=[],I()}function Bu(e){let t=Ke.get(e);return t?(Ke.delete(e),Ke.set(e,t),!0):!1}var F2=100;function $2(e,t){let r=s=>(e/s+32)*(2*t/s+64)/2/256,n=1;for(;r(n)>F2&&n<64;)n*=1.05;return n}var Dt=null;function D2(e,t,r,n,s){let i=Dt.y,o=e*16,a=t*16;return{x0:(o-a-16)*s-s,x1:(o+16-a)*s+s,y0:(o+a)*s/2-(n+1-i)*s,y1:(o+a+32)*s/2-(r-i)*s+s}}var q2=(e,t)=>e.x0=0)return[s,i];let o=Dt.y;return[Math.max(0,o-16),Math.min(r-1,o+16)]}function Yo(e,t,r){let n=Dt.y,s=e.x0/t-2,i=e.x1/t+2,o=2*(e.y0/t-n)-2,a=2*(e.y1/t+r-n)+2,l=Math.floor((s+o)/32)-1,c=Math.floor((i+a)/32)+1,u=Math.floor((o-i)/32)-1,h=Math.floor((a-s)/32)+1,d=[];for(let f=l;f<=c;f++)for(let m=Math.max(u,Math.floor((f*16-i)/16)-1);m<=Math.min(h,Math.floor((f*16+16-s)/16)+1);m++){let[p,g]=Y2(f,m,r);g>=p&&q2(D2(f,m,p,g,t),e)&&d.push([f,m])}return d}function J2(e){e.highest<0||Dt&&!Dt.fixed&&(Dt.y=Math.round((e.lowest+e.highest)/2),Dt.fixed=!0)}var Xo=null,Mu;function j2(){clearTimeout(Mu),Mu=setTimeout(()=>Xo?.(),200)}function Jo(e,t,r,n){let s=st&&st.s===r&&st.key.startsWith(qt+"#")&&e.x0>=st.x0&&e.y0>=st.y0&&e.x1<=st.x1&&e.y1<=st.y1,i=s?st:t,o=Yo(i,r,n).filter(([x,v])=>Ke.has(`${x},${v}`)),a=`${qt}#${r}#${o.map(x=>x.join(",")).sort().join(";")}`;if(s&&st.key===a)return st;let l=Math.ceil(i.x1-i.x0),c=Math.ceil(i.y1-i.y0);if(l*c>N2)return i===e?null:Jo(e,e,r,n);let u=1/0,h=1/0,d=-1/0,f=-1/0;for(let[x,v]of o)u=Math.min(u,x),h=Math.min(h,v),d=Math.max(d,x),f=Math.max(f,v);let m=[];for(let x=u;x<=d;x++){let v=[];for(let y=h;y<=f;y++)v.push(Ke.get(`${x},${y}`));m.push(v)}ci?.key!==a&&(ci=E2(a,m,0,n));let p=ci,g=new OffscreenCanvas(l,c),w=o.length===0||p.bottom>p.top;if(!w){let x=Dt.y,v=(u*16-h*16)*r-i.x0,y=(u*16+h*16)*r/2+x*r-i.y0;A2(g.getContext("2d"),p,r,v,y,l,c)}return st={key:a,s:r,x0:i.x0,y0:i.y0,x1:i.x1,y1:i.y1,image:g,empty:w},st}function ui(e,t,r){let n=fa(r.facing),s=n.rx!==0,i=s?n.rx:n.rz,o=l=>(l+.5-e/2)*r.scale,a=l=>(l+.5-t/2)*r.scale;return{...n,alongX:s,depth:Math.floor(s?r.z:r.x),along:l=>(s?r.x:r.z)+i*o(l),y:l=>r.y-a(l),x:(l,c)=>r.x+n.rx*o(l)+n.dx*a(c),z:(l,c)=>r.z+n.rz*o(l)+n.dz*a(c),at:l=>s?[l,r.z]:[r.x,l]}}async function U2(e,t,r){r!==cs&&(cs=r,tr.clear());let n=ui(e.width,e.height,e.view),s=Math.floor(Math.floor(n.along(e.width/2))/16),i=Nu(n.alongX,n.depth,s);if(!tr.has(i)){let o=await li(()=>Ru(t,n.alongX,n.depth,s));jr(e),tr.set(i,o)}return t}async function G2(e,t,r){let{width:n,height:s,view:i}=e,o=t.settings.noise.minY,a=o+t.settings.noise.height,l=t.settings.seaLevel;r!==cs&&(cs=r,tr.clear());let c=ui(n,s,i),u=new Float32Array(n*s).fill(NaN),h=new Uint8ClampedArray(n*s*4),d=t.settings.noise.height,f=new Set,m=performance.now();for(let p=0;p40){if(await _n(),e.seq!==kt)throw new xt;m=performance.now()}v=Ru(t,c.alongX,c.depth,w),tr.set(x,v)}let y=g-w*16,[I,b]=c.at(g),k=t.rs.router.chunkSurfaceLevel.compute(j.context(I,0,b));for(let E=0;E=a){fr(h,N*4,ai);continue}let z=v[y*d+(A-o)],F=wt[z];u[N]=z,F==="minecraft:air"?fr(h,N*4,A512)for(let p of tr.keys())f.has(p)||tr.delete(p);return{type:"rendered",seq:e.seq,width:n,height:s,pixels:h,values:u,min:1/0,max:-1/0,labels:wt.slice(),seaLevel:l,minY:o,maxY:a}}async function Z2(e,t,r){let{width:n,height:s,view:i}=e,o=n*s,a=new Float32Array(o),l=new Uint8ClampedArray(o*4),c=new Float32Array(o*6),u=new Float32Array(o).fill(NaN),h=ui(n,s,i),d=Math.floor(i.y)>>2,f=new Map,m=new Map,{entries:p,lookup:g}=t,w=performance.now();for(let v=0;v40){if(await _n(),e.seq!==kt)throw new xt;w=performance.now()}for(let y=0;y>2,b=Math.floor(h.z(y,v))>>2,k=`${I},${b}`,E=m.get(k);if(E===void 0){let z=r.sampler.sample(I,d,b);if(p&&g){let F=g.find(z);E={b:bn(p.biomes[F]),t:z,f:Gr(p,F,z.toArray())}}else E={b:bn(t.biomes.getBiome(I,d,b,r.sampler).toString()),t:z,f:NaN};m.set(k,E)}let A=v*n+y,N=E.b;a[A]=N,c[A]=E.t.temperature,c[o+A]=E.t.humidity,c[2*o+A]=E.t.continentalness,c[3*o+A]=E.t.erosion,c[4*o+A]=E.t.depth,c[5*o+A]=E.t.weirdness,u[A]=E.f,f.set(N,(f.get(N)??0)+1),fr(l,A*4,Ro(wt[N]))}}for(let v=0;vy[1]-v[1]).map(([v])=>({id:wt[v],color:`rgb(${Ro(wt[v]).join(" ")})`}));return{type:"rendered",seq:e.seq,width:n,height:s,pixels:l,values:a,min:1/0,max:-1/0,labels:wt.slice(),legend:x,climate:c,fit:p?u:void 0,entries:p}}var Fo=null;async function jo(e){let t=Eu(e.seed),r=R.parse(e.id),n=R.parse(e.options.biome||"minecraft:plains"),s=e.kind==="dimension"?"":`${e.options.terrain}|${n}`,i=[us,e.seed,e.kind,e.id,e.mode,s].join("|");if(Fo?.key===i)return{terrain:Fo.t,key:i};let o=e.kind==="dimension"?await li(()=>{let a=Au(e.id),l=ns(new Qt(a.settings,t));return{settings:a.settings,rule:a.settings.materialRule,rs:l,biomeAt:(c,u,h)=>a.biomes.getBiome(c>>2,u>>2,h>>2,l.sampler),shape:[qo,e.seed,"dimension",e.id].join("|")}}):await li(()=>{let a=e.kind==="material_rule"?R.parse(e.options.terrain||"minecraft:overworld"):r,l=xe.NOISE_SETTINGS.getOrThrow(a),c=e.kind==="material_rule"?xe.MATERIAL_RULE.getOrThrow(r):l.materialRule,u=ns(new Qt(l,t)),h=[qo,e.seed,"noise_settings",a].join("|");return{settings:l,rule:c,rs:u,biomeAt:()=>n,shape:h}});return Fo={key:i,t:o},{terrain:o,key:i}}function $o(e,t,r,n){let s=-1,i=[],o=[],a=n<1;return(l,c,u,h,d,f)=>{if(!r)return f(u,h,d);let m=Math.floor(u),p=Math.floor(h),g=Math.floor(d);if(!a)return f(m,p,g);c!==s&&(o=s===c-1?i:[],i=new Array(e),s=c);let w=`${m} ${p} ${g}`;i[l]=w;let x=c*e+l;return l>0&&i[l-1]===w?t[x-1]:o[l]===w?t[x-e]:f(m,p,g)}}var Do=null;async function os(e,t){let r=[us,e.seed,e.kind,e.mode,e.id].join("|");if(Do?.key===r)return Do.value;let n=await li(t);return Do={key:r,value:n},n}async function as(e){let{width:t,height:r,view:n}=e,s=Eu(e.seed),i=R.parse(e.id),o=new Float32Array(t*r),a=new Uint8ClampedArray(t*r*4),l=ui(t,r,n),c=1/0,u=-1/0,h=b=>{bu&&(u=b)};if(e.kind==="dimension"&&e.mode==="biomes"){let{dim:b,rs:k}=await os(e,()=>{let E=Au(e.id),A=new Qt(E.settings,s);return A.sampler.sample(0,0,0),{dim:E,rs:A}});return Z2(e,b,k)}if(e.kind==="dimension"||e.kind==="material_rule"||e.kind==="noise_settings"&&e.mode!=="density"){if(e.mode==="blocks"&&n.down){let E={...e,mode:"iso"},{terrain:A,key:N}=await jo(E);return jr(e),C2(E,A,N)}let{terrain:b,key:k}=await jo(e);return jr(e),e.mode==="iso"?L2(e,b,k):(await U2(e,b,k),jr(e),G2(e,b,k))}if(e.kind==="noise"){let b=await os(e,()=>new Qt(Vt.create({}),s).getOrCreateNoise(i)),k=Lo(e),E=$o(t,o,!!n.blocks,n.scale);for(let A=0;Ab.get3D(F,Y,$));o[A*t+N]=z,h(z)}return{type:"rendered",seq:e.seq,width:t,height:r,pixels:a,values:o,min:c,max:u}}if(e.kind==="density_function"){let b=await os(e,()=>{let N=new Qt(Vt.create({}),s);return new j.HolderHolder(he.reference(xe.DENSITY_FUNCTION,i)).mapAll(N.createVisitor(!1))}),k=Lo(e),E=$o(t,o,!!n.blocks,n.scale),A=(N,z,F)=>b.compute(j.context(N,z,F));for(let N=0;N{let b=xe.NOISE_SETTINGS.getOrThrow(i),k=ns(new Qt(b,s));return{settings:b,router:k.router}}),m=d.noise.minY,p=m+d.noise.height,g=d.seaLevel,w=b=>n.down?n.y:l.y(b),x=Lo(e),v=$o(t,o,!!n.blocks,n.scale),y=(b,k,E)=>f.finalDensity.compute(j.context(b,k,E));for(let b=0;b=m&&k0){let F=110+Math.min(1,z/I)*70;a[N]=F,a[N+1]=F,a[N+2]=F+6}else kas({...e,width:Math.ceil(e.width/o),height:Math.ceil(e.height/o),view:{...e.view,scale:e.view.scale*o}}),n=performance.now(),s=await r(gn);jr(e);let i=(performance.now()-n)*gn*gn;if(iW2){let o=await r(2);jr(e),Ur({...o,partial:!0,step:2})}return as(e)}function Ur(e){let t=[e.pixels.buffer,e.values.buffer];e.bitmap&&t.push(e.bitmap),e.heights&&t.push(e.heights.buffer),e.climate&&t.push(e.climate.buffer),e.fit&&t.push(e.fit.buffer),self.postMessage(e,t)}function Lu(e){ku=e,Iu=new Map(e.filter(r=>r.kind==="dimension").map(r=>[r.id,r.json])),us++;let t=x2(e);t!==gu&&(gu=t,qo++),ls={type:"setup",files:e};for(let r of Mn)r.port.postMessage(ls)}var kt=0;self.onmessage=async e=>{let t=e.data;if(t.type==="ping"){self.postMessage({type:"pong"});return}if(t.type==="setup"){Lu(t.files);return}if(t.type==="helpers"){T2(t.ports);return}if(t.type==="serve"){let{port:r}=t;r.onmessage=n=>B2(r,n.data);return}if(kt=t.seq,await _n(),t.seq===kt){self.postMessage({type:"started",seq:t.seq});try{let r=await X2(t);if(r.seq!==kt)return;Ur(r)}catch(r){if(r instanceof xt||t.seq!==kt)return;self.postMessage({type:"error",seq:t.seq,message:String(r instanceof Error?r.message:r)})}}};var V2={biome:"minecraft:plains",terrain:"minecraft:overworld"};function Cu(e,t,r,n,s,i,o){return Jt({kind:"dimension",mode:"biomes",id:e,width:i,height:i,view:{x:r,y:n,z:s,facing:"north",scale:o},seed:t,options:V2})}function Vo(e,t){let r=e.params.filter(s=>s.off>0).map(s=>`${s.param} ${pe(s.value)} is outside ${pe(s.min)}..${pe(s.max)} by ${pe(s.off)}`);e.offset&&r.push(`offset ${pe(e.offset)}`);let n=r.length?`: ${r.join("; ")}`:": every parameter in range";return`${e.biome} (entry ${e.index}), distance ${pe(e.distance)}${t?", wins":""}${n}`}function Fu(e,t){let r=e.width*e.height;return kn.map((n,s)=>e.climate[s*r+t])}async function $u(e,t){let r=t.filter(b=>b.kind==="dimension").map(b=>b.id),n=Yt(e,"dimension");if(!n&&r.length!==1)throw new Ie(r.length?`Give dimension: one of ${r.join(", ")}.`:"The project has no Dimension with a noise generator to map.");let s=n?mr("dimension",n,r):r[0],i=String(e.seed??"0"),o=Math.floor(Ce(e,"x",0)),a=Math.floor(Ce(e,"z",0)),l=Math.floor(Ce(e,"y",64,-2048,2048)),c=Math.floor(Ce(e,"radius",2048,16,32768)),u=128,h=c*2/u,d=Yt(e,"biome"),f=await Cu(s,i,o,l,a,u,h),m=f.entries,p=f.labels??[],g=u*u,w=new Map;for(let b=0;bA[1]-E[1]))x.push(`- ${b} ${Zr(k,g)}`);let v=ca(m,w.keys());v.length&&x.push(`Listed by the source but not in the area: ${v.join(", ")}.`);let y=await Cu(s,i,o,l,a,1,1),I=Fu(y,0);return x.push("",`At x ${o}, z ${a} (y ${l}): ${y.labels?.[y.values[0]]??"no biome"}.`),x.push(`Climate: ${kn.map((b,k)=>`${b} ${pe(I[k])}`).join(", ")}.`),m&&(x.push("Nearest entries (the lowest distance wins; at most one per biome):"),gs(m,I,5).forEach((b,k)=>x.push(`${k+1}. ${Vo(b,k===0)}`))),d&&x.push("",...Q2(K2(d,[...w.keys(),...m?.biomes??[]]),f,m,w,g,o,a,h)),x.join(` +`)}function K2(e,t){if(e.includes(":"))return e;let r=[...new Set(t)].filter(n=>n.slice(n.indexOf(":")+1)===e);if(r.length>1)throw new Ie(`${e} could be ${r.join(" or ")}; give the namespace.`);return r[0]??ua(e)}function Q2(e,t,r,n,s,i,o,a){let l=t.width,c=t.labels??[],u=w=>{let x=w%l,v=Math.floor(w/l);return{x:Math.floor(i+(x+.5-l/2)*a),z:Math.floor(o+(v+.5-l/2)*a)}},h=n.get(e)??0;if(h>0){let w=-1,x=1/0;for(let y=0;y=0){let w=Fu(t,m),x=oa(r,e,w),v=gs(r,w,1)[0],y=u(m);d.push(`It comes closest at x ${y.x}, z ${y.z}, losing to ${v.biome} by ${pe(f[m])}.`),d.push(`There: ${Vo(x,!1)}.`),d.push(`The winner: ${Vo(v,!0)}.`)}let p=[];r.biomes.forEach((w,x)=>w===e&&p.push(x)),d.push("",`Climate in the area against what ${e}'s entries ask for:`);let g=!1;return kn.forEach((w,x)=>{let v=1/0,y=-1/0;for(let k=0;ky&&(y=E)}let I=p.map(k=>`${pe(r.params[k*13+x*2])}..${pe(r.params[k*13+x*2+1])}`),b=p.some(k=>r.params[k*13+x*2]<=y&&r.params[k*13+x*2+1]>=v);d.push(`- ${w}: area ${pe(v)}..${pe(y)}; asks ${[...new Set(I)].join(" or ")}${b?"":" (never in range here)"}`),!b&&w==="depth"&&(g=!0)}),g&&d.push("Depth changes with y (it is 0 at the surface and grows downwards), so try another y."),d}var Ko=["noise","density_function","noise_settings","dimension"],ew={noise:"worldgen/noise",density_function:"worldgen/density_function",noise_settings:"worldgen/noise_settings"},fi={biome:"minecraft:plains",terrain:"minecraft:overworld"};function tw(e,t,r,n){let s=a=>{let l=r.filter(h=>h.kind===a).map(h=>h.id),c=ew[a],u=c?Object.keys(n[c]??{}).map(h=>`minecraft:${h}`):[];return{own:l,all:[...new Set([...l,...u])]}},i=a=>{let{own:l,all:c}=s(a);if(!e.includes(":"))try{return mr(a.replace("_"," "),e,l)}catch{}return mr(a.replace("_"," "),e,c)};if(t)return{kind:t,id:i(t)};let o=[];for(let a of Ko)try{o.push({kind:a,id:i(a)})}catch{}if(o.length===1)return o[0];throw o.length>1?new Ie(`${e} names more than one thing: give kind, one of ${o.map(a=>a.kind).join(", ")}.`):new Ie(`No noise, density function, noise settings or dimension is called ${e}.`)}async function Du(e,t,r){let n=Yt(e,"id");if(!n)throw new Ie("Give id: the noise, density function, noise settings or dimension to sample.");let s=Yt(e,"kind");if(s&&!Ko.includes(s))throw new Ie(`kind must be one of ${Ko.join(", ")}.`);let{kind:i,id:o}=tw(n,s,t,r),a=String(e.seed??"0"),l=Yt(e,"mode")??(i==="dimension"?"surface":"area");if(!["area","column","surface"].includes(l))throw new Ie("mode must be area, column or surface.");let c=Math.floor(Ce(e,"x",0)),u=Math.floor(Ce(e,"z",0)),h=`${i.replace("_"," ")} ${o}, seed ${a}`;if(l==="surface"){if(i!=="noise_settings"&&i!=="dimension")throw new Ie("mode surface needs noise settings or a dimension: it builds the terrain.");return iw(h,i,o,a,c,u,e)}if(i==="dimension")throw new Ie("A dimension has no density of its own: use mode surface, or sample its noise settings' final density.");if(l==="column"){if(i==="noise")throw new Ie("A noise is sampled top-down at one y; use mode area, with y.");return nw(h,i,o,a,c,u,e)}return rw(h,i,o,a,c,u,e)}async function rw(e,t,r,n,s,i,o){let a=Ce(o,"y",64),l=Math.floor(Ce(o,"radius",256,1,32768)),c=Math.floor(Ce(o,"size",8,2,32)),u=64,h=await Jt({kind:t,mode:"density",id:r,width:u,height:u,view:{x:s,y:a,z:i,facing:"north",scale:2*l/u,down:!0},seed:n,options:fi}),d=await Jt({kind:t,mode:"density",id:r,width:c,height:c,view:{x:s,y:a,z:i,facing:"north",scale:2*l/c,down:!0},seed:n,options:fi}),f=[`${e}, at y ${pe(a)}, x ${s-l}..${s+l}, z ${i-l}..${i+l}.`];f.push(qu(h)),f.push("",`Values on a ${c}\xD7${c} grid, ${pe(2*l/c)} blocks apart (rows run north to south, columns west to east; coordinates rounded to 3 decimals):`);let m=2*l/c,p=Array.from({length:c},(w,x)=>s+(x+.5-c/2)*m),g=[["z \\ x",...p.map(w=>pe(w))]];for(let w=0;wpe(d.values[w*c+y],2))])}return f.push(pr(g)),f.join(` +`)}function qu(e){let t=0,r=0,n=0;for(let s of e.values)Number.isNaN(s)||(t+=s,r++,s>0&&n++);return r?`Min ${pe(e.min)}, max ${pe(e.max)}, mean ${pe(t/r)}; above 0 at ${Zr(n,r)} of ${r} samples.`:"No values: the area is outside the world height."}async function nw(e,t,r,n,s,i,o){let a=Math.floor(Ce(o,"from",-64,-2048,2048)),l=Math.floor(Ce(o,"to",320,-2048,2048));if(l<=a)throw new Ie("to must be above from.");let c=Math.max(Math.floor(Ce(o,"step",8,1,512)),Math.ceil((l-a)/511)),u=Math.floor((l-a)/c)+1,h=await Jt({kind:t,mode:"density",id:r,width:1,height:u,view:{x:s,y:a+(u/2-.5)*c,z:i,facing:"north",scale:c},seed:n,options:fi}),d=Array.from({length:u},(p,g)=>a+(u-1-g)*c),f=[`${e}, the column at x ${s}, z ${i}, y ${a}..${d[0]} every ${c}.`,qu(h)],m=[];for(let p=1;p0==w>0||m.push(`between y ${d[p]} and ${d[p-1]} (${w>0?"positive below":"positive above"})`)}return f.push(m.length?`Crosses 0 ${m.join("; ")}.`:"Never crosses 0 in this range."),f.push("",pr([["y","value"],...d.map((p,g)=>[String(p),pe(h.values[g])])])),f.join(` +`)}async function iw(e,t,r,n,s,i,o){let a=Math.floor(Ce(o,"radius",32,1,64)),l=Math.floor(Ce(o,"size",8,2,32)),c=Ce(o,"y",2032),u=Math.min(2*a,64),h=N=>({x:s,y:c,z:i,facing:"north",scale:2*a/N,down:!0}),d=await Jt({kind:t,mode:"blocks",id:r,width:u,height:u,view:h(u),seed:n,options:fi}),f=await Jt({kind:t,mode:"blocks",id:r,width:l,height:l,view:h(l),seed:n,options:fi}),m=[`${e}, the top block of each column${c<2032?` at or below y ${pe(c)}`:""}, x ${s-a}..${s+a}, z ${i-a}..${i+a}. Sea level is ${d.seaLevel}.`],p=d.labels??[],g=new Map,w=1/0,x=-1/0,v=0,y=0;for(let N=0;Nz[1]-N[1]).map(([N,z])=>`${N} ${Zr(z,y)}`).join(", ")}.`),d.notice&&m.push(d.notice);let I=2*a/l,b=Array.from({length:l},(N,z)=>Math.floor(s+(z+.5-l/2)*I)),k=f.labels??[],E=N=>N?N.replace(/^minecraft:/,""):"-";m.push("",`Height and top block on a ${l}\xD7${l} grid, ${pe(I)} blocks apart (rows run north to south):`);let A=[["z \\ x",...b.map(String)]];for(let N=0;N{let $=N*l+Y,V=f.heights?.[$]??NaN;return Number.isNaN(V)?"-":`${V} ${E(k[f.values[$]])}`})])}return m.push(pr(A)),m.join(` +`)}var hr=e=>e.includes(":")?e:`minecraft:${e}`;var fs=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rr="minecraft:empty",Qo=class{hi=0;lo=0;constructor(t){let r=(BigInt.asUintN(64,BigInt(t))^0x5deece66dn)&(1n<<48n)-1n;this.hi=Number(r>>24n),this.lo=Number(r&0xffffffn)}next(t){let r=this.lo*15525485+11,n=r%16777216,s=Math.floor(r/16777216),i=(this.hi*15525485+this.lo*1502+s)%16777216;this.hi=i,this.lo=n;let o=Math.floor((i*16777216+n)/2**(48-t));return o>=2**(t-1)&&t===32?o-2**32:o}nextInt(t){if((t&-t)===t)return Number(BigInt(t)*BigInt(this.next(31))>>31n);for(;;){let r=this.next(31),n=r%t;if(r-n+(t-1)<2**31)return n}}};function hi(e,t){for(let r=e.length;r>1;r--){let n=t.nextInt(r);[e[r-1],e[n]]=[e[n],e[r-1]]}return e}var Yu=["north","east","south","west"],sw={north:"south",south:"north",east:"west",west:"east",up:"down",down:"up"},ow={north:[0,0,-1],south:[0,0,1],east:[1,0,0],west:[-1,0,0],up:[0,1,0],down:[0,-1,0]};function Ju(e,t){let r=Yu.indexOf(e);return r<0?e:Yu[(r+(t===3?3:t))%4]}function aw(e,t){let[r,n]=e.split("_");return`${Ju(r,t)}_${Ju(n??"up",t)}`}function ea([e,t,r],n){switch(n){case 1:return[-r,t,e];case 2:return[-e,t,-r];case 3:return[r,t,-e];default:return[e,t,r]}}function cw(e,t,r){let n=ea([0,0,0],t),s=ea([e[0]-1,e[1]-1,e[2]-1],t);return[[Math.min(n[0],s[0])+r[0],Math.min(n[1],s[1])+r[1],Math.min(n[2],s[2])+r[2]],[Math.max(n[0],s[0])+r[0],Math.max(n[1],s[1])+r[1],Math.max(n[2],s[2])+r[2]]]}var lw=(e,t)=>t.every((r,n)=>r>=e[0][n]&&r<=e[1][n]),uw=(e,t)=>e[0].every((r,n)=>r>=t[0][n])&&e[1].every((r,n)=>r<=t[1][n]),fw=(e,t)=>e[0].every((r,n)=>r<=t[1][n])&&e[1].every((r,n)=>r>=t[0][n]),hw=(e,t)=>[e[0].map((r,n)=>r+t[n]),e[1].map((r,n)=>r+t[n])],dw=(e,t)=>uw(t,e.box)&&!e.taken.some(r=>fw(r,t)),hs=e=>e.split("_")[0],ju=e=>e.split("_")[1]??"up";function mw(e){let t=e.orientation??"north_up",r=hs(t);return{pos:[...e.pos],orientation:t,pool:hr(e.pool),name:hr(e.name),target:hr(e.target),joint:e.joint??(r==="up"||r==="down"?"rollable":"aligned"),finalState:e.final_state??"minecraft:air",selection:e.selection_priority??0,placement:e.placement_priority??0}}var pw=(e,t)=>({...e,pos:ea(e.pos,t),orientation:aw(e.orientation,t)}),gw=(e,t)=>hs(e.orientation)===sw[hs(t.orientation)]&&(e.joint==="rollable"||ju(e.orientation)===ju(t.orientation))&&e.target===t.name,ww={pos:[0,0,0],orientation:"down_south",pool:rr,name:"minecraft:bottom",target:rr,joint:"rollable",finalState:"minecraft:air",selection:0,placement:0},xw=/^data\/([^/]+)\/structures?\/(.+)\.nbt$/;function vw(e){let t=new Map;for(let r of e){let n=xw.exec(r.path);n&&t.set(`${n[1]}:${n[2]}`,r)}return t}function Zu(e,t){let r=s=>({kind:"unknown",id:s,box:i=>[[...i],[...i]],jigsaws:()=>[]});if(!fs(e))return r("?");let n=String(e.element_type??"").replace(/^minecraft:/,"");switch(n){case"single_pool_element":case"legacy_single_pool_element":{let s=hr(String(e.location??"?")),i=t.get(s);if(!i?.size||!i.jigsaws)return r(s);let o=i.size,a=i.jigsaws.map(mw);return{kind:"single",id:s,box:(l,c)=>cw(o,c,l),jigsaws:l=>a.map(c=>pw(c,l))}}case"list_pool_element":{let s=(Array.isArray(e.elements)?e.elements:[]).map(o=>Zu(o,t));if(!s.length)return{kind:"empty",id:"empty list",box:o=>[[...o],[...o]],jigsaws:()=>[]};let i=s.find(o=>o.kind==="unknown");return i?r(i.id):{kind:"list",id:s.map(o=>o.id).join(" + "),parts:s.map(o=>o.id),box:(o,a)=>{let l=s.map(c=>c.box(o,a));return[[0,1,2].map(c=>Math.min(...l.map(u=>u[0][c]))),[0,1,2].map(c=>Math.max(...l.map(u=>u[1][c])))]},jigsaws:o=>s[0].jigsaws(o)}}case"feature_pool_element":return{kind:"feature",id:`feature ${String(e.feature??"?").replace(/^minecraft:/,"")}`,box:i=>[[...i],[...i]],jigsaws:()=>[ww]};case"empty_pool_element":return{kind:"empty",id:"empty",box:s=>[[...s],[...s]],jigsaws:()=>[]};default:return r(n||"?")}}function Uu(e){if(e!==void 0)try{return JSON.parse(e)}catch{return}}var ta=20;function Hu(e,t,r=[],n={}){let s=new Map(t.map(B=>[B.path,B])),i=Uu(s.get(e)?.text);if(!fs(i)||String(i.type??"").replace(/^minecraft:/,"")!=="jigsaw"||typeof i.start_pool!="string")return null;let o=n.seed??0,a=n.limit??4096,l=typeof i.size=="number"?i.size:7,c=Math.max(0,Math.min(ta,Math.floor(n.depth??l))),u=typeof i.max_distance_from_center=="number"?i.max_distance_from_center:80,h=typeof i.start_jigsaw_name=="string"?hr(i.start_jigsaw_name):void 0,d=vw(r),f=new Set,m={seed:o,pieces:[],bounds:[[0,0,0],[0,0,0]],depth:c,size:l,reached:0,notes:[]},p=B=>{f.has(B)||(f.add(B),m.notes.push(B))};i.use_expansion_hack===!0&&p("The expansion hack is not simulated."),Array.isArray(i.pool_aliases)&&i.pool_aliases.length&&p("Pool aliases are not simulated; jigsaw blocks draw from the pools they name.");let g=new Map,w=B=>{if(g.has(B))return g.get(B);let D=null;if(B===rr)D={id:B,templates:[],fallback:rr};else{let[ie,ee]=B.split(":",2),de=Uu(s.get(`data/${ie}/worldgen/template_pool/${ee}.json`)?.text);if(fs(de)){let Q=[];for(let _ of Array.isArray(de.elements)?de.elements:[]){if(!fs(_))continue;let S=Zu(_.element,d);S.kind==="unknown"&&p(`${S.id} is not one of this project's structure files, so it is never placed here.`);let O=typeof _.weight=="number"?_.weight:1;for(let U=0;UD.name===h);if(!B)return m.failed=`The start piece ${I.id} has no jigsaw block named ${h}.`,m;b=B.pos}let k=[-b[0],-b[1],-b[2]],E=I.box(k,v),A=Math.trunc((E[1][0]+E[0][0])/2),N=Math.trunc((E[1][2]+E[0][2])/2),z=k[1]-(E[0][1]+1);E=hw(E,[0,z,0]);let F=[k[0],k[1]+z,k[2]],Y=k[1]+b[1];m.bounds=[[A-u,Y-u,N-u],[A+u,Y+u,N+u]];let $=[],V=0,ce=(B,D)=>(B.jigsaws=D.map(ie=>({pos:ie.pos,orientation:ie.orientation,pool:ie.pool,name:ie.name,target:ie.target,finalState:ie.finalState})),m.pieces.push(B),m.reached=Math.max(m.reached,B.depth),m.pieces.length-1),oe=I.jigsaws(v).map(B=>({...B,pos:B.pos.map((D,ie)=>D+F[ie])}));ce({id:I.id,kind:I.kind,...I.parts?{parts:I.parts}:{},pool:y.id,depth:0,rotation:v,origin:F,box:E,jigsaws:[]},oe);let T=[I];for(c>0&&$.push({piece:0,free:{box:m.bounds,taken:[E]},depth:0,priority:0,order:V++});$.length;){let B=0;for(let S=1;S<$.length;S++)$[S].priority>$[B].priority&&(B=S);let D=$.splice(B,1)[0],ie=m.pieces[D.piece],ee=T[D.piece],de=ie.box,Q,_=ee.jigsaws(ie.rotation).map((S,O)=>({j:{...S,pos:S.pos.map((U,ue)=>U+ie.origin[ue])},i:O}));hi(_,x),_.sort((S,O)=>O.j.selection-S.j.selection);e:for(let{j:S,i:O}of _){let U=ie.jigsaws[O],ue=Se=>{U.joined||(U.result=Se)},qe=hs(S.orientation),Ae=ow[qe]??[0,0,0],Ne=[S.pos[0]+Ae[0],S.pos[1]+Ae[1],S.pos[2]+Ae[2]],ye=w(S.pool);if(!ye||!ye.templates.length&&ye.id!==rr){ue({none:S.pool===rr?"empty":"unknown-pool"}),!ye&&!S.pool.startsWith("minecraft:")?p(`No TemplatePool declares ${S.pool}.`):ye||p(`${S.pool} is a vanilla pool, which the simulation does not have.`);continue}let le=w(ye.fallback);if(!le||!le.templates.length&&le.id!==rr){ue({none:"unknown-pool"});continue}if(S.pool===rr){ue({none:"empty"});continue}let q;lw(de,Ne)?q=Q??={box:de,taken:[]}:q=D.free;let L=[];if(D.depth!==c)for(let Se of hi([...ye.templates],x))L.push({c:Se,from:ye.id});for(let Se of hi([...le.templates],x))L.push({c:Se,from:le.id});let ae=D.depth===c?"depth":"no-fit";for(let{c:Se,from:ft}of L){if(Se.kind==="empty"){ae="empty-piece";break}for(let Qe of hi([0,1,2,3],x)){let It=Gu(Se,Qe,x);for(let nt of It){if(!gw(S,nt))continue;let Sn=[Ne[0]-nt.pos[0],Ne[1]-nt.pos[1],Ne[2]-nt.pos[2]],ms=Se.box(Sn,Qe);if(!dw(q,ms))continue;if(q.taken.push(ms),m.pieces.length>=a){p(`The simulation stops at ${a} pieces.`);break e}let Qu=Se.jigsaws(Qe).map(mi=>({...mi,pos:mi.pos.map((ps,pi)=>ps+Sn[pi])})),di=ce({id:Se.id,kind:Se.kind,...Se.parts?{parts:Se.parts}:{},pool:ft,depth:D.depth+1,rotation:Qe,origin:Sn,box:ms,jigsaws:[],parent:{piece:D.piece,jigsaw:O}},Qu);T.push(Se);let ra=m.pieces[di].jigsaws.findIndex(mi=>mi.pos.every((ps,pi)=>ps===nt.pos[pi]+Sn[pi]));ra>=0&&(m.pieces[di].jigsaws[ra].joined=!0),ue({piece:di}),D.depth+1<=c&&$.push({piece:di,free:q,depth:D.depth+1,priority:S.placement,order:V++});continue e}}}ue({none:ae})}}return m}function Gu(e,t,r){return hi(e.jigsaws(t),r).sort((s,i)=>i.selection-s.selection)}var Wu={empty:"its pool is minecraft:empty","unknown-pool":"its pool is not in the pack",depth:"the structure was at its last depth and the fallback had nothing that fit","no-fit":"no piece could join or fit the free space","empty-piece":"the pool drew its empty piece"},yw=/^data\/([^/]+)\/worldgen\/structure\/(.+)\.json$/;function Xu(e,t,r){let n=[];for(let f of t){let m=yw.exec(f.path);m&&/"type"\s*:\s*"(minecraft:)?jigsaw"/.test(f.text)&&n.push(`${m[1]}:${m[2]}`)}let s=Yt(e,"structure");if(!s&&n.length!==1)throw new Ie(n.length?`Give structure: one of ${n.join(", ")}.`:"The project has no jigsaw structure.");let i=s?mr("jigsaw structure",s,n):n[0],[o,a]=i.split(":",2),l=`data/${o}/worldgen/structure/${a}.json`,c=Math.floor(Ce(e,"seed",0,-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER-200)),u=Math.floor(Ce(e,"runs",1,1,200)),h=e.depth===void 0?void 0:Math.floor(Ce(e,"depth",0,0,ta)),d=[];for(let f=c;fa.path===`data/${s}/worldgen/template_pool/${i}.json`);if(o)try{let a=JSON.parse(o.text),l=new Set;for(let c of a.elements??[])for(let u of[c.element,...c.element?.elements??[]]){let h=u?.location;typeof h=="string"&&l.add(h.includes(":")?h:`minecraft:${h}`)}r.set(n,[...l])}catch{}}return r}var _w=e=>`${e[0].join(" ")} to ${e[1].join(" ")}`;function Vu(e,t){let r=[`Jigsaw structure ${e}: depth ${t.depth}${t.depth!==t.size?` (its size is ${t.size})`:""}.`];return t.notes.length&&r.push(...t.notes.map(n=>`Note: ${n}`)),r}function Mw(e,t,r){let n=Vu(e,t);if(n.push(`Seed ${t.seed}.`),t.failed)return[...n,`Nothing is placed: ${t.failed}`].join(` +`);n.push(`${t.pieces.length} pieces, ${t.reached} deep. Bounds (max_distance_from_center): ${_w(t.bounds)}.`),n.push("","Pieces (index, depth, structure, pool, rotation, origin, joined onto piece):");let s=[["#","depth","piece","pool","rot","origin","parent"]];t.pieces.forEach((o,a)=>{s.push([String(a),String(o.depth),o.id,o.pool,`${o.rotation*90}\xB0`,o.origin.join(" "),o.parent?String(o.parent.piece):"-"])}),n.push(pr(s));let i=[];return t.pieces.forEach((o,a)=>o.jigsaws.forEach(l=>{l.result&&"none"in l.result&&l.result.none!=="empty"&&i.push(`- piece ${a} (${o.id}) at ${l.pos.join(" ")}, pool ${l.pool}, target ${l.target}: ${Wu[l.result.none]}`)})),i.length&&n.push("","Jigsaw blocks that placed nothing (minecraft:empty pools left out):",...i),n.push(...Ku(r,[t])),n.join(` +`)}function Sw(e,t,r){let n=Vu(e,t[0]);n.push(`Seeds ${t[0].seed}..${t[t.length-1].seed} (${t.length} runs).`);let s=t.filter(o=>o.failed);if(s.length){let o=new Map;for(let a of s)o.set(a.failed,(o.get(a.failed)??0)+1);n.push(`${s.length} runs placed nothing:`,...[...o].map(([a,l])=>`- ${l}\xD7: ${a}`))}let i=t.filter(o=>!o.failed);if(i.length){let o=t.map(d=>d.pieces.length),a=i.map(d=>d.reached);n.push(`Pieces per run: ${Math.min(...o)}..${Math.max(...o)}, mean ${pe(o.reduce((d,f)=>d+f,0)/t.length,1)}. Depth reached: ${Math.min(...a)}..${Math.max(...a)}.`);let l=new Map,c=new Map;for(let d of i){let f=new Set;for(let m of d.pieces)c.set(m.id,(c.get(m.id)??0)+1),f.add(m.id);for(let m of f)l.set(m,(l.get(m)??0)+1)}n.push("","Pieces (runs that place it, mean count per run):");let u=[["piece","runs","mean"]];for(let[d,f]of[...l].sort((m,p)=>p[1]-m[1]||m[0].localeCompare(p[0])))u.push([d,`${f}/${t.length}`,pe(c.get(d)/t.length,2)]);n.push(pr(u));let h=new Map;for(let d of i)for(let f of d.pieces)for(let m of f.jigsaws)if(m.result&&"none"in m.result&&m.result.none!=="empty"){let p=`${f.id}: pool ${m.pool}, target ${m.target}: ${Wu[m.result.none]}`;h.set(p,(h.get(p)??0)+1)}if(h.size){n.push("","Jigsaw blocks that placed nothing, over all runs (minecraft:empty pools left out):");for(let[d,f]of[...h].sort((m,p)=>p[1]-m[1]))n.push(`- ${f}\xD7 ${d}`)}}return n.push(...Ku(r,i)),n.join(` +`)}function Ku(e,t){let r=new Set,n=new Set;for(let i of t)for(let o of i.pieces){r.add(o.id),n.add(o.pool);for(let a of o.jigsaws)n.add(a.pool.includes(":")?a.pool:`minecraft:${a.pool}`)}let s=[];for(let[i,o]of bw(e,n)){let a=o.filter(l=>!r.has(l));a.length&&s.push(`- ${i}: ${a.join(", ")}`)}return s.length?["",`Pieces their pools list that ${t.length>1?"no run":"this run"} placed:`,...s]:[]}async function kw(e){try{let t=la(e.files);ys(t,e.vanilla??{});let r=e.args??{};switch(e.tool){case"biomes":return{text:await $u(r,t)};case"density":return{text:await Du(r,t,e.vanilla??{})};case"jigsaw":return{text:Xu(r,e.files,e.assets??[])}}return{error:`unknown tool ${String(e.tool)}`}}catch(t){return ds.env.MMS_JS_DEBUG&&console.error(t),{error:t instanceof Error?t.message:String(t),args:t instanceof Ie}}}async function Iw(){let e=[];for await(let t of ds.stdin)e.push(t);return Buffer.concat(e).toString("utf8")}var Ew=await kw(JSON.parse(await Iw()));ds.stdout.write(JSON.stringify(Ew));ds.exit(0);export{kw as run}; /*! Bundled license information: is-buffer/index.js: