vitessce 3.9.6 → 4.0.0-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/GeometryAndMeshXR-BXSNjAqF.js +137 -0
  2. package/dist/OrbitControls-sTxvpi67.js +7700 -0
  3. package/dist/{ReactNeuroglancer-BUfn_iuv.js → ReactNeuroglancer-fiVOZeyq.js} +1970 -1969
  4. package/dist/XREnterButton-CqAKdcbm.js +37 -0
  5. package/dist/XRSceneComponents-576Z0OEa.js +48 -0
  6. package/dist/XRWrapper-CEbjgPSQ.js +10 -0
  7. package/dist/{deflate-_PAyjIxQ.js → deflate-CRhk-nLA.js} +1 -1
  8. package/dist/emulate-CAN_KLPP.js +28295 -0
  9. package/dist/{higlass-DKNFlOLu.js → higlass-CxcCRpJe.js} +47279 -45097
  10. package/dist/{index-BMZKt_WD.js → index-D4CxZdC_.js} +190 -189
  11. package/dist/index-D4KH2LJg.js +57 -0
  12. package/dist/{index-CiwyZ_Wn.js → index-DGE5D5mY.js} +99231 -98958
  13. package/dist/index-ZG9rMo1v.js +7680 -0
  14. package/dist/index.min.js +33 -32
  15. package/dist/{jpeg-D6QGAYrj.js → jpeg-CNrYxDrc.js} +14 -14
  16. package/dist/{lerc-CpU83gFy.js → lerc-KMDR2rmU.js} +1 -1
  17. package/dist/living_room-uy_CEYZC.js +11 -0
  18. package/dist/{lzw-IDKOxNdH.js → lzw-Dby8KO0a.js} +10 -10
  19. package/dist/meeting_room-BjXC3fLc.js +11 -0
  20. package/dist/music_room-AFchga9Y.js +11 -0
  21. package/dist/office_large-qDeoZNBo.js +11 -0
  22. package/dist/office_small-B_PLvrYC.js +11 -0
  23. package/dist/packbits-ClNSUn48.js +24 -0
  24. package/dist/raw-ChZAypg0.js +9 -0
  25. package/dist/ray-grab-JOm82e9E.js +3714 -0
  26. package/dist/{webimage-zvGex_8D.js → webimage-BHhPz6os.js} +1 -1
  27. package/dist/xrStore-CEMqzA4H.js +10 -0
  28. package/package.json +7 -7
  29. package/dist/OrbitControls-gS0qAcAF.js +0 -6202
  30. package/dist/index-CApj7rdC.js +0 -6178
  31. package/dist/packbits-Dj8eDgHa.js +0 -24
  32. package/dist/raw-BBDtkWgc.js +0 -9
  33. package/dist/troika-three-text.esm-DtEcqwS6.js +0 -4192
