@expofp/floorplan
Version:
Interactive floor plan library for expos and events
1,932 lines • 98 kB
JavaScript
function __vite_inject_css__(css, id, forceLightDom){ if (typeof document==='undefined') return; var shadow=!forceLightDom&&typeof window!=='undefined'&&window.__efpShadowDOMStyleParent; var parent=shadow||document.head; var s=document.createElement('style'); s.setAttribute('data-chunk-style', id); s.appendChild(document.createTextNode(css)); parent.appendChild(s); if (shadow) (window.__efpStyleElements||(window.__efpStyleElements=[])).push(s);}
(function() {
try {
var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {};
e.SENTRY_RELEASE = { id: "3.39.1" };
var t = new e.Error().stack;
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "6ca64e6f-17c4-42f2-a3bc-069f7b0df007", e._sentryDebugIdIdentifier = "sentry-dbid-6ca64e6f-17c4-42f2-a3bc-069f7b0df007");
} catch {}
})();
import { r as e } from "./rolldown-runtime-BOCG9HEF.js";
import { t } from "./react-CM7l092i.js";
import { t as n } from "./jsx-runtime-BGutO_I9.js";
import { t as r } from "./client-BtPJvi_3.js";
import { S as i, b as a, c as o, n as s, t as c } from "./debug-context-CxXzVYRx.js";
//#region ../../node_modules/.pnpm/webgl-memory@1.1.3/node_modules/webgl-memory/webgl-memory.js
var l = i();
(function(e) {
typeof define == "function" && define.amd ? define(e) : e();
})((function() {
let e = 5121, t = 5126, n = 32819, r = 32820, i = 5131, a = 36193, o;
function s(s) {
if (!o) {
let s = {};
s[6406] = {
bytesPerElement: [
1,
2,
2,
4
],
type: [
e,
i,
a,
t
]
}, s[6409] = {
bytesPerElement: [
1,
2,
2,
4
],
type: [
e,
i,
a,
t
]
}, s[6410] = {
bytesPerElement: [
2,
4,
4,
8
],
type: [
e,
i,
a,
t
]
}, s[6407] = {
bytesPerElement: [
3,
6,
6,
12,
2
],
type: [
e,
i,
a,
t,
33635
]
}, s[6408] = {
bytesPerElement: [
4,
8,
8,
16,
2,
2
],
type: [
e,
i,
a,
t,
n,
r
]
}, s[35906] = {
bytesPerElement: [
4,
8,
8,
16,
2,
2
],
type: [
e,
i,
a,
t,
n,
r
]
}, s[6402] = {
bytesPerElement: [2, 4],
type: [5125, 5123]
}, s[34041] = { bytesPerElement: [4] }, s[33321] = { bytesPerElement: [1] }, s[36756] = { bytesPerElement: [1] }, s[33325] = { bytesPerElement: [2] }, s[33326] = { bytesPerElement: [4] }, s[33330] = { bytesPerElement: [1] }, s[33329] = { bytesPerElement: [1] }, s[33332] = { bytesPerElement: [2] }, s[33331] = { bytesPerElement: [2] }, s[33334] = { bytesPerElement: [4] }, s[33333] = { bytesPerElement: [4] }, s[33323] = { bytesPerElement: [2] }, s[36757] = { bytesPerElement: [2] }, s[33327] = { bytesPerElement: [4] }, s[33328] = { bytesPerElement: [8] }, s[33336] = { bytesPerElement: [2] }, s[33335] = { bytesPerElement: [2] }, s[33338] = { bytesPerElement: [4] }, s[33337] = { bytesPerElement: [4] }, s[33340] = { bytesPerElement: [8] }, s[33339] = { bytesPerElement: [8] }, s[32849] = { bytesPerElement: [3] }, s[35905] = { bytesPerElement: [3] }, s[36194] = { bytesPerElement: [2] }, s[36758] = { bytesPerElement: [3] }, s[35898] = { bytesPerElement: [4] }, s[35901] = { bytesPerElement: [4] }, s[34843] = { bytesPerElement: [6] }, s[34837] = { bytesPerElement: [12] }, s[36221] = { bytesPerElement: [3] }, s[36239] = { bytesPerElement: [3] }, s[36215] = { bytesPerElement: [6] }, s[36233] = { bytesPerElement: [6] }, s[36209] = { bytesPerElement: [12] }, s[36227] = { bytesPerElement: [12] }, s[32856] = { bytesPerElement: [4] }, s[35907] = { bytesPerElement: [4] }, s[36759] = { bytesPerElement: [4] }, s[32855] = { bytesPerElement: [2] }, s[32854] = { bytesPerElement: [2] }, s[32857] = { bytesPerElement: [4] }, s[34842] = { bytesPerElement: [8] }, s[34836] = { bytesPerElement: [16] }, s[36220] = { bytesPerElement: [4] }, s[36238] = { bytesPerElement: [4] }, s[36975] = { bytesPerElement: [4] }, s[36214] = { bytesPerElement: [8] }, s[36232] = { bytesPerElement: [8] }, s[36226] = { bytesPerElement: [16] }, s[36208] = { bytesPerElement: [16] }, s[33189] = { bytesPerElement: [2] }, s[33190] = { bytesPerElement: [4] }, s[36012] = { bytesPerElement: [4] }, s[35056] = { bytesPerElement: [4] }, s[36013] = { bytesPerElement: [4] }, s[36168] = { bytesPerElement: [1] }, o = s;
}
return o[s];
}
function c(e, t, n) {
return function(r, i, a) {
return ((r + e - 1) / e | 0) * ((i + t - 1) / t | 0) * n * a;
};
}
function l(e, t, n) {
return function(r, i, a) {
return (Math.max(r, e) * Math.max(i, t) / n | 0) * a;
};
}
let u = /* @__PURE__ */ new Map([
[33776, c(4, 4, 8)],
[33777, c(4, 4, 8)],
[33778, c(4, 4, 16)],
[33779, c(4, 4, 16)],
[36196, c(4, 4, 8)],
[35840, l(8, 8, 2)],
[35842, l(8, 8, 2)],
[35841, l(16, 8, 4)],
[35843, l(16, 8, 4)],
[37488, c(4, 4, 8)],
[37489, c(4, 4, 8)],
[37492, c(4, 4, 8)],
[37493, c(4, 4, 8)],
[37494, c(4, 4, 8)],
[37495, c(4, 4, 8)],
[37490, c(4, 4, 16)],
[37491, c(4, 4, 16)],
[37496, c(4, 4, 16)],
[37497, c(4, 4, 16)],
[37808, c(4, 4, 16)],
[37840, c(4, 4, 16)],
[37809, c(5, 4, 16)],
[37841, c(5, 4, 16)],
[37810, c(5, 5, 16)],
[37842, c(5, 5, 16)],
[37811, c(6, 5, 16)],
[37843, c(6, 5, 16)],
[37812, c(6, 6, 16)],
[37844, c(6, 6, 16)],
[37813, c(8, 5, 16)],
[37845, c(8, 5, 16)],
[37814, c(8, 6, 16)],
[37846, c(8, 6, 16)],
[37815, c(8, 8, 16)],
[37847, c(8, 8, 16)],
[37816, c(10, 5, 16)],
[37848, c(10, 5, 16)],
[37817, c(10, 6, 16)],
[37849, c(10, 6, 16)],
[37818, c(10, 8, 16)],
[37850, c(10, 8, 16)],
[37819, c(10, 10, 16)],
[37851, c(10, 10, 16)],
[37820, c(12, 10, 16)],
[37852, c(12, 10, 16)],
[37821, c(12, 12, 16)],
[37853, c(12, 12, 16)],
[35916, c(4, 4, 8)],
[35917, c(4, 4, 8)],
[35918, c(4, 4, 16)],
[35919, c(4, 4, 16)],
[36492, c(4, 4, 16)],
[36493, c(4, 4, 16)],
[36494, c(4, 4, 16)],
[36495, c(4, 4, 16)],
[36283, c(4, 4, 8)],
[36284, c(4, 4, 8)],
[36285, c(4, 4, 16)],
[36286, c(4, 4, 16)]
]);
function d(e, t) {
let n = s(e);
if (!n) throw "unknown internal format";
if (n.type) {
let r = n.type.indexOf(t);
if (r < 0) throw Error(`unsupported type ${t} for internalformat ${e}`);
return n.bytesPerElement[r];
}
return n.bytesPerElement[0];
}
function f(e, t, n, r, i) {
let a = d(e, i);
return t * n * r * a;
}
function p(e, t, n, r, i) {
let a = u.get(e);
return a ? a(t, n, r) : f(e, t, n, r, i);
}
function m(e) {
return e && e.buffer && e.buffer instanceof ArrayBuffer;
}
function h(e) {
return m(e) || e instanceof ArrayBuffer;
}
function g(e) {
return {
samples: e.getParameter(e.SAMPLES) || 1,
depthBits: e.getParameter(e.DEPTH_BITS),
stencilBits: e.getParameter(e.STENCIL_BITS),
contextAttributes: e.getContextAttributes()
};
}
function _(e) {
let { depthBits: t, stencilBits: n } = e, r = (t + n + 7) / 8 | 0;
return r === 3 ? 4 : r;
}
function v(e, t) {
if (e.isContextLost()) return 0;
let { samples: n } = t, r = e.drawingBufferWidth * e.drawingBufferHeight, i = _(t);
return r * 4 + r * n * 4 + r * i;
}
function y(e) {
return typeof e == "number";
}
function b(e, t) {
return [...e.webglObjectToMemory.keys()].filter((e) => e instanceof t).map((t) => e.webglObjectToMemory.get(t));
}
function x() {
return (/* @__PURE__ */ Error()).stack.split("\n").slice(2).filter((e) => !e.includes("webgl-memory.js")).join("\n");
}
let S = /* @__PURE__ */ new Set();
function C(e, t, n = {}) {
if (S.has(e)) return e;
S.add(e);
let r = n.origGLErrorFn || e.getError;
function i(e) {
let t = g(e), r = {
baseContext: e,
config: n,
apis: { gman_webgl_memory: { ctx: {
getMemoryInfo() {
let n = v(e, t);
return {
memory: {
...l,
drawingbuffer: n,
total: n + l.buffer + l.texture + l.renderbuffer
},
resources: { ...u }
};
},
getResourcesInfo(e) {
return b(r, e);
}
} } },
resources: {},
memory: {
texture: 0,
buffer: 0,
renderbuffer: 0
},
bindings: /* @__PURE__ */ new Map(),
defaultVertexArray: {},
webglObjectToMemory: /* @__PURE__ */ new Map()
}, i = /* @__PURE__ */ new Set([
"webgl",
"webgl2",
"webgl_lose_context"
]);
function a() {
r.bindings.clear(), r.webglObjectToMemory.clear(), r.webglObjectToMemory.set(r.defaultVertexArray, {}), r.currentVertexArray = r.defaultVertexArray, r.activeTextureUnit = 33984, [r.resources, r.memory].forEach(function(e) {
for (let t in e) e[t] = 0;
});
}
function o() {
a(), r.isContextLost = !0;
for (let [e, { ctx: t, origFuncs: n }] of [...Object.entries(r.apis)]) if (!i.has(e) && n) {
S.delete(t);
for (let [e, r] of Object.entries(n)) t[e] = r;
delete s[e];
}
}
function c() {
r.isContextLost = !1;
}
return e.canvas && (e.canvas.addEventListener("webglcontextlost", o), e.canvas.addEventListener("webglcontextrestored", c)), a(), r;
}
function a(e) {
return `${o.activeTextureUnit}_${e}`;
}
let o = n.sharedState || i(e);
n.sharedState = o;
let { apis: s, bindings: c, memory: l, resources: u, webglObjectToMemory: d } = o, f = {};
function m() {}
function _(e, t, n) {
return e[n || `create${t[0].toUpperCase()}${t.substr(1)}`] ? (u[t] = 0, function(e, n, r, i) {
o.isContextLost || (++u[t], d.set(i, {
size: 0,
stackCreated: x()
}));
}) : null;
}
function w(t, n = m, r) {
return e[r || `delete${t[0].toUpperCase()}${t.substr(1)}`] ? function(e, r, i) {
if (o.isContextLost) return;
let [a] = i, s = d.get(a);
s && (--u[t], n(a, s), d.delete(a));
} : null;
}
function T(e, t, n, r, i) {
if (o.isContextLost) return;
let a = c.get(e);
if (!a) throw Error(`no renderbuffer bound to ${e}`);
let s = d.get(a);
if (!s) throw Error(`unknown renderbuffer ${a}`);
let u = p(n, r, i, 1) * t;
l.renderbuffer -= s.size, s.size = u, s.stackUpdated = x(), l.renderbuffer += u;
}
let E = 34963, D = 5121, O = 34067, k = 35866, A = 34069, j = /* @__PURE__ */ new Set([
A,
34070,
34071,
34072,
34073,
34074
]);
function M(e) {
return j.has(e);
}
function N(e) {
e = M(e) ? O : e;
let t = a(e), n = c.get(t);
if (!n) throw Error(`no texture bound to ${e} on unit ${o.activeTextureUnit - 33984}`);
let r = d.get(n);
if (!r) throw Error(`unknown texture ${n}`);
return r;
}
function P(e, t, n, r, i, a, o, s) {
let c = e.size, u = p(r, i, a, o, s), d = M(t) ? t - A : 0;
e.mips = e.mips || [], e.mips[n] = e.mips[n] || [];
let f = e.mips[n][d] || {};
e.size -= f.size || 0, f.size = u, f.internalFormat = r, f.type = s, f.width = i, f.height = a, f.depth = o, e.mips[n][d] = f, e.size += u, l.texture -= c, l.texture += e.size, e.stackUpdated = x();
}
function F(e, t, n, r, i, a) {
let o = N(e), s = e === O ? 6 : 1, c = e === O ? A : e;
for (let l = 0; l < t; ++l) {
for (let e = 0; e < s; ++e) P(o, c + e, l, n, r, i, a);
r = Math.ceil(Math.max(r / 2, 1)), i = Math.ceil(Math.max(i / 2, 1)), a = e === k ? a : Math.ceil(Math.max(a / 2, 1));
}
}
function I(e, t, n) {
if (o.isContextLost) return;
let [r] = n;
o.currentVertexArray = r || o.defaultVertexArray;
}
function L(e, t) {
if (!o.isContextLost) switch (e) {
case E: {
let e = d.get(o.currentVertexArray);
e.elementArrayBuffer = t;
break;
}
default:
c.set(e, t);
break;
}
}
let R = {}, z = {
bufferData(e, t, n) {
if (o.isContextLost) return;
let [r, i, , , a = void 0] = n, s;
switch (r) {
case E:
s = d.get(o.currentVertexArray).elementArrayBuffer;
break;
default:
s = c.get(r);
break;
}
if (!s) throw Error(`no buffer bound to ${r}`);
let u = 0;
if (a !== void 0) u = a * i.BYTES_PER_ELEMENT;
else if (h(i)) u = i.byteLength;
else if (y(i)) u = i;
else throw Error(`unsupported bufferData src type ${i}`);
let f = d.get(s);
if (!f) throw Error(`unknown buffer ${s}`);
l.buffer -= f.size, f.size = u, f.stackUpdated = x(), l.buffer += u;
},
bindVertexArray: I,
bindVertexArrayOES: I,
bindBuffer(e, t, n) {
let [r, i] = n;
L(r, i);
},
bindBufferBase(e, t, n) {
let [r, , i] = n;
L(r, i);
},
bindBufferRange(e, t, n) {
let [r, , i, ,] = n;
L(r, i);
},
bindRenderbuffer(e, t, n) {
if (o.isContextLost) return;
let [r, i] = n;
c.set(r, i);
},
activeTexture(e, t, n) {
if (o.isContextLost) return;
let [r] = n;
o.activeTextureUnit = r;
},
bindTexture(e, t, n) {
if (o.isContextLost) return;
let [r, i] = n, s = a(r);
c.set(s, i);
},
copyTexImage2D(e, t, n) {
if (o.isContextLost) return;
let [r, i, a, , , s, c] = n;
P(N(r), r, i, a, s, c, 1, D);
},
createBuffer: _(e, "buffer"),
createFramebuffer: _(e, "framebuffer"),
createRenderbuffer: _(e, "renderbuffer"),
createProgram: _(e, "program"),
createQuery: _(e, "query"),
createShader: _(e, "shader"),
createSampler: _(e, "sampler"),
createTexture: _(e, "texture"),
createTransformFeedback: _(e, "transformFeedback"),
createVertexArray: _(e, "vertexArray"),
createVertexArrayOES: _(e, "vertexArray", "createVertexArrayOES"),
compressedTexImage2D(e, t, n) {
if (o.isContextLost) return;
let [r, i, a, s, c] = n;
P(N(r), r, i, a, s, c, 1, D);
},
compressedTexImage3D(e, t, n) {
if (o.isContextLost) return;
let [r, i, a, s, c, l] = n;
P(N(r), r, i, a, s, c, l, D);
},
deleteBuffer: w("buffer", function(e, t) {
l.buffer -= t.size;
}),
deleteFramebuffer: w("framebuffer"),
deleteProgram: w("program"),
deleteQuery: w("query"),
deleteRenderbuffer: w("renderbuffer", function(e, t) {
l.renderbuffer -= t.size;
}),
deleteSampler: w("sampler"),
deleteShader: w("shader"),
deleteSync: w("sync"),
deleteTexture: w("texture", function(e, t) {
l.texture -= t.size;
}),
deleteTransformFeedback: w("transformFeedback"),
deleteVertexArray: w("vertexArray"),
deleteVertexArrayOES: w("vertexArray", m, "deleteVertexArrayOES"),
fenceSync: function(e) {
if (!o.isContextLost && e.fenceSync) return u.sync = 0, function(e, t, n, r) {
++u.sync, d.set(r, { size: 0 });
};
}(e),
generateMipmap(e, t, n) {
if (o.isContextLost) return;
let [r] = n, i = N(r), a = i.parameters && i.parameters.get(33084) || 0, s = i.parameters && i.parameters.get(33085) || 1024, c = i.mips[a][0], { width: l, height: u, depth: d } = c, { internalFormat: f, type: p } = c, m = a + 1, h = r === O ? 6 : 1, g = r === O ? A : r;
for (; m <= s && !(l === 1 && u === 1 && (d === 1 || r === k));) {
l = Math.ceil(Math.max(l / 2, 1)), u = Math.ceil(Math.max(u / 2, 1)), d = r === k ? d : Math.ceil(Math.max(d / 2, 1));
for (let e = 0; e < h; ++e) P(i, g + e, m, f, l, u, d, p);
++m;
}
},
getSupportedExtensions(e, t, n, r) {
o.isContextLost || r.push("GMAN_webgl_memory");
},
renderbufferStorage(e, t, n) {
let [r, i, a, o] = n;
T(r, 1, i, a, o);
},
renderbufferStorageMultisample(e, t, n) {
let [r, i, a, o, s] = n;
T(r, i, a, o, s);
},
texImage2D(e, t, n) {
if (o.isContextLost) return;
let [r, i, a] = n, s, c, l;
if (n.length === 6) {
let e = n[5];
s = e.width, c = e.height, l = n[4];
} else s = n[3], c = n[4], l = n[7];
P(N(r), r, i, a, s, c, 1, l);
},
texImage3D(e, t, n) {
if (o.isContextLost) return;
let [r, i, a, s, c, l, , , u] = n;
P(N(r), r, i, a, s, c, l, u);
},
texParameteri(e, t, n) {
if (o.isContextLost) return;
let [r, i, a] = n, s = N(r);
s.parameters = s.parameters || /* @__PURE__ */ new Map(), s.parameters.set(i, a);
},
texStorage2D(e, t, n) {
let [r, i, a, o, s] = n;
F(r, i, a, o, s, 1);
},
texStorage3D(e, t, n) {
let [r, i, a, o, s, c] = n;
F(r, i, a, o, s, c);
}
}, B = { getExtension(e, t) {
if (o.isContextLost) return;
let i = e[t];
e[t] = function(...t) {
let a = t[0].toLowerCase(), o = s[a];
if (o) return o.ctx;
let c = i.call(e, ...t);
return c && C(c, a, {
...n,
origGLErrorFn: r
}), c;
};
} };
function V(e, t) {
let n = e[t], i = R[t] || m, a = z[t] || m;
if (i === m && z === m) return;
e[t] = function(...r) {
i(e, t, r);
let o = n.call(e, ...r);
return a(e, t, r, o), o;
};
let o = B[t];
o && o(e, t, r);
}
for (let t in e) typeof e[t] == "function" && (f[t] = e[t], V(e, t));
s[t.toLowerCase()] = {
ctx: e,
origFuncs: f
};
}
function w(e) {
let t = e.prototype.getContext;
e.prototype.getContext = function(e, ...n) {
let r = t.call(this, e, ...n);
return r && r.bindTexture && (C(r, e, {}), r.getExtension("GMAN_webgl_memory")), r;
};
}
typeof HTMLCanvasElement < "u" && w(HTMLCanvasElement), typeof OffscreenCanvas < "u" && w(OffscreenCanvas);
}));
//#endregion
//#region ../renderer/src/debug/components/Panel.module.css
var u = /* @__PURE__ */ e(t(), 1), d = r(), f = {
info: "_info_hhyz2_1",
toggle: "_toggle_hhyz2_9",
container: "_container_hhyz2_26",
left: "_left_hhyz2_40",
right: "_right_hhyz2_44"
}, p = n();
function m(e) {
let t = (0, l.c)(17), { corner: n, label: r, value: i } = e, [a, o] = (0, u.useState)(!1), s;
t[0] === e ? s = t[1] : (s = function(t, n) {
return Array.isArray(n) ? `[${n.join(", ")}]` : e.replacer ? e.replacer(t, n) : n;
}, t[0] = e, t[1] = s);
let c = s, d;
t[2] !== a || t[3] !== c || t[4] !== i ? (d = function() {
var e;
if (!a) return "";
let t = i;
if (typeof i == "object" && i) {
let e = Object.keys(i);
t = e.length === 1 ? i[e[0]] : i;
}
return ((e = JSON.stringify(t, c, 2)) == null ? "" : e).replaceAll("\"", "");
}, t[2] = a, t[3] = c, t[4] = i, t[5] = d) : d = t[5];
let m = d, g = `${f.container} ${f[n]}`, _;
t[6] === Symbol.for("react.memo_cache_sentinel") ? (_ = () => o(h), t[6] = _) : _ = t[6];
let v = a ? "Hide" : "Show", y;
t[7] !== r || t[8] !== v ? (y = /* @__PURE__ */ (0, p.jsxs)("button", {
className: f.toggle,
onClick: _,
children: [
v,
" ",
r
]
}), t[7] = r, t[8] = v, t[9] = y) : y = t[9];
let b;
t[10] !== a || t[11] !== m ? (b = a && /* @__PURE__ */ (0, p.jsx)("div", {
className: f.info,
children: m()
}), t[10] = a, t[11] = m, t[12] = b) : b = t[12];
let x;
return t[13] !== g || t[14] !== y || t[15] !== b ? (x = /* @__PURE__ */ (0, p.jsxs)("div", {
className: g,
children: [y, b]
}), t[13] = g, t[14] = y, t[15] = b, t[16] = x) : x = t[16], x;
}
function h(e) {
return !e;
}
function g(e) {
let t = (0, l.c)(9), { corner: n, label: r, value: i, replacer: a } = e, [o] = (0, u.useState)(_), s = (0, u.useRef)(null), c = (0, u.useRef)(!1), f, h;
t[0] === o ? (f = t[1], h = t[2]) : (f = () => {
var e;
c.current = !1, document.body.appendChild(o);
let t = (e = s.current) == null ? (0, d.createRoot)(o) : e;
return s.current = t, () => {
o.remove(), c.current = !0, Promise.resolve().then(() => {
var e;
c.current && ((e = s.current) == null || e.unmount(), s.current = null);
});
};
}, h = [o], t[0] = o, t[1] = f, t[2] = h), (0, u.useEffect)(f, h);
let g, v;
return t[3] !== n || t[4] !== r || t[5] !== a || t[6] !== i ? (g = () => {
var e;
(e = s.current) == null || e.render(/* @__PURE__ */ (0, p.jsx)(m, {
corner: n,
label: r,
value: i,
replacer: a
}));
}, v = [
n,
r,
i,
a
], t[3] = n, t[4] = r, t[5] = a, t[6] = i, t[7] = g, t[8] = v) : (g = t[7], v = t[8]), (0, u.useEffect)(g, v), null;
}
function _() {
return document.createElement("div");
}
//#endregion
//#region ../renderer/src/debug/components/DebugPanelProvider.tsx
function v(e) {
let t = (0, l.c)(7), { children: n } = e, r;
t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = {}, t[0] = r) : r = t[0];
let [i, a] = (0, u.useState)(r), o;
t[1] === Symbol.for("react.memo_cache_sentinel") ? (o = {
set(e, t) {
a((n) => {
if (e in n) return Object.is(n[e], t) ? n : {
...n,
[e]: t
};
let r = {};
for (let i of [...Object.keys(n), e].sort()) r[i] = i === e ? t : n[i];
return r;
});
},
remove(e) {
a((t) => {
if (!(e in t)) return t;
let n = { ...t };
return delete n[e], n;
});
}
}, t[1] = o) : o = t[1];
let s = o, d;
t[2] === i ? d = t[3] : (d = /* @__PURE__ */ (0, p.jsx)(g, {
corner: "right",
label: "Debug",
value: i
}), t[2] = i, t[3] = d);
let f;
return t[4] !== n || t[5] !== d ? (f = /* @__PURE__ */ (0, p.jsxs)(c, {
value: s,
children: [n, d]
}), t[4] = n, t[5] = d, t[6] = f) : f = t[6], f;
}
//#endregion
//#region ../../node_modules/.pnpm/lil-gui@0.21.0/node_modules/lil-gui/dist/lil-gui.esm.js
var y = class e {
constructor(t, n, r, i, a = "div") {
this.parent = t, this.object = n, this.property = r, this._disabled = !1, this._hidden = !1, this.initialValue = this.getValue(), this.domElement = document.createElement(a), this.domElement.classList.add("lil-controller"), this.domElement.classList.add(i), this.$name = document.createElement("div"), this.$name.classList.add("lil-name"), e.nextNameID = e.nextNameID || 0, this.$name.id = `lil-gui-name-${++e.nextNameID}`, this.$widget = document.createElement("div"), this.$widget.classList.add("lil-widget"), this.$disable = this.$widget, this.domElement.appendChild(this.$name), this.domElement.appendChild(this.$widget), this.domElement.addEventListener("keydown", (e) => e.stopPropagation()), this.domElement.addEventListener("keyup", (e) => e.stopPropagation()), this.parent.children.push(this), this.parent.controllers.push(this), this.parent.$children.appendChild(this.domElement), this._listenCallback = this._listenCallback.bind(this), this.name(r);
}
name(e) {
return this._name = e, this.$name.textContent = e, this;
}
onChange(e) {
return this._onChange = e, this;
}
_callOnChange() {
this.parent._callOnChange(this), this._onChange !== void 0 && this._onChange.call(this, this.getValue()), this._changed = !0;
}
onFinishChange(e) {
return this._onFinishChange = e, this;
}
_callOnFinishChange() {
this._changed && (this.parent._callOnFinishChange(this), this._onFinishChange !== void 0 && this._onFinishChange.call(this, this.getValue())), this._changed = !1;
}
reset() {
return this.setValue(this.initialValue), this._callOnFinishChange(), this;
}
enable(e = !0) {
return this.disable(!e);
}
disable(e = !0) {
return e === this._disabled ? this : (this._disabled = e, this.domElement.classList.toggle("lil-disabled", e), this.$disable.toggleAttribute("disabled", e), this);
}
show(e = !0) {
return this._hidden = !e, this.domElement.style.display = this._hidden ? "none" : "", this;
}
hide() {
return this.show(!1);
}
options(e) {
let t = this.parent.add(this.object, this.property, e);
return t.name(this._name), this.destroy(), t;
}
min(e) {
return this;
}
max(e) {
return this;
}
step(e) {
return this;
}
decimals(e) {
return this;
}
listen(e = !0) {
return this._listening = e, this._listenCallbackID !== void 0 && (cancelAnimationFrame(this._listenCallbackID), this._listenCallbackID = void 0), this._listening && this._listenCallback(), this;
}
_listenCallback() {
this._listenCallbackID = requestAnimationFrame(this._listenCallback);
let e = this.save();
e !== this._listenPrevValue && this.updateDisplay(), this._listenPrevValue = e;
}
getValue() {
return this.object[this.property];
}
setValue(e) {
return this.getValue() !== e && (this.object[this.property] = e, this._callOnChange(), this.updateDisplay()), this;
}
updateDisplay() {
return this;
}
load(e) {
return this.setValue(e), this._callOnFinishChange(), this;
}
save() {
return this.getValue();
}
destroy() {
this.listen(!1), this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.controllers.splice(this.parent.controllers.indexOf(this), 1), this.parent.$children.removeChild(this.domElement);
}
}, b = class extends y {
constructor(e, t, n) {
super(e, t, n, "lil-boolean", "label"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "checkbox"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$widget.appendChild(this.$input), this.$input.addEventListener("change", () => {
this.setValue(this.$input.checked), this._callOnFinishChange();
}), this.$disable = this.$input, this.updateDisplay();
}
updateDisplay() {
return this.$input.checked = this.getValue(), this;
}
};
function x(e) {
let t, n;
return (t = e.match(/(#|0x)?([a-f0-9]{6})/i)) ? n = t[2] : (t = e.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/)) ? n = parseInt(t[1]).toString(16).padStart(2, 0) + parseInt(t[2]).toString(16).padStart(2, 0) + parseInt(t[3]).toString(16).padStart(2, 0) : (t = e.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i)) && (n = t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), n ? "#" + n : !1;
}
var S = {
isPrimitive: !0,
match: (e) => typeof e == "string",
fromHexString: x,
toHexString: x
}, C = {
isPrimitive: !0,
match: (e) => typeof e == "number",
fromHexString: (e) => parseInt(e.substring(1), 16),
toHexString: (e) => "#" + e.toString(16).padStart(6, 0)
}, w = [
S,
C,
{
isPrimitive: !1,
match: (e) => Array.isArray(e) || ArrayBuffer.isView(e),
fromHexString(e, t, n = 1) {
let r = C.fromHexString(e);
t[0] = (r >> 16 & 255) / 255 * n, t[1] = (r >> 8 & 255) / 255 * n, t[2] = (r & 255) / 255 * n;
},
toHexString([e, t, n], r = 1) {
r = 255 / r;
let i = e * r << 16 ^ t * r << 8 ^ n * r << 0;
return C.toHexString(i);
}
},
{
isPrimitive: !1,
match: (e) => Object(e) === e,
fromHexString(e, t, n = 1) {
let r = C.fromHexString(e);
t.r = (r >> 16 & 255) / 255 * n, t.g = (r >> 8 & 255) / 255 * n, t.b = (r & 255) / 255 * n;
},
toHexString({ r: e, g: t, b: n }, r = 1) {
r = 255 / r;
let i = e * r << 16 ^ t * r << 8 ^ n * r << 0;
return C.toHexString(i);
}
}
];
function T(e) {
return w.find((t) => t.match(e));
}
var E = class extends y {
constructor(e, t, n, r) {
super(e, t, n, "lil-color"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "color"), this.$input.setAttribute("tabindex", -1), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$text = document.createElement("input"), this.$text.setAttribute("type", "text"), this.$text.setAttribute("spellcheck", "false"), this.$text.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("lil-display"), this.$display.appendChild(this.$input), this.$widget.appendChild(this.$display), this.$widget.appendChild(this.$text), this._format = T(this.initialValue), this._rgbScale = r, this._initialValueHexString = this.save(), this._textFocused = !1, this.$input.addEventListener("input", () => {
this._setValueFromHexString(this.$input.value);
}), this.$input.addEventListener("blur", () => {
this._callOnFinishChange();
}), this.$text.addEventListener("input", () => {
let e = x(this.$text.value);
e && this._setValueFromHexString(e);
}), this.$text.addEventListener("focus", () => {
this._textFocused = !0, this.$text.select();
}), this.$text.addEventListener("blur", () => {
this._textFocused = !1, this.updateDisplay(), this._callOnFinishChange();
}), this.$disable = this.$text, this.updateDisplay();
}
reset() {
return this._setValueFromHexString(this._initialValueHexString), this;
}
_setValueFromHexString(e) {
if (this._format.isPrimitive) {
let t = this._format.fromHexString(e);
this.setValue(t);
} else this._format.fromHexString(e, this.getValue(), this._rgbScale), this._callOnChange(), this.updateDisplay();
}
save() {
return this._format.toHexString(this.getValue(), this._rgbScale);
}
load(e) {
return this._setValueFromHexString(e), this._callOnFinishChange(), this;
}
updateDisplay() {
return this.$input.value = this._format.toHexString(this.getValue(), this._rgbScale), this._textFocused || (this.$text.value = this.$input.value.substring(1)), this.$display.style.backgroundColor = this.$input.value, this;
}
}, D = class extends y {
constructor(e, t, n) {
super(e, t, n, "lil-function"), this.$button = document.createElement("button"), this.$button.appendChild(this.$name), this.$widget.appendChild(this.$button), this.$button.addEventListener("click", (e) => {
e.preventDefault(), this.getValue().call(this.object), this._callOnChange();
}), this.$button.addEventListener("touchstart", () => {}, { passive: !0 }), this.$disable = this.$button;
}
}, O = class extends y {
constructor(e, t, n, r, i, a) {
super(e, t, n, "lil-number"), this._initInput(), this.min(r), this.max(i);
let o = a !== void 0;
this.step(o ? a : this._getImplicitStep(), o), this.updateDisplay();
}
decimals(e) {
return this._decimals = e, this.updateDisplay(), this;
}
min(e) {
return this._min = e, this._onUpdateMinMax(), this;
}
max(e) {
return this._max = e, this._onUpdateMinMax(), this;
}
step(e, t = !0) {
return this._step = e, this._stepExplicit = t, this;
}
updateDisplay() {
let e = this.getValue();
if (this._hasSlider) {
let t = (e - this._min) / (this._max - this._min);
t = Math.max(0, Math.min(t, 1)), this.$fill.style.width = t * 100 + "%";
}
return this._inputFocused || (this.$input.value = this._decimals === void 0 ? e : e.toFixed(this._decimals)), this;
}
_initInput() {
this.$input = document.createElement("input"), this.$input.setAttribute("type", "text"), this.$input.setAttribute("aria-labelledby", this.$name.id), window.matchMedia("(pointer: coarse)").matches && (this.$input.setAttribute("type", "number"), this.$input.setAttribute("step", "any")), this.$widget.appendChild(this.$input), this.$disable = this.$input;
let e = () => {
let e = parseFloat(this.$input.value);
isNaN(e) || (this._stepExplicit && (e = this._snap(e)), this.setValue(this._clamp(e)));
}, t = (e) => {
let t = parseFloat(this.$input.value);
isNaN(t) || (this._snapClampSetValue(t + e), this.$input.value = this.getValue());
}, n = (e) => {
e.key === "Enter" && this.$input.blur(), e.code === "ArrowUp" && (e.preventDefault(), t(this._step * this._arrowKeyMultiplier(e))), e.code === "ArrowDown" && (e.preventDefault(), t(this._step * this._arrowKeyMultiplier(e) * -1));
}, r = (e) => {
this._inputFocused && (e.preventDefault(), t(this._step * this._normalizeMouseWheel(e)));
}, i = !1, a, o, s, c, l, u = (e) => {
a = e.clientX, o = s = e.clientY, i = !0, c = this.getValue(), l = 0, window.addEventListener("mousemove", d), window.addEventListener("mouseup", f);
}, d = (e) => {
if (i) {
let t = e.clientX - a, n = e.clientY - o;
Math.abs(n) > 5 ? (e.preventDefault(), this.$input.blur(), i = !1, this._setDraggingStyle(!0, "vertical")) : Math.abs(t) > 5 && f();
}
if (!i) {
let t = e.clientY - s;
l -= t * this._step * this._arrowKeyMultiplier(e), c + l > this._max ? l = this._max - c : c + l < this._min && (l = this._min - c), this._snapClampSetValue(c + l);
}
s = e.clientY;
}, f = () => {
this._setDraggingStyle(!1, "vertical"), this._callOnFinishChange(), window.removeEventListener("mousemove", d), window.removeEventListener("mouseup", f);
};
this.$input.addEventListener("input", e), this.$input.addEventListener("keydown", n), this.$input.addEventListener("wheel", r, { passive: !1 }), this.$input.addEventListener("mousedown", u), this.$input.addEventListener("focus", () => {
this._inputFocused = !0;
}), this.$input.addEventListener("blur", () => {
this._inputFocused = !1, this.updateDisplay(), this._callOnFinishChange();
});
}
_initSlider() {
this._hasSlider = !0, this.$slider = document.createElement("div"), this.$slider.classList.add("lil-slider"), this.$fill = document.createElement("div"), this.$fill.classList.add("lil-fill"), this.$slider.appendChild(this.$fill), this.$widget.insertBefore(this.$slider, this.$input), this.domElement.classList.add("lil-has-slider");
let e = (e, t, n, r, i) => (e - t) / (n - t) * (i - r) + r, t = (t) => {
let n = this.$slider.getBoundingClientRect(), r = e(t, n.left, n.right, this._min, this._max);
this._snapClampSetValue(r);
}, n = (e) => {
this._setDraggingStyle(!0), t(e.clientX), window.addEventListener("mousemove", r), window.addEventListener("mouseup", i);
}, r = (e) => {
t(e.clientX);
}, i = () => {
this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", i);
}, a = !1, o, s, c = (e) => {
e.preventDefault(), this._setDraggingStyle(!0), t(e.touches[0].clientX), a = !1;
}, l = (e) => {
e.touches.length > 1 || (this._hasScrollBar ? (o = e.touches[0].clientX, s = e.touches[0].clientY, a = !0) : c(e), window.addEventListener("touchmove", u, { passive: !1 }), window.addEventListener("touchend", d));
}, u = (e) => {
if (a) {
let t = e.touches[0].clientX - o, n = e.touches[0].clientY - s;
Math.abs(t) > Math.abs(n) ? c(e) : (window.removeEventListener("touchmove", u), window.removeEventListener("touchend", d));
} else e.preventDefault(), t(e.touches[0].clientX);
}, d = () => {
this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("touchmove", u), window.removeEventListener("touchend", d);
}, f = this._callOnFinishChange.bind(this), p;
this.$slider.addEventListener("mousedown", n), this.$slider.addEventListener("touchstart", l, { passive: !1 }), this.$slider.addEventListener("wheel", (e) => {
if (Math.abs(e.deltaX) < Math.abs(e.deltaY) && this._hasScrollBar) return;
e.preventDefault();
let t = this._normalizeMouseWheel(e) * this._step;
this._snapClampSetValue(this.getValue() + t), this.$input.value = this.getValue(), clearTimeout(p), p = setTimeout(f, 400);
}, { passive: !1 });
}
_setDraggingStyle(e, t = "horizontal") {
this.$slider && this.$slider.classList.toggle("lil-active", e), document.body.classList.toggle("lil-dragging", e), document.body.classList.toggle(`lil-${t}`, e);
}
_getImplicitStep() {
return this._hasMin && this._hasMax ? (this._max - this._min) / 1e3 : .1;
}
_onUpdateMinMax() {
!this._hasSlider && this._hasMin && this._hasMax && (this._stepExplicit || this.step(this._getImplicitStep(), !1), this._initSlider(), this.updateDisplay());
}
_normalizeMouseWheel(e) {
let { deltaX: t, deltaY: n } = e;
return Math.floor(e.deltaY) !== e.deltaY && e.wheelDelta && (t = 0, n = -e.wheelDelta / 120, n *= this._stepExplicit ? 1 : 10), t + -n;
}
_arrowKeyMultiplier(e) {
let t = this._stepExplicit ? 1 : 10;
return e.shiftKey ? t *= 10 : e.altKey && (t /= 10), t;
}
_snap(e) {
let t = 0;
return this._hasMin ? t = this._min : this._hasMax && (t = this._max), e -= t, e = Math.round(e / this._step) * this._step, e += t, e = parseFloat(e.toPrecision(15)), e;
}
_clamp(e) {
return e < this._min && (e = this._min), e > this._max && (e = this._max), e;
}
_snapClampSetValue(e) {
this.setValue(this._clamp(this._snap(e)));
}
get _hasScrollBar() {
let e = this.parent.root.$children;
return e.scrollHeight > e.clientHeight;
}
get _hasMin() {
return this._min !== void 0;
}
get _hasMax() {
return this._max !== void 0;
}
}, k = class extends y {
constructor(e, t, n, r) {
super(e, t, n, "lil-option"), this.$select = document.createElement("select"), this.$select.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("lil-display"), this.$select.addEventListener("change", () => {
this.setValue(this._values[this.$select.selectedIndex]), this._callOnFinishChange();
}), this.$select.addEventListener("focus", () => {
this.$display.classList.add("lil-focus");
}), this.$select.addEventListener("blur", () => {
this.$display.classList.remove("lil-focus");
}), this.$widget.appendChild(this.$select), this.$widget.appendChild(this.$display), this.$disable = this.$select, this.options(r);
}
options(e) {
return this._values = Array.isArray(e) ? e : Object.values(e), this._names = Array.isArray(e) ? e : Object.keys(e), this.$select.replaceChildren(), this._names.forEach((e) => {
let t = document.createElement("option");
t.textContent = e, this.$select.appendChild(t);
}), this.updateDisplay(), this;
}
updateDisplay() {
let e = this.getValue(), t = this._values.indexOf(e);
return this.$select.selectedIndex = t, this.$display.textContent = t === -1 ? e : this._names[t], this;
}
}, A = class extends y {
constructor(e, t, n) {
super(e, t, n, "lil-string"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "text"), this.$input.setAttribute("spellcheck", "false"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$input.addEventListener("input", () => {
this.setValue(this.$input.value);
}), this.$input.addEventListener("keydown", (e) => {
e.code === "Enter" && this.$input.blur();
}), this.$input.addEventListener("blur", () => {
this._callOnFinishChange();
}), this.$widget.appendChild(this.$input), this.$disable = this.$input, this.updateDisplay();
}
updateDisplay() {
return this.$input.value = this.getValue(), this;
}
}, j = ".lil-gui {\n font-family: var(--font-family);\n font-size: var(--font-size);\n line-height: 1;\n font-weight: normal;\n font-style: normal;\n text-align: left;\n color: var(--text-color);\n user-select: none;\n -webkit-user-select: none;\n touch-action: manipulation;\n --background-color: #1f1f1f;\n --text-color: #ebebeb;\n --title-background-color: #111111;\n --title-text-color: #ebebeb;\n --widget-color: #424242;\n --hover-color: #4f4f4f;\n --focus-color: #595959;\n --number-color: #2cc9ff;\n --string-color: #a2db3c;\n --font-size: 11px;\n --input-font-size: 11px;\n --font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Arial, sans-serif;\n --font-family-mono: Menlo, Monaco, Consolas, \"Droid Sans Mono\", monospace;\n --padding: 4px;\n --spacing: 4px;\n --widget-height: 20px;\n --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);\n --name-width: 45%;\n --slider-knob-width: 2px;\n --slider-input-width: 27%;\n --color-input-width: 27%;\n --slider-input-min-width: 45px;\n --color-input-min-width: 45px;\n --folder-indent: 7px;\n --widget-padding: 0 0 0 3px;\n --widget-border-radius: 2px;\n --checkbox-size: calc(0.75 * var(--widget-height));\n --scrollbar-width: 5px;\n}\n.lil-gui, .lil-gui * {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n.lil-gui.lil-root {\n width: var(--width, 245px);\n display: flex;\n flex-direction: column;\n background: var(--background-color);\n}\n.lil-gui.lil-root > .lil-title {\n background: var(--title-background-color);\n color: var(--title-text-color);\n}\n.lil-gui.lil-root > .lil-children {\n overflow-x: hidden;\n overflow-y: auto;\n}\n.lil-gui.lil-root > .lil-children::-webkit-scrollbar {\n width: var(--scrollbar-width);\n height: var(--scrollbar-width);\n background: var(--background-color);\n}\n.lil-gui.lil-root > .lil-children::-webkit-scrollbar-thumb {\n border-radius: var(--scrollbar-width);\n background: var(--focus-color);\n}\n@media (pointer: coarse) {\n .lil-gui.lil-allow-touch-styles, .lil-gui.lil-allow-touch-styles .lil-gui {\n --widget-height: 28px;\n --padding: 6px;\n --spacing: 6px;\n --font-size: 13px;\n --input-font-size: 16px;\n --folder-indent: 10px;\n --scrollbar-width: 7px;\n --slider-input-min-width: 50px;\n --color-input-min-width: 65px;\n }\n}\n.lil-gui.lil-force-touch-styles, .lil-gui.lil-force-touch-styles .lil-gui {\n --widget-height: 28px;\n --padding: 6px;\n --spacing: 6px;\n --font-size: 13px;\n --input-font-size: 16px;\n --folder-indent: 10px;\n --scrollbar-width: 7px;\n --slider-input-min-width: 50px;\n --color-input-min-width: 65px;\n}\n.lil-gui.lil-auto-place, .lil-gui.autoPlace {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 1001;\n}\n\n.lil-controller {\n display: flex;\n align-items: center;\n padding: 0 var(--padding);\n margin: var(--spacing) 0;\n}\n.lil-controller.lil-disabled {\n opacity: 0.5;\n}\n.lil-controller.lil-disabled, .lil-controller.lil-disabled * {\n pointer-events: none !important;\n}\n.lil-controller > .lil-name {\n min-width: var(--name-width);\n flex-shrink: 0;\n white-space: pre;\n padding-right: var(--spacing);\n line-height: var(--widget-height);\n}\n.lil-controller .lil-widget {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n min-height: var(--widget-height);\n}\n.lil-controller.lil-string input {\n color: var(--string-color);\n}\n.lil-controller.lil-boolean {\n cursor: pointer;\n}\n.lil-controller.lil-color .lil-display {\n width: 100%;\n height: var(--widget-height);\n border-radius: var(--widget-border-radius);\n position: relative;\n}\n@media (hover: hover) {\n .lil-controller.lil-color .lil-display:hover:before {\n content: \" \";\n display: block;\n position: absolute;\n border-radius: var(--widget-border-radius);\n border: 1px solid #fff9;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n}\n.lil-controller.lil-color input[type=color] {\n opacity: 0;\n width: 100%;\n height: 100%;\n cursor: pointer;\n}\n.lil-controller.lil-color input[type=text] {\n margin-left: var(--spacing);\n font-family: var(--font-family-mono);\n min-width: var(--color-input-min-width);\n width: var(--color-input-width);\n flex-shrink: 0;\n}\n.lil-controller.lil-option select {\n opacity: 0;\n position: absolute;\n width: 100%;\n max-width: 100%;\n}\n.lil-controller.lil-option .lil-display {\n position: relative;\n pointer-events: none;\n border-radius: var(--widget-border-radius);\n height: var(--widget-height);\n line-height: var(--widget-height);\n max-width: 100%;\n overflow: hidden;\n word-break: break-all;\n padding-left: 0.55em;\n padding-right: 1.75em;\n background: var(--widget-color);\n}\n@media (hover: hover) {\n .lil-controller.lil-option .lil-display.lil-focus {\n background: var(--focus-color);\n }\n}\n.lil-controller.lil-option .lil-display.lil-active {\n background: var(--focus-color);\n}\n.lil-controller.lil-option .lil-display:after {\n font-family: \"lil-gui\";\n content: \"↕\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n padding-right: 0.375em;\n}\n.lil-controller.lil-option .lil-widget,\n.lil-controller.lil-option select {\n cursor: pointer;\n}\n@media (hover: hover) {\n .lil-controller.lil-option .lil-widget:hover .lil-display {\n background: var(--hover-color);\n }\n}\n.lil-controller.lil-number input {\n color: var(--number-color);\n}\n.lil-controller.lil-number.lil-has-slider input {\n margin-left: var(--spacing);\n width: var(--slider-input-width);\n min-width: var(--slider-input-min-width);\n flex-shrink: 0;\n}\n.lil-controller.lil-number .lil-slider {\n width: 100%;\n height: var(--widget-height);\n background: var(--widget-color);\n border-radius: var(--widget-border-radius);\n padding-right: var(--slider-knob-width);\n overflow: hidden;\n cursor: ew-resize;\n touch-action: pan-y;\n}\n@media (hover: hover) {\n .lil-controller.lil-number .lil-slider:hover {\n background: var(--hover-color);\n }\n}\n.lil-controller.lil-number .lil-slider.lil-active {\n background: var(--focus-color);\n}\n.lil-controller.lil-number .lil-slider.lil-active .lil-fill {\n opacity: 0.95;\n}\n.lil-controller.lil-number .lil-fill {\n height: 100%;\n border-right: var(--slider-knob-width) solid var(--number-color);\n box-sizing: content-box;\n}\n\n.lil-dragging .lil-gui {\n --hover-color: var(--widget-color);\n}\n.lil-dragging * {\n cursor: ew-resize !important;\n}\n.lil-dragging.lil-vertical * {\n cursor: ns-resize !important;\n}\n\n.lil-gui .lil-title {\n height: var(--title-height);\n font-weight: 600;\n padding: 0 var(--padding);\n width: 100%;\n text-align: left;\n background: none;\n text-decoration-skip: objects;\n}\n.lil-gui .lil-title:before {\n font-family: \"lil-gui\";\n content: \"▾\";\n padding-right: 2px;\n display: inline-block;\n}\n.lil-gui .lil-title:active {\n background: var(--title-background-color);\n opacity: 0.75;\n}\n@media (hover: hover) {\n body:not(.lil-dragging) .lil-gui .lil-title:hover {\n background: var(--title-background-color);\n opacity: 0.85;\n }\n .lil-gui .lil-title:focus {\n text-decoration: underline var(--focus-color);\n }\n}\n.lil-gui.lil-root > .lil-title:focus {\n text-decoration: none !important;\n}\n.lil-gui.lil-closed > .lil-title:before {\n content: \"▸\";\n}\n.lil-gui.lil-closed > .lil-children {\n transform: translateY(-7px);\n opacity: 0;\n}\n.lil-gui.lil-closed:not(.lil-transition) > .lil-children {\n display: none;\n}\n.lil-gui.lil-transition > .lil-children {\n transition-duration: 300ms;\n transition-property: height, opacity, transform;\n transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);\n overflow: hidden;\n pointer-events: none;\n}\n.lil-gui .lil-children:empty:before {\n content: \"Empty\";\n padding: 0 var(--padding);\n margin: var(--spacing) 0;\n display: block;\n height: var(--widget-height);\n font-style: italic;\n line-height: var(--widget-height);\n opacity: 0.5;\n}\n.lil-gui.lil-root > .lil-children > .lil-gui > .lil-title {\n border: 0 solid var(--widget-color);\n border-width: 1px 0;\n transition: border-color 300ms;\n}\n.lil-gui.lil-root > .lil-children > .lil-gui.lil-closed > .lil-title {\n border-bottom-color: transparent;\n}\n.lil-gui + .lil-controller {\n border-top: 1px solid var(--widget-color);\n margin-top: 0;\n padding-top: var(--spacing);\n}\n.lil-gui .lil-gui .lil-gui > .lil-title {\n border: none;\n}\n.lil-gui .lil-gui .lil-gui > .lil-children {\n border: none;\n margin-left: var(--folder-indent);\n border-left: 2px solid var(--widget-color);\n}\n.lil-gui .lil-gui .lil-controller {\n border: none;\n}\n\n.lil-gui label, .lil-gui input, .lil-gui button {\n -webkit-tap-highlight-color: transparent;\n}\n.lil-gui input {\n border: 0;\n outline: none;\n font-family: var(--font-family);\n font-size: var(--input-font-size);\n border-radius: var(--widget-border-radius);\n height: var(--widget-height);\n background: var(--widget-color);\n color: var(--text-color);\n width: 100%;\n}\n@media (hover: hover) {\n .lil-gui input:hover {\n background: var(--hover-color);\n }\n .lil-gui input:active {\n background: var(--focus-color);\n }\n}\n.lil-gui input:disabled {\n opacity: 1;\n}\n.lil-gui input[type=text],\n.lil-gui input[type=number] {\n padding: var(--widget-padding);\n -moz-appearance: textfield;\n}\n.lil-gui input[type=text]:focus,\n.lil-gui input[type=number]:focus {\n background: var(--focus-color);\n}\n.lil-gui input[type=checkbox] {\n appearance: none;\n width: var(--checkbox-size);\n height: var(--checkbox-size);\n border-radius: var(--widget-border-radius);\n text-align: center;\n cursor: pointer;\n}\n.lil-gui input[type=checkbox]:checked:before {\n font-family: \"lil-gui\";\n content: \"✓\";\n font-size: var(--checkbox-size);\n line-height: var(--checkbox-size);\n}\n@media (hover: hover) {\n .lil-gui input[type=checkbox]:focus {\n box-shadow: inset 0 0 0 1px var(--focus-color);\n }\n}\n.lil-gui button {\n outline: none;\n cursor: pointer;\n font-family: var(--font-family);\n font-size: var(--font-size);\n color: var(--text-color);\n width: 100%;\n border: none;\n}\n.lil-gui .lil-controller button {\n height: var(--widget-height);\n text-transform: none;\n background: var(--widget-color);\n border-radius: var(--widget-border-radius);\n}\n@media (hover: hover) {\n .lil-gui .lil-controller button:hover {\n background: var(--hover-color);\n }\n .lil-gui .lil-controller button:focus {\n box-shadow: inset 0 0 0 1px var(--focus-color);\n }\n}\n.lil-gui .lil-controller button:active {\n background: var(--focus-color);\n}\n\n@font-face {\n font-family: \"lil-gui\";\n src: url(\"data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAALkAAsAAAAABtQAAAKVAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACDMgqBBIEbATYCJAMUCwwABCAFhAoHgQQbHAbIDiUFEYVARAAAYQTVWNmz9MxhEgodq49wYRUFKE8GWNiUBxI2LBRaVnc51U83Gmhs0Q7JXWMiz5eteLwrKwuxHO8VFxUX9UpZBs6pa5ABRwHA+t3UxUnH20EvVknRerzQgX6xC/GH6ZUvTcAjAv122dF28OTqCXrPuyaDER30YBA1xnkVutDDo4oCi71Ca7rrV9xS8dZHbPHefsuwIyCpmT7j+MnjAH5X3984UZoFFuJ0yiZ4XEJFxjagEBeqs+e1iyK8Xf/nOuwF+vVK0ur765+vf7txotUi0m3N0m/84RGSrBCNrh8Ee5GjODjF4gnWP+dJrH/Lk9k4oT6d+gr6g/wssA2j64JJGP6cmx554vUZnpZfn6ZfX2bMwPPrlANsB86/DiHjhl0OP+c87+gaJo/gY084s3HoYL/ZkWHTRfBXvvoHnnkHvngKun4KBE/ede7tvq3/vQOxDXB1/fdNz6XbPdcr0Vhpojj9dG+owuSKFsslCi1tgEjirjXdwMiov2EioadxmqTHUCIwo8NgQaeIasAi0fTYSPTbSmwbMOFduyh9wvBrESGY0MtgRjtgQR8Q1bRPohn2UoCRZf9wyYANMXFeJTysqAe0I4mrherOekFdKMrYvJjLvOIUM9SuwYB5DVZUwwVjJJOaUnZCmcEkIZZrKqNvRGRMvmFZsmhP4VMKCSXBhSqUBxgMS7h0cZvEd71AWkEhGWaeMFcNnpqyJkyXgYL7PQ1MoSq0wDAkRtJIijkZSmqYTiSImfLiSWXIZwhRh3Rug2X0kk1Dgj+Iu43u5p98ghopcpSo0Uyc8SnjlYX59WUeaMoDqmVD2TOWD9a4pCRAzf2ECgwGcrHjPOWY9bNxq/OL3I/QjwEAAAA=\") format(\"woff2\");\n}";
function M(e) {
let t = document.createElement("style");
t.innerHTML = e;
let n = document.querySelector("head link[rel=stylesheet], head style");
n ? document.head.insertBefore(t, n) : document.head.appendChild(t);
}
var N = !1, P = class e {
constructor({ parent: e, autoPlace: t = e === void 0, container: n, width: r, title: i = "Controls", closeFolders: a = !1, injectStyles: o = !0, touchStyles: s = !0 } = {}) {
if (this.parent = e, this.root = e ? e.root : this, this.children = [], this.controllers = [], this.folders = [], this._closed = !1, this._hidden = !1, this.domElement = document.createElement("div"), this.domElement.classList.add("lil-gui"), this.$title = document.createElement("button"), this.$title.classList.add("lil-title"), this.$title.setAttribute("aria-expanded", !0), this.$title.addEventListener("click", () => this.openAnimated(this._closed)), this.$title.addEventListener("touchstart", () => {}, { passive: !0 }), this.$children = document.createElement("div"), this.$children.classList.add("lil-children"), this.domElement.appendChild(this.$title), this.domElement.appendChild(this.$children), this.title(i), this.parent) {
this.parent.children.push(this), this.parent.folders.push(this), this.parent.$children.appendChild(this.domElement);
return;
}
this.domElement.classList.add("lil-root"), s && this.domElement.classList.add("lil-allow-touch-styles"), !N && o && (M(j), N = !0), n ? n.appendChild(this.domElement) : t && (this.domElement.classList.add("lil-auto-place", "autoPlace"), document.body.appendChild(this.domElement)), r && this.domElement.style.setProperty("--width", r + "px"), this._closeFolders = a;
}
add(e, t, n, r, i) {
if (Object(n) === n) return new k(this, e, t, n);
let a = e[t];
switch (typeof a) {
case "number": return new O(this, e, t, n, r, i);
case "boolean": return new b(this, e, t);
case "string": return new A(this, e, t);
case "function": return new D(this, e, t);
}
console.error("gui.add failed\n property:", t, "\n object:", e, "\n value:", a);
}
addColor(e, t, n = 1) {
return new E(this, e, t, n);
}
addFolder(t) {
let n = new e({
parent: this,
title: t
});
return this.root._closeFolders && n.close(), n;
}
load(e, t = !0) {
return e.controllers && this.controllers.forEach((t) => {
t instanceof D || t._name in e.controllers && t.load(e.controllers[t._name]);
}), t && e.folders && this.folders.forEach((t) => {
t._title in e.folders && t.load(e.folders[t._title]);
}), this;
}
save(e = !0) {
let t = {
controllers: {},
folders: {}
};
return this.controllers.forEach((e) => {
if (!(e instanceof D)) {
if (e._name in t.controllers) throw Error(`Cannot save GUI with duplicate property "${e._name}"`);
t.controllers[e._name] = e.save();
}
}), e && this.folders.forEach((e) => {
if (e._title in t.folders) throw Error(`Cannot save GUI with duplicate folder "${e._title}"`);
t.folders[e._title] = e.save();
}), t;
}
open(e = !0) {
return this._setClosed(!e), this.$title.setAttribute("aria-expanded", !this._closed), this.domElement.classList.toggle("lil-closed", this._closed), this;
}
close() {
return this.open(!1);
}
_setClosed(e) {
this._closed !== e && (this._closed = e, this._callOnOpenClose(this));
}
show(e = !0) {
return this._hidden = !e, this.domElement.style.display = this._hidden ? "none" : "", this;
}
hide() {
return this.show(!1);
}
openAnimated(e = !0) {
return this._setClosed(!e), this.$title.setAttribute("aria-expanded", !this._closed), requestAnimationFrame(() => {
let t = this.$children.clientHeight;
this.$children.style.height = t + "px", this.domElement.classList.add("lil-transition");
let n = (e) => {
e.target === this.$children && (this.$children.style.height = "", this.domElement.classList.remove("lil-transition"), this.$children.removeEventListener("transitionend", n));
};
this.$children.addEventListener("transitionend", n);
let r = e ? this.$children.scrollHeight : 0;
this.domElement.classList.toggle("lil-closed", !e), requestAnimationFrame(() => {
this.$children.style.height = r + "px";
});
}), this;
}
title(e) {
return this._title = e, this.$title.textContent = e, this;
}
reset(e = !0) {
return (e ? this.controllersRecursive() : this.controllers).forEach((e) => e.reset()), this;
}
onChange(e) {
return this._onChange = e, this;
}
_callOnChange(e) {
this.parent && this.parent._callOnChange(e), this._onChange !== void 0 && this._onChange.call(this, {
object: e.object,
property: e.property,
value: e.getValue(),
controller: e
});
}
onFinishChange(e) {
return this._onFinishChange = e, this;
}
_callOnFinishChange(e) {
this.parent && this.parent._callOnFinishChange(e), this._onFinishChange !== void 0 && this._onFinishChange.call(this, {
object: e.object,
property: e.property,
value: e.getValue(),
controller: e
});
}
onOpenClose(e) {
return this._onOpenClose = e, this;
}
_callOnOpenClose(e) {
this.parent && this.parent._callOnOpenClose(e), this._onOpenClose !== void 0 && this._onOpenClose.call(this, e);
}
destroy() {
this.parent && (this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.folders.splice(this.parent.folders.indexOf(this), 1)), this.domElement.parentElement && this.domElement.parentElement.removeChild(this.domElement), Array.from(this.children).forEach((e) => e.destroy());
}
controllersRecursive() {
let e = Array.from(this.controllers);
return this.folders.forEach((t) => {
e = e.concat(t.controllersRecursive());
}), e;
}
foldersRecursive() {
let e = Array.from(this.folders);
return this.folders.forEach((t) => {
e = e.concat(t.foldersRecursive());
}), e;
}
};
//#endregion
//#region ../renderer/src/debug/components/Gui.tsx
function F(e) {
let t = (0, l.c)(7), { children: n } = e, [r] = (0, u.useState)(L), i = a(I), o, c;
t[0] !== r || t[1] !== i ? (o = () => (r.domElement.classList.add("lil-auto-place", "autoPlace"), document.body.appendChild(r.domElement), r.close(), r.onChange(() => i()), () => r.destroy()), c = [r, i], t[0] = r, t[1] = i, t[2] = o, t[3] = c) : (o = t[2], c = t[3]), (0, u.useEffect)(o, c);
let d;
return t[4] !== n || t[5] !== r ? (d = /* @__PURE__ */ (0, p.jsx)(s, {
value: r,
children: n
}), t[4] = n, t[5] = r, t[6] = d) : d = t[6], d;
}
function I(e) {
return e.invalidate;
}
function L() {
return new P({
autoPlace: !1,
closeFolders: !0
});
}
//#endregion
//#region ../renderer/src/debug/components/MemoryInfo.tsx
function R() {
let e = (0, l.c)(5), t = a(z), [n, r] = (0, u.useState)(null), i, s;
e[0] === t ? (i = e[1], s = e[2]) : (i = () => {
let e = t.getContext().getExtension("GMAN_webgl_memory");
if (e) return o(() => {
r({
...e.getMemoryInfo(),
drawCalls: t.info.render.calls
});
});
}, s = [t], e[0] = t, e[1] = i, e[2] = s), (0, u.useEffect)(i, s);
let c;
return e[3] === n ? c = e[4] : (c = /* @__PURE__ */ (0, p.jsx)(g, {
corner: "left",
label: "Memory Info",
value: n,
replacer: B
}), e[3] = n, e[4] = c), c;
}
function z(e) {
return e.gl;
}
function B(e, t) {
return typeof t == "number" ? t.toLocaleString() : t;
}
//#endregion
//#region ../../node_modules/.pnpm/stats-gl@4.2.3_three@0.185.1/node_modules/stats-gl/dist/core.js
var V = class {
constructor({ trackGPU: e = !1, trackCPT: t = !1, trackHz: n = !1, trackFPS: r = !0, logsPerSecond: i = 4, graphsPerSecond: a = 30, samplesLog: o = 40, samplesGraph: s = 10, precision: c = 2, maxTimestampPairs: l = 2048 } = {}) {
this.gl = null, this.ext = null, this.gpuDevice = null, this.gpuBackend = null, this.renderer = null, this.activeQuery = null, this.gpuQueries = [], this.threeRendererPatched = !1, this.maxTimestampPairs = 2048, this.webgpuNative = !1, this.gpuQuerySet = null, this.gpuResolveBuffer = null, this.gpuTimestampBufferSize = 0, this.frameCursor = 0, this.slotTypes = [], this.readBufferPool = [], this.inFlightFrames = [], this.poolWarnThreshold = 8, this.warnedMapError = !1, this.warnedSlotOverflow = !1, this.warnedPoolGrowth = !1, this.frameTimes = [], this.frameTimesHead = 0, this.renderCount = 0, this.cpuStartTime = 0, this.isRunningCPUProfiling = !1, this.totalCpuDuration = 0, this.totalGpuDuration = 0, this.totalGpuDurationCompute = 0, this.averageFps = {
logs: [],
graph: []
}, this.averageCpu = {
logs: [],
graph: []
}, this.averageGpu = {
logs: [],
graph: []
}, this.averageGpuCompute = {
logs: [],
graph: []
}, this.trackGPU = e, this.trackCPT = t, this.trackHz = n, this.trackFPS = r, this.samplesLog = o, this.samplesGraph = s, this.precision = c, this.logsPerSecond = i, this.graphsPerSecond = a, this.maxTimestampPairs = Math.max(1, l);
let u = performance.now();
this.prevGraphTime = u, this.beginTime = u, this.prevTextTime = u, this.prevCpuTime = u;
}
async init(e) {
if (!e) {
console.error("Stats: The \"canvas\" parameter is undefined.");
return;
}
if (!this.handleThreeRenderer(e) && !await this.handleWebGPURenderer(e) && !this.handleNativeWebGPU(e)) if (this.initializeWebGL(e)) {
this.trackGPU && this.initializeGPUTracking();
return;
} else console.error("Stats-gl: Failed to initialize WebGL context");
}
handleNativeWebGPU(e) {
var t;
return e && typeof e.createCommandEncoder == "function" && typeof e.createQuerySet == "function" && e.queue ? (this.gpuDevice = e, this.webgpuNative = !0, this.trackGPU && (t = e.features) != null && t.has("timestamp-query") && (this.initializeWebGPUTiming(), this.onWebGPUTimestampSupported()), !0) : !1;
}
initializeWebGPUTiming() {
if (!this.gpuDevice) return;
let e = this.maxTimestampPairs * 2;
this.gpuTimestampBufferSize = e * 8, this.gpuQuerySet = this.gpuDevice.createQuerySet({
type: "timestamp",
count: e
}), this.gpuResolveBuffer = this.gpuDevice.createBuffer({
size: this.gpuTimestampBufferSize,
usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC
});
}
acquireReadBuffer() {
if (!this.gpuDevice) return null;
let e = this.readBufferPool.pop();
if (e) return e;
let t = this.inFlightFrames.length + this.readBufferPool.length + 1;
return t > this.poolWarnThreshold && !this.warnedPoolGrowth && (console.warn(`stats-gl: WebGPU timestamp readback pool grew to ${t} buffers — is update() being called every frame after queue.submit?`), this.warnedPoolGrowth = !0), this.gpuDevice.createBuffer({
size: this.gpuTimestampBufferSize,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
});
}
handleThreeRenderer(e) {
return e.isWebGLRenderer && !this.threeRendererPatched ? (this.patchThreeRenderer(e), this.gl = e.getContext(), this.trackGPU && this.initializeGPUTracking(), !0) : !1;
}
async handleWebGPURenderer(e) {
var t;
return e.isWebGPURenderer ? (this.renderer = e, (this.trackGPU || this.trackCPT) && (e.backend.trackTimestamp = !0, e._initialized || await e.init(), e.hasFeature("timestamp-query") && this.onWebGPUTimestampSupported()), this.info = e.info, this.gpuBackend = e.backend, this.gpuDevice = ((t = e.backend) == null ? void 0 : t.device) || null, this.patchThreeWebGPU(e), !0) : !1;
}
onWebGPUTimestampSupported() {}
initializeWebGL(e) {
if (e instanceof WebGL2RenderingContext) this.gl = e;
else if (e instanceof HTMLCanvasElement || e instanceof OffscreenCanvas) {
if (this.gl = e.getContext("webgl2"), !this.gl) return console.error("Stats: Unable to obtain WebGL2 context."), !1;
} else return console.error("Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas."), !1;
return !0;
}
initializeGPUTracking() {
this.gl && (this.ext = this.gl.getExtension("EXT_disjoint_timer_query_webgl2"), this.ext && this.onGPUTrackingInitialized());
}
onGPUTrackingInitialized() {}
getTimestampWrites(e = "render") {
if (!this.webgpuNative || !this.gpuQuerySet) return;
if (this.frameCursor >= this.maxTimestampPairs) {
this.warnedSlotOverflow || (console.warn(`stats-gl: WebGPU timestamp pair budget exhausted (maxTimestampPairs=${this.maxTimestampPairs}). Increase maxTimestampPairs in StatsOptions to instrument more passes.`), this.warnedSlotOverflow = !0);
return;
}
let t = this.frameCursor++;
return this.slotTypes[t] = e, {
querySet: this.gpuQuerySet,
beginningOfPassWriteIndex: t * 2,
endOfPassWriteIndex: t * 2 + 1
};
}
begin(e) {
if (this.beginProfiling(), this.webgpuNative) {
this.frameCursor = 0, this.slotTypes.length = 0;
return;
}
!this.gl || !this.ext || (this.activeQuery && this.gl.endQuery(this.ext.TIME_ELAPSED_EXT), this.activeQuery = this.gl.createQuery(), this.activeQuery && this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT, this.activeQuery));
}
end(e) {
if (this.renderCount++, this.webgpuNative && e && this.gpuQuerySet && this.gpuResolveBuffer) {
let t = this.frameCursor;
if (t > 0) {
let n = t * 2, r = n * 8;
e.resolveQuerySet(this.gpuQuerySet, 0, n, this.gpuResolveBuffer, 0);
let i = this.acquireReadBuffer();
i && (e.copyBufferToBuffer(this.gpuResolveBuffer, 0, i, 0, r), this.inFlightFrames.push({
buffer: i,
pairCount: t,
slotTypes: this.slotTypes.slice(0, t),
mapPromise: null,
ready: !1,
error: null
}));
}
this.endProfiling();
return;
}
this.gl && this.ext && this.activeQuery && (this.gl.endQuery(this.ext.TIME_ELAPSED_EXT), this.gpuQueries.push({ query: this.activeQuery }), this.activeQuery = null), this.endProfiling();
}
async resolveTimestampsAsync() {
if (!this.webgpuNative) return this.totalGpuDuration;
for (let e of this.inFlightFrames) e.mapPromise === null && (e.mapPromise = e.buffer.mapAsync(GPUMapMode.READ).then(() => {
e.ready = !0;
}, (t) => {
e.error = t, e.ready = !0;
}));
for (; this.inFlightFrames.length > 0 && this.inFlightFrames[0].ready;) {
let e = this.inFlightFrames.shift();
if (e.error) {
this.warnedMapError || (console.warn("stats-gl: WebGPU timestamp mapAsync failed", e.error), this.warnedMapError = !0), this.totalGpuDuration = 0, this.totalGpuDurationCompute = 0, this.readBufferPool.push(e.buffer);
continue;
}
let t = new BigUint64Array(e.buffer.getMappedRange()), n = 0, r = 0;
for (let i = 0; i < e.pairCount; i++) {
let a = t[i * 2], o = t[i * 2 + 1], s = o >= a ? Number(o - a) : 0;
e.slotTypes[i] === "compute" ? r += s : n += s;
}
e.buffer.unmap(), this.readBufferPool.push(e.buffer), this.totalGpuDuration = n / 1e6, this.totalGpuDurationCompute = r / 1e6;
}
return this.totalGpuDuration;
}
processGpuQueries() {
if (!(!this.gl || !this.ext)) {
this.totalGpuDuration = 0;
for (let e = this.gpuQueries.length - 1; e >= 0; e--) {
let t = this.gpuQueries[e], n = this.gl.getQueryParameter(t.query, this.gl.QUERY_RESULT_AVAILABLE), r = this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);
if (n && !r) {
let n = this.gl.getQueryParameter(t.query, this.gl.QUERY_RESULT) * 1e-6;
this.totalGpuDuration += n, this.gl.deleteQuery(t.query), this.gpuQueries.splice(e, 1);
}
}
}
}
processWebGPUTimestamps() {
this.totalGpuDuration = this.info.render.timestamp, this.totalGpuDurationCompute = this.info.compute.timestamp;
}
beginProfiling() {
this.cpuStartTime = performance.now(), this.isRunningCPUProfiling = !0;
}
endProfiling() {
this.isRunningCPUProfiling && (this.totalCpuDuration += performance.now() - this.cpuStartTime, this.isRunningCPUProfiling = !1);
}
calculateFps() {
let e = performance.now(), t = e - 1e3;
for (this.frameTimes.push(e); this.frameTimesHead < this.frameTimes.length && this.frameTimes[this.frameTimesHead] <= t;) this.frameTimesHead++;
return this.frameTimesHead > 128 && (this.frameTimes = this.frameTimes.slice(this.frameTimesHead), this.frameTimesHead = 0), Math.round(this.frameTimes.length - this.frameTimesHead);
}
updateAverages() {
this.addToAverage(this.totalCpuDuration, this.averageCpu), this.addToAverage(this.totalGpuDuration, this.averageGpu), (this.info || this.webgpuNative) && this.totalGpuDurationCompute !== void 0 && this.addToAverage(this.totalGpuDurationCompute, this.averageGpuCompute);
}
addToAverage(e, t) {
for (t.logs.push(e); t.logs.length > this.samplesLog;) t.logs.shift();
for (t.graph.push(e); t.graph.length > this.samplesGraph;) t.graph.shift();
}
resetCounters() {
this.renderCount = 0, this.totalCpuDuration = 0, this.beginTime = performance.now();
}
getData() {
let e = this.averageFps.logs, t = this.averageCpu.logs, n = this.averageGpu.logs, r = this.averageGpuCompute.logs;
return {
fps: e.length > 0 ? e[e.length - 1] : 0,
cpu: t.length > 0 ? t[t.length - 1] : 0,
gpu: n.length > 0 ? n[n.length - 1] : 0,
gpuCompute: r.length > 0 ? r[r.length - 1] : 0
};
}
patchThreeWebGPU(e) {
let t = e.info.reset, n = this;
e.info.reset = function() {
n.beginProfiling(), t.call(this);
};
}
patchThreeRenderer(e) {
let t = e.render, n = this;
e.render = function(e, r) {
n.begin(), t.call(this, e, r), n.end();
}, this.threeRendererPatched = !0;
}
dispose() {
if (this.gl) {
if (this.activeQuery && this.ext) {
try {
this.gl.endQuery(this.ext.TIME_ELAPSED_EXT);
} catch {}
this.gl.deleteQuery(this.activeQuery), this.activeQuery = null;
}
for (let e of this.gpuQueries) this.gl.deleteQuery(e.query);
this.gpuQueries.length = 0;
}
this.gpuQuerySet && (this.gpuQuerySet.destroy(), this.gpuQuerySet = null), this.gpuResolveBuffer && (this.gpuResolveBuffer.destroy(), this.gpuResolveBuffer = null);
for (let e of this.inFlightFrames) {
try {
e.buffer.mapState === "mapped" && e.buffer.unmap();
} catch {}
e.buffer.destroy();
}
this.inFlightFrames.length = 0;
for (let e of this.readBufferPool) e.destroy();
this.readBufferPool.length = 0, this.frameCursor = 0, this.slotTypes.length = 0, this.gpuTimestampBufferSize = 0, this.warnedMapError = !1, this.warnedSlotOverflow = !1, this.warnedPoolGrowth = !1, this.webgpuNative = !1, this.gl = null, this.ext = null, this.info = void 0, this.gpuDevice = null, this.gpuBackend = null, this.renderer = null, this.frameTimes.length = 0, this.frameTimesHead = 0, this.averageFps.logs.length = 0, this.averageFps.graph.length = 0, this.averageCpu.logs.length = 0, this.averageCpu.graph.length = 0, this.averageGpu.logs.length = 0, this.averageGpu.graph.length = 0, this.averageGpuCompute.logs.length = 0, this.averageGpuCompute.graph.length = 0;
}
}, H = class {
constructor(e, t, n) {
this.id = 0, this.name = e, this.fg = t, this.bg = n, this.gradient = null, this.PR = Math.round(typeof window < "u" && window.devicePixelRatio || 1), this.WIDTH = 90 * this.PR, this.HEIGHT = 48 * this.PR, this.TEXT_X = 3 * this.PR, this.TEXT_Y = 2 * this.PR, this.GRAPH_X = 3 * this.PR, this.GRAPH_Y = 15 * this.PR, this.GRAPH_WIDTH = 84 * this.PR, this.GRAPH_HEIGHT = 30 * this.PR, this.canvas = typeof document < "u" ? document.createElement("canvas") : new OffscreenCanvas(this.WIDTH, this.HEIGHT), this.canvas.width = this.WIDTH, this.canvas.height = this.HEIGHT, this.canvas.style.width = "90px", this.canvas.style.height = "48px", this.canvas.style.position = "absolute", this.canvas.style.cssText = "width:90px;height:48px;background-color: transparent !important;", this.context = this.canvas.getContext("2d"), this.initializeCanvas();
}
createGradient() {
if (!this.context) throw Error("No context");
let e = this.context.createLinearGradient(0, this.GRAPH_Y, 0, this.GRAPH_Y + this.GRAPH_HEIGHT), t, n = this.fg;
switch (this.fg.toLowerCase()) {
case "#0ff":
t = "#006666";
break;
case "#0f0":
t = "#006600";
break;
case "#ff0":
t = "#666600";
break;
case "#e1e1e1":
t = "#666666";
break;
default:
t = this.bg;
break;
}
return e.addColorStop(0, t), e.addColorStop(1, n), e;
}
initializeCanvas() {
this.context && (this.context.imageSmoothingEnabled = !1, this.context.font = "bold " + 9 * this.PR + "px Helvetica,Arial,sans-serif", this.context.textBaseline = "top", this.gradient = this.createGradient(), this.context.fillStyle = this.bg, this.context.fillRect(0, 0, this.WIDTH, this.HEIGHT), this.context.fillStyle = this.fg, this.context.fillText(this.name, this.TEXT_X, this.TEXT_Y), this.context.fillStyle = this.bg, this.context.globalAlpha = .9, this.context.fillRect(this.GRAPH_X, this.GRAPH_Y, this.GRAPH_WIDTH, this.GRAPH_HEIGHT));
}
update(e, t, n = 0, r = "") {
if (!this.context || !this.gradient) return;
let i = Math.min(Infinity, e), a = Math.max(t, e);
this.context.globalAlpha = 1, this.context.fillStyle = this.bg, this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y);
let o = `${e.toFixed(n)} ${this.name}`;
this.context.fillStyle = this.fg, this.context.fillText(o, this.TEXT_X, this.TEXT_Y);
let s = this.TEXT_X + this.context.measureText(o).width;
r && (this.context.fillStyle = "#f90", this.context.fillText(r, s, this.TEXT_Y), s += this.context.measureText(r).width), this.context.fillStyle = this.fg, this.context.fillText(` (${i.toFixed(n)}-${parseFloat(a.toFixed(n))})`, s, this.TEXT_Y);
}
updateGraph(e, t) {
if (!this.context || !this.gradient) return;
e === 0 && t === 0 && (t = 1), t = Math.max(t, e, .1), e = Math.max(e, 0);
let n = Math.round(this.GRAPH_X), r = Math.round(this.GRAPH_Y), i = Math.round(this.GRAPH_WIDTH), a = Math.round(this.GRAPH_HEIGHT), o = Math.round(this.PR);
this.context.drawImage(this.canvas, n + o, r, i - o, a, n, r, i - o, a), this.context.fillStyle = this.bg, this.context.fillRect(n + i - o, r, o, a);
let s = Math.min(a, Math.round(e / t * a));
s > 0 && (this.context.globalAlpha = .9, this.context.fillStyle = this.gradient, this.context.fillRect(n + i - o, r + (a - s), o, s)), this.context.globalAlpha = 1;
}
}, U = class extends H {
constructor(e, t, n) {
super(e, t, n), this.vsyncValue = 0, this.SMALL_HEIGHT = 9 * this.PR, this.HEIGHT = this.SMALL_HEIGHT, this.WIDTH = 35 * this.PR, this.TEXT_Y = 0 * this.PR, this.canvas.height = this.HEIGHT, this.canvas.width = this.WIDTH, this.canvas.style.height = "9px", this.canvas.style.width = "35px", this.canvas.style.cssText = "\n width: 35px;\n height: 9px;\n position: absolute;\n top: 0;\n left: 0;\n background-color: transparent !important;\n pointer-events: none;\n ", this.initializeCanvas();
}
initializeCanvas() {
this.context && (this.context.imageSmoothingEnabled = !1, this.context.font = "bold " + 9 * this.PR + "px Helvetica,Arial,sans-serif", this.context.textBaseline = "top", this.context.globalAlpha = 1);
}
update(e, t, n = 0) {
this.context && (this.vsyncValue = e, this.context.clearRect(0, 0, this.WIDTH, this.HEIGHT), this.context.globalAlpha = 1, this.context.fillStyle = this.bg, this.context.fillText(`${e.toFixed(0)}Hz`, this.TEXT_X, this.TEXT_Y));
}
updateGraph(e, t) {}
setOffset(e, t) {
this.canvas.style.transform = `translate(${e}px, ${t}px)`;
}
}, W = class extends H {
constructor(e) {
super(e, "#fff", "#111"), this.currentBitmap = null, this.sourceAspect = 1, this.initializeCanvas();
}
initializeCanvas() {
this.context && (this.context.imageSmoothingEnabled = !0, this.context.font = "bold " + 9 * this.PR + "px Helvetica,Arial,sans-serif", this.context.textBaseline = "top", this.context.fillStyle = "#000", this.context.fillRect(0, 0, this.WIDTH, this.HEIGHT), this.drawLabelOverlay());
}
drawLabelOverlay() {
this.context && (this.context.fillStyle = "rgba(0, 0, 0, 0.5)", this.context.fillRect(0, 0, this.WIDTH, this.GRAPH_Y), this.context.fillStyle = this.fg, this.context.fillText(this.name, this.TEXT_X, this.TEXT_Y));
}
setSourceSize(e, t) {
this.sourceAspect = e / t;
}
updateTexture(e) {
if (!this.context) return;
this.currentBitmap && this.currentBitmap.close(), this.currentBitmap = e, this.context.fillStyle = "#000", this.context.fillRect(0, 0, this.WIDTH, this.HEIGHT);
let t = this.WIDTH / this.HEIGHT, n, r, i, a;
this.sourceAspect > t ? (n = this.WIDTH, r = this.WIDTH / this.sourceAspect, i = 0, a = (this.HEIGHT - r) / 2) : (r = this.HEIGHT, n = this.HEIGHT * this.sourceAspect, i = (this.WIDTH - n) / 2, a = 0), this.context.drawImage(e, i, a, n, r), this.drawLabelOverlay();
}
setLabel(e) {
this.name = e, this.drawLabelOverlay();
}
update(e, t, n = 0, r = "") {}
updateGraph(e, t) {}
dispose() {
this.currentBitmap && (this.currentBitmap.close(), this.currentBitmap = null);
}
}, G = class {
constructor(e, t = 90, n = 48) {
this.previewFbo = null, this.previewTexture = null, this.gl = e, this.previewWidth = t, this.previewHeight = n, this.pixels = new Uint8Array(t * n * 4), this.flippedPixels = new Uint8Array(t * n * 4), this.initResources();
}
resize(e, t) {
e === this.previewWidth && t === this.previewHeight || (this.previewWidth = e, this.previewHeight = t, this.pixels = new Uint8Array(e * t * 4), this.flippedPixels = new Uint8Array(e * t * 4), this.dispose(), this.initResources());
}
initResources() {
let e = this.gl;
this.previewTexture = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.previewTexture), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA8, this.previewWidth, this.previewHeight, 0, e.RGBA, e.UNSIGNED_BYTE, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), this.previewFbo = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, this.previewFbo), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this.previewTexture, 0), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindTexture(e.TEXTURE_2D, null);
}
async capture(e, t, n, r = "default") {
let i = this.gl, a = i.getParameter(i.READ_FRAMEBUFFER_BINDING), o = i.getParameter(i.DRAW_FRAMEBUFFER_BINDING);
i.bindFramebuffer(i.READ_FRAMEBUFFER, e), i.bindFramebuffer(i.DRAW_FRAMEBUFFER, this.previewFbo), i.blitFramebuffer(0, 0, t, n, 0, 0, this.previewWidth, this.previewHeight, i.COLOR_BUFFER_BIT, i.LINEAR), i.bindFramebuffer(i.READ_FRAMEBUFFER, this.previewFbo), i.readPixels(0, 0, this.previewWidth, this.previewHeight, i.RGBA, i.UNSIGNED_BYTE, this.pixels), i.bindFramebuffer(i.READ_FRAMEBUFFER, a), i.bindFramebuffer(i.DRAW_FRAMEBUFFER, o);
let s = this.flipY(this.pixels, this.previewWidth, this.previewHeight), c = new ImageData(new Uint8ClampedArray(s), this.previewWidth, this.previewHeight);
return createImageBitmap(c);
}
flipY(e, t, n) {
let r = t * 4;
for (let t = 0; t < n; t++) {
let i = t * r, a = (n - 1 - t) * r;
this.flippedPixels.set(e.subarray(i, i + r), a);
}
return this.flippedPixels;
}
removeSource(e) {}
dispose() {
let e = this.gl;
this.previewFbo && (e.deleteFramebuffer(this.previewFbo), this.previewFbo = null), this.previewTexture && (e.deleteTexture(this.previewTexture), this.previewTexture = null);
}
}, K = class {
constructor(e, t = 90, n = 48) {
this.previewTexture = null, this.stagingBuffer = null, this.blitPipeline = null, this.sampler = null, this.bindGroupLayout = null, this.initialized = !1, this.device = e, this.previewWidth = t, this.previewHeight = n, this.pixelsBuffer = new Uint8ClampedArray(t * n * 4);
}
resize(e, t) {
e === this.previewWidth && t === this.previewHeight || (this.previewWidth = e, this.previewHeight = t, this.pixelsBuffer = new Uint8ClampedArray(e * t * 4), this.previewTexture && this.previewTexture.destroy(), this.stagingBuffer && this.stagingBuffer.destroy(), this.previewTexture = null, this.stagingBuffer = null, this.initialized && this.createSizeResources());
}
createSizeResources() {
let e = this.device;
this.previewTexture = e.createTexture({
size: {
width: this.previewWidth,
height: this.previewHeight
},
format: "rgba8unorm",
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
});
let t = Math.ceil(this.previewWidth * 4 / 256) * 256;
this.stagingBuffer = e.createBuffer({
size: t * this.previewHeight,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
});
}
async initResources() {
if (this.initialized) return;
let e = this.device;
this.createSizeResources(), this.sampler = e.createSampler({
minFilter: "linear",
magFilter: "linear"
});
let t = e.createShaderModule({ code: "\n @group(0) @binding(0) var texSampler: sampler;\n @group(0) @binding(1) var texInput: texture_2d<f32>;\n\n struct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) uv: vec2f\n }\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var positions = array<vec2f, 3>(\n vec2f(-1.0, -1.0),\n vec2f(3.0, -1.0),\n vec2f(-1.0, 3.0)\n );\n var uvs = array<vec2f, 3>(\n vec2f(0.0, 1.0),\n vec2f(2.0, 1.0),\n vec2f(0.0, -1.0)\n );\n\n var output: VertexOutput;\n output.position = vec4f(positions[vertexIndex], 0.0, 1.0);\n output.uv = uvs[vertexIndex];\n return output;\n }\n\n @fragment\n fn fragmentMain(@location(0) uv: vec2f) -> @location(0) vec4f {\n return textureSample(texInput, texSampler, uv);\n }\n " });
this.bindGroupLayout = e.createBindGroupLayout({ entries: [{
binding: 0,
visibility: GPUShaderStage.FRAGMENT,
sampler: { type: "filtering" }
}, {
binding: 1,
visibility: GPUShaderStage.FRAGMENT,
texture: { sampleType: "float" }
}] }), this.blitPipeline = e.createRenderPipeline({
layout: e.createPipelineLayout({ bindGroupLayouts: [this.bindGroupLayout] }),
vertex: {
module: t,
entryPoint: "vertexMain"
},
fragment: {
module: t,
entryPoint: "fragmentMain",
targets: [{ format: "rgba8unorm" }]
},
primitive: { topology: "triangle-list" }
}), this.initialized = !0;
}
async capture(e) {
if (await this.initResources(), !this.previewTexture || !this.stagingBuffer || !this.blitPipeline || !this.sampler || !this.bindGroupLayout) return null;
let t = this.device, n = t.createBindGroup({
layout: this.bindGroupLayout,
entries: [{
binding: 0,
resource: this.sampler
}, {
binding: 1,
resource: e.createView()
}]
}), r = t.createCommandEncoder(), i = r.beginRenderPass({ colorAttachments: [{
view: this.previewTexture.createView(),
loadOp: "clear",
storeOp: "store",
clearValue: {
r: 0,
g: 0,
b: 0,
a: 1
}
}] });
i.setPipeline(this.blitPipeline), i.setBindGroup(0, n), i.draw(3), i.end();
let a = Math.ceil(this.previewWidth * 4 / 256) * 256;
r.copyTextureToBuffer({ texture: this.previewTexture }, {
buffer: this.stagingBuffer,
bytesPerRow: a
}, {
width: this.previewWidth,
height: this.previewHeight
}), t.queue.submit([r.finish()]), await this.stagingBuffer.mapAsync(GPUMapMode.READ);
let o = new Uint8Array(this.stagingBuffer.getMappedRange());
for (let e = 0; e < this.previewHeight; e++) {
let t = e * a, n = e * this.previewWidth * 4;
this.pixelsBuffer.set(o.subarray(t, t + this.previewWidth * 4), n);
}
this.stagingBuffer.unmap();
let s = new ImageData(new Uint8ClampedArray(this.pixelsBuffer), this.previewWidth, this.previewHeight);
return createImageBitmap(s);
}
dispose() {
this.previewTexture && this.previewTexture.destroy(), this.stagingBuffer && this.stagingBuffer.destroy(), this.previewTexture = null, this.stagingBuffer = null, this.blitPipeline = null, this.sampler = null, this.bindGroupLayout = null, this.initialized = !1;
}
};
function q(e, t) {
return e.isWebGLRenderTarget && e.__webglFramebuffer ? {
framebuffer: e.__webglFramebuffer,
width: e.width || 1,
height: e.height || 1
} : null;
}
function J(e, t) {
if (e.isRenderTarget && e.texture && t.get) {
let n = t.get(e.texture);
return (n == null ? void 0 : n.texture) || null;
}
return null;
}
//#endregion
//#region ../../node_modules/.pnpm/stats-gl@4.2.3_three@0.185.1/node_modules/stats-gl/dist/main.js
var Y = class e extends V {
constructor({ trackGPU: t = !1, trackCPT: n = !1, trackHz: r = !1, trackFPS: i = !0, logsPerSecond: a = 4, graphsPerSecond: o = 30, samplesLog: s = 40, samplesGraph: c = 10, precision: l = 2, minimal: u = !1, horizontal: d = !0, mode: f = 0 } = {}) {
super({
trackGPU: t,
trackCPT: n,
trackHz: r,
trackFPS: i,
logsPerSecond: a,
graphsPerSecond: o,
samplesLog: s,
samplesGraph: c,
precision: l
}), this.fpsPanel = null, this.msPanel = null, this.gpuPanel = null, this.gpuPanelCompute = null, this.vsyncPanel = null, this.workerCpuPanel = null, this.texturePanels = /* @__PURE__ */ new Map(), this.texturePanelRow = null, this.textureCaptureWebGL = null, this.textureCaptureWebGPU = null, this.textureSourcesWebGL = /* @__PURE__ */ new Map(), this.textureSourcesWebGPU = /* @__PURE__ */ new Map(), this.texturePreviewWidth = 90, this.texturePreviewHeight = 48, this.lastRendererWidth = 0, this.lastRendererHeight = 0, this.textureUpdatePending = !1, this.updateCounter = 0, this.lastMin = {}, this.lastMax = {}, this.lastValue = {}, this.VSYNC_RATES = [
{
refreshRate: 60,
frameTime: 16.67
},
{
refreshRate: 75,
frameTime: 13.33
},
{
refreshRate: 90,
frameTime: 11.11
},
{
refreshRate: 120,
frameTime: 8.33
},
{
refreshRate: 144,
frameTime: 6.94
},
{
refreshRate: 165,
frameTime: 6.06
},
{
refreshRate: 240,
frameTime: 4.17
}
], this.detectedVSync = null, this.frameTimeHistory = [], this.HISTORY_SIZE = 120, this.VSYNC_THRESHOLD = .05, this.lastFrameTime = 0, this.externalData = null, this.hasNewExternalData = !1, this.isWorker = !1, this.averageWorkerCpu = {
logs: [],
graph: []
}, this.handleClick = (e) => {
e.preventDefault(), this.showPanel(++this.mode % this.dom.children.length);
}, this.handleResize = () => {
this.fpsPanel && this.resizePanel(this.fpsPanel), this.msPanel && this.resizePanel(this.msPanel), this.workerCpuPanel && this.resizePanel(this.workerCpuPanel), this.gpuPanel && this.resizePanel(this.gpuPanel), this.gpuPanelCompute && this.resizePanel(this.gpuPanelCompute);
}, this.mode = f, this.horizontal = d, this.minimal = u, this.dom = document.createElement("div"), this.initializeDOM(), this._panelId = 0, this.trackFPS && (this.fpsPanel = this.addPanel(new e.Panel("FPS", "#0ff", "#002")), this.msPanel = this.addPanel(new e.Panel("CPU", "#0f0", "#020"))), this.trackGPU && (this.gpuPanel = this.addPanel(new e.Panel("GPU", "#ff0", "#220"))), this.trackCPT && (this.gpuPanelCompute = this.addPanel(new e.Panel("CPT", "#e1e1e1", "#212121"))), this.trackHz === !0 && (this.vsyncPanel = new U("", "#f0f", "#202"), this.dom.appendChild(this.vsyncPanel.canvas), this.vsyncPanel.setOffset(56, 35)), this.setupEventListeners();
}
initializeDOM() {
this.dom.style.cssText = `
position: fixed;
top: 0;
left: 0;
opacity: 0.9;
z-index: 10000;
${this.minimal ? "cursor: pointer;" : ""}
`;
}
setupEventListeners() {
this.minimal ? (this.dom.addEventListener("click", this.handleClick), this.showPanel(this.mode)) : window.addEventListener("resize", this.handleResize);
}
updateTexturePreviewDimensions() {
var e, t;
if (!this.renderer) return;
let n = ((e = this.renderer.domElement) == null ? void 0 : e.width) || 0, r = ((t = this.renderer.domElement) == null ? void 0 : t.height) || 0;
if (n === this.lastRendererWidth && r === this.lastRendererHeight || n === 0 || r === 0) return;
this.lastRendererWidth = n, this.lastRendererHeight = r;
let i = n / r, a, o;
if (i > 1.875 ? (a = 90, o = Math.round(90 / i)) : (o = 48, a = Math.round(48 * i)), a = Math.max(a, 16), o = Math.max(o, 16), a !== this.texturePreviewWidth || o !== this.texturePreviewHeight) {
this.texturePreviewWidth = a, this.texturePreviewHeight = o, this.textureCaptureWebGL && this.textureCaptureWebGL.resize(a, o), this.textureCaptureWebGPU && this.textureCaptureWebGPU.resize(a, o);
for (let e of this.texturePanels.values()) e.setSourceSize(n, r);
}
}
onWebGPUTimestampSupported() {}
onGPUTrackingInitialized() {}
setData(t) {
if (this.externalData = t, this.hasNewExternalData = !0, !this.isWorker && this.msPanel) {
this.isWorker = !0, this.workerCpuPanel = new e.Panel("WRK", "#f90", "#220");
let t = this.msPanel.id + 1;
this.workerCpuPanel.id = t, this.gpuPanel && this.gpuPanel.id >= t && (this.gpuPanel.id++, this.resizePanel(this.gpuPanel)), this.gpuPanelCompute && this.gpuPanelCompute.id >= t && (this.gpuPanelCompute.id++, this.resizePanel(this.gpuPanelCompute));
let n = this.msPanel.canvas;
n.nextSibling ? this.dom.insertBefore(this.workerCpuPanel.canvas, n.nextSibling) : this.dom.appendChild(this.workerCpuPanel.canvas), this.resizePanel(this.workerCpuPanel), this._panelId++;
}
}
update() {
this.externalData ? this.updateFromExternalData() : this.updateFromInternalData();
}
updateFromExternalData() {
let e = this.externalData;
this.endProfiling(), this.addToAverage(this.totalCpuDuration, this.averageCpu), this.totalCpuDuration = 0, this.hasNewExternalData && (this.addToAverage(e.cpu, this.averageWorkerCpu), this.addToAverage(e.fps, this.averageFps), this.addToAverage(e.gpu, this.averageGpu), this.addToAverage(e.gpuCompute, this.averageGpuCompute), this.hasNewExternalData = !1), this.renderPanels();
}
updateFromInternalData() {
this.endProfiling(), this.webgpuNative ? this.resolveTimestampsAsync() : this.info ? this.processWebGPUTimestamps() : this.processGpuQueries(), this.updateAverages(), this.resetCounters(), this.renderPanels();
}
renderPanels() {
var e;
let t = performance.now();
if (!this.isWorker) {
for (this.frameTimes.push(t); this.frameTimes.length > 0 && this.frameTimes[0] <= t - 1e3;) this.frameTimes.shift();
let e = Math.round(this.frameTimes.length);
this.addToAverage(e, this.averageFps);
}
let n = t >= this.prevTextTime + 1e3 / this.logsPerSecond, r = t >= this.prevGraphTime + 1e3 / this.graphsPerSecond, i = this.isWorker ? " ⛭" : "";
if (this.updatePanelComponents(this.fpsPanel, this.averageFps, 0, n, r, i), this.updatePanelComponents(this.msPanel, this.averageCpu, this.precision, n, r, ""), this.workerCpuPanel && this.isWorker && this.updatePanelComponents(this.workerCpuPanel, this.averageWorkerCpu, this.precision, n, r, " ⛭"), this.gpuPanel && this.updatePanelComponents(this.gpuPanel, this.averageGpu, this.precision, n, r, i), this.trackCPT && this.gpuPanelCompute && this.updatePanelComponents(this.gpuPanelCompute, this.averageGpuCompute, this.precision, n, r, i), n && (this.prevTextTime = t), r && (this.prevGraphTime = t, this.texturePanels.size > 0 && !this.textureUpdatePending && (this.textureUpdatePending = !0, this.updateTexturePanels().finally(() => {
this.textureUpdatePending = !1;
})), this.captureStatsGLNodes()), this.vsyncPanel !== null) {
this.detectVSync(t);
let r = ((e = this.detectedVSync) == null ? void 0 : e.refreshRate) || 0;
n && r > 0 && this.vsyncPanel.update(r, r);
}
}
resetCounters() {
this.renderCount = 0, this.totalCpuDuration = 0, this.beginTime = performance.now();
}
resizePanel(e) {
e.canvas.style.position = "absolute", this.minimal ? e.canvas.style.display = "none" : (e.canvas.style.display = "block", this.horizontal ? (e.canvas.style.top = "0px", e.canvas.style.left = e.id * e.WIDTH / e.PR + "px") : (e.canvas.style.left = "0px", e.canvas.style.top = e.id * e.HEIGHT / e.PR + "px"));
}
addPanel(e) {
return e.canvas && (this.dom.appendChild(e.canvas), e.id = this._panelId, this.resizePanel(e), this._panelId++), e;
}
showPanel(e) {
for (let t = 0; t < this.dom.children.length; t++) {
let n = this.dom.children[t];
n.style.display = t === e ? "block" : "none";
}
this.mode = e;
}
addTexturePanel(e) {
this.texturePanelRow || (this.texturePanelRow = document.createElement("div"), this.texturePanelRow.style.cssText = "\n position: absolute;\n top: 48px;\n left: 0;\n display: flex;\n flex-direction: row;\n ", this.dom.appendChild(this.texturePanelRow));
let t = new W(e);
return t.canvas.style.position = "relative", t.canvas.style.left = "", t.canvas.style.top = "", this.texturePanelRow.appendChild(t.canvas), this.texturePanels.set(e, t), t;
}
setTexture(e, t) {
this.updateTexturePreviewDimensions(), this.gl && !this.textureCaptureWebGL && (this.textureCaptureWebGL = new G(this.gl, this.texturePreviewWidth, this.texturePreviewHeight)), this.gpuDevice && !this.textureCaptureWebGPU && (this.textureCaptureWebGPU = new K(this.gpuDevice, this.texturePreviewWidth, this.texturePreviewHeight));
let n = this.texturePanels.get(e);
if (t.isWebGLRenderTarget && this.gl) {
let r = q(t, this.gl);
r && (this.textureSourcesWebGL.set(e, {
target: t,
...r
}), n && n.setSourceSize(r.width, r.height));
return;
}
if (t.isRenderTarget && this.gpuBackend) {
let r = J(t, this.gpuBackend);
r && (this.textureSourcesWebGPU.set(e, r), n && t.width && t.height && n.setSourceSize(t.width, t.height));
return;
}
if (t && typeof t.createView == "function") {
this.textureSourcesWebGPU.set(e, t);
return;
}
}
setTextureWebGL(e, t, n, r) {
this.updateTexturePreviewDimensions(), this.gl && !this.textureCaptureWebGL && (this.textureCaptureWebGL = new G(this.gl, this.texturePreviewWidth, this.texturePreviewHeight)), this.textureSourcesWebGL.set(e, {
target: { isWebGLRenderTarget: !0 },
framebuffer: t,
width: n,
height: r
});
let i = this.texturePanels.get(e);
i && i.setSourceSize(n, r);
}
setTextureBitmap(e, t, n, r) {
let i = this.texturePanels.get(e);
i && (n !== void 0 && r !== void 0 && i.setSourceSize(n, r), i.updateTexture(t));
}
removeTexturePanel(e) {
let t = this.texturePanels.get(e);
t && (t.dispose(), t.canvas.remove(), this.texturePanels.delete(e), this.textureSourcesWebGL.delete(e), this.textureSourcesWebGPU.delete(e));
}
async updateTexturePanels() {
if (this.updateTexturePreviewDimensions(), this.textureCaptureWebGL) for (let [e, t] of this.textureSourcesWebGL) {
let n = this.texturePanels.get(e);
if (n) {
let r = t.framebuffer, i = t.width, a = t.height;
t.target.isWebGLRenderTarget && t.target.__webglFramebuffer && (r = t.target.__webglFramebuffer, i = t.target.width || i, a = t.target.height || a);
let o = await this.textureCaptureWebGL.capture(r, i, a, e);
o && n.updateTexture(o);
}
}
if (this.textureCaptureWebGPU) for (let [e, t] of this.textureSourcesWebGPU) {
let n = this.texturePanels.get(e);
if (n) {
let e = await this.textureCaptureWebGPU.capture(t);
e && n.updateTexture(e);
}
}
}
captureStatsGLNodes() {
let e = this._statsGLCaptures;
if (!(!e || e.size === 0 || !this.renderer)) for (let t of e.values()) t.capture && t.capture(this.renderer);
}
detectVSync(e) {
if (this.lastFrameTime === 0) {
this.lastFrameTime = e;
return;
}
let t = e - this.lastFrameTime;
if (this.lastFrameTime = e, this.frameTimeHistory.push(t), this.frameTimeHistory.length > this.HISTORY_SIZE && this.frameTimeHistory.shift(), this.frameTimeHistory.length < 60) return;
let n = this.frameTimeHistory.reduce((e, t) => e + t) / this.frameTimeHistory.length, r = this.frameTimeHistory.reduce((e, t) => e + (t - n) ** 2, 0) / this.frameTimeHistory.length;
if (Math.sqrt(r) > 2) {
this.detectedVSync = null;
return;
}
let i = null, a = Infinity;
for (let e of this.VSYNC_RATES) {
let t = Math.abs(n - e.frameTime);
t < a && (a = t, i = e);
}
i && a / i.frameTime <= this.VSYNC_THRESHOLD ? this.detectedVSync = i : this.detectedVSync = null;
}
updatePanelComponents(e, t, n, r, i, a = "") {
if (!e || t.logs.length === 0) return;
let o = String(e.id);
o in this.lastMin || (this.lastMin[o] = Infinity, this.lastMax[o] = 0, this.lastValue[o] = 0);
let s = t.logs[t.logs.length - 1];
this.lastMax[o] = Math.max(...t.logs), this.lastMin[o] = Math.min(this.lastMin[o], s), this.lastValue[o] = this.lastValue[o] * .7 + s * .3;
let c = Math.max(Math.max(...t.logs), ...t.graph.slice(-this.samplesGraph));
this.updateCounter++, r && e.update(this.lastValue[o], this.lastMax[o], n, a), i && e.updateGraph(s, c);
}
updatePanel(e, t, n = 2) {
if (!e || t.logs.length === 0) return;
let r = performance.now();
e.name in this.lastMin || (this.lastMin[e.name] = Infinity, this.lastMax[e.name] = 0, this.lastValue[e.name] = 0);
let i = t.logs[t.logs.length - 1], a = Math.max(...t.logs.slice(-30));
this.lastMin[e.name] = Math.min(this.lastMin[e.name], i), this.lastMax[e.name] = Math.max(this.lastMax[e.name], i), this.lastValue[e.name] = this.lastValue[e.name] * .7 + i * .3;
let o = Math.max(a, ...t.graph.slice(-this.samplesGraph));
this.updateCounter++, this.updateCounter % (this.logsPerSecond * 2) == 0 && (this.lastMax[e.name] = a, this.lastMin[e.name] = i), e.update && (r >= this.prevCpuTime + 1e3 / this.logsPerSecond && e.update(this.lastValue[e.name], i, this.lastMax[e.name], o, n), r >= this.prevGraphTime + 1e3 / this.graphsPerSecond && (e.updateGraph(i, o), this.prevGraphTime = r));
}
get domElement() {
return this.dom;
}
dispose() {
this.minimal ? this.dom.removeEventListener("click", this.handleClick) : window.removeEventListener("resize", this.handleResize), this.textureCaptureWebGL && (this.textureCaptureWebGL.dispose(), this.textureCaptureWebGL = null), this.textureCaptureWebGPU && (this.textureCaptureWebGPU.dispose(), this.textureCaptureWebGPU = null);
for (let e of this.texturePanels.values()) e.dispose();
this.texturePanels.clear(), this.textureSourcesWebGL.clear(), this.textureSourcesWebGPU.clear();
let e = this._statsGLCaptures;
if (e) {
for (let t of e.values()) t.dispose && t.dispose();
e.clear();
}
this.texturePanelRow && (this.texturePanelRow.remove(), this.texturePanelRow = null), this.dom.remove(), this.fpsPanel = null, this.msPanel = null, this.gpuPanel = null, this.gpuPanelCompute = null, this.vsyncPanel = null, this.workerCpuPanel = null, this.frameTimeHistory.length = 0, this.averageWorkerCpu.logs.length = 0, this.averageWorkerCpu.graph.length = 0, super.dispose();
}
};
Y.Panel = H, Y.PanelTexture = W;
var X = Y;
//#endregion
//#region ../renderer/src/debug/components/Stats.tsx
function Z() {
let e = (0, l.c)(3), t = a(Q), n, r;
return e[0] === t ? (n = e[1], r = e[2]) : (n = () => {
let e = new X({
trackGPU: !0,
trackHz: !0
});
e.init(t), document.body.appendChild(e.domElement);
let n = o(() => e.update());
return () => {
e.dispose(), n();
};
}, r = [t], e[0] = t, e[1] = n, e[2] = r), (0, u.useEffect)(n, r), null;
}
function Q(e) {
return e.gl;
}
//#endregion
//#region ../renderer/src/debug/components/DebugTools.tsx
function $(e) {
let t = (0, l.c)(4), { children: n } = e, r, i;
t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ (0, p.jsx)(Z, {}), i = /* @__PURE__ */ (0, p.jsx)(R, {}), t[0] = r, t[1] = i) : (r = t[0], i = t[1]);
let a;
return t[2] === n ? a = t[3] : (a = /* @__PURE__ */ (0, p.jsx)(F, { children: /* @__PURE__ */ (0, p.jsxs)(v, { children: [
n,
r,
i
] }) }), t[2] = n, t[3] = a), a;
}
//#endregion
export { $ as DebugTools };
;/* vite-per-chunk-css */
__vite_inject_css__("._info_hhyz2_1{color:#fff;white-space:pre;padding:.5em;font-family:monospace;line-height:1.5}._toggle_hhyz2_9{color:#ebebeb;cursor:pointer;background:#111;border:none;height:25px;padding:0 4px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Arial,sans-serif;font-size:11px;font-weight:600;transition:background .2s}._toggle_hhyz2_9:hover{opacity:.85}._container_hhyz2_26{z-index:1;background:#1f1f1fa0;flex-direction:column-reverse;align-items:stretch;width:250px;display:flex;position:absolute;bottom:0}._left_hhyz2_40{left:0}._right_hhyz2_44{width:350px;right:0}\n/*$vite$:1*/", "DebugTools.css", true);