@uptimizr/dashboard 0.1.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.
- package/LICENSE +201 -0
- package/README.md +76 -0
- package/out/404.html +1 -0
- package/out/__next.__PAGE__.txt +9 -0
- package/out/__next._full.txt +20 -0
- package/out/__next._head.txt +6 -0
- package/out/__next._index.txt +5 -0
- package/out/__next._tree.txt +4 -0
- package/out/_next/static/93W3szqylNKDg-afLRmVW/_buildManifest.js +11 -0
- package/out/_next/static/93W3szqylNKDg-afLRmVW/_clientMiddlewareManifest.js +1 -0
- package/out/_next/static/93W3szqylNKDg-afLRmVW/_ssgManifest.js +1 -0
- package/out/_next/static/chunks/0-2y-_oomza2l.js +87 -0
- package/out/_next/static/chunks/00k_j_r7bv_eb.js +266 -0
- package/out/_next/static/chunks/00zdau6mcqeae.js +1 -0
- package/out/_next/static/chunks/023axeoslq39i.js +1 -0
- package/out/_next/static/chunks/068j6934u8j16.js +1 -0
- package/out/_next/static/chunks/0_rf76jneiwal.js +176 -0
- package/out/_next/static/chunks/0aznt7717miff.js +1 -0
- package/out/_next/static/chunks/0cu-q5q3a7uf3.js +1 -0
- package/out/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
- package/out/_next/static/chunks/0dm32-jq30tg8.js +1 -0
- package/out/_next/static/chunks/0dn0yx0rn6mpf.js +1 -0
- package/out/_next/static/chunks/0flc7nppbmsl1.js +3 -0
- package/out/_next/static/chunks/0fskcfh9vbhtv.js +1 -0
- package/out/_next/static/chunks/0gv7mblzv3dl3.js +87 -0
- package/out/_next/static/chunks/0impkpmxx3ttp.js +1 -0
- package/out/_next/static/chunks/0jmn7u31w95ly.js +91 -0
- package/out/_next/static/chunks/0n8n481szj90g.js +1 -0
- package/out/_next/static/chunks/0o6ayai0s01js.js +1 -0
- package/out/_next/static/chunks/0rys92_73hdb0.js +22 -0
- package/out/_next/static/chunks/0tl_moiyi2txt.js +1 -0
- package/out/_next/static/chunks/0tx1j_ghpz7rc.css +3 -0
- package/out/_next/static/chunks/0ufbyo1x3qkmo.js +1 -0
- package/out/_next/static/chunks/0v82oqyoy9zol.js +1 -0
- package/out/_next/static/chunks/0wrm9jr-9bw0e.js +1893 -0
- package/out/_next/static/chunks/0wwcfw8i3j_zx.js +1 -0
- package/out/_next/static/chunks/0ys9-ozuluawt.js +1 -0
- package/out/_next/static/chunks/1-61zh4waha61.js +1 -0
- package/out/_next/static/chunks/10r_824wzt8hj.js +1 -0
- package/out/_next/static/chunks/112hws17nz665.js +7 -0
- package/out/_next/static/chunks/123xxske5c9na.js +1 -0
- package/out/_next/static/chunks/13isnf0--pmx1.js +1 -0
- package/out/_next/static/chunks/157d9euci08yu.js +1 -0
- package/out/_next/static/chunks/15s7425ffrec9.js +3 -0
- package/out/_next/static/chunks/163fa70v4mgxj.js +1 -0
- package/out/_next/static/chunks/17q0c2h5ui10r.js +4 -0
- package/out/_next/static/chunks/18u58lorfahxi.js +4 -0
- package/out/_next/static/chunks/1_aahautsz2v_.js +1 -0
- package/out/_next/static/chunks/1a9l89j7e6mqu.js +23 -0
- package/out/_next/static/chunks/1dsy2ngmfflis.js +123 -0
- package/out/_next/static/chunks/1flb8adpj6_2o.js +62 -0
- package/out/_next/static/chunks/1lsg-22yob8dx.js +1 -0
- package/out/_next/static/chunks/1nj82er7msdto.js +2 -0
- package/out/_next/static/chunks/1o1d0p-v1z8ty.js +1 -0
- package/out/_next/static/chunks/1pdep2_c530sg.js +1 -0
- package/out/_next/static/chunks/1thjncpj7u6pq.js +1 -0
- package/out/_next/static/chunks/1vdjn0pkoyypn.js +1 -0
- package/out/_next/static/chunks/1yehxf-fmeicg.js +1 -0
- package/out/_next/static/chunks/1zvc1tv--w8nn.js +1 -0
- package/out/_next/static/chunks/1zx2q-r32thv1.js +4 -0
- package/out/_next/static/chunks/2-sjjedfr0kfq.js +1 -0
- package/out/_next/static/chunks/21o42k82w4llc.js +1 -0
- package/out/_next/static/chunks/25b9x-li-tvk2.js +1 -0
- package/out/_next/static/chunks/2712627rfsmwn.js +1 -0
- package/out/_next/static/chunks/296w2ke-v5tbm.js +9 -0
- package/out/_next/static/chunks/29tfeb6amdkjb.js +23 -0
- package/out/_next/static/chunks/2a3spdq-m8drh.js +3 -0
- package/out/_next/static/chunks/2aelw3far6rii.js +1 -0
- package/out/_next/static/chunks/2aor7m-wbis85.js +1 -0
- package/out/_next/static/chunks/2cbmf9m7lqv6k.js +4 -0
- package/out/_next/static/chunks/2d09v5u7dfq0q.js +1 -0
- package/out/_next/static/chunks/2feca0xcipcyt.js +850 -0
- package/out/_next/static/chunks/2fh-_9b6tqhvb.js +1 -0
- package/out/_next/static/chunks/2g5gecypj0rqe.js +1 -0
- package/out/_next/static/chunks/2kazjq29jeamx.js +1109 -0
- package/out/_next/static/chunks/2p2vv6cc9i-3q.js +255 -0
- package/out/_next/static/chunks/2szdcpl41-kzv.js +1 -0
- package/out/_next/static/chunks/2tws5udjdcmh3.js +1 -0
- package/out/_next/static/chunks/2u6shh3oeycm-.js +1 -0
- package/out/_next/static/chunks/2unhhuv0arlcv.js +1 -0
- package/out/_next/static/chunks/2xwy0-qfho1iz.js +91 -0
- package/out/_next/static/chunks/2ycvtdd68gub7.js +1 -0
- package/out/_next/static/chunks/2yiy_l8bwiw2_.js +3 -0
- package/out/_next/static/chunks/2yph6f7khgqii.js +1 -0
- package/out/_next/static/chunks/3-shckrcpvbxu.js +1681 -0
- package/out/_next/static/chunks/30fq_t9e2_fv-.js +1 -0
- package/out/_next/static/chunks/30yzu213bqtq0.js +5 -0
- package/out/_next/static/chunks/310uz81hnnzsu.js +1 -0
- package/out/_next/static/chunks/3218lp8l0a5g_.js +1 -0
- package/out/_next/static/chunks/35h5n42wxwgzk.js +123 -0
- package/out/_next/static/chunks/37vzwr3ciejf1.js +1 -0
- package/out/_next/static/chunks/38fhw7fatsyvd.js +3 -0
- package/out/_next/static/chunks/3be6s4_kn9q-o.js +1 -0
- package/out/_next/static/chunks/3i3gbhccmhu7j.js +210 -0
- package/out/_next/static/chunks/3l1dr_qm_x5kp.js +1 -0
- package/out/_next/static/chunks/3mqy-84_ul3t2.js +1 -0
- package/out/_next/static/chunks/3nz-dh9d7cehk.js +1 -0
- package/out/_next/static/chunks/3pufs8g4ui943.js +1 -0
- package/out/_next/static/chunks/3sjq_xoi4rbyg.js +31 -0
- package/out/_next/static/chunks/3t06schbtqonl.js +1 -0
- package/out/_next/static/chunks/3v3-7fio3nw_t.js +1 -0
- package/out/_next/static/chunks/3v5ha25nxo43j.js +1 -0
- package/out/_next/static/chunks/3yfrsm8lfi6ls.js +22 -0
- package/out/_next/static/chunks/3zskk1hxu3-_o.js +1 -0
- package/out/_next/static/chunks/turbopack-2ropzf0axp1x9.js +1 -0
- package/out/_next/static/media/0c89a48fa5027cee-s.p.2cyn07wtgehh0.woff2 +0 -0
- package/out/_next/static/media/13bf9871fe164e7f-s.2f7nqdagzwx2-.woff2 +0 -0
- package/out/_next/static/media/28868e710e86be81-s.2eksvhm1z0jwa.woff2 +0 -0
- package/out/_next/static/media/32687112bd2dd8db-s.1gepa_7fcx9fm.woff2 +0 -0
- package/out/_next/static/media/3fe682a82f50d426-s.0vfdmo25voy_0.woff2 +0 -0
- package/out/_next/static/media/70bc3e132a0a741e-s.p.3t6q91iet4nsy.woff2 +0 -0
- package/out/_next/static/media/71b036adf157cdcf-s.0bp8oijd_gu96.woff2 +0 -0
- package/out/_next/static/media/89b21bb081cb7469-s.1fby2rem9ngyr.woff2 +0 -0
- package/out/_next/static/media/cc545e633e20c56d-s.176arc174-8zp.woff2 +0 -0
- package/out/_next/static/media/icon.08h29dad3pcxg.svg +4 -0
- package/out/_not-found/__next._full.txt +16 -0
- package/out/_not-found/__next._head.txt +6 -0
- package/out/_not-found/__next._index.txt +5 -0
- package/out/_not-found/__next._not-found.__PAGE__.txt +5 -0
- package/out/_not-found/__next._not-found.txt +5 -0
- package/out/_not-found/__next._tree.txt +2 -0
- package/out/_not-found.html +1 -0
- package/out/_not-found.txt +16 -0
- package/out/api/projects +1 -0
- package/out/icon.svg +4 -0
- package/out/index.html +1 -0
- package/out/index.txt +20 -0
- package/out/logo.svg +46 -0
- package/package.json +67 -0
- package/server/standalone.mjs +182 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,4357,e=>{"use strict";var r=e.i(12423);let t="helperFunctions",a=`const PI: f32=3.1415926535897932384626433832795;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08;
|
|
2
|
+
const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3f=vec3f(0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}
|
|
3
|
+
fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}
|
|
4
|
+
fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));}
|
|
5
|
+
fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
|
|
6
|
+
fn maxEps(x: f32)->f32 {return max(x,Epsilon);}
|
|
7
|
+
fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}
|
|
8
|
+
fn absEps(x: f32)->f32 {return abs(x)+Epsilon;}
|
|
9
|
+
fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(
|
|
10
|
+
vec3(i0.x,i1.x,i2.x),
|
|
11
|
+
vec3(i0.y,i1.y,i2.y),
|
|
12
|
+
vec3(i0.z,i1.z,i2.z)
|
|
13
|
+
);return outMatrix;}
|
|
14
|
+
fn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,
|
|
15
|
+
b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,
|
|
16
|
+
b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}
|
|
17
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
18
|
+
fn toLinearSpaceExact(color: vec3f)->vec3f
|
|
19
|
+
{let nearZeroSection: vec3f=0.0773993808*color;let remainingSection: vec3f=pow(0.947867299*(color+vec3f(0.055)),vec3f(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.04045)));}
|
|
20
|
+
fn toGammaSpaceExact(color: vec3f)->vec3f
|
|
21
|
+
{let nearZeroSection: vec3f=12.92*color;let remainingSection: vec3f=1.055*pow(color,vec3f(0.41666))-vec3f(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.0031308)));}
|
|
22
|
+
#endif
|
|
23
|
+
fn toLinearSpace(color: f32)->f32
|
|
24
|
+
{
|
|
25
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
26
|
+
var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);
|
|
27
|
+
#else
|
|
28
|
+
return pow(color,LinearEncodePowerApprox);
|
|
29
|
+
#endif
|
|
30
|
+
}
|
|
31
|
+
fn toLinearSpaceVec3(color: vec3f)->vec3f
|
|
32
|
+
{
|
|
33
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
34
|
+
return toLinearSpaceExact(color);
|
|
35
|
+
#else
|
|
36
|
+
return pow(color,vec3f(LinearEncodePowerApprox));
|
|
37
|
+
#endif
|
|
38
|
+
}
|
|
39
|
+
fn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>
|
|
40
|
+
{
|
|
41
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
42
|
+
return vec4f(toLinearSpaceExact(color.rgb),color.a);
|
|
43
|
+
#else
|
|
44
|
+
return vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
fn toGammaSpace(color: vec4<f32>)->vec4<f32>
|
|
48
|
+
{
|
|
49
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
50
|
+
return vec4<f32>(toGammaSpaceExact(color.rgb),color.a);
|
|
51
|
+
#else
|
|
52
|
+
return vec4<f32>(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a);
|
|
53
|
+
#endif
|
|
54
|
+
}
|
|
55
|
+
fn toGammaSpaceVec3(color: vec3f)->vec3f
|
|
56
|
+
{
|
|
57
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
58
|
+
return toGammaSpaceExact(color);
|
|
59
|
+
#else
|
|
60
|
+
return pow(color,vec3f(GammaEncodePowerApprox));
|
|
61
|
+
#endif
|
|
62
|
+
}
|
|
63
|
+
fn squareVec3(value: vec3f)->vec3f
|
|
64
|
+
{return value*value;}
|
|
65
|
+
fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}
|
|
66
|
+
fn double_refract(I: vec3f,N: vec3f,eta: f32)->vec3f {let Tfront: vec3f=refract(I,N,1.0/eta);let Nback: vec3f=normalize(reflect(N,Tfront));return refract(Tfront,-Nback,eta);}
|
|
67
|
+
fn getLuminanceUnclamped(color: vec3f)->f32
|
|
68
|
+
{return dot(color,LuminanceEncodeApprox);}
|
|
69
|
+
fn getLuminance(color: vec3f)->f32
|
|
70
|
+
{return saturate(getLuminanceUnclamped(color));}
|
|
71
|
+
fn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}
|
|
72
|
+
fn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}
|
|
73
|
+
const rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3f)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3f =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(saturateVec3(rgb),D);}
|
|
74
|
+
fn fromRGBD(rgbd: vec4<f32>)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}
|
|
75
|
+
fn parallaxCorrectNormal(vertexPos: vec3f,origVec: vec3f,cubeSize: vec3f,cubePos: vec3f)->vec3f {let invOrigVec: vec3f=vec3f(1.)/origVec;let halfSize: vec3f=cubeSize*0.5;let intersecAtMaxPlane: vec3f=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3f=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3f=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3f=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
|
|
76
|
+
fn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*TWO_PI-PI;var latitude : f32=HALF_PI-uv.y*PI;var direction : vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
|
77
|
+
fn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));}
|
|
78
|
+
fn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));}
|
|
79
|
+
fn singleScatterToMultiScatterAlbedo(rho_ss: vec3f)->vec3f {let s: vec3f=sqrt(max(vec3f(1.0)-rho_ss,vec3f(0.0)));return (vec3f(1.0)-s)*(vec3f(1.0)-vec3f(0.139)*s)/(vec3f(1.0)+vec3f(1.17)*s);}
|
|
80
|
+
fn multiScatterToSingleScatterAlbedo(rho_ms: vec3f)->vec3f {let s: vec3f=4.09712f+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return 1.0f-s*s;}
|
|
81
|
+
fn multiScatterToSingleScatterAlbedoWithAniso(rho_ms: vec3f,aniso: f32)->vec3f {let s: vec3f=4.09712+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return (vec3f(1.0f)-s*s)/maxEpsVec3(vec3f(1.0f)-vec3f(aniso)*s*s);}
|
|
82
|
+
fn min3(v: vec3f)->f32 {return min(v.x,min(v.y,v.z));}
|
|
83
|
+
fn max3(v: vec3f)->f32 {return max(v.x,max(v.y,v.z));}
|
|
84
|
+
fn uint2float(i: u32)->f32 {return bitcast<f32>(0x3F800000u | (i>>9u))-1.0;}
|
|
85
|
+
fn plasticSequence(rstate: u32)->vec2f {return vec2f(uint2float(rstate*3242174889u),
|
|
86
|
+
uint2float(rstate*2447445414u));}
|
|
87
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=a),e.s(["helperFunctionsWGSL",0,{name:t,shader:a}])},8617,e=>{"use strict";var r=e.i(12423),t=e.i(4357);let a="rgbdDecodePixelShader",c=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
|
88
|
+
#include<helperFunctions>
|
|
89
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
90
|
+
@fragment
|
|
91
|
+
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(fromRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV)),1.0);}`;for(let e of(r.ShaderStore.ShadersStoreWGSL[a]||(r.ShaderStore.ShadersStoreWGSL[a]=c),[t.helperFunctionsWGSL]))r.ShaderStore.IncludesShadersStoreWGSL[e.name]||(r.ShaderStore.IncludesShadersStoreWGSL[e.name]=e.shader);e.s(["rgbdDecodePixelShaderWGSL",0,{name:a,shader:c}])}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,94080,e=>{"use strict";var t,r,i,n,s,a,l,u,h,o,_,c=e.i(71379);let E=!1;E=!0,c.ThinEngine.prototype.setAlphaMode=function(e,t=!1,r=0){if(this._alphaMode[r]===e){if(!t){let t=0===e;this.depthCullingState.depthMask!==t&&(this.depthCullingState.depthMask=t)}return}let i=0===e;this._alphaState.setAlphaBlend(!i,r),this._alphaState.setAlphaMode(e,r),t||(this.depthCullingState.depthMask=i),this._alphaMode[r]=e};var T=e.i(84201),f=e.i(13379),p=e.i(68179);let d=!1;function g(e,t,r,i){let n,s=1;1===i?n=new Float32Array(t*r*4):2===i?(n=new Uint16Array(t*r*4),s=15360):n=7===i?new Uint32Array(t*r*4):new Uint8Array(t*r*4);for(let i=0;i<t;i++)for(let a=0;a<r;a++){let r=(a*t+i)*3,l=(a*t+i)*4;n[l+0]=e[r+0],n[l+1]=e[r+1],n[l+2]=e[r+2],n[l+3]=s}return n}function R(e){return function(t,r,i,n,s,a,l,u,h=null,o=0){let _=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,c=new T.InternalTexture(this,e?10:11);c.baseWidth=r,c.baseHeight=i,c.baseDepth=n,c.width=r,c.height=i,c.depth=n,c.format=s,c.type=o,c.generateMipMaps=a,c.samplingMode=u,e?c.is3D=!0:c.is2DArray=!0,this._doNotHandleContextLost||(c._bufferView=t),e?this.updateRawTexture3D(c,t,s,l,h,o):this.updateRawTexture2DArray(c,t,s,l,h,o),this._bindTextureDirectly(_,c,!0);let E=this._getSamplingParameters(u,a);return this._gl.texParameteri(_,this._gl.TEXTURE_MAG_FILTER,E.mag),this._gl.texParameteri(_,this._gl.TEXTURE_MIN_FILTER,E.min),a&&this._gl.generateMipmap(_),this._bindTextureDirectly(_,null),this._internalTexturesCache.push(c),c}}function m(e){return function(t,r,i,n,s=null,a=0){let l=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,u=this._getWebGLTextureType(a),h=this._getInternalFormat(i),o=this._getRGBABufferInternalSizedFormat(a,i);this._bindTextureDirectly(l,t,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(t._bufferView=r,t.format=i,t.invertY=n,t._compression=s),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),s&&r?this._gl.compressedTexImage3D(l,0,this.getCaps().s3tc[s],t.width,t.height,t.depth,0,r):this._gl.texImage3D(l,0,o,t.width,t.height,t.depth,0,h,u,r),t.generateMipMaps&&this._gl.generateMipmap(l),this._bindTextureDirectly(l,null),t.isReady=!0}}d=!0,c.ThinEngine.prototype.updateRawTexture=function(e,t,r,i,n=null,s=0,a=!1){if(!e)return;let l=this._getRGBABufferInternalSizedFormat(s,r,a),u=this._getInternalFormat(r),h=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===i||!!i),this._doNotHandleContextLost||(e._bufferView=t,e.format=r,e.type=s,e.invertY=i,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,l,e.width,e.height,0,u,h,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0},c.ThinEngine.prototype.createRawTexture=function(e,t,r,i,n,s,a,l=null,u=0,h=0,o=!1){let _=new T.InternalTexture(this,3);_.baseWidth=t,_.baseHeight=r,_.width=t,_.height=r,_.format=i,_.generateMipMaps=n,_.samplingMode=a,_.invertY=s,_._compression=l,_.type=u,_._useSRGBBuffer=this._getUseSRGBBuffer(o,!n),this._doNotHandleContextLost||(_._bufferView=e),this.updateRawTexture(_,e,i,s,l,u,_._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,_,!0);let c=this._getSamplingParameters(a,n);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,c.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,c.min),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(_),_},c.ThinEngine.prototype.createRawCubeTexture=function(e,t,r,i,n,s,a,l=null){let u=this._gl,h=new T.InternalTexture(this,8);h.isCube=!0,h.format=r,h.type=i,this._doNotHandleContextLost||(h._bufferViewArray=e);let o=this._getWebGLTextureType(i),_=this._getInternalFormat(r);if(_===u.RGB&&(_=u.RGBA),o!==u.FLOAT||this._caps.textureFloatLinearFiltering?o!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?o!==u.FLOAT||this._caps.textureFloatRender?o!==u.HALF_FLOAT||this._caps.colorBufferFloat||(n=!1,f.Logger.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(n=!1,f.Logger.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(n=!1,a=1,f.Logger.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(n=!1,a=1,f.Logger.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")),h.width=t,h.height=t,h.invertY=s,h._compression=l,!this.needPOTTextures||(0,p.IsExponentOfTwo)(h.width)&&(0,p.IsExponentOfTwo)(h.height)||(n=!1),e)this.updateRawCubeTexture(h,e,r,i,s,l);else{let e=this._getRGBABufferInternalSizedFormat(i);this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,h,!0);for(let t=0;t<6;t++)l?u.compressedTexImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,this.getCaps().s3tc[l],h.width,h.height,0,void 0):u.texImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,e,h.width,h.height,0,_,o,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,h,!0),e&&n&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);let c=this._getSamplingParameters(a,n);return u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,c.mag),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,c.min),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,null),h.generateMipMaps=n,h.samplingMode=a,h.isReady=!0,h},c.ThinEngine.prototype.updateRawCubeTexture=function(e,t,r,i,n,s=null,a=0){e._bufferViewArray=t,e.format=r,e.type=i,e.invertY=n,e._compression=s;let l=this._gl,u=this._getWebGLTextureType(i),h=this._getInternalFormat(r),o=this._getRGBABufferInternalSizedFormat(i),_=!1;h===l.RGB&&(h=l.RGBA,_=!0),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===n||!!n),e.width%4!=0&&l.pixelStorei(l.UNPACK_ALIGNMENT,1);for(let r=0;r<6;r++){let n=t[r];s?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+r,a,this.getCaps().s3tc[s],e.width,e.height,0,n):(_&&(n=g(n,e.width,e.height,i)),l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+r,a,o,e.width,e.height,0,h,u,n))}(!this.needPOTTextures||(0,p.IsExponentOfTwo)(e.width)&&(0,p.IsExponentOfTwo)(e.height))&&e.generateMipMaps&&0===a&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),e.isReady=!0},c.ThinEngine.prototype.createRawCubeTextureFromUrl=function(e,t,r,i,n,s,a,l,u=null,h=null,o=3,_=!1){let c=this._gl,E=this.createRawCubeTexture(null,r,i,n,!s,_,o,null);t?.addPendingData(E),E.url=e,E.isReady=!1,this._internalTexturesCache.push(E);let T=(e,r)=>{t?.removePendingData(E),h&&h(e?e.status+" "+e.statusText:"Failed to parse texture data",r)},f=async e=>{if(!E._hardwareTexture)return;let r=a(e);if(!r)return;let s=r instanceof Promise?await r:r,h=E.width;if(l){let e=this._getWebGLTextureType(n),t=this._getInternalFormat(i),r=this._getRGBABufferInternalSizedFormat(n),a=!1;t===c.RGB&&(t=c.RGBA,a=!0),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,E,!0),this._unpackFlipY(!1);let u=l(s);for(let i=0;i<u.length;i++){let s=h>>i;for(let l=0;l<6;l++){let h=u[i][l];a&&(h=g(h,s,s,n)),c.texImage2D(l,i,r,s,s,0,t,e,h)}}this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(E,s,i,n,_);E.isReady=!0,t?.removePendingData(E),E.onLoadedObservable.notifyObservers(E),E.onLoadedObservable.clear(),u&&u()};return this._loadFile(e,e=>{f(e).catch(e=>{T(void 0,e)})},void 0,t?.offlineProvider,!0,T),E},c.ThinEngine.prototype.createRawTexture2DArray=R(!1),c.ThinEngine.prototype.createRawTexture3D=R(!0),c.ThinEngine.prototype.updateRawTexture2DArray=m(!1),c.ThinEngine.prototype.updateRawTexture3D=m(!0);var A=e.i(75017);let b=!1;b=!0,c.ThinEngine.prototype._readTexturePixelsSync=function(e,t,r,i=-1,n=0,s=null,a=!0,l=!1,u=0,h=0){let o=this._gl;if(!o)throw Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){let e=o.createFramebuffer();if(!e)throw Error("Unable to create dummy framebuffer");this._dummyFramebuffer=e}o.bindFramebuffer(o.FRAMEBUFFER,this._dummyFramebuffer),i>-1&&(e.is2DArray||e.is3D)?o.framebufferTextureLayer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,e._hardwareTexture?.underlyingResource,n,i):i>-1?o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._hardwareTexture?.underlyingResource,n):o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,e._hardwareTexture?.underlyingResource,n);let _=void 0!==e.type?this._getWebGLTextureType(e.type):o.UNSIGNED_BYTE;return l?s||(s=(0,A.allocateAndCopyTypedBuffer)(e.type,4*t*r)):_===o.UNSIGNED_BYTE?(s||(s=new Uint8Array(4*t*r)),_=o.UNSIGNED_BYTE):(s||(s=new Float32Array(4*t*r)),_=o.FLOAT),a&&this.flushFramebuffer(),o.readPixels(u,h,t,r,o.RGBA,_,s),o.bindFramebuffer(o.FRAMEBUFFER,this._currentFramebuffer),s},c.ThinEngine.prototype._readTexturePixels=function(e,t,r,i=-1,n=0,s=null,a=!0,l=!1,u=0,h=0){return Promise.resolve(this._readTexturePixelsSync(e,t,r,i,n,s,a,l,u,h))},(0,e.i(55069).RegisterEngineDynamicBuffer)();let S=!1;S=!0,c.ThinEngine.prototype._createDepthStencilCubeTexture=function(e,t){let r=new T.InternalTexture(this,12);if(r.isCube=!0,1===this.webGLVersion)return f.Logger.Error("Depth cube texture is not supported by WebGL 1."),r;let i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t},n=this._gl;this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,r,!0),this._setupDepthStencilTexture(r,e,i.bilinearFiltering,i.comparisonFunction);for(let t=0;t<6;t++)i.generateStencil?n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH24_STENCIL8,e,e,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH_COMPONENT24,e,e,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null);return this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(r),r},c.ThinEngine.prototype._setCubeMapTextureParams=function(e,t,r){let i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?3:2,t&&this.getCaps().textureMaxLevel&&void 0!==r&&r>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,r),e._maxLodLevel=r),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},c.ThinEngine.prototype.createCubeTexture=function(e,t,r,i,n=null,s=null,a,l=null,u=!1,h=0,o=0,_=null,c,E=!1,T=null){let d=this._gl;return this.createCubeTextureBase(e,t,r,!!i,n,s,a,l,u,h,o,_,e=>this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,e,!0),(e,t)=>{let r=this.needPOTTextures?(0,p.GetExponentOfTwo)(t[0].width,this._caps.maxCubemapTextureSize):t[0].width,s=[d.TEXTURE_CUBE_MAP_POSITIVE_X,d.TEXTURE_CUBE_MAP_POSITIVE_Y,d.TEXTURE_CUBE_MAP_POSITIVE_Z,d.TEXTURE_CUBE_MAP_NEGATIVE_X,d.TEXTURE_CUBE_MAP_NEGATIVE_Y,d.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(!1);let l=a?this._getInternalFormat(a,e._useSRGBBuffer):e._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:d.RGBA,u=a?this._getInternalFormat(a):d.RGBA;e._useSRGBBuffer&&1===this.webGLVersion&&(u=l);for(let e=0;e<s.length;e++)if(t[e].width!==r||t[e].height!==r){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext)return void f.Logger.Warn("Cannot create canvas to resize texture.");this._workingCanvas.width=r,this._workingCanvas.height=r,this._workingContext.drawImage(t[e],0,0,t[e].width,t[e].height,0,0,r,r),d.texImage2D(s[e],0,l,u,d.UNSIGNED_BYTE,this._workingCanvas)}else d.texImage2D(s[e],0,l,u,d.UNSIGNED_BYTE,t[e]);i||d.generateMipmap(d.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(e,!i),e.width=r,e.height=r,e.isReady=!0,a&&(e.format=a),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear(),n&&n()},!!E,T)},c.ThinEngine.prototype.generateMipMapsForCubemap=function(e,t=!0){if(e.generateMipMaps){let r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,e,!0),r.generateMipmap(r.TEXTURE_CUBE_MAP),t&&this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null)}};var F=e.i(79814);class x{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=(0,F.HasStencilAspect)(e.format))}get depthStencilTextureWithStencil(){return this._depthStencilTextureWithStencil}get isCube(){return this._isCube}get isMulti(){return this._isMulti}get is2DArray(){return this.layers>0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width??this._size}get height(){return this._size.height??this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){return this._textures?.[0]??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){if(!this._textures)return -1;let t=this._textures[e],r=this._layerIndices?.[e]??0,i=this._faceIndices?.[e]??0;return t.isCube?6*r+i:t.is3D?0:r}get samples(){return this._samples}setSamples(e,t=!0,r=!1){if(this.samples===e&&!r)return e;let i=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,i}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&(this.isMulti?this._engine.unBindMultiColorAttachmentFramebuffer(this,!0):this._engine.unBindFramebuffer(this,!0)),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,t,r,i,n){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=r,this._engine=i,this._depthStencilTexture=null,this.label=n}setTextures(e){Array.isArray(e)?this._textures=e:e?this._textures=[e]:this._textures=null}setTexture(e,t=0,r=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&r&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,r){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),void 0!==t&&t>=0&&(this._layerIndices[e]=t),void 0!==r&&r>=0&&(this._faceIndices[e]=r)}createDepthStencilTexture(e=0,t=!0,r=!1,i=1,n=14,s){return this._depthStencilTexture?.dispose(),this._depthStencilTextureWithStencil=r,this._depthStencilTextureLabel=s,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:r,isCube:this._isCube,samples:i,depthTextureFormat:n,label:s},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){let e=null;if(this._isMulti){let t=this.textures;if(t&&t.length>0){let r=!1,i=t.length,n=-1,s=t[t.length-1]._source;(14===s||12===s)&&(r=!0,n=t[t.length-1].format,i--);let a=[],l=[],u=[],h=[],o=[],_=[],c=[],E={};for(let e=0;e<i;++e){let r=t[e];a.push(r.samplingMode),l.push(r.type),u.push(r.format),void 0!==E[r.uniqueId]?(h.push(-1),c.push(0)):(E[r.uniqueId]=e,r.is2DArray?(h.push(35866),c.push(r.depth)):r.isCube?(h.push(34067),c.push(0)):r.is3D?(h.push(32879),c.push(r.depth)):(h.push(3553),c.push(0))),this._faceIndices&&o.push(this._faceIndices[e]??0),this._layerIndices&&_.push(this._layerIndices[e]??0)}let T={samplingModes:a,generateMipMaps:t[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:r,depthTextureFormat:n,types:l,formats:u,textureCount:i,targetTypes:h,faceIndex:o,layerIndex:_,layerCounts:c,label:this.label},f={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(f,T);for(let r=0;r<i;++r){if(-1!==h[r])continue;let i=E[t[r].uniqueId];e.setTexture(e.textures[i],r)}}}else{let t={};if(t.generateDepthBuffer=this._generateDepthBuffer,t.generateMipMaps=this.texture?.generateMipMaps??!1,t.generateStencilBuffer=this._generateStencilBuffer,t.samplingMode=this.texture?.samplingMode,t.type=this.texture?.type,t.format=this.texture?.format,t.noColorAttachment=!this._textures,t.label=this.label,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,t);else{let r={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?this.texture?.depth:void 0};e=this._engine.createRenderTargetTexture(r,t)}e.texture&&(e.texture.isReady=!0)}return e}_swapRenderTargetWrapper(e){if(this._textures&&e._textures)for(let t=0;t<this._textures.length;++t)this._textures[t]._swapAndDie(e._textures[t],!1),e._textures[t].isReady=!0;this._depthStencilTexture&&e._depthStencilTexture&&(this._depthStencilTexture._swapAndDie(e._depthStencilTexture),e._depthStencilTexture.isReady=!0),this._textures=null,this._depthStencilTexture=null}_rebuild(){let e=this._cloneRenderTargetWrapper();if(e){if(this._depthStencilTexture){let t=this._depthStencilTexture.samplingMode,r=this._depthStencilTexture.format;e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction,2===t||3===t||11===t,this._depthStencilTextureWithStencil,this._depthStencilTexture.samples,r,this._depthStencilTextureLabel)}this.samples>1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;++e)this._textures[e].dispose();this._textures=null}dispose(e=!1){e||(this._depthStencilTexture?.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)}}class M extends x{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;let r=this._engine,i=this._context,n=e._hardwareTexture;if(n&&e._autoMSAAManagement&&this._MSAAFramebuffer){let t=r._currentFramebuffer;r._bindUnboundFramebuffer(this._MSAAFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,(0,F.HasStencilAspect)(e.format)?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n.getMSAARenderBuffer()),r._bindUnboundFramebuffer(t)}}constructor(e,t,r,i,n){super(e,t,r,i),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=n}_cloneRenderTargetWrapper(){let e;return this._colorTextureArray&&this._depthStencilTextureArray?(e=this._engine.createMultiviewRenderTargetTexture(this.width,this.height)).texture.isReady=!0:e=super._cloneRenderTargetWrapper(),e}_swapRenderTargetWrapper(e){super._swapRenderTargetWrapper(e),e._framebuffer=this._framebuffer,e._depthStencilBuffer=this._depthStencilBuffer,e._MSAAFramebuffer=this._MSAAFramebuffer,e._colorTextureArray=this._colorTextureArray,e._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null}createDepthStencilTexture(e=0,t=!0,r=!1,i=1,n=14,s){if(this._depthStencilBuffer){let e=this._engine,t=e._currentFramebuffer,r=this._context;e._bindUnboundFramebuffer(this._framebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,null),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,null),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.STENCIL_ATTACHMENT,r.RENDERBUFFER,null),e._bindUnboundFramebuffer(t),r.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,t,r,i,n,s)}shareDepth(e){super.shareDepth(e);let t=this._context,r=this._depthStencilBuffer,i=e._MSAAFramebuffer||e._framebuffer,n=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==r&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=r;let s=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;n._bindUnboundFramebuffer(i),t.framebufferRenderbuffer(t.FRAMEBUFFER,s,t.RENDERBUFFER,r),n._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,r,i=0){let n,s=e._hardwareTexture;if(!s)return;let a=this._framebuffer,l=this._engine,u=l._currentFramebuffer;if(l._bindUnboundFramebuffer(a),l.webGLVersion>1){let a=this._context;n=a["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(r=r??this.layerIndices?.[t]??0,a.framebufferTextureLayer(a.FRAMEBUFFER,n,s.underlyingResource,i,r)):e.isCube?(r=r??this.faceIndices?.[t]??0,a.framebufferTexture2D(a.FRAMEBUFFER,n,a.TEXTURE_CUBE_MAP_POSITIVE_X+r,s.underlyingResource,i)):a.framebufferTexture2D(a.FRAMEBUFFER,n,a.TEXTURE_2D,s.underlyingResource,i)}else{let e=this._context;n=e["COLOR_ATTACHMENT"+t+"_WEBGL"];let a=void 0!==r?e.TEXTURE_CUBE_MAP_POSITIVE_X+r:e.TEXTURE_2D;e.framebufferTexture2D(e.FRAMEBUFFER,n,a,s.underlyingResource,i)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){let e=this._context;l._bindUnboundFramebuffer(this._MSAAFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,s.getMSAARenderBuffer())}l._bindUnboundFramebuffer(u)}setTexture(e,t=0,r=!0){super.setTexture(e,t,r),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;let r=this._attachments?.length??this.textures.length;for(let e=0;e<r;e++){let t=this.textures[e];t&&(t.is2DArray||t.is3D?this._bindTextureRenderTarget(t,e,this.layerIndices[e]):t.isCube?this._bindTextureRenderTarget(t,e,this.faceIndices[e]):this._bindTextureRenderTarget(t,e))}}setLayerAndFaceIndex(e=0,t,r){if(super.setLayerAndFaceIndex(e,t,r),!this.textures||!this.layerIndices||!this.faceIndices)return;let i=this.textures[e];i.is2DArray||i.is3D?this._bindTextureRenderTarget(this.textures[e],e,this.layerIndices[e]):i.isCube&&this._bindTextureRenderTarget(this.textures[e],e,this.faceIndices[e])}resolveMSAATextures(){let e=this._engine,t=e._currentFramebuffer;e._bindUnboundFramebuffer(this._MSAAFramebuffer),super.resolveMSAATextures(),e._bindUnboundFramebuffer(t)}dispose(e=this._disposeOnlyFramebuffers){let t=this._context;!e&&(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(t.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(t.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(t.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),super.dispose(e)}}let U=!1;U=!0,c.ThinEngine.prototype._createHardwareRenderTargetWrapper=function(e,t,r){let i=new M(e,t,r,this,this._gl);return this._renderTargetWrapperCache.push(i),i},c.ThinEngine.prototype.createRenderTargetTexture=function(e,t){let r,i,n=this._createHardwareRenderTargetWrapper(!1,!1,e),s=!0,a=!1,l=!1,u=1;void 0!==t&&"object"==typeof t&&(s=t.generateDepthBuffer??!0,a=!!t.generateStencilBuffer,l=!!t.noColorAttachment,r=t.colorAttachment,u=t.samples??1,i=t.label);let h=r||(l?null:this._createInternalTexture(e,t,!0,5)),o=e.width||e,_=e.height||e,c=this._currentFramebuffer,E=this._gl,T=E.createFramebuffer();if(this._bindUnboundFramebuffer(T),n._depthStencilBuffer=this._setupFramebufferDepthAttachments(a,s,o,_),!h||h.is2DArray||h.is3D||E.framebufferTexture2D(E.FRAMEBUFFER,E.COLOR_ATTACHMENT0,E.TEXTURE_2D,h._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(c),n.label=i??"RenderTargetWrapper",n._framebuffer=T,n._generateDepthBuffer=s,n._generateStencilBuffer=a,n.setTextures(h),r){if(n._samples=r.samples,r.samples>1){let e=r._hardwareTexture.getMSAARenderBuffer(0);n._MSAAFramebuffer=E.createFramebuffer(),this._bindUnboundFramebuffer(n._MSAAFramebuffer),E.framebufferRenderbuffer(E.FRAMEBUFFER,E.COLOR_ATTACHMENT0,E.RENDERBUFFER,e),this._bindUnboundFramebuffer(null)}}else this.updateRenderTargetTextureSampleCount(n,u);return n},c.ThinEngine.prototype._createDepthStencilTexture=function(e,t,r){let i=this._gl,n=e.layers||0,s=e.depth||0,a=i.TEXTURE_2D;0!==n?a=i.TEXTURE_2D_ARRAY:0!==s&&(a=i.TEXTURE_3D);let l=new T.InternalTexture(this,12);if(l.label=t.label,!this._caps.depthTextureExtension)return f.Logger.Error("Depth texture is not supported by your browser or hardware."),l;let u={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t};if(this._bindTextureDirectly(a,l,!0),this._setupDepthStencilTexture(l,e,0!==u.comparisonFunction&&u.bilinearFiltering,u.comparisonFunction,u.samples),void 0!==u.depthTextureFormat){if(15!==u.depthTextureFormat&&16!==u.depthTextureFormat&&17!==u.depthTextureFormat&&13!==u.depthTextureFormat&&14!==u.depthTextureFormat&&18!==u.depthTextureFormat)return f.Logger.Error(`Depth texture ${u.depthTextureFormat} format is not supported.`),l;l.format=u.depthTextureFormat}else l.format=u.generateStencil?13:16;let h=(0,F.HasStencilAspect)(l.format),o=this._getWebGLTextureTypeFromDepthTextureFormat(l.format),_=h?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,c=this._getInternalFormatFromDepthTextureFormat(l.format,!0,h);return l.is2DArray?i.texImage3D(a,0,c,l.width,l.height,n,0,_,o,null):l.is3D?i.texImage3D(a,0,c,l.width,l.height,s,0,_,o,null):i.texImage2D(a,0,c,l.width,l.height,0,_,o,null),this._bindTextureDirectly(a,null),this._internalTexturesCache.push(l),r._depthStencilBuffer&&(i.deleteRenderbuffer(r._depthStencilBuffer),r._depthStencilBuffer=null),this._bindUnboundFramebuffer(r._MSAAFramebuffer??r._framebuffer),r._generateStencilBuffer=h,r._depthStencilTextureWithStencil=h,r._depthStencilBuffer=this._setupFramebufferDepthAttachments(r._generateStencilBuffer,r._generateDepthBuffer,r.width,r.height,r.samples,l.format),this._bindUnboundFramebuffer(null),l},c.ThinEngine.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;let r=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(r.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(r.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);let i=e.texture?._hardwareTexture;if(i?.releaseMSAARenderBuffers(),e.texture&&t>1&&"function"==typeof r.renderbufferStorageMultisample){let n=r.createFramebuffer();if(!n)throw Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=n,this._bindUnboundFramebuffer(e._MSAAFramebuffer);let s=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBABufferInternalSizedFormat(e.texture.type,e.texture.format,e.texture._useSRGBBuffer),r.COLOR_ATTACHMENT0,!1);if(!s)throw Error("Unable to create multi sampled framebuffer");i?.addMSAARenderBuffer(s)}this._bindUnboundFramebuffer(e._MSAAFramebuffer??e._framebuffer),e.texture&&(e.texture.samples=t),e._samples=t;let n=e._depthStencilTexture?e._depthStencilTexture.format:void 0;return e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t,n),this._bindUnboundFramebuffer(null),t},c.ThinEngine.prototype._setupDepthStencilTexture=function(e,t,r,i,n=1){let s=t.width??t,a=t.height??t,l=t.layers||0,u=t.depth||0;e.baseWidth=s,e.baseHeight=a,e.width=s,e.height=a,e.is2DArray=l>0,e.depth=l||u,e.isReady=!0,e.samples=n,e.generateMipMaps=!1,e.samplingMode=r?2:1,e.type=0,e._comparisonFunction=i;let h=this._gl,o=this._getTextureTarget(e),_=this._getSamplingParameters(e.samplingMode,!1);h.texParameteri(o,h.TEXTURE_MAG_FILTER,_.mag),h.texParameteri(o,h.TEXTURE_MIN_FILTER,_.min),h.texParameteri(o,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(o,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this.webGLVersion>1&&(0===i?(h.texParameteri(o,h.TEXTURE_COMPARE_FUNC,515),h.texParameteri(o,h.TEXTURE_COMPARE_MODE,h.NONE)):(h.texParameteri(o,h.TEXTURE_COMPARE_FUNC,i),h.texParameteri(o,h.TEXTURE_COMPARE_MODE,h.COMPARE_REF_TO_TEXTURE)))};let D=!1;D=!0,c.ThinEngine.prototype.setDepthStencilTexture=function(e,t,r,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),r&&r.depthStencilTexture?this._setTexture(e,r,!1,!0,i):this._setTexture(e,null,void 0,void 0,i))};let P=!1;P=!0,c.ThinEngine.prototype.createRenderTargetCubeTexture=function(e,t){let r=this._createHardwareRenderTargetWrapper(!1,!0,e),i={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...t};i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(1!==i.type||this._caps.textureFloatLinearFiltering)&&(2!==i.type||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=1);let n=this._gl,s=new T.InternalTexture(this,5);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,s,!0);let a=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);1!==i.type||this._caps.textureFloat||(i.type=0,f.Logger.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,a.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,a.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(let t=0;t<6;t++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);let l=n.createFramebuffer();return this._bindUnboundFramebuffer(l),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),r._framebuffer=l,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=i.generateStencilBuffer,s.width=e,s.height=e,s.isReady=!0,s.isCube=!0,s.samples=1,s.generateMipMaps=i.generateMipMaps,s.samplingMode=i.samplingMode,s.type=i.type,s.format=i.format,this._internalTexturesCache.push(s),r.setTextures(s),r};var y=e.i(14953),C=e.i(52153);let B=!1;B=!0,c.ThinEngine.prototype.createPrefilteredCubeTexture=function(t,r,i,n,s=null,a=null,l,u=null,h=!0){let o=async t=>{if(!t){s&&s(null);return}let a=t.texture;if(h?t.info.sphericalPolynomial&&(a._sphericalPolynomial=t.info.sphericalPolynomial):a._sphericalPolynomial=a._sphericalPolynomial??new y.SphericalPolynomial,a._source=9,this.getCaps().textureLOD){s&&s(a);return}let l=this._gl,u=t.width;if(!u)return;let{DDSTools:o}=await e.A(98673),_=[];for(let e=0;e<3;e++){let s=Math.log2(u)*i+n,h=Math.round(Math.min(Math.max(n+(s-n)*(1-e/2),0),s)),c=new T.InternalTexture(this,2);if(c.type=a.type,c.format=a.format,c.width=Math.pow(2,Math.max(Math.log2(u)-h,0)),c.height=c.width,c.isCube=!0,c._cachedWrapU=0,c._cachedWrapV=0,this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c,!0),c.samplingMode=2,l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),t.isDDS){let e=t.info,r=t.data;this._unpackFlipY(e.isCompressed),o.UploadDDSLevels(this,c,r,e,!0,6,h)}else f.Logger.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null);let E=new C.BaseTexture(r);E._isCube=!0,E._texture=c,c.isReady=!0,_.push(E)}a._lodTextureHigh=_[2],a._lodTextureMid=_[1],a._lodTextureLow=_[0],s&&s(a)};return this.createCubeTexture(t,r,null,!1,o,a,l,u,h,i,n)};var I=e.i(20483);let L=!1;L=!0,c.ThinEngine.prototype.createUniformBuffer=function(e,t){let r=this._gl.createBuffer();if(!r)throw Error("Unable to create uniform buffer");let i=new I.WebGLDataBuffer(r);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},c.ThinEngine.prototype.createDynamicUniformBuffer=function(e,t){let r=this._gl.createBuffer();if(!r)throw Error("Unable to create dynamic uniform buffer");let i=new I.WebGLDataBuffer(r);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},c.ThinEngine.prototype.updateUniformBuffer=function(e,t,r,i){this.bindUniformBuffer(e),void 0===r&&(r=0),void 0===i?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(r,r+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(r,r+i)),this.bindUniformBuffer(null)},c.ThinEngine.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},c.ThinEngine.prototype.bindUniformBufferBase=function(e,t,r){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},c.ThinEngine.prototype.bindUniformBlock=function(e,t,r){let i=e.program,n=this._gl.getUniformBlockIndex(i,t);0xffffffff!==n&&this._gl.uniformBlockBinding(i,n,r)};var O=e.i(64545),X=e.i(76535);let N=!1;N=!0,X.AbstractEngine.prototype.displayLoadingUI=function(){if(!(0,O.IsWindowObjectExist)())return;let e=this.loadingScreen;e&&e.displayLoadingUI()},X.AbstractEngine.prototype.hideLoadingUI=function(){if(!(0,O.IsWindowObjectExist)())return;let e=this._loadingScreen;e&&e.hideLoadingUI()},Object.defineProperty(X.AbstractEngine.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=X.AbstractEngine.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(X.AbstractEngine.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(X.AbstractEngine.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0});let w=!1;function v(){w||(w=!0,X.AbstractEngine.prototype.getInputElement=function(){return this._renderingCanvas},X.AbstractEngine.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},X.AbstractEngine.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},X.AbstractEngine.prototype.getAspectRatio=function(e,t=!1){let r=e.viewport;return this.getRenderWidth(t)*r.width/(this.getRenderHeight(t)*r.height)},X.AbstractEngine.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},X.AbstractEngine.prototype._verifyPointerLock=function(){this._onPointerLockChange?.()})}v();let G=!1;G=!0,X.AbstractEngine.prototype.getInputElement=function(){return this._renderingCanvas},X.AbstractEngine.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},X.AbstractEngine.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},X.AbstractEngine.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)},X.AbstractEngine.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)},X.AbstractEngine.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)},X.AbstractEngine.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)},X.AbstractEngine.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},X.AbstractEngine.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},X.AbstractEngine.prototype.setAlphaConstants=function(e,t,r,i){this._alphaState.setAlphaBlendConstants(e,t,r,i)},X.AbstractEngine.prototype.getAlphaMode=function(e=0){return this._alphaMode[e]},X.AbstractEngine.prototype.getAlphaEquation=function(e=0){return this._alphaEquation[e]};let k=!1;k=!0,X.AbstractEngine.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},X.AbstractEngine.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},X.AbstractEngine.prototype.getStencilMask=function(){return this._stencilState.stencilMask},X.AbstractEngine.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},X.AbstractEngine.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},X.AbstractEngine.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc},X.AbstractEngine.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},X.AbstractEngine.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},X.AbstractEngine.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},X.AbstractEngine.prototype.setStencilBackFunction=function(e){this._stencilState.stencilBackFunc=e},X.AbstractEngine.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},X.AbstractEngine.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},X.AbstractEngine.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},X.AbstractEngine.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail},X.AbstractEngine.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},X.AbstractEngine.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail},X.AbstractEngine.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},X.AbstractEngine.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass},X.AbstractEngine.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},X.AbstractEngine.prototype.setStencilBackOperationFail=function(e){this._stencilState.stencilBackOpStencilFail=e},X.AbstractEngine.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},X.AbstractEngine.prototype.setStencilBackOperationDepthFail=function(e){this._stencilState.stencilBackOpDepthFail=e},X.AbstractEngine.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},X.AbstractEngine.prototype.setStencilBackOperationPass=function(e){this._stencilState.stencilBackOpStencilDepthPass=e},X.AbstractEngine.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},X.AbstractEngine.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)};var W=e.i(69938);(0,W.RegisterAbstractEngineRenderPass)();let H=!1;H=!0,X.AbstractEngine.prototype.createDepthStencilTexture=function(e,t,r){if(!t.isCube)return this._createDepthStencilTexture(e,t,r);{let r=e.width||e;return this._createDepthStencilCubeTexture(r,t)}};let Y=!1;Y=!0,X.AbstractEngine.prototype._loadFileAsync=async function(e,t,r){return await new Promise((i,n)=>{this._loadFile(e,e=>{i(e)},void 0,t,r,(e,t)=>{n(t)})})};var V=e.i(53730);X.AbstractEngine.GetCompatibleTextureLoader=V._GetCompatibleTextureLoader;let z=!1;z=!0,c.ThinEngine.prototype.enableScissor=function(e,t,r,i){let n=this._gl;n.enable(n.SCISSOR_TEST),n.scissor(e,t,r,i)},c.ThinEngine.prototype.disableScissor=function(){let e=this._gl;e.disable(e.SCISSOR_TEST)},e.s([],52617),e.i(52617);var q=e.i(81623),K=c,j=e.i(36395);class Q{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new Z(e)}sampleFrame(e=j.PrecisionDate.Now){if(this._enabled){if(null!=this._lastFrameTimeMs){let t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){let e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class Z{constructor(e){this._samples=Array(e),this.reset()}add(e){let t;if(this.isSaturated()){let e=this._samples[this._pos];t=e-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(e-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;let t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){let t=this._samples.length;return(e%t+t)%t}}var $=e.i(40462);function J(e){return Number.isFinite(e.ascent)&&Number.isFinite(e.height)&&Number.isFinite(e.descent)&&e.height>0}async function ee(e,t,r){return await new Promise((i,n)=>{let s=new Image;s.onload=()=>{s.decode().then(()=>{e.createImageBitmap(s,r).then(e=>{i(e)})})},s.onerror=()=>{n(`Error loading image ${s.src}`)},s.src=t})}function et(e){if(e.requestPointerLock){let t=e.requestPointerLock();t instanceof Promise?t.then(()=>{e.focus()}).catch(()=>{}):e.focus()}}var er=e.i(67359),ei=e.i(23240),en=e.i(75405);class es extends K.ThinEngine{static get NpmPackage(){return X.AbstractEngine.NpmPackage}static get Version(){return X.AbstractEngine.Version}static get Instances(){return q.EngineStore.Instances}static get LastCreatedEngine(){return q.EngineStore.LastCreatedEngine}static get LastCreatedScene(){return q.EngineStore.LastCreatedScene}static DefaultLoadingScreenFactory(e){return X.AbstractEngine.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!es._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,t,r,i=!1){if(v(),(0,W.RegisterAbstractEngineRenderPass)(),super(e,t,r,i),this._performanceMonitor=new Q,this._drawCalls=new er.PerfCounter,!e)return;this._features.supportRenderPasses=!0}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){var t,r;let i;super._sharedInit(e),t=this,r=this._creationOptions,t._onCanvasFocus=()=>{t.onCanvasFocusObservable.notifyObservers(t)},t._onCanvasBlur=()=>{t.onCanvasBlurObservable.notifyObservers(t)},t._onCanvasContextMenu=e=>{t.disableContextMenu&&e.preventDefault()},e.addEventListener("focus",t._onCanvasFocus),e.addEventListener("blur",t._onCanvasBlur),e.addEventListener("contextmenu",t._onCanvasContextMenu),t._onBlur=()=>{t.disablePerformanceMonitorInBackground&&t.performanceMonitor.disable(),t._windowIsBackground=!0},t._onFocus=()=>{t.disablePerformanceMonitorInBackground&&t.performanceMonitor.enable(),t._windowIsBackground=!1},t._onCanvasPointerOut=r=>{document.elementFromPoint(r.clientX,r.clientY)!==e&&t.onCanvasPointerOutObservable.notifyObservers(r)},(i=t.getHostWindow())&&"function"==typeof i.addEventListener&&(i.addEventListener("blur",t._onBlur),i.addEventListener("focus",t._onFocus)),e.addEventListener("pointerout",t._onCanvasPointerOut),!r.doNotHandleTouchAction&&e&&e.setAttribute&&(e.setAttribute("touch-action","none"),e.style.touchAction="none",e.style.webkitTapHighlightColor="transparent"),!X.AbstractEngine.audioEngine&&r.audioEngine&&X.AbstractEngine.AudioEngineFactory&&(X.AbstractEngine.audioEngine=X.AbstractEngine.AudioEngineFactory(t.getRenderingCanvas(),t.getAudioContext(),t.getAudioDestination())),(0,O.IsDocumentAvailable)()&&(t._onFullscreenChange=()=>{t.isFullscreen=!!document.fullscreenElement,t.isFullscreen&&t._pointerLockRequested&&e&&et(e)},document.addEventListener("fullscreenchange",t._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",t._onFullscreenChange,!1),t._onPointerLockChange=()=>{t.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",t._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",t._onPointerLockChange,!1)),t.enableOfflineSupport=void 0!==X.AbstractEngine.OfflineProviderFactory,t._deterministicLockstep=!!r.deterministicLockstep,t._lockstepMaxSteps=r.lockstepMaxSteps||0,t._timeStep=r.timeStep||1/60}resizeImageBitmap(e,t,r){let i=this.createCanvas(t,r).getContext("2d");if(!i)throw Error("Unable to get 2d context for resizeImageBitmap");return i.drawImage(e,0,0),i.getImageData(0,0,t,r).data}async _createImageBitmapFromSource(e,t){return await ee(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){if(!this.isFullscreen){var t;let r;this._pointerLockRequested=e,this._renderingCanvas&&(r=(t=this._renderingCanvas).requestFullscreen||t.webkitRequestFullscreen)&&r.call(t)}}exitFullscreen(){let e;this.isFullscreen&&(e=document,document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen())}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,t,r,i){let n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,r,i),n}scissorClear(e,t,r,i,n){this.enableScissor(e,t,r,i),this.clear(n,!0,!0,!0),this.disableScissor()}getVertexShaderSource(e){let t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){let t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(let e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(let e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){var t;let r,i,n,s,a=function(e){let t,r;if(!(0,O.IsDocumentAvailable)()||!document.body)return null;let i=document.createElement("span");i.textContent="Hg",i.style.font=e;let n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px",n.style.verticalAlign="bottom";let s=document.createElement("div");s.style.whiteSpace="nowrap",s.appendChild(i),s.appendChild(n),document.body.appendChild(s);try{r=n.getBoundingClientRect().top-i.getBoundingClientRect().top,n.style.verticalAlign="baseline",t=n.getBoundingClientRect().top-i.getBoundingClientRect().top}finally{document.body.removeChild(s)}let a={ascent:t,height:r,descent:r-t};return J(a)?a:null}(e);if(a)return a;let l=function(e){let t=null;try{"u">typeof OffscreenCanvas?t=new OffscreenCanvas(64,64):(0,O.IsDocumentAvailable)()&&"function"==typeof document.createElement&&((t=document.createElement("canvas")).width=64,t.height=64);let r=t?.getContext("2d");if(!r)return null;r.font=e;let i=r.measureText("Hg"),n=Number(i.actualBoundingBoxAscent??i.fontBoundingBoxAscent),s=Number(i.actualBoundingBoxDescent??i.fontBoundingBoxDescent),a={ascent:n,height:n+s,descent:s};return J(a)?a:null}catch{return null}finally{let e=t;"function"==typeof e?.dispose&&e.dispose()}}(e);return l||(n=.8*(i=Math.max(1,(t=e,(r=/(?:^|\s)([0-9]+(?:\.[0-9]+)?)px(?:\/|\s|$)/.exec(String(t||"")))?Number(r[1]):16))),{ascent:n,height:n+(s=.2*i),descent:s})}enterPointerlock(){this._renderingCanvas&&et(this._renderingCanvas)}exitPointerlock(){document.exitPointerLock&&document.exitPointerLock()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){e&&e.program&&e.transformFeedback&&(this.deleteTransformFeedback(e.transformFeedback),e.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,r,i,n,s=null){n=n||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);let a=super.createShaderProgram(e,t,r,i,n,s);return this.onAfterShaderCompilationObservable.notifyObservers(this),a}_createShaderProgram(e,t,r,i,n=null){let s=i.createProgram();if(e.program=s,!s)throw Error("Unable to create program");if(i.attachShader(s,t),i.attachShader(s,r),this.webGLVersion>1&&n){let t=this.createTransformFeedback();this.bindTransformFeedback(t),this.setTranformFeedbackVaryings(s,n),e.transformFeedback=t}return i.linkProgram(s),this.webGLVersion>1&&n&&this.bindTransformFeedback(null),e.context=i,e.vertexShader=t,e.fragmentShader=r,e.isParallelCompiled||this._finalizePipelineContext(e),s}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){for(let t of(super._releaseRenderTargetWrapper(e),this.scenes)){for(let r of t.postProcesses)r._outputTexture===e&&(r._outputTexture=null);for(let r of t.cameras)for(let t of r._postProcesses)t&&t._outputTexture===e&&(t._outputTexture=null)}}_rescaleTexture(e,t,r,i,n){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);let s=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&es._RescalePostProcessFactory&&(this._rescalePostProcess=es._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;let a=()=>{this._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};let a=r;a||(a=this.scenes[this.scenes.length-1]),a.postProcessManager.directRender([this._rescalePostProcess],s,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,i,0,0,t.width,t.height,0),this.unBindFramebuffer(s),s.dispose(),n&&n()},l=this._rescalePostProcess.getEffect();l?l.executeWhenCompiled(a):this._rescalePostProcess.onEffectCreatedObservable.addOnce(e=>{e.executeWhenCompiled(a)})}}wrapWebGLTexture(e,t=!1,r=3,i=0,n=0){let s=new $.WebGLHardwareTexture(e,this._gl),a=new T.InternalTexture(this,15,!0);return a._hardwareTexture=s,a.baseWidth=i,a.baseHeight=n,a.width=i,a.height=n,a.isReady=!0,a.useMipMaps=t,this.updateTextureSamplingMode(r,a),a}updateWrappedWebGLTexture(e,t){if(15!==e.source)throw Error("updateWrappedWebGLTexture: target InternalTexture was not produced by wrapWebGLTexture.");for(let t of this._renderTargetWrapperCache)if(t.textures?.includes(e)){if(t.isMulti)throw Error("updateWrappedWebGLTexture: wrapped texture is part of a multi render-target; not supported. Dispose and re-wrap.");if(t._depthStencilTexture)throw Error("updateWrappedWebGLTexture: wrapped texture's render-target wrapper has a depth/stencil texture; not supported. Dispose and re-wrap.")}for(let r in e._hardwareTexture=new $.WebGLHardwareTexture(t,this._gl),e.isReady=!0,e._cachedCoordinatesMode=null,e._cachedWrapU=null,e._cachedWrapV=null,e._cachedWrapR=null,e._cachedAnisotropicFilteringLevel=null,this._boundTexturesCache)this._boundTexturesCache[r]===e&&(this._boundTexturesCache[r]=null);this.updateTextureSamplingMode(e.samplingMode,e);let r=this._gl;for(let i of this._renderTargetWrapperCache){if(i.texture!==e)continue;let n=i.samples,s=n>1;i._framebuffer&&r.deleteFramebuffer(i._framebuffer),!s&&i._depthStencilBuffer&&(r.deleteRenderbuffer(i._depthStencilBuffer),i._depthStencilBuffer=null);let a=this._currentFramebuffer,l=r.createFramebuffer();this._bindUnboundFramebuffer(l),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),s||(i._depthStencilBuffer=this._setupFramebufferDepthAttachments(i._generateStencilBuffer,i._generateDepthBuffer,i.width,i.height)),this._bindUnboundFramebuffer(a),i._framebuffer=l,s&&(i._samples=1,this.updateRenderTargetTextureSampleCount(i,n))}}_uploadImageToTexture(e,t,r=0,i=0){let n=this._gl,s=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),l=this._getRGBABufferInternalSizedFormat(e.type,a),u=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(u,e,!0),this._unpackFlipY(e.invertY);let h=n.TEXTURE_2D;e.isCube&&(h=n.TEXTURE_CUBE_MAP_POSITIVE_X+r),n.texImage2D(h,i,l,a,s,t),this._bindTextureDirectly(u,null,!0)}updateTextureComparisonFunction(e,t){if(1===this.webGLVersion)return void f.Logger.Error("WebGL 1 does not support texture comparison.");let r=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,515),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,t),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,515),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}createInstancesBuffer(e){let t=this._gl.createBuffer();if(!t)throw Error("Unable to create instance buffer");let r=new I.WebGLDataBuffer(t);return r.capacity=e,this.bindArrayBuffer(r),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),r.references=1,r}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,t=0,r=10){let i=this._gl;return await new Promise((n,s)=>{(0,ei._RetryWithInterval)(()=>{let r=i.clientWaitSync(e,t,0);if(r==i.WAIT_FAILED)throw Error("clientWaitSync failed");return r!=i.TIMEOUT_EXPIRED},n,s,r)})}_readPixelsAsync(e,t,r,i,n,s,a){if(this._webGLVersion<2)throw Error("_readPixelsAsync only work on WebGL2+");let l=this._gl,u=l.createBuffer();l.bindBuffer(l.PIXEL_PACK_BUFFER,u),l.bufferData(l.PIXEL_PACK_BUFFER,a.byteLength,l.STREAM_READ),l.readPixels(e,t,r,i,n,s,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);let h=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);return h?(l.flush(),this._clientWaitAsync(h,0,10).then(()=>(l.deleteSync(h),l.bindBuffer(l.PIXEL_PACK_BUFFER,u),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,a),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),l.deleteBuffer(u),a))):null}dispose(){var e;let t;this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),e=this._renderingCanvas,1===q.EngineStore.Instances.length&&X.AbstractEngine.audioEngine&&(X.AbstractEngine.audioEngine.dispose(),X.AbstractEngine.audioEngine=null),(t=this.getHostWindow())&&"function"==typeof t.removeEventListener&&(t.removeEventListener("blur",this._onBlur),t.removeEventListener("focus",this._onFocus)),e&&(e.removeEventListener("focus",this._onCanvasFocus),e.removeEventListener("blur",this._onCanvasBlur),e.removeEventListener("pointerout",this._onCanvasPointerOut),e.removeEventListener("contextmenu",this._onCanvasContextMenu)),(0,O.IsDocumentAvailable)()&&(document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange)),super.dispose()}}es.ALPHA_DISABLE=0,es.ALPHA_ADD=1,es.ALPHA_COMBINE=2,es.ALPHA_SUBTRACT=3,es.ALPHA_MULTIPLY=4,es.ALPHA_MAXIMIZED=5,es.ALPHA_ONEONE=6,es.ALPHA_PREMULTIPLIED=7,es.ALPHA_PREMULTIPLIED_PORTERDUFF=8,es.ALPHA_INTERPOLATE=9,es.ALPHA_SCREENMODE=10,es.DELAYLOADSTATE_NONE=0,es.DELAYLOADSTATE_LOADED=1,es.DELAYLOADSTATE_LOADING=2,es.DELAYLOADSTATE_NOTLOADED=4,es.NEVER=512,es.ALWAYS=519,es.LESS=513,es.EQUAL=514,es.LEQUAL=515,es.GREATER=516,es.GEQUAL=518,es.NOTEQUAL=517,es.KEEP=7680,es.REPLACE=7681,es.INCR=7682,es.DECR=7683,es.INVERT=5386,es.INCR_WRAP=34055,es.DECR_WRAP=34056,es.TEXTURE_CLAMP_ADDRESSMODE=0,es.TEXTURE_WRAP_ADDRESSMODE=1,es.TEXTURE_MIRROR_ADDRESSMODE=2,es.TEXTUREFORMAT_ALPHA=0,es.TEXTUREFORMAT_LUMINANCE=1,es.TEXTUREFORMAT_LUMINANCE_ALPHA=2,es.TEXTUREFORMAT_RGB=4,es.TEXTUREFORMAT_RGBA=5,es.TEXTUREFORMAT_RED=6,es.TEXTUREFORMAT_R=6,es.TEXTUREFORMAT_R16_UNORM=33322,es.TEXTUREFORMAT_RG16_UNORM=33324,es.TEXTUREFORMAT_RGB16_UNORM=32852,es.TEXTUREFORMAT_RGBA16_UNORM=32859,es.TEXTUREFORMAT_R16_SNORM=36760,es.TEXTUREFORMAT_RG16_SNORM=36761,es.TEXTUREFORMAT_RGB16_SNORM=36762,es.TEXTUREFORMAT_RGBA16_SNORM=36763,es.TEXTUREFORMAT_RG=7,es.TEXTUREFORMAT_RED_INTEGER=8,es.TEXTUREFORMAT_R_INTEGER=8,es.TEXTUREFORMAT_RG_INTEGER=9,es.TEXTUREFORMAT_RGB_INTEGER=10,es.TEXTUREFORMAT_RGBA_INTEGER=11,es.TEXTURETYPE_UNSIGNED_BYTE=0,es.TEXTURETYPE_UNSIGNED_INT=0,es.TEXTURETYPE_FLOAT=1,es.TEXTURETYPE_HALF_FLOAT=2,es.TEXTURETYPE_BYTE=3,es.TEXTURETYPE_SHORT=4,es.TEXTURETYPE_UNSIGNED_SHORT=5,es.TEXTURETYPE_INT=6,es.TEXTURETYPE_UNSIGNED_INTEGER=7,es.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,es.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,es.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,es.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,es.TEXTURETYPE_UNSIGNED_INT_24_8=12,es.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,es.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,es.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,es.TEXTURE_NEAREST_SAMPLINGMODE=1,es.TEXTURE_BILINEAR_SAMPLINGMODE=2,es.TEXTURE_TRILINEAR_SAMPLINGMODE=3,es.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,es.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,es.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,es.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,es.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,es.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,es.TEXTURE_NEAREST_LINEAR=7,es.TEXTURE_NEAREST_NEAREST=1,es.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,es.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,es.TEXTURE_LINEAR_LINEAR=2,es.TEXTURE_LINEAR_NEAREST=12,es.TEXTURE_EXPLICIT_MODE=0,es.TEXTURE_SPHERICAL_MODE=1,es.TEXTURE_PLANAR_MODE=2,es.TEXTURE_CUBIC_MODE=3,es.TEXTURE_PROJECTION_MODE=4,es.TEXTURE_SKYBOX_MODE=5,es.TEXTURE_INVCUBIC_MODE=6,es.TEXTURE_EQUIRECTANGULAR_MODE=7,es.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,es.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,es.SCALEMODE_FLOOR=1,es.SCALEMODE_NEAREST=2,es.SCALEMODE_CEILING=3,(t=es.prototype).createMultiviewRenderTargetTexture??(t.createMultiviewRenderTargetTexture=(0,en._MissingSideEffect)("Engine","createMultiviewRenderTargetTexture")),(r=es.prototype).bindMultiviewFramebuffer??(r.bindMultiviewFramebuffer=(0,en._MissingSideEffect)("Engine","bindMultiviewFramebuffer")),(i=es.prototype).bindSpaceWarpFramebuffer??(i.bindSpaceWarpFramebuffer=(0,en._MissingSideEffect)("Engine","bindSpaceWarpFramebuffer")),(n=es.prototype).createTransformFeedback??(n.createTransformFeedback=(0,en._MissingSideEffect)("Engine","createTransformFeedback")),(s=es.prototype).deleteTransformFeedback??(s.deleteTransformFeedback=(0,en._MissingSideEffect)("Engine","deleteTransformFeedback")),(a=es.prototype).bindTransformFeedback??(a.bindTransformFeedback=(0,en._MissingSideEffect)("Engine","bindTransformFeedback")),(l=es.prototype).beginTransformFeedback??(l.beginTransformFeedback=(0,en._MissingSideEffect)("Engine","beginTransformFeedback")),(u=es.prototype).endTransformFeedback??(u.endTransformFeedback=(0,en._MissingSideEffect)("Engine","endTransformFeedback")),(h=es.prototype).setTranformFeedbackVaryings??(h.setTranformFeedbackVaryings=(0,en._MissingSideEffect)("Engine","setTranformFeedbackVaryings")),(o=es.prototype).bindTransformFeedbackBuffer??(o.bindTransformFeedbackBuffer=(0,en._MissingSideEffect)("Engine","bindTransformFeedbackBuffer")),(_=es.prototype).readTransformFeedbackBuffer??(_.readTransformFeedbackBuffer=(0,en._MissingSideEffect)("Engine","readTransformFeedbackBuffer")),e.s(["Engine",0,es],95769),e.i(95769),e.s(["Engine",0,es],94080)}]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,51581,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"BailoutToCSR",{enumerable:!0,get:function(){return l}});let n=e.r(59922);function l({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},16201,(e,t,s)=>{"use strict";function n(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"encodeURIPath",{enumerable:!0,get:function(){return n}})},1299,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"PreloadChunks",{enumerable:!0,get:function(){return o}});let n=e.r(29212),l=e.r(90611),r=e.r(50803),a=e.r(16201),i=e.r(29434);function o({moduleIds:e}){if("u">typeof window)return null;let t=r.workAsyncStorage.getStore();if(void 0===t)return null;let s=[];if(t.reactLoadableManifest&&e){let n=t.reactLoadableManifest;for(let t of e){if(!n[t])continue;let e=n[t].files;s.push(...e)}}if(0===s.length)return null;let d=(0,i.getAssetTokenQuery)();return(0,n.jsx)(n.Fragment,{children:s.map(e=>{let s=`${t.assetPrefix}/_next/${(0,a.encodeURIPath)(e)}${d}`;return e.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:s,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,l.preload)(s,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},89699,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return d}});let n=e.r(29212),l=e.r(94179),r=e.r(51581),a=e.r(1299);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},d=function(e){let t={...o,...e},s=(0,l.lazy)(()=>t.loader().then(i)),d=t.loading;function c(e){let i=d?(0,n.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,o=!t.ssr||!!t.loading,c=o?l.Suspense:l.Fragment,u=t.ssr?(0,n.jsxs)(n.Fragment,{children:["u"<typeof window?(0,n.jsx)(a.PreloadChunks,{moduleIds:t.modules}):null,(0,n.jsx)(s,{...e})]}):(0,n.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(s,{...e})});return(0,n.jsx)(c,{...o?{fallback:i}:{},children:u})}return c.displayName="LoadableComponent",c}},80268,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),Object.defineProperty(s,"default",{enumerable:!0,get:function(){return l}});let n=e.r(81258)._(e.r(89699));function l(e,t){let s={};"function"==typeof e&&(s.loader=e);let l={...s,...t};return(0,n.default)({...l,modules:l.loadableGenerated?.modules})}("function"==typeof s.default||"object"==typeof s.default&&null!==s.default)&&void 0===s.default.__esModule&&(Object.defineProperty(s.default,"__esModule",{value:!0}),Object.assign(s.default,s),t.exports=s.default)},14936,e=>{"use strict";e.i(23838);var t=e.i(29212),s=e.i(80268),n=e.i(94179),l=e.i(82665),r=e.i(20880);let a={window:"1h"},i=[{id:"1h",label:"Last hour"},{id:"24h",label:"Last 24h"},{id:"7d",label:"Last 7 days"},{id:"all",label:"All time"}],o={"1h":36e5,"24h":864e5,"7d":6048e5};function d(e,t=Date.now()){return"all"===e.window?{}:"custom"===e.window?{since:e.since,until:e.until}:{since:t-o[e.window],until:t}}function c(e,t=Date.now()){return{...d(e,t),scene:e.scene&&e.scene.length>0?e.scene:void 0,source:e.source,cameraMode:e.cameraMode}}let u=[60,300,900,1800,3600,10800,21600,43200,86400,604800];function x(e){return"xr-controller"===e?"XR controller":e.charAt(0).toUpperCase()+e.slice(1)}let m=["mouse","touch","stylus","pen","xr-controller","hand","gaze","transient","other"];var p=e.i(56054);function h(e,t=1){let[s,n,l]=(0,p.heatRgb)(e);return`rgba(${Math.round(255*s)}, ${Math.round(255*n)}, ${Math.round(255*l)}, ${t})`}function f(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t}):"—"}var g=e.i(88725);let b="#161210",j={fontSize:13,color:"#a8917c"},v={padding:"6px 10px",fontSize:13,borderTop:"1px solid #34291f"};function y({sessions:e,onSelect:s,selectedId:n}){return 0===e.length?(0,t.jsx)("p",{style:j,children:"No sessions in range."}):(0,t.jsx)("div",{style:{maxHeight:320,overflow:"auto"},children:(0,t.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",textAlign:"left"},children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{style:{fontSize:11,textTransform:"uppercase",color:"#a8917c"},children:[(0,t.jsx)("th",{style:{padding:"6px 10px"},children:"Session"}),(0,t.jsx)("th",{style:{padding:"6px 10px"},children:"Visitor"}),(0,t.jsx)("th",{style:{padding:"6px 10px",textAlign:"right"},children:"Events"}),(0,t.jsx)("th",{style:{padding:"6px 10px"},children:"Started"})]})}),(0,t.jsx)("tbody",{children:e.map(e=>{var l;let r,a=e.session_id===n;return(0,t.jsxs)("tr",{onClick:s?()=>s(e.session_id):void 0,style:{cursor:s?"pointer":"default",background:a?"rgba(237,166,62,0.15)":void 0},children:[(0,t.jsx)("td",{style:{...v,fontFamily:"ui-monospace, monospace",color:"#d8c8b8"},children:e.session_id.slice(0,12)}),(0,t.jsx)("td",{style:{...v,fontFamily:"ui-monospace, monospace",color:"#a8917c"},children:e.visitor_id.slice(0,8)}),(0,t.jsx)("td",{style:{...v,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:f(e.events)}),(0,t.jsx)("td",{style:{...v,fontSize:12,color:"#a8917c"},children:Number.isNaN((r=new Date((l=e.started_at).includes("T")?l:l.replace(" ","T")+"Z")).getTime())?l:r.toLocaleString()})]},e.session_id)})})]})})}function w({bins:e,gridSize:s,size:l=320,className:r,style:a}){let i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=i.current;if(!t)return;let n=t.getContext("2d");n&&function(e,t,s,n){if(e.clearRect(0,0,n,n),e.fillStyle=b,e.fillRect(0,0,n,n),0===t.length)return;let l=t.reduce((e,t)=>Math.max(e,t.count),0),r=n/s;for(let s of t)e.fillStyle=h(l>0?s.count/l:0,.85),e.fillRect(s.gx*r,s.gy*r,Math.ceil(r),Math.ceil(r))}(n,e,s,l)},[e,s,l]),(0,t.jsx)("canvas",{ref:i,width:l,height:l,className:r,style:a,"aria-label":"Pointer heatmap"})}function N({bins:e,gridSize:s,size:l=340,className:r,style:a}){let i=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=i.current;if(!t)return;let n=t.getContext("2d");if(!n)return;let r=Math.min(window.devicePixelRatio||1,2);t.width=l*r,t.height=l*r,n.setTransform(r,0,0,r,0,0),function(e,t,s,n){let l=n/2,r=n/2,a=n/2-18;if(e.clearRect(0,0,n,n),e.fillStyle=b,e.fillRect(0,0,n,n),e.strokeStyle="#34291f",e.lineWidth=1,e.beginPath(),e.arc(l,r,a,0,2*Math.PI),e.stroke(),e.beginPath(),e.arc(l,r,a/2,0,2*Math.PI),e.stroke(),t.length>0){let n=t.reduce((e,t)=>Math.max(e,t.count),0),i=2*Math.PI/s;for(let o of t){let t=n>0?o.count/n:0,d=1-(o.elevation_bin+1)/s,c=1-o.elevation_bin/s,u=Math.max(0,d)*a,x=Math.max(0,c)*a,m=o.azimuth_bin*i,p=m+i;e.beginPath(),e.arc(l,r,x,m,p),e.arc(l,r,u,p,m,!0),e.closePath(),e.fillStyle=h(t,.85),e.fill()}}let i=(t,s,n)=>{e.lineWidth=3,e.strokeStyle="rgba(22,18,16,0.9)",e.strokeText(t,s,n),e.fillStyle="#d8c8b8",e.fillText(t,s,n)};for(let t of(e.font="600 10px ui-sans-serif, system-ui, sans-serif",e.textAlign="left",e.textBaseline="middle",e.strokeStyle="rgba(203,213,225,0.35)",e.lineWidth=1,e.beginPath(),e.moveTo(l,r),e.lineTo(l,r-a),e.stroke(),[0,a/2,a]))e.beginPath(),e.moveTo(l-3,r-t),e.lineTo(l+3,r-t),e.stroke();i("up",l+6,r),i("horizon",l+6,r-a/2),i("down",l+6,r-a+2)}(n,e,s,l)},[e,s,l]),(0,t.jsx)("canvas",{ref:i,className:r,style:{width:l,height:l,...a},"aria-label":"Camera view-direction heatmap: top-down polar plot where the center is looking up, the middle ring is the horizon, and the rim is looking down; color shows how often each direction was viewed."})}let S={background:"rgba(32,25,19,0.6)",borderRadius:8,padding:12},k={fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"#a8917c"},P={marginTop:4,fontSize:24,fontWeight:600,color:"#f4eadf",fontVariantNumeric:"tabular-nums"};function M({label:e,value:s}){return(0,t.jsxs)("div",{style:S,children:[(0,t.jsx)("div",{style:k,children:e}),(0,t.jsx)("div",{style:P,children:s})]})}function _({perf:e}){return e&&0!==e.samples?(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:12},children:[(0,t.jsx)(M,{label:"Samples",value:f(e.samples)}),(0,t.jsx)(M,{label:"Avg FPS",value:f(e.avg_fps,1)}),(0,t.jsx)(M,{label:"p50 FPS",value:f(e.p50_fps,1)}),(0,t.jsx)(M,{label:"Min FPS",value:f(e.min_fps,1)})]}):(0,t.jsx)("p",{style:j,children:"No performance samples in range."})}var C=e.i(93425);function R({bins:e,gridSize:s}){return(0,t.jsx)(C.Panel,{title:"View-direction heatmap",subtitle:"Top-down sphere — center = looking up, rim = looking down",help:(0,t.jsxs)(t.Fragment,{children:["A flattened top-down view of where the camera pointed."," ",(0,t.jsx)("strong",{children:"Distance from the center"})," is the up/down tilt: the ",(0,t.jsx)("strong",{children:"center"})," ","is looking straight up, the ",(0,t.jsx)("strong",{children:"middle ring"})," is the horizon (level), and the"," ",(0,t.jsx)("strong",{children:"outer rim"})," is looking straight down. The"," ",(0,t.jsx)("strong",{children:"angle around the disc"})," is the facing (azimuth) direction. Color shows how often each direction was viewed, normalized to the most-viewed direction in range."]}),children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsx)(N,{bins:e,gridSize:s,className:"rounded-lg border border-edge"}),e.length>0?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-fg-muted",children:[(0,t.jsx)("span",{className:"font-medium text-fg",children:"View density"}),(0,t.jsx)("span",{children:"rarely"}),(0,t.jsx)("span",{className:"h-2 w-28 rounded-sm",style:{background:p.HEAT_GRADIENT}}),(0,t.jsx)("span",{children:"most-viewed"})]}):null]})})}function T({bins:e,cellSize:s}){let l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=l.current;if(!t)return;let s=t.getContext("2d");if(!s||(s.clearRect(0,0,360,360),s.fillStyle="#0b0e14",s.fillRect(0,0,360,360),0===e.length))return;let n=1/0,r=-1/0,a=1/0,i=-1/0,o=0;for(let t of e)t.gx<n&&(n=t.gx),t.gx>r&&(r=t.gx),t.gz<a&&(a=t.gz),t.gz>i&&(i=t.gz),t.count>o&&(o=t.count);let d=344/Math.max(r-n+1,i-a+1);for(let t of e){s.fillStyle=h(o>0?t.count/o:0,.9);let e=8+(t.gx-n)*d,l=8+(i-t.gz)*d;s.fillRect(e,l,Math.ceil(d),Math.ceil(d))}},[e,s]),(0,t.jsxs)(C.Panel,{title:"Floor-plan heatmap",subtitle:"Where visitors stand (top-down, first-person)",help:"Camera positions binned on the ground plane — the first-person counterpart of the pointer heatmap. Filter to the first-person camera mode to isolate walkable sessions.",children:[(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("canvas",{ref:l,width:360,height:360,className:"rounded-lg border border-edge","aria-label":"Floor-plan position heatmap"})}),0===e.length?(0,t.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"No camera-position data in range. Capture a first-person session to populate the plan."}):null]})}function z(e){return null==e?"":new Date(e-6e4*new Date(e).getTimezoneOffset()).toISOString().slice(0,16)}function $(e){if(!e)return;let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}function E({filters:e,scenes:s,onChange:n,busy:l}){let r=t=>n({...e,...t});return(0,t.jsxs)("section",{className:"mb-6 flex flex-wrap items-end gap-x-4 gap-y-3 rounded-xl border border-edge bg-panel p-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-fg-muted",children:"Time window"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-1",role:"group","aria-label":"Time window",children:[i.map(s=>{let n=e.window===s.id;return(0,t.jsx)("button",{type:"button",onClick:()=>r({window:s.id}),className:`rounded-md border px-2.5 py-1.5 text-xs transition ${n?"border-amber bg-amber/10 text-saffron":"border-edge text-fg hover:border-amber/60 hover:text-fg-hi"}`,children:s.label},s.id)}),(0,t.jsx)("button",{type:"button",onClick:()=>r({window:"custom",since:e.since??Date.now()-864e5,until:e.until??Date.now()}),className:`rounded-md border px-2.5 py-1.5 text-xs transition ${"custom"===e.window?"border-amber bg-amber/10 text-saffron":"border-edge text-fg hover:border-amber/60 hover:text-fg-hi"}`,children:"Custom"})]})]}),"custom"===e.window?(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["From",(0,t.jsx)("input",{type:"datetime-local",value:z(e.since),onChange:e=>r({since:$(e.target.value)}),className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["To",(0,t.jsx)("input",{type:"datetime-local",value:z(e.until),onChange:e=>r({until:$(e.target.value)}),className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron"})]})]}):null,(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Scene",(0,t.jsxs)("select",{value:e.scene??"",onChange:e=>r({scene:e.target.value||void 0}),className:"min-w-40 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,t.jsx)("option",{value:"",children:"All scenes"}),s.map(e=>(0,t.jsxs)("option",{value:e.scene_id,children:[e.scene_id," (",e.events.toLocaleString(),")"]},e.scene_id))]})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Input source",(0,t.jsxs)("select",{value:e.source??"",onChange:e=>r({source:e.target.value||void 0}),className:"min-w-36 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,t.jsx)("option",{value:"",children:"All sources"}),m.map(e=>(0,t.jsx)("option",{value:e,children:x(e)},e))]})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Camera mode",(0,t.jsxs)("select",{value:e.cameraMode??"",onChange:e=>r({cameraMode:e.target.value||void 0}),className:"min-w-36 rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",children:[(0,t.jsx)("option",{value:"",children:"All cameras"}),(0,t.jsx)("option",{value:"viewer",children:"Viewer (orbit)"}),(0,t.jsx)("option",{value:"first-person",children:"First-person (walk)"})]})]}),(0,t.jsx)("span",{className:`ml-auto text-xs ${l?"text-saffron":"text-fg-muted"}`,"aria-live":"polite",children:l?"Refreshing…":"Up to date"})]})}function A({rows:e}){let s=function(e){let t=new Map;for(let s of e){let e=t.get(s.source);e||(e={source:s.source,total:0,sessions:0,byType:[]},t.set(s.source,e)),e.total+=s.count,e.sessions=Math.max(e.sessions,s.sessions),e.byType.push({event_type:s.event_type,count:s.count})}for(let e of t.values())e.byType.sort((e,t)=>t.count-e.count);return[...t.values()].sort((e,t)=>t.total-e.total)}(e),n=s.reduce((e,t)=>Math.max(e,t.total),0);return(0,t.jsx)(C.Panel,{title:"Input sources",subtitle:"Interactions by input source",children:0===s.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No source-bearing interactions in range."}):(0,t.jsx)("ul",{className:"space-y-3",children:s.map(e=>(0,t.jsxs)("li",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"font-medium text-fg",children:x(e.source)}),(0,t.jsxs)("span",{className:"tabular-nums text-fg-muted",children:[f(e.total),(0,t.jsxs)("span",{className:"ml-1 text-xs text-fg-muted",children:["· ",f(e.sessions)," ",1===e.sessions?"session":"sessions"]})]})]}),(0,t.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,t.jsx)("div",{className:"h-full rounded bg-amber",style:{width:`${n>0?e.total/n*100:0}%`}})}),(0,t.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.byType.map(e=>{let s;return(0,t.jsxs)("span",{className:"rounded bg-ink/60 px-1.5 py-0.5 font-mono text-[11px] text-fg-muted",children:[(s=e.event_type.replace(/_/g," ")).charAt(0).toUpperCase()+s.slice(1)," ",f(e.count)]},e.event_type)})})]},e.source))})})}function I({perf:e}){return(0,t.jsx)(C.Panel,{title:"Rendering performance",subtitle:"frame_perf samples",children:(0,t.jsx)(_,{perf:e})})}function D({label:e,value:s,unit:n}){return(0,t.jsxs)("div",{className:"rounded-lg bg-ink/60 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,t.jsxs)("div",{className:"mt-1 text-2xl font-semibold tabular-nums text-fg-hi",children:[s,n?(0,t.jsx)("span",{className:"ml-1 text-sm font-normal text-fg-muted",children:n}):null]})]})}function F(e){return f(e/1048576,1)}function L({bins:e}){if(0===e.length)return(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No FPS samples in range."});let s=[...e].sort((e,t)=>e.bucket-t.bucket),n=s.reduce((e,t)=>Math.max(e,t.sessions),0)||1,l=s.length>1?s[1].bucket-s[0].bucket:10;return(0,t.jsx)("div",{className:"space-y-1.5",children:s.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsxs)("span",{className:"w-16 shrink-0 text-right tabular-nums text-fg-muted",children:[e.bucket,"–",e.bucket+l]}),(0,t.jsx)("div",{className:"h-4 flex-1 overflow-hidden rounded bg-ink/60",children:(0,t.jsx)("div",{className:"h-full rounded bg-emerald-500/70",style:{width:`${e.sessions/n*100}%`}})}),(0,t.jsx)("span",{className:"w-10 shrink-0 tabular-nums text-fg-muted",children:e.sessions})]},e.bucket))})}function U({data:e}){let{distribution:s,histogram:n,frameTime:l,jank:r,byDevice:a,byScene:i,resources:o,stability:d}=e,c=(s?.samples??0)>0;return(0,t.jsxs)("section",{className:"space-y-4",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold uppercase tracking-wide text-fg-muted",children:"Performance"}),(0,t.jsx)(C.Panel,{title:"FPS distribution",subtitle:"per-session p05 / p50 / p95, summarized across sessions",children:c?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,t.jsx)(D,{label:"p05 FPS (worst)",value:f(s.p05_fps,1)}),(0,t.jsx)(D,{label:"p50 FPS (typical)",value:f(s.p50_fps,1)}),(0,t.jsx)(D,{label:"p95 FPS (best)",value:f(s.p95_fps,1)}),(0,t.jsx)(D,{label:"Sessions",value:f(s.sessions)})]}),(0,t.jsx)(L,{bins:n})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No performance samples in range."})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsx)(C.Panel,{title:"Frame time",subtitle:"per-session median & worst-window p95",children:l&&0!==l.sessions?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(D,{label:"p50 frame time",value:f(l.p50_ms,1),unit:"ms"}),(0,t.jsx)(D,{label:"p95 frame time",value:f(l.p95_ms,1),unit:"ms"})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No frame-time samples in range."})}),(0,t.jsx)(C.Panel,{title:"Jank",subtitle:"long frames per sample window",children:r&&0!==r.sessions?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(D,{label:"Median session",value:f(r.median_rate,2)}),(0,t.jsx)(D,{label:"Worst decile",value:f(r.worst_decile_rate,2)})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No jank data in range."})})]}),(0,t.jsx)(C.Panel,{title:"FPS by device",subtitle:"per-session median FPS, attributed to session_start.device",children:0===a.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No device data in range."}):(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,t.jsx)("thead",{className:"text-xs uppercase tracking-wide text-fg-muted",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Backend"}),(0,t.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Mobile"}),(0,t.jsx)("th",{className:"py-1 pr-4 font-medium",children:"GPU"}),(0,t.jsx)("th",{className:"py-1 pr-4 text-right font-medium",children:"Sessions"}),(0,t.jsx)("th",{className:"py-1 text-right font-medium",children:"p50 FPS"})]})}),(0,t.jsx)("tbody",{className:"text-fg",children:a.map((e,s)=>(0,t.jsxs)("tr",{className:"border-t border-ink/60",children:[(0,t.jsx)("td",{className:"py-1 pr-4",children:e.engine||"—"}),(0,t.jsx)("td",{className:"py-1 pr-4",children:"true"===e.is_mobile?"yes":"no"}),(0,t.jsx)("td",{className:"py-1 pr-4 max-w-[16rem] truncate",title:e.renderer,children:e.renderer||"—"}),(0,t.jsx)("td",{className:"py-1 pr-4 text-right tabular-nums",children:f(e.sessions)}),(0,t.jsx)("td",{className:"py-1 text-right tabular-nums",children:f(e.p50_fps,1)})]},`${e.engine}|${e.is_mobile}|${e.renderer}|${s}`))})]})})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsx)(C.Panel,{title:"FPS by scene",subtitle:"per-session median FPS per scene",children:0===i.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No scene data in range."}):(0,t.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,t.jsx)("thead",{className:"text-xs uppercase tracking-wide text-fg-muted",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"py-1 pr-4 font-medium",children:"Scene"}),(0,t.jsx)("th",{className:"py-1 pr-4 text-right font-medium",children:"Sessions"}),(0,t.jsx)("th",{className:"py-1 text-right font-medium",children:"p50 FPS"})]})}),(0,t.jsx)("tbody",{className:"text-fg",children:i.map(e=>(0,t.jsxs)("tr",{className:"border-t border-ink/60",children:[(0,t.jsx)("td",{className:"py-1 pr-4",children:e.scene_id||"—"}),(0,t.jsx)("td",{className:"py-1 pr-4 text-right tabular-nums",children:f(e.sessions)}),(0,t.jsx)("td",{className:"py-1 text-right tabular-nums",children:f(e.p50_fps,1)})]},e.scene_id))})]})}),(0,t.jsx)(C.Panel,{title:"Stability",subtitle:"hard failures frame_perf can't show",children:d?(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,t.jsx)(D,{label:"Context losses",value:f(d.context_losses)}),(0,t.jsx)(D,{label:"Compile stalls",value:f(d.compile_stalls)}),(0,t.jsx)(D,{label:"Incidents",value:f(d.incidents)})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No stability data in range."})})]}),(0,t.jsx)(C.Panel,{title:"Resource footprint",subtitle:"per-session p50 / p95 of what the scene asked of the device",children:o&&0!==o.sessions?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[(0,t.jsx)(D,{label:"p50 JS heap",value:F(o.p50_js_heap_bytes),unit:"MB"}),(0,t.jsx)(D,{label:"p50 texture",value:F(o.p50_texture_bytes),unit:"MB"}),(0,t.jsx)(D,{label:"p50 triangles",value:f(o.p50_triangles)}),(0,t.jsx)(D,{label:"p95 JS heap",value:F(o.p95_js_heap_bytes),unit:"MB"}),(0,t.jsx)(D,{label:"p95 texture",value:F(o.p95_texture_bytes),unit:"MB"}),(0,t.jsx)(D,{label:"p95 triangles",value:f(o.p95_triangles)})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No resource samples in range."})})]})}function O({bins:e,gridSize:s}){return(0,t.jsx)(C.Panel,{title:"Pointer heatmap",subtitle:"Normalized screen positions",children:(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)(w,{bins:e,gridSize:s,className:"rounded-lg border border-edge"})})})}function B({label:e,value:s,tone:n="neutral",hint:l}){return(0,t.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,t.jsx)("p",{className:`mt-0.5 text-lg font-semibold tabular-nums ${"bad"===n?"text-red-300":"warn"===n?"text-amber-300":"good"===n?"text-emerald-300":"text-fg-hi"}`,children:s}),l?(0,t.jsx)("p",{className:"text-[11px] text-fg-muted",children:l}):null]})}function G({counts:e,perf:s}){let n=new Map(e.map(e=>[e.event_type,e.count])),l=e=>n.get(e)??0,r=l("session_start"),a=l("runtime_error"),i=l("context_lost"),o=l("focus_change"),d=l("visibility_change"),c=l("viewport_resize"),u=e.reduce((e,t)=>e+t.count,0),x=r>0?a/r:0;return(0,t.jsx)(C.Panel,{title:"Scene health",subtitle:"Errors, GPU context loss & attention gaps in the selected window",children:u>0?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:[(0,t.jsx)(B,{label:"Errors",value:f(a),tone:a>0?"bad":"good",hint:r>0?`${x.toFixed(2)} / session`:void 0}),(0,t.jsx)(B,{label:"Context loss",value:f(i),tone:i>0?"warn":"good",hint:"GPU device lost"}),(0,t.jsx)(B,{label:"Avg FPS",value:s&&s.samples>0?f(s.avg_fps,1):"—",tone:s&&s.samples>0?s.avg_fps>=50?"good":"warn":"neutral",hint:s&&s.samples>0?`min ${f(s.min_fps,0)}`:void 0}),(0,t.jsx)(B,{label:"Sessions",value:f(r)}),(0,t.jsx)(B,{label:"Attention",value:f(o+d),hint:"focus + visibility changes"}),(0,t.jsx)(B,{label:"Resizes",value:f(c),hint:"viewport changes"})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No events in range."})})}function H({label:e,value:s,hint:n}){return(0,t.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:e}),(0,t.jsx)("p",{className:"mt-0.5 text-lg font-semibold tabular-nums text-fg-hi",children:s}),n?(0,t.jsx)("p",{className:"text-[11px] text-fg-muted",children:n}):null]})}function K({buckets:e,bucketSize:s}){if(0===e.length)return(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No camera samples in range."});let n=[...e].sort((e,t)=>e.bucket-t.bucket),l=n.reduce((e,t)=>Math.max(e,t.count),0)||1;return(0,t.jsx)("div",{className:"flex flex-col gap-1",children:n.map(e=>{let n=e.bucket*s;return(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"w-24 shrink-0 text-right font-mono text-[11px] text-fg-muted",children:[f(n,1),"–",f(n+s,1)]}),(0,t.jsx)("div",{className:"h-3.5 flex-1 overflow-hidden rounded-sm bg-ink/60",children:(0,t.jsx)("div",{className:"h-full rounded-sm bg-amber",style:{width:`${e.count/l*100}%`}})}),(0,t.jsx)("span",{className:"w-12 shrink-0 text-right font-mono text-[11px] text-fg-muted",children:f(e.count)})]},e.bucket)})})}function V({coverage:e,cellSize:s,distance:n,bucketSize:l,navigation:r}){let a=e.length,i=e.reduce((e,t)=>e+t.count,0),o=r.reduce((e,t)=>e+t.total_distance,0),d=r.reduce((e,t)=>e+t.segments,0),c=r.reduce((e,t)=>e+t.active_segments,0),u=r.length,x=a>0||r.length>0;return(0,t.jsx)(C.Panel,{title:"Scene traversal",subtitle:"Coverage, camera distance & navigation effort — derived from camera_sample",collapsible:!0,defaultCollapsed:!0,children:x?(0,t.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[(0,t.jsx)(H,{label:"Visited cells",value:f(a),hint:`${f(s,2)} u voxels`}),(0,t.jsx)(H,{label:"Camera samples",value:f(i)}),(0,t.jsx)(H,{label:"Avg travel",value:f(u>0?o/u:0,1),hint:u>0?`over ${f(u)} sessions`:void 0}),(0,t.jsx)(H,{label:"Active movement",value:`${f(100*(d>0?c/d:0),0)}%`,hint:"of camera segments"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1.5 text-xs uppercase tracking-wide text-fg-muted",children:"Camera distance distribution"}),(0,t.jsx)(K,{buckets:n,bucketSize:l})]})]}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No camera samples in range."})})}let W={babylon:"Babylon.js","babylon-lite":"Babylon (lite)",three:"three.js",playcanvas:"PlayCanvas",r3f:"react-three-fiber",aframe:"A-Frame"};function J({project:e,playgroundUrl:s,onView:l,onOpenOverlay:r}){var a;let i=e.scene,o=i?.engines.length?i.engines:[],[d,c]=(0,n.useState)(i?.defaultEngine??o[0]??""),u=s.length>0&&d.length>0;return(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-edge bg-panel p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-fg-hi",children:i?.label??e.name}),(0,t.jsx)("p",{className:"text-xs text-fg-muted",children:e.name})]}),i?(0,t.jsx)("span",{className:"shrink-0 rounded-full border border-edge bg-ink/50 px-2 py-0.5 text-[11px] text-fg-muted",children:"first-person"===i.cameraMode?"first-person":"viewer"}):null]}),i?.description?(0,t.jsx)("p",{className:"text-xs leading-relaxed text-fg-muted",children:i.description}):(0,t.jsx)("p",{className:"text-xs leading-relaxed text-fg-muted",children:"A project without scene metadata — open its analytics directly."}),o.length>1?(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-[11px] text-fg-muted",children:["Engine",(0,t.jsx)("select",{className:"rounded-md border border-edge bg-ink px-2 py-1.5 text-xs text-fg outline-none focus:border-saffron",value:d,onChange:e=>c(e.target.value),children:o.map(e=>(0,t.jsx)("option",{value:e,children:W[e]??e},e))})]}):1===o.length?(0,t.jsxs)("p",{className:"text-[11px] text-fg-muted",children:["Engine: ",W[a=o[0]]??a]}):null,(0,t.jsxs)("div",{className:"mt-auto flex flex-wrap gap-2 pt-1",children:[(0,t.jsx)("button",{type:"button",onClick:()=>l(e),className:"rounded-md bg-amber px-3 py-1.5 text-xs font-medium text-ink transition hover:bg-ember",children:"View analytics"}),i?(0,t.jsx)("button",{type:"button",disabled:!u,onClick:()=>r(e,d),className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi disabled:opacity-40",children:"Open live scene"}):null]})]})}function Q({projects:e,playgroundUrl:s,onView:l}){let[r,a]=(0,n.useState)(null),i=(0,n.useMemo)(()=>{let t=[],s=[],n=[];for(let l of e)l.scene?"first-person"===l.scene.cameraMode?s.push(l):t.push(l):n.push(l);return{viewer:t,firstPerson:s,other:n}},[e]),o=(e,t)=>{let n=e.scene;n&&s&&a({url:`${s.replace(/\/$/,"")}/?scene=${encodeURIComponent(n.id)}&engine=${encodeURIComponent(t)}`,title:`${n.label} \xb7 ${W[t]??t}`})},d=(e,n)=>n.length>0?(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-fg-muted",children:e}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:n.map(e=>(0,t.jsx)(J,{project:e,playgroundUrl:s,onView:l,onOpenOverlay:o},e.id))})]}):null;return(0,t.jsxs)(C.Panel,{title:"Scenes",subtitle:"Pick a scene to explore its analytics, or open it live to test capture.",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[d("Viewer",i.viewer),d("First-person",i.firstPerson),d("Other projects",i.other)]}),r?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/70 p-4 sm:p-8",role:"dialog","aria-modal":"true","aria-label":"Live scene overlay",children:(0,t.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-edge bg-panel",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-edge px-4 py-2.5",children:[(0,t.jsx)("p",{className:"text-sm text-fg",children:r.title}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("a",{href:r.url,target:"_blank",rel:"noreferrer",className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Open in new tab ↗"}),(0,t.jsx)("button",{type:"button",onClick:()=>a(null),className:"rounded-md border border-edge px-3 py-1.5 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Close ✕"})]})]}),(0,t.jsx)("iframe",{title:r.title,src:r.url,className:"h-full w-full flex-1 bg-ink"})]})}):null]})}function X({sessions:e,onSelect:s,selectedId:n}){return(0,t.jsx)(C.Panel,{title:"Sessions",subtitle:s?`${e.length} most recent \xb7 select to drill in`:`${e.length} most recent`,children:(0,t.jsx)(y,{sessions:e,onSelect:s,selectedId:n})})}function q({meshes:e}){let s=e.reduce((e,t)=>Math.max(e,t.count),0);return(0,t.jsx)(C.Panel,{title:"Top meshes",subtitle:"Most-interacted meshes",children:0===e.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"No mesh interactions in range."}):(0,t.jsx)("ul",{className:"space-y-1.5",children:e.map(e=>(0,t.jsxs)("li",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"truncate font-mono text-xs text-fg",children:e.mesh}),(0,t.jsx)("span",{className:"tabular-nums text-fg-muted",children:f(e.count)})]}),(0,t.jsx)("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded bg-ink/60",children:(0,t.jsx)("div",{className:"h-full rounded bg-amber",style:{width:`${s>0?e.count/s*100:0}%`}})})]},e.mesh))})})}function Y({baseUrl:e,apiKey:s,sessionId:l,scene:a}){let i=(0,n.useRef)(null),[o,d]=(0,n.useState)([]),[c,u]=(0,n.useState)("loading");return(0,n.useEffect)(()=>{let t=!1;return u("loading"),new r.CollectorApi(e,s).sessionTrajectory(l,{scene:a,limit:5e3}).then(e=>{t||(d(e),u("ready"))}).catch(()=>{t||(d([]),u("error"))}),()=>{t=!0}},[e,s,l,a]),(0,n.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.getContext("2d");if(!t||(t.clearRect(0,0,360,360),t.fillStyle="#0b0e14",t.fillRect(0,0,360,360),0===o.length))return;let s=1/0,n=-1/0,l=1/0,r=-1/0;for(let e of o)e.x<s&&(s=e.x),e.x>n&&(n=e.x),e.z<l&&(l=e.z),e.z>r&&(r=e.z);let a=328/Math.max(n-s,r-l,.001),d=e=>[16+(e.x-s)*a,16+(r-e.z)*a];t.lineWidth=2,t.strokeStyle="#38bdf8",t.beginPath(),o.forEach((e,s)=>{let[n,l]=d(e);0===s?t.moveTo(n,l):t.lineTo(n,l)}),t.stroke();let c=o[0],u=o[o.length-1];if(c){let[e,s]=d(c);t.fillStyle="#22c55e",t.beginPath(),t.arc(e,s,5,0,2*Math.PI),t.fill()}if(u){let[e,s]=d(u);t.fillStyle="#ef4444",t.beginPath(),t.arc(e,s,5,0,2*Math.PI),t.fill()}},[o]),(0,t.jsxs)(C.Panel,{title:"Walked path",subtitle:"Camera trajectory (top-down)",help:"The ordered route this session's camera took across the X/Z ground plane — green is the start, red is the end. Meaningful for first-person (walkable) sessions.",children:[(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("canvas",{ref:i,width:360,height:360,className:"rounded-lg border border-edge","aria-label":"Session camera trajectory"})}),"loading"===c?(0,t.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"Loading trajectory…"}):"error"===c?(0,t.jsx)("p",{className:"mt-2 text-center text-xs text-red-400",children:"Failed to load trajectory."}):0===o.length?(0,t.jsx)("p",{className:"mt-2 text-center text-xs text-fg-muted",children:"No camera movement recorded for this session."}):null]})}function Z(e){return e>=36e5?`${Math.round(e/36e5)}h`:e>=6e4?`${Math.round(e/6e4)}m`:e>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function ee({buckets:e,intervalMs:s,onBrush:l,onClear:r,brushed:a}){let i=(0,n.useRef)(null),o=(0,n.useRef)(null),[d,c]=(0,n.useState)(640),u=(0,n.useRef)(null),[x,m]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>c(Math.max(320,e.clientWidth));t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[]);let p={x:40,y:14,w:Math.max(1,d-40-36),h:114},h=e.length>0?{start:e[0].bucket,end:e[e.length-1].bucket+s}:null,f=(0,n.useCallback)(e=>{if(!h)return 0;let t=(e-p.x)/p.w;return Math.round(h.start+Math.max(0,Math.min(1,t))*(h.end-h.start))},[h,p.x,p.w]);(0,n.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.getContext("2d");if(!n)return;if(n.clearRect(0,0,d,150),n.fillStyle="#0b0e14",n.fillRect(0,0,d,150),0===e.length||!h){n.fillStyle="#64748b",n.font="12px system-ui, sans-serif",n.textAlign="center",n.fillText("No events in range",d/2,75);return}let l=e.reduce((e,t)=>Math.max(e,t.events),0)||1,r=h.end-h.start,a=Math.max(1,p.w/e.length*.8);for(let t of e){let e=p.x+(t.bucket-h.start)/r*p.w,s=t.events/l*p.h;n.fillStyle="rgba(56, 189, 248, 0.55)",n.fillRect(e,p.y+p.h-s,a,s)}if(n.font="10px system-ui, sans-serif",n.textBaseline="middle",n.fillStyle="rgba(56, 189, 248, 0.95)",n.textAlign="right",n.fillText(String(l),p.x-5,p.y+4),n.fillText("0",p.x-5,p.y+p.h),n.textBaseline="alphabetic",n.fillStyle="rgba(56, 189, 248, 0.7)",n.textAlign="left",n.fillText(`events / ${Z(s)}`,p.x,144),x){let e=Math.min(x.x0,x.x1),t=Math.max(x.x0,x.x1);n.fillStyle="rgba(56, 189, 248, 0.18)",n.fillRect(e,p.y,t-e,p.h),n.strokeStyle="rgba(56, 189, 248, 0.8)",n.lineWidth=1,n.strokeRect(e,p.y,t-e,p.h)}},[e,d,h,x,s,p.x,p.y,p.w,p.h]);let g=()=>{let e=u.current;if(u.current=null,m(null),!e||4>Math.abs(e.x1-e.x0))return;let t=f(Math.min(e.x0,e.x1)),s=f(Math.max(e.x0,e.x1));s>t&&l(t,s)};return(0,t.jsx)(C.Panel,{title:"Event volume over time",subtitle:`Bars: events per ${Z(s)} \xb7 drag to zoom the time window`,children:(0,t.jsxs)("div",{ref:i,className:"relative",children:[(0,t.jsx)("canvas",{ref:o,width:d,height:150,className:"w-full cursor-crosshair rounded-lg border border-edge",onMouseDown:e=>{let t=e.currentTarget.getBoundingClientRect(),s=e.clientX-t.left;u.current={x0:s,x1:s},m({x0:s,x1:s})},onMouseMove:e=>{if(!u.current)return;let t=e.currentTarget.getBoundingClientRect(),s={...u.current,x1:e.clientX-t.left};u.current=s,m(s)},onMouseUp:g,onMouseLeave:g,"aria-label":"Event volume time series"}),a&&r?(0,t.jsx)("button",{type:"button",onClick:r,className:"absolute right-2 top-2 rounded-md border border-edge bg-ink/80 px-2 py-1 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:"Clear zoom"}):null]})})}var et=e.i(19761);function es({label:e,value:s}){return(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-3 py-0.5",children:[(0,t.jsx)("span",{className:"shrink-0 text-xs text-fg-muted",children:e}),(0,t.jsx)("span",{className:"min-w-0 truncate text-right font-mono text-xs text-fg",title:s,children:s})]})}function en({title:e,rows:s}){return 0===s.length?null:(0,t.jsxs)("div",{className:"rounded-lg border border-edge bg-ink/40 p-3",children:[(0,t.jsx)("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-fg-muted",children:e}),s.map(([e,s])=>(0,t.jsx)(es,{label:e,value:s},e))]})}function el(e){let t=[];for(let[s,n]of e){let e=null==n||""===n?null:Array.isArray(n)?n.join(" × "):"boolean"==typeof n?n?"yes":"no":"object"==typeof n?JSON.stringify(n):String(n);null!=e&&t.push([s,e])}return t}function er({baseUrl:e,apiKey:s,sessionId:l,hiddenTypes:r,onToggleType:a,onSetAllHidden:i}){let o,d,c,[u,x]=(0,n.useState)([]),[m,p]=(0,n.useState)("loading"),[h,f]=(0,n.useState)(null),[g,b]=(0,n.useState)(new Set);(0,n.useEffect)(()=>{let t=!1;return p("loading"),f(null),x([]),b(new Set),(async()=>{try{let n=await (0,et.fetchSessionEvents)({endpoint:e,apiKey:s,sessionId:l});if(t)return;x(n),p(0===n.length?"empty":"ready")}catch(e){if(t)return;p("error"),f(e instanceof Error?e.message:"Failed to load session data.")}})(),()=>{t=!0}},[e,s,l]);let{meta:j,byType:v,allTypes:y,sorted:w}=(0,n.useMemo)(()=>{let e=[...u].sort((e,t)=>e.ts-t.ts),t=new Map;for(let s of e)t.set(s.type,(t.get(s.type)??0)+1);let s=[...t.keys()].sort(),n=e[0];return{meta:{start:n,end:e[e.length-1],startEvent:e.find(e=>"session_start"===e.type)},byType:t,allTypes:s,sorted:e}},[u]);if("ready"!==m)return(0,t.jsx)(C.Panel,{title:"Session data",subtitle:"Metadata and captured event breakdown",children:(0,t.jsx)("p",{className:"py-6 text-center text-sm text-fg-muted",children:"loading"===m?"Loading session data…":"empty"===m?"No events captured for this session.":h??"Session data unavailable."})});let N=j.start,S=j.end,k=j.startEvent,P=N&&S?S.ts-N.ts:0,M=e=>e?new Date(e).toLocaleString():"—",_=N?.pageMeta,R=el([["Project",N?.projectId],["Session",N?.sessionId],["Visitor",N?.visitorId],["SDK",N?.sdkVersion],["Scene ID",N?.sceneId],["URL",N?.url],["Started",M(N?.ts)],["Ended",M(S?.ts)],["Duration",(d=Math.floor((o=Math.round(P/1e3))/60),c=o%60,d>0?`${d}m ${c}s`:`${c}s`)],["Events",String(w.length)]]),T=_?el([["Title",_.title],["Language",_.language],["Referrer",_.referrer],["Viewport",_.viewport],["Device pixel ratio",_.devicePixelRatio]]):[],z=k?.type==="session_start"?k.device:void 0,$=k?.type==="session_start"?k.graphics:void 0,E=k?.type==="session_start"?k.scene:void 0,A=k?.type==="session_start"?k.connector:void 0,I=k?.type==="session_start"?k.user:void 0,D=el([["Engine",z?.engine],["Graphics API",$?.api],["Backend",$?.backend],["API version",$?.apiVersion],["Shading language",$?.shadingLanguage],["GPU vendor",z?.vendor],["GPU renderer",z?.renderer],["Max texture size",z?.maxTextureSize],["CPU cores",z?.hardwareConcurrency],["Device memory (GB)",z?.deviceMemoryGb],["Mobile",z?.isMobile]]),F=el([["Connector",A?[A.name,A.version].filter(Boolean).join(" "):null],["Coordinate system",A?.coordinateSystem],["Description",E?.description],["Camera type",E?.cameraType],["Camera name",E?.cameraName],["Mesh count",E?.meshCount],["User id",I?.id],["User traits",I?.traits]]),L=y.every(e=>r.has(e));return(0,t.jsxs)(C.Panel,{title:"Session data",subtitle:"Metadata that was sent and a per-feature breakdown — toggle a type to show/hide it in the replay, expand to inspect raw payloads",help:(0,t.jsxs)(t.Fragment,{children:["Project-level metadata beyond the ",(0,t.jsx)("strong",{children:"Project ID"}),"isn't stored in the OSS collector (Phase 1) — everything here is derived from the session's own events. The"," ",(0,t.jsx)("strong",{children:"Device / graphics"})," and ",(0,t.jsx)("strong",{children:"Scene / connector"})," blocks come from the one-time ",(0,t.jsx)("code",{children:"session_start"})," event."]}),children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,t.jsx)(en,{title:"Identity",rows:R}),(0,t.jsx)(en,{title:"Page context",rows:T}),(0,t.jsx)(en,{title:"Device / graphics",rows:D}),(0,t.jsx)(en,{title:"Scene / connector",rows:F})]}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-fg-muted",children:["Captured features (",y.length," event types)"]}),(0,t.jsx)("button",{type:"button",onClick:()=>i(!L,y),className:"rounded-md border border-edge px-2 py-1 text-xs text-fg transition hover:border-amber hover:text-fg-hi",children:L?"Show all":"Hide all"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2 lg:grid-cols-3",children:y.map(e=>{let s=!r.has(e),n=g.has(e),l=w.filter(t=>t.type===e).slice(0,3);return(0,t.jsxs)("div",{className:`self-start rounded-lg border border-edge bg-ink/40 ${n?"sm:col-span-2 lg:col-span-3":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[(0,t.jsxs)("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[(0,t.jsx)("input",{type:"checkbox",checked:s,onChange:()=>a(e),className:"accent-amber"}),(0,t.jsx)("span",{className:"truncate font-mono text-xs text-fg",children:e})]}),(0,t.jsx)("span",{className:"tabular-nums text-xs text-fg-muted",children:v.get(e)}),(0,t.jsx)("button",{type:"button",onClick:()=>b(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s}),"aria-expanded":n?"true":"false",className:"rounded border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted transition hover:border-amber hover:text-fg-hi",children:n?"Hide raw":"Raw"})]}),n?(0,t.jsxs)("pre",{className:"max-h-64 overflow-auto border-t border-edge bg-black/30 px-3 py-2 text-[10px] leading-relaxed text-fg",children:[l.map(e=>JSON.stringify(e,null,2)).join("\n\n"),(v.get(e)??0)>l.length?`
|
|
2
|
+
|
|
3
|
+
… ${(v.get(e)??0)-l.length} more`:""]}):null]},e)})})]})]})}function ea(e){return e.length>10?`${e.slice(0,8)}…`:e}function ei(e,t){let s=Math.max(0,Math.round((t-e)/1e3));if(s<60)return`${s}s ago`;let n=Math.floor(s/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}let eo={active:"bg-emerald-400",recent:"bg-amber-400",idle:"bg-fg-muted"},ed={idle:"offline",connecting:"connecting…",open:"live",reconnecting:"reconnecting…"};function ec({status:e,sessions:s}){let n="open"===e;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 rounded-full border border-edge bg-ink px-3 py-1 text-xs",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[n?(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}):null,(0,t.jsx)("span",{className:`relative inline-flex h-2 w-2 rounded-full ${n?"bg-emerald-400":"idle"===e?"bg-fg-muted":"bg-amber-400"}`})]}),(0,t.jsx)("span",{className:"font-medium text-fg",children:n?`${f(s)} live now`:ed[e]})]})}function eu({snapshot:e,status:s,feed:n,now:l,onSelectSession:r}){let a=e?.sessions??[],i=e?.activeSessions??0,o=e?.activeVisitors??0;return(0,t.jsxs)(C.Panel,{title:"Live now",subtitle:"Active sessions and a real-time event feed, updating in place.",help:(0,t.jsx)(t.Fragment,{children:"Sessions seen within the liveness window, streamed over SSE from the collector. The roster is intentionally non-identifying — no geo, user-agent, or visitor id. Click a session to follow it live."}),children:[(0,t.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[(0,t.jsx)(ec,{status:s,sessions:i}),(0,t.jsxs)("span",{className:"text-xs text-fg-muted",children:[(0,t.jsx)("span",{className:"font-semibold text-fg",children:f(o)})," visitor",1===o?"":"s"]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"mb-2 text-xs uppercase tracking-wide text-fg-muted",children:["Sessions (",a.length,")"]}),0===a.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"open"===s?"No active sessions right now.":"Waiting for live data…"}):(0,t.jsx)("ul",{className:"flex max-h-64 flex-col gap-1 overflow-y-auto pr-1",children:a.map(e=>(0,t.jsx)("li",{children:r?(0,t.jsxs)("button",{type:"button",onClick:()=>r(e.sessionId),className:"flex w-full items-center gap-2 rounded-md border border-transparent px-2 py-1.5 text-left transition hover:border-edge hover:bg-ink",children:[(0,t.jsx)("span",{className:`h-2 w-2 flex-none rounded-full ${eo[e.activity]}`,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-mono text-xs text-fg",children:ea(e.sessionId)}),(0,t.jsx)("span",{className:"truncate text-xs text-fg-muted",children:e.sceneId}),(0,t.jsx)("span",{className:"ml-auto flex-none text-xs text-fg-muted",children:ei(e.lastSeen,l)})]}):(0,t.jsxs)("div",{className:"flex w-full items-center gap-2 px-2 py-1.5",children:[(0,t.jsx)("span",{className:`h-2 w-2 flex-none rounded-full ${eo[e.activity]}`,"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-mono text-xs text-fg",children:ea(e.sessionId)}),(0,t.jsx)("span",{className:"truncate text-xs text-fg-muted",children:e.sceneId}),(0,t.jsx)("span",{className:"ml-auto flex-none text-xs text-fg-muted",children:ei(e.lastSeen,l)})]})},e.sessionId))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-xs uppercase tracking-wide text-fg-muted",children:"Event feed"}),0===n.length?(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"open"===s?"Listening for events…":"Waiting for live data…"}):(0,t.jsx)("ul",{className:"flex max-h-64 flex-col gap-1 overflow-y-auto pr-1 font-mono text-xs",children:n.map((e,s)=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-2 py-1",children:[(0,t.jsx)("span",{className:"flex-none rounded bg-amber/15 px-1.5 py-0.5 text-[11px] text-saffron",children:e.type}),(0,t.jsx)("span",{className:"text-fg-muted",children:ea(e.sessionId)}),(0,t.jsx)("span",{className:"ml-auto flex-none text-fg-muted",children:ei(e.ts,l)})]},`${e.sessionId}-${e.ts}-${s}`))})]})]})]})}let ex=(0,s.default)(()=>e.A(69091).then(e=>e.SessionReplay),{loadableGenerated:{modules:[12449]},ssr:!1}),em=(0,s.default)(()=>e.A(33996).then(e=>e.WorldHeatmap3D),{loadableGenerated:{modules:[25453]},ssr:!1}),ep=(0,s.default)(()=>e.A(58913).then(e=>e.CameraDome3D),{loadableGenerated:{modules:[98568]},ssr:!1}),eh=(0,s.default)(()=>e.A(56403).then(e=>e.ClickRays3D),{loadableGenerated:{modules:[61518]},ssr:!1}),ef=(0,s.default)(()=>e.A(70019).then(e=>e.FlowSankey3D),{loadableGenerated:{modules:[36471]},ssr:!1}),eg={sessions:[],pointer:[],camera:[],meshes:[],perf:null,world:[],gaze:[],clickRays:[],flowLinks:[],flowQuery:{},hasFirstPerson:!1,proxyMeshes:[],timeseries:[],counts:[],coverage:[],distance:[],navigation:[],sources:[],floorPlan:[],performance:{distribution:null,histogram:[],frameTime:null,jank:null,byDevice:[],byScene:[],resources:null,stability:null},intervalMs:36e5};e.s(["default",0,function(){let[e,s]=(0,n.useState)(l.DEFAULT_COLLECTOR_URL),[i,o]=(0,n.useState)(l.DEFAULT_API_KEY),[x,m]=(0,n.useState)([]),[p,h]=(0,n.useState)(""),[f,b]=(0,n.useState)(a),[j,v]=(0,n.useState)([]),[y,w]=(0,n.useState)(eg),[N,S]=(0,n.useState)("idle"),[k,P]=(0,n.useState)(null),[M,_]=(0,n.useState)(null),[C,z]=(0,n.useState)("idle"),[$,D]=(0,n.useState)(new Set),[F,L]=(0,n.useState)([]),[B,H]=(0,n.useState)(()=>Date.now()),K=(0,n.useRef)(f);K.current=f;let W=(0,n.useRef)(a.window),J=(0,n.useRef)(p);J.current=p;let Z=(0,n.useRef)(M);Z.current=M;let et=(0,n.useRef)(null),es=(0,n.useRef)(null),en=(0,n.useRef)(!1),el=(0,n.useCallback)((e,t)=>{let s=`/projects/${encodeURIComponent(e)}`;return t?`${s}/session/${encodeURIComponent(t)}`:s},[]),ea=(0,n.useCallback)(e=>{window.location.pathname!==e&&window.history.pushState({},"",e)},[]);(0,n.useEffect)(()=>{let e=window.location.pathname.match(/^\/projects\/([^/]+)(?:\/session\/([^/]+))?/);e?.[1]&&(et.current=decodeURIComponent(e[1]),e[2]&&(es.current=decodeURIComponent(e[2])))},[]),(0,n.useEffect)(()=>{l.COLLECTOR_URL_IS_PINNED||s(window.location.origin)},[]),(0,n.useEffect)(()=>{let e=!1;return fetch("/api/projects").then(e=>e.ok?e.json():[]).then(t=>{if(e||!Array.isArray(t)||0===t.length)return;m(t);let[s]=t,n=et.current,r=(n?t.find(e=>e.id===n):void 0)??t.find(e=>e.apiKey===l.DEFAULT_API_KEY)??s;r&&(h(r.id),o(r.apiKey),(n&&r.id===n||1===t.length&&!r.scene)&&(en.current=!0))}).catch(()=>{}),()=>{e=!0}},[]);let ei=(0,n.useCallback)(async t=>{let s=t??i;if(!s){S("error"),P("An API key is required.");return}S("loading"),P(null),_(null),z("idle");let n=K.current,l=c(n),a=d(n),o=new r.CollectorApi(e,s);try{let e=await o.sessions({...l,source:void 0,limit:100}),t=a.until??Date.now(),s=a.since;if(null==s){let n=e.reduce((e,t)=>{var s;let n=(s=t.started_at,new Date(s.includes("T")?s:s.replace(" ","T")+"Z").getTime());return Number.isFinite(n)?Math.min(e,n):e},Date.now());s=Number.isFinite(n)?n:t-864e5}let n=function(e,t=80){let s=Math.max(60,Math.round(e/t/1e3));return u.find(e=>e>=s)??604800}(Math.max(6e4,t-s)),[r,i,d,c,x,m,p,h,f,g,b,j,y,N,k,P,M]=await Promise.all([o.pointerHeatmap({...l,bins:50}),o.cameraHeatmap({...l,source:void 0,bins:36}),o.topMeshes({...l,source:void 0,scene:void 0,limit:25}),o.perf({...l,source:void 0}),o.worldHeatmap({...l,cellSize:.5}),o.gazeHeatmap({...l,source:void 0,cellSize:.5}),o.clickRays({...l,cellSize:.5}),o.flowHeatmap({...l,bins:36,limit:400,groupByOrigin:!0}),o.scenes({since:a.since,until:a.until,limit:200}),o.timeseries({since:a.since,until:a.until,scene:l.scene,interval:n}),o.eventCounts({since:a.since,until:a.until,scene:l.scene}),o.coverage({...l,source:void 0,cellSize:1}),o.cameraDistance({...l,source:void 0,bucketSize:1}),o.navigation({...l,source:void 0}),o.interactionsBySource(l),o.cameraPositionHeatmap({...l,source:void 0,cameraMode:"first-person",cellSize:1}),(async()=>{let[e,t,s,n,r,a,i,d]=await Promise.all([o.perfDistribution({...l,source:void 0}),o.fpsHistogram({...l,source:void 0}),o.frameTimePercentiles({...l,source:void 0}),o.jankRate({...l,source:void 0}),o.perfByDevice({...l,source:void 0}),o.perfByScene({...l,source:void 0,scene:void 0}),o.resourcePercentiles({...l,source:void 0}),o.stabilityCounts({...l,source:void 0})]);return{distribution:e,histogram:t,frameTime:s,jank:n,byDevice:r,byScene:a,resources:i,stability:d}})()]);v(f);let _=l.scene??(1===f.length?f[0]?.scene_id:void 0),C=_?(await o.sceneRepresentation(_).catch(()=>null))?.proxy?.meshes??[]:[];w({sessions:e,pointer:r,camera:i,meshes:d,perf:c,world:x,gaze:m,clickRays:p,flowLinks:h,flowQuery:{since:a.since,until:a.until,scene:l.scene,source:l.source},hasFirstPerson:P.length>0,proxyMeshes:C,timeseries:g,counts:b,coverage:j,distance:y,navigation:N,sources:k,floorPlan:P,performance:M,intervalMs:1e3*n}),S("ready")}catch(e){w(eg),S("error"),P(e instanceof r.ApiError?`${e.status}: ${e.message}`:e instanceof Error?e.message:"Request failed.")}},[i,e]),eo=(0,n.useCallback)(e=>{h(e.id),o(e.apiKey),ea(el(e.id)),ei(e.apiKey)},[ei,el,ea]);(0,n.useEffect)(()=>{if("idle"===N)return;let e=setTimeout(()=>void ei(),300);return()=>clearTimeout(e)},[f]);let ed="idle"!==N&&!!i,ec=(0,n.useRef)(0),eb=(0,n.useRef)(!1);eb.current=null!=M;let ej=(0,n.useCallback)(e=>{L(t=>[e,...t].slice(0,30));let t=Date.now();eb.current||t-ec.current<5e3||(ec.current=t,ei())},[ei]),{snapshot:ev,status:ey}=(0,g.useLivePresence)(e,i,ed);(0,g.useLiveStream)(e,i,ed,ej),(0,n.useEffect)(()=>{if(!ed)return;let e=setInterval(()=>H(Date.now()),1e3);return()=>clearInterval(e)},[ed]);let ew=(0,n.useCallback)(async t=>{let s=c(K.current),n=new r.CollectorApi(e,i),[l,a,o,d,u]=await Promise.all([n.pointerHeatmap({...s,bins:50,session:t}),n.cameraHeatmap({...s,source:void 0,bins:36,session:t}),n.topMeshes({...s,source:void 0,scene:void 0,limit:25,session:t}),n.perf({...s,source:void 0,session:t}),n.sessionMeta(t).catch(()=>null)]);return{id:t,meta:u,pointer:l,camera:a,meshes:o,perf:d}},[e,i]),eN=(0,n.useCallback)(async e=>{let t=J.current;t&&ea(el(t,e)),window.scrollTo({top:0,behavior:"smooth"}),_({id:e,meta:null,pointer:[],camera:[],meshes:[],perf:null}),z("loading"),D(new Set);try{_(await ew(e)),z("ready")}catch(e){z("error"),P(e instanceof r.ApiError?`${e.status}: ${e.message}`:e instanceof Error?e.message:"Request failed.")}},[ew,el,ea]),eS=(0,n.useCallback)(()=>{let e=J.current;e&&ea(el(e)),_(null),z("idle"),D(new Set)},[el,ea]),ek=(0,n.useCallback)(e=>{let t=x.find(t=>t.id===e);h(e),t&&o(t.apiKey),w(eg),v([]),S("idle"),P(null),_(null),z("idle"),D(new Set)},[x]),eP=(0,n.useCallback)(e=>{D(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),eM=(0,n.useCallback)((e,t)=>{D(e?new Set(t):new Set)},[]),e_=(0,n.useCallback)((e,t)=>{b(s=>("custom"!==s.window&&(W.current=s.window),{...s,window:"custom",since:e,until:t}))},[]),eC=(0,n.useCallback)(()=>{b(e=>({...e,window:W.current}))},[]);(0,n.useEffect)(()=>{en.current&&i&&(en.current=!1,ei())},[x,i,ei]),(0,n.useEffect)(()=>{if("ready"===N&&es.current){let e=es.current;es.current=null,eN(e)}},[N,eN]),(0,n.useEffect)(()=>{let e=()=>{let e=window.location.pathname.match(/^\/projects\/[^/]+(?:\/session\/([^/]+))?/),t=e?.[1]?decodeURIComponent(e[1]):null;t?Z.current?.id!==t&&eN(t):Z.current&&eS()};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[eN,eS]);let eR=!!(M&&ev?.sessions.some(e=>e.sessionId===M.id)),eT=(0,n.useRef)(eR);return(0,n.useEffect)(()=>{let e=eT.current;if(eT.current=eR,!e||eR)return;let t=Z.current;if(!t||"ready"!==C)return;let s=t.id,n=!1;return(async()=>{try{let e=await ew(s);n||Z.current?.id!==s||_(e)}catch{}})(),()=>{n=!0}},[eR,C,ew]),(0,n.useEffect)(()=>{if(!eR||"ready"!==C)return;let e=Z.current?.id;if(!e)return;let t=!1,s=setInterval(()=>{(async()=>{try{let s=await ew(e);t||Z.current?.id!==e||_(s)}catch{}})()},1e3);return()=>{t=!0,clearInterval(s)}},[eR,C,ew]),(0,t.jsxs)("main",{className:"mx-auto max-w-6xl px-6 py-8",children:[(0,t.jsxs)("header",{className:"mb-6 flex items-center gap-3",children:[(0,t.jsx)("img",{src:"/logo.svg",alt:"Uptimizr",width:36,height:36,className:"h-9 w-9 shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"font-display text-2xl font-bold text-fg-hi",children:"Uptimizr"}),(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"Analytics for 3D scenes — open-source collector."})]})]}),(0,t.jsxs)("form",{className:"mb-6 flex flex-wrap items-end gap-3 rounded-xl border border-edge bg-panel p-4",onSubmit:e=>{e.preventDefault(),p&&ea(el(p)),ei()},children:[x.length>0?(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:["Project",(0,t.jsx)("select",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:p,onChange:e=>ek(e.target.value),children:x.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))})]}):null,(0,t.jsxs)("label",{className:"flex flex-1 flex-col gap-1 text-xs text-fg-muted",children:["Collector URL",(0,t.jsx)("input",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:e,onChange:e=>s(e.target.value),placeholder:"http://localhost:4318"})]}),(0,t.jsxs)("label",{className:"flex flex-1 flex-col gap-1 text-xs text-fg-muted",children:["Project API key",(0,t.jsx)("input",{className:"min-w-56 rounded-md border border-edge bg-ink px-3 py-2 text-sm text-fg outline-none focus:border-saffron",value:i,onChange:e=>o(e.target.value),type:"password",placeholder:"utk_…"})]}),(0,t.jsx)("button",{type:"submit",disabled:"loading"===N,className:"rounded-md bg-amber px-4 py-2 text-sm font-medium text-ink transition hover:bg-ember disabled:opacity-50",children:"loading"===N?"Loading…":"Load"})]}),"idle"!==N?(0,t.jsx)(E,{filters:f,scenes:j,onChange:b,busy:"loading"===N}):null,k?(0,t.jsx)("div",{className:"mb-6 rounded-lg border border-red-900/60 bg-red-950/40 px-4 py-3 text-sm text-red-300",children:k}):null,"idle"===N?x.length>0?(0,t.jsx)(Q,{projects:x,playgroundUrl:l.DEFAULT_PLAYGROUND_URL,onView:eo}):(0,t.jsx)("p",{className:"text-sm text-fg-muted",children:"Enter your collector URL and a project API key, then load to view analytics."}):M?(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[(0,t.jsxs)("div",{className:"lg:col-span-2 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-panel p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-wide text-fg-muted",children:"Session"}),(0,t.jsx)("p",{className:"font-mono text-sm text-fg",children:M.id}),(0,t.jsx)("p",{className:"mt-1 text-xs text-fg-muted",children:"loading"===C?"Loading session…":[M.meta?.scene?.sceneId?`scene: ${M.meta.scene.sceneId}`:null,M.meta?.device?.gpu?`gpu: ${M.meta.device.gpu}`:null,M.meta?.startedAt?`started: ${M.meta.startedAt}`:null].filter(Boolean).join(" · ")||"No session metadata."})]}),(0,t.jsx)("button",{type:"button",onClick:eS,className:"rounded-md border border-edge px-3 py-2 text-sm text-fg transition hover:border-amber hover:text-fg-hi",children:"← All sessions"})]}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(ex,{baseUrl:e,apiKey:i,sessionId:M.id,hiddenTypes:$,isLive:eR})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(er,{baseUrl:e,apiKey:i,sessionId:M.id,hiddenTypes:$,onToggleType:eP,onSetAllHidden:eM})}),(0,t.jsx)(I,{perf:M.perf}),(0,t.jsx)(q,{meshes:M.meshes}),(0,t.jsx)(O,{bins:M.pointer,gridSize:50}),(0,t.jsx)(R,{bins:M.camera,gridSize:36}),M.meta?.scene?.cameraType==="free"?(0,t.jsx)(Y,{baseUrl:e,apiKey:i,sessionId:M.id,scene:M.meta?.scene?.sceneId??f.scene}):null,(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(ep,{bins:M.camera,gridSize:36})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(X,{sessions:y.sessions,selectedId:M.id,onSelect:eN})})]}):(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(eu,{snapshot:ev,status:ey,feed:F,now:B,onSelectSession:eN})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(ee,{buckets:y.timeseries,intervalMs:y.intervalMs,onBrush:e_,brushed:"custom"===f.window,onClear:eC})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(G,{counts:y.counts,perf:y.perf})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(V,{coverage:y.coverage,cellSize:1,distance:y.distance,bucketSize:1,navigation:y.navigation})}),(0,t.jsx)(I,{perf:y.perf}),(0,t.jsx)(q,{meshes:y.meshes}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(U,{data:y.performance})}),(0,t.jsx)(A,{rows:y.sources}),(0,t.jsx)(O,{bins:y.pointer,gridSize:50}),(0,t.jsx)(R,{bins:y.camera,gridSize:36}),"viewer"!==f.cameraMode?(0,t.jsx)(T,{bins:y.floorPlan,cellSize:1}):null,(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(ep,{bins:y.camera,gridSize:36})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(em,{voxels:y.world,cellSize:.5,proxyMeshes:y.proxyMeshes})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(em,{voxels:y.gaze,cellSize:.5,proxyMeshes:y.proxyMeshes,title:"Gaze heatmap (3D)",subtitle:"Camera-pose gaze hit-points voxel-binned in world space — what viewers actually look at",legendTitle:"Gaze density",legendLow:"few looks",legendHigh:"most looks",legendNote:"Each marker is a voxel where the camera-forward (gaze) ray hit your scene. Enable gaze capture in the SDK to populate this.",emptyLabel:"No gaze hit-points in range. Enable gaze capture in the SDK."})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(eh,{rays:y.clickRays,cellSize:.5,proxyMeshes:y.proxyMeshes})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(ef,{links:y.flowLinks,gridSize:36,proxyMeshes:y.proxyMeshes,maxLinks:80,baseUrl:e,apiKey:i,flowQuery:y.flowQuery,hasFirstPerson:y.hasFirstPerson})}),(0,t.jsx)("div",{className:"lg:col-span-2",children:(0,t.jsx)(X,{sessions:y.sessions,onSelect:eN})})]})]})}],14936)}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,20461,e=>{"use strict";var t=e.i(96265),r=e.i(46703),a=e.i(14953),o=e.i(89030),l=e.i(70653);class i{constructor(e,t,r,a){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=r,this.worldAxisForFileY=a}}class n{static _NearestPow2Floor(e){return e<=1?1:1<<Math.floor(Math.log2(e))}static ConvertCubeMapTextureToSphericalPolynomial(e){let t,r;if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();let a=e.getSize().width,o=e._sphericalPolynomialTargetSize,l=o>0?this._NearestPow2Floor(o):0,i=!e.noMipmap&&e._texture?.generateMipMaps===!0,n=l>0&&l<a&&i,s=n?Math.max(0,Math.round(Math.log2(a/l))):0,f=n?Math.max(1,Math.floor(a/Math.pow(2,s))):a,u=e.readPixels(0,s,void 0,!1),c=e.readPixels(1,s,void 0,!1);e.isRenderTarget?(t=e.readPixels(3,s,void 0,!1),r=e.readPixels(2,s,void 0,!1)):(t=e.readPixels(2,s,void 0,!1),r=e.readPixels(3,s,void 0,!1));let p=e.readPixels(4,s,void 0,!1),m=e.readPixels(5,s,void 0,!1),h=e.gammaSpace,A=l>0&&l<a&&!n;return new Promise(e=>{Promise.all([c,u,t,r,p,m]).then(([t,r,o,i,n,s])=>{let u=f;A&&(t=this._DownsampleFace(t,a,l,4),r=this._DownsampleFace(r,a,l,4),o=this._DownsampleFace(o,a,l,4),i=this._DownsampleFace(i,a,l,4),n=this._DownsampleFace(n,a,l,4),s=this._DownsampleFace(s,a,l,4),u=l);let c={size:u,right:r,left:t,up:o,down:i,front:n,back:s,format:5,type:+(t instanceof Float32Array),gammaSpace:h};e(this.ConvertCubeMapToSphericalPolynomial(c))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static _DownsampleFace(e,t,r,a){let o=e instanceof Float32Array?e:Float32Array.from(e),l=r*r*a,i=new Float32Array(l),n=t/r,s=1/(n*n);for(let e=0;e<r;e++){let l=Math.floor(e*n),f=Math.floor((e+1)*n);for(let u=0;u<r;u++){let c=Math.floor(u*n),p=Math.floor((u+1)*n),m=(e*r+u)*a;for(let e=0;e<a;e++){let r=0;for(let i=l;i<f;i++)for(let l=c;l<p;l++)r+=o[(i*t+l)*a+e];i[m+e]=r*s}}}if(e instanceof Float32Array)return i;let f=new e.constructor(l);for(let e=0;e<l;e++)f[e]=i[e]+.5|0;return f}static ConvertCubeMapToSphericalPolynomial(e,t=0){let i=t>0?this._NearestPow2Floor(t):0;if(i>0&&e.size>i){let t=5===e.format?4:3,r={};for(let a of["right","left","up","down","front","back"])r[a]=this._DownsampleFace(e[a],e.size,i,t);e={...e,...r,size:i}}let n=new a.SphericalHarmonics,s=0,f=2/e.size,u=.5*f,c=u-1;for(let t=0;t<6;t++){let a=this._FileFaces[t],i=e[a.name],p=c,m=5===e.format?4:3;for(let t=0;t<e.size;t++){let h=c;for(let c=0;c<e.size;c++){let A=a.worldAxisForFileX.scale(h).add(a.worldAxisForFileY.scale(p)).add(a.worldAxisForNormal);A.normalize();let F=this._AreaElement(h-u,p-u)-this._AreaElement(h-u,p+u)-this._AreaElement(h+u,p-u)+this._AreaElement(h+u,p+u),d=i[t*e.size*m+c*m+0],y=i[t*e.size*m+c*m+1],w=i[t*e.size*m+c*m+2];isNaN(d)&&(d=0),isNaN(y)&&(y=0),isNaN(w)&&(w=0),0===e.type&&(d/=255,y/=255,w/=255),e.gammaSpace&&(d=Math.pow((0,r.Clamp)(d),o.ToLinearSpace),y=Math.pow((0,r.Clamp)(y),o.ToLinearSpace),w=Math.pow((0,r.Clamp)(w),o.ToLinearSpace));let C=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){let e=Math.max(d,y,w);if(e>C){let t=C/e;d*=t,y*=t,w*=t}}else d=(0,r.Clamp)(d,0,C),y=(0,r.Clamp)(y,0,C),w=(0,r.Clamp)(w,0,C);let _=new l.Color3(d,y,w);n.addLight(A,_,F),s+=F,h+=f}p+=f}}let p=4*Math.PI*6/6/s;return n.scaleInPlace(p),n.convertIncidentRadianceToIrradiance(),n.convertIrradianceToLambertianRadiance(),a.SphericalPolynomial.FromHarmonics(n)}}n._FileFaces=[new i("right",new t.Vector3(1,0,0),new t.Vector3(0,0,-1),new t.Vector3(0,-1,0)),new i("left",new t.Vector3(-1,0,0),new t.Vector3(0,0,1),new t.Vector3(0,-1,0)),new i("up",new t.Vector3(0,1,0),new t.Vector3(1,0,0),new t.Vector3(0,0,1)),new i("down",new t.Vector3(0,-1,0),new t.Vector3(1,0,0),new t.Vector3(0,0,-1)),new i("front",new t.Vector3(0,0,1),new t.Vector3(1,0,0),new t.Vector3(0,-1,0)),new i("back",new t.Vector3(0,0,-1),new t.Vector3(-1,0,0),new t.Vector3(0,-1,0))],n.MAX_HDRI_VALUE=4096,n.PRESERVE_CLAMPED_COLORS=!1,e.s(["CubeMapToSphericalPolynomialTools",0,n])},39669,e=>{"use strict";var t=e.i(46703),r=e.i(13379),a=e.i(20461),o=e.i(96704);function l(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}let i=l("DXT1"),n=l("DXT3"),s=l("DXT5"),f=l("DX10");class u{static GetDDSInfo(e){let t=new Int32Array(e.buffer,e.byteOffset,31),r=new Int32Array(e.buffer,e.byteOffset,35),a=1;131072&t[2]&&(a=Math.max(1,t[7]));let o=t[21],l=o===f?r[32]:0,u=0;switch(o){case 113:u=2;break;case 116:u=1;break;case f:if(10===l){u=2;break}2===l&&(u=1)}return{width:t[4],height:t[3],mipmapCount:a,isFourCC:(4&t[20])==4,isRGB:(64&t[20])==64,isLuminance:(131072&t[20])==131072,isCube:(512&t[28])==512,isCompressed:o===i||o===n||o===s,dxgiFormat:l,textureType:u}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,r,a,l,i){let n=new Float32Array(a),s=new Uint16Array(l,r),f=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=(t+r*e)*4;n[f]=(0,o.FromHalfFloat)(s[a]),n[f+1]=(0,o.FromHalfFloat)(s[a+1]),n[f+2]=(0,o.FromHalfFloat)(s[a+2]),u.StoreLODInAlphaChannel?n[f+3]=i:n[f+3]=(0,o.FromHalfFloat)(s[a+3]),f+=4}return n}static _GetHalfFloatRGBAArrayBuffer(e,t,r,a,l,i){if(u.StoreLODInAlphaChannel){let n=new Uint16Array(a),s=new Uint16Array(l,r),f=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=(t+r*e)*4;n[f]=s[a],n[f+1]=s[a+1],n[f+2]=s[a+2],n[f+3]=(0,o.ToHalfFloat)(i),f+=4}return n}return new Uint16Array(l,r,a)}static _GetFloatRGBAArrayBuffer(e,t,r,a,o,l){if(u.StoreLODInAlphaChannel){let i=new Float32Array(a),n=new Float32Array(o,r),s=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=(t+r*e)*4;i[s]=n[a],i[s+1]=n[a+1],i[s+2]=n[a+2],i[s+3]=l,s+=4}return i}return new Float32Array(o,r,a)}static _GetFloatAsHalfFloatRGBAArrayBuffer(e,t,r,a,l,i){let n=new Uint16Array(a),s=new Float32Array(l,r),f=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++)n[f]=(0,o.ToHalfFloat)(s[f]),n[f+1]=(0,o.ToHalfFloat)(s[f+1]),n[f+2]=(0,o.ToHalfFloat)(s[f+2]),u.StoreLODInAlphaChannel?n[f+3]=(0,o.ToHalfFloat)(i):n[f+3]=(0,o.ToHalfFloat)(s[f+3]),f+=4;return n}static _GetFloatAsUIntRGBAArrayBuffer(e,r,a,o,l,i){let n=new Uint8Array(o),s=new Float32Array(l,a),f=0;for(let a=0;a<r;a++)for(let r=0;r<e;r++){let o=(r+a*e)*4;n[f]=255*(0,t.Clamp)(s[o]),n[f+1]=255*(0,t.Clamp)(s[o+1]),n[f+2]=255*(0,t.Clamp)(s[o+2]),u.StoreLODInAlphaChannel?n[f+3]=i:n[f+3]=255*(0,t.Clamp)(s[o+3]),f+=4}return n}static _GetHalfFloatAsUIntRGBAArrayBuffer(e,r,a,l,i,n){let s=new Uint8Array(l),f=new Uint16Array(i,a),c=0;for(let a=0;a<r;a++)for(let r=0;r<e;r++){let l=(r+a*e)*4;s[c]=255*(0,t.Clamp)((0,o.FromHalfFloat)(f[l])),s[c+1]=255*(0,t.Clamp)((0,o.FromHalfFloat)(f[l+1])),s[c+2]=255*(0,t.Clamp)((0,o.FromHalfFloat)(f[l+2])),u.StoreLODInAlphaChannel?s[c+3]=n:s[c+3]=255*(0,t.Clamp)((0,o.FromHalfFloat)(f[l+3])),c+=4}return s}static _GetRGBAArrayBuffer(e,t,r,a,o,l,i,n,s){let f=new Uint8Array(a),u=new Uint8Array(o,r),c=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=(t+r*e)*4;f[c]=u[a+l],f[c+1]=u[a+i],f[c+2]=u[a+n],f[c+3]=u[a+s],c+=4}return f}static _ExtractLongWordOrder(e){return 0===e||255===e||-0x1000000===e?0:1+u._ExtractLongWordOrder(e>>8)}static _GetRGBArrayBuffer(e,t,r,a,o,l,i,n){let s=new Uint8Array(a),f=new Uint8Array(o,r),u=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=(t+r*e)*3;s[u]=f[a+l],s[u+1]=f[a+i],s[u+2]=f[a+n],u+=3}return s}static _GetLuminanceArrayBuffer(e,t,r,a,o){let l=new Uint8Array(a),i=new Uint8Array(o,r),n=0;for(let r=0;r<t;r++)for(let t=0;t<e;t++){let a=t+r*e;l[n]=i[a],n++}return l}static UploadDDSLevels(e,t,o,l,c,p,m=-1,h,A=!0){let F,d,y,w=null;l.sphericalPolynomial&&(w=[]);let C=!!e.getCaps().s3tc;t.generateMipMaps=c;let _=new Int32Array(o.buffer,o.byteOffset,31),b,D,G,g=0,B,M=0,S=1;if(0x20534444!==_[0])return void r.Logger.Error("Invalid magic number in DDS header");if(!l.isFourCC&&!l.isRGB&&!l.isLuminance)return void r.Logger.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(l.isCompressed&&!C)return void r.Logger.Error("Compressed textures are not supported on this platform.");let x=_[22];B=_[1]+4;let T=!1;if(l.isFourCC)switch(b=_[21]){case i:S=8,M=33777;break;case n:S=16,M=33778;break;case s:S=16,M=33779;break;case 113:T=!0,x=64;break;case 116:T=!0,x=128;break;case f:{B+=20;let e=!1;switch(l.dxgiFormat){case 10:T=!0,x=64,e=!0;break;case 2:T=!0,x=128,e=!0;break;case 88:l.isRGB=!0,l.isFourCC=!1,x=32,e=!0}if(e)break}default:r.Logger.Error(["Unsupported FourCC code:",String.fromCharCode(255&b,b>>8&255,b>>16&255,b>>24&255)]);return}let R=u._ExtractLongWordOrder(_[23]),L=u._ExtractLongWordOrder(_[24]),O=u._ExtractLongWordOrder(_[25]),P=u._ExtractLongWordOrder(_[26]);T&&(M=e._getRGBABufferInternalSizedFormat(l.textureType)),d=1,131072&_[2]&&!1!==c&&(d=Math.max(1,_[7]));let H=h||0,U=e.getCaps();for(let r=H;r<p;r++){for(y=0,D=_[4],G=_[3];y<d;++y){if(-1===m||m===y){let a=-1===m?y:0;if(!l.isCompressed&&l.isFourCC){t.format=5,g=D*G*4;let l=null;if(e._badOS||e._badDesktopOS||!U.textureHalfFloat&&!U.textureFloat)128===x?(l=u._GetFloatAsUIntRGBAArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,a),w&&0==a&&w.push(u._GetFloatRGBAArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,a))):64===x&&(l=u._GetHalfFloatAsUIntRGBAArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,a),w&&0==a&&w.push(u._GetHalfFloatAsFloatRGBAArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,a))),t.type=0;else{let e,r=U.textureFloat&&(A&&U.textureFloatLinearFiltering||!A),i=U.textureHalfFloat&&(A&&U.textureHalfFloatLinearFiltering||!A),n=(128===x||64===x&&!i)&&r?1:(64===x||128===x&&!r)&&i?2:0,s=null;if(128===x)switch(n){case 1:e=u._GetFloatRGBAArrayBuffer,s=null;break;case 2:e=u._GetFloatAsHalfFloatRGBAArrayBuffer,s=u._GetFloatRGBAArrayBuffer;break;case 0:e=u._GetFloatAsUIntRGBAArrayBuffer,s=u._GetFloatRGBAArrayBuffer}else switch(n){case 1:e=u._GetHalfFloatAsFloatRGBAArrayBuffer,s=null;break;case 2:e=u._GetHalfFloatRGBAArrayBuffer,s=u._GetHalfFloatAsFloatRGBAArrayBuffer;break;case 0:e=u._GetHalfFloatAsUIntRGBAArrayBuffer,s=u._GetHalfFloatAsFloatRGBAArrayBuffer}t.type=n,l=e(D,G,o.byteOffset+B,g,o.buffer,a),w&&0==a&&w.push(s?s(D,G,o.byteOffset+B,g,o.buffer,a):l)}l&&e._uploadDataToTextureDirectly(t,l,r,a)}else if(l.isRGB)t.type=0,24===x?(t.format=4,g=D*G*3,F=u._GetRGBArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,R,L,O)):(t.format=5,g=D*G*4,F=u._GetRGBAArrayBuffer(D,G,o.byteOffset+B,g,o.buffer,R,L,O,P)),e._uploadDataToTextureDirectly(t,F,r,a);else if(l.isLuminance){let l=e._getUnpackAlignement(),i=D;g=Math.floor((D+l-1)/l)*l*(G-1)+i,F=u._GetLuminanceArrayBuffer(D,G,o.byteOffset+B,g,o.buffer),t.format=1,t.type=0,e._uploadDataToTextureDirectly(t,F,r,a)}else g=Math.max(4,D)/4*Math.max(4,G)/4*S,F=new Uint8Array(o.buffer,o.byteOffset+B,g),t.type=0,e._uploadCompressedDataToTextureDirectly(t,M,D,G,F,r,a)}B+=x?D*G*(x/8):g,D*=.5,G*=.5,D=Math.max(1,D),G=Math.max(1,G)}if(void 0!==h)break}w&&w.length>0?l.sphericalPolynomial=a.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({size:_[4],right:w[0],left:w[1],up:w[2],down:w[3],front:w[4],back:w[5],format:5,type:1,gammaSpace:!1}):l.sphericalPolynomial=void 0}}u.StoreLODInAlphaChannel=!1,e.s(["DDSTools",0,u])},97991,e=>{"use strict";var t=e.i(14953),r=e.i(39669);e.s(["_DDSTextureLoader",0,class{constructor(){this.supportCascades=!0}loadCubeData(e,a,o,l){let i,n=a.getEngine(),s=!1,f=1e3;if(Array.isArray(e))for(let t=0;t<e.length;t++){let o=e[t];a.width=(i=r.DDSTools.GetDDSInfo(o)).width,a.height=i.height,s=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&a.generateMipMaps,n._unpackFlipY(i.isCompressed),r.DDSTools.UploadDDSLevels(n,a,o,i,s,6,-1,t),i.isFourCC||1!==i.mipmapCount?f=i.mipmapCount-1:n.generateMipMapsForCubemap(a)}else a.width=(i=r.DDSTools.GetDDSInfo(e)).width,a.height=i.height,o&&(i.sphericalPolynomial=new t.SphericalPolynomial),s=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&a.generateMipMaps,n._unpackFlipY(i.isCompressed),r.DDSTools.UploadDDSLevels(n,a,e,i,s,6),i.isFourCC||1!==i.mipmapCount?f=i.mipmapCount-1:n.generateMipMapsForCubemap(a,!1);n._setCubeMapTextureParams(a,s,f),a.isReady=!0,a.onLoadedObservable.notifyObservers(a),a.onLoadedObservable.clear(),l&&l({isDDS:!0,width:a.width,info:i,data:e,texture:a})}loadData(e,t,a){let o=r.DDSTools.GetDDSInfo(e),l=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps&&Math.max(o.width,o.height)>>o.mipmapCount-1==1;a(o.width,o.height,l,o.isFourCC,()=>{r.DDSTools.UploadDDSLevels(t.getEngine(),t,e,o,l,1)})}}])}]);
|