@@ -0,0 +1,3714 @@
1
+ var Sr = Object.defineProperty;
2
+ var Pr = (t, e, n) => e in t ? Sr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var v = (t, e, n) => Pr(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsx as m, jsxs as N, Fragment as q } from "react/jsx-runtime";
5
+ import { ax as qe, M as j, V as w, ap as $, o as Mr, j as W, Q as st, ad as Rr, a6 as Cr, g as Ir, p as Z, ay as _n, ak as On, _ as U, a1 as Pt, az as Tn, aA as Et, aq as Xn, ae as Mt, a2 as Ge, v as $e, ac as Fn, aB as Ar, aC as Er, P as zn, aD as Lr, aE as _r, aF as Or, aG as Tr, aH as we, aI as Xr, aJ as Fr, d as Vt, aK as zr, am as Wr, H as Dr, aL as Hr, aM as Wn, aN as Dn, w as Vr, S as jr, k as Hn, O as kr } from "./index-DGE5D5mY.js";
6
+ import re, { createContext as Ue, forwardRef as _, useImperativeHandle as k, useMemo as A, useState as be, useRef as C, useContext as se, useEffect as O, Suspense as oe, useSyncExternalStore as Br, useCallback as Vn } from "react";
7
+ import { s as Nr, a as X, c as Lt, b as qr, d as ae, u as xe, r as jn, e as kn, f as Gr } from "./OrbitControls-sTxvpi67.js";
8
+ import { createRoot as $r } from "react-dom/client";
9
+ var Ur = Object.defineProperty, Qr = (t, e, n) => e in t ? Ur(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, S = (t, e, n) => (Qr(t, typeof e != "symbol" ? e + "" : e, n), n);
10
+ function ot(t, e, n, r, i) {
11
+ let s;
12
+ if (t = t.subarray || t.slice ? t : t.buffer, n = n.subarray || n.slice ? n : n.buffer, t = e ? t.subarray ? t.subarray(e, i && e + i) : t.slice(e, i && e + i) : t, n.set)
13
+ n.set(t, r);
14
+ else
15
+ for (s = 0; s < t.length; s++)
16
+ n[s + r] = t[s];
17
+ return n;
18
+ }
19
+ function Yr(t) {
20
+ return t instanceof Float32Array ? t : t instanceof qe ? t.getAttribute("position").array : t.map((e) => {
21
+ const n = Array.isArray(e);
22
+ return e instanceof w ? [e.x, e.y, e.z] : e instanceof W ? [e.x, e.y, 0] : n && e.length === 3 ? [e[0], e[1], e[2]] : n && e.length === 2 ? [e[0], e[1], 0] : e;
23
+ }).flat();
24
+ }
25
+ class Kr extends qe {
26
+ constructor() {
27
+ super(), S(this, "type", "MeshLine"), S(this, "isMeshLine", !0), S(this, "positions", []), S(this, "previous", []), S(this, "next", []), S(this, "side", []), S(this, "width", []), S(this, "indices_array", []), S(this, "uvs", []), S(this, "counters", []), S(this, "widthCallback", null), S(this, "_attributes"), S(this, "_points", []), S(this, "points"), S(this, "matrixWorld", new j()), Object.defineProperties(this, {
28
+ points: {
29
+ enumerable: !0,
30
+ get() {
31
+ return this._points;
32
+ },
33
+ set(e) {
34
+ this.setPoints(e, this.widthCallback);
35
+ }
36
+ }
37
+ });
38
+ }
39
+ setMatrixWorld(e) {
40
+ this.matrixWorld = e;
41
+ }
42
+ setPoints(e, n) {
43
+ if (e = Yr(e), this._points = e, this.widthCallback = n ?? null, this.positions = [], this.counters = [], e.length && e[0] instanceof w)
44
+ for (let r = 0; r < e.length; r++) {
45
+ const i = e[r], s = r / (e.length - 1);
46
+ this.positions.push(i.x, i.y, i.z), this.positions.push(i.x, i.y, i.z), this.counters.push(s), this.counters.push(s);
47
+ }
48
+ else
49
+ for (let r = 0; r < e.length; r += 3) {
50
+ const i = r / (e.length - 1);
51
+ this.positions.push(e[r], e[r + 1], e[r + 2]), this.positions.push(e[r], e[r + 1], e[r + 2]), this.counters.push(i), this.counters.push(i);
52
+ }
53
+ this.process();
54
+ }
55
+ compareV3(e, n) {
56
+ const r = e * 6, i = n * 6;
57
+ return this.positions[r] === this.positions[i] && this.positions[r + 1] === this.positions[i + 1] && this.positions[r + 2] === this.positions[i + 2];
58
+ }
59
+ copyV3(e) {
60
+ const n = e * 6;
61
+ return [this.positions[n], this.positions[n + 1], this.positions[n + 2]];
62
+ }
63
+ process() {
64
+ const e = this.positions.length / 6;
65
+ this.previous = [], this.next = [], this.side = [], this.width = [], this.indices_array = [], this.uvs = [];
66
+ let n, r;
67
+ this.compareV3(0, e - 1) ? r = this.copyV3(e - 2) : r = this.copyV3(0), this.previous.push(r[0], r[1], r[2]), this.previous.push(r[0], r[1], r[2]);
68
+ for (let i = 0; i < e; i++) {
69
+ if (this.side.push(1), this.side.push(-1), this.widthCallback ? n = this.widthCallback(i / (e - 1)) : n = 1, this.width.push(n), this.width.push(n), this.uvs.push(i / (e - 1), 0), this.uvs.push(i / (e - 1), 1), i < e - 1) {
70
+ r = this.copyV3(i), this.previous.push(r[0], r[1], r[2]), this.previous.push(r[0], r[1], r[2]);
71
+ const s = i * 2;
72
+ this.indices_array.push(s, s + 1, s + 2), this.indices_array.push(s + 2, s + 1, s + 3);
73
+ }
74
+ i > 0 && (r = this.copyV3(i), this.next.push(r[0], r[1], r[2]), this.next.push(r[0], r[1], r[2]));
75
+ }
76
+ this.compareV3(e - 1, 0) ? r = this.copyV3(1) : r = this.copyV3(e - 1), this.next.push(r[0], r[1], r[2]), this.next.push(r[0], r[1], r[2]), !this._attributes || this._attributes.position.count !== this.counters.length ? this._attributes = {
77
+ position: new $(new Float32Array(this.positions), 3),
78
+ previous: new $(new Float32Array(this.previous), 3),
79
+ next: new $(new Float32Array(this.next), 3),
80
+ side: new $(new Float32Array(this.side), 1),
81
+ width: new $(new Float32Array(this.width), 1),
82
+ uv: new $(new Float32Array(this.uvs), 2),
83
+ index: new $(new Uint16Array(this.indices_array), 1),
84
+ counters: new $(new Float32Array(this.counters), 1)
85
+ } : (this._attributes.position.copyArray(new Float32Array(this.positions)), this._attributes.position.needsUpdate = !0, this._attributes.previous.copyArray(new Float32Array(this.previous)), this._attributes.previous.needsUpdate = !0, this._attributes.next.copyArray(new Float32Array(this.next)), this._attributes.next.needsUpdate = !0, this._attributes.side.copyArray(new Float32Array(this.side)), this._attributes.side.needsUpdate = !0, this._attributes.width.copyArray(new Float32Array(this.width)), this._attributes.width.needsUpdate = !0, this._attributes.uv.copyArray(new Float32Array(this.uvs)), this._attributes.uv.needsUpdate = !0, this._attributes.index.copyArray(new Uint16Array(this.indices_array)), this._attributes.index.needsUpdate = !0), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setAttribute("position", this._attributes.position), this.setAttribute("previous", this._attributes.previous), this.setAttribute("next", this._attributes.next), this.setAttribute("side", this._attributes.side), this.setAttribute("width", this._attributes.width), this.setAttribute("uv", this._attributes.uv), this.setAttribute("counters", this._attributes.counters), this.setIndex(this._attributes.index), this.computeBoundingSphere(), this.computeBoundingBox();
86
+ }
87
+ advance({ x: e, y: n, z: r }) {
88
+ const i = this._attributes.position.array, s = this._attributes.previous.array, o = this._attributes.next.array, a = i.length;
89
+ ot(i, 0, s, 0, a), ot(i, 6, i, 0, a - 6), i[a - 6] = e, i[a - 5] = n, i[a - 4] = r, i[a - 3] = e, i[a - 2] = n, i[a - 1] = r, ot(i, 6, o, 0, a - 6), o[a - 6] = e, o[a - 5] = n, o[a - 4] = r, o[a - 3] = e, o[a - 2] = n, o[a - 1] = r, this._attributes.position.needsUpdate = !0, this._attributes.previous.needsUpdate = !0, this._attributes.next.needsUpdate = !0;
90
+ }
91
+ }
92
+ const Zr = `
93
+ #include <common>
94
+ #include <logdepthbuf_pars_vertex>
95
+ #include <fog_pars_vertex>
96
+ #include <clipping_planes_pars_vertex>
97
+
98
+ attribute vec3 previous;
99
+ attribute vec3 next;
100
+ attribute float side;
101
+ attribute float width;
102
+ attribute float counters;
103
+
104
+ uniform vec2 resolution;
105
+ uniform float lineWidth;
106
+ uniform vec3 color;
107
+ uniform float opacity;
108
+ uniform float sizeAttenuation;
109
+
110
+ varying vec2 vUV;
111
+ varying vec4 vColor;
112
+ varying float vCounters;
113
+
114
+ vec2 fix(vec4 i, float aspect) {
115
+ vec2 res = i.xy / i.w;
116
+ res.x *= aspect;
117
+ return res;
118
+ }
119
+
120
+ void main() {
121
+ float aspect = resolution.x / resolution.y;
122
+ vColor = vec4(color, opacity);
123
+ vUV = uv;
124
+ vCounters = counters;
125
+
126
+ mat4 m = projectionMatrix * modelViewMatrix;
127
+ vec4 finalPosition = m * vec4(position, 1.0) * aspect;
128
+ vec4 prevPos = m * vec4(previous, 1.0);
129
+ vec4 nextPos = m * vec4(next, 1.0);
130
+
131
+ vec2 currentP = fix(finalPosition, aspect);
132
+ vec2 prevP = fix(prevPos, aspect);
133
+ vec2 nextP = fix(nextPos, aspect);
134
+
135
+ float w = lineWidth * width;
136
+
137
+ vec2 dir;
138
+ if (nextP == currentP) dir = normalize(currentP - prevP);
139
+ else if (prevP == currentP) dir = normalize(nextP - currentP);
140
+ else {
141
+ vec2 dir1 = normalize(currentP - prevP);
142
+ vec2 dir2 = normalize(nextP - currentP);
143
+ dir = normalize(dir1 + dir2);
144
+
145
+ vec2 perp = vec2(-dir1.y, dir1.x);
146
+ vec2 miter = vec2(-dir.y, dir.x);
147
+ //w = clamp(w / dot(miter, perp), 0., 4. * lineWidth * width);
148
+ }
149
+
150
+ //vec2 normal = (cross(vec3(dir, 0.), vec3(0., 0., 1.))).xy;
151
+ vec4 normal = vec4(-dir.y, dir.x, 0., 1.);
152
+ normal.xy *= .5 * w;
153
+ //normal *= projectionMatrix;
154
+ if (sizeAttenuation == 0.) {
155
+ normal.xy *= finalPosition.w;
156
+ normal.xy /= (vec4(resolution, 0., 1.) * projectionMatrix).xy * aspect;
157
+ }
158
+
159
+ finalPosition.xy += normal.xy * side;
160
+ gl_Position = finalPosition;
161
+ #include <logdepthbuf_vertex>
162
+ #include <fog_vertex>
163
+ vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
164
+ #include <clipping_planes_vertex>
165
+ #include <fog_vertex>
166
+ }
167
+ `, Jr = parseInt(Cr.replace(/\D+/g, "")), ei = Jr >= 154 ? "colorspace_fragment" : "encodings_fragment", ti = `
168
+ #include <fog_pars_fragment>
169
+ #include <logdepthbuf_pars_fragment>
170
+ #include <clipping_planes_pars_fragment>
171
+
172
+ uniform sampler2D map;
173
+ uniform sampler2D alphaMap;
174
+ uniform float useGradient;
175
+ uniform float useMap;
176
+ uniform float useAlphaMap;
177
+ uniform float useDash;
178
+ uniform float dashArray;
179
+ uniform float dashOffset;
180
+ uniform float dashRatio;
181
+ uniform float visibility;
182
+ uniform float alphaTest;
183
+ uniform vec2 repeat;
184
+ uniform vec3 gradient[2];
185
+
186
+ varying vec2 vUV;
187
+ varying vec4 vColor;
188
+ varying float vCounters;
189
+
190
+ void main() {
191
+ #include <logdepthbuf_fragment>
192
+ vec4 diffuseColor = vColor;
193
+ if (useGradient == 1.) diffuseColor = vec4(mix(gradient[0], gradient[1], vCounters), 1.0);
194
+ if (useMap == 1.) diffuseColor *= texture2D(map, vUV * repeat);
195
+ if (useAlphaMap == 1.) diffuseColor.a *= texture2D(alphaMap, vUV * repeat).a;
196
+ if (diffuseColor.a < alphaTest) discard;
197
+ if (useDash == 1.) diffuseColor.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
198
+ diffuseColor.a *= step(vCounters, visibility);
199
+ #include <clipping_planes_fragment>
200
+ gl_FragColor = diffuseColor;
201
+ #include <fog_fragment>
202
+ #include <tonemapping_fragment>
203
+ #include <${ei}>
204
+ }
205
+ `;
206
+ class ni extends Mr {
207
+ constructor(e) {
208
+ super({
209
+ uniforms: {
210
+ ...Rr.fog,
211
+ lineWidth: { value: 1 },
212
+ map: { value: null },
213
+ useMap: { value: 0 },
214
+ alphaMap: { value: null },
215
+ useAlphaMap: { value: 0 },
216
+ color: { value: new st(16777215) },
217
+ gradient: { value: [new st(16711680), new st(65280)] },
218
+ opacity: { value: 1 },
219
+ resolution: { value: new W(1, 1) },
220
+ sizeAttenuation: { value: 1 },
221
+ dashArray: { value: 0 },
222
+ dashOffset: { value: 0 },
223
+ dashRatio: { value: 0.5 },
224
+ useDash: { value: 0 },
225
+ useGradient: { value: 0 },
226
+ visibility: { value: 1 },
227
+ alphaTest: { value: 0 },
228
+ repeat: { value: new W(1, 1) }
229
+ },
230
+ vertexShader: Zr,
231
+ fragmentShader: ti
232
+ }), S(this, "lineWidth"), S(this, "map"), S(this, "useMap"), S(this, "alphaMap"), S(this, "useAlphaMap"), S(this, "color"), S(this, "gradient"), S(this, "resolution"), S(this, "sizeAttenuation"), S(this, "dashArray"), S(this, "dashOffset"), S(this, "dashRatio"), S(this, "useDash"), S(this, "useGradient"), S(this, "visibility"), S(this, "repeat"), this.type = "MeshLineMaterial", Object.defineProperties(this, {
233
+ lineWidth: {
234
+ enumerable: !0,
235
+ get() {
236
+ return this.uniforms.lineWidth.value;
237
+ },
238
+ set(n) {
239
+ this.uniforms.lineWidth.value = n;
240
+ }
241
+ },
242
+ map: {
243
+ enumerable: !0,
244
+ get() {
245
+ return this.uniforms.map.value;
246
+ },
247
+ set(n) {
248
+ this.uniforms.map.value = n;
249
+ }
250
+ },
251
+ useMap: {
252
+ enumerable: !0,
253
+ get() {
254
+ return this.uniforms.useMap.value;
255
+ },
256
+ set(n) {
257
+ this.uniforms.useMap.value = n;
258
+ }
259
+ },
260
+ alphaMap: {
261
+ enumerable: !0,
262
+ get() {
263
+ return this.uniforms.alphaMap.value;
264
+ },
265
+ set(n) {
266
+ this.uniforms.alphaMap.value = n;
267
+ }
268
+ },
269
+ useAlphaMap: {
270
+ enumerable: !0,
271
+ get() {
272
+ return this.uniforms.useAlphaMap.value;
273
+ },
274
+ set(n) {
275
+ this.uniforms.useAlphaMap.value = n;
276
+ }
277
+ },
278
+ color: {
279
+ enumerable: !0,
280
+ get() {
281
+ return this.uniforms.color.value;
282
+ },
283
+ set(n) {
284
+ this.uniforms.color.value = n;
285
+ }
286
+ },
287
+ gradient: {
288
+ enumerable: !0,
289
+ get() {
290
+ return this.uniforms.gradient.value;
291
+ },
292
+ set(n) {
293
+ this.uniforms.gradient.value = n;
294
+ }
295
+ },
296
+ opacity: {
297
+ enumerable: !0,
298
+ get() {
299
+ return this.uniforms.opacity.value;
300
+ },
301
+ set(n) {
302
+ this.uniforms.opacity.value = n;
303
+ }
304
+ },
305
+ resolution: {
306
+ enumerable: !0,
307
+ get() {
308
+ return this.uniforms.resolution.value;
309
+ },
310
+ set(n) {
311
+ this.uniforms.resolution.value.copy(n);
312
+ }
313
+ },
314
+ sizeAttenuation: {
315
+ enumerable: !0,
316
+ get() {
317
+ return this.uniforms.sizeAttenuation.value;
318
+ },
319
+ set(n) {
320
+ this.uniforms.sizeAttenuation.value = n;
321
+ }
322
+ },
323
+ dashArray: {
324
+ enumerable: !0,
325
+ get() {
326
+ return this.uniforms.dashArray.value;
327
+ },
328
+ set(n) {
329
+ this.uniforms.dashArray.value = n, this.useDash = n !== 0 ? 1 : 0;
330
+ }
331
+ },
332
+ dashOffset: {
333
+ enumerable: !0,
334
+ get() {
335
+ return this.uniforms.dashOffset.value;
336
+ },
337
+ set(n) {
338
+ this.uniforms.dashOffset.value = n;
339
+ }
340
+ },
341
+ dashRatio: {
342
+ enumerable: !0,
343
+ get() {
344
+ return this.uniforms.dashRatio.value;
345
+ },
346
+ set(n) {
347
+ this.uniforms.dashRatio.value = n;
348
+ }
349
+ },
350
+ useDash: {
351
+ enumerable: !0,
352
+ get() {
353
+ return this.uniforms.useDash.value;
354
+ },
355
+ set(n) {
356
+ this.uniforms.useDash.value = n;
357
+ }
358
+ },
359
+ useGradient: {
360
+ enumerable: !0,
361
+ get() {
362
+ return this.uniforms.useGradient.value;
363
+ },
364
+ set(n) {
365
+ this.uniforms.useGradient.value = n;
366
+ }
367
+ },
368
+ visibility: {
369
+ enumerable: !0,
370
+ get() {
371
+ return this.uniforms.visibility.value;
372
+ },
373
+ set(n) {
374
+ this.uniforms.visibility.value = n;
375
+ }
376
+ },
377
+ alphaTest: {
378
+ enumerable: !0,
379
+ get() {
380
+ return this.uniforms.alphaTest.value;
381
+ },
382
+ set(n) {
383
+ this.uniforms.alphaTest.value = n;
384
+ }
385
+ },
386
+ repeat: {
387
+ enumerable: !0,
388
+ get() {
389
+ return this.uniforms.repeat.value;
390
+ },
391
+ set(n) {
392
+ this.uniforms.repeat.value.copy(n);
393
+ }
394
+ }
395
+ }), this.setValues(e);
396
+ }
397
+ copy(e) {
398
+ return super.copy(e), this.lineWidth = e.lineWidth, this.map = e.map, this.useMap = e.useMap, this.alphaMap = e.alphaMap, this.useAlphaMap = e.useAlphaMap, this.color.copy(e.color), this.gradient = e.gradient, this.opacity = e.opacity, this.resolution.copy(e.resolution), this.sizeAttenuation = e.sizeAttenuation, this.dashArray = e.dashArray, this.dashOffset = e.dashOffset, this.dashRatio = e.dashRatio, this.useDash = e.useDash, this.useGradient = e.useGradient, this.visibility = e.visibility, this.alphaTest = e.alphaTest, this.repeat.copy(e.repeat), this;
399
+ }
400
+ }
401
+ const ri = {}, jt = (t) => {
402
+ let e;
403
+ const n = /* @__PURE__ */ new Set(), r = (p, c) => {
404
+ const h = typeof p == "function" ? p(e) : p;
405
+ if (!Object.is(h, e)) {
406
+ const d = e;
407
+ e = c ?? (typeof h != "object" || h === null) ? h : Object.assign({}, e, h), n.forEach((g) => g(e, d));
408
+ }
409
+ }, i = () => e, l = { setState: r, getState: i, getInitialState: () => u, subscribe: (p) => (n.add(p), () => n.delete(p)), destroy: () => {
410
+ (ri ? "lib" : void 0) !== "production" && console.warn(
411
+ "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
412
+ ), n.clear();
413
+ } }, u = e = t(r, i, l);
414
+ return l;
415
+ }, Bn = (t) => t ? jt(t) : jt;
416
+ var at = { exports: {} }, lt = {}, ut = { exports: {} }, ct = {};
417
+ /**
418
+ * @license React
419
+ * use-sync-external-store-shim.production.min.js
420
+ *
421
+ * Copyright (c) Facebook, Inc. and its affiliates.
422
+ *
423
+ * This source code is licensed under the MIT license found in the
424
+ * LICENSE file in the root directory of this source tree.
425
+ */
426
+ var kt;
427
+ function ii() {
428
+ if (kt) return ct;
429
+ kt = 1;
430
+ var t = re;
431
+ function e(c, h) {
432
+ return c === h && (c !== 0 || 1 / c === 1 / h) || c !== c && h !== h;
433
+ }
434
+ var n = typeof Object.is == "function" ? Object.is : e, r = t.useState, i = t.useEffect, s = t.useLayoutEffect, o = t.useDebugValue;
435
+ function a(c, h) {
436
+ var d = h(), g = r({ inst: { value: d, getSnapshot: h } }), y = g[0].inst, f = g[1];
437
+ return s(function() {
438
+ y.value = d, y.getSnapshot = h, l(y) && f({ inst: y });
439
+ }, [c, d, h]), i(function() {
440
+ return l(y) && f({ inst: y }), c(function() {
441
+ l(y) && f({ inst: y });
442
+ });
443
+ }, [c]), o(d), d;
444
+ }
445
+ function l(c) {
446
+ var h = c.getSnapshot;
447
+ c = c.value;
448
+ try {
449
+ var d = h();
450
+ return !n(c, d);
451
+ } catch {
452
+ return !0;
453
+ }
454
+ }
455
+ function u(c, h) {
456
+ return h();
457
+ }
458
+ var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : a;
459
+ return ct.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : p, ct;
460
+ }
461
+ var Bt;
462
+ function si() {
463
+ return Bt || (Bt = 1, ut.exports = ii()), ut.exports;
464
+ }
465
+ /**
466
+ * @license React
467
+ * use-sync-external-store-shim/with-selector.production.min.js
468
+ *
469
+ * Copyright (c) Facebook, Inc. and its affiliates.
470
+ *
471
+ * This source code is licensed under the MIT license found in the
472
+ * LICENSE file in the root directory of this source tree.
473
+ */
474
+ var Nt;
475
+ function oi() {
476
+ if (Nt) return lt;
477
+ Nt = 1;
478
+ var t = re, e = si();
479
+ function n(u, p) {
480
+ return u === p && (u !== 0 || 1 / u === 1 / p) || u !== u && p !== p;
481
+ }
482
+ var r = typeof Object.is == "function" ? Object.is : n, i = e.useSyncExternalStore, s = t.useRef, o = t.useEffect, a = t.useMemo, l = t.useDebugValue;
483
+ return lt.useSyncExternalStoreWithSelector = function(u, p, c, h, d) {
484
+ var g = s(null);
485
+ if (g.current === null) {
486
+ var y = { hasValue: !1, value: null };
487
+ g.current = y;
488
+ } else y = g.current;
489
+ g = a(function() {
490
+ function R(L) {
491
+ if (!I) {
492
+ if (I = !0, b = L, L = h(L), d !== void 0 && y.hasValue) {
493
+ var H = y.value;
494
+ if (d(H, L)) return T = H;
495
+ }
496
+ return T = L;
497
+ }
498
+ if (H = T, r(b, L)) return H;
499
+ var P = h(L);
500
+ return d !== void 0 && d(H, P) ? H : (b = L, T = P);
501
+ }
502
+ var I = !1, b, T, D = c === void 0 ? null : c;
503
+ return [function() {
504
+ return R(p());
505
+ }, D === null ? void 0 : function() {
506
+ return R(D());
507
+ }];
508
+ }, [p, c, h, d]);
509
+ var f = i(u, g[0], g[1]);
510
+ return o(function() {
511
+ y.hasValue = !0, y.value = f;
512
+ }, [f]), l(f), f;
513
+ }, lt;
514
+ }
515
+ var qt;
516
+ function ai() {
517
+ return qt || (qt = 1, at.exports = oi()), at.exports;
518
+ }
519
+ var li = ai();
520
+ const ui = /* @__PURE__ */ Ir(li), Nn = {}, { useDebugValue: ci } = re, { useSyncExternalStoreWithSelector: di } = ui;
521
+ let Gt = !1;
522
+ const fi = (t) => t;
523
+ function Qe(t, e = fi, n) {
524
+ (Nn ? "lib" : void 0) !== "production" && n && !Gt && (console.warn(
525
+ "[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
526
+ ), Gt = !0);
527
+ const r = di(
528
+ t.subscribe,
529
+ t.getState,
530
+ t.getServerState || t.getInitialState,
531
+ e,
532
+ n
533
+ );
534
+ return ci(r), r;
535
+ }
536
+ const $t = (t) => {
537
+ (Nn ? "lib" : void 0) !== "production" && typeof t != "function" && console.warn(
538
+ "[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
539
+ );
540
+ const e = typeof t == "function" ? Bn(t) : t, n = (r, i) => Qe(e, r, i);
541
+ return Object.assign(n, e), n;
542
+ }, qn = (t) => t ? $t(t) : $t;
543
+ var Ut, Qt;
544
+ const Yt = typeof window < "u" && ((Ut = window.document) != null && Ut.createElement || ((Qt = window.navigator) == null ? void 0 : Qt.product) === "ReactNative") ? re.useLayoutEffect : re.useEffect;
545
+ function hi() {
546
+ const t = qn((e) => ({
547
+ current: new Array(),
548
+ version: 0,
549
+ set: e
550
+ }));
551
+ return {
552
+ In: ({
553
+ children: e
554
+ }) => {
555
+ const n = t((i) => i.set), r = t((i) => i.version);
556
+ return Yt(() => {
557
+ n((i) => ({
558
+ version: i.version + 1
559
+ }));
560
+ }, []), Yt(() => (n(({
561
+ current: i
562
+ }) => ({
563
+ current: [...i, e]
564
+ })), () => n(({
565
+ current: i
566
+ }) => ({
567
+ current: i.filter((s) => s !== e)
568
+ }))), [e, r]), null;
569
+ },
570
+ Out: () => {
571
+ const e = t((n) => n.current);
572
+ return /* @__PURE__ */ re.createElement(re.Fragment, null, e);
573
+ }
574
+ };
575
+ }
576
+ function We(t, e, n) {
577
+ return Math.max(e, Math.min(n, t));
578
+ }
579
+ const pi = 0.05, Kt = 0.1;
580
+ function Gn(t, e, n) {
581
+ const r = e.gamepad;
582
+ if (r == null)
583
+ return;
584
+ const i = n.components;
585
+ for (const s in i) {
586
+ let o = t[s];
587
+ o == null && (t[s] = o = {});
588
+ const { gamepadIndices: a } = i[s];
589
+ let l = !1, u = !1;
590
+ if (a.button != null && a.button < r.buttons.length) {
591
+ const p = r.buttons[a.button];
592
+ o.button = We(p.value, 0, 1), l || (l = p.pressed || o.button === 1), u || (u = p.touched || o.button > pi);
593
+ }
594
+ a.xAxis != null && a.xAxis < r.axes.length && (o.xAxis = We(r.axes[a.xAxis], -1, 1), u || (u = Math.abs(o.xAxis) > Kt)), a.yAxis != null && a.yAxis < r.axes.length && (o.yAxis = We(r.axes[a.yAxis], -1, 1), u || (u = Math.abs(o.yAxis) > Kt)), o.state = l ? "pressed" : u ? "touched" : "default";
595
+ }
596
+ }
597
+ function mi(t) {
598
+ return {
599
+ //distances: {},
600
+ //name: undefined,
601
+ data: new Float32Array(t.size * 16)
602
+ };
603
+ }
604
+ function gi(t, e, n, r, i) {
605
+ const s = r.getReferenceSpace();
606
+ s == null || e == null || e.session.visibilityState === "visible-blurred" || e.session.visibilityState === "hidden" || yi(e, s, n, t.data);
607
+ }
608
+ const dt = new j(), ft = new j();
609
+ function yi(t, e, n, r) {
610
+ if (!t.fillPoses(n.values(), e, r))
611
+ return !1;
612
+ dt.fromArray(r, 0), dt.invert();
613
+ for (let s = 0; s < r.length; s += 16)
614
+ ft.fromArray(r, s), ft.premultiply(dt), ft.toArray(r, s);
615
+ return !0;
616
+ }
617
+ function vi(t) {
618
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = t.clone();
619
+ return $n(t, r, function(i, s) {
620
+ e.set(s, i), n.set(i, s);
621
+ }), r.traverse(function(i) {
622
+ if (!i.isSkinnedMesh) return;
623
+ const s = i, o = e.get(i), a = o.skeleton.bones;
624
+ s.skeleton = o.skeleton.clone(), s.bindMatrix.copy(o.bindMatrix), s.skeleton.bones = a.map(function(l) {
625
+ return n.get(l);
626
+ }), s.bind(s.skeleton, s.bindMatrix);
627
+ }), r;
628
+ }
629
+ function $n(t, e, n) {
630
+ n(t, e);
631
+ for (let r = 0; r < t.children.length; r++)
632
+ $n(t.children[r], e.children[r], n);
633
+ }
634
+ const wi = "generic-hand";
635
+ function bi(t, e) {
636
+ const n = e?.baseAssetPath ?? hr, r = e?.defaultXRHandProfileId ?? wi;
637
+ return new URL(`${r}/${t}.glb`, n).href;
638
+ }
639
+ function xi({ scene: t }) {
640
+ const e = vi(t), n = e.getObjectByProperty("type", "SkinnedMesh");
641
+ if (n == null)
642
+ throw new Error("missing SkinnedMesh in loaded XRHand model");
643
+ return n.frustumCulled = !1, e;
644
+ }
645
+ function Si(t, e) {
646
+ t.renderOrder = e?.renderOrder ?? 0, t.traverse((n) => {
647
+ n instanceof Z && n.material instanceof _n && (n.material.colorWrite = e?.colorWrite ?? !0);
648
+ });
649
+ }
650
+ function Pi(t, e, n, r, i) {
651
+ return {
652
+ id: t,
653
+ isPrimary: i,
654
+ type: "hand",
655
+ inputSource: e,
656
+ pose: mi(e.hand),
657
+ assetPath: bi(e.handedness, n),
658
+ events: r
659
+ };
660
+ }
661
+ function Mi({ inputSource: t, pose: e }, n, r) {
662
+ gi(e, n, t.hand, r, t.handedness);
663
+ }
664
+ const Ri = [
665
+ "wrist",
666
+ "thumb-metacarpal",
667
+ "thumb-phalanx-proximal",
668
+ "thumb-phalanx-distal",
669
+ "thumb-tip",
670
+ "index-finger-metacarpal",
671
+ "index-finger-phalanx-proximal",
672
+ "index-finger-phalanx-intermediate",
673
+ "index-finger-phalanx-distal",
674
+ "index-finger-tip",
675
+ "middle-finger-metacarpal",
676
+ "middle-finger-phalanx-proximal",
677
+ "middle-finger-phalanx-intermediate",
678
+ "middle-finger-phalanx-distal",
679
+ "middle-finger-tip",
680
+ "ring-finger-metacarpal",
681
+ "ring-finger-phalanx-proximal",
682
+ "ring-finger-phalanx-intermediate",
683
+ "ring-finger-phalanx-distal",
684
+ "ring-finger-tip",
685
+ "pinky-finger-metacarpal",
686
+ "pinky-finger-phalanx-proximal",
687
+ "pinky-finger-phalanx-intermediate",
688
+ "pinky-finger-phalanx-distal",
689
+ "pinky-finger-tip"
690
+ ];
691
+ function Ci(t, e, n) {
692
+ const r = new Float32Array(t.size * 16), i = Ri.map((s) => {
693
+ const o = e.getObjectByName(s);
694
+ if (o == null)
695
+ throw new Error(`missing joint "${s}" in hand model`);
696
+ return o.matrixAutoUpdate = !1, o;
697
+ });
698
+ return (s) => {
699
+ const o = typeof n == "function" ? n() : n;
700
+ if (s == null || o == null)
701
+ return;
702
+ s.fillPoses(t.values(), o, r);
703
+ const a = i.length;
704
+ for (let l = 0; l < a; l++)
705
+ i[l].matrix.fromArray(r, l * 16);
706
+ };
707
+ }
708
+ function Ii(t) {
709
+ return t != null && typeof t == "object" && "inputSource" in t;
710
+ }
711
+ function Ai(t, e) {
712
+ const n = (r) => e.push(r);
713
+ return t.addEventListener("selectstart", n), t.addEventListener("selectend", n), t.addEventListener("select", n), t.addEventListener("squeeze", n), t.addEventListener("squeezestart", n), t.addEventListener("squeezeend", n), () => {
714
+ t.removeEventListener("selectstart", n), t.removeEventListener("selectend", n), t.removeEventListener("select", n), t.removeEventListener("squeeze", n), t.removeEventListener("squeezestart", n), t.removeEventListener("squeezeend", n);
715
+ };
716
+ }
717
+ let Ei = 0;
718
+ function Li(t, e) {
719
+ const n = /* @__PURE__ */ new Map(), r = new io(e), i = /* @__PURE__ */ new Map();
720
+ return (s, o, a) => {
721
+ if (a === "remove-all") {
722
+ for (const u of n.values())
723
+ u();
724
+ return o;
725
+ }
726
+ const l = [...o];
727
+ for (const { added: u, isPrimary: p, removed: c } of a) {
728
+ if (c != null)
729
+ for (const h of c) {
730
+ const d = l.findIndex(({ inputSource: g, isPrimary: y }) => y === p && g === h);
731
+ d !== -1 && (l.splice(d, 1), n.get(h)?.(), n.delete(h));
732
+ }
733
+ if (u != null)
734
+ for (const h of u) {
735
+ const d = [];
736
+ let g = Ai(s, d);
737
+ const y = `${h.handedness}-${h.hand ? "hand" : "nohand"}-${h.targetRayMode}-${h.profiles.join(",")}`;
738
+ let f;
739
+ if ((f = i.get(y)) == null && i.set(y, f = `${Ei++}`), h.hand != null)
740
+ l.push(Pi(f, h, e, d, p));
741
+ else
742
+ switch (h.targetRayMode) {
743
+ case "gaze":
744
+ l.push({ id: f, isPrimary: p, type: "gaze", inputSource: h, events: d });
745
+ break;
746
+ case "screen":
747
+ l.push({ id: f, isPrimary: p, type: "screenInput", inputSource: h, events: d });
748
+ break;
749
+ case "transient-pointer":
750
+ l.push({ id: f, isPrimary: p, type: "transientPointer", inputSource: h, events: d });
751
+ break;
752
+ case "tracked-pointer":
753
+ let R = !1;
754
+ const I = g;
755
+ g = () => {
756
+ I(), R = !0;
757
+ };
758
+ const b = so(f, h, r, d, p);
759
+ b instanceof Promise ? b.then((T) => !R && t(T)).catch(console.error) : l.push(b);
760
+ break;
761
+ }
762
+ n.set(h, g);
763
+ }
764
+ }
765
+ return l;
766
+ };
767
+ }
768
+ function _i(t, e) {
769
+ const n = (r, i) => {
770
+ i != null && r.visibilityState === i.visibilityState || e(r.visibilityState === "visible");
771
+ };
772
+ return n(t.getState()), t.subscribe(n);
773
+ }
774
+ class Oi extends On {
775
+ constructor() {
776
+ super({ transparent: !0, toneMapped: !1, depthWrite: !1 });
777
+ }
778
+ onBeforeCompile(e, n) {
779
+ super.onBeforeCompile(e, n), e.vertexShader = `varying vec2 vLocalPosition;
780
+ ` + e.vertexShader, e.vertexShader = e.vertexShader.replace("#include <color_vertex>", `#include <color_vertex>
781
+ vLocalPosition = position.xy * 2.0;`), e.fragmentShader = `varying vec2 vLocalPosition;
782
+ ` + e.fragmentShader, e.fragmentShader = e.fragmentShader.replace("#include <color_fragment>", `#include <color_fragment>
783
+ float value = max(0.0, 1.0 - sqrt(dot(vLocalPosition, vLocalPosition)));
784
+ diffuseColor.a = diffuseColor.a * value * value;`);
785
+ }
786
+ }
787
+ const Ti = new w(0, 0, 1), Zt = new U(), ht = new w();
788
+ function Xi(t, e, n, r, i) {
789
+ const s = r.getIntersection();
790
+ if (s == null || !r.getEnabled() || s.object.isVoidObject === !0 || !Un(t)) {
791
+ e.visible = !1;
792
+ return;
793
+ }
794
+ e.visible = !0;
795
+ const o = typeof i.color == "function" ? i.color(r) : i.color;
796
+ Array.isArray(o) ? n.color.set(...o) : n.color.set(o ?? "white"), n.opacity = typeof i.opacity == "function" ? i.opacity(r) : i.opacity ?? 0.4, e.position.copy(s.pointOnFace), e.scale.setScalar(i.size ?? 0.1);
797
+ const a = s.normal ?? s.face?.normal;
798
+ a != null && (Zt.setFromUnitVectors(Ti, a), s.object.getWorldQuaternion(e.quaternion), e.quaternion.multiply(Zt), ht.set(0, 0, i.cursorOffset ?? 0.01), ht.applyQuaternion(e.quaternion), e.position.add(ht)), e.updateMatrix();
799
+ }
800
+ function Un({ visible: t, parent: e }) {
801
+ return t ? e == null ? !0 : Un(e) : !1;
802
+ }
803
+ class Fi extends On {
804
+ constructor() {
805
+ super({ transparent: !0, toneMapped: !1 });
806
+ }
807
+ onBeforeCompile(e, n) {
808
+ super.onBeforeCompile(e, n), e.vertexShader = `varying float vFade;
809
+ ` + e.vertexShader, e.vertexShader = e.vertexShader.replace("#include <color_vertex>", `#include <color_vertex>
810
+ vFade = position.z + 0.5;`), e.fragmentShader = `varying float vFade;
811
+ ` + e.fragmentShader, e.fragmentShader = e.fragmentShader.replace("#include <color_fragment>", `#include <color_fragment>
812
+ diffuseColor.a *= vFade;`);
813
+ }
814
+ }
815
+ function zi(t, e, n, r) {
816
+ const i = n.getIntersection();
817
+ if (!n.getEnabled() || i == null) {
818
+ t.visible = !1;
819
+ return;
820
+ }
821
+ t.visible = !0;
822
+ const s = typeof r.color == "function" ? r.color(n) : r.color;
823
+ Array.isArray(s) ? e.color.set(...s) : e.color.set(s ?? "white"), e.opacity = typeof r.opacity == "function" ? r.opacity(n) : r.opacity ?? 0.4;
824
+ const o = Math.min(r.maxLength ?? 1, i.distance);
825
+ t.position.z = -o / 2;
826
+ const a = r.size ?? 5e-3;
827
+ t.scale.set(a, a, o), t.updateMatrix();
828
+ }
829
+ function Wi(t, e, n, r, i, s = {}) {
830
+ const o = (c) => {
831
+ c.inputSource === n && t.down(Object.assign(c, { button: s.button ?? 0 }));
832
+ }, a = (c) => {
833
+ c.inputSource === n && t.up(Object.assign(c, { button: s.button ?? 0 }));
834
+ }, l = `${r}start`, u = `${r}end`, p = i.length;
835
+ for (let c = 0; c < p; c++) {
836
+ const h = i[c];
837
+ switch (h.type) {
838
+ case l:
839
+ o(h);
840
+ break;
841
+ case u:
842
+ a(h);
843
+ break;
844
+ }
845
+ }
846
+ return e.addEventListener(l, o), e.addEventListener(u, a), () => {
847
+ e.removeEventListener(l, o), e.removeEventListener(u, a);
848
+ };
849
+ }
850
+ function Di(t) {
851
+ return t.getButtonsDown().size > 0 ? 0.6 : Qn(t.getIntersection()?.distance ?? 1 / 0, 0.07, 0, 0.2, 0.4);
852
+ }
853
+ function De(t) {
854
+ return t.getButtonsDown().size > 0 ? 0.6 : 0.4;
855
+ }
856
+ function Hi(t) {
857
+ return Qn(t.getIntersection()?.distance ?? 1 / 0, 0.1, 0.03, 0.2, 0.6);
858
+ }
859
+ function Qn(t, e, n, r, i) {
860
+ return r + Math.max(0, Math.min(1, (t - e) / (n - e))) * (i - r);
861
+ }
862
+ function Vi(t, e) {
863
+ return (n, r) => {
864
+ if (t === e)
865
+ return n.identity(), !0;
866
+ const i = typeof e == "function" ? e() : e;
867
+ if (i == null)
868
+ return !1;
869
+ const s = r?.getPose(t, i);
870
+ return s == null ? !1 : (n.fromArray(s.transform.matrix), !0);
871
+ };
872
+ }
873
+ function Ye(t, e, n, r) {
874
+ t.updateWorldMatrix(!0, !1), r?.copy(t.matrix);
875
+ const i = Yn(t.parent, t, r);
876
+ return i ?? (r != null && ji(t, e, r), n);
877
+ }
878
+ function ji(t, e, n) {
879
+ if (t.updateWorldMatrix(!0, !1), e == null) {
880
+ n.copy(t.matrixWorld);
881
+ return;
882
+ }
883
+ e.updateWorldMatrix(!0, !1), n.copy(e.matrixWorld).invert().multiply(t.matrixWorld);
884
+ }
885
+ function Yn(t, e, n) {
886
+ if (t != null)
887
+ return t.xrSpace != null ? (n?.copy(t.matrixWorld).invert().multiply(e.matrixWorld), t.xrSpace) : Yn(t.parent, e, n);
888
+ }
889
+ class ki {
890
+ constructor(e) {
891
+ v(this, "nativeEvent");
892
+ v(this, "NONE", 0);
893
+ v(this, "CAPTURING_PHASE", 1);
894
+ v(this, "AT_TARGET", 2);
895
+ v(this, "BUBBLING_PHASE", 3);
896
+ v(this, "relatedTarget", null);
897
+ this.nativeEvent = e;
898
+ }
899
+ get altKey() {
900
+ return this.getFromNative("altKey", !1);
901
+ }
902
+ get button() {
903
+ return this.getFromNative("button", 0);
904
+ }
905
+ get buttons() {
906
+ return this.getFromNative("buttons", 0);
907
+ }
908
+ get clientX() {
909
+ return this.getFromNative("clientX", 0);
910
+ }
911
+ get clientY() {
912
+ return this.getFromNative("clientY", 0);
913
+ }
914
+ get ctrlKey() {
915
+ return this.getFromNative("ctrlKey", !1);
916
+ }
917
+ get layerX() {
918
+ return this.getFromNative("layerX", 0);
919
+ }
920
+ get layerY() {
921
+ return this.getFromNative("layerY", 0);
922
+ }
923
+ get metaKey() {
924
+ return this.getFromNative("metaKey", !1);
925
+ }
926
+ get movementX() {
927
+ return this.getFromNative("movementX", 0);
928
+ }
929
+ get movementY() {
930
+ return this.getFromNative("movementY", 0);
931
+ }
932
+ get offsetX() {
933
+ return this.getFromNative("offsetX", 0);
934
+ }
935
+ get offsetY() {
936
+ return this.getFromNative("offsetY", 0);
937
+ }
938
+ get pageX() {
939
+ return this.getFromNative("pageX", 0);
940
+ }
941
+ get pageY() {
942
+ return this.getFromNative("pageY", 0);
943
+ }
944
+ get screenX() {
945
+ return this.getFromNative("screenX", 0);
946
+ }
947
+ get screenY() {
948
+ return this.getFromNative("screenY", 0);
949
+ }
950
+ get shiftKey() {
951
+ return this.getFromNative("shiftKey", !1);
952
+ }
953
+ get x() {
954
+ return this.getFromNative("x", 0);
955
+ }
956
+ get y() {
957
+ return this.getFromNative("y", 0);
958
+ }
959
+ get detail() {
960
+ return this.getFromNative("detail", 0);
961
+ }
962
+ get view() {
963
+ return this.getFromNative("view", null);
964
+ }
965
+ get which() {
966
+ return this.getFromNative("which", 0);
967
+ }
968
+ get cancelBubble() {
969
+ return this.getFromNative("cancelBubble", !1);
970
+ }
971
+ get composed() {
972
+ return this.getFromNative("composed", !1);
973
+ }
974
+ get eventPhase() {
975
+ return this.getFromNative("eventPhase", 0);
976
+ }
977
+ get isTrusted() {
978
+ return this.getFromNative("isTrusted", !1);
979
+ }
980
+ get returnValue() {
981
+ return this.getFromNative("returnValue", !1);
982
+ }
983
+ get timeStamp() {
984
+ return this.getFromNative("timeStamp", 0);
985
+ }
986
+ get cancelable() {
987
+ return this.getFromNative("cancelable", !1);
988
+ }
989
+ get defaultPrevented() {
990
+ return this.getFromNative("defaultPrevented", !1);
991
+ }
992
+ getFromNative(e, n) {
993
+ return e in this.nativeEvent ? this.nativeEvent[e] : n;
994
+ }
995
+ }
996
+ const pt = new w();
997
+ class F extends ki {
998
+ constructor(n, r, i, s, o, a, l = o.object, u = l, p = {
999
+ stopped: !r,
1000
+ stoppedImmediate: !1
1001
+ }) {
1002
+ super(i);
1003
+ v(this, "type");
1004
+ v(this, "bubbles");
1005
+ v(this, "internalPointer");
1006
+ v(this, "intersection");
1007
+ v(this, "camera");
1008
+ v(this, "currentObject");
1009
+ v(this, "object");
1010
+ v(this, "propagationState");
1011
+ v(this, "_pointer");
1012
+ v(this, "_ray");
1013
+ v(this, "_intersections", []);
1014
+ v(this, "_unprojectedPoint");
1015
+ this.type = n, this.bubbles = r, this.internalPointer = s, this.intersection = o, this.camera = a, this.currentObject = l, this.object = u, this.propagationState = p;
1016
+ }
1017
+ //--- pointer events data
1018
+ get pointerId() {
1019
+ return this.internalPointer.id;
1020
+ }
1021
+ get pointerType() {
1022
+ return this.internalPointer.type;
1023
+ }
1024
+ get pointerState() {
1025
+ return this.internalPointer.state;
1026
+ }
1027
+ //--- intersection data
1028
+ get distance() {
1029
+ return this.intersection.distance;
1030
+ }
1031
+ get distanceToRay() {
1032
+ return this.intersection.distanceToRay;
1033
+ }
1034
+ get point() {
1035
+ return this.intersection.point;
1036
+ }
1037
+ get index() {
1038
+ return this.intersection.index;
1039
+ }
1040
+ get face() {
1041
+ return this.intersection.face;
1042
+ }
1043
+ get faceIndex() {
1044
+ return this.intersection.faceIndex;
1045
+ }
1046
+ get uv() {
1047
+ return this.intersection.uv;
1048
+ }
1049
+ get uv1() {
1050
+ return this.intersection.uv1;
1051
+ }
1052
+ get normal() {
1053
+ return this.intersection.normal;
1054
+ }
1055
+ get instanceId() {
1056
+ return this.intersection.instanceId;
1057
+ }
1058
+ get pointOnLine() {
1059
+ return this.intersection.pointOnLine;
1060
+ }
1061
+ get batchId() {
1062
+ return this.intersection.batchId;
1063
+ }
1064
+ get pointerPosition() {
1065
+ return this.intersection.pointerPosition;
1066
+ }
1067
+ get pointerQuaternion() {
1068
+ return this.intersection.pointerQuaternion;
1069
+ }
1070
+ get pointOnFace() {
1071
+ return this.intersection.pointOnFace;
1072
+ }
1073
+ get localPoint() {
1074
+ return this.intersection.localPoint;
1075
+ }
1076
+ get details() {
1077
+ return this.intersection.details;
1078
+ }
1079
+ /** same as object */
1080
+ get target() {
1081
+ return this.object;
1082
+ }
1083
+ /** same as currentObject */
1084
+ get currentTarget() {
1085
+ return this.currentObject;
1086
+ }
1087
+ /** same as currentObject */
1088
+ get eventObject() {
1089
+ return this.currentObject;
1090
+ }
1091
+ /** same as object */
1092
+ get srcElement() {
1093
+ return this.currentObject;
1094
+ }
1095
+ get pointer() {
1096
+ return this._pointer == null && (pt.copy(this.intersection.point).project(this.camera), this._pointer = new W(pt.x, pt.y)), this._pointer;
1097
+ }
1098
+ get ray() {
1099
+ if (this._ray != null)
1100
+ return this._ray;
1101
+ switch (this.intersection.details.type) {
1102
+ case "screen-ray":
1103
+ case "ray":
1104
+ case "sphere":
1105
+ return this._ray = new Pt(this.intersection.pointerPosition, new w(0, 0, -1).applyQuaternion(this.intersection.pointerQuaternion));
1106
+ case "lines":
1107
+ return this._ray = new Pt(this.intersection.details.line.start, this.intersection.details.line.end.clone().sub(this.intersection.details.line.start).normalize());
1108
+ }
1109
+ }
1110
+ get intersections() {
1111
+ return this._intersections == null && (this._intersections = [{ ...this.intersection, eventObject: this.currentObject }]), this._intersections;
1112
+ }
1113
+ get unprojectedPoint() {
1114
+ if (this._unprojectedPoint == null) {
1115
+ const n = this.pointer;
1116
+ this._unprojectedPoint = new w(n.x, n.y, 0).unproject(this.camera);
1117
+ }
1118
+ return this._unprojectedPoint;
1119
+ }
1120
+ get stopped() {
1121
+ return this.propagationState.stoppedImmediate || this.propagationState.stopped;
1122
+ }
1123
+ get stoppedImmediate() {
1124
+ return this.propagationState.stoppedImmediate;
1125
+ }
1126
+ get delta() {
1127
+ throw new Error("not supported");
1128
+ }
1129
+ stopPropagation() {
1130
+ this.propagationState.stopped = !0;
1131
+ }
1132
+ stopImmediatePropagation() {
1133
+ this.propagationState.stoppedImmediate = !0;
1134
+ }
1135
+ /**
1136
+ * for internal use
1137
+ */
1138
+ retarget(n) {
1139
+ return new F(this.type, this.bubbles, this.nativeEvent, this.internalPointer, this.intersection, this.camera, n, this.target, this.propagationState);
1140
+ }
1141
+ }
1142
+ class He extends F {
1143
+ get deltaX() {
1144
+ return this.nativeEvent.deltaX;
1145
+ }
1146
+ get deltaY() {
1147
+ return this.nativeEvent.deltaY;
1148
+ }
1149
+ get deltaZ() {
1150
+ return this.nativeEvent.deltaZ;
1151
+ }
1152
+ constructor(e, n, r, i, s, o) {
1153
+ super("wheel", !0, e, n, r, i, s, o);
1154
+ }
1155
+ /**
1156
+ * for internal use
1157
+ */
1158
+ retarget(e) {
1159
+ return new He(this.nativeEvent, this.internalPointer, this.intersection, this.camera, e, this.target);
1160
+ }
1161
+ }
1162
+ function V(t) {
1163
+ Kn(t, t.currentObject);
1164
+ }
1165
+ function Kn(t, e) {
1166
+ if (e == null)
1167
+ return;
1168
+ const n = Ni(e, t.type);
1169
+ if (n != null && n.length > 0) {
1170
+ const r = t.retarget(e), i = n.length;
1171
+ for (let s = 0; s < i && !r.stoppedImmediate; s++)
1172
+ n[s](r);
1173
+ }
1174
+ t.stopped || Kn(t, e.parent);
1175
+ }
1176
+ const Zn = {
1177
+ click: "onClick",
1178
+ contextmenu: "onContextMenu",
1179
+ dblclick: "onDoubleClick",
1180
+ pointercancel: "onPointerCancel",
1181
+ pointerdown: "onPointerDown",
1182
+ pointerenter: "onPointerEnter",
1183
+ pointerleave: "onPointerLeave",
1184
+ pointermove: "onPointerMove",
1185
+ pointerout: "onPointerOut",
1186
+ pointerover: "onPointerOver",
1187
+ pointerup: "onPointerUp",
1188
+ wheel: "onWheel"
1189
+ }, Bi = Object.keys(Zn);
1190
+ function Ni(t, e) {
1191
+ if (t._listeners != null && e in t._listeners)
1192
+ return t._listeners[e];
1193
+ let n;
1194
+ if (t.isVoidObject && e === "click" && t.parent?.__r3f != null && (n = t.parent.__r3f.root.getState().onPointerMissed), t.__r3f != null && (n = t.__r3f.handlers[Zn[e]]), n != null)
1195
+ return [n];
1196
+ }
1197
+ const qi = 1e10, Gi = new Tn(qi), Jt = /* @__PURE__ */ new Map();
1198
+ function Jn(t) {
1199
+ let e = Jt.get(t);
1200
+ return e == null && (e = new Z(Gi), e.isVoidObject = !0, e.parent = t, e.pointerEventsOrder = -1 / 0, Jt.set(t, e)), e;
1201
+ }
1202
+ function Ke(t, e, n) {
1203
+ const r = e.normal ?? e.face?.normal;
1204
+ return r == null ? !1 : (t.setFromNormalAndCoplanarPoint(r, e.localPoint), t.applyMatrix4(n), !0);
1205
+ }
1206
+ function $i(t, e, n) {
1207
+ if (e === "none" || e === "listener" && !t)
1208
+ return !1;
1209
+ if (n === "all")
1210
+ return !0;
1211
+ if (typeof n == "function")
1212
+ return ({ id: s, type: o, state: a }) => n(s, o, a);
1213
+ let r, i;
1214
+ return "deny" in n ? (i = !0, r = n.deny) : (i = !1, r = n.allow), Array.isArray(r) ? (s) => en(r.includes(s.type), i) : (s) => en(r === s.type, i);
1215
+ }
1216
+ function en(t, e) {
1217
+ return e ? !t : t;
1218
+ }
1219
+ function _t(t, e, n, r = !1, i, s, o) {
1220
+ const a = r || Ui(t, e), l = e.pointerEvents ?? i, u = l ?? e.defaultPointerEvents ?? "listener", p = e.pointerEventsType ?? s ?? "all", c = e.pointerEventsOrder ?? o ?? 0, h = $i(a, u, p), d = n.length;
1221
+ if (d === 1)
1222
+ (h === !0 || typeof h == "function" && h(n[0])) && mt(n[0], e, u, p, c);
1223
+ else if (h === !0)
1224
+ for (let f = 0; f < d; f++)
1225
+ mt(n[f], e, u, p, c);
1226
+ else if (typeof h == "function")
1227
+ for (let f = 0; f < d; f++) {
1228
+ const R = n[f];
1229
+ h(R) && mt(R, e, u, p, c);
1230
+ }
1231
+ if (e.children.length === 0 || e.intersectChildren === !1)
1232
+ return;
1233
+ const g = e.interactableDescendants ?? e.children, y = g.length;
1234
+ for (let f = 0; f < y; f++)
1235
+ _t(t, g[f], n, a, l, p, c);
1236
+ }
1237
+ function Ui(t, e) {
1238
+ if (e.ancestorsHaveListeners || t === "pointer" && e.ancestorsHavePointerListeners || t === "wheel" && e.ancestorsHaveWheelListeners || e.__r3f != null && e.__r3f?.eventCount > 0 && (t === "wheel" && e.__r3f.handlers.onWheel != null || t === "pointer" && Object.keys(e.__r3f.handlers).some((i) => i != "onWheel")))
1239
+ return !0;
1240
+ if (e._listeners == null)
1241
+ return !1;
1242
+ if (t === "wheel") {
1243
+ const i = e._listeners.wheel;
1244
+ return i != null && i.length > 0;
1245
+ }
1246
+ const n = Object.entries(e._listeners), r = n.length;
1247
+ for (let i = 0; i < r; i++) {
1248
+ const s = n[i];
1249
+ if (s[0] !== "wheel" && Bi.includes(s[0]) && s[1] != null && s[1].length > 0)
1250
+ return !0;
1251
+ }
1252
+ return !1;
1253
+ }
1254
+ function mt({ intersector: t, options: e }, n, r, i, s) {
1255
+ e.filter?.(n, r, i, s) !== !1 && t.executeIntersection(n, s);
1256
+ }
1257
+ function Ze(t, e, { customSort: n = Qi } = {}, r) {
1258
+ let i, s, o;
1259
+ const a = t.length;
1260
+ for (let l = 0; l < a; l++) {
1261
+ const u = t[l];
1262
+ if (r?.(u) === !1)
1263
+ continue;
1264
+ const p = e?.[l];
1265
+ (i == null || n(u, p, i, s) < 0) && (o = l, i = u, s = p);
1266
+ }
1267
+ return o;
1268
+ }
1269
+ function Qi(t, e = 0, n, r = 0) {
1270
+ return e != r ? r - e : t.distance - n.distance;
1271
+ }
1272
+ const tn = 1e7;
1273
+ function Ot(t, e, n, r, i, s = 0) {
1274
+ const o = e.direction.clone().multiplyScalar(tn), a = tn;
1275
+ return {
1276
+ distance: a + s,
1277
+ object: Jn(t),
1278
+ point: o,
1279
+ normal: e.origin.clone().sub(o).normalize(),
1280
+ details: n(o, a),
1281
+ pointerPosition: r,
1282
+ pointerQuaternion: i,
1283
+ pointOnFace: o,
1284
+ localPoint: o
1285
+ };
1286
+ }
1287
+ function Ve(t, e, n) {
1288
+ for (; n > 0; )
1289
+ t.push(e), --n;
1290
+ }
1291
+ const he = Symbol("buttonsDownTime"), gt = Symbol("buttonsClickTime");
1292
+ globalThis.pointerEventspointerMap ?? (globalThis.pointerEventspointerMap = /* @__PURE__ */ new Map());
1293
+ Et.prototype.setPointerCapture = function(t) {
1294
+ Tt(t)?.setCapture(this);
1295
+ };
1296
+ Et.prototype.releasePointerCapture = function(t) {
1297
+ const e = Tt(t);
1298
+ e == null || !e.hasCaptured(this) || e.setCapture(void 0);
1299
+ };
1300
+ Et.prototype.hasPointerCapture = function(t) {
1301
+ return Tt(t)?.hasCaptured(this) ?? !1;
1302
+ };
1303
+ function Tt(t) {
1304
+ return globalThis.pointerEventspointerMap?.get(t);
1305
+ }
1306
+ class de {
1307
+ constructor(e, n, r, i, s, o, a, l, u = {}) {
1308
+ v(this, "id");
1309
+ v(this, "type");
1310
+ v(this, "state");
1311
+ v(this, "intersector");
1312
+ v(this, "getCamera");
1313
+ v(this, "onMoveCommited");
1314
+ v(this, "parentSetPointerCapture");
1315
+ v(this, "parentReleasePointerCapture");
1316
+ v(this, "options");
1317
+ //state
1318
+ v(this, "prevIntersection");
1319
+ v(this, "intersection");
1320
+ v(this, "prevEnabled", !0);
1321
+ v(this, "enabled", !0);
1322
+ v(this, "wheelIntersection");
1323
+ //derived state
1324
+ /**
1325
+ * ordered leaf -> root (bottom -> top)
1326
+ */
1327
+ v(this, "pointerEntered", []);
1328
+ v(this, "pointerEnteredHelper", []);
1329
+ v(this, "pointerCapture");
1330
+ v(this, "buttonsDownTime", /* @__PURE__ */ new Map());
1331
+ v(this, "buttonsDown", /* @__PURE__ */ new Set());
1332
+ //to handle interaction before first move (after exit)
1333
+ v(this, "wasMoved", !1);
1334
+ v(this, "onFirstMove", []);
1335
+ this.id = e, this.type = n, this.state = r, this.intersector = i, this.getCamera = s, this.onMoveCommited = o, this.parentSetPointerCapture = a, this.parentReleasePointerCapture = l, this.options = u, globalThis.pointerEventspointerMap?.set(e, this);
1336
+ }
1337
+ getPointerCapture() {
1338
+ return this.pointerCapture;
1339
+ }
1340
+ hasCaptured(e) {
1341
+ return this.pointerCapture?.object === e;
1342
+ }
1343
+ setCapture(e) {
1344
+ this.pointerCapture?.object !== e && (this.pointerCapture != null && (this.parentReleasePointerCapture?.(), this.pointerCapture = void 0), e != null && this.intersection != null && (this.pointerCapture = { object: e, intersection: this.intersection }, this.parentSetPointerCapture?.()));
1345
+ }
1346
+ getButtonsDown() {
1347
+ return this.buttonsDown;
1348
+ }
1349
+ /**
1350
+ * @returns undefined if no intersection was executed yet
1351
+ */
1352
+ getIntersection() {
1353
+ return this.intersection;
1354
+ }
1355
+ getEnabled() {
1356
+ return this.enabled;
1357
+ }
1358
+ setEnabled(e, n, r = !0) {
1359
+ this.enabled !== e && (!e && this.pointerCapture != null && (this.parentReleasePointerCapture?.(), this.pointerCapture = void 0), this.enabled = e, r && this.commit(n, !1));
1360
+ }
1361
+ computeIntersection(e, n, r) {
1362
+ return this.pointerCapture != null ? this.intersector.intersectPointerCapture(this.pointerCapture, r) : (this.intersector.startIntersection(r), _t(e, n, [this]), this.intersector.finalizeIntersection(n));
1363
+ }
1364
+ setIntersection(e) {
1365
+ this.intersection = e;
1366
+ }
1367
+ commit(e, n) {
1368
+ const r = this.getCamera(), i = this.prevEnabled ? this.prevIntersection : void 0, s = this.enabled ? this.intersection : void 0;
1369
+ i != null && i.object != s?.object && V(new F("pointerout", !0, e, this, i, r));
1370
+ const o = this.pointerEntered;
1371
+ this.pointerEntered = [], this.pointerEnteredHelper.length = 0, er(s?.object, this.pointerEntered, o, this.pointerEnteredHelper);
1372
+ const a = o.length;
1373
+ for (let l = 0; l < a; l++) {
1374
+ const u = o[l];
1375
+ V(new F("pointerleave", !1, e, this, i, r, u));
1376
+ }
1377
+ s != null && i?.object != s.object && V(new F("pointerover", !0, e, this, s, r));
1378
+ for (let l = this.pointerEnteredHelper.length - 1; l >= 0; l--) {
1379
+ const u = this.pointerEnteredHelper[l];
1380
+ V(new F("pointerenter", !1, e, this, s, r, u));
1381
+ }
1382
+ if (n && s != null && V(new F("pointermove", !0, e, this, s, r)), this.prevIntersection = this.intersection, this.prevEnabled = this.enabled, !this.wasMoved && this.intersector.isReady()) {
1383
+ this.wasMoved = !0;
1384
+ const l = this.onFirstMove.length;
1385
+ for (let u = 0; u < l; u++)
1386
+ this.onFirstMove[u](r);
1387
+ this.onFirstMove.length = 0;
1388
+ }
1389
+ this.onMoveCommited?.(this);
1390
+ }
1391
+ /**
1392
+ * computes and commits a move
1393
+ */
1394
+ move(e, n) {
1395
+ this.intersection = this.computeIntersection("pointer", e, n), this.commit(n, !0);
1396
+ }
1397
+ /**
1398
+ * computes and commits the pointer if a move has not yet occured
1399
+ */
1400
+ over(e, n) {
1401
+ this.wasMoved || (this.intersection = this.computeIntersection("pointer", e, n), this.commit(n, !1));
1402
+ }
1403
+ /**
1404
+ * emits a move without (re-)computing the intersection
1405
+ * just emitting a move event to the current intersection
1406
+ */
1407
+ emitMove(e) {
1408
+ this.intersection != null && V(new F("pointermove", !0, e, this, this.intersection, this.getCamera()));
1409
+ }
1410
+ down(e) {
1411
+ if (this.buttonsDown.add(e.button), !this.enabled)
1412
+ return;
1413
+ if (!this.wasMoved) {
1414
+ this.onFirstMove.push(this.down.bind(this, e));
1415
+ return;
1416
+ }
1417
+ if (this.intersection == null)
1418
+ return;
1419
+ V(new F("pointerdown", !0, e, this, this.intersection, this.getCamera()));
1420
+ const { object: n } = this.intersection;
1421
+ n[he] ?? (n[he] = /* @__PURE__ */ new Map()), n[he].set(e.button, e.timeStamp), this.buttonsDownTime.set(e.button, e.timeStamp);
1422
+ }
1423
+ up(e) {
1424
+ if (this.buttonsDown.delete(e.button), !this.enabled)
1425
+ return;
1426
+ if (!this.wasMoved) {
1427
+ this.onFirstMove.push(this.up.bind(this, e));
1428
+ return;
1429
+ }
1430
+ if (this.intersection == null)
1431
+ return;
1432
+ const { clickThesholdMs: n, contextMenuButton: r = 2, dblClickThresholdMs: i = 500, clickThresholdMs: s = n ?? 300 } = this.options;
1433
+ this.pointerCapture = void 0;
1434
+ const o = Yi(this.buttonsDownTime, this.intersection.object[he], e.button, e.timeStamp, s), a = this.getCamera();
1435
+ if (o && e.button === r && V(new F("contextmenu", !0, e, this, this.intersection, a)), V(new F("pointerup", !0, e, this, this.intersection, a)), !o || e.button === r)
1436
+ return;
1437
+ V(new F("click", !0, e, this, this.intersection, a));
1438
+ const { object: l } = this.intersection, u = l[gt] ?? (l[gt] = /* @__PURE__ */ new Map()), p = u.get(e.button);
1439
+ if (p == null || e.timeStamp - p > i) {
1440
+ u.set(e.button, e.timeStamp);
1441
+ return;
1442
+ }
1443
+ V(new F("dblclick", !0, e, this, this.intersection, a)), u.delete(e.button);
1444
+ }
1445
+ cancel(e) {
1446
+ if (this.enabled) {
1447
+ if (!this.wasMoved) {
1448
+ this.onFirstMove.push(this.cancel.bind(this, e));
1449
+ return;
1450
+ }
1451
+ this.intersection != null && V(new F("pointercancel", !0, e, this, this.intersection, this.getCamera()));
1452
+ }
1453
+ }
1454
+ wheel(e, n, r = !1) {
1455
+ if (!this.enabled)
1456
+ return;
1457
+ if (!this.wasMoved && r) {
1458
+ this.onFirstMove.push(this.wheel.bind(this, e, n, r));
1459
+ return;
1460
+ }
1461
+ r || (this.wheelIntersection = this.computeIntersection("wheel", e, n));
1462
+ const i = r ? this.intersection : this.wheelIntersection;
1463
+ i != null && V(new He(n, this, i, this.getCamera()));
1464
+ }
1465
+ emitWheel(e, n = !1) {
1466
+ if (!this.enabled)
1467
+ return;
1468
+ if (!this.wasMoved && n) {
1469
+ this.onFirstMove.push(this.emitWheel.bind(this, e, n));
1470
+ return;
1471
+ }
1472
+ const r = n ? this.intersection : this.wheelIntersection;
1473
+ r != null && V(new He(e, this, r, this.getCamera()));
1474
+ }
1475
+ exit(e) {
1476
+ this.wasMoved && (this.pointerCapture != null && (this.parentReleasePointerCapture?.(), this.pointerCapture = void 0), this.intersection = void 0, this.commit(e, !1)), this.onFirstMove.length = 0, this.wasMoved = !1;
1477
+ }
1478
+ }
1479
+ function er(t, e, n, r) {
1480
+ if (t == null)
1481
+ return;
1482
+ const i = n.indexOf(t);
1483
+ i != -1 ? n.splice(i, 1) : r.push(t), e.push(t), er(t.parent, e, n, r);
1484
+ }
1485
+ function Yi(t, e, n, r, i) {
1486
+ if (e == null)
1487
+ return !1;
1488
+ const s = e.get(n);
1489
+ return !(s == null || r - s > i || s != t.get(n));
1490
+ }
1491
+ function Je(t) {
1492
+ return t.transformReady === !1 ? !1 : t.parent == null ? (t.matrixWorld.copy(t.matrix), !0) : Je(t.parent) ? (t.matrixWorld.multiplyMatrices(t.parent.matrixWorld, t.matrix), !0) : !1;
1493
+ }
1494
+ const pe = new Xn(), yt = new Xn(), nn = new W(), rn = new W(), sn = new W(), vt = new w(), Ki = new j(), Ae = new w();
1495
+ function Se(t, e, n) {
1496
+ Ae.copy(e).applyMatrix4(Ki.copy(n.matrixWorld).invert());
1497
+ const r = n.geometry.attributes.uv;
1498
+ if (r == null || !(r instanceof $))
1499
+ return !1;
1500
+ let i;
1501
+ return Zi(n, (s, o, a) => {
1502
+ n.getVertexPosition(s, pe.a), n.getVertexPosition(o, pe.b), n.getVertexPosition(a, pe.c);
1503
+ const l = pe.closestPointToPoint(Ae, vt).distanceTo(Ae);
1504
+ i != null && l >= i || (i = l, yt.copy(pe), nn.fromBufferAttribute(r, s), rn.fromBufferAttribute(r, o), sn.fromBufferAttribute(r, a));
1505
+ }), i == null ? !1 : (yt.closestPointToPoint(Ae, vt), yt.getInterpolation(vt, nn, rn, sn, t), !0);
1506
+ }
1507
+ function Zi(t, e) {
1508
+ const n = t.geometry.drawRange;
1509
+ if (t.geometry.index != null) {
1510
+ const o = t.geometry.index, a = Math.max(0, n.start), l = Math.min(o.count, n.start + n.count);
1511
+ for (let u = a; u < l; u += 3)
1512
+ e(o.getX(u), o.getX(u + 1), o.getX(u + 2));
1513
+ return;
1514
+ }
1515
+ const r = t.geometry.attributes.position;
1516
+ if (r == null)
1517
+ return;
1518
+ const i = Math.max(0, n.start), s = Math.min(r.count, n.start + n.count);
1519
+ for (let o = i; o < s; o += 3)
1520
+ e(o, o + 1, o + 2);
1521
+ }
1522
+ const Ji = new j(), wt = new Mt(), es = new w(), on = new Ge(), ts = new Pt(), an = new W(), ln = [new w(0, 0, 0), new w(0, 0, 1)];
1523
+ class ns {
1524
+ constructor(e, n) {
1525
+ v(this, "space");
1526
+ v(this, "options");
1527
+ v(this, "raycasters", []);
1528
+ v(this, "fromMatrixWorld", new j());
1529
+ v(this, "ready");
1530
+ v(this, "intersects", []);
1531
+ v(this, "pointerEventsOrders", []);
1532
+ v(this, "raycasterIndices", []);
1533
+ this.space = e, this.options = n;
1534
+ }
1535
+ isReady() {
1536
+ return this.ready ?? this.prepareTransformation();
1537
+ }
1538
+ prepareTransformation() {
1539
+ const e = this.space.current;
1540
+ return e == null ? this.ready = !1 : (this.ready = Je(e), this.ready ? (this.fromMatrixWorld.copy(e.matrixWorld), !0) : !1);
1541
+ }
1542
+ intersectPointerCapture({ intersection: e, object: n }) {
1543
+ const r = e.details;
1544
+ if (r.type != "lines")
1545
+ throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a lines intersector`);
1546
+ if (!this.prepareTransformation())
1547
+ return e;
1548
+ const i = this.options.linePoints ?? ln;
1549
+ wt.set(i[r.lineIndex], i[r.lineIndex + 1]).applyMatrix4(this.fromMatrixWorld);
1550
+ const s = wt.at(r.distanceOnLine / wt.distance(), new w());
1551
+ e.object.updateWorldMatrix(!0, !1), Ke(on, e, e.object.matrixWorld);
1552
+ const o = ts.intersectPlane(on, new w()) ?? s, a = new w(), l = new U();
1553
+ this.fromMatrixWorld.decompose(a, l, es);
1554
+ let u = e.uv;
1555
+ return e.object instanceof Z && Se(an, s, e.object) && (u = an.clone()), {
1556
+ ...e,
1557
+ object: n,
1558
+ uv: u,
1559
+ pointOnFace: o,
1560
+ point: s,
1561
+ pointerPosition: a,
1562
+ pointerQuaternion: l
1563
+ };
1564
+ }
1565
+ startIntersection() {
1566
+ if (!this.prepareTransformation())
1567
+ return;
1568
+ const e = this.options.linePoints ?? ln, n = e.length - 1;
1569
+ for (let r = 0; r < n; r++) {
1570
+ const i = e[r], s = e[r + 1], o = this.raycasters[r] ?? (this.raycasters[r] = new $e());
1571
+ o.ray.origin.copy(i).applyMatrix4(this.fromMatrixWorld), o.ray.direction.copy(s).applyMatrix4(this.fromMatrixWorld), o.ray.direction.sub(o.ray.origin);
1572
+ const a = o.ray.direction.length();
1573
+ o.ray.direction.divideScalar(a), o.far = a;
1574
+ }
1575
+ this.raycasters.length = n;
1576
+ }
1577
+ executeIntersection(e, n) {
1578
+ if (!this.isReady())
1579
+ return;
1580
+ const r = this.intersects.length, i = this.raycasters.length;
1581
+ for (let s = 0; s < i; s++) {
1582
+ const o = this.raycasters[s], a = this.intersects.length;
1583
+ e.raycast(o, this.intersects), Ve(this.raycasterIndices, s, this.intersects.length - a);
1584
+ }
1585
+ Ve(this.pointerEventsOrders, n, this.intersects.length - r);
1586
+ }
1587
+ finalizeIntersection(e) {
1588
+ const n = new w().setFromMatrixPosition(this.fromMatrixWorld), r = new U().setFromRotationMatrix(this.fromMatrixWorld), i = Ze(this.intersects, this.pointerEventsOrders, this.options), s = i == null ? void 0 : this.intersects[i], o = i == null ? void 0 : this.raycasterIndices[i];
1589
+ if (this.intersects.length = 0, this.raycasterIndices.length = 0, this.pointerEventsOrders.length = 0, s == null || o == null) {
1590
+ const u = this.raycasters.length - 1, p = this.raycasters.reduce((h, d, g) => g === u ? h : h + d.far, 0), c = this.raycasters[u];
1591
+ return Ot(e, c.ray, (h, d) => ({
1592
+ line: new Mt(c.ray.origin.clone(), h),
1593
+ lineIndex: this.raycasters.length - 1,
1594
+ distanceOnLine: d,
1595
+ type: "lines"
1596
+ }), n, r, p);
1597
+ }
1598
+ let a = s.distance;
1599
+ for (let u = 0; u < o; u++)
1600
+ a += this.raycasters[u].far;
1601
+ s.object.updateWorldMatrix(!0, !1);
1602
+ const l = this.raycasters[o];
1603
+ return Object.assign(s, {
1604
+ details: {
1605
+ lineIndex: o,
1606
+ distanceOnLine: s.distance,
1607
+ type: "lines",
1608
+ line: new Mt(l.ray.origin.clone(), l.ray.direction.clone().multiplyScalar(l.far).add(l.ray.origin))
1609
+ },
1610
+ distance: a,
1611
+ pointerPosition: n,
1612
+ pointerQuaternion: r,
1613
+ pointOnFace: s.point,
1614
+ localPoint: s.point.clone().applyMatrix4(Ji.copy(s.object.matrixWorld).invert())
1615
+ });
1616
+ }
1617
+ }
1618
+ const Rt = new j(), Ct = new w(), rs = new w(0, 0, -1), un = new Ge(), je = new W();
1619
+ class is {
1620
+ constructor(e, n) {
1621
+ v(this, "space");
1622
+ v(this, "options");
1623
+ v(this, "raycaster", new $e());
1624
+ v(this, "raycasterQuaternion", new U());
1625
+ v(this, "worldScale", 0);
1626
+ v(this, "ready");
1627
+ v(this, "intersects", []);
1628
+ v(this, "pointerEventsOrders", []);
1629
+ this.space = e, this.options = n;
1630
+ }
1631
+ isReady() {
1632
+ return this.ready ?? this.prepareTransformation();
1633
+ }
1634
+ prepareTransformation() {
1635
+ const e = this.space.current;
1636
+ return e == null ? this.ready = !1 : (this.ready = Je(e), this.ready ? (e.matrixWorld.decompose(this.raycaster.ray.origin, this.raycasterQuaternion, Ct), this.worldScale = Ct.x, this.raycaster.ray.direction.copy(this.options?.direction ?? rs).applyQuaternion(this.raycasterQuaternion), !0) : !1);
1637
+ }
1638
+ intersectPointerCapture({ intersection: e, object: n }) {
1639
+ if (e.details.type != "ray")
1640
+ throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a ray intersector`);
1641
+ if (!this.prepareTransformation())
1642
+ return e;
1643
+ e.object.updateWorldMatrix(!0, !1), Ke(un, e, e.object.matrixWorld);
1644
+ const { ray: r } = this.raycaster, i = r.intersectPlane(un, new w()) ?? e.point, s = r.direction.clone().multiplyScalar(e.pointerPosition.distanceTo(e.point)).add(r.origin);
1645
+ let o = e.uv;
1646
+ return e.object instanceof Z && Se(je, s, e.object) && (o = je.clone()), {
1647
+ ...e,
1648
+ uv: o,
1649
+ object: n,
1650
+ pointOnFace: i,
1651
+ point: s,
1652
+ pointerPosition: r.origin.clone(),
1653
+ pointerQuaternion: this.raycasterQuaternion.clone()
1654
+ };
1655
+ }
1656
+ startIntersection() {
1657
+ this.prepareTransformation();
1658
+ }
1659
+ executeIntersection(e, n) {
1660
+ if (!this.isReady())
1661
+ return;
1662
+ const r = this.intersects.length;
1663
+ e.raycast(this.raycaster, this.intersects), Ve(this.pointerEventsOrders, n, this.intersects.length - r);
1664
+ }
1665
+ finalizeIntersection(e) {
1666
+ const n = this.raycaster.ray.origin.clone(), r = this.raycasterQuaternion.clone();
1667
+ let i;
1668
+ if (this.options.minDistance != null) {
1669
+ const a = this.options.minDistance / this.worldScale;
1670
+ i = (l) => l.distance >= a;
1671
+ }
1672
+ const s = Ze(this.intersects, this.pointerEventsOrders, this.options, i), o = s == null ? void 0 : this.intersects[s];
1673
+ return this.intersects.length = 0, this.pointerEventsOrders.length = 0, o == null ? Ot(e, this.raycaster.ray, () => ({ type: "ray" }), n, r) : (o.object.updateWorldMatrix(!0, !1), Object.assign(o, {
1674
+ details: {
1675
+ type: "ray"
1676
+ },
1677
+ pointerPosition: n,
1678
+ pointerQuaternion: r,
1679
+ pointOnFace: o.point,
1680
+ localPoint: o.point.clone().applyMatrix4(Rt.copy(o.object.matrixWorld).invert())
1681
+ }));
1682
+ }
1683
+ }
1684
+ const ss = new w();
1685
+ class os {
1686
+ constructor(e, n) {
1687
+ v(this, "prepareTransformation");
1688
+ v(this, "options");
1689
+ v(this, "raycaster", new $e());
1690
+ v(this, "cameraQuaternion", new U());
1691
+ v(this, "fromPosition", new w());
1692
+ v(this, "fromQuaternion", new U());
1693
+ v(this, "coords", new W());
1694
+ v(this, "viewPlane", new Ge());
1695
+ v(this, "intersects", []);
1696
+ v(this, "pointerEventsOrders", []);
1697
+ this.prepareTransformation = e, this.options = n;
1698
+ }
1699
+ isReady() {
1700
+ return !0;
1701
+ }
1702
+ intersectPointerCapture({ intersection: e, object: n }, r) {
1703
+ const i = e.details;
1704
+ if (i.type != "screen-ray")
1705
+ throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a camera ray intersector`);
1706
+ if (!this.startIntersection(r))
1707
+ return e;
1708
+ this.viewPlane.constant -= i.distanceViewPlane;
1709
+ const s = this.raycaster.ray.intersectPlane(this.viewPlane, new w());
1710
+ if (s == null)
1711
+ return e;
1712
+ e.object.updateWorldMatrix(!0, !1), Ke(this.viewPlane, e, e.object.matrixWorld);
1713
+ let o = e.uv;
1714
+ return e.object instanceof Z && Se(je, s, e.object) && (o = je.clone()), {
1715
+ ...e,
1716
+ details: {
1717
+ ...i,
1718
+ direction: this.raycaster.ray.direction.clone(),
1719
+ screenPoint: this.coords.clone()
1720
+ },
1721
+ uv: o,
1722
+ object: n,
1723
+ point: s,
1724
+ pointOnFace: s,
1725
+ pointerPosition: this.raycaster.ray.origin.clone(),
1726
+ pointerQuaternion: this.cameraQuaternion.clone()
1727
+ };
1728
+ }
1729
+ startIntersection(e) {
1730
+ const n = this.prepareTransformation(e, this.coords);
1731
+ return n == null ? !1 : (n.updateWorldMatrix(!0, !1), n.matrixWorld.decompose(this.fromPosition, this.fromQuaternion, Ct), this.raycaster.setFromCamera(this.coords, n), this.viewPlane.setFromNormalAndCoplanarPoint(n.getWorldDirection(ss), this.raycaster.ray.origin), !0);
1732
+ }
1733
+ executeIntersection(e, n) {
1734
+ const r = this.intersects.length;
1735
+ e.raycast(this.raycaster, this.intersects), Ve(this.pointerEventsOrders, n, this.intersects.length - r);
1736
+ }
1737
+ finalizeIntersection(e) {
1738
+ const n = this.fromPosition.clone(), r = this.cameraQuaternion.clone(), i = this.raycaster.ray.direction.clone(), s = Ze(this.intersects, this.pointerEventsOrders, this.options), o = s == null ? void 0 : this.intersects[s];
1739
+ return this.intersects.length = 0, this.pointerEventsOrders.length = 0, o == null ? Ot(e, this.raycaster.ray, (a, l) => ({
1740
+ type: "screen-ray",
1741
+ distanceViewPlane: l,
1742
+ screenPoint: this.coords.clone(),
1743
+ direction: i
1744
+ }), n, r) : (o.object.updateWorldMatrix(!0, !1), Rt.copy(o.object.matrixWorld).invert(), Object.assign(o, {
1745
+ details: {
1746
+ type: "screen-ray",
1747
+ distanceViewPlane: this.viewPlane.distanceToPoint(o.point),
1748
+ screenPoint: this.coords.clone(),
1749
+ direction: i
1750
+ },
1751
+ pointOnFace: o.point,
1752
+ pointerPosition: n,
1753
+ pointerQuaternion: r,
1754
+ localPoint: o.point.clone().applyMatrix4(Rt)
1755
+ }));
1756
+ }
1757
+ }
1758
+ const as = new w(), ke = new W();
1759
+ class tr {
1760
+ constructor(e, n, r) {
1761
+ v(this, "space");
1762
+ v(this, "getSphereRadius");
1763
+ v(this, "options");
1764
+ v(this, "fromPosition", new w());
1765
+ v(this, "fromQuaternion", new U());
1766
+ v(this, "collisionSphere", new Fn());
1767
+ v(this, "ready");
1768
+ v(this, "intersects", []);
1769
+ this.space = e, this.getSphereRadius = n, this.options = r;
1770
+ }
1771
+ isReady() {
1772
+ return this.ready ?? this.prepareTransformation();
1773
+ }
1774
+ prepareTransformation() {
1775
+ const e = this.space.current;
1776
+ return e == null ? this.ready = !1 : (this.ready = Je(e), this.ready ? (e.matrixWorld.decompose(this.fromPosition, this.fromQuaternion, as), !0) : !1);
1777
+ }
1778
+ intersectPointerCapture({ intersection: e, object: n }) {
1779
+ if (e.details.type != "sphere")
1780
+ throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a sphere intersector`);
1781
+ if (!this.prepareTransformation())
1782
+ return e;
1783
+ cn.copy(e.point).sub(e.pointerPosition), dn.copy(e.pointerQuaternion).invert().multiply(this.fromQuaternion);
1784
+ const r = cn.clone().applyQuaternion(dn).add(this.fromPosition);
1785
+ e.object.updateWorldMatrix(!0, !1), Ke(fn, e, e.object.matrixWorld);
1786
+ const i = fn.projectPoint(this.fromPosition, new w());
1787
+ let s = e.uv;
1788
+ return e.object instanceof Z && Se(ke, r, e.object) && (s = ke.clone()), {
1789
+ details: {
1790
+ type: "sphere"
1791
+ },
1792
+ uv: s,
1793
+ distance: r.distanceTo(i),
1794
+ pointerPosition: this.fromPosition.clone(),
1795
+ pointerQuaternion: this.fromQuaternion.clone(),
1796
+ object: n,
1797
+ point: r,
1798
+ pointOnFace: i,
1799
+ face: e.face,
1800
+ localPoint: e.localPoint
1801
+ };
1802
+ }
1803
+ startIntersection() {
1804
+ this.prepareTransformation() && (this.collisionSphere.center.copy(this.fromPosition), this.collisionSphere.radius = this.getSphereRadius());
1805
+ }
1806
+ executeIntersection(e) {
1807
+ this.isReady() && ls(this.collisionSphere, e, this.intersects);
1808
+ }
1809
+ finalizeIntersection(e) {
1810
+ const n = this.fromPosition.clone(), r = this.fromQuaternion.clone(), i = Ze(this.intersects, void 0, this.options), s = i == null ? void 0 : this.intersects[i];
1811
+ return this.intersects.length = 0, s == null ? {
1812
+ details: {
1813
+ type: "sphere"
1814
+ },
1815
+ distance: 0,
1816
+ point: n,
1817
+ object: Jn(e),
1818
+ pointerPosition: n,
1819
+ pointerQuaternion: r,
1820
+ pointOnFace: n,
1821
+ localPoint: n
1822
+ } : (s.object.updateWorldMatrix(!0, !1), Object.assign(s, {
1823
+ details: {
1824
+ type: "sphere"
1825
+ },
1826
+ pointOnFace: s.point,
1827
+ pointerPosition: this.fromPosition.clone(),
1828
+ pointerQuaternion: this.fromQuaternion.clone(),
1829
+ localPoint: s.point.clone().applyMatrix4(Be.copy(s.object.matrixWorld).invert())
1830
+ }));
1831
+ }
1832
+ }
1833
+ const Ee = new j();
1834
+ function ls(t, e, n) {
1835
+ if (e.updateWorldMatrix(!0, !1), e.spherecast != null) {
1836
+ e.spherecast(t, n);
1837
+ return;
1838
+ }
1839
+ if (e instanceof Ar) {
1840
+ e.geometry.boundingSphere == null && e.geometry.computeBoundingSphere(), e.geometry.boundingBox == null && e.geometry.computeBoundingBox();
1841
+ for (let i = 0; i < e.count; i++) {
1842
+ if (e.getMatrixAt(i, Ee), Ee.premultiply(e.matrixWorld), !hn(t, e, Ee))
1843
+ continue;
1844
+ const s = mn(t, e, Ee, i);
1845
+ s != null && n.push(s);
1846
+ }
1847
+ }
1848
+ if (!(e instanceof Z) || !hn(t, e, e.matrixWorld))
1849
+ return;
1850
+ Be.copy(e.matrixWorld).invert();
1851
+ const r = mn(t, e, e.matrixWorld);
1852
+ r != null && n.push(r);
1853
+ }
1854
+ const cn = new w(), dn = new U(), fn = new Ge(), le = new Fn();
1855
+ function hn(t, { geometry: e }, n) {
1856
+ return e.boundingSphere == null && e.computeBoundingSphere(), le.copy(e.boundingSphere).applyMatrix4(n), le.center.distanceToSquared(t.center) < (t.radius + le.radius) ** 2;
1857
+ }
1858
+ const Le = new w(), bt = new w(), pn = new w(), us = new w(1e-4, 1e-4, 1e-4), Be = new j();
1859
+ function mn(t, e, n, r) {
1860
+ Be.copy(n).invert(), le.copy(t).applyMatrix4(Be);
1861
+ const { geometry: i } = e;
1862
+ i.boundingBox == null && i.computeBoundingBox(), i.boundingBox.getSize(bt), i.boundingBox.getCenter(pn), i.boundingBox.clampPoint(le.center, Le), Le.applyMatrix4(n);
1863
+ const s = Le.distanceToSquared(t.center);
1864
+ if (s > t.radius * t.radius)
1865
+ return;
1866
+ bt.max(us);
1867
+ const o = le.center.clone().sub(pn);
1868
+ o.divide(bt), cs(o);
1869
+ const a = Le.clone();
1870
+ let l;
1871
+ return Se(ke, a, e) && (l = ke.clone()), {
1872
+ distance: Math.sqrt(s),
1873
+ face: {
1874
+ a: 0,
1875
+ b: 0,
1876
+ c: 0,
1877
+ materialIndex: 0,
1878
+ normal: o
1879
+ },
1880
+ uv: l,
1881
+ normal: o,
1882
+ point: a,
1883
+ instanceId: r,
1884
+ object: e
1885
+ };
1886
+ }
1887
+ function cs(t) {
1888
+ const e = Math.abs(t.x), n = Math.abs(t.y), r = Math.abs(t.z);
1889
+ if (e >= n && e >= r) {
1890
+ t.set(t.x < 0 ? -1 : 1, 0, 0);
1891
+ return;
1892
+ }
1893
+ if (n >= e && n >= r) {
1894
+ t.set(0, t.y < 0 ? -1 : 1, 0);
1895
+ return;
1896
+ }
1897
+ t.set(0, 0, t.z < 0 ? -1 : 1);
1898
+ }
1899
+ function ds(t, e, n, r = {}, i = "grab") {
1900
+ return new de(Pe(), i, n, new tr(e, () => r.radius ?? 0.07, r), t, void 0, void 0, void 0, r);
1901
+ }
1902
+ function fs(t, e, n, r = {}, i = "ray") {
1903
+ return new de(Pe(), i, n, new is(e, r), t, void 0, void 0, void 0, r);
1904
+ }
1905
+ function hs(t, e, n, r = {}, i = "lines") {
1906
+ return new de(Pe(), i, n, new ns(e, r), t, void 0, void 0, void 0, r);
1907
+ }
1908
+ function ps(t, e, n, r = {}, i = "touch") {
1909
+ return new de(Pe(), i, n, new tr(e, () => r.hoverRadius ?? 0.1, r), t, ms(r), void 0, void 0, r);
1910
+ }
1911
+ function ms(t) {
1912
+ let e = !1;
1913
+ return (n) => {
1914
+ if (!n.getEnabled())
1915
+ return;
1916
+ const r = n.getIntersection(), i = gs(r, t.downRadius ?? 0.03);
1917
+ if (i === e)
1918
+ return;
1919
+ const s = { timeStamp: performance.now(), button: t.button ?? 0 };
1920
+ i ? n.down(s) : n.up(s), e = i;
1921
+ };
1922
+ }
1923
+ function gs(t, e) {
1924
+ return t == null ? !1 : t.distance <= e;
1925
+ }
1926
+ let ys = 23412;
1927
+ function Pe() {
1928
+ return ys++;
1929
+ }
1930
+ function vs(t, e, n) {
1931
+ if (!(e instanceof globalThis.MouseEvent))
1932
+ return n.set(0, 0);
1933
+ const { width: r, height: i, top: s, left: o } = t.getBoundingClientRect(), a = e.clientX - o, l = e.clientY - s;
1934
+ return n.set(a / r * 2 - 1, -(l / i) * 2 + 1);
1935
+ }
1936
+ function ra(t, e, n, r) {
1937
+ return nr(
1938
+ t,
1939
+ //backwards compatibility
1940
+ typeof e == "function" ? e : () => e,
1941
+ n,
1942
+ vs.bind(null, t),
1943
+ t.setPointerCapture.bind(t),
1944
+ (i) => {
1945
+ t.hasPointerCapture(i) && t.releasePointerCapture(i);
1946
+ },
1947
+ {
1948
+ pointerTypePrefix: "screen-",
1949
+ ...r
1950
+ }
1951
+ );
1952
+ }
1953
+ function ws(t, e) {
1954
+ return !(t instanceof F) || t.uv == null ? e.set(0, 0) : e.copy(t.uv).multiplyScalar(2).addScalar(-1);
1955
+ }
1956
+ function bs(t, e, n, r) {
1957
+ return nr(t, e, n, ws, t.setPointerCapture.bind(t), t.releasePointerCapture.bind(t), r);
1958
+ }
1959
+ function nr(t, e, n, r, i, s, o = {}) {
1960
+ const a = o?.forwardPointerCapture ?? !0, l = /* @__PURE__ */ new Map(), u = o.pointerTypePrefix ?? "forward-", p = (P, M) => {
1961
+ let x = l.get(P.pointerId);
1962
+ return x != null || (x = new de(Pe(), `${u}${P.pointerType}`, P.pointerState, new os((G, B) => (r(G, B), e()), o), e, void 0, a ? i.bind(null, P.pointerId) : void 0, a ? s.bind(null, P.pointerId) : void 0, o), M != "move" && M != "wheel" && (x.setIntersection(x.computeIntersection("pointer", n, P)), x.commit(P, !1)), l.set(P.pointerId, x)), x;
1963
+ }, c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), d = [], g = [], y = (P, M, x) => {
1964
+ switch (P) {
1965
+ case "move":
1966
+ x.move(n, M);
1967
+ return;
1968
+ case "over":
1969
+ x.move(n, M);
1970
+ return;
1971
+ case "wheel":
1972
+ x.wheel(n, M);
1973
+ return;
1974
+ case "cancel":
1975
+ x.cancel(M);
1976
+ return;
1977
+ case "down":
1978
+ if (!gn(M))
1979
+ return;
1980
+ x.down(M);
1981
+ return;
1982
+ case "up":
1983
+ if (!gn(M))
1984
+ return;
1985
+ x.up(M);
1986
+ return;
1987
+ case "exit":
1988
+ h.delete(x), c.delete(x), x.exit(M);
1989
+ return;
1990
+ }
1991
+ }, f = (P, M) => {
1992
+ const x = p(M, P);
1993
+ P === "move" && h.set(x, M), P === "wheel" && c.set(x, M), o.batchEvents ?? !0 ? g.push({ type: P, event: M }) : y(P, M, x);
1994
+ }, R = f.bind(null, "move"), I = f.bind(null, "over"), b = f.bind(null, "cancel"), T = f.bind(null, "down"), D = f.bind(null, "up"), L = f.bind(null, "wheel"), H = f.bind(null, "exit");
1995
+ return t.addEventListener("pointermove", R), t.addEventListener("pointerover", I), t.addEventListener("pointercancel", b), t.addEventListener("pointerdown", T), t.addEventListener("pointerup", D), t.addEventListener("wheel", L), t.addEventListener("pointerleave", H), {
1996
+ destroy() {
1997
+ t.removeEventListener("pointermove", R), t.removeEventListener("pointerover", I), t.removeEventListener("pointercancel", b), t.removeEventListener("pointerdown", T), t.removeEventListener("pointerup", D), t.removeEventListener("wheel", L), t.removeEventListener("pointerleave", H), h.clear(), c.clear();
1998
+ },
1999
+ update() {
2000
+ const P = g.length;
2001
+ for (let M = 0; M < P; M++) {
2002
+ const { type: x, event: G } = g[M], B = p(G, x);
2003
+ if (x === "move" && (d.push(B), h.get(B) != G)) {
2004
+ B.emitMove(G);
2005
+ continue;
2006
+ }
2007
+ if (x === "wheel" && c.get(B) != G) {
2008
+ B.emitWheel(G);
2009
+ continue;
2010
+ }
2011
+ y(x, G, B);
2012
+ }
2013
+ if (g.length = 0, o.intersectEveryFrame ?? !1)
2014
+ for (const [M, x] of h.entries())
2015
+ d.includes(M) || M.move(n, x);
2016
+ d.length = 0;
2017
+ }
2018
+ };
2019
+ }
2020
+ function gn(t) {
2021
+ return t.button != null;
2022
+ }
2023
+ let rr = class It {
2024
+ constructor(e) {
2025
+ v(this, "enableMultiplePointers");
2026
+ v(this, "pointers", []);
2027
+ v(this, "isDefaults", []);
2028
+ v(this, "enabled", !0);
2029
+ v(this, "activePointer");
2030
+ v(this, "nonCapturedPointers", []);
2031
+ this.enableMultiplePointers = e;
2032
+ }
2033
+ register(e, n = !1) {
2034
+ return this.pointers.push(e), this.isDefaults.push(n), this.unregister.bind(this, e);
2035
+ }
2036
+ unregister(e) {
2037
+ const n = this.pointers.indexOf(e);
2038
+ n !== -1 && (this.isDefaults.splice(n, 1), this.pointers.splice(n, 1));
2039
+ }
2040
+ /**
2041
+ * @returns true if any pointer is captured
2042
+ */
2043
+ startIntersection(e, n) {
2044
+ const r = this.pointers.length;
2045
+ let i = !1;
2046
+ for (let s = 0; s < r; s++) {
2047
+ const o = this.pointers[s];
2048
+ if (o instanceof It) {
2049
+ o.startIntersection(e, n);
2050
+ continue;
2051
+ }
2052
+ const a = o.getPointerCapture();
2053
+ if (a != null) {
2054
+ i = !0, o.setIntersection(o.intersector.intersectPointerCapture(a, n));
2055
+ continue;
2056
+ }
2057
+ e.push(o), o.intersector.startIntersection(n);
2058
+ }
2059
+ return i;
2060
+ }
2061
+ /**
2062
+ * only for internal use
2063
+ */
2064
+ getIntersection() {
2065
+ return this.activePointer?.getIntersection();
2066
+ }
2067
+ /**
2068
+ * only for internal use
2069
+ */
2070
+ getPointerCapture() {
2071
+ return this.activePointer?.getPointerCapture();
2072
+ }
2073
+ computeActivePointer() {
2074
+ let e;
2075
+ this.activePointer = void 0;
2076
+ const n = this.pointers.length;
2077
+ for (let r = 0; r < n; r++) {
2078
+ const i = this.pointers[r];
2079
+ i instanceof It && i.computeActivePointer();
2080
+ const s = i.getIntersection(), o = i.getPointerCapture() != null ? -1 / 0 : s?.object.isVoidObject ? 1 / 0 : s?.distance ?? 1 / 0, a = this.isDefaults[r];
2081
+ (e == null || a && o === e || o < e) && (this.activePointer = i, e = o);
2082
+ }
2083
+ }
2084
+ /**
2085
+ * only for internal use
2086
+ */
2087
+ commit(e, n, r = !0) {
2088
+ if (this.enableMultiplePointers) {
2089
+ const s = this.pointers.length;
2090
+ for (let o = 0; o < s; o++)
2091
+ this.pointers[o].commit(e, n);
2092
+ return;
2093
+ }
2094
+ r && this.computeActivePointer();
2095
+ const i = this.pointers.length;
2096
+ for (let s = 0; s < i; s++) {
2097
+ const o = this.pointers[s];
2098
+ o.setEnabled(o === this.activePointer, e, !1), o.commit(e, n, !1);
2099
+ }
2100
+ }
2101
+ move(e, n) {
2102
+ if (!this.enabled)
2103
+ return;
2104
+ if (this.nonCapturedPointers.length = 0, !this.startIntersection(this.nonCapturedPointers, n) || this.enableMultiplePointers) {
2105
+ _t("pointer", e, this.nonCapturedPointers);
2106
+ const i = this.nonCapturedPointers.length;
2107
+ for (let s = 0; s < i; s++) {
2108
+ const o = this.nonCapturedPointers[s];
2109
+ o.setIntersection(o.intersector.finalizeIntersection(e));
2110
+ }
2111
+ }
2112
+ this.commit(n, !0);
2113
+ }
2114
+ setEnabled(e, n) {
2115
+ this.enabled = e;
2116
+ const r = this.pointers.length;
2117
+ for (let i = 0; i < r; i++) {
2118
+ const s = this.pointers[i];
2119
+ s.setEnabled(e && (this.enableMultiplePointers || s == this.activePointer), n);
2120
+ }
2121
+ }
2122
+ };
2123
+ new w();
2124
+ new w();
2125
+ new w();
2126
+ function xs() {
2127
+ return navigator.userAgent.includes("Macintosh") && navigator.xr != null;
2128
+ }
2129
+ function ir(t, e, {
2130
+ anchors: n = !0,
2131
+ handTracking: r = !xs(),
2132
+ layers: i = !0,
2133
+ meshDetection: s = !0,
2134
+ planeDetection: o = !0,
2135
+ customSessionInit: a,
2136
+ depthSensing: l = !1,
2137
+ hitTest: u = !0,
2138
+ domOverlay: p = !0,
2139
+ bodyTracking: c = !1,
2140
+ //until 6.7 since breaking change
2141
+ bounded: h
2142
+ } = {}) {
2143
+ if (a != null)
2144
+ return a;
2145
+ const d = h == null ? ["local-floor"] : h ? ["bounded-floor"] : ["unbounded", "local-floor"], g = [];
2146
+ p instanceof Element && (p = !0), Y(n, "anchors", d, g), Y(r, "hand-tracking", d, g), Y(i, "layers", d, g), Y(s, "mesh-detection", d, g), Y(o, "plane-detection", d, g), Y(l, "depth-sensing", d, g), Y(p, "dom-overlay", d, g), Y(u, "hit-test", d, g), Y(c, "body-tracking", d, g);
2147
+ const y = {
2148
+ requiredFeatures: d,
2149
+ optionalFeatures: g
2150
+ };
2151
+ return e != null && (y.domOverlay = { root: e }), l && Object.assign(y, { depthSensing: { usagePreference: ["gpu-optimized"], dataFormatPreference: [] } }), y;
2152
+ }
2153
+ function Y(t, e, n, r) {
2154
+ if (t !== !1) {
2155
+ if (t === !0) {
2156
+ r.push(e);
2157
+ return;
2158
+ }
2159
+ n.push(e);
2160
+ }
2161
+ }
2162
+ function ue(t, e, n) {
2163
+ return typeof t == "function" ? t : (typeof t == "object" && (e != null && Ss(t, e) ? t = t[e] : "default" in t && (t = t.default)), t === !1 ? !1 : t === !0 ? n : t ?? n);
2164
+ }
2165
+ function Ss(t, e) {
2166
+ return e in t;
2167
+ }
2168
+ const sr = {
2169
+ session: void 0,
2170
+ mediaBinding: void 0,
2171
+ originReferenceSpace: void 0,
2172
+ visibilityState: void 0,
2173
+ mode: null,
2174
+ frameRate: void 0,
2175
+ inputSourceStates: [],
2176
+ detectedMeshes: [],
2177
+ detectedPlanes: [],
2178
+ layerEntries: []
2179
+ };
2180
+ async function yn(t, e, n) {
2181
+ if (typeof navigator > "u")
2182
+ return !1;
2183
+ const [r, i] = await Promise.all([
2184
+ navigator.xr?.isSessionSupported("immersive-vr").catch((o) => (console.error(o), !1)),
2185
+ navigator.xr?.isSessionSupported("immersive-ar").catch((o) => (console.error(o), !1))
2186
+ ]);
2187
+ if (i || r)
2188
+ return !1;
2189
+ const { emulate: s } = await import("./emulate-CAN_KLPP.js");
2190
+ return n && window.alert("emulator started"), t.setState({
2191
+ emulator: s(e === !0 ? "metaQuest3" : e)
2192
+ }), !0;
2193
+ }
2194
+ const xt = new w(), _e = new w();
2195
+ function Ps(t) {
2196
+ const e = typeof HTMLElement > "u" ? void 0 : t?.domOverlay instanceof HTMLElement ? t.domOverlay : document.createElement("div"), n = Bn(() => ({
2197
+ ...sr,
2198
+ controller: t?.controller,
2199
+ hand: t?.hand,
2200
+ gaze: t?.gaze,
2201
+ screenInput: t?.screenInput,
2202
+ transientPointer: t?.transientPointer,
2203
+ domOverlayRoot: e
2204
+ })), r = n.subscribe(({ session: d }, { session: g }) => {
2205
+ g != null && d == null && c != null && Oe(c, t, e).catch(console.error);
2206
+ }), i = t?.emulate ?? "metaQuest3";
2207
+ let s;
2208
+ if (typeof window < "u" && i != !1) {
2209
+ const d = (typeof i == "object" ? i.inject : void 0) ?? { hostname: "localhost" };
2210
+ (d === !0 || typeof d != "boolean" && window.location.hostname === d.hostname) && yn(n, i, !1).then((y) => {
2211
+ !y || c == null || Oe(c, t, e);
2212
+ });
2213
+ const g = (y) => {
2214
+ y.altKey && y.metaKey && y.code === "KeyE" && yn(n, i, !0).then((f) => {
2215
+ !f || c == null || Oe(c, t, e);
2216
+ });
2217
+ };
2218
+ window.addEventListener("keydown", g), s = () => window.removeEventListener("keydown", g);
2219
+ }
2220
+ let o;
2221
+ if (e != null) {
2222
+ if (e.parentNode == null) {
2223
+ const d = (y) => {
2224
+ e.style.display = y.session != null ? "block" : "none";
2225
+ }, g = n.subscribe(d);
2226
+ d(n.getState()), document.body.appendChild(e), o = () => {
2227
+ e.remove(), g();
2228
+ };
2229
+ }
2230
+ document.body.append(e);
2231
+ }
2232
+ const a = Li((d) => n.setState({ inputSourceStates: [...n.getState().inputSourceStates, d] }), t), l = Cs(n, a, t?.secondaryInputSources ?? !1), u = Rs(t?.enterGrantedSession, (d) => Te(e, d, t, c)), p = [];
2233
+ let c;
2234
+ const h = () => {
2235
+ n.setState(l(c.getSession()));
2236
+ };
2237
+ return Object.assign(n, {
2238
+ addLayerEntry(d) {
2239
+ n.getState().session != null && n.setState({ layerEntries: [...n.getState().layerEntries, d] });
2240
+ },
2241
+ removeLayerEntry(d) {
2242
+ n.getState().session != null && n.setState({ layerEntries: n.getState().layerEntries.filter((g) => g != d) });
2243
+ },
2244
+ requestFrame() {
2245
+ return new Promise((d) => p.push(d));
2246
+ },
2247
+ setWebXRManager(d) {
2248
+ if (c === d)
2249
+ return;
2250
+ c?.removeEventListener("sessionstart", h), c = d, c.addEventListener("sessionstart", h);
2251
+ const { foveation: g, bounded: y } = t ?? {};
2252
+ c.setReferenceSpaceType(y ? "bounded-floor" : "local-floor"), g != null && c.setFoveation(g), Oe(c, t, e).catch(console.error);
2253
+ },
2254
+ setFrameRate(d) {
2255
+ const { session: g } = n.getState();
2256
+ g != null && or(g, d);
2257
+ },
2258
+ setHand(d, g) {
2259
+ if (g == null) {
2260
+ n.setState({ hand: d });
2261
+ return;
2262
+ }
2263
+ const y = n.getState().hand, f = {};
2264
+ typeof y == "object" && Object.assign(f, y), Object.assign(f, {
2265
+ default: ue(y, void 0, {}),
2266
+ [g]: d
2267
+ }), n.setState({
2268
+ hand: f
2269
+ });
2270
+ },
2271
+ setController(d, g) {
2272
+ if (g == null) {
2273
+ n.setState({ controller: d });
2274
+ return;
2275
+ }
2276
+ const y = n.getState().controller, f = {};
2277
+ typeof y == "object" && Object.assign(f, y), Object.assign(f, {
2278
+ default: ue(y, void 0, {}),
2279
+ [g]: d
2280
+ }), n.setState({
2281
+ controller: f
2282
+ });
2283
+ },
2284
+ setTransientPointer(d, g) {
2285
+ if (g == null) {
2286
+ n.setState({ transientPointer: d });
2287
+ return;
2288
+ }
2289
+ const y = n.getState().transientPointer, f = {};
2290
+ typeof y == "object" && Object.assign(f, y), Object.assign(f, {
2291
+ default: ue(y, void 0, {}),
2292
+ [g]: d
2293
+ }), n.setState({
2294
+ transientPointer: f
2295
+ });
2296
+ },
2297
+ setGaze(d) {
2298
+ n.setState({ gaze: d });
2299
+ },
2300
+ setScreenInput(d) {
2301
+ n.setState({ screenInput: d });
2302
+ },
2303
+ destroy() {
2304
+ c?.removeEventListener("sessionstart", h), s?.(), o?.(), u?.(), r(), l(void 0);
2305
+ },
2306
+ enterXR: (d) => Te(e, d, t, c),
2307
+ enterAR: () => Te(e, "immersive-ar", t, c),
2308
+ enterVR: () => Te(e, "immersive-vr", t, c),
2309
+ onBeforeFrame(d, g, y) {
2310
+ let f;
2311
+ const R = c?.getReferenceSpace() ?? void 0, I = n.getState(), b = g.parent ?? d;
2312
+ if (I.origin != b && (f ?? (f = {}), f.origin = b), R != I.originReferenceSpace && (f ?? (f = {}), f.originReferenceSpace = R), b.xrSpace = R, I.origin != b && I.origin != null && (I.origin.xrSpace = void 0), y != null && (c != null && Is(n, y, c), I.body != y.body && (f ?? (f = {}), f.body = y.body)), f != null && n.setState(f), y != null) {
2313
+ const T = p.length;
2314
+ for (let D = 0; D < T; D++)
2315
+ p[D](y);
2316
+ p.length = 0;
2317
+ }
2318
+ },
2319
+ onBeforeRender() {
2320
+ const { session: d, layerEntries: g } = n.getState();
2321
+ if (d == null || c == null)
2322
+ return;
2323
+ const y = c.getCamera();
2324
+ y.aspect = y.projectionMatrix.elements[5] / y.projectionMatrix.elements[0];
2325
+ const f = d?.renderState.layers;
2326
+ if (f == null)
2327
+ return;
2328
+ y.getWorldPosition(xt), g.sort((b, T) => {
2329
+ const D = b.renderOrder - T.renderOrder;
2330
+ if (D !== 0)
2331
+ return D;
2332
+ b.object3D.getWorldPosition(_e);
2333
+ const L = _e.distanceToSquared(xt);
2334
+ return T.object3D.getWorldPosition(_e), _e.distanceToSquared(xt) - L;
2335
+ });
2336
+ let R = !1;
2337
+ const I = g.map(({ layer: b }, T) => (b != f[T] && (R = !0), b));
2338
+ R && (I.push(c.getBaseLayer()), d.updateRenderState({
2339
+ layers: I
2340
+ }));
2341
+ }
2342
+ });
2343
+ }
2344
+ async function Oe(t, e, n) {
2345
+ const r = e?.offerSession ?? !0;
2346
+ if (navigator.xr?.offerSession == null || r === !1)
2347
+ return;
2348
+ let i;
2349
+ r === !0 ? i = await navigator.xr.isSessionSupported("immersive-ar") ?? !1 ? "immersive-ar" : "immersive-vr" : i = r;
2350
+ const s = await navigator.xr.offerSession(i, ir(i, n, e));
2351
+ ar(s, t, e);
2352
+ }
2353
+ async function or(t, e) {
2354
+ if (e === !1)
2355
+ return;
2356
+ const { supportedFrameRates: n } = t;
2357
+ if (n == null || n.length === 0)
2358
+ return;
2359
+ if (typeof e == "function") {
2360
+ const i = e(n);
2361
+ if (i === !1)
2362
+ return;
2363
+ await t.updateTargetFrameRate(i);
2364
+ return;
2365
+ }
2366
+ const r = e === "high" ? 1 : e === "mid" ? 0.5 : 0;
2367
+ await t.updateTargetFrameRate(n[Math.ceil((n.length - 1) * r)]);
2368
+ }
2369
+ async function Te(t, e, n, r) {
2370
+ if (typeof navigator > "u" || navigator.xr == null)
2371
+ return Promise.reject(new Error("WebXR not supported"));
2372
+ if (r == null)
2373
+ return Promise.reject(new Error("not connected to three.js. You either might be missing the <XR> component or the canvas is not yet loaded?"));
2374
+ const i = await navigator.xr.requestSession(e, ir(e, t, n));
2375
+ return await ar(i, r, n), i;
2376
+ }
2377
+ async function ar(t, e, n) {
2378
+ await Promise.all([or(t, n?.frameRate ?? "high"), Ms(e, t, n)]);
2379
+ }
2380
+ async function Ms(t, e, n) {
2381
+ if (t == null)
2382
+ return;
2383
+ const r = XRWebGLLayer.getNativeFramebufferScaleFactor(e);
2384
+ let i = n?.frameBufferScaling;
2385
+ typeof i == "function" && (i = i(r)), typeof i == "string" && (i = i === "high" ? r : i === "mid" ? 1 : 0.5), i != null && t?.setFramebufferScaleFactor(i), await t?.setSession(e);
2386
+ }
2387
+ const vn = ["immersive-ar", "immersive-vr", "inline"];
2388
+ function Rs(t = vn, e) {
2389
+ if (typeof navigator > "u" || t === !1)
2390
+ return;
2391
+ t === !0 && (t = vn);
2392
+ const n = async () => {
2393
+ for (const r of t)
2394
+ await navigator.xr?.isSessionSupported(r) && e(r);
2395
+ };
2396
+ return navigator.xr?.addEventListener("sessiongranted", n), () => navigator.xr?.removeEventListener("sessiongranted", n);
2397
+ }
2398
+ function Cs(t, e, n) {
2399
+ let r;
2400
+ return (i) => {
2401
+ if (r?.(), i == null)
2402
+ return {};
2403
+ const s = [];
2404
+ let o;
2405
+ const a = () => {
2406
+ o = void 0, t.setState({
2407
+ inputSourceStates: e(i, t.getState().inputSourceStates, s)
2408
+ }), s.length = 0;
2409
+ }, l = (y, f) => {
2410
+ s.push({ isPrimary: y, added: f.added, removed: f.removed }), o == null && (n ? o = setTimeout(a, 100) : a());
2411
+ }, u = l.bind(null, !0);
2412
+ i.addEventListener("inputsourceschange", u);
2413
+ let p;
2414
+ if (n) {
2415
+ const y = l.bind(null, !1);
2416
+ i.addEventListener("trackedsourceschange", y), p = () => i.removeEventListener("trackedsourceschange", y);
2417
+ }
2418
+ const c = () => t.setState({ frameRate: i.frameRate, visibilityState: i.visibilityState });
2419
+ i.addEventListener("frameratechange", c), i.addEventListener("visibilitychange", c);
2420
+ const h = () => {
2421
+ r?.(), r = void 0, t.setState({
2422
+ emulator: t.getState().emulator,
2423
+ ...sr
2424
+ });
2425
+ };
2426
+ i.addEventListener("end", h);
2427
+ const d = [
2428
+ { isPrimary: !0, added: i.inputSources }
2429
+ ];
2430
+ n && d.push({ isPrimary: !1, added: i.trackedSources });
2431
+ const g = e(i, [], d);
2432
+ return r = () => {
2433
+ p?.(), clearTimeout(o), e(i, t.getState().inputSourceStates, "remove-all"), i.removeEventListener("end", h), i.removeEventListener("frameratechange", c), i.removeEventListener("visibilitychange", c), i.removeEventListener("inputsourceschange", u);
2434
+ }, {
2435
+ inputSourceStates: g,
2436
+ frameRate: i.frameRate,
2437
+ visibilityState: i.visibilityState,
2438
+ detectedMeshes: [],
2439
+ detectedPlanes: [],
2440
+ mode: i.environmentBlendMode === "opaque" ? "immersive-vr" : "immersive-ar",
2441
+ session: i,
2442
+ mediaBinding: typeof XRMediaBinding > "u" ? void 0 : new XRMediaBinding(i)
2443
+ };
2444
+ };
2445
+ }
2446
+ function Is(t, e, n) {
2447
+ const r = n.getReferenceSpace(), { detectedMeshes: i, detectedPlanes: s, session: o, inputSourceStates: a } = t.getState();
2448
+ if (r == null || o == null)
2449
+ return;
2450
+ const l = wn(s, e.detectedPlanes), u = wn(i, e.detectedMeshes);
2451
+ (s != l || i != u) && t.setState({ detectedPlanes: l, detectedMeshes: u });
2452
+ const p = a.length;
2453
+ for (let c = 0; c < p; c++) {
2454
+ const h = a[c];
2455
+ switch (h.type) {
2456
+ case "controller":
2457
+ oo(h);
2458
+ break;
2459
+ case "hand":
2460
+ Mi(h, e, n);
2461
+ break;
2462
+ }
2463
+ }
2464
+ }
2465
+ const As = [];
2466
+ function wn(t, e) {
2467
+ return e == null ? As : t != null && Es(e, t) ? t : Array.from(e);
2468
+ }
2469
+ function Es(t, e) {
2470
+ if (t.size != e.length)
2471
+ return !1;
2472
+ for (const n of e)
2473
+ if (!t.has(n))
2474
+ return !1;
2475
+ return !0;
2476
+ }
2477
+ new Er();
2478
+ new zn();
2479
+ async function Ls(t, e = no) {
2480
+ const { scene: n } = await e.loadAsync(t.assetPath);
2481
+ return n.clone(!0);
2482
+ }
2483
+ function _s(t, e) {
2484
+ t.renderOrder = e?.renderOrder ?? 0, t.traverse((n) => {
2485
+ n instanceof Z && n.material instanceof _n && (n.material.colorWrite = e?.colorWrite ?? !0);
2486
+ });
2487
+ }
2488
+ function Os(t, e, n) {
2489
+ const r = [];
2490
+ for (const i in e.components) {
2491
+ const s = e.components[i];
2492
+ let o = n[i];
2493
+ o == null && (n[i] = o = {
2494
+ state: "default"
2495
+ }), r.push(...Object.values(s.visualResponses).map((a) => Ts(t, o, a)));
2496
+ }
2497
+ return () => {
2498
+ const i = r.length;
2499
+ for (let s = 0; s < i; s++)
2500
+ r[s]();
2501
+ };
2502
+ }
2503
+ function Ts(t, e, n) {
2504
+ const r = t.getObjectByName(n.valueNodeName);
2505
+ if (e.object = r, r == null)
2506
+ return () => {
2507
+ };
2508
+ if (n.valueNodeProperty === "visibility")
2509
+ return () => r.visible = n.states.includes(e.state);
2510
+ const i = t.getObjectByName(n.minNodeName), s = t.getObjectByName(n.maxNodeName);
2511
+ return i == null || s == null ? () => {
2512
+ } : () => {
2513
+ const o = Xs(e, n);
2514
+ r.quaternion.slerpQuaternions(i.quaternion, s.quaternion, o), r.position.lerpVectors(i.position, s.position, o), r.updateMatrix();
2515
+ };
2516
+ }
2517
+ function Xs(t, { componentProperty: e, states: n }) {
2518
+ const r = n.includes(t.state);
2519
+ switch (e) {
2520
+ case "xAxis":
2521
+ return r ? bn(t).x : 0.5;
2522
+ case "yAxis":
2523
+ return r ? bn(t).y : 0.5;
2524
+ case "button":
2525
+ return r ? t.button ?? 0 : 0;
2526
+ case "state":
2527
+ return r ? 1 : 0;
2528
+ }
2529
+ }
2530
+ const me = new W();
2531
+ function bn({ xAxis: t = 0, yAxis: e = 0 }) {
2532
+ if (me.lengthSq() > 1) {
2533
+ const r = Math.atan2(e, t);
2534
+ me.set(Math.cos(r), Math.sin(r));
2535
+ } else
2536
+ me.set(t, e);
2537
+ return me.multiplyScalar(0.5).addScalar(0.5), me;
2538
+ }
2539
+ function xn(t, e) {
2540
+ if (e != null && e.createdAt != null && e.createdAt >= t.lastChangedTime)
2541
+ return e;
2542
+ const n = new qe();
2543
+ return n.setIndex(new $(t.indices, 1)), n.setAttribute("position", new $(t.vertices, 3)), Object.assign(n, { creationTime: t.lastChangedTime });
2544
+ }
2545
+ function Sn(t, e) {
2546
+ return e != null && e.createdAt != null && e.createdAt >= t.lastChangedTime ? e : Object.assign(Fs(t.polygon), { createdAt: t.lastChangedTime });
2547
+ }
2548
+ const ge = new Lr(), Xe = new W();
2549
+ function Fs(t) {
2550
+ if (t.length === 0)
2551
+ return new qe();
2552
+ const e = new _r(), n = t.map(({ x: i, z: s }) => new W(i, s));
2553
+ ge.setFromPoints(n), ge.getSize(Xe);
2554
+ for (const i of n)
2555
+ i.sub(ge.min), i.divide(Xe);
2556
+ e.setFromPoints(n);
2557
+ const r = new Or(e);
2558
+ return r.scale(Xe.x, Xe.y, 1), r.translate(ge.min.x, ge.min.y, 0), r.rotateX(Math.PI / 2), r;
2559
+ }
2560
+ function Ne(t, e = 1) {
2561
+ if (t != null)
2562
+ return {
2563
+ x: ne(t.x),
2564
+ y: ne(t.y),
2565
+ z: ne(t.z),
2566
+ w: "w" in t ? ne(t.w, e) : e
2567
+ };
2568
+ }
2569
+ function ne(t, e = 0) {
2570
+ return isNaN(t) ? e : t;
2571
+ }
2572
+ const Xt = 60 / 180 * Math.PI, lr = 60 / 180 * Math.PI, ur = -30 / 180 * Math.PI, cr = 30 / 180 * Math.PI;
2573
+ function zs(t, e, n, r, i, s, o) {
2574
+ return t instanceof HTMLVideoElement ? Ws(t, e, n, i, s, o) : Ds(t, e.origin, n, r, i, s, o);
2575
+ }
2576
+ function Ws(t, e, n, r, { invertStereo: i, layout: s, shape: o = "quad" }, a = {}) {
2577
+ const l = Ye(r, e.origin, n, ce), u = Ft(ce, ie), p = {
2578
+ invertStereo: i,
2579
+ layout: s,
2580
+ space: l,
2581
+ transform: u
2582
+ };
2583
+ Wt(o, p, a.centralAngle, ie);
2584
+ const c = `create${dr(o)}Layer`, h = e.mediaBinding?.[c](t, p);
2585
+ if (h != null)
2586
+ return zt(h, a), h;
2587
+ }
2588
+ function Ds(t, e, n, r, i, { shape: s = "quad", ...o }, a = {}) {
2589
+ const l = Ye(i, e, n, ce), u = Ft(ce, ie), p = {
2590
+ ...o,
2591
+ isStatic: !(t instanceof we),
2592
+ textureType: "texture",
2593
+ viewPixelWidth: o.layout === "stereo-left-right" ? t.width / 2 : t.width,
2594
+ viewPixelHeight: o.layout === "stereo-top-bottom" ? t.height / 2 : t.height,
2595
+ space: l,
2596
+ transform: u
2597
+ };
2598
+ Wt(s, p, a.centralAngle, ie);
2599
+ const c = `create${dr(s)}Layer`, h = r.getBinding()?.[c](p);
2600
+ if (h != null)
2601
+ return zt(h, a), h;
2602
+ }
2603
+ const ce = new j(), Pn = new w(), Mn = new U(), ie = new w();
2604
+ function Ft(t, e = ie) {
2605
+ return t.decompose(Pn, Mn, e), e.x = ne(e.x), e.y = ne(e.y), e.z = ne(e.z), new XRRigidTransform(Ne(Pn), Ne(Mn));
2606
+ }
2607
+ const Hs = 64 / Math.PI;
2608
+ function St(t) {
2609
+ return Math.ceil(t * Hs);
2610
+ }
2611
+ function Vs(t, e, n, r) {
2612
+ if (n != null && r != null) {
2613
+ const i = t.xr.getBinding().getSubImage(n.layer, r);
2614
+ t.setRenderTargetTextures(e, i.colorTexture);
2615
+ }
2616
+ t.setRenderTarget(e);
2617
+ }
2618
+ function js(t, e) {
2619
+ switch (t) {
2620
+ case "cylinder":
2621
+ const n = e.centralAngle ?? Xt;
2622
+ return new Tr(1, 1, 1, St(n), 1, !0, Math.PI - n / 2, n).scale(-1, 1, 1);
2623
+ case "equirect": {
2624
+ const r = e.centralHorizontalAngle ?? lr, i = e.upperVerticalAngle ?? cr, s = e.lowerVerticalAngle ?? ur, o = i - s;
2625
+ return new Tn(1, St(r), St(o), -Math.PI / 2 - r / 2, r, Math.PI / 2 - i, o).scale(-1, 1, 1);
2626
+ }
2627
+ case "quad":
2628
+ return new zn();
2629
+ }
2630
+ }
2631
+ function dr(t) {
2632
+ return `${t[0].toUpperCase()}${t.slice(1)}`;
2633
+ }
2634
+ function zt(t, e = {}) {
2635
+ if (t.chromaticAberrationCorrection = e.chromaticAberrationCorrection, t.quality = e.quality ?? "default", t.blendTextureSourceAlpha = e.blendTextureSourceAlpha ?? !1, t instanceof XRCylinderLayer) {
2636
+ t.centralAngle = e?.centralAngle ?? Xt;
2637
+ return;
2638
+ }
2639
+ t instanceof XREquirectLayer && (t.centralHorizontalAngle = e?.centralHorizontalAngle ?? lr, t.lowerVerticalAngle = e?.lowerVerticalAngle ?? ur, t.upperVerticalAngle = e?.upperVerticalAngle ?? cr);
2640
+ }
2641
+ function ks(t, e, n, r) {
2642
+ let i = !1;
2643
+ const s = async () => {
2644
+ const o = await e.requestFrame();
2645
+ i || qs(t, n, o, r);
2646
+ };
2647
+ return n.addEventListener("redraw", s), s(), () => {
2648
+ i = !0, n.removeEventListener("redraw", s);
2649
+ };
2650
+ }
2651
+ async function Bs(t) {
2652
+ if (t instanceof HTMLImageElement && !t.complete && await new Promise((e) => {
2653
+ const n = () => {
2654
+ e(), t.removeEventListener("load", n);
2655
+ };
2656
+ t.addEventListener("load", n);
2657
+ }), t instanceof HTMLVideoElement && t.readyState < 1)
2658
+ return new Promise((e) => {
2659
+ const n = () => {
2660
+ e(), t.removeEventListener("loadedmetadata", n);
2661
+ };
2662
+ t.addEventListener("loadedmetadata", n);
2663
+ });
2664
+ }
2665
+ function Ns(t) {
2666
+ if (t instanceof we)
2667
+ return t.texture;
2668
+ const e = t instanceof HTMLVideoElement ? new zr(t) : new Wr(t);
2669
+ return e.colorSpace = Dr, e.needsUpdate = !0, e;
2670
+ }
2671
+ function qs(t, e, n, r) {
2672
+ const i = t.getContext(), s = t.xr.getBinding().getSubImage(e, n);
2673
+ t.state.bindTexture(i.TEXTURE_2D, s.colorTexture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0), i.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, r.width, r.height, i.RGBA, i.UNSIGNED_BYTE, r);
2674
+ }
2675
+ function Gs(t, e, n, r) {
2676
+ t.originReferenceSpace != null && (e.space = Ye(r, t.origin, t.originReferenceSpace, ce), e.transform = Ft(ce, ie), Wt($s(e), e, n, ie));
2677
+ }
2678
+ function Wt(t, e, n, r) {
2679
+ if (t === "cylinder") {
2680
+ const s = (r.x + r.z) / 2, o = s * (n ?? Xt);
2681
+ e.radius = s, e.aspectRatio = r.y === 0 ? 1 : o / r.y;
2682
+ } else t === "quad" ? (e.width = r.x / 2, e.height = r.y / 2) : e.radius = (r.x + r.y + r.z) / 3;
2683
+ }
2684
+ function $s(t) {
2685
+ return t instanceof XRCylinderLayer ? "cylinder" : t instanceof XREquirectLayer ? "equirect" : "quad";
2686
+ }
2687
+ function fr(t, e, n) {
2688
+ return new we(t * n, e * n, {
2689
+ minFilter: Vt,
2690
+ magFilter: Vt,
2691
+ type: Fr,
2692
+ depthTexture: new Xr(t, e)
2693
+ });
2694
+ }
2695
+ const ye = new Wn(0, 0, 0, "YXZ"), Fe = new U();
2696
+ function Us(t, e, n) {
2697
+ t.updateWorldMatrix(!0, !1), t.matrixWorld.decompose(e.position, Fe, e.scale), ye.setFromQuaternion(Fe), ye.z = 0, ye.x = We(ye.x - 10 * Math.PI / 180, -Math.PI / 2, 1.1 * Math.PI / 4), Fe.setFromEuler(ye), e.quaternion.slerp(Fe, n / 100);
2698
+ }
2699
+ function Qs(t) {
2700
+ return t.userData.teleportTarget === !0;
2701
+ }
2702
+ function Ys(t = {}) {
2703
+ return (e, n, r, i) => !(!Qs(e) || t.filter != null && !t.filter(e, n, r, i));
2704
+ }
2705
+ function Ks() {
2706
+ return new Hr(new w(0, 0, 0), new w(0, 0, -8), new w(0, -20, -15)).getPoints(20);
2707
+ }
2708
+ let Zs = class extends Z {
2709
+ constructor(n) {
2710
+ const r = new Kr(), i = new Float32Array(n.length * 3);
2711
+ for (let a = 0; a < n.length; a++)
2712
+ n[a].toArray(i, a * 3);
2713
+ r.setPoints(i);
2714
+ const s = (n.length * 3 - 3) / (n.length * 3 - 1), o = new ni({
2715
+ lineWidth: 0.1,
2716
+ resolution: void 0,
2717
+ visibility: s
2718
+ });
2719
+ super(r, o);
2720
+ v(this, "multiplier");
2721
+ v(this, "lineLengths");
2722
+ v(this, "options", {});
2723
+ this.material.transparent = !0, this.multiplier = s, this.material = o, this.lineLengths = n.slice(0, -1).map((a, l) => a.distanceTo(n[l + 1]));
2724
+ }
2725
+ update(n) {
2726
+ const r = n.getEnabled(), i = n.getIntersection();
2727
+ if (!r || n.getButtonsDown().size === 0 || i == null) {
2728
+ this.visible = !1;
2729
+ return;
2730
+ }
2731
+ if (this.visible = !0, i.details.type != "lines") {
2732
+ this.material.visibility = this.multiplier;
2733
+ return;
2734
+ }
2735
+ const { distanceOnLine: s, lineIndex: o } = i.details, a = this.lineLengths[o];
2736
+ this.material.visibility = this.multiplier * (o + s / a) / this.lineLengths.length;
2737
+ const { color: l = "white", opacity: u = 0.4, size: p = 0.01 } = this.options;
2738
+ this.material.lineWidth = p, this.material.opacity = typeof u == "function" ? u(n) : u;
2739
+ const c = typeof l == "function" ? l(n) : l;
2740
+ Array.isArray(c) ? this.material.color.set(...c) : this.material.color.set(c);
2741
+ }
2742
+ };
2743
+ const Rn = new j(), ze = new w(), Js = new w(), Cn = new U();
2744
+ async function eo(t, e, n, r = ["point", "plane", "mesh"]) {
2745
+ typeof n == "string" && (n = await e.requestReferenceSpace(n));
2746
+ const i = Array.isArray(r) ? r : [r];
2747
+ let s, o, a;
2748
+ const l = t.getState();
2749
+ if (n instanceof XRSpace)
2750
+ s = { space: n, entityTypes: i }, a = l.origin;
2751
+ else {
2752
+ const p = Ye(n, l.origin, l.originReferenceSpace, Rn);
2753
+ if (p == null)
2754
+ return;
2755
+ Rn.decompose(ze, Cn, Js);
2756
+ const c = Ne(ze);
2757
+ ze.set(0, 0, -1).applyQuaternion(Cn);
2758
+ const h = new XRRay(c, Ne(ze, 0));
2759
+ a = n, s = { space: p, offsetRay: h, entityTypes: i }, o = p;
2760
+ }
2761
+ const u = await e?.requestHitTestSource?.(s);
2762
+ if (u != null)
2763
+ return {
2764
+ source: u,
2765
+ getWorldMatrix: to.bind(null, t, o, a)
2766
+ };
2767
+ }
2768
+ function to(t, e, n, r, i) {
2769
+ if (e ?? (e = t.getState().originReferenceSpace), e == null)
2770
+ return !1;
2771
+ const s = i.getPose(e);
2772
+ return s == null ? !1 : (r.fromArray(s.transform.matrix), n != null && (n.updateWorldMatrix(!0, !1), r.premultiply(n.matrixWorld)), !0);
2773
+ }
2774
+ new w(1, 1, 1);
2775
+ new w(0, 0, 0);
2776
+ new j();
2777
+ new j();
2778
+ new w();
2779
+ new w();
2780
+ new w();
2781
+ new Wn();
2782
+ new w();
2783
+ new w();
2784
+ const no = new Dn(), hr = "https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/";
2785
+ function At(t, ...e) {
2786
+ let n = t();
2787
+ for (const r of e)
2788
+ n instanceof Promise ? n = n.then(r) : n = r(n);
2789
+ return n;
2790
+ }
2791
+ const ro = "generic-trigger";
2792
+ class io {
2793
+ constructor(e) {
2794
+ v(this, "baseAssetPath");
2795
+ v(this, "defaultProfileId");
2796
+ //cache
2797
+ v(this, "profilesListCache");
2798
+ v(this, "profileCacheMap", /* @__PURE__ */ new Map());
2799
+ //alias for Loader compatibility
2800
+ v(this, "loadAsync", this.load);
2801
+ this.baseAssetPath = e?.baseAssetPath ?? hr, this.defaultProfileId = e?.defaultControllerProfileId ?? ro;
2802
+ }
2803
+ load(e, n) {
2804
+ return At(
2805
+ //load profile
2806
+ () => this.loadProfile(e),
2807
+ //get controller layout from profile
2808
+ (r) => {
2809
+ for (const i in r.layouts)
2810
+ if (i.includes(n))
2811
+ return r.layouts[i];
2812
+ throw new Error(`No matching layout for "${n}", in profile ${r.profileId} with layouts ${Object.keys(r.layouts).join(", ")}.`);
2813
+ }
2814
+ );
2815
+ }
2816
+ loadProfile(e) {
2817
+ return At(
2818
+ //load profiles list
2819
+ () => this.profilesListCache ?? In(new URL("profilesList.json", this.baseAssetPath).href).then((n) => this.profilesListCache = n),
2820
+ //load profile
2821
+ (n) => {
2822
+ const r = e.length;
2823
+ let i;
2824
+ for (let s = 0; s < r && (i = n[e[s]], i == null); s++)
2825
+ ;
2826
+ if (i ?? (i = n[this.defaultProfileId]), i == null)
2827
+ throw new Error(`no matching profile found for profiles "${e.join(", ")}" in profile list ${JSON.stringify(n)}`);
2828
+ return this.loadProfileFromPath(i.path);
2829
+ }
2830
+ );
2831
+ }
2832
+ loadProfileFromPath(e) {
2833
+ const n = this.profileCacheMap.get(e);
2834
+ if (n != null)
2835
+ return n;
2836
+ const r = new URL(e, this.baseAssetPath).href;
2837
+ return In(r).then((i) => {
2838
+ for (const s in i.layouts) {
2839
+ const o = i.layouts[s];
2840
+ o != null && (o.assetPath = new URL(o.assetPath, r).href);
2841
+ }
2842
+ return this.profileCacheMap.set(e, i), i;
2843
+ });
2844
+ }
2845
+ }
2846
+ async function In(t) {
2847
+ let e = await fetch(t);
2848
+ return e.ok ? e.json() : Promise.reject(new Error(e.statusText));
2849
+ }
2850
+ function so(t, e, n, r, i) {
2851
+ return At(() => n.load(e.profiles, e.handedness), (s) => {
2852
+ const o = {};
2853
+ return Gn(o, e, s), {
2854
+ id: t,
2855
+ isPrimary: i,
2856
+ events: r,
2857
+ type: "controller",
2858
+ inputSource: e,
2859
+ gamepad: o,
2860
+ layout: s
2861
+ };
2862
+ });
2863
+ }
2864
+ function oo({ gamepad: t, inputSource: e, layout: n }) {
2865
+ Gn(t, e, n);
2866
+ }
2867
+ const pr = Ue(void 0), te = Ue(void 0), Me = Ue(void 0), Dt = Ue(void 0);
2868
+ function Re(t, e) {
2869
+ if (Object.is(t, e))
2870
+ return !0;
2871
+ if (typeof t != "object" || t === null || typeof e != "object" || e === null)
2872
+ return !1;
2873
+ if (t instanceof Map && e instanceof Map) {
2874
+ if (t.size !== e.size)
2875
+ return !1;
2876
+ for (const [r, i] of t)
2877
+ if (!Object.is(i, e.get(r)))
2878
+ return !1;
2879
+ return !0;
2880
+ }
2881
+ if (t instanceof Set && e instanceof Set) {
2882
+ if (t.size !== e.size)
2883
+ return !1;
2884
+ for (const r of t)
2885
+ if (!e.has(r))
2886
+ return !1;
2887
+ return !0;
2888
+ }
2889
+ const n = Object.keys(t);
2890
+ if (n.length !== Object.keys(e).length)
2891
+ return !1;
2892
+ for (const r of n)
2893
+ if (!Object.prototype.hasOwnProperty.call(e, r) || !Object.is(t[r], e[r]))
2894
+ return !1;
2895
+ return !0;
2896
+ }
2897
+ _(({ id: t, children: e, onPress: n, onRelease: r }, i) => {
2898
+ const s = ee("controller"), [o, a] = be(void 0);
2899
+ if (k(i, () => o, [o]), ao(s, t, (l) => l === "pressed" ? n?.() : r?.()), X(() => a(s.gamepad[t]?.object)), o != null)
2900
+ return Lt(e, o);
2901
+ });
2902
+ function ao(t, e, n) {
2903
+ const r = C(void 0);
2904
+ X(() => {
2905
+ const i = t?.gamepad[e]?.state;
2906
+ i != null && i != r.current && n(i), r.current = i;
2907
+ });
2908
+ }
2909
+ const lo = Symbol("loadXRControllerModel"), uo = _((t, e) => {
2910
+ const n = ee("controller"), r = Nr(Ls, [n.layout, void 0, lo]);
2911
+ _s(r, t), n.object = r, k(e, () => r, [r]);
2912
+ const i = A(() => Os(r, n.layout, n.gamepad), [r, n.layout, n.gamepad]);
2913
+ return X(i), m(Q, { space: "grip-space", children: m("primitive", { object: r }) });
2914
+ }), co = _((t, e) => {
2915
+ const n = ee("hand"), r = qr(Dn, n.assetPath), i = A(() => xi(r), [r]);
2916
+ Si(i, t), n.object = i, k(e, () => i, [i]);
2917
+ const s = wr(), o = A(() => Ci(n.inputSource.hand, i, s), [n.inputSource, i, s]);
2918
+ return X((a, l, u) => o(u)), m("primitive", { object: i });
2919
+ });
2920
+ _(({ joint: t, children: e }, n) => m(Q, { ref: n, space: t, children: e }));
2921
+ function mr({ children: t }) {
2922
+ const e = A(() => new rr(!1), []);
2923
+ return Ce(e), m(Dt.Provider, { value: e, children: t });
2924
+ }
2925
+ function et(t) {
2926
+ for (const e of Object.keys(t))
2927
+ delete t[e];
2928
+ }
2929
+ function fo(t, e, n, r) {
2930
+ const i = A(() => ({}), []);
2931
+ et(i), Object.assign(i, n);
2932
+ const s = ae(), o = A(() => ds(() => s.getState().camera, t, e, i, r), [s, t, e, i, r]);
2933
+ return Ce(o, n?.makeDefault), o;
2934
+ }
2935
+ function ho(t, e, n, r) {
2936
+ const i = A(() => ({}), []);
2937
+ et(i), Object.assign(i, n);
2938
+ const s = ae(), o = A(() => fs(() => s.getState().camera, t, e, i, r), [s, t, e, i, r]);
2939
+ return Ce(o, n?.makeDefault), o;
2940
+ }
2941
+ function po(t, e, n, r) {
2942
+ const i = A(() => ({}), []);
2943
+ et(i), Object.assign(i, n);
2944
+ const s = ae(), o = A(() => hs(() => s.getState().camera, t, e, i, r), [s, t, e, i, r]);
2945
+ return Ce(o, n?.makeDefault), o;
2946
+ }
2947
+ function mo(t, e, n, r) {
2948
+ const i = A(() => ({}), []);
2949
+ et(i), Object.assign(i, n);
2950
+ const s = ae(), o = A(() => ps(() => s.getState().camera, t, e, i, r), [s, t, e, i, r]);
2951
+ return Ce(o, n?.makeDefault), o;
2952
+ }
2953
+ const go = _((t, e) => {
2954
+ const n = A(() => {
2955
+ const i = t.materialClass ?? Fi;
2956
+ return new i();
2957
+ }, [t.materialClass]), r = C(null);
2958
+ return k(e, () => r.current, []), X(() => r.current != null && zi(r.current, n, t.pointer, t)), m("mesh", { matrixAutoUpdate: !1, renderOrder: t.renderOrder ?? 2, ref: r, material: n, children: m("boxGeometry", {}) });
2959
+ }), tt = _((t, e) => {
2960
+ const n = A(() => {
2961
+ const o = t.materialClass ?? Oi;
2962
+ return new o();
2963
+ }, [t.materialClass]), r = C(null), i = C(null);
2964
+ k(e, () => r.current, []), X(() => r.current != null && i.current != null && Xi(i.current, r.current, n, t.pointer, t));
2965
+ const s = xe((o) => o.scene);
2966
+ return N(q, { children: [m("group", { ref: i }), Lt(m("mesh", { renderOrder: t.renderOrder ?? 1, ref: r, matrixAutoUpdate: !1, material: n, children: m("planeGeometry", {}) }), s)] });
2967
+ });
2968
+ function Ht(t, e, n, r) {
2969
+ const i = E((s) => s.session);
2970
+ O(() => {
2971
+ if (i != null)
2972
+ return Wi(t, i, e, n, r);
2973
+ }, [n, e, t, i, r]);
2974
+ }
2975
+ function Ce(t, e = !1) {
2976
+ const n = se(Dt);
2977
+ if (n == null)
2978
+ throw new Error("xr pointers can only be used inside the XR component");
2979
+ O(() => {
2980
+ const r = n.register(t, e);
2981
+ return () => {
2982
+ r();
2983
+ };
2984
+ }, [n, t, e]), O(() => {
2985
+ if (t instanceof de)
2986
+ return () => t.exit({ timeStamp: performance.now() });
2987
+ }, [t]);
2988
+ }
2989
+ const yo = _(({ pointer: t, linePoints: e, ...n }, r) => {
2990
+ const i = A(() => new Zs(e), [e]);
2991
+ return k(r, () => i, [i]), i.options = n, X(() => i.update(t)), m("primitive", { object: i });
2992
+ });
2993
+ function gr(t, e, n) {
2994
+ const r = se(te);
2995
+ if (r == null)
2996
+ throw new Error("DefaultXRInputSourceGrabPointer can only be used inside a XRInputSource");
2997
+ const i = C(null), s = fo(i, r, n);
2998
+ Ht(s, r.inputSource, t, r.events);
2999
+ const o = n.cursorModel;
3000
+ return m(Q, { ref: i, space: e, children: o !== !1 && m(tt, { pointer: s, opacity: Di, ...z(o) }) });
3001
+ }
3002
+ const vo = gr.bind(null, "select", "index-finger-tip"), wo = gr.bind(null, "squeeze", "grip-space");
3003
+ function Ie(t) {
3004
+ const e = ee(), n = C(null), r = ho(n, e, t);
3005
+ Ht(r, e.inputSource, "select", e.events);
3006
+ const i = t.rayModel, s = t.cursorModel;
3007
+ return N(Q, { ref: n, space: "target-ray-space", children: [i !== !1 && m(go, { pointer: r, opacity: De, ...z(i) }), s !== !1 && m(tt, { pointer: r, opacity: De, ...z(s) })] });
3008
+ }
3009
+ function bo(t) {
3010
+ const e = ee("hand"), n = C(null), r = mo(n, e, t), i = t.cursorModel;
3011
+ return m(Q, { ref: n, space: e.inputSource.hand.get("index-finger-tip"), children: i !== !1 && m(tt, { pointer: r, opacity: Hi, ...z(i) }) });
3012
+ }
3013
+ function xo(t) {
3014
+ const e = t.model, n = t.grabPointer, r = t.rayPointer, i = t.teleportPointer ?? !1;
3015
+ return N(q, { children: [e !== !1 && m(oe, { children: m(uo, { ...z(e) }) }), N(mr, { children: [n !== !1 && m(wo, { ...z(n) }), r !== !1 && m(Ie, { makeDefault: !0, minDistance: 0.2, ...z(r) }), i !== !1 && m(yr, { ...z(i) })] })] });
3016
+ }
3017
+ function So(t) {
3018
+ const e = t.model, n = t.grabPointer, r = t.rayPointer, i = t.touchPointer, s = t.teleportPointer ?? !1, o = r === !1 ? !1 : z(r)?.rayModel;
3019
+ return N(q, { children: [e !== !1 && m(oe, { children: m(co, { ...z(e) }) }), N(mr, { children: [n !== !1 && m(vo, { ...z(n) }), i !== !1 && m(bo, { ...z(i) }), r !== !1 && m(Ie, { makeDefault: !0, minDistance: 0.2, ...z(r), rayModel: o === !1 ? !1 : { maxLength: 0.2, ...z(o) } }), s !== !1 && m(yr, { ...z(s) })] })] });
3020
+ }
3021
+ function Po(t) {
3022
+ return m(Ie, { ...t, rayModel: !1 });
3023
+ }
3024
+ function Mo(t) {
3025
+ return m(Ie, { ...t, rayModel: !1 });
3026
+ }
3027
+ function Ro(t) {
3028
+ return m(Ie, { ...t, cursorModel: !1, rayModel: !1 });
3029
+ }
3030
+ function yr(t) {
3031
+ const e = se(te);
3032
+ if (e == null)
3033
+ throw new Error("DefaultXRInputSourceRayPointer can only be used inside a XRInputSource");
3034
+ const n = C(null), r = C(null), i = A(() => Ks(), []), s = po(r, e, {
3035
+ ...t,
3036
+ linePoints: i,
3037
+ filter: Ys(t)
3038
+ }, "teleport");
3039
+ Ht(s, e.inputSource, "select", e.events);
3040
+ const o = t.rayModel, a = t.cursorModel, l = xe((p) => p.scene), u = C(null);
3041
+ return X((p, c) => {
3042
+ u.current != null && (u.current.visible = s.getEnabled() && s.getButtonsDown().size > 0);
3043
+ const h = r.current, d = n.current;
3044
+ h == null || d == null || Us(d, h, c * 1e3);
3045
+ }), N(q, { children: [m(Q, { ref: n, space: "target-ray-space" }), Lt(N("group", { ref: r, children: [o !== !1 && m(yo, { linePoints: i, pointer: s, opacity: De, ...z(o) }), a !== !1 && m(tt, { ref: u, pointer: s, opacity: De, ...z(a) })] }), l)] });
3046
+ }
3047
+ function z(t) {
3048
+ if (t !== !0)
3049
+ return t;
3050
+ }
3051
+ function Co() {
3052
+ return E((t) => t.visibilityState);
3053
+ }
3054
+ function Io(t, e) {
3055
+ const n = C(e);
3056
+ n.current = e;
3057
+ const [r, i] = A(() => {
3058
+ let s;
3059
+ return [
3060
+ (o) => {
3061
+ let a = !1;
3062
+ return typeof navigator > "u" || navigator.xr == null ? (s = !1, () => {
3063
+ }) : (navigator.xr.isSessionSupported(t).then((l) => {
3064
+ s = l, !a && o();
3065
+ }).catch((l) => {
3066
+ a || n.current?.(l);
3067
+ }), () => a = !0);
3068
+ },
3069
+ () => s
3070
+ ];
3071
+ }, [t]);
3072
+ return Br(r, i);
3073
+ }
3074
+ function Ao(t) {
3075
+ return E(({ session: e }) => e?.enabledFeatures?.includes(t) ?? !1);
3076
+ }
3077
+ let Eo = 0;
3078
+ const An = /* @__PURE__ */ new Map();
3079
+ function nt(t) {
3080
+ let e = An.get(t);
3081
+ return e == null && An.set(t, e = Eo++), e;
3082
+ }
3083
+ function Lo({ children: t }) {
3084
+ const e = E((o) => o.originReferenceSpace), n = E((o) => o.origin), r = Co() === "visible", i = ae(), s = A(() => Object.assign({}, i, {
3085
+ getState() {
3086
+ return { ...i.getState(), scene: n };
3087
+ }
3088
+ }), [n, i]);
3089
+ return n == null || e == null ? null : m(q, { children: jn.createPortal(m(kn.Provider, { value: i, children: N(Me.Provider, { value: e, children: [N("group", { matrixAutoUpdate: !1, visible: r, children: [m(_o, {}), m(Oo, {}), m(To, {}), m(Xo, {}), m(Fo, {})] }), t] }) }), s, null) });
3090
+ }
3091
+ function _o() {
3092
+ const t = E((n) => n.inputSourceStates.filter((r) => r.type === "controller"), Re);
3093
+ let e = E((n) => n.controller);
3094
+ return e === !1 ? null : m(q, { children: t.map((n) => {
3095
+ const r = ue(e, n.inputSource.handedness, {});
3096
+ return r === !1 ? null : m(te.Provider, { value: n, children: m(Q, { space: "target-ray-space", children: m(oe, { children: typeof r == "function" ? m(r, {}) : m(xo, { ...r }) }) }) }, n.id);
3097
+ }) });
3098
+ }
3099
+ function Oo() {
3100
+ const t = E((n) => n.inputSourceStates.filter((r) => r.type === "hand"), Re), e = E((n) => n.hand);
3101
+ return e === !1 ? null : m(q, { children: t.map((n) => {
3102
+ const r = ue(e, n.inputSource.handedness, {});
3103
+ return r === !1 ? null : m(te.Provider, { value: n, children: m(Q, { space: "target-ray-space", children: m(oe, { children: typeof r == "function" ? m(r, {}) : m(So, { ...r }) }) }) }, nt(n));
3104
+ }) });
3105
+ }
3106
+ function To() {
3107
+ const t = E((n) => n.inputSourceStates.filter((r) => r.type === "transientPointer"), Re), e = E((n) => n.transientPointer);
3108
+ return e === !1 ? null : m(q, { children: t.map((n) => {
3109
+ const r = ue(e, n.inputSource.handedness, {});
3110
+ return r === !1 ? null : m(te.Provider, { value: n, children: m(Q, { space: "target-ray-space", children: m(oe, { children: typeof r == "function" ? m(r, {}) : m(Po, { ...r }) }) }) }, nt(n));
3111
+ }) });
3112
+ }
3113
+ function Xo() {
3114
+ const t = E((n) => n.inputSourceStates.filter((r) => r.type === "gaze"), Re), e = E((n) => n.gaze);
3115
+ return e === !1 ? null : m(q, { children: t.map((n) => m(te.Provider, { value: n, children: m(Q, { space: "target-ray-space", children: m(oe, { children: typeof e == "function" ? m(e, {}) : m(Mo, { ...vr(e) }) }) }) }, nt(n))) });
3116
+ }
3117
+ function Fo() {
3118
+ const t = E((n) => n.inputSourceStates.filter((r) => r.type === "screenInput"), Re), e = E((n) => n.screenInput);
3119
+ return e === !1 ? null : m(q, { children: t.map((n) => m(te.Provider, { value: n, children: m(Q, { space: "target-ray-space", children: m(oe, { children: typeof e == "function" ? m(e, {}) : m(Ro, { ...vr(e) }) }) }) }, nt(n))) });
3120
+ }
3121
+ function vr(t) {
3122
+ if (t !== !0)
3123
+ return t;
3124
+ }
3125
+ function sa(t) {
3126
+ return Ps(t);
3127
+ }
3128
+ function oa({ children: t, store: e }) {
3129
+ e.setWebXRManager(xe((r) => r.gl.xr));
3130
+ const n = ae();
3131
+ return O(() => {
3132
+ let r;
3133
+ return e.subscribe((i, s) => {
3134
+ if (i.session !== s.session) {
3135
+ if (i.session != null) {
3136
+ const { camera: o, gl: a } = n.getState();
3137
+ r = o, n.setState({ camera: a.xr.getCamera() });
3138
+ return;
3139
+ }
3140
+ r != null && n.setState({ camera: r });
3141
+ }
3142
+ });
3143
+ }, [n, e]), X((r, i, s) => e.onBeforeFrame(r.scene, r.camera, s), -1e3), X(() => e.onBeforeRender()), m(pr.Provider, { value: e, children: N(zo, { children: [m(Lo, {}), t] }) });
3144
+ }
3145
+ function zo({ children: t }) {
3146
+ const e = rt(), n = A(() => new rr(!0), []);
3147
+ return O(() => _i(e, (r) => n.setEnabled(r, { timeStamp: performance.now() })), [e, n]), X((r) => n.move(r.scene, { timeStamp: performance.now() }), -50), m(Dt.Provider, { value: n, children: t });
3148
+ }
3149
+ function rt() {
3150
+ const t = se(pr);
3151
+ if (t == null)
3152
+ throw new Error("XR features can only be used inside the <XR> component");
3153
+ return t;
3154
+ }
3155
+ function E(t = (n) => n, e) {
3156
+ return Qe(rt(), t, e);
3157
+ }
3158
+ function aa(t, e) {
3159
+ return E((n) => n.inputSourceStates.find((r) => r.type === t && (e == null || r.inputSource.handedness === e)));
3160
+ }
3161
+ function ee(t) {
3162
+ const e = se(te);
3163
+ if (e == null)
3164
+ throw new Error("useXRInputSourceStateContext() can only be used inside the xr store config");
3165
+ if (t != null && e.type != t)
3166
+ throw new Error(`useXRInputSourceStateContext(${t}) can not be used inside a component for input type "${e.type}"`);
3167
+ return e;
3168
+ }
3169
+ const Q = _(({ space: t, children: e }, n) => {
3170
+ const r = C(null), i = typeof t == "string" ? wr(t) : t;
3171
+ k(n, () => r.current, []), Do(r, i);
3172
+ const s = Vn((o) => {
3173
+ o != null && (o.transformReady = !1, o.visible = !1), r.current = o;
3174
+ }, []);
3175
+ return m("group", { xrSpace: i, matrixAutoUpdate: !1, ref: s, children: i && m(Me.Provider, { value: i, children: e }) });
3176
+ });
3177
+ function wr(t) {
3178
+ switch (t) {
3179
+ case "grip-space":
3180
+ return ee().inputSource.gripSpace;
3181
+ case "target-ray-space":
3182
+ return ee().inputSource.targetRaySpace;
3183
+ case "wrist":
3184
+ case "thumb-metacarpal":
3185
+ case "thumb-phalanx-proximal":
3186
+ case "thumb-phalanx-distal":
3187
+ case "thumb-tip":
3188
+ case "index-finger-metacarpal":
3189
+ case "index-finger-phalanx-proximal":
3190
+ case "index-finger-phalanx-intermediate":
3191
+ case "index-finger-phalanx-distal":
3192
+ case "index-finger-tip":
3193
+ case "middle-finger-metacarpal":
3194
+ case "middle-finger-phalanx-proximal":
3195
+ case "middle-finger-phalanx-intermediate":
3196
+ case "middle-finger-phalanx-distal":
3197
+ case "middle-finger-tip":
3198
+ case "ring-finger-metacarpal":
3199
+ case "ring-finger-phalanx-proximal":
3200
+ case "ring-finger-phalanx-intermediate":
3201
+ case "ring-finger-phalanx-distal":
3202
+ case "ring-finger-tip":
3203
+ case "pinky-finger-metacarpal":
3204
+ case "pinky-finger-phalanx-proximal":
3205
+ case "pinky-finger-phalanx-intermediate":
3206
+ case "pinky-finger-phalanx-distal":
3207
+ case "pinky-finger-tip":
3208
+ return ee("hand").inputSource.hand.get(t);
3209
+ case "root":
3210
+ case "hips":
3211
+ case "spine-lower":
3212
+ case "spine-middle":
3213
+ case "spine-upper":
3214
+ case "chest":
3215
+ case "neck":
3216
+ case "head":
3217
+ case "left-shoulder":
3218
+ case "left-scapula":
3219
+ case "left-arm-upper":
3220
+ case "left-arm-lower":
3221
+ case "left-hand-wrist-twist":
3222
+ case "right-shoulder":
3223
+ case "right-scapula":
3224
+ case "right-arm-upper":
3225
+ case "right-arm-lower":
3226
+ case "right-hand-wrist-twist":
3227
+ case "left-hand-palm":
3228
+ case "left-hand-wrist":
3229
+ case "left-hand-thumb-metacarpal":
3230
+ case "left-hand-thumb-phalanx-proximal":
3231
+ case "left-hand-thumb-phalanx-distal":
3232
+ case "left-hand-thumb-tip":
3233
+ case "left-hand-index-metacarpal":
3234
+ case "left-hand-index-phalanx-proximal":
3235
+ case "left-hand-index-phalanx-intermediate":
3236
+ case "left-hand-index-phalanx-distal":
3237
+ case "left-hand-index-tip":
3238
+ case "left-hand-middle-metacarpal":
3239
+ case "left-hand-middle-phalanx-proximal":
3240
+ case "left-hand-middle-phalanx-intermediate":
3241
+ case "left-hand-middle-phalanx-distal":
3242
+ case "left-hand-middle-tip":
3243
+ case "left-hand-ring-metacarpal":
3244
+ case "left-hand-ring-phalanx-proximal":
3245
+ case "left-hand-ring-phalanx-intermediate":
3246
+ case "left-hand-ring-phalanx-distal":
3247
+ case "left-hand-ring-tip":
3248
+ case "left-hand-little-metacarpal":
3249
+ case "left-hand-little-phalanx-proximal":
3250
+ case "left-hand-little-phalanx-intermediate":
3251
+ case "left-hand-little-phalanx-distal":
3252
+ case "left-hand-little-tip":
3253
+ case "right-hand-palm":
3254
+ case "right-hand-wrist":
3255
+ case "right-hand-thumb-metacarpal":
3256
+ case "right-hand-thumb-phalanx-proximal":
3257
+ case "right-hand-thumb-phalanx-distal":
3258
+ case "right-hand-thumb-tip":
3259
+ case "right-hand-index-metacarpal":
3260
+ case "right-hand-index-phalanx-proximal":
3261
+ case "right-hand-index-phalanx-intermediate":
3262
+ case "right-hand-index-phalanx-distal":
3263
+ case "right-hand-index-tip":
3264
+ case "right-hand-middle-metacarpal":
3265
+ case "right-hand-middle-phalanx-proximal":
3266
+ case "right-hand-middle-phalanx-intermediate":
3267
+ case "right-hand-middle-phalanx-distal":
3268
+ case "right-hand-middle-tip":
3269
+ case "right-hand-ring-metacarpal":
3270
+ case "right-hand-ring-phalanx-proximal":
3271
+ case "right-hand-ring-phalanx-intermediate":
3272
+ case "right-hand-ring-phalanx-distal":
3273
+ case "right-hand-ring-tip":
3274
+ case "right-hand-little-metacarpal":
3275
+ case "right-hand-little-phalanx-proximal":
3276
+ case "right-hand-little-phalanx-intermediate":
3277
+ case "right-hand-little-phalanx-distal":
3278
+ case "right-hand-little-tip":
3279
+ case "left-upper-leg":
3280
+ case "left-lower-leg":
3281
+ case "left-foot-ankle-twist":
3282
+ case "left-foot-ankle":
3283
+ case "left-foot-subtalar":
3284
+ case "left-foot-transverse":
3285
+ case "left-foot-ball":
3286
+ case "right-upper-leg":
3287
+ case "right-lower-leg":
3288
+ case "right-foot-ankle-twist":
3289
+ case "right-foot-ankle":
3290
+ case "right-foot-subtalar":
3291
+ case "right-foot-transverse":
3292
+ case "right-foot-ball":
3293
+ return E((i) => i.body)?.get(t);
3294
+ }
3295
+ if (t == null) {
3296
+ const i = se(Me);
3297
+ if (i == null)
3298
+ throw new Error("XR objects must be placed inside the XROrigin");
3299
+ return i;
3300
+ }
3301
+ const [e, n] = be(void 0), r = E((i) => i.session);
3302
+ return O(() => {
3303
+ if (r == null)
3304
+ return;
3305
+ let i = !1;
3306
+ return r.requestReferenceSpace(t).then((s) => {
3307
+ i || n(s);
3308
+ }), () => void (i = !0);
3309
+ }, [r, t]), e;
3310
+ }
3311
+ function Wo(t) {
3312
+ const e = se(Me), n = E((r) => e ?? r.originReferenceSpace);
3313
+ return A(() => t == null || n == null ? void 0 : Vi(t, n), [t, n]);
3314
+ }
3315
+ function Do(t, e, n) {
3316
+ const r = Wo(e);
3317
+ X((i, s, o) => {
3318
+ t.current != null && (t.current.visible = t.current.transformReady = r?.(t.current.matrix, o) ?? !1);
3319
+ }, -100);
3320
+ }
3321
+ _(({ mesh: t, ...e }, n) => {
3322
+ const r = Ho(t);
3323
+ return m("mesh", { ref: n, geometry: r, ...e });
3324
+ });
3325
+ function Ho(t, e = !0) {
3326
+ const [n, r] = be(xn(t, void 0));
3327
+ return X(() => r((i) => xn(t, i))), O(() => {
3328
+ if (e)
3329
+ return () => n.dispose();
3330
+ }, [n]), n;
3331
+ }
3332
+ _(({ plane: t, ...e }, n) => {
3333
+ const r = Vo(t);
3334
+ return m("mesh", { ref: n, geometry: r, ...e });
3335
+ });
3336
+ function Vo(t, e = !0) {
3337
+ const [n, r] = be(Sn(t, void 0));
3338
+ return X(() => r((i) => Sn(t, i))), O(() => {
3339
+ if (e)
3340
+ return () => n.dispose();
3341
+ }, [n]), n;
3342
+ }
3343
+ _(({ children: t, disabled: e, ...n }, r) => {
3344
+ const i = xe((a) => a.gl.xr.getCamera()), s = C(null), o = E((a) => a.originReferenceSpace);
3345
+ return k(r, () => s.current, []), O(() => {
3346
+ const a = s.current;
3347
+ if (!(a == null || e))
3348
+ return a.add(i), () => void a.remove(i);
3349
+ }, [e, i]), m("group", { ref: s, ...n, children: m(Me.Provider, { value: o, children: t }) });
3350
+ });
3351
+ function jo(t, e, n) {
3352
+ const r = C(void 0);
3353
+ ko(e, n, Vn((i) => r.current = i, [])), X((i, s, o) => {
3354
+ t == null || o == null || r.current == null || t(o.getHitTestResults(r.current.source), r.current.getWorldMatrix);
3355
+ });
3356
+ }
3357
+ function ko(t, e, n) {
3358
+ const r = rt(), i = Qe(r, (s) => s.session);
3359
+ O(() => {
3360
+ if (i == null)
3361
+ return;
3362
+ let s, o = !1;
3363
+ const a = t instanceof XRSpace || typeof t == "string" ? t : t?.current;
3364
+ if (a != null)
3365
+ return eo(r, i, a, e).then((l) => {
3366
+ o || (s = l, n(l));
3367
+ }), () => {
3368
+ n(void 0), o = !0, s?.source.cancel();
3369
+ };
3370
+ }, [i, r, t, e, n]);
3371
+ }
3372
+ _(({ trackableType: t, onResults: e, space: n, ...r }, i) => {
3373
+ const s = C(null);
3374
+ return k(i, () => s.current), jo(e, n ?? s, t), m("group", { ...r, ref: s });
3375
+ });
3376
+ _((t, e) => {
3377
+ const n = E((s) => s.domOverlayRoot), { In: r, Out: i } = A(hi, []);
3378
+ return O(() => {
3379
+ if (n == null)
3380
+ return;
3381
+ const s = $r(n);
3382
+ return s.render(m(i, {})), () => s.unmount();
3383
+ }, [n, i]), m(r, { children: m("div", { ...t, ref: e }) });
3384
+ });
3385
+ _(function({ src: e, pixelWidth: n = 1024, pixelHeight: r = 1024, dpr: i = 1, renderPriority: s = 0, children: o, customRender: a, ...l }, u) {
3386
+ const [p, c] = be(!1), h = C(null), d = C(void 0), g = C(void 0);
3387
+ O(() => {
3388
+ c(!1);
3389
+ let I = !1;
3390
+ return Bs(e).then(() => !I && c(!0)), () => void (I = !0);
3391
+ }, [e]);
3392
+ const y = Ao("layers"), f = A(() => js(l.shape ?? "quad", {
3393
+ centralAngle: l.centralAngle,
3394
+ centralHorizontalAngle: l.centralHorizontalAngle,
3395
+ lowerVerticalAngle: l.lowerVerticalAngle,
3396
+ upperVerticalAngle: l.upperVerticalAngle
3397
+ }), [l.centralAngle, l.centralHorizontalAngle, l.lowerVerticalAngle, l.shape, l.upperVerticalAngle]), R = $o(n, r, i);
3398
+ return qo(R, h, [p, y]), k(u, () => h.current, [p, y]), p ? N(q, { children: [e == null && m(Uo, { customRender: a, store: R, renderPriority: s, renderTargetRef: d, layerEntryRef: y ? g : void 0, children: o }), y ? m(Bo, { renderTargetRef: d, layerEntryRef: g, pixelWidth: n, pixelHeight: r, dpr: i, ref: h, ...l, src: e, geometry: f }) : m(No, { renderTargetRef: d, ref: h, ...l, src: e, pixelWidth: n, pixelHeight: r, dpr: i, geometry: f })] }) : null;
3399
+ });
3400
+ const Bo = _(({ src: t, shape: e, colorFormat: n, depthFormat: r, layout: i, mipLevels: s, renderOrder: o = 0, blendTextureSourceAlpha: a, centralAngle: l, centralHorizontalAngle: u, chromaticAberrationCorrection: p, lowerVerticalAngle: c, quality: h, upperVerticalAngle: d, invertStereo: g, pixelWidth: y, pixelHeight: f, dpr: R, renderTargetRef: I, layerEntryRef: b, ...T }, D) => {
3401
+ const L = C(null), H = xe((J) => J.gl), P = rt(), M = {
3402
+ blendTextureSourceAlpha: a,
3403
+ centralAngle: l,
3404
+ centralHorizontalAngle: u,
3405
+ chromaticAberrationCorrection: p,
3406
+ lowerVerticalAngle: c,
3407
+ quality: h,
3408
+ upperVerticalAngle: d
3409
+ }, x = C(M);
3410
+ x.current = M;
3411
+ const G = C(o);
3412
+ G.current = o;
3413
+ const B = E((J) => J.originReferenceSpace);
3414
+ return O(() => {
3415
+ if (L.current == null || B == null)
3416
+ return;
3417
+ const J = t ?? (I.current = fr(y, f, R)), fe = zs(J, P.getState(), B, H.xr, L.current, {
3418
+ colorFormat: n,
3419
+ depthFormat: r,
3420
+ invertStereo: g,
3421
+ layout: i,
3422
+ mipLevels: s,
3423
+ shape: e
3424
+ }, x.current);
3425
+ if (fe == null)
3426
+ return;
3427
+ const it = b.current = {
3428
+ layer: fe,
3429
+ renderOrder: G.current,
3430
+ object3D: L.current
3431
+ };
3432
+ if (P.addLayerEntry(it), J instanceof HTMLVideoElement || J instanceof we)
3433
+ return () => {
3434
+ P.removeLayerEntry(it), fe.destroy();
3435
+ };
3436
+ const xr = ks(H, P, fe, J);
3437
+ return () => {
3438
+ P.removeLayerEntry(it), xr(), fe.destroy();
3439
+ };
3440
+ }, [
3441
+ B,
3442
+ n,
3443
+ r,
3444
+ g,
3445
+ b,
3446
+ i,
3447
+ s,
3448
+ f,
3449
+ y,
3450
+ R,
3451
+ I,
3452
+ H,
3453
+ e,
3454
+ t,
3455
+ P
3456
+ ]), b.current != null && (b.current.renderOrder = o), b.current != null && zt(b.current.layer, x.current), X(() => {
3457
+ b.current == null || L.current == null || Gs(P.getState(), b.current.layer, x.current.centralAngle, L.current);
3458
+ }), k(D, () => L.current, []), m("mesh", { ...T, renderOrder: -1 / 0, ref: L, children: m("meshBasicMaterial", { colorWrite: !1 }) });
3459
+ }), No = _(({ src: t, renderTargetRef: e, dpr: n, renderOrder: r, pixelWidth: i, pixelHeight: s, ...o }, a) => {
3460
+ const l = C(null);
3461
+ return O(() => {
3462
+ if (l.current == null)
3463
+ return;
3464
+ const u = t ?? (e.current = fr(i, s, n)), p = Ns(u);
3465
+ return l.current.map = p, l.current.needsUpdate = !0, () => {
3466
+ if (u instanceof we) {
3467
+ u.dispose();
3468
+ return;
3469
+ }
3470
+ p.dispose();
3471
+ };
3472
+ }, [t, i, s, n, e]), m("mesh", { ref: a, ...o, children: m("meshBasicMaterial", { ref: l, toneMapped: !1 }) });
3473
+ });
3474
+ function qo(t, e, n) {
3475
+ O(() => {
3476
+ const { current: r } = e;
3477
+ if (r == null)
3478
+ return;
3479
+ let i;
3480
+ const s = (a, l) => {
3481
+ if (a.camera === l?.camera && a.scene === l.scene)
3482
+ return;
3483
+ i?.();
3484
+ const { destroy: u, update: p } = bs(r, () => a.camera, a.scene), c = Gr(p);
3485
+ i = () => {
3486
+ u(), c();
3487
+ };
3488
+ };
3489
+ s(t.getState());
3490
+ const o = t.subscribe(s);
3491
+ return () => {
3492
+ o(), i?.();
3493
+ };
3494
+ }, [t, e, ...n]);
3495
+ }
3496
+ const Go = [
3497
+ "set",
3498
+ "get",
3499
+ "setSize",
3500
+ "setFrameloop",
3501
+ "setDpr",
3502
+ "events",
3503
+ "invalidate",
3504
+ "advance",
3505
+ "size",
3506
+ "viewport"
3507
+ ];
3508
+ function $o(t, e, n) {
3509
+ const r = ae(), i = A(() => {
3510
+ let s = r.getState();
3511
+ const o = new Vr(50, 1, 0.1, 1e3);
3512
+ o.position.set(0, 0, 5);
3513
+ const a = new W();
3514
+ let l = {
3515
+ events: { enabled: !1, priority: 0 },
3516
+ size: { width: 1, height: 1, left: 0, top: 0 },
3517
+ camera: o,
3518
+ scene: new jr(),
3519
+ raycaster: new $e(),
3520
+ pointer: a,
3521
+ mouse: a,
3522
+ previousRoot: r
3523
+ };
3524
+ const u = qn((p, c) => {
3525
+ const h = () => {
3526
+ const g = {};
3527
+ for (const y in s)
3528
+ Go.includes(y) || (g[y] = s[y]);
3529
+ return Object.assign(g, l, {
3530
+ events: { ...s.events, ...l.events },
3531
+ viewport: Object.assign({}, s.viewport, s.viewport.getCurrentViewport(o, new w(), l.size))
3532
+ });
3533
+ }, d = () => p(h());
3534
+ return {
3535
+ ...s,
3536
+ // Set and get refer to this root-state
3537
+ set(g) {
3538
+ typeof g == "function" && (g = g(c())), Object.assign(l, g), d();
3539
+ },
3540
+ setPreviousState(g) {
3541
+ s = g, d();
3542
+ },
3543
+ get: c,
3544
+ setEvents() {
3545
+ },
3546
+ ...h()
3547
+ };
3548
+ });
3549
+ return Object.assign(u, {
3550
+ setState(p) {
3551
+ u.getState().set(p);
3552
+ }
3553
+ });
3554
+ }, [r]);
3555
+ return O(() => r.subscribe(i.getState().setPreviousState), [r, i]), O(() => {
3556
+ const s = {
3557
+ factor: 1,
3558
+ distance: 0,
3559
+ dpr: n,
3560
+ initialDpr: n,
3561
+ left: 0,
3562
+ top: 0,
3563
+ getCurrentViewport: () => s,
3564
+ width: t,
3565
+ height: e,
3566
+ aspect: t / e
3567
+ };
3568
+ i.setState({
3569
+ size: { width: t, height: e, top: 0, left: 0 },
3570
+ viewport: s
3571
+ });
3572
+ }, [t, e, n, i, r]), i;
3573
+ }
3574
+ const ve = new Hn();
3575
+ function En(t) {
3576
+ return this.getViewport(ve), t.x = ve.z - ve.x, t.y = ve.w - ve.y, t;
3577
+ }
3578
+ const Ln = new Hn();
3579
+ function Uo({ renderPriority: t, children: e, layerEntryRef: n, renderTargetRef: r, store: i, customRender: s }) {
3580
+ O(() => {
3581
+ const h = (d, g) => {
3582
+ const { size: y, camera: f } = d;
3583
+ f instanceof kr ? (f.left = y.width / -2, f.right = y.width / 2, f.top = y.height / 2, f.bottom = y.height / -2) : f.aspect = y.width / y.height, (y !== g?.size || f !== g.camera) && (f.updateProjectionMatrix(), f.updateMatrixWorld());
3584
+ };
3585
+ return h(i.getState()), i.subscribe(h);
3586
+ }, [i]);
3587
+ let o, a, l, u, p, c;
3588
+ return X((h, d, g) => {
3589
+ if (r.current == null || n != null && (n.current == null || g == null))
3590
+ return;
3591
+ const y = i.getState(), { gl: f, scene: R, camera: I } = y;
3592
+ o = f.autoClear, a = f.xr.enabled, l = f.xr.isPresenting, u = f.getRenderTarget(), c = f.getSize, p = f.getDrawingBufferSize, f.getViewport(Ln), f.autoClear = !0, f.xr.enabled = !1, f.xr.isPresenting = !1;
3593
+ const b = r.current;
3594
+ f.setViewport(0, 0, b.width, b.height), f.getSize = En, f.getDrawingBufferSize = En, Vs(f, b, n?.current, g), s != null ? s(b, y, d, g) : f.render(R, I), f.setRenderTarget(u), f.setViewport(Ln), f.autoClear = o, f.xr.enabled = a, f.xr.isPresenting = l, f.getSize = c, f.getDrawingBufferSize = p;
3595
+ }, t), m(q, { children: jn.createPortal(m(kn.Provider, { value: i, children: e }), i, null) });
3596
+ }
3597
+ const br = _(({ store: t, mode: e, onError: n, children: r, ...i }, s) => {
3598
+ const o = Qe(t, (l) => l.session), a = Io(e, n);
3599
+ return m("button", { ref: s, ...i, onClick: () => o != null ? o.end() : t.enterXR(e).catch(n), children: typeof r == "function" ? r(a ? o != null ? "entered" : "exited" : "unsupported") : r });
3600
+ });
3601
+ _((t, e) => m(br, { ref: e, mode: "immersive-ar", ...t }));
3602
+ _((t, e) => m(br, { ref: e, mode: "immersive-vr", ...t }));
3603
+ const Qo = {
3604
+ onBlur: "pointerleave",
3605
+ onHover: "pointerenter",
3606
+ onMove: "pointermove",
3607
+ onSelect: {
3608
+ type: "click",
3609
+ filter: (t) => t.pointerType === "ray"
3610
+ },
3611
+ onSelectEnd: {
3612
+ type: "pointerup",
3613
+ filter: (t) => t.pointerType === "ray"
3614
+ },
3615
+ onSelectStart: {
3616
+ type: "pointerdown",
3617
+ filter: (t) => t.pointerType === "ray"
3618
+ },
3619
+ onSqueeze: {
3620
+ type: "click",
3621
+ filter: (t) => t.pointerType === "grab"
3622
+ },
3623
+ onSqueezeEnd: {
3624
+ type: "pointerup",
3625
+ filter: (t) => t.pointerType === "grab"
3626
+ },
3627
+ onSqueezeStart: {
3628
+ type: "pointerdown",
3629
+ filter: (t) => t.pointerType === "grab"
3630
+ }
3631
+ };
3632
+ function K(t, e, n) {
3633
+ const r = C(n);
3634
+ r.current = n, O(() => {
3635
+ const { current: i } = t;
3636
+ if (i == null)
3637
+ return;
3638
+ const s = Qo[e], o = typeof s == "string" ? (l) => r.current?.({ intersection: l, intersections: [l], target: l.pointerState }) : (l) => {
3639
+ l instanceof F && !s.filter(l) || r.current?.({ intersection: l, intersections: [l], target: l.pointerState });
3640
+ }, a = typeof s == "string" ? s : s.type;
3641
+ return i.addEventListener(a, o), () => i.removeEventListener(a, o);
3642
+ }, [t, e]);
3643
+ }
3644
+ const Yo = _(({ onHover: t, onBlur: e, onSelectStart: n, onSelectEnd: r, onSelect: i, onSqueezeStart: s, onSqueezeEnd: o, onSqueeze: a, onMove: l, children: u }, p) => {
3645
+ const c = C(null);
3646
+ return k(p, () => c.current), K(c, "onHover", t), K(c, "onBlur", e), K(c, "onSelectStart", n), K(c, "onSelectEnd", r), K(c, "onSelect", i), K(c, "onSqueezeStart", s), K(c, "onSqueezeEnd", o), K(c, "onSqueeze", a), K(c, "onMove", l), m("group", { ref: c, children: u });
3647
+ });
3648
+ _(function({ onSelectStart: e, onSelectEnd: n, children: r, ...i }, s) {
3649
+ const o = C(void 0), a = C(null), l = A(() => new j(), []);
3650
+ return k(s, () => a.current), X(() => {
3651
+ const u = o.current, p = a.current;
3652
+ !p || !u || (p.applyMatrix4(l), u.updateWorldMatrix(!0, !1), p.applyMatrix4(u.matrixWorld), p.updateMatrixWorld(), l.copy(u.matrixWorld).invert());
3653
+ }), m(Yo, { ref: a, onSelectStart: (u) => {
3654
+ Ii(u.target) && (u.target.type === "controller" || u.target.type === "hand") && u.target.object != null && (o.current = u.target.object, u.target.object.updateWorldMatrix(!0, !1), l.copy(u.target.object.matrixWorld).invert(), e?.(u));
3655
+ }, onSelectEnd: (u) => {
3656
+ u.target.controller === o.current && (o.current = void 0), n?.(u);
3657
+ }, ...i, children: r });
3658
+ });
3659
+ export {
3660
+ ra as $,
3661
+ Po as A,
3662
+ Mo as B,
3663
+ mr as C,
3664
+ vo as D,
3665
+ Ro as E,
3666
+ yr as F,
3667
+ Di as G,
3668
+ De as H,
3669
+ Hi as I,
3670
+ sa as J,
3671
+ oa as K,
3672
+ rt as L,
3673
+ E as M,
3674
+ jo as N,
3675
+ eo as O,
3676
+ go as P,
3677
+ Bo as Q,
3678
+ zo as R,
3679
+ No as S,
3680
+ yo as T,
3681
+ Go as U,
3682
+ $o as V,
3683
+ br as W,
3684
+ Q as X,
3685
+ K as Y,
3686
+ Yo as Z,
3687
+ We as _,
3688
+ Wo as a,
3689
+ Do as b,
3690
+ ao as c,
3691
+ uo as d,
3692
+ co as e,
3693
+ Ho as f,
3694
+ Vo as g,
3695
+ fo as h,
3696
+ xs as i,
3697
+ ho as j,
3698
+ po as k,
3699
+ mo as l,
3700
+ tt as m,
3701
+ Ht as n,
3702
+ Ii as o,
3703
+ Co as p,
3704
+ Io as q,
3705
+ Ao as r,
3706
+ aa as s,
3707
+ ee as t,
3708
+ wr as u,
3709
+ wo as v,
3710
+ Ie as w,
3711
+ bo as x,
3712
+ xo as y,
3713
+ So as z
3714
+ };