@rr0/ufoathome 0.178.2 → 0.178.4
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/dist-embed-scene/rr0-scene.mjs +4 -4
- package/dist-embed-sighting/{CaseReportExport-IaDMFEro.js → CaseReportExport-DHdgnsTQ.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +112 -110
- package/dist-embed-sighting-editor/{CaseReportExport-D0r6soze.js → CaseReportExport-D_e5Uij7.js} +1 -1
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +7 -7
- package/package.json +1 -1
|
@@ -1389,7 +1389,7 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
1389
1389
|
uniform float lightMapIntensity;
|
|
1390
1390
|
#endif`,QD=`LambertMaterial material;
|
|
1391
1391
|
material.diffuseColor = diffuseColor.rgb;
|
|
1392
|
-
material.specularStrength = specularStrength;`,
|
|
1392
|
+
material.specularStrength = specularStrength;`,t6=`varying vec3 vViewPosition;
|
|
1393
1393
|
struct LambertMaterial {
|
|
1394
1394
|
vec3 diffuseColor;
|
|
1395
1395
|
float specularStrength;
|
|
@@ -1403,7 +1403,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
1403
1403
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1404
1404
|
}
|
|
1405
1405
|
#define RE_Direct RE_Direct_Lambert
|
|
1406
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
1406
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,e6=`uniform bool receiveShadow;
|
|
1407
1407
|
uniform vec3 ambientLightColor;
|
|
1408
1408
|
#if defined( USE_LIGHT_PROBES )
|
|
1409
1409
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -1520,7 +1520,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1520
1520
|
return irradiance;
|
|
1521
1521
|
}
|
|
1522
1522
|
#endif
|
|
1523
|
-
#include <lightprobes_pars_fragment>`,
|
|
1523
|
+
#include <lightprobes_pars_fragment>`,i6=`#ifdef USE_ENVMAP
|
|
1524
1524
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
1525
1525
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
1526
1526
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -1553,8 +1553,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1553
1553
|
#endif
|
|
1554
1554
|
}
|
|
1555
1555
|
#endif
|
|
1556
|
-
#endif`,
|
|
1557
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
1556
|
+
#endif`,n6=`ToonMaterial material;
|
|
1557
|
+
material.diffuseColor = diffuseColor.rgb;`,s6=`varying vec3 vViewPosition;
|
|
1558
1558
|
struct ToonMaterial {
|
|
1559
1559
|
vec3 diffuseColor;
|
|
1560
1560
|
};
|
|
@@ -1566,11 +1566,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
1566
1566
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1567
1567
|
}
|
|
1568
1568
|
#define RE_Direct RE_Direct_Toon
|
|
1569
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1569
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,r6=`BlinnPhongMaterial material;
|
|
1570
1570
|
material.diffuseColor = diffuseColor.rgb;
|
|
1571
1571
|
material.specularColor = specular;
|
|
1572
1572
|
material.specularShininess = shininess;
|
|
1573
|
-
material.specularStrength = specularStrength;`,
|
|
1573
|
+
material.specularStrength = specularStrength;`,a6=`varying vec3 vViewPosition;
|
|
1574
1574
|
struct BlinnPhongMaterial {
|
|
1575
1575
|
vec3 diffuseColor;
|
|
1576
1576
|
vec3 specularColor;
|
|
@@ -1587,7 +1587,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1587
1587
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1588
1588
|
}
|
|
1589
1589
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1590
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1590
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,o6=`PhysicalMaterial material;
|
|
1591
1591
|
material.diffuseColor = diffuseColor.rgb;
|
|
1592
1592
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1593
1593
|
material.metalness = metalnessFactor;
|
|
@@ -1677,7 +1677,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1677
1677
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1678
1678
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1679
1679
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1680
|
-
#endif`,
|
|
1680
|
+
#endif`,c6=`uniform sampler2D dfgLUT;
|
|
1681
1681
|
struct PhysicalMaterial {
|
|
1682
1682
|
vec3 diffuseColor;
|
|
1683
1683
|
vec3 diffuseContribution;
|
|
@@ -2037,7 +2037,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
2037
2037
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
2038
2038
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
2039
2039
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
2040
|
-
}`,
|
|
2040
|
+
}`,l6=`
|
|
2041
2041
|
vec3 geometryPosition = - vViewPosition;
|
|
2042
2042
|
vec3 geometryNormal = normal;
|
|
2043
2043
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -2159,7 +2159,7 @@ IncidentLight directLight;
|
|
|
2159
2159
|
#if defined( RE_IndirectSpecular )
|
|
2160
2160
|
vec3 radiance = vec3( 0.0 );
|
|
2161
2161
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
2162
|
-
#endif`,
|
|
2162
|
+
#endif`,h6=`#if defined( RE_IndirectDiffuse )
|
|
2163
2163
|
#ifdef USE_LIGHTMAP
|
|
2164
2164
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
2165
2165
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -2180,7 +2180,7 @@ IncidentLight directLight;
|
|
|
2180
2180
|
#ifdef USE_CLEARCOAT
|
|
2181
2181
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
2182
2182
|
#endif
|
|
2183
|
-
#endif`,
|
|
2183
|
+
#endif`,u6=`#if defined( RE_IndirectDiffuse )
|
|
2184
2184
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
2185
2185
|
irradiance += iblIrradiance;
|
|
2186
2186
|
#endif
|
|
@@ -2188,7 +2188,7 @@ IncidentLight directLight;
|
|
|
2188
2188
|
#endif
|
|
2189
2189
|
#if defined( RE_IndirectSpecular )
|
|
2190
2190
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
2191
|
-
#endif`,
|
|
2191
|
+
#endif`,d6=`#ifdef USE_LIGHT_PROBES_GRID
|
|
2192
2192
|
uniform highp sampler3D probesSH;
|
|
2193
2193
|
uniform vec3 probesMin;
|
|
2194
2194
|
uniform vec3 probesMax;
|
|
@@ -2233,27 +2233,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2233
2233
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
2234
2234
|
return max( result, vec3( 0.0 ) );
|
|
2235
2235
|
}
|
|
2236
|
-
#endif`,
|
|
2236
|
+
#endif`,f6=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
2237
2237
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
2238
|
-
#endif`,
|
|
2238
|
+
#endif`,p6=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
2239
2239
|
uniform float logDepthBufFC;
|
|
2240
2240
|
varying float vFragDepth;
|
|
2241
2241
|
varying float vIsPerspective;
|
|
2242
|
-
#endif`,
|
|
2242
|
+
#endif`,m6=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
2243
2243
|
varying float vFragDepth;
|
|
2244
2244
|
varying float vIsPerspective;
|
|
2245
|
-
#endif`,
|
|
2245
|
+
#endif`,g6=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
2246
2246
|
vFragDepth = 1.0 + gl_Position.w;
|
|
2247
2247
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
2248
|
-
#endif`,
|
|
2248
|
+
#endif`,v6=`#ifdef USE_MAP
|
|
2249
2249
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
2250
2250
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
2251
2251
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
2252
2252
|
#endif
|
|
2253
2253
|
diffuseColor *= sampledDiffuseColor;
|
|
2254
|
-
#endif`,
|
|
2254
|
+
#endif`,M6=`#ifdef USE_MAP
|
|
2255
2255
|
uniform sampler2D map;
|
|
2256
|
-
#endif`,
|
|
2256
|
+
#endif`,y6=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
2257
2257
|
#if defined( USE_POINTS_UV )
|
|
2258
2258
|
vec2 uv = vUv;
|
|
2259
2259
|
#else
|
|
@@ -2265,7 +2265,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2265
2265
|
#endif
|
|
2266
2266
|
#ifdef USE_ALPHAMAP
|
|
2267
2267
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
2268
|
-
#endif`,
|
|
2268
|
+
#endif`,w6=`#if defined( USE_POINTS_UV )
|
|
2269
2269
|
varying vec2 vUv;
|
|
2270
2270
|
#else
|
|
2271
2271
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -2277,19 +2277,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2277
2277
|
#endif
|
|
2278
2278
|
#ifdef USE_ALPHAMAP
|
|
2279
2279
|
uniform sampler2D alphaMap;
|
|
2280
|
-
#endif`,
|
|
2280
|
+
#endif`,x6=`float metalnessFactor = metalness;
|
|
2281
2281
|
#ifdef USE_METALNESSMAP
|
|
2282
2282
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
2283
2283
|
metalnessFactor *= texelMetalness.b;
|
|
2284
|
-
#endif`,
|
|
2284
|
+
#endif`,b6=`#ifdef USE_METALNESSMAP
|
|
2285
2285
|
uniform sampler2D metalnessMap;
|
|
2286
|
-
#endif`,
|
|
2286
|
+
#endif`,S6=`#ifdef USE_INSTANCING_MORPH
|
|
2287
2287
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
2288
2288
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
2289
2289
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2290
2290
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
2291
2291
|
}
|
|
2292
|
-
#endif`,
|
|
2292
|
+
#endif`,E6=`#if defined( USE_MORPHCOLORS )
|
|
2293
2293
|
vColor *= morphTargetBaseInfluence;
|
|
2294
2294
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2295
2295
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -2298,12 +2298,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2298
2298
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
2299
2299
|
#endif
|
|
2300
2300
|
}
|
|
2301
|
-
#endif`,
|
|
2301
|
+
#endif`,A6=`#ifdef USE_MORPHNORMALS
|
|
2302
2302
|
objectNormal *= morphTargetBaseInfluence;
|
|
2303
2303
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2304
2304
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
2305
2305
|
}
|
|
2306
|
-
#endif`,
|
|
2306
|
+
#endif`,_6=`#ifdef USE_MORPHTARGETS
|
|
2307
2307
|
#ifndef USE_INSTANCING_MORPH
|
|
2308
2308
|
uniform float morphTargetBaseInfluence;
|
|
2309
2309
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -2317,12 +2317,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2317
2317
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
2318
2318
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
2319
2319
|
}
|
|
2320
|
-
#endif`,
|
|
2320
|
+
#endif`,T6=`#ifdef USE_MORPHTARGETS
|
|
2321
2321
|
transformed *= morphTargetBaseInfluence;
|
|
2322
2322
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2323
2323
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
2324
2324
|
}
|
|
2325
|
-
#endif`,
|
|
2325
|
+
#endif`,R6=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
2326
2326
|
#ifdef FLAT_SHADED
|
|
2327
2327
|
vec3 fdx = dFdx( vViewPosition );
|
|
2328
2328
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -2363,7 +2363,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2363
2363
|
tbn2[1] *= faceDirection;
|
|
2364
2364
|
#endif
|
|
2365
2365
|
#endif
|
|
2366
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
2366
|
+
vec3 nonPerturbedNormal = normal;`,I6=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
2367
2367
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2368
2368
|
#ifdef FLIP_SIDED
|
|
2369
2369
|
normal = - normal;
|
|
@@ -2381,19 +2381,19 @@ vec3 nonPerturbedNormal = normal;`,IC=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2381
2381
|
normal = normalize( tbn * mapN );
|
|
2382
2382
|
#elif defined( USE_BUMPMAP )
|
|
2383
2383
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
2384
|
-
#endif`,
|
|
2384
|
+
#endif`,D6=`#ifndef FLAT_SHADED
|
|
2385
2385
|
varying vec3 vNormal;
|
|
2386
2386
|
#ifdef USE_TANGENT
|
|
2387
2387
|
varying vec3 vTangent;
|
|
2388
2388
|
varying vec3 vBitangent;
|
|
2389
2389
|
#endif
|
|
2390
|
-
#endif`,
|
|
2390
|
+
#endif`,C6=`#ifndef FLAT_SHADED
|
|
2391
2391
|
varying vec3 vNormal;
|
|
2392
2392
|
#ifdef USE_TANGENT
|
|
2393
2393
|
varying vec3 vTangent;
|
|
2394
2394
|
varying vec3 vBitangent;
|
|
2395
2395
|
#endif
|
|
2396
|
-
#endif`,
|
|
2396
|
+
#endif`,O6=`#ifndef FLAT_SHADED
|
|
2397
2397
|
vNormal = normalize( transformedNormal );
|
|
2398
2398
|
#ifdef USE_TANGENT
|
|
2399
2399
|
vTangent = normalize( transformedTangent );
|
|
@@ -2402,7 +2402,7 @@ vec3 nonPerturbedNormal = normal;`,IC=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2402
2402
|
vBitangent = - vBitangent;
|
|
2403
2403
|
#endif
|
|
2404
2404
|
#endif
|
|
2405
|
-
#endif`,
|
|
2405
|
+
#endif`,P6=`#ifdef USE_NORMALMAP
|
|
2406
2406
|
uniform sampler2D normalMap;
|
|
2407
2407
|
uniform vec2 normalScale;
|
|
2408
2408
|
#endif
|
|
@@ -2424,13 +2424,13 @@ vec3 nonPerturbedNormal = normal;`,IC=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2424
2424
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
2425
2425
|
return mat3( T * scale, B * scale, N );
|
|
2426
2426
|
}
|
|
2427
|
-
#endif`,
|
|
2427
|
+
#endif`,N6=`#ifdef USE_CLEARCOAT
|
|
2428
2428
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
2429
|
-
#endif`,
|
|
2429
|
+
#endif`,L6=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2430
2430
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2431
2431
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
2432
2432
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
2433
|
-
#endif`,
|
|
2433
|
+
#endif`,k6=`#ifdef USE_CLEARCOATMAP
|
|
2434
2434
|
uniform sampler2D clearcoatMap;
|
|
2435
2435
|
#endif
|
|
2436
2436
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -2439,18 +2439,18 @@ vec3 nonPerturbedNormal = normal;`,IC=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2439
2439
|
#endif
|
|
2440
2440
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2441
2441
|
uniform sampler2D clearcoatRoughnessMap;
|
|
2442
|
-
#endif`,
|
|
2442
|
+
#endif`,F6=`#ifdef USE_IRIDESCENCEMAP
|
|
2443
2443
|
uniform sampler2D iridescenceMap;
|
|
2444
2444
|
#endif
|
|
2445
2445
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2446
2446
|
uniform sampler2D iridescenceThicknessMap;
|
|
2447
|
-
#endif`,
|
|
2447
|
+
#endif`,U6=`#ifdef OPAQUE
|
|
2448
2448
|
diffuseColor.a = 1.0;
|
|
2449
2449
|
#endif
|
|
2450
2450
|
#ifdef USE_TRANSMISSION
|
|
2451
2451
|
diffuseColor.a *= material.transmissionAlpha;
|
|
2452
2452
|
#endif
|
|
2453
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
2453
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,z6=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
2454
2454
|
return normalize( normal ) * 0.5 + 0.5;
|
|
2455
2455
|
}
|
|
2456
2456
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -2529,9 +2529,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2529
2529
|
#else
|
|
2530
2530
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
2531
2531
|
#endif
|
|
2532
|
-
}`,
|
|
2532
|
+
}`,B6=`#ifdef PREMULTIPLIED_ALPHA
|
|
2533
2533
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2534
|
-
#endif`,
|
|
2534
|
+
#endif`,H6=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
2535
2535
|
#ifdef USE_BATCHING
|
|
2536
2536
|
mvPosition = batchingMatrix * mvPosition;
|
|
2537
2537
|
#endif
|
|
@@ -2539,22 +2539,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2539
2539
|
mvPosition = instanceMatrix * mvPosition;
|
|
2540
2540
|
#endif
|
|
2541
2541
|
mvPosition = modelViewMatrix * mvPosition;
|
|
2542
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
2542
|
+
gl_Position = projectionMatrix * mvPosition;`,G6=`#ifdef DITHERING
|
|
2543
2543
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
2544
|
-
#endif`,
|
|
2544
|
+
#endif`,V6=`#ifdef DITHERING
|
|
2545
2545
|
vec3 dithering( vec3 color ) {
|
|
2546
2546
|
float grid_position = rand( gl_FragCoord.xy );
|
|
2547
2547
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
2548
2548
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
2549
2549
|
return color + dither_shift_RGB;
|
|
2550
2550
|
}
|
|
2551
|
-
#endif`,
|
|
2551
|
+
#endif`,W6=`float roughnessFactor = roughness;
|
|
2552
2552
|
#ifdef USE_ROUGHNESSMAP
|
|
2553
2553
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
2554
2554
|
roughnessFactor *= texelRoughness.g;
|
|
2555
|
-
#endif`,
|
|
2555
|
+
#endif`,X6=`#ifdef USE_ROUGHNESSMAP
|
|
2556
2556
|
uniform sampler2D roughnessMap;
|
|
2557
|
-
#endif`,$
|
|
2557
|
+
#endif`,$6=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2558
2558
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2559
2559
|
#endif
|
|
2560
2560
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2754,7 +2754,7 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2754
2754
|
}
|
|
2755
2755
|
#endif
|
|
2756
2756
|
#endif
|
|
2757
|
-
#endif`,
|
|
2757
|
+
#endif`,Y6=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2758
2758
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2759
2759
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2760
2760
|
#endif
|
|
@@ -2795,7 +2795,7 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2795
2795
|
};
|
|
2796
2796
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2797
2797
|
#endif
|
|
2798
|
-
#endif`,
|
|
2798
|
+
#endif`,K6=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2799
2799
|
#ifdef HAS_NORMAL
|
|
2800
2800
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2801
2801
|
#else
|
|
@@ -2831,7 +2831,7 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2831
2831
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2832
2832
|
}
|
|
2833
2833
|
#pragma unroll_loop_end
|
|
2834
|
-
#endif`,
|
|
2834
|
+
#endif`,q6=`float getShadowMask() {
|
|
2835
2835
|
float shadow = 1.0;
|
|
2836
2836
|
#ifdef USE_SHADOWMAP
|
|
2837
2837
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2863,12 +2863,12 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2863
2863
|
#endif
|
|
2864
2864
|
#endif
|
|
2865
2865
|
return shadow;
|
|
2866
|
-
}`,
|
|
2866
|
+
}`,Z6=`#ifdef USE_SKINNING
|
|
2867
2867
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2868
2868
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2869
2869
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2870
2870
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2871
|
-
#endif`,
|
|
2871
|
+
#endif`,J6=`#ifdef USE_SKINNING
|
|
2872
2872
|
uniform mat4 bindMatrix;
|
|
2873
2873
|
uniform mat4 bindMatrixInverse;
|
|
2874
2874
|
uniform highp sampler2D boneTexture;
|
|
@@ -2883,7 +2883,7 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2883
2883
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2884
2884
|
return mat4( v1, v2, v3, v4 );
|
|
2885
2885
|
}
|
|
2886
|
-
#endif`,
|
|
2886
|
+
#endif`,j6=`#ifdef USE_SKINNING
|
|
2887
2887
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2888
2888
|
vec4 skinned = vec4( 0.0 );
|
|
2889
2889
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2891,7 +2891,7 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2891
2891
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2892
2892
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2893
2893
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2894
|
-
#endif`,
|
|
2894
|
+
#endif`,Q6=`#ifdef USE_SKINNING
|
|
2895
2895
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2896
2896
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2897
2897
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2902,17 +2902,17 @@ gl_Position = projectionMatrix * mvPosition;`,GC=`#ifdef DITHERING
|
|
|
2902
2902
|
#ifdef USE_TANGENT
|
|
2903
2903
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2904
2904
|
#endif
|
|
2905
|
-
#endif`,
|
|
2905
|
+
#endif`,tC=`float specularStrength;
|
|
2906
2906
|
#ifdef USE_SPECULARMAP
|
|
2907
2907
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2908
2908
|
specularStrength = texelSpecular.r;
|
|
2909
2909
|
#else
|
|
2910
2910
|
specularStrength = 1.0;
|
|
2911
|
-
#endif`,
|
|
2911
|
+
#endif`,eC=`#ifdef USE_SPECULARMAP
|
|
2912
2912
|
uniform sampler2D specularMap;
|
|
2913
|
-
#endif`,
|
|
2913
|
+
#endif`,iC=`#if defined( TONE_MAPPING )
|
|
2914
2914
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2915
|
-
#endif`,
|
|
2915
|
+
#endif`,nC=`#ifndef saturate
|
|
2916
2916
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2917
2917
|
#endif
|
|
2918
2918
|
uniform float toneMappingExposure;
|
|
@@ -3009,7 +3009,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
3009
3009
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
3010
3010
|
return mix( color, vec3( newPeak ), g );
|
|
3011
3011
|
}
|
|
3012
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
3012
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,sC=`#ifdef USE_TRANSMISSION
|
|
3013
3013
|
material.transmission = transmission;
|
|
3014
3014
|
material.transmissionAlpha = 1.0;
|
|
3015
3015
|
material.thickness = thickness;
|
|
@@ -3030,7 +3030,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3030
3030
|
material.attenuationColor, material.attenuationDistance );
|
|
3031
3031
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
3032
3032
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
3033
|
-
#endif`,
|
|
3033
|
+
#endif`,rC=`#ifdef USE_TRANSMISSION
|
|
3034
3034
|
uniform float transmission;
|
|
3035
3035
|
uniform float thickness;
|
|
3036
3036
|
uniform float attenuationDistance;
|
|
@@ -3156,7 +3156,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3156
3156
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
3157
3157
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
3158
3158
|
}
|
|
3159
|
-
#endif`,
|
|
3159
|
+
#endif`,aC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3160
3160
|
varying vec2 vUv;
|
|
3161
3161
|
#endif
|
|
3162
3162
|
#ifdef USE_MAP
|
|
@@ -3226,7 +3226,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3226
3226
|
#ifdef USE_THICKNESSMAP
|
|
3227
3227
|
uniform mat3 thicknessMapTransform;
|
|
3228
3228
|
varying vec2 vThicknessMapUv;
|
|
3229
|
-
#endif`,
|
|
3229
|
+
#endif`,oC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3230
3230
|
varying vec2 vUv;
|
|
3231
3231
|
#endif
|
|
3232
3232
|
#ifdef USE_MAP
|
|
@@ -3320,7 +3320,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3320
3320
|
#ifdef USE_THICKNESSMAP
|
|
3321
3321
|
uniform mat3 thicknessMapTransform;
|
|
3322
3322
|
varying vec2 vThicknessMapUv;
|
|
3323
|
-
#endif`,
|
|
3323
|
+
#endif`,cC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3324
3324
|
vUv = vec3( uv, 1 ).xy;
|
|
3325
3325
|
#endif
|
|
3326
3326
|
#ifdef USE_MAP
|
|
@@ -3391,7 +3391,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3391
3391
|
#endif
|
|
3392
3392
|
#ifdef USE_THICKNESSMAP
|
|
3393
3393
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
3394
|
-
#endif`,
|
|
3394
|
+
#endif`,lC=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
3395
3395
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
3396
3396
|
#ifdef USE_BATCHING
|
|
3397
3397
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -3400,12 +3400,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,s6=`#ifdef USE_TRANSMISS
|
|
|
3400
3400
|
worldPosition = instanceMatrix * worldPosition;
|
|
3401
3401
|
#endif
|
|
3402
3402
|
worldPosition = modelMatrix * worldPosition;
|
|
3403
|
-
#endif`;const
|
|
3403
|
+
#endif`;const hC=`varying vec2 vUv;
|
|
3404
3404
|
uniform mat3 uvTransform;
|
|
3405
3405
|
void main() {
|
|
3406
3406
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3407
3407
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
3408
|
-
}`,
|
|
3408
|
+
}`,uC=`uniform sampler2D t2D;
|
|
3409
3409
|
uniform float backgroundIntensity;
|
|
3410
3410
|
varying vec2 vUv;
|
|
3411
3411
|
void main() {
|
|
@@ -3417,14 +3417,14 @@ void main() {
|
|
|
3417
3417
|
gl_FragColor = texColor;
|
|
3418
3418
|
#include <tonemapping_fragment>
|
|
3419
3419
|
#include <colorspace_fragment>
|
|
3420
|
-
}`,
|
|
3420
|
+
}`,dC=`varying vec3 vWorldDirection;
|
|
3421
3421
|
#include <common>
|
|
3422
3422
|
void main() {
|
|
3423
3423
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3424
3424
|
#include <begin_vertex>
|
|
3425
3425
|
#include <project_vertex>
|
|
3426
3426
|
gl_Position.z = gl_Position.w;
|
|
3427
|
-
}`,
|
|
3427
|
+
}`,fC=`#ifdef ENVMAP_TYPE_CUBE
|
|
3428
3428
|
uniform samplerCube envMap;
|
|
3429
3429
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
3430
3430
|
uniform sampler2D envMap;
|
|
@@ -3446,14 +3446,14 @@ void main() {
|
|
|
3446
3446
|
gl_FragColor = texColor;
|
|
3447
3447
|
#include <tonemapping_fragment>
|
|
3448
3448
|
#include <colorspace_fragment>
|
|
3449
|
-
}`,
|
|
3449
|
+
}`,pC=`varying vec3 vWorldDirection;
|
|
3450
3450
|
#include <common>
|
|
3451
3451
|
void main() {
|
|
3452
3452
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3453
3453
|
#include <begin_vertex>
|
|
3454
3454
|
#include <project_vertex>
|
|
3455
3455
|
gl_Position.z = gl_Position.w;
|
|
3456
|
-
}`,
|
|
3456
|
+
}`,mC=`uniform samplerCube tCube;
|
|
3457
3457
|
uniform float tFlip;
|
|
3458
3458
|
uniform float opacity;
|
|
3459
3459
|
varying vec3 vWorldDirection;
|
|
@@ -3463,7 +3463,7 @@ void main() {
|
|
|
3463
3463
|
gl_FragColor.a *= opacity;
|
|
3464
3464
|
#include <tonemapping_fragment>
|
|
3465
3465
|
#include <colorspace_fragment>
|
|
3466
|
-
}`,
|
|
3466
|
+
}`,gC=`#include <common>
|
|
3467
3467
|
#include <batching_pars_vertex>
|
|
3468
3468
|
#include <uv_pars_vertex>
|
|
3469
3469
|
#include <displacementmap_pars_vertex>
|
|
@@ -3490,7 +3490,7 @@ void main() {
|
|
|
3490
3490
|
#include <logdepthbuf_vertex>
|
|
3491
3491
|
#include <clipping_planes_vertex>
|
|
3492
3492
|
vHighPrecisionZW = gl_Position.zw;
|
|
3493
|
-
}`,
|
|
3493
|
+
}`,vC=`#if DEPTH_PACKING == 3200
|
|
3494
3494
|
uniform float opacity;
|
|
3495
3495
|
#endif
|
|
3496
3496
|
#include <common>
|
|
@@ -3528,7 +3528,7 @@ void main() {
|
|
|
3528
3528
|
#elif DEPTH_PACKING == 3203
|
|
3529
3529
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
3530
3530
|
#endif
|
|
3531
|
-
}`,
|
|
3531
|
+
}`,MC=`#define DISTANCE
|
|
3532
3532
|
varying vec3 vWorldPosition;
|
|
3533
3533
|
#include <common>
|
|
3534
3534
|
#include <batching_pars_vertex>
|
|
@@ -3555,7 +3555,7 @@ void main() {
|
|
|
3555
3555
|
#include <worldpos_vertex>
|
|
3556
3556
|
#include <clipping_planes_vertex>
|
|
3557
3557
|
vWorldPosition = worldPosition.xyz;
|
|
3558
|
-
}`,
|
|
3558
|
+
}`,yC=`#define DISTANCE
|
|
3559
3559
|
uniform vec3 referencePosition;
|
|
3560
3560
|
uniform float nearDistance;
|
|
3561
3561
|
uniform float farDistance;
|
|
@@ -3578,13 +3578,13 @@ void main() {
|
|
|
3578
3578
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3579
3579
|
dist = saturate( dist );
|
|
3580
3580
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3581
|
-
}`,
|
|
3581
|
+
}`,wC=`varying vec3 vWorldDirection;
|
|
3582
3582
|
#include <common>
|
|
3583
3583
|
void main() {
|
|
3584
3584
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3585
3585
|
#include <begin_vertex>
|
|
3586
3586
|
#include <project_vertex>
|
|
3587
|
-
}`,
|
|
3587
|
+
}`,xC=`uniform sampler2D tEquirect;
|
|
3588
3588
|
varying vec3 vWorldDirection;
|
|
3589
3589
|
#include <common>
|
|
3590
3590
|
void main() {
|
|
@@ -3593,7 +3593,7 @@ void main() {
|
|
|
3593
3593
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3594
3594
|
#include <tonemapping_fragment>
|
|
3595
3595
|
#include <colorspace_fragment>
|
|
3596
|
-
}`,
|
|
3596
|
+
}`,bC=`uniform float scale;
|
|
3597
3597
|
attribute float lineDistance;
|
|
3598
3598
|
varying float vLineDistance;
|
|
3599
3599
|
#include <common>
|
|
@@ -3615,7 +3615,7 @@ void main() {
|
|
|
3615
3615
|
#include <logdepthbuf_vertex>
|
|
3616
3616
|
#include <clipping_planes_vertex>
|
|
3617
3617
|
#include <fog_vertex>
|
|
3618
|
-
}`,
|
|
3618
|
+
}`,SC=`uniform vec3 diffuse;
|
|
3619
3619
|
uniform float opacity;
|
|
3620
3620
|
uniform float dashSize;
|
|
3621
3621
|
uniform float totalSize;
|
|
@@ -3643,7 +3643,7 @@ void main() {
|
|
|
3643
3643
|
#include <colorspace_fragment>
|
|
3644
3644
|
#include <fog_fragment>
|
|
3645
3645
|
#include <premultiplied_alpha_fragment>
|
|
3646
|
-
}`,
|
|
3646
|
+
}`,EC=`#include <common>
|
|
3647
3647
|
#include <batching_pars_vertex>
|
|
3648
3648
|
#include <uv_pars_vertex>
|
|
3649
3649
|
#include <envmap_pars_vertex>
|
|
@@ -3675,7 +3675,7 @@ void main() {
|
|
|
3675
3675
|
#include <worldpos_vertex>
|
|
3676
3676
|
#include <envmap_vertex>
|
|
3677
3677
|
#include <fog_vertex>
|
|
3678
|
-
}`,
|
|
3678
|
+
}`,AC=`uniform vec3 diffuse;
|
|
3679
3679
|
uniform float opacity;
|
|
3680
3680
|
#ifndef FLAT_SHADED
|
|
3681
3681
|
varying vec3 vNormal;
|
|
@@ -3723,7 +3723,7 @@ void main() {
|
|
|
3723
3723
|
#include <fog_fragment>
|
|
3724
3724
|
#include <premultiplied_alpha_fragment>
|
|
3725
3725
|
#include <dithering_fragment>
|
|
3726
|
-
}`,
|
|
3726
|
+
}`,_C=`#define LAMBERT
|
|
3727
3727
|
varying vec3 vViewPosition;
|
|
3728
3728
|
#include <common>
|
|
3729
3729
|
#include <batching_pars_vertex>
|
|
@@ -3762,7 +3762,7 @@ void main() {
|
|
|
3762
3762
|
#include <envmap_vertex>
|
|
3763
3763
|
#include <shadowmap_vertex>
|
|
3764
3764
|
#include <fog_vertex>
|
|
3765
|
-
}`,
|
|
3765
|
+
}`,TC=`#define LAMBERT
|
|
3766
3766
|
uniform vec3 diffuse;
|
|
3767
3767
|
uniform vec3 emissive;
|
|
3768
3768
|
uniform float opacity;
|
|
@@ -3820,7 +3820,7 @@ void main() {
|
|
|
3820
3820
|
#include <fog_fragment>
|
|
3821
3821
|
#include <premultiplied_alpha_fragment>
|
|
3822
3822
|
#include <dithering_fragment>
|
|
3823
|
-
}`,
|
|
3823
|
+
}`,RC=`#define MATCAP
|
|
3824
3824
|
varying vec3 vViewPosition;
|
|
3825
3825
|
#include <common>
|
|
3826
3826
|
#include <batching_pars_vertex>
|
|
@@ -3854,7 +3854,7 @@ void main() {
|
|
|
3854
3854
|
#include <clipping_planes_vertex>
|
|
3855
3855
|
#include <fog_vertex>
|
|
3856
3856
|
vViewPosition = - mvPosition.xyz;
|
|
3857
|
-
}`,
|
|
3857
|
+
}`,IC=`#define MATCAP
|
|
3858
3858
|
uniform vec3 diffuse;
|
|
3859
3859
|
uniform float opacity;
|
|
3860
3860
|
uniform sampler2D matcap;
|
|
@@ -3900,7 +3900,7 @@ void main() {
|
|
|
3900
3900
|
#include <fog_fragment>
|
|
3901
3901
|
#include <premultiplied_alpha_fragment>
|
|
3902
3902
|
#include <dithering_fragment>
|
|
3903
|
-
}`,
|
|
3903
|
+
}`,DC=`#define NORMAL
|
|
3904
3904
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3905
3905
|
varying vec3 vViewPosition;
|
|
3906
3906
|
#endif
|
|
@@ -3933,7 +3933,7 @@ void main() {
|
|
|
3933
3933
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3934
3934
|
vViewPosition = - mvPosition.xyz;
|
|
3935
3935
|
#endif
|
|
3936
|
-
}`,
|
|
3936
|
+
}`,CC=`#define NORMAL
|
|
3937
3937
|
uniform float opacity;
|
|
3938
3938
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3939
3939
|
varying vec3 vViewPosition;
|
|
@@ -3954,7 +3954,7 @@ void main() {
|
|
|
3954
3954
|
#ifdef OPAQUE
|
|
3955
3955
|
gl_FragColor.a = 1.0;
|
|
3956
3956
|
#endif
|
|
3957
|
-
}`,
|
|
3957
|
+
}`,OC=`#define PHONG
|
|
3958
3958
|
varying vec3 vViewPosition;
|
|
3959
3959
|
#include <common>
|
|
3960
3960
|
#include <batching_pars_vertex>
|
|
@@ -3993,7 +3993,7 @@ void main() {
|
|
|
3993
3993
|
#include <envmap_vertex>
|
|
3994
3994
|
#include <shadowmap_vertex>
|
|
3995
3995
|
#include <fog_vertex>
|
|
3996
|
-
}`,
|
|
3996
|
+
}`,PC=`#define PHONG
|
|
3997
3997
|
uniform vec3 diffuse;
|
|
3998
3998
|
uniform vec3 emissive;
|
|
3999
3999
|
uniform vec3 specular;
|
|
@@ -4053,7 +4053,7 @@ void main() {
|
|
|
4053
4053
|
#include <fog_fragment>
|
|
4054
4054
|
#include <premultiplied_alpha_fragment>
|
|
4055
4055
|
#include <dithering_fragment>
|
|
4056
|
-
}`,
|
|
4056
|
+
}`,NC=`#define STANDARD
|
|
4057
4057
|
varying vec3 vViewPosition;
|
|
4058
4058
|
#ifdef USE_TRANSMISSION
|
|
4059
4059
|
varying vec3 vWorldPosition;
|
|
@@ -4096,7 +4096,7 @@ void main() {
|
|
|
4096
4096
|
#ifdef USE_TRANSMISSION
|
|
4097
4097
|
vWorldPosition = worldPosition.xyz;
|
|
4098
4098
|
#endif
|
|
4099
|
-
}`,
|
|
4099
|
+
}`,LC=`#define STANDARD
|
|
4100
4100
|
#ifdef PHYSICAL
|
|
4101
4101
|
#define IOR
|
|
4102
4102
|
#define USE_SPECULAR
|
|
@@ -4221,7 +4221,7 @@ void main() {
|
|
|
4221
4221
|
#include <fog_fragment>
|
|
4222
4222
|
#include <premultiplied_alpha_fragment>
|
|
4223
4223
|
#include <dithering_fragment>
|
|
4224
|
-
}`,
|
|
4224
|
+
}`,kC=`#define TOON
|
|
4225
4225
|
varying vec3 vViewPosition;
|
|
4226
4226
|
#include <common>
|
|
4227
4227
|
#include <batching_pars_vertex>
|
|
@@ -4258,7 +4258,7 @@ void main() {
|
|
|
4258
4258
|
#include <worldpos_vertex>
|
|
4259
4259
|
#include <shadowmap_vertex>
|
|
4260
4260
|
#include <fog_vertex>
|
|
4261
|
-
}`,
|
|
4261
|
+
}`,FC=`#define TOON
|
|
4262
4262
|
uniform vec3 diffuse;
|
|
4263
4263
|
uniform vec3 emissive;
|
|
4264
4264
|
uniform float opacity;
|
|
@@ -4310,7 +4310,7 @@ void main() {
|
|
|
4310
4310
|
#include <fog_fragment>
|
|
4311
4311
|
#include <premultiplied_alpha_fragment>
|
|
4312
4312
|
#include <dithering_fragment>
|
|
4313
|
-
}`,
|
|
4313
|
+
}`,UC=`uniform float size;
|
|
4314
4314
|
uniform float scale;
|
|
4315
4315
|
#include <common>
|
|
4316
4316
|
#include <color_pars_vertex>
|
|
@@ -4341,7 +4341,7 @@ void main() {
|
|
|
4341
4341
|
#include <clipping_planes_vertex>
|
|
4342
4342
|
#include <worldpos_vertex>
|
|
4343
4343
|
#include <fog_vertex>
|
|
4344
|
-
}`,
|
|
4344
|
+
}`,zC=`uniform vec3 diffuse;
|
|
4345
4345
|
uniform float opacity;
|
|
4346
4346
|
#include <common>
|
|
4347
4347
|
#include <color_pars_fragment>
|
|
@@ -4366,7 +4366,7 @@ void main() {
|
|
|
4366
4366
|
#include <colorspace_fragment>
|
|
4367
4367
|
#include <fog_fragment>
|
|
4368
4368
|
#include <premultiplied_alpha_fragment>
|
|
4369
|
-
}`,
|
|
4369
|
+
}`,BC=`#include <common>
|
|
4370
4370
|
#include <batching_pars_vertex>
|
|
4371
4371
|
#include <fog_pars_vertex>
|
|
4372
4372
|
#include <morphtarget_pars_vertex>
|
|
@@ -4389,7 +4389,7 @@ void main() {
|
|
|
4389
4389
|
#include <worldpos_vertex>
|
|
4390
4390
|
#include <shadowmap_vertex>
|
|
4391
4391
|
#include <fog_vertex>
|
|
4392
|
-
}`,
|
|
4392
|
+
}`,HC=`uniform vec3 color;
|
|
4393
4393
|
uniform float opacity;
|
|
4394
4394
|
#include <common>
|
|
4395
4395
|
#include <fog_pars_fragment>
|
|
@@ -4405,7 +4405,7 @@ void main() {
|
|
|
4405
4405
|
#include <colorspace_fragment>
|
|
4406
4406
|
#include <fog_fragment>
|
|
4407
4407
|
#include <premultiplied_alpha_fragment>
|
|
4408
|
-
}`,
|
|
4408
|
+
}`,GC=`uniform float rotation;
|
|
4409
4409
|
uniform vec2 center;
|
|
4410
4410
|
#include <common>
|
|
4411
4411
|
#include <uv_pars_vertex>
|
|
@@ -4429,7 +4429,7 @@ void main() {
|
|
|
4429
4429
|
#include <logdepthbuf_vertex>
|
|
4430
4430
|
#include <clipping_planes_vertex>
|
|
4431
4431
|
#include <fog_vertex>
|
|
4432
|
-
}`,
|
|
4432
|
+
}`,VC=`uniform vec3 diffuse;
|
|
4433
4433
|
uniform float opacity;
|
|
4434
4434
|
#include <common>
|
|
4435
4435
|
#include <uv_pars_fragment>
|
|
@@ -4454,7 +4454,7 @@ void main() {
|
|
|
4454
4454
|
#include <tonemapping_fragment>
|
|
4455
4455
|
#include <colorspace_fragment>
|
|
4456
4456
|
#include <fog_fragment>
|
|
4457
|
-
}`,ue={alphahash_fragment:hD,alphahash_pars_fragment:uD,alphamap_fragment:dD,alphamap_pars_fragment:fD,alphatest_fragment:pD,alphatest_pars_fragment:mD,aomap_fragment:gD,aomap_pars_fragment:vD,batching_pars_vertex:MD,batching_vertex:yD,begin_vertex:wD,beginnormal_vertex:xD,bsdfs:bD,iridescence_fragment:SD,bumpmap_pars_fragment:ED,clipping_planes_fragment:AD,clipping_planes_pars_fragment:_D,clipping_planes_pars_vertex:TD,clipping_planes_vertex:RD,color_fragment:ID,color_pars_fragment:DD,color_pars_vertex:CD,color_vertex:OD,common:PD,cube_uv_reflection_fragment:ND,defaultnormal_vertex:LD,displacementmap_pars_vertex:kD,displacementmap_vertex:FD,emissivemap_fragment:UD,emissivemap_pars_fragment:zD,colorspace_fragment:BD,colorspace_pars_fragment:HD,envmap_fragment:GD,envmap_common_pars_fragment:VD,envmap_pars_fragment:WD,envmap_pars_vertex:XD,envmap_physical_pars_fragment:iC,envmap_vertex:$D,fog_vertex:YD,fog_pars_vertex:KD,fog_fragment:qD,fog_pars_fragment:ZD,gradientmap_pars_fragment:JD,lightmap_pars_fragment:jD,lights_lambert_fragment:QD,lights_lambert_pars_fragment:tC,lights_pars_begin:eC,lights_toon_fragment:nC,lights_toon_pars_fragment:sC,lights_phong_fragment:rC,lights_phong_pars_fragment:aC,lights_physical_fragment:oC,lights_physical_pars_fragment:cC,lights_fragment_begin:lC,lights_fragment_maps:hC,lights_fragment_end:uC,lightprobes_pars_fragment:dC,logdepthbuf_fragment:fC,logdepthbuf_pars_fragment:pC,logdepthbuf_pars_vertex:mC,logdepthbuf_vertex:gC,map_fragment:vC,map_pars_fragment:MC,map_particle_fragment:yC,map_particle_pars_fragment:wC,metalnessmap_fragment:xC,metalnessmap_pars_fragment:bC,morphinstance_vertex:SC,morphcolor_vertex:EC,morphnormal_vertex:AC,morphtarget_pars_vertex:_C,morphtarget_vertex:TC,normal_fragment_begin:RC,normal_fragment_maps:IC,normal_pars_fragment:DC,normal_pars_vertex:CC,normal_vertex:OC,normalmap_pars_fragment:PC,clearcoat_normal_fragment_begin:NC,clearcoat_normal_fragment_maps:LC,clearcoat_pars_fragment:kC,iridescence_pars_fragment:FC,opaque_fragment:UC,packing:zC,premultiplied_alpha_fragment:BC,project_vertex:HC,dithering_fragment:GC,dithering_pars_fragment:VC,roughnessmap_fragment:WC,roughnessmap_pars_fragment:XC,shadowmap_pars_fragment:$C,shadowmap_pars_vertex:YC,shadowmap_vertex:KC,shadowmask_pars_fragment:qC,skinbase_vertex:ZC,skinning_pars_vertex:JC,skinning_vertex:jC,skinnormal_vertex:QC,specularmap_fragment:t6,specularmap_pars_fragment:e6,tonemapping_fragment:i6,tonemapping_pars_fragment:n6,transmission_fragment:s6,transmission_pars_fragment:r6,uv_pars_fragment:a6,uv_pars_vertex:o6,uv_vertex:c6,worldpos_vertex:l6,background_vert:h6,background_frag:u6,backgroundCube_vert:d6,backgroundCube_frag:f6,cube_vert:p6,cube_frag:m6,depth_vert:g6,depth_frag:v6,distance_vert:M6,distance_frag:y6,equirect_vert:w6,equirect_frag:x6,linedashed_vert:b6,linedashed_frag:S6,meshbasic_vert:E6,meshbasic_frag:A6,meshlambert_vert:_6,meshlambert_frag:T6,meshmatcap_vert:R6,meshmatcap_frag:I6,meshnormal_vert:D6,meshnormal_frag:C6,meshphong_vert:O6,meshphong_frag:P6,meshphysical_vert:N6,meshphysical_frag:L6,meshtoon_vert:k6,meshtoon_frag:F6,points_vert:U6,points_frag:z6,shadow_vert:B6,shadow_frag:H6,sprite_vert:G6,sprite_frag:V6},bt={common:{diffuse:{value:new rt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new de},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new de}},envmap:{envMap:{value:null},envMapRotation:{value:new de},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new de}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new de}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new de},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new de},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new de},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new de}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new de}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new de}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new rt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new T},probesMax:{value:new T},probesResolution:{value:new T}},points:{diffuse:{value:new rt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0},uvTransform:{value:new de}},sprite:{diffuse:{value:new rt(16777215)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new de},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0}}},fa={basic:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:ue.meshbasic_vert,fragmentShader:ue.meshbasic_frag},lambert:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},envMapIntensity:{value:1}}]),vertexShader:ue.meshlambert_vert,fragmentShader:ue.meshlambert_frag},phong:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},specular:{value:new rt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ue.meshphong_vert,fragmentShader:ue.meshphong_frag},standard:{uniforms:ws([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ue.meshphysical_vert,fragmentShader:ue.meshphysical_frag},toon:{uniforms:ws([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new rt(0)}}]),vertexShader:ue.meshtoon_vert,fragmentShader:ue.meshtoon_frag},matcap:{uniforms:ws([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:ue.meshmatcap_vert,fragmentShader:ue.meshmatcap_frag},points:{uniforms:ws([bt.points,bt.fog]),vertexShader:ue.points_vert,fragmentShader:ue.points_frag},dashed:{uniforms:ws([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ue.linedashed_vert,fragmentShader:ue.linedashed_frag},depth:{uniforms:ws([bt.common,bt.displacementmap]),vertexShader:ue.depth_vert,fragmentShader:ue.depth_frag},normal:{uniforms:ws([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:ue.meshnormal_vert,fragmentShader:ue.meshnormal_frag},sprite:{uniforms:ws([bt.sprite,bt.fog]),vertexShader:ue.sprite_vert,fragmentShader:ue.sprite_frag},background:{uniforms:{uvTransform:{value:new de},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ue.background_vert,fragmentShader:ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new de}},vertexShader:ue.backgroundCube_vert,fragmentShader:ue.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ue.cube_vert,fragmentShader:ue.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ue.equirect_vert,fragmentShader:ue.equirect_frag},distance:{uniforms:ws([bt.common,bt.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ue.distance_vert,fragmentShader:ue.distance_frag},shadow:{uniforms:ws([bt.lights,bt.fog,{color:{value:new rt(0)},opacity:{value:1}}]),vertexShader:ue.shadow_vert,fragmentShader:ue.shadow_frag}};fa.physical={uniforms:ws([fa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new de},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new de},clearcoatNormalScale:{value:new tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new de},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new de},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new de},sheen:{value:0},sheenColor:{value:new rt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new de},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new de},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new de},transmissionSamplerSize:{value:new tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new de},attenuationDistance:{value:0},attenuationColor:{value:new rt(0)},specularColor:{value:new rt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new de},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new de},anisotropyVector:{value:new tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new de}}]),vertexShader:ue.meshphysical_vert,fragmentShader:ue.meshphysical_frag};const Mp={r:0,b:0,g:0},W6=new Gt,NA=new de;NA.set(-1,0,0,0,1,0,0,0,1);function X6(o,t,e,i,n,s){const r=new rt(0);let a=n===!0?0:1,c,l,h=null,u=0,d=null;function f(M){let w=M.isScene===!0?M.background:null;if(w&&w.isTexture){const y=M.backgroundBlurriness>0;w=t.get(w,y)}return w}function p(M){let w=!1;const y=f(M);y===null?g(r,a):y&&y.isColor&&(g(y,1),w=!0);const x=o.xr.getEnvironmentBlendMode();x==="additive"?e.buffers.color.setClear(0,0,0,1,s):x==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(o.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),o.clear(o.autoClearColor,o.autoClearDepth,o.autoClearStencil))}function m(M,w){const y=f(w);y&&(y.isCubeTexture||y.mapping===Dm)?(l===void 0&&(l=new yt(new en(1,1,1),new De({name:"BackgroundCubeMaterial",uniforms:Mu(fa.backgroundCube.uniforms),vertexShader:fa.backgroundCube.vertexShader,fragmentShader:fa.backgroundCube.fragmentShader,side:zi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(x,b,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(W6.makeRotationFromEuler(w.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(NA),l.material.toneMapped=He.getTransfer(y.colorSpace)!==ui,(h!==y||u!==y.version||d!==o.toneMapping)&&(l.material.needsUpdate=!0,h=y,u=y.version,d=o.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new yt(new vs(2,2),new De({name:"BackgroundMaterial",uniforms:Mu(fa.background.uniforms),vertexShader:fa.background.vertexShader,fragmentShader:fa.background.fragmentShader,side:Ba,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=He.getTransfer(y.colorSpace)!==ui,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||u!==y.version||d!==o.toneMapping)&&(c.material.needsUpdate=!0,h=y,u=y.version,d=o.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function g(M,w){M.getRGB(Mp,AA(o)),e.buffers.color.setClear(Mp.r,Mp.g,Mp.b,w,s)}function v(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(M,w=1){r.set(M),a=w,g(r,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,g(r,a)},render:p,addToRenderList:m,dispose:v}}function $6(o,t){const e=o.getParameter(o.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function a(I,D,O,P,N){let k=!1;const B=u(I,P,O,D);s!==B&&(s=B,l(s.object)),k=f(I,P,O,N),k&&p(I,P,O,N),N!==null&&t.update(N,o.ELEMENT_ARRAY_BUFFER),(k||r)&&(r=!1,y(I,D,O,P),N!==null&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.get(N).buffer))}function c(){return o.createVertexArray()}function l(I){return o.bindVertexArray(I)}function h(I){return o.deleteVertexArray(I)}function u(I,D,O,P){const N=P.wireframe===!0;let k=i[D.id];k===void 0&&(k={},i[D.id]=k);const B=I.isInstancedMesh===!0?I.id:0;let W=k[B];W===void 0&&(W={},k[B]=W);let Q=W[O.id];Q===void 0&&(Q={},W[O.id]=Q);let Z=Q[N];return Z===void 0&&(Z=d(c()),Q[N]=Z),Z}function d(I){const D=[],O=[],P=[];for(let N=0;N<e;N++)D[N]=0,O[N]=0,P[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:O,attributeDivisors:P,object:I,attributes:{},index:null}}function f(I,D,O,P){const N=s.attributes,k=D.attributes;let B=0;const W=O.getAttributes();for(const Q in W)if(W[Q].location>=0){const nt=N[Q];let ot=k[Q];if(ot===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(ot=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(ot=I.instanceColor)),nt===void 0||nt.attribute!==ot||ot&&nt.data!==ot.data)return!0;B++}return s.attributesNum!==B||s.index!==P}function p(I,D,O,P){const N={},k=D.attributes;let B=0;const W=O.getAttributes();for(const Q in W)if(W[Q].location>=0){let nt=k[Q];nt===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(nt=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(nt=I.instanceColor));const ot={};ot.attribute=nt,nt&&nt.data&&(ot.data=nt.data),N[Q]=ot,B++}s.attributes=N,s.attributesNum=B,s.index=P}function m(){const I=s.newAttributes;for(let D=0,O=I.length;D<O;D++)I[D]=0}function g(I){v(I,0)}function v(I,D){const O=s.newAttributes,P=s.enabledAttributes,N=s.attributeDivisors;O[I]=1,P[I]===0&&(o.enableVertexAttribArray(I),P[I]=1),N[I]!==D&&(o.vertexAttribDivisor(I,D),N[I]=D)}function M(){const I=s.newAttributes,D=s.enabledAttributes;for(let O=0,P=D.length;O<P;O++)D[O]!==I[O]&&(o.disableVertexAttribArray(O),D[O]=0)}function w(I,D,O,P,N,k,B){B===!0?o.vertexAttribIPointer(I,D,O,N,k):o.vertexAttribPointer(I,D,O,P,N,k)}function y(I,D,O,P){m();const N=P.attributes,k=O.getAttributes(),B=D.defaultAttributeValues;for(const W in k){const Q=k[W];if(Q.location>=0){let Z=N[W];if(Z===void 0&&(W==="instanceMatrix"&&I.instanceMatrix&&(Z=I.instanceMatrix),W==="instanceColor"&&I.instanceColor&&(Z=I.instanceColor)),Z!==void 0){const nt=Z.normalized,ot=Z.itemSize,Ut=t.get(Z);if(Ut===void 0)continue;const Zt=Ut.buffer,jt=Ut.type,K=Ut.bytesPerElement,lt=jt===o.INT||jt===o.UNSIGNED_INT||Z.gpuType===oy;if(Z.isInterleavedBufferAttribute){const ct=Z.data,V=ct.stride,Lt=Z.offset;if(ct.isInstancedInterleavedBuffer){for(let Xt=0;Xt<Q.locationSize;Xt++)v(Q.location+Xt,ct.meshPerAttribute);I.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let Xt=0;Xt<Q.locationSize;Xt++)g(Q.location+Xt);o.bindBuffer(o.ARRAY_BUFFER,Zt);for(let Xt=0;Xt<Q.locationSize;Xt++)w(Q.location+Xt,ot/Q.locationSize,jt,nt,V*K,(Lt+ot/Q.locationSize*Xt)*K,lt)}else{if(Z.isInstancedBufferAttribute){for(let ct=0;ct<Q.locationSize;ct++)v(Q.location+ct,Z.meshPerAttribute);I.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ct=0;ct<Q.locationSize;ct++)g(Q.location+ct);o.bindBuffer(o.ARRAY_BUFFER,Zt);for(let ct=0;ct<Q.locationSize;ct++)w(Q.location+ct,ot/Q.locationSize,jt,nt,ot*K,ot/Q.locationSize*ct*K,lt)}}else if(B!==void 0){const nt=B[W];if(nt!==void 0)switch(nt.length){case 2:o.vertexAttrib2fv(Q.location,nt);break;case 3:o.vertexAttrib3fv(Q.location,nt);break;case 4:o.vertexAttrib4fv(Q.location,nt);break;default:o.vertexAttrib1fv(Q.location,nt)}}}}M()}function x(){A();for(const I in i){const D=i[I];for(const O in D){const P=D[O];for(const N in P){const k=P[N];for(const B in k)h(k[B].object),delete k[B];delete P[N]}}delete i[I]}}function b(I){if(i[I.id]===void 0)return;const D=i[I.id];for(const O in D){const P=D[O];for(const N in P){const k=P[N];for(const B in k)h(k[B].object),delete k[B];delete P[N]}}delete i[I.id]}function E(I){for(const D in i){const O=i[D];for(const P in O){const N=O[P];if(N[I.id]===void 0)continue;const k=N[I.id];for(const B in k)h(k[B].object),delete k[B];delete N[I.id]}}}function S(I){for(const D in i){const O=i[D],P=I.isInstancedMesh===!0?I.id:0,N=O[P];if(N!==void 0){for(const k in N){const B=N[k];for(const W in B)h(B[W].object),delete B[W];delete N[k]}delete O[P],Object.keys(O).length===0&&delete i[D]}}}function A(){_(),r=!0,s!==n&&(s=n,l(s.object))}function _(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:a,reset:A,resetDefaultState:_,dispose:x,releaseStatesOfGeometry:b,releaseStatesOfObject:S,releaseStatesOfProgram:E,initAttributes:m,enableAttribute:g,disableUnusedAttributes:M}}function Y6(o,t,e){let i;function n(c){i=c}function s(c,l){o.drawArrays(i,c,l),e.update(l,i,1)}function r(c,l,h){h!==0&&(o.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function a(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=a}function K6(o,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");n=o.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(E){return!(E!==tn&&i.convert(E)!==o.getParameter(o.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){const S=E===Ye&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==fs&&i.convert(E)!==o.getParameter(o.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==ts&&!S)}function c(E){if(E==="highp"){if(o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.HIGH_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.MEDIUM_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Ht("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Ht("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),p=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=o.getParameter(o.MAX_TEXTURE_SIZE),g=o.getParameter(o.MAX_CUBE_MAP_TEXTURE_SIZE),v=o.getParameter(o.MAX_VERTEX_ATTRIBS),M=o.getParameter(o.MAX_VERTEX_UNIFORM_VECTORS),w=o.getParameter(o.MAX_VARYING_VECTORS),y=o.getParameter(o.MAX_FRAGMENT_UNIFORM_VECTORS),x=o.getParameter(o.MAX_SAMPLES),b=o.getParameter(o.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:y,maxSamples:x,samples:b}}function q6(o){const t=this;let e=null,i=0,n=!1,s=!1;const r=new Hr,a=new de,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,m=u.clipIntersection,g=u.clipShadows,v=o.get(u);if(!n||p===null||p.length===0||s&&!g)s?h(null):l();else{const M=s?0:i,w=M*4;let y=v.clippingState||null;c.value=y,y=h(p,d,w,f);for(let x=0;x!==w;++x)y[x]=e[x];v.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=M}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const m=u!==null?u.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const v=f+m*4,M=d.matrixWorldInverse;a.getNormalMatrix(M),(g===null||g.length<v)&&(g=new Float32Array(v));for(let w=0,y=f;w!==m;++w,y+=4)r.copy(u[w]).applyMatrix4(M,a),r.normal.toArray(g,y),g[y+3]=r.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}const fc=4,Sx=[.125,.215,.35,.446,.526,.582],Gc=20,Z6=256,Vu=new ur,Ex=new rt;let Gg=null,Vg=0,Wg=0,Xg=!1;const J6=new T;class rM{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,s={}){const{size:r=256,position:a=J6}=s;Gg=this._renderer.getRenderTarget(),Vg=this._renderer.getActiveCubeFace(),Wg=this._renderer.getActiveMipmapLevel(),Xg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,c,a),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Tx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_x(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Gg,Vg,Wg),this._renderer.xr.enabled=Xg,t.scissorTest=!1,th(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===wl||t.mapping===pu?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Gg=this._renderer.getRenderTarget(),Vg=this._renderer.getActiveCubeFace(),Wg=this._renderer.getActiveMipmapLevel(),Xg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:Me,minFilter:Me,generateMipmaps:!1,type:Ye,format:tn,colorSpace:G0,depthBuffer:!1},n=Ax(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ax(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=j6(s)),this._blurMaterial=tO(s,t,e),this._ggxMaterial=Q6(s,t,e)}return n}_compileMaterial(t){const e=new yt(new be,t);this._renderer.compile(e,Vu)}_sceneToCubeUV(t,e,i,n,s){const c=new jn(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Ex),u.toneMapping=ka,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new yt(new en,new Is({name:"PMREM.Background",side:zi,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,g=m.material;let v=!1;const M=t.background;M?M.isColor&&(g.color.copy(M),t.background=null,v=!0):(g.color.copy(Ex),v=!0);for(let w=0;w<6;w++){const y=w%3;y===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):y===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const x=this._cubeSize;th(n,y*x,w>2?x:0,x,x),u.setRenderTarget(n),v&&u.render(m,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=M}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===wl||t.mapping===pu;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Tx()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_x());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const a=s.uniforms;a.envMap.value=t;const c=this._cubeSize;th(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(r,Vu)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[i];a.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,m=this._sizeLods[i],g=3*m*(i>p-fc?i-p+fc:0),v=4*(this._cubeSize-m);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,th(s,g,v,3*m,2*m),n.setRenderTarget(s),n.render(a,Vu),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,th(t,g,v,3*m,2*m),n.setRenderTarget(t),n.render(a,Vu)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&le("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Gc-1),m=s/p,g=isFinite(s)?1+Math.floor(h*m):Gc;g>Gc&&Ht(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Gc}`);const v=[];let M=0;for(let E=0;E<Gc;++E){const S=E/m,A=Math.exp(-S*S/2);v.push(A),E===0?M+=A:E<g&&(M+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/M;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=v,d.latitudinal.value=r==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const y=this._sizeLods[n],x=3*y*(n>w-fc?n-w+fc:0),b=4*(this._cubeSize-y);th(e,x,b,3*y,2*y),c.setRenderTarget(e),c.render(u,Vu)}}function j6(o){const t=[],e=[],i=[];let n=o;const s=o-fc+1+Sx.length;for(let r=0;r<s;r++){const a=Math.pow(2,n);t.push(a);let c=1/a;r>o-fc?c=Sx[r-o+fc-1]:r===0&&(c=0),e.push(c);const l=1/(a-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,m=3,g=2,v=1,M=new Float32Array(m*p*f),w=new Float32Array(g*p*f),y=new Float32Array(v*p*f);for(let b=0;b<f;b++){const E=b%3*2/3-1,S=b>2?0:-1,A=[E,S,0,E+2/3,S,0,E+2/3,S+1,0,E,S,0,E+2/3,S+1,0,E,S+1,0];M.set(A,m*p*b),w.set(d,g*p*b);const _=[b,b,b,b,b,b];y.set(_,v*p*b)}const x=new be;x.setAttribute("position",new ye(M,m)),x.setAttribute("uv",new ye(w,g)),x.setAttribute("faceIndex",new ye(y,v)),i.push(new yt(x,null)),n>fc&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Ax(o,t,e){const i=new Qe(o,t,e);return i.texture.mapping=Dm,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function th(o,t,e,i,n){o.viewport.set(t,e,i,n),o.scissor.set(t,e,i,n)}function Q6(o,t,e){return new De({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Z6,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Nm(),fragmentShader:`
|
|
4457
|
+
}`,ue={alphahash_fragment:hD,alphahash_pars_fragment:uD,alphamap_fragment:dD,alphamap_pars_fragment:fD,alphatest_fragment:pD,alphatest_pars_fragment:mD,aomap_fragment:gD,aomap_pars_fragment:vD,batching_pars_vertex:MD,batching_vertex:yD,begin_vertex:wD,beginnormal_vertex:xD,bsdfs:bD,iridescence_fragment:SD,bumpmap_pars_fragment:ED,clipping_planes_fragment:AD,clipping_planes_pars_fragment:_D,clipping_planes_pars_vertex:TD,clipping_planes_vertex:RD,color_fragment:ID,color_pars_fragment:DD,color_pars_vertex:CD,color_vertex:OD,common:PD,cube_uv_reflection_fragment:ND,defaultnormal_vertex:LD,displacementmap_pars_vertex:kD,displacementmap_vertex:FD,emissivemap_fragment:UD,emissivemap_pars_fragment:zD,colorspace_fragment:BD,colorspace_pars_fragment:HD,envmap_fragment:GD,envmap_common_pars_fragment:VD,envmap_pars_fragment:WD,envmap_pars_vertex:XD,envmap_physical_pars_fragment:i6,envmap_vertex:$D,fog_vertex:YD,fog_pars_vertex:KD,fog_fragment:qD,fog_pars_fragment:ZD,gradientmap_pars_fragment:JD,lightmap_pars_fragment:jD,lights_lambert_fragment:QD,lights_lambert_pars_fragment:t6,lights_pars_begin:e6,lights_toon_fragment:n6,lights_toon_pars_fragment:s6,lights_phong_fragment:r6,lights_phong_pars_fragment:a6,lights_physical_fragment:o6,lights_physical_pars_fragment:c6,lights_fragment_begin:l6,lights_fragment_maps:h6,lights_fragment_end:u6,lightprobes_pars_fragment:d6,logdepthbuf_fragment:f6,logdepthbuf_pars_fragment:p6,logdepthbuf_pars_vertex:m6,logdepthbuf_vertex:g6,map_fragment:v6,map_pars_fragment:M6,map_particle_fragment:y6,map_particle_pars_fragment:w6,metalnessmap_fragment:x6,metalnessmap_pars_fragment:b6,morphinstance_vertex:S6,morphcolor_vertex:E6,morphnormal_vertex:A6,morphtarget_pars_vertex:_6,morphtarget_vertex:T6,normal_fragment_begin:R6,normal_fragment_maps:I6,normal_pars_fragment:D6,normal_pars_vertex:C6,normal_vertex:O6,normalmap_pars_fragment:P6,clearcoat_normal_fragment_begin:N6,clearcoat_normal_fragment_maps:L6,clearcoat_pars_fragment:k6,iridescence_pars_fragment:F6,opaque_fragment:U6,packing:z6,premultiplied_alpha_fragment:B6,project_vertex:H6,dithering_fragment:G6,dithering_pars_fragment:V6,roughnessmap_fragment:W6,roughnessmap_pars_fragment:X6,shadowmap_pars_fragment:$6,shadowmap_pars_vertex:Y6,shadowmap_vertex:K6,shadowmask_pars_fragment:q6,skinbase_vertex:Z6,skinning_pars_vertex:J6,skinning_vertex:j6,skinnormal_vertex:Q6,specularmap_fragment:tC,specularmap_pars_fragment:eC,tonemapping_fragment:iC,tonemapping_pars_fragment:nC,transmission_fragment:sC,transmission_pars_fragment:rC,uv_pars_fragment:aC,uv_pars_vertex:oC,uv_vertex:cC,worldpos_vertex:lC,background_vert:hC,background_frag:uC,backgroundCube_vert:dC,backgroundCube_frag:fC,cube_vert:pC,cube_frag:mC,depth_vert:gC,depth_frag:vC,distance_vert:MC,distance_frag:yC,equirect_vert:wC,equirect_frag:xC,linedashed_vert:bC,linedashed_frag:SC,meshbasic_vert:EC,meshbasic_frag:AC,meshlambert_vert:_C,meshlambert_frag:TC,meshmatcap_vert:RC,meshmatcap_frag:IC,meshnormal_vert:DC,meshnormal_frag:CC,meshphong_vert:OC,meshphong_frag:PC,meshphysical_vert:NC,meshphysical_frag:LC,meshtoon_vert:kC,meshtoon_frag:FC,points_vert:UC,points_frag:zC,shadow_vert:BC,shadow_frag:HC,sprite_vert:GC,sprite_frag:VC},bt={common:{diffuse:{value:new rt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new de},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new de}},envmap:{envMap:{value:null},envMapRotation:{value:new de},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new de}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new de}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new de},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new de},normalScale:{value:new tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new de},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new de}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new de}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new de}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new rt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new T},probesMax:{value:new T},probesResolution:{value:new T}},points:{diffuse:{value:new rt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0},uvTransform:{value:new de}},sprite:{diffuse:{value:new rt(16777215)},opacity:{value:1},center:{value:new tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new de},alphaMap:{value:null},alphaMapTransform:{value:new de},alphaTest:{value:0}}},fa={basic:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:ue.meshbasic_vert,fragmentShader:ue.meshbasic_frag},lambert:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},envMapIntensity:{value:1}}]),vertexShader:ue.meshlambert_vert,fragmentShader:ue.meshlambert_frag},phong:{uniforms:ws([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},specular:{value:new rt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ue.meshphong_vert,fragmentShader:ue.meshphong_frag},standard:{uniforms:ws([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new rt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ue.meshphysical_vert,fragmentShader:ue.meshphysical_frag},toon:{uniforms:ws([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new rt(0)}}]),vertexShader:ue.meshtoon_vert,fragmentShader:ue.meshtoon_frag},matcap:{uniforms:ws([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:ue.meshmatcap_vert,fragmentShader:ue.meshmatcap_frag},points:{uniforms:ws([bt.points,bt.fog]),vertexShader:ue.points_vert,fragmentShader:ue.points_frag},dashed:{uniforms:ws([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ue.linedashed_vert,fragmentShader:ue.linedashed_frag},depth:{uniforms:ws([bt.common,bt.displacementmap]),vertexShader:ue.depth_vert,fragmentShader:ue.depth_frag},normal:{uniforms:ws([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:ue.meshnormal_vert,fragmentShader:ue.meshnormal_frag},sprite:{uniforms:ws([bt.sprite,bt.fog]),vertexShader:ue.sprite_vert,fragmentShader:ue.sprite_frag},background:{uniforms:{uvTransform:{value:new de},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ue.background_vert,fragmentShader:ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new de}},vertexShader:ue.backgroundCube_vert,fragmentShader:ue.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ue.cube_vert,fragmentShader:ue.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ue.equirect_vert,fragmentShader:ue.equirect_frag},distance:{uniforms:ws([bt.common,bt.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ue.distance_vert,fragmentShader:ue.distance_frag},shadow:{uniforms:ws([bt.lights,bt.fog,{color:{value:new rt(0)},opacity:{value:1}}]),vertexShader:ue.shadow_vert,fragmentShader:ue.shadow_frag}};fa.physical={uniforms:ws([fa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new de},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new de},clearcoatNormalScale:{value:new tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new de},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new de},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new de},sheen:{value:0},sheenColor:{value:new rt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new de},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new de},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new de},transmissionSamplerSize:{value:new tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new de},attenuationDistance:{value:0},attenuationColor:{value:new rt(0)},specularColor:{value:new rt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new de},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new de},anisotropyVector:{value:new tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new de}}]),vertexShader:ue.meshphysical_vert,fragmentShader:ue.meshphysical_frag};const Mp={r:0,b:0,g:0},WC=new Gt,NA=new de;NA.set(-1,0,0,0,1,0,0,0,1);function XC(o,t,e,i,n,s){const r=new rt(0);let a=n===!0?0:1,c,l,h=null,u=0,d=null;function f(M){let w=M.isScene===!0?M.background:null;if(w&&w.isTexture){const y=M.backgroundBlurriness>0;w=t.get(w,y)}return w}function p(M){let w=!1;const y=f(M);y===null?g(r,a):y&&y.isColor&&(g(y,1),w=!0);const x=o.xr.getEnvironmentBlendMode();x==="additive"?e.buffers.color.setClear(0,0,0,1,s):x==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(o.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),o.clear(o.autoClearColor,o.autoClearDepth,o.autoClearStencil))}function m(M,w){const y=f(w);y&&(y.isCubeTexture||y.mapping===Dm)?(l===void 0&&(l=new yt(new en(1,1,1),new De({name:"BackgroundCubeMaterial",uniforms:Mu(fa.backgroundCube.uniforms),vertexShader:fa.backgroundCube.vertexShader,fragmentShader:fa.backgroundCube.fragmentShader,side:zi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(x,b,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=y,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(WC.makeRotationFromEuler(w.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(NA),l.material.toneMapped=He.getTransfer(y.colorSpace)!==ui,(h!==y||u!==y.version||d!==o.toneMapping)&&(l.material.needsUpdate=!0,h=y,u=y.version,d=o.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new yt(new vs(2,2),new De({name:"BackgroundMaterial",uniforms:Mu(fa.background.uniforms),vertexShader:fa.background.vertexShader,fragmentShader:fa.background.fragmentShader,side:Ba,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=He.getTransfer(y.colorSpace)!==ui,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||u!==y.version||d!==o.toneMapping)&&(c.material.needsUpdate=!0,h=y,u=y.version,d=o.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function g(M,w){M.getRGB(Mp,AA(o)),e.buffers.color.setClear(Mp.r,Mp.g,Mp.b,w,s)}function v(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(M,w=1){r.set(M),a=w,g(r,a)},getClearAlpha:function(){return a},setClearAlpha:function(M){a=M,g(r,a)},render:p,addToRenderList:m,dispose:v}}function $C(o,t){const e=o.getParameter(o.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function a(I,D,O,P,N){let k=!1;const B=u(I,P,O,D);s!==B&&(s=B,l(s.object)),k=f(I,P,O,N),k&&p(I,P,O,N),N!==null&&t.update(N,o.ELEMENT_ARRAY_BUFFER),(k||r)&&(r=!1,y(I,D,O,P),N!==null&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.get(N).buffer))}function c(){return o.createVertexArray()}function l(I){return o.bindVertexArray(I)}function h(I){return o.deleteVertexArray(I)}function u(I,D,O,P){const N=P.wireframe===!0;let k=i[D.id];k===void 0&&(k={},i[D.id]=k);const B=I.isInstancedMesh===!0?I.id:0;let W=k[B];W===void 0&&(W={},k[B]=W);let Q=W[O.id];Q===void 0&&(Q={},W[O.id]=Q);let Z=Q[N];return Z===void 0&&(Z=d(c()),Q[N]=Z),Z}function d(I){const D=[],O=[],P=[];for(let N=0;N<e;N++)D[N]=0,O[N]=0,P[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:O,attributeDivisors:P,object:I,attributes:{},index:null}}function f(I,D,O,P){const N=s.attributes,k=D.attributes;let B=0;const W=O.getAttributes();for(const Q in W)if(W[Q].location>=0){const nt=N[Q];let ot=k[Q];if(ot===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(ot=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(ot=I.instanceColor)),nt===void 0||nt.attribute!==ot||ot&&nt.data!==ot.data)return!0;B++}return s.attributesNum!==B||s.index!==P}function p(I,D,O,P){const N={},k=D.attributes;let B=0;const W=O.getAttributes();for(const Q in W)if(W[Q].location>=0){let nt=k[Q];nt===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(nt=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(nt=I.instanceColor));const ot={};ot.attribute=nt,nt&&nt.data&&(ot.data=nt.data),N[Q]=ot,B++}s.attributes=N,s.attributesNum=B,s.index=P}function m(){const I=s.newAttributes;for(let D=0,O=I.length;D<O;D++)I[D]=0}function g(I){v(I,0)}function v(I,D){const O=s.newAttributes,P=s.enabledAttributes,N=s.attributeDivisors;O[I]=1,P[I]===0&&(o.enableVertexAttribArray(I),P[I]=1),N[I]!==D&&(o.vertexAttribDivisor(I,D),N[I]=D)}function M(){const I=s.newAttributes,D=s.enabledAttributes;for(let O=0,P=D.length;O<P;O++)D[O]!==I[O]&&(o.disableVertexAttribArray(O),D[O]=0)}function w(I,D,O,P,N,k,B){B===!0?o.vertexAttribIPointer(I,D,O,N,k):o.vertexAttribPointer(I,D,O,P,N,k)}function y(I,D,O,P){m();const N=P.attributes,k=O.getAttributes(),B=D.defaultAttributeValues;for(const W in k){const Q=k[W];if(Q.location>=0){let Z=N[W];if(Z===void 0&&(W==="instanceMatrix"&&I.instanceMatrix&&(Z=I.instanceMatrix),W==="instanceColor"&&I.instanceColor&&(Z=I.instanceColor)),Z!==void 0){const nt=Z.normalized,ot=Z.itemSize,Ut=t.get(Z);if(Ut===void 0)continue;const Zt=Ut.buffer,jt=Ut.type,K=Ut.bytesPerElement,lt=jt===o.INT||jt===o.UNSIGNED_INT||Z.gpuType===oy;if(Z.isInterleavedBufferAttribute){const ct=Z.data,V=ct.stride,Lt=Z.offset;if(ct.isInstancedInterleavedBuffer){for(let Xt=0;Xt<Q.locationSize;Xt++)v(Q.location+Xt,ct.meshPerAttribute);I.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let Xt=0;Xt<Q.locationSize;Xt++)g(Q.location+Xt);o.bindBuffer(o.ARRAY_BUFFER,Zt);for(let Xt=0;Xt<Q.locationSize;Xt++)w(Q.location+Xt,ot/Q.locationSize,jt,nt,V*K,(Lt+ot/Q.locationSize*Xt)*K,lt)}else{if(Z.isInstancedBufferAttribute){for(let ct=0;ct<Q.locationSize;ct++)v(Q.location+ct,Z.meshPerAttribute);I.isInstancedMesh!==!0&&P._maxInstanceCount===void 0&&(P._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ct=0;ct<Q.locationSize;ct++)g(Q.location+ct);o.bindBuffer(o.ARRAY_BUFFER,Zt);for(let ct=0;ct<Q.locationSize;ct++)w(Q.location+ct,ot/Q.locationSize,jt,nt,ot*K,ot/Q.locationSize*ct*K,lt)}}else if(B!==void 0){const nt=B[W];if(nt!==void 0)switch(nt.length){case 2:o.vertexAttrib2fv(Q.location,nt);break;case 3:o.vertexAttrib3fv(Q.location,nt);break;case 4:o.vertexAttrib4fv(Q.location,nt);break;default:o.vertexAttrib1fv(Q.location,nt)}}}}M()}function x(){A();for(const I in i){const D=i[I];for(const O in D){const P=D[O];for(const N in P){const k=P[N];for(const B in k)h(k[B].object),delete k[B];delete P[N]}}delete i[I]}}function b(I){if(i[I.id]===void 0)return;const D=i[I.id];for(const O in D){const P=D[O];for(const N in P){const k=P[N];for(const B in k)h(k[B].object),delete k[B];delete P[N]}}delete i[I.id]}function E(I){for(const D in i){const O=i[D];for(const P in O){const N=O[P];if(N[I.id]===void 0)continue;const k=N[I.id];for(const B in k)h(k[B].object),delete k[B];delete N[I.id]}}}function S(I){for(const D in i){const O=i[D],P=I.isInstancedMesh===!0?I.id:0,N=O[P];if(N!==void 0){for(const k in N){const B=N[k];for(const W in B)h(B[W].object),delete B[W];delete N[k]}delete O[P],Object.keys(O).length===0&&delete i[D]}}}function A(){_(),r=!0,s!==n&&(s=n,l(s.object))}function _(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:a,reset:A,resetDefaultState:_,dispose:x,releaseStatesOfGeometry:b,releaseStatesOfObject:S,releaseStatesOfProgram:E,initAttributes:m,enableAttribute:g,disableUnusedAttributes:M}}function YC(o,t,e){let i;function n(c){i=c}function s(c,l){o.drawArrays(i,c,l),e.update(l,i,1)}function r(c,l,h){h!==0&&(o.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function a(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=a}function KC(o,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const E=t.get("EXT_texture_filter_anisotropic");n=o.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(E){return!(E!==tn&&i.convert(E)!==o.getParameter(o.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){const S=E===Ye&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(E!==fs&&i.convert(E)!==o.getParameter(o.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==ts&&!S)}function c(E){if(E==="highp"){if(o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.HIGH_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.MEDIUM_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Ht("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&Ht("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),p=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=o.getParameter(o.MAX_TEXTURE_SIZE),g=o.getParameter(o.MAX_CUBE_MAP_TEXTURE_SIZE),v=o.getParameter(o.MAX_VERTEX_ATTRIBS),M=o.getParameter(o.MAX_VERTEX_UNIFORM_VECTORS),w=o.getParameter(o.MAX_VARYING_VECTORS),y=o.getParameter(o.MAX_FRAGMENT_UNIFORM_VECTORS),x=o.getParameter(o.MAX_SAMPLES),b=o.getParameter(o.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:y,maxSamples:x,samples:b}}function qC(o){const t=this;let e=null,i=0,n=!1,s=!1;const r=new Hr,a=new de,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,m=u.clipIntersection,g=u.clipShadows,v=o.get(u);if(!n||p===null||p.length===0||s&&!g)s?h(null):l();else{const M=s?0:i,w=M*4;let y=v.clippingState||null;c.value=y,y=h(p,d,w,f);for(let x=0;x!==w;++x)y[x]=e[x];v.clippingState=y,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=M}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const m=u!==null?u.length:0;let g=null;if(m!==0){if(g=c.value,p!==!0||g===null){const v=f+m*4,M=d.matrixWorldInverse;a.getNormalMatrix(M),(g===null||g.length<v)&&(g=new Float32Array(v));for(let w=0,y=f;w!==m;++w,y+=4)r.copy(u[w]).applyMatrix4(M,a),r.normal.toArray(g,y),g[y+3]=r.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=m,t.numIntersection=0,g}}const fc=4,Sx=[.125,.215,.35,.446,.526,.582],Gc=20,ZC=256,Vu=new ur,Ex=new rt;let Gg=null,Vg=0,Wg=0,Xg=!1;const JC=new T;class rM{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,s={}){const{size:r=256,position:a=JC}=s;Gg=this._renderer.getRenderTarget(),Vg=this._renderer.getActiveCubeFace(),Wg=this._renderer.getActiveMipmapLevel(),Xg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,c,a),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Tx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_x(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Gg,Vg,Wg),this._renderer.xr.enabled=Xg,t.scissorTest=!1,th(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===wl||t.mapping===pu?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Gg=this._renderer.getRenderTarget(),Vg=this._renderer.getActiveCubeFace(),Wg=this._renderer.getActiveMipmapLevel(),Xg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:Me,minFilter:Me,generateMipmaps:!1,type:Ye,format:tn,colorSpace:G0,depthBuffer:!1},n=Ax(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ax(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=jC(s)),this._blurMaterial=tO(s,t,e),this._ggxMaterial=QC(s,t,e)}return n}_compileMaterial(t){const e=new yt(new be,t);this._renderer.compile(e,Vu)}_sceneToCubeUV(t,e,i,n,s){const c=new jn(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Ex),u.toneMapping=ka,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new yt(new en,new Is({name:"PMREM.Background",side:zi,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,g=m.material;let v=!1;const M=t.background;M?M.isColor&&(g.color.copy(M),t.background=null,v=!0):(g.color.copy(Ex),v=!0);for(let w=0;w<6;w++){const y=w%3;y===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):y===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const x=this._cubeSize;th(n,y*x,w>2?x:0,x,x),u.setRenderTarget(n),v&&u.render(m,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=M}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===wl||t.mapping===pu;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Tx()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_x());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const a=s.uniforms;a.envMap.value=t;const c=this._cubeSize;th(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(r,Vu)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,a=this._lodMeshes[i];a.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,m=this._sizeLods[i],g=3*m*(i>p-fc?i-p+fc:0),v=4*(this._cubeSize-m);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,th(s,g,v,3*m,2*m),n.setRenderTarget(s),n.render(a,Vu),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,th(t,g,v,3*m,2*m),n.setRenderTarget(t),n.render(a,Vu)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,a){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&le("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Gc-1),m=s/p,g=isFinite(s)?1+Math.floor(h*m):Gc;g>Gc&&Ht(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Gc}`);const v=[];let M=0;for(let E=0;E<Gc;++E){const S=E/m,A=Math.exp(-S*S/2);v.push(A),E===0?M+=A:E<g&&(M+=2*A)}for(let E=0;E<v.length;E++)v[E]=v[E]/M;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=v,d.latitudinal.value=r==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const y=this._sizeLods[n],x=3*y*(n>w-fc?n-w+fc:0),b=4*(this._cubeSize-y);th(e,x,b,3*y,2*y),c.setRenderTarget(e),c.render(u,Vu)}}function jC(o){const t=[],e=[],i=[];let n=o;const s=o-fc+1+Sx.length;for(let r=0;r<s;r++){const a=Math.pow(2,n);t.push(a);let c=1/a;r>o-fc?c=Sx[r-o+fc-1]:r===0&&(c=0),e.push(c);const l=1/(a-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,m=3,g=2,v=1,M=new Float32Array(m*p*f),w=new Float32Array(g*p*f),y=new Float32Array(v*p*f);for(let b=0;b<f;b++){const E=b%3*2/3-1,S=b>2?0:-1,A=[E,S,0,E+2/3,S,0,E+2/3,S+1,0,E,S,0,E+2/3,S+1,0,E,S+1,0];M.set(A,m*p*b),w.set(d,g*p*b);const _=[b,b,b,b,b,b];y.set(_,v*p*b)}const x=new be;x.setAttribute("position",new ye(M,m)),x.setAttribute("uv",new ye(w,g)),x.setAttribute("faceIndex",new ye(y,v)),i.push(new yt(x,null)),n>fc&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Ax(o,t,e){const i=new Qe(o,t,e);return i.texture.mapping=Dm,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function th(o,t,e,i,n){o.viewport.set(t,e,i,n),o.scissor.set(t,e,i,n)}function QC(o,t,e){return new De({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ZC,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Nm(),fragmentShader:`
|
|
4458
4458
|
|
|
4459
4459
|
precision highp float;
|
|
4460
4460
|
precision highp int;
|
|
@@ -4891,7 +4891,7 @@ void main() {
|
|
|
4891
4891
|
|
|
4892
4892
|
}
|
|
4893
4893
|
|
|
4894
|
-
}`;class ZP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new gA(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new De({vertexShader:KP,fragmentShader:qP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new vs(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class JP extends _c{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const m=typeof XRWebGLBinding<"u",g=new ZP,v={},M=e.getContextAttributes();let w=null,y=null;const x=[],b=[],E=new tt;let S=null;const A=new jn;A.viewport=new Ie;const _=new jn;_.viewport=new Ie;const I=[A,_],D=new $I;let O=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getTargetRaySpace()},this.getControllerGrip=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getGripSpace()},this.getHand=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getHandSpace()};function N(K){const lt=b.indexOf(K.inputSource);if(lt===-1)return;const ct=x[lt];ct!==void 0&&(ct.update(K.inputSource,K.frame,l||r),ct.dispatchEvent({type:K.type,data:K.inputSource}))}function k(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",k),n.removeEventListener("inputsourceschange",B);for(let K=0;K<x.length;K++){const lt=b[K];lt!==null&&(b[K]=null,x[K].disconnect(lt))}O=null,P=null,g.reset();for(const K in v)delete v[K];t.setRenderTarget(w),f=null,d=null,u=null,n=null,y=null,jt.stop(),i.isPresenting=!1,t.setPixelRatio(S),t.setSize(E.width,E.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){s=K,i.isPresenting===!0&&Ht("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){a=K,i.isPresenting===!0&&Ht("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(K){if(n=K,n!==null){if(w=t.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",k),n.addEventListener("inputsourceschange",B),M.xrCompatible!==!0&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(E),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let ct=null,V=null,Lt=null;M.depth&&(Lt=M.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ct=M.stencil?tl:So,V=M.stencil?cf:_r);const Xt={colorFormat:e.RGBA8,depthFormat:Lt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Xt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Qe(d.textureWidth,d.textureHeight,{format:tn,type:fs,depthTexture:new Sc(d.textureWidth,d.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,ct),stencilBuffer:M.stencil,colorSpace:t.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ct={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,ct),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Qe(f.framebufferWidth,f.framebufferHeight,{format:tn,type:fs,colorSpace:t.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(a),jt.setContext(n),jt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function B(K){for(let lt=0;lt<K.removed.length;lt++){const ct=K.removed[lt],V=b.indexOf(ct);V>=0&&(b[V]=null,x[V].disconnect(ct))}for(let lt=0;lt<K.added.length;lt++){const ct=K.added[lt];let V=b.indexOf(ct);if(V===-1){for(let Xt=0;Xt<x.length;Xt++)if(Xt>=b.length){b.push(ct),V=Xt;break}else if(b[Xt]===null){b[Xt]=ct,V=Xt;break}if(V===-1)break}const Lt=x[V];Lt&&Lt.connect(ct)}}const W=new T,Q=new T;function Z(K,lt,ct){W.setFromMatrixPosition(lt.matrixWorld),Q.setFromMatrixPosition(ct.matrixWorld);const V=W.distanceTo(Q),Lt=lt.projectionMatrix.elements,Xt=ct.projectionMatrix.elements,kt=Lt[14]/(Lt[10]-1),Rt=Lt[14]/(Lt[10]+1),te=(Lt[9]+1)/Lt[5],ne=(Lt[9]-1)/Lt[5],se=(Lt[8]-1)/Lt[0],ri=(Xt[8]+1)/Xt[0],ai=kt*se,$i=kt*ri,Gi=V/(-se+ri),Yi=Gi*-se;if(lt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Yi),K.translateZ(Gi),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Lt[10]===-1)K.projectionMatrix.copy(lt.projectionMatrix),K.projectionMatrixInverse.copy(lt.projectionMatrixInverse);else{const un=kt+Gi,z=Rt+Gi,Os=ai-Yi,oi=$i+(V-Yi),L=te*Rt/z*un,R=ne*Rt/z*un;K.projectionMatrix.makePerspective(Os,oi,L,R,un,z),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function nt(K,lt){lt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(lt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(n===null)return;let lt=K.near,ct=K.far;g.texture!==null&&(g.depthNear>0&&(lt=g.depthNear),g.depthFar>0&&(ct=g.depthFar)),D.near=_.near=A.near=lt,D.far=_.far=A.far=ct,(O!==D.near||P!==D.far)&&(n.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,P=D.far),D.layers.mask=K.layers.mask|6,A.layers.mask=D.layers.mask&-5,_.layers.mask=D.layers.mask&-3;const V=K.parent,Lt=D.cameras;nt(D,V);for(let Xt=0;Xt<Lt.length;Xt++)nt(Lt[Xt],V);Lt.length===2?Z(D,A,_):D.projectionMatrix.copy(A.projectionMatrix),ot(K,D,V)};function ot(K,lt,ct){ct===null?K.matrix.copy(lt.matrixWorld):(K.matrix.copy(ct.matrixWorld),K.matrix.invert(),K.matrix.multiply(lt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(lt.projectionMatrix),K.projectionMatrixInverse.copy(lt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=gu*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(D)},this.getCameraTexture=function(K){return v[K]};let Ut=null;function Zt(K,lt){if(h=lt.getViewerPose(l||r),p=lt,h!==null){const ct=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let V=!1;ct.length!==D.cameras.length&&(D.cameras.length=0,V=!0);for(let Rt=0;Rt<ct.length;Rt++){const te=ct[Rt];let ne=null;if(f!==null)ne=f.getViewport(te);else{const ri=u.getViewSubImage(d,te);ne=ri.viewport,Rt===0&&(t.setRenderTargetTextures(y,ri.colorTexture,ri.depthStencilTexture),t.setRenderTarget(y))}let se=I[Rt];se===void 0&&(se=new jn,se.layers.enable(Rt),se.viewport=new Ie,I[Rt]=se),se.matrix.fromArray(te.transform.matrix),se.matrix.decompose(se.position,se.quaternion,se.scale),se.projectionMatrix.fromArray(te.projectionMatrix),se.projectionMatrixInverse.copy(se.projectionMatrix).invert(),se.viewport.set(ne.x,ne.y,ne.width,ne.height),Rt===0&&(D.matrix.copy(se.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),V===!0&&D.cameras.push(se)}const Lt=n.enabledFeatures;if(Lt&&Lt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&m){u=i.getBinding();const Rt=u.getDepthInformation(ct[0]);Rt&&Rt.isValid&&Rt.texture&&g.init(Rt,n.renderState)}if(Lt&&Lt.includes("camera-access")&&m){t.state.unbindTexture(),u=i.getBinding();for(let Rt=0;Rt<ct.length;Rt++){const te=ct[Rt].camera;if(te){let ne=v[te];ne||(ne=new gA,v[te]=ne);const se=u.getCameraImage(te);ne.sourceTexture=se}}}}for(let ct=0;ct<x.length;ct++){const V=b[ct],Lt=x[ct];V!==null&&Lt!==void 0&&Lt.update(V,lt,l||r)}Ut&&Ut(K,lt),lt.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:lt}),p=null}const jt=new PA;jt.setAnimationLoop(Zt),this.setAnimationLoop=function(K){Ut=K},this.dispose=function(){}}}const jP=new Gt,zA=new de;zA.set(-1,0,0,0,1,0,0,0,1);function QP(o,t){function e(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function i(g,v){v.color.getRGB(g.fogColor.value,AA(o)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function n(g,v,M,w,y){v.isNodeMaterial?v.uniformsNeedUpdate=!1:v.isMeshBasicMaterial?s(g,v):v.isMeshLambertMaterial?(s(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshToonMaterial?(s(g,v),u(g,v)):v.isMeshPhongMaterial?(s(g,v),h(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshStandardMaterial?(s(g,v),d(g,v),v.isMeshPhysicalMaterial&&f(g,v,y)):v.isMeshMatcapMaterial?(s(g,v),p(g,v)):v.isMeshDepthMaterial?s(g,v):v.isMeshDistanceMaterial?(s(g,v),m(g,v)):v.isMeshNormalMaterial?s(g,v):v.isLineBasicMaterial?(r(g,v),v.isLineDashedMaterial&&a(g,v)):v.isPointsMaterial?c(g,v,M,w):v.isSpriteMaterial?l(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,e(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,e(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===zi&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,e(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===zi&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,e(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,e(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,e(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);const M=t.get(v),w=M.envMap,y=M.envMapRotation;w&&(g.envMap.value=w,g.envMapRotation.value.setFromMatrix4(jP.makeRotationFromEuler(y)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(zA),g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap&&(g.lightMap.value=v.lightMap,g.lightMapIntensity.value=v.lightMapIntensity,e(v.lightMap,g.lightMapTransform)),v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,e(v.aoMap,g.aoMapTransform))}function r(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,e(v.map,g.mapTransform))}function a(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function c(g,v,M,w){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*M,g.scale.value=w*.5,v.map&&(g.map.value=v.map,e(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function l(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,e(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function h(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function u(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function d(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,e(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,e(v.roughnessMap,g.roughnessMapTransform)),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function f(g,v,M){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,e(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,e(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,e(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,e(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,e(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===zi&&g.clearcoatNormalScale.value.negate())),v.dispersion>0&&(g.dispersion.value=v.dispersion),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,e(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,e(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=M.texture,g.transmissionSamplerSize.value.set(M.width,M.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,e(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,e(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,e(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,e(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,e(v.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,v){v.matcap&&(g.matcap.value=v.matcap)}function m(g,v){const M=t.get(v).light;g.referencePosition.value.setFromMatrixPosition(M.matrixWorld),g.nearDistance.value=M.shadow.camera.near,g.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function t8(o,t,e,i){let n={},s={},r=[];const a=o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,x){const b=x.program;i.uniformBlockBinding(y,b)}function l(y,x){let b=n[y.id];b===void 0&&(g(y),b=h(y),n[y.id]=b,y.addEventListener("dispose",M));const E=x.program;i.updateUBOMapping(y,E);const S=t.render.frame;s[y.id]!==S&&(d(y),s[y.id]=S)}function h(y){const x=u();y.__bindingPointIndex=x;const b=o.createBuffer(),E=y.__size,S=y.usage;return o.bindBuffer(o.UNIFORM_BUFFER,b),o.bufferData(o.UNIFORM_BUFFER,E,S),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,x,b),b}function u(){for(let y=0;y<a;y++)if(r.indexOf(y)===-1)return r.push(y),y;return le("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=n[y.id],b=y.uniforms,E=y.__cache;o.bindBuffer(o.UNIFORM_BUFFER,x);for(let S=0,A=b.length;S<A;S++){const _=b[S];if(Array.isArray(_))for(let I=0,D=_.length;I<D;I++)f(_[I],S,I,E);else f(_,S,0,E)}o.bindBuffer(o.UNIFORM_BUFFER,null)}function f(y,x,b,E){if(m(y,x,b,E)===!0){const S=y.__offset,A=y.value;if(Array.isArray(A)){let _=0;for(let I=0;I<A.length;I++){const D=A[I],O=v(D);p(D,y.__data,_),typeof D!="number"&&typeof D!="boolean"&&!D.isMatrix3&&!ArrayBuffer.isView(D)&&(_+=O.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,y.__data,0);o.bufferSubData(o.UNIFORM_BUFFER,S,y.__data)}}function p(y,x,b){typeof y=="number"||typeof y=="boolean"?x[0]=y:y.isMatrix3?(x[0]=y.elements[0],x[1]=y.elements[1],x[2]=y.elements[2],x[3]=0,x[4]=y.elements[3],x[5]=y.elements[4],x[6]=y.elements[5],x[7]=0,x[8]=y.elements[6],x[9]=y.elements[7],x[10]=y.elements[8],x[11]=0):ArrayBuffer.isView(y)?x.set(new y.constructor(y.buffer,y.byteOffset,x.length)):y.toArray(x,b)}function m(y,x,b,E){const S=y.value,A=x+"_"+b;if(E[A]===void 0)return typeof S=="number"||typeof S=="boolean"?E[A]=S:ArrayBuffer.isView(S)?E[A]=S.slice():E[A]=S.clone(),!0;{const _=E[A];if(typeof S=="number"||typeof S=="boolean"){if(_!==S)return E[A]=S,!0}else{if(ArrayBuffer.isView(S))return!0;if(_.equals(S)===!1)return _.copy(S),!0}}return!1}function g(y){const x=y.uniforms;let b=0;const E=16;for(let A=0,_=x.length;A<_;A++){const I=Array.isArray(x[A])?x[A]:[x[A]];for(let D=0,O=I.length;D<O;D++){const P=I[D],N=Array.isArray(P.value)?P.value:[P.value];for(let k=0,B=N.length;k<B;k++){const W=N[k],Q=v(W),Z=b%E,nt=Z%Q.boundary,ot=Z+nt;b+=nt,ot!==0&&E-ot<Q.storage&&(b+=E-ot),P.__data=new Float32Array(Q.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=b,b+=Q.storage}}}const S=b%E;return S>0&&(b+=E-S),y.__size=b,y.__cache={},this}function v(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(x.boundary=16,x.storage=y.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",y),x}function M(y){const x=y.target;x.removeEventListener("dispose",M);const b=r.indexOf(x.__bindingPointIndex);r.splice(b,1),o.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function w(){for(const y in n)o.deleteBuffer(n[y]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const e8=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let ta=null;function i8(){return ta===null&&(ta=new Ds(e8,16,16,xl,Ye),ta.name="DFG_LUT",ta.minFilter=Me,ta.magFilter=Me,ta.wrapS=Qi,ta.wrapT=Qi,ta.generateMipmaps=!1,ta.needsUpdate=!0),ta}class n8{constructor(t={}){const{canvas:e=J4(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=fs}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const m=f,g=new Set([dy,uy,hy]),v=new Set([fs,_r,of,cf,cy,ly]),M=new Uint32Array(4),w=new Int32Array(4),y=new T;let x=null,b=null;const E=[],S=[];let A=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ka,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let I=!1,D=null,O=null,P=null,N=null;this._outputColorSpace=Bn;let k=0,B=0,W=null,Q=-1,Z=null;const nt=new Ie,ot=new Ie;let Ut=null;const Zt=new rt(0);let jt=0,K=e.width,lt=e.height,ct=1,V=null,Lt=null;const Xt=new Ie(0,0,K,lt),kt=new Ie(0,0,K,lt);let Rt=!1;const te=new Cm;let ne=!1,se=!1;const ri=new Gt,ai=new T,$i=new Ie,Gi={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Yi=!1;function un(){return W===null?ct:1}let z=i;function Os(C,H){return e.getContext(C,H)}try{const C={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_f}`),e.addEventListener("webglcontextlost",Ki,!1),e.addEventListener("webglcontextrestored",Ti,!1),e.addEventListener("webglcontextcreationerror",Zr,!1),z===null){const H="webgl2";if(z=Os(H,C),z===null)throw Os(H)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw le("WebGLRenderer: "+C.message),C}let oi,L,R,G,Y,J,ut,pt,j,it,gt,$t,xt,vt,Qt,ae,Ae,U,ft,et,Mt,At,st;function Wt(){oi=new iO(z),oi.init(),Mt=new YP(z,oi),L=new K6(z,oi,t,Mt),R=new XP(z,oi),L.reversedDepthBuffer&&d&&R.buffers.depth.setReversed(!0),O=z.createFramebuffer(),P=z.createFramebuffer(),N=z.createFramebuffer(),G=new rO(z),Y=new CP,J=new $P(z,oi,R,Y,L,Mt,G),ut=new eO(_),pt=new lD(z),At=new $6(z,pt),j=new nO(z,pt,G,At),it=new oO(z,j,pt,At,G),U=new aO(z,L,J),Qt=new q6(Y),gt=new DP(_,ut,oi,L,At,Qt),$t=new QP(_,Y),xt=new PP,vt=new zP(oi),Ae=new X6(_,ut,R,it,p,c),ae=new WP(_,it,L),st=new t8(z,G,L,R),ft=new Y6(z,oi,G),et=new sO(z,oi,G),G.programs=gt.programs,_.capabilities=L,_.extensions=oi,_.properties=Y,_.renderLists=xt,_.shadowMap=ae,_.state=R,_.info=G}Wt(),m!==fs&&(A=new lO(m,e.width,e.height,a,n,s));const Ft=new JP(_,z);this.xr=Ft,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const C=oi.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=oi.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ct},this.setPixelRatio=function(C){C!==void 0&&(ct=C,this.setSize(K,lt,!1))},this.getSize=function(C){return C.set(K,lt)},this.setSize=function(C,H,q=!0){if(Ft.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}K=C,lt=H,e.width=Math.floor(C*ct),e.height=Math.floor(H*ct),q===!0&&(e.style.width=C+"px",e.style.height=H+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,C,H)},this.getDrawingBufferSize=function(C){return C.set(K*ct,lt*ct).floor()},this.setDrawingBufferSize=function(C,H,q){K=C,lt=H,ct=q,e.width=Math.floor(C*q),e.height=Math.floor(H*q),this.setViewport(0,0,C,H)},this.setEffects=function(C){if(m===fs){le("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let H=0;H<C.length;H++)if(C[H].isOutputPass===!0){Ht("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy(nt)},this.getViewport=function(C){return C.copy(Xt)},this.setViewport=function(C,H,q,X){C.isVector4?Xt.set(C.x,C.y,C.z,C.w):Xt.set(C,H,q,X),R.viewport(nt.copy(Xt).multiplyScalar(ct).round())},this.getScissor=function(C){return C.copy(kt)},this.setScissor=function(C,H,q,X){C.isVector4?kt.set(C.x,C.y,C.z,C.w):kt.set(C,H,q,X),R.scissor(ot.copy(kt).multiplyScalar(ct).round())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(C){R.setScissorTest(Rt=C)},this.setOpaqueSort=function(C){V=C},this.setTransparentSort=function(C){Lt=C},this.getClearColor=function(C){return C.copy(Ae.getClearColor())},this.setClearColor=function(){Ae.setClearColor(...arguments)},this.getClearAlpha=function(){return Ae.getClearAlpha()},this.setClearAlpha=function(){Ae.setClearAlpha(...arguments)},this.clear=function(C=!0,H=!0,q=!0){let X=0;if(C){let $=!1;if(W!==null){const Et=W.texture.format;$=g.has(Et)}if($){const Et=W.texture.type,It=v.has(Et),St=Ae.getClearColor(),zt=Ae.getClearAlpha(),Yt=St.r,_e=St.g,Ce=St.b;It?(M[0]=Yt,M[1]=_e,M[2]=Ce,M[3]=zt,z.clearBufferuiv(z.COLOR,0,M)):(w[0]=Yt,w[1]=_e,w[2]=Ce,w[3]=zt,z.clearBufferiv(z.COLOR,0,w))}else X|=z.COLOR_BUFFER_BIT}H&&(X|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(X|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),X!==0&&z.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(C){C.setRenderer(this),D=C},this.dispose=function(){e.removeEventListener("webglcontextlost",Ki,!1),e.removeEventListener("webglcontextrestored",Ti,!1),e.removeEventListener("webglcontextcreationerror",Zr,!1),Ae.dispose(),xt.dispose(),vt.dispose(),Y.dispose(),ut.dispose(),it.dispose(),At.dispose(),st.dispose(),gt.dispose(),Ft.dispose(),Ft.removeEventListener("sessionstart",qy),Ft.removeEventListener("sessionend",Zy),Rc.stop()};function Ki(C){C.preventDefault(),X0("WebGLRenderer: Context Lost."),I=!0}function Ti(){X0("WebGLRenderer: Context Restored."),I=!1;const C=G.autoReset,H=ae.enabled,q=ae.autoUpdate,X=ae.needsUpdate,$=ae.type;Wt(),G.autoReset=C,ae.enabled=H,ae.autoUpdate=q,ae.needsUpdate=X,ae.type=$}function Zr(C){le("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Jr(C){const H=C.target;H.removeEventListener("dispose",Jr),B3(H)}function B3(C){H3(C),Y.remove(C)}function H3(C){const H=Y.get(C).programs;H!==void 0&&(H.forEach(function(q){gt.releaseProgram(q)}),C.isShaderMaterial&>.releaseShaderCache(C))}this.renderBufferDirect=function(C,H,q,X,$,Et){H===null&&(H=Gi);const It=$.isMesh&&$.matrixWorld.determinantAffine()<0,St=W3(C,H,q,X,$);R.setMaterial(X,It);let zt=q.index,Yt=1;if(X.wireframe===!0){if(zt=j.getWireframeAttribute(q),zt===void 0)return;Yt=2}const _e=q.drawRange,Ce=q.attributes.position;let qt=_e.start*Yt,gi=(_e.start+_e.count)*Yt;Et!==null&&(qt=Math.max(qt,Et.start*Yt),gi=Math.min(gi,(Et.start+Et.count)*Yt)),zt!==null?(qt=Math.max(qt,0),gi=Math.min(gi,zt.count)):Ce!=null&&(qt=Math.max(qt,0),gi=Math.min(gi,Ce.count));const nn=gi-qt;if(nn<0||nn===1/0)return;At.setup($,X,St,q,zt);let qi,wi=ft;if(zt!==null&&(qi=pt.get(zt),wi=et,wi.setIndex(qi)),$.isMesh)X.wireframe===!0?(R.setLineWidth(X.wireframeLinewidth*un()),wi.setMode(z.LINES)):wi.setMode(z.TRIANGLES);else if($.isLine){let is=X.linewidth;is===void 0&&(is=1),R.setLineWidth(is*un()),$.isLineSegments?wi.setMode(z.LINES):$.isLineLoop?wi.setMode(z.LINE_LOOP):wi.setMode(z.LINE_STRIP)}else $.isPoints?wi.setMode(z.POINTS):$.isSprite&&wi.setMode(z.TRIANGLES);if($.isBatchedMesh)if(oi.get("WEBGL_multi_draw"))wi.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else{const is=$._multiDrawStarts,Tt=$._multiDrawCounts,Zs=$._multiDrawCount,Xe=zt?pt.get(zt).bytesPerElement:1,dr=Y.get(X).currentProgram.getUniforms();for(let jr=0;jr<Zs;jr++)dr.setValue(z,"_gl_DrawID",jr),wi.render(is[jr]/Xe,Tt[jr])}else if($.isInstancedMesh)wi.renderInstances(qt,nn,$.count);else if(q.isInstancedBufferGeometry){const is=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Tt=Math.min(q.instanceCount,is);wi.renderInstances(qt,nn,Tt)}else wi.render(qt,nn)};function Ky(C,H,q){C.transparent===!0&&C.side===Tn&&C.forceSinglePass===!1?(C.side=zi,C.needsUpdate=!0,Df(C,H,q),C.side=Ba,C.needsUpdate=!0,Df(C,H,q),C.side=Tn):Df(C,H,q)}this.compile=function(C,H,q=null){q===null&&(q=C),b=vt.get(q),b.init(H),S.push(b),q.traverseVisible(function($){$.isLight&&$.layers.test(H.layers)&&(b.pushLight($),$.castShadow&&b.pushShadow($))}),C!==q&&C.traverseVisible(function($){$.isLight&&$.layers.test(H.layers)&&(b.pushLight($),$.castShadow&&b.pushShadow($))}),b.setupLights();const X=new Set;return C.traverse(function($){if(!($.isMesh||$.isPoints||$.isLine||$.isSprite))return;const Et=$.material;if(Et)if(Array.isArray(Et))for(let It=0;It<Et.length;It++){const St=Et[It];Ky(St,q,$),X.add(St)}else Ky(Et,q,$),X.add(Et)}),b=S.pop(),X},this.compileAsync=function(C,H,q=null){const X=this.compile(C,H,q);return new Promise($=>{function Et(){if(X.forEach(function(It){Y.get(It).currentProgram.isReady()&&X.delete(It)}),X.size===0){$(C);return}setTimeout(Et,10)}oi.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let Gm=null;function G3(C){Gm&&Gm(C)}function qy(){Rc.stop()}function Zy(){Rc.start()}const Rc=new PA;Rc.setAnimationLoop(G3),typeof self<"u"&&Rc.setContext(self),this.setAnimationLoop=function(C){Gm=C,Ft.setAnimationLoop(C),C===null?Rc.stop():Rc.start()},Ft.addEventListener("sessionstart",qy),Ft.addEventListener("sessionend",Zy),this.render=function(C,H){if(H!==void 0&&H.isCamera!==!0){le("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;D!==null&&D.renderStart(C,H);const q=Ft.enabled===!0&&Ft.isPresenting===!0,X=A!==null&&(W===null||q)&&A.begin(_,W);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Ft.enabled===!0&&Ft.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Ft.cameraAutoUpdate===!0&&Ft.updateCamera(H),H=Ft.getCamera()),C.isScene===!0&&C.onBeforeRender(_,C,H,W),b=vt.get(C,S.length),b.init(H),b.state.textureUnits=J.getTextureUnits(),S.push(b),ri.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),te.setFromProjectionMatrix(ri,Ca,H.reversedDepth),se=this.localClippingEnabled,ne=Qt.init(this.clippingPlanes,se),x=xt.get(C,E.length),x.init(),E.push(x),Ft.enabled===!0&&Ft.isPresenting===!0){const It=_.xr.getDepthSensingMesh();It!==null&&Vm(It,H,-1/0,_.sortObjects)}Vm(C,H,0,_.sortObjects),x.finish(),_.sortObjects===!0&&x.sort(V,Lt,H.reversedDepth),Yi=Ft.enabled===!1||Ft.isPresenting===!1||Ft.hasDepthSensing()===!1,Yi&&Ae.addToRenderList(x,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ne===!0&&Qt.beginShadows();const $=b.state.shadowsArray;if(ae.render($,C,H),ne===!0&&Qt.endShadows(),(X&&A.hasRenderPass())===!1){const It=x.opaque,St=x.transmissive;if(b.setupLights(),H.isArrayCamera){const zt=H.cameras;if(St.length>0)for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt];jy(It,St,C,Ce)}Yi&&Ae.render(C);for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt];Jy(x,C,Ce,Ce.viewport)}}else St.length>0&&jy(It,St,C,H),Yi&&Ae.render(C),Jy(x,C,H)}W!==null&&B===0&&(J.updateMultisampleRenderTarget(W),J.updateRenderTargetMipmap(W)),X&&A.end(_),C.isScene===!0&&C.onAfterRender(_,C,H),At.resetDefaultState(),Q=-1,Z=null,S.pop(),S.length>0?(b=S[S.length-1],J.setTextureUnits(b.state.textureUnits),ne===!0&&Qt.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,E.pop(),E.length>0?x=E[E.length-1]:x=null,D!==null&&D.renderEnd()};function Vm(C,H,q,X){if(C.visible===!1)return;if(C.layers.test(H.layers)){if(C.isGroup)q=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(H);else if(C.isLightProbeGrid)b.pushLightProbeGrid(C);else if(C.isLight)b.pushLight(C),C.castShadow&&b.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||te.intersectsSprite(C)){X&&$i.setFromMatrixPosition(C.matrixWorld).applyMatrix4(ri);const It=it.update(C),St=C.material;St.visible&&x.push(C,It,St,q,$i.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||te.intersectsObject(C))){const It=it.update(C),St=C.material;if(X&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),$i.copy(C.boundingSphere.center)):(It.boundingSphere===null&&It.computeBoundingSphere(),$i.copy(It.boundingSphere.center)),$i.applyMatrix4(C.matrixWorld).applyMatrix4(ri)),Array.isArray(St)){const zt=It.groups;for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt],qt=St[Ce.materialIndex];qt&&qt.visible&&x.push(C,It,qt,q,$i.z,Ce)}}else St.visible&&x.push(C,It,St,q,$i.z,null)}}const Et=C.children;for(let It=0,St=Et.length;It<St;It++)Vm(Et[It],H,q,X)}function Jy(C,H,q,X){const{opaque:$,transmissive:Et,transparent:It}=C;b.setupLightsView(q),ne===!0&&Qt.setGlobalState(_.clippingPlanes,q),X&&R.viewport(nt.copy(X)),$.length>0&&If($,H,q),Et.length>0&&If(Et,H,q),It.length>0&&If(It,H,q),R.buffers.depth.setTest(!0),R.buffers.depth.setMask(!0),R.buffers.color.setMask(!0),R.setPolygonOffset(!1)}function jy(C,H,q,X){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[X.id]===void 0){const qt=oi.has("EXT_color_buffer_half_float")||oi.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[X.id]=new Qe(1,1,{generateMipmaps:!0,type:qt?Ye:fs,minFilter:cr,samples:Math.max(4,L.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:He.workingColorSpace})}const Et=b.state.transmissionRenderTarget[X.id],It=X.viewport||nt;Et.setSize(It.z*_.transmissionResolutionScale,It.w*_.transmissionResolutionScale);const St=_.getRenderTarget(),zt=_.getActiveCubeFace(),Yt=_.getActiveMipmapLevel();_.setRenderTarget(Et),_.getClearColor(Zt),jt=_.getClearAlpha(),jt<1&&_.setClearColor(16777215,.5),_.clear(),Yi&&Ae.render(q);const _e=_.toneMapping;_.toneMapping=ka;const Ce=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),b.setupLightsView(X),ne===!0&&Qt.setGlobalState(_.clippingPlanes,X),If(C,q,X),J.updateMultisampleRenderTarget(Et),J.updateRenderTargetMipmap(Et),oi.has("WEBGL_multisampled_render_to_texture")===!1){let qt=!1;for(let gi=0,nn=H.length;gi<nn;gi++){const qi=H[gi],{object:wi,geometry:is,material:Tt,group:Zs}=qi;if(Tt.side===Tn&&wi.layers.test(X.layers)){const Xe=Tt.side;Tt.side=zi,Tt.needsUpdate=!0,Qy(wi,q,X,is,Tt,Zs),Tt.side=Xe,Tt.needsUpdate=!0,qt=!0}}qt===!0&&(J.updateMultisampleRenderTarget(Et),J.updateRenderTargetMipmap(Et))}_.setRenderTarget(St,zt,Yt),_.setClearColor(Zt,jt),Ce!==void 0&&(X.viewport=Ce),_.toneMapping=_e}function If(C,H,q){const X=H.isScene===!0?H.overrideMaterial:null;for(let $=0,Et=C.length;$<Et;$++){const It=C[$],{object:St,geometry:zt,group:Yt}=It;let _e=It.material;_e.allowOverride===!0&&X!==null&&(_e=X),St.layers.test(q.layers)&&Qy(St,H,q,zt,_e,Yt)}}function Qy(C,H,q,X,$,Et){C.onBeforeRender(_,H,q,X,$,Et),C.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),$.onBeforeRender(_,H,q,X,C,Et),$.transparent===!0&&$.side===Tn&&$.forceSinglePass===!1?($.side=zi,$.needsUpdate=!0,_.renderBufferDirect(q,H,X,$,C,Et),$.side=Ba,$.needsUpdate=!0,_.renderBufferDirect(q,H,X,$,C,Et),$.side=Tn):_.renderBufferDirect(q,H,X,$,C,Et),C.onAfterRender(_,H,q,X,$,Et)}function Df(C,H,q){H.isScene!==!0&&(H=Gi);const X=Y.get(C),$=b.state.lights,Et=b.state.shadowsArray,It=$.state.version,St=gt.getParameters(C,$.state,Et,H,q,b.state.lightProbeGridArray),zt=gt.getProgramCacheKey(St);let Yt=X.programs;X.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?H.environment:null,X.fog=H.fog;const _e=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;X.envMap=ut.get(C.envMap||X.environment,_e),X.envMapRotation=X.environment!==null&&C.envMap===null?H.environmentRotation:C.envMapRotation,Yt===void 0&&(C.addEventListener("dispose",Jr),Yt=new Map,X.programs=Yt);let Ce=Yt.get(zt);if(Ce!==void 0){if(X.currentProgram===Ce&&X.lightsStateVersion===It)return e2(C,St),Ce}else St.uniforms=gt.getUniforms(C),D!==null&&C.isNodeMaterial&&D.build(C,q,St),C.onBeforeCompile(St,_),Ce=gt.acquireProgram(St,zt),Yt.set(zt,Ce),X.uniforms=St.uniforms;const qt=X.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(qt.clippingPlanes=Qt.uniform),e2(C,St),X.needsLights=$3(C),X.lightsStateVersion=It,X.needsLights&&(qt.ambientLightColor.value=$.state.ambient,qt.lightProbe.value=$.state.probe,qt.directionalLights.value=$.state.directional,qt.directionalLightShadows.value=$.state.directionalShadow,qt.spotLights.value=$.state.spot,qt.spotLightShadows.value=$.state.spotShadow,qt.rectAreaLights.value=$.state.rectArea,qt.ltc_1.value=$.state.rectAreaLTC1,qt.ltc_2.value=$.state.rectAreaLTC2,qt.pointLights.value=$.state.point,qt.pointLightShadows.value=$.state.pointShadow,qt.hemisphereLights.value=$.state.hemi,qt.directionalShadowMatrix.value=$.state.directionalShadowMatrix,qt.spotLightMatrix.value=$.state.spotLightMatrix,qt.spotLightMap.value=$.state.spotLightMap,qt.pointShadowMatrix.value=$.state.pointShadowMatrix),X.lightProbeGrid=b.state.lightProbeGridArray.length>0,X.currentProgram=Ce,X.uniformsList=null,Ce}function t2(C){if(C.uniformsList===null){const H=C.currentProgram.getUniforms();C.uniformsList=h0.seqWithValue(H.seq,C.uniforms)}return C.uniformsList}function e2(C,H){const q=Y.get(C);q.outputColorSpace=H.outputColorSpace,q.batching=H.batching,q.batchingColor=H.batchingColor,q.instancing=H.instancing,q.instancingColor=H.instancingColor,q.instancingMorph=H.instancingMorph,q.skinning=H.skinning,q.morphTargets=H.morphTargets,q.morphNormals=H.morphNormals,q.morphColors=H.morphColors,q.morphTargetsCount=H.morphTargetsCount,q.numClippingPlanes=H.numClippingPlanes,q.numIntersection=H.numClipIntersection,q.vertexAlphas=H.vertexAlphas,q.vertexTangents=H.vertexTangents,q.toneMapping=H.toneMapping}function V3(C,H){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(H.matrixWorld);for(let q=0,X=C.length;q<X;q++){const $=C[q];if($.texture!==null&&$.boundingBox.containsPoint(y))return $}return null}function W3(C,H,q,X,$){H.isScene!==!0&&(H=Gi),J.resetTextureUnits();const Et=H.fog,It=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?H.environment:null,St=W===null?_.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:He.workingColorSpace,zt=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Yt=ut.get(X.envMap||It,zt),_e=X.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Ce=!!q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),qt=!!q.morphAttributes.position,gi=!!q.morphAttributes.normal,nn=!!q.morphAttributes.color;let qi=ka;X.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(qi=_.toneMapping);const wi=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,is=wi!==void 0?wi.length:0,Tt=Y.get(X),Zs=b.state.lights;if(ne===!0&&(se===!0||C!==Z)){const Ri=C===Z&&X.id===Q;Qt.setState(X,C,Ri)}let Xe=!1;X.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==Zs.state.version||Tt.outputColorSpace!==St||$.isBatchedMesh&&Tt.batching===!1||!$.isBatchedMesh&&Tt.batching===!0||$.isBatchedMesh&&Tt.batchingColor===!0&&$.colorTexture===null||$.isBatchedMesh&&Tt.batchingColor===!1&&$.colorTexture!==null||$.isInstancedMesh&&Tt.instancing===!1||!$.isInstancedMesh&&Tt.instancing===!0||$.isSkinnedMesh&&Tt.skinning===!1||!$.isSkinnedMesh&&Tt.skinning===!0||$.isInstancedMesh&&Tt.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&Tt.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&Tt.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&Tt.instancingMorph===!1&&$.morphTexture!==null||Tt.envMap!==Yt||X.fog===!0&&Tt.fog!==Et||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==Qt.numPlanes||Tt.numIntersection!==Qt.numIntersection)||Tt.vertexAlphas!==_e||Tt.vertexTangents!==Ce||Tt.morphTargets!==qt||Tt.morphNormals!==gi||Tt.morphColors!==nn||Tt.toneMapping!==qi||Tt.morphTargetsCount!==is||!!Tt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Xe=!0):(Xe=!0,Tt.__version=X.version);let dr=Tt.currentProgram;Xe===!0&&(dr=Df(X,H,$),D&&X.isNodeMaterial&&D.onUpdateProgram(X,dr,Tt));let jr=!1,Ro=!1,Al=!1;const xi=dr.getUniforms(),sn=Tt.uniforms;if(R.useProgram(dr.program)&&(jr=!0,Ro=!0,Al=!0),X.id!==Q&&(Q=X.id,Ro=!0),Tt.needsLights){const Ri=V3(b.state.lightProbeGridArray,$);Tt.lightProbeGrid!==Ri&&(Tt.lightProbeGrid=Ri,Ro=!0)}if(jr||Z!==C){R.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),xi.setValue(z,"projectionMatrix",C.projectionMatrix),xi.setValue(z,"viewMatrix",C.matrixWorldInverse);const Do=xi.map.cameraPosition;Do!==void 0&&Do.setValue(z,ai.setFromMatrixPosition(C.matrixWorld)),L.logarithmicDepthBuffer&&xi.setValue(z,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&xi.setValue(z,"isOrthographic",C.isOrthographicCamera===!0),Z!==C&&(Z=C,Ro=!0,Al=!0)}if(Tt.needsLights&&(Zs.state.directionalShadowMap.length>0&&xi.setValue(z,"directionalShadowMap",Zs.state.directionalShadowMap,J),Zs.state.spotShadowMap.length>0&&xi.setValue(z,"spotShadowMap",Zs.state.spotShadowMap,J),Zs.state.pointShadowMap.length>0&&xi.setValue(z,"pointShadowMap",Zs.state.pointShadowMap,J)),$.isSkinnedMesh){xi.setOptional(z,$,"bindMatrix"),xi.setOptional(z,$,"bindMatrixInverse");const Ri=$.skeleton;Ri&&(Ri.boneTexture===null&&Ri.computeBoneTexture(),xi.setValue(z,"boneTexture",Ri.boneTexture,J))}$.isBatchedMesh&&(xi.setOptional(z,$,"batchingTexture"),xi.setValue(z,"batchingTexture",$._matricesTexture,J),xi.setOptional(z,$,"batchingIdTexture"),xi.setValue(z,"batchingIdTexture",$._indirectTexture,J),xi.setOptional(z,$,"batchingColorTexture"),$._colorsTexture!==null&&xi.setValue(z,"batchingColorTexture",$._colorsTexture,J));const Io=q.morphAttributes;if((Io.position!==void 0||Io.normal!==void 0||Io.color!==void 0)&&U.update($,q,dr),(Ro||Tt.receiveShadow!==$.receiveShadow)&&(Tt.receiveShadow=$.receiveShadow,xi.setValue(z,"receiveShadow",$.receiveShadow)),(X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&H.environment!==null&&(sn.envMapIntensity.value=H.environmentIntensity),sn.dfgLUT!==void 0&&(sn.dfgLUT.value=i8()),Ro){if(xi.setValue(z,"toneMappingExposure",_.toneMappingExposure),Tt.needsLights&&X3(sn,Al),Et&&X.fog===!0&&$t.refreshFogUniforms(sn,Et),$t.refreshMaterialUniforms(sn,X,ct,lt,b.state.transmissionRenderTarget[C.id]),Tt.needsLights&&Tt.lightProbeGrid){const Ri=Tt.lightProbeGrid;sn.probesSH.value=Ri.texture,sn.probesMin.value.copy(Ri.boundingBox.min),sn.probesMax.value.copy(Ri.boundingBox.max),sn.probesResolution.value.copy(Ri.resolution)}h0.upload(z,t2(Tt),sn,J)}if(X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(h0.upload(z,t2(Tt),sn,J),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&xi.setValue(z,"center",$.center),xi.setValue(z,"modelViewMatrix",$.modelViewMatrix),xi.setValue(z,"normalMatrix",$.normalMatrix),xi.setValue(z,"modelMatrix",$.matrixWorld),X.uniformsGroups!==void 0){const Ri=X.uniformsGroups;for(let Do=0,_l=Ri.length;Do<_l;Do++){const i2=Ri[Do];st.update(i2,dr),st.bind(i2,dr)}}return dr}function X3(C,H){C.ambientLightColor.needsUpdate=H,C.lightProbe.needsUpdate=H,C.directionalLights.needsUpdate=H,C.directionalLightShadows.needsUpdate=H,C.pointLights.needsUpdate=H,C.pointLightShadows.needsUpdate=H,C.spotLights.needsUpdate=H,C.spotLightShadows.needsUpdate=H,C.rectAreaLights.needsUpdate=H,C.hemisphereLights.needsUpdate=H}function $3(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return W},this.setRenderTargetTextures=function(C,H,q){const X=Y.get(C);X.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1&&(X.__useRenderToTexture=!1),Y.get(C.texture).__webglTexture=H,Y.get(C.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:q,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,H){const q=Y.get(C);q.__webglFramebuffer=H,q.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(C,H=0,q=0){W=C,k=H,B=q;let X=null,$=!1,Et=!1;if(C){const St=Y.get(C);if(St.__useDefaultFramebuffer!==void 0){R.bindFramebuffer(z.FRAMEBUFFER,St.__webglFramebuffer),nt.copy(C.viewport),ot.copy(C.scissor),Ut=C.scissorTest,R.viewport(nt),R.scissor(ot),R.setScissorTest(Ut),Q=-1;return}else if(St.__webglFramebuffer===void 0)J.setupRenderTarget(C);else if(St.__hasExternalTextures)J.rebindTextures(C,Y.get(C.texture).__webglTexture,Y.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const _e=C.depthTexture;if(St.__boundDepthTexture!==_e){if(_e!==null&&Y.has(_e)&&(C.width!==_e.image.width||C.height!==_e.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(C)}}const zt=C.texture;(zt.isData3DTexture||zt.isDataArrayTexture||zt.isCompressedArrayTexture)&&(Et=!0);const Yt=Y.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Yt[H])?X=Yt[H][q]:X=Yt[H],$=!0):C.samples>0&&J.useMultisampledRTT(C)===!1?X=Y.get(C).__webglMultisampledFramebuffer:Array.isArray(Yt)?X=Yt[q]:X=Yt,nt.copy(C.viewport),ot.copy(C.scissor),Ut=C.scissorTest}else nt.copy(Xt).multiplyScalar(ct).floor(),ot.copy(kt).multiplyScalar(ct).floor(),Ut=Rt;if(q!==0&&(X=O),R.bindFramebuffer(z.FRAMEBUFFER,X)&&R.drawBuffers(C,X),R.viewport(nt),R.scissor(ot),R.setScissorTest(Ut),$){const St=Y.get(C.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,St.__webglTexture,q)}else if(Et){const St=H;for(let zt=0;zt<C.textures.length;zt++){const Yt=Y.get(C.textures[zt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+zt,Yt.__webglTexture,q,St)}}else if(C!==null&&q!==0){const St=Y.get(C.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,St.__webglTexture,q)}Q=-1},this.readRenderTargetPixels=function(C,H,q,X,$,Et,It,St=0){if(!(C&&C.isWebGLRenderTarget)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let zt=Y.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&It!==void 0&&(zt=zt[It]),zt){R.bindFramebuffer(z.FRAMEBUFFER,zt);try{const Yt=C.textures[St],_e=Yt.format,Ce=Yt.type;if(C.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+St),!L.textureFormatReadable(_e)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!L.textureTypeReadable(Ce)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=C.width-X&&q>=0&&q<=C.height-$&&z.readPixels(H,q,X,$,Mt.convert(_e),Mt.convert(Ce),Et)}finally{const Yt=W!==null?Y.get(W).__webglFramebuffer:null;R.bindFramebuffer(z.FRAMEBUFFER,Yt)}}},this.readRenderTargetPixelsAsync=async function(C,H,q,X,$,Et,It,St=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let zt=Y.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&It!==void 0&&(zt=zt[It]),zt)if(H>=0&&H<=C.width-X&&q>=0&&q<=C.height-$){R.bindFramebuffer(z.FRAMEBUFFER,zt);const Yt=C.textures[St],_e=Yt.format,Ce=Yt.type;if(C.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+St),!L.textureFormatReadable(_e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!L.textureTypeReadable(Ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.bufferData(z.PIXEL_PACK_BUFFER,Et.byteLength,z.STREAM_READ),z.readPixels(H,q,X,$,Mt.convert(_e),Mt.convert(Ce),0);const gi=W!==null?Y.get(W).__webglFramebuffer:null;R.bindFramebuffer(z.FRAMEBUFFER,gi);const nn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await j4(z,nn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,Et),z.deleteBuffer(qt),z.deleteSync(nn),Et}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,H=null,q=0){const X=Math.pow(2,-q),$=Math.floor(C.image.width*X),Et=Math.floor(C.image.height*X),It=H!==null?H.x:0,St=H!==null?H.y:0;J.setTexture2D(C,0),z.copyTexSubImage2D(z.TEXTURE_2D,q,0,0,It,St,$,Et),R.unbindTexture()},this.copyTextureToTexture=function(C,H,q=null,X=null,$=0,Et=0){let It,St,zt,Yt,_e,Ce,qt,gi,nn;const qi=C.isCompressedTexture?C.mipmaps[Et]:C.image;if(q!==null)It=q.max.x-q.min.x,St=q.max.y-q.min.y,zt=q.isBox3?q.max.z-q.min.z:1,Yt=q.min.x,_e=q.min.y,Ce=q.isBox3?q.min.z:0;else{const sn=Math.pow(2,-$);It=Math.floor(qi.width*sn),St=Math.floor(qi.height*sn),C.isDataArrayTexture?zt=qi.depth:C.isData3DTexture?zt=Math.floor(qi.depth*sn):zt=1,Yt=0,_e=0,Ce=0}X!==null?(qt=X.x,gi=X.y,nn=X.z):(qt=0,gi=0,nn=0);const wi=Mt.convert(H.format),is=Mt.convert(H.type);let Tt;H.isData3DTexture?(J.setTexture3D(H,0),Tt=z.TEXTURE_3D):H.isDataArrayTexture||H.isCompressedArrayTexture?(J.setTexture2DArray(H,0),Tt=z.TEXTURE_2D_ARRAY):(J.setTexture2D(H,0),Tt=z.TEXTURE_2D),R.activeTexture(z.TEXTURE0),R.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),R.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),R.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);const Zs=R.getParameter(z.UNPACK_ROW_LENGTH),Xe=R.getParameter(z.UNPACK_IMAGE_HEIGHT),dr=R.getParameter(z.UNPACK_SKIP_PIXELS),jr=R.getParameter(z.UNPACK_SKIP_ROWS),Ro=R.getParameter(z.UNPACK_SKIP_IMAGES);R.pixelStorei(z.UNPACK_ROW_LENGTH,qi.width),R.pixelStorei(z.UNPACK_IMAGE_HEIGHT,qi.height),R.pixelStorei(z.UNPACK_SKIP_PIXELS,Yt),R.pixelStorei(z.UNPACK_SKIP_ROWS,_e),R.pixelStorei(z.UNPACK_SKIP_IMAGES,Ce);const Al=C.isDataArrayTexture||C.isData3DTexture,xi=H.isDataArrayTexture||H.isData3DTexture;if(C.isDepthTexture){const sn=Y.get(C),Io=Y.get(H),Ri=Y.get(sn.__renderTarget),Do=Y.get(Io.__renderTarget);R.bindFramebuffer(z.READ_FRAMEBUFFER,Ri.__webglFramebuffer),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,Do.__webglFramebuffer);for(let _l=0;_l<zt;_l++)Al&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Y.get(C).__webglTexture,$,Ce+_l),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Y.get(H).__webglTexture,Et,nn+_l)),z.blitFramebuffer(Yt,_e,It,St,qt,gi,It,St,z.DEPTH_BUFFER_BIT,z.NEAREST);R.bindFramebuffer(z.READ_FRAMEBUFFER,null),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if($!==0||C.isRenderTargetTexture||Y.has(C)){const sn=Y.get(C),Io=Y.get(H);R.bindFramebuffer(z.READ_FRAMEBUFFER,P),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,N);for(let Ri=0;Ri<zt;Ri++)Al?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,sn.__webglTexture,$,Ce+Ri):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,sn.__webglTexture,$),xi?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Io.__webglTexture,Et,nn+Ri):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Io.__webglTexture,Et),$!==0?z.blitFramebuffer(Yt,_e,It,St,qt,gi,It,St,z.COLOR_BUFFER_BIT,z.NEAREST):xi?z.copyTexSubImage3D(Tt,Et,qt,gi,nn+Ri,Yt,_e,It,St):z.copyTexSubImage2D(Tt,Et,qt,gi,Yt,_e,It,St);R.bindFramebuffer(z.READ_FRAMEBUFFER,null),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else xi?C.isDataTexture||C.isData3DTexture?z.texSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,is,qi.data):H.isCompressedArrayTexture?z.compressedTexSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,qi.data):z.texSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,is,qi):C.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,Et,qt,gi,It,St,wi,is,qi.data):C.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,Et,qt,gi,qi.width,qi.height,wi,qi.data):z.texSubImage2D(z.TEXTURE_2D,Et,qt,gi,It,St,wi,is,qi);R.pixelStorei(z.UNPACK_ROW_LENGTH,Zs),R.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Xe),R.pixelStorei(z.UNPACK_SKIP_PIXELS,dr),R.pixelStorei(z.UNPACK_SKIP_ROWS,jr),R.pixelStorei(z.UNPACK_SKIP_IMAGES,Ro),Et===0&&H.generateMipmaps&&z.generateMipmap(Tt),R.unbindTexture()},this.initRenderTarget=function(C){Y.get(C).__webglFramebuffer===void 0&&J.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?J.setTextureCube(C,0):C.isData3DTexture?J.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?J.setTexture2DArray(C,0):J.setTexture2D(C,0),R.unbindTexture()},this.resetState=function(){k=0,B=0,W=null,R.reset(),At.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ca}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=He._getDrawingBufferColorSpace(t),e.unpackColorSpace=He._getUnpackColorSpace()}}class el{constructor(t){this.rateAt=t}static HISTORY_S=20;sums=[0];at(t){if(!(t>0))return 0;const e=Math.floor(t);for(;this.sums.length<=e+1;){const i=this.sums.length-1;this.sums.push(this.sums[i]+(this.rateAt(i)+this.rateAt(i+1))/2)}return this.sums[e]+(this.sums[e+1]-this.sums[e])*(t-e)}stateAt(t){return{impacts:this.at(t),history:Array.from({length:el.HISTORY_S},(e,i)=>this.at(t-i-1))}}}class ke{static NONE={ghosts:[],blades:0,bladeAngleRad:0,scattered:0,drops:0,impacts:0,history:[],still:!1,running:0,reachDeg:30,placed:[]};static PHONE=[{scale:-1,share:5e-5,blur:.006,cause:"sensor",tint:[.41,1,.83]},{scale:-.45,share:5e-6,blur:.02,tint:[.7,1,.8]},{scale:.55,share:375e-8,blur:.035,tint:[1,.75,1]}];static CAMERA=[{scale:-1.4,share:3e-4,blur:.045,tint:[1,.8,1]},{scale:-.8,share:4e-4,blur:.02,tint:[.75,1,.8]},{scale:-.35,share:25e-5,blur:.012,tint:[1,.9,.7]},{scale:.3,share:2e-4,blur:.03,tint:[.8,.9,1]},{scale:.65,share:15e-5,blur:.06,tint:[1,.85,1]}];static FILTER={scale:-1,share:.001,blur:.004,cause:"filter"};static WINDOW={scale:1,share:.0016,blur:.002,offset:[0,.006],cause:"glass"};static WINDSCREEN={scale:1,share:.02,blur:.003,offset:[0,.025],cause:"glass"};static OFF_FRAME_REACH_DEG=30;static offFrameShare(t,e,i=ke.OFF_FRAME_REACH_DEG){const n=Math.min(Math.max((t-e)/i,0),1);return 1-n*n*(3-2*n)}static REFERENCE_F_NUMBER=4;static of(t){return t.ghosts?t.ghosts:ke.records(t)?t.category==="phone"?ke.PHONE:ke.CAMERA:[]}static records(t){return t.medium!==void 0||t.category==="camera"||t.category==="dslr"||t.category==="phone"}static optics(t,e,i,n,s=0){const r=ke.of(t);if(r.length===0)return ke.NONE;const a=t.fNumber??ke.REFERENCE_F_NUMBER,c=e??a,l=[...r,...i?.ghosts??[]].map(y=>({...y,blur:y.blur*a/c}));i?.glass==="filter"?l.push({...ke.FILTER}):i?.glass==="window"?l.push({...ke.WINDOW}):i?.glass==="windscreen"&&l.push({...ke.WINDSCREEN});const h=ke.share(i?.condensation),u=ke.share(i?.dirt),d=ke.falling(i),f=d?n?.impacts??0:0,p=d?n?.history??[]:[],m=f-(p[ke.DROP_LIFE_S-1]??0),g=i?.drops!==void 0?ke.share(i.drops):d?Math.min(1,m):0;h>0&&(l.push({scale:1,share:.25*h,blur:.03,cause:"condensation"}),l.push({scale:1,share:.15*h,blur:.12,cause:"condensation"})),u>0&&(l.push({scale:1,share:.03*u,blur:.04,cause:"dirt"}),l.push({scale:1,share:.02*u,blur:.15,cause:"dirt"})),g>0&&l.push({scale:1,share:.12*g,blur:.025,cause:"drops"});const v=l.filter(y=>ke.scatters(y)).reduce((y,x)=>y+x.share,0),M=_i.bladesShowing(t,e)>=.5?t.apertureBlades??0:0,w=i?.glass==="window"||i?.glass==="windscreen"?1:.25;return{ghosts:l,blades:M,bladeAngleRad:.3,scattered:Math.min(.9,v),drops:g,impacts:f,history:p,still:i?.drops!==void 0,running:w,reachDeg:i?.reachDeg??ke.OFF_FRAME_REACH_DEG,placed:(i?.placedDrops??[]).map(y=>ke.placedAt(y,s))}}static placedAt(t,e){const i=t.track,n=i.findIndex(c=>c.t>e);if(n===0)return{x:i[0].x,y:i[0].y,radius:t.radius};if(n===-1){const c=i[i.length-1];return{x:c.x,y:c.y,radius:t.radius}}const s=i[n-1],r=i[n],a=(e-s.t)/(r.t-s.t);return{x:s.x+(r.x-s.x)*a,y:s.y+(r.y-s.y)*a,radius:t.radius}}static falling(t){return t?.drops===void 0&&!t?.sheltered}static DROP_LIFE_S=8;static impactRate(t,e,i){const n=ke.dropsFrom(t);if(n===0)return 0;const s=t.precipitationType==="snow"?1:6.5,r=((i?.windFromDeg??0)+180)*Math.PI/180,a=i?.windSpeedMS??0,c=[Math.sin(r)*a,Math.cos(r)*a,-s],l=(i?.headingDeg??0)*Math.PI/180,h=(e==="window"?0:e==="windscreen"?60:i?.pitchDeg??0)*Math.PI/180,u=[Math.sin(l)*Math.cos(h),Math.cos(l)*Math.cos(h),Math.sin(h)],d=Math.hypot(c[0],c[1],c[2]),f=Math.max(0,-(c[0]*u[0]+c[1]*u[1]+c[2]*u[2])/d);return n*.4*(.02+.98*f)}static scatters(t){return t.cause==="condensation"||t.cause==="dirt"||t.cause==="drops"}static dropsFrom(t){if(!t||t.precipitationType==="none"||t.precipitationType==="hail")return 0;const e=ke.share(t.precipitationIntensity);return e===0?0:t.precipitationType==="snow"?.5*e:Math.min(1,.3+.7*e)}static positionOf(t,e){return{x:e.x*t.scale+2*(t.offset?.[0]??0),y:e.y*t.scale+2*(t.offset?.[1]??0)}}static sourceOf(t,e){return{x:(e.x-2*(t.offset?.[0]??0))/t.scale,y:(e.y-2*(t.offset?.[1]??0))/t.scale}}static share(t){return Math.max(0,Math.min(1,t??0))}}const Ln=Math.PI/180;class ee{constructor(t){this.words=t}static COARSE_DEG=2;static FINE_DEG=.25;findingsOf(t,e){const i=Ze.strip(e).recording,n=i.interpretation?.mechanism;if(!n)return[];const s=ee.settingOf(t,n.explains);if(!s)return[];const r="interpretation.mechanism";switch(n.kind){case"fixed-in-frame":{const a=ee.missOf(s.samples,ee.fixedPoint(s.samples));return[this.finding(this.words.bestFixed,a,s,{},"established",r)]}case"driven-one-way":{const{miss:a,directionDeg:c}=ee.oneWay(s.samples);return[this.finding(this.words.bestOneWay,a,s,{direction:Math.round(c)},"established",r)]}case"lens-ghost":return this.lensGhostFindings(s,i,r);case"stated-ghost":return this.statedGhostFindings(s,i,r);case"ghost-of":return this.ghostOfFindings(s,i,n.of,r);case"real-object":return[this.realObjectFinding(s,i,n.explains,r)]}}ghostOfFindings(t,e,i,n){const s=e.interpretation?.bodies?.find(u=>u.id===i);if(!s)return[];const r=t.samples.map(u=>{const d=ee.bodyDirectionAt(s,u.t);if(!d)return;const f=d.applyQuaternion(u.frame.inverse);return f.z<0?{x:f.x/-f.z,y:f.y/-f.z}:void 0}),a=ke.of(_i.byId(e.instrument)).filter(u=>!ke.scatters(u)).map(u=>u.scale);let c;for(const u of a){const d=r.map(p=>p?{x:u*p.x,y:u*p.y}:void 0),f=ee.missOfTrack(t.samples,d);(!c||f.medianDeg<c.miss.medianDeg)&&(c={miss:f,k:u,track:d})}if(!c)return[];const l=c.track.filter(u=>u!==void 0);let h=0;for(const u of l)for(const d of l)h=Math.max(h,ee.angleDeg(u,d));return[this.finding(this.words.bestGhostOf,c.miss,t,{k:this.number(c.k),ghostTravel:this.number(h)},"established",n)]}realObjectFinding(t,e,i,n){const r=e.interpretation?.bodies?.find(l=>l.explains?.includes(i))?.track[0]?.distanceM??ee.DEFAULT_DISTANCE_M,a=t.samples.map(l=>new T(l.at.x,l.at.y,-1).normalize().applyQuaternion(l.frame.rotation));let c=0;for(let l=0;l<a.length;l++){const h=t.samples.findIndex(u=>u.t>=t.samples[l].t+ee.RATE_WINDOW_MS);if(h<0)break;c=Math.max(c,a[l].angleTo(a[h])/((t.samples[h].t-t.samples[l].t)/1e3))}return{text:this.fill(this.words.bestRealObject,{medianDeg:0,maxDeg:0},t,{distance:Math.round(r),width:this.number(r*t.sizeDeg*Ln),speed:Math.round(r*c)}),outcome:"holds",against:"established",path:n}}static bodyDirectionAt(t,e){const i=t.track.filter(l=>l.azimuthDeg!==void 0&&l.altitudeDeg!==void 0);if(i.length===0)return;const n=i.findIndex(l=>l.t>e),s=i[n<=0?n===0?0:i.length-1:n-1],r=n<=0?s:i[n],a=r.t>s.t?(e-s.t)/(r.t-s.t):0,c=((r.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return ee.direction(s.azimuthDeg+c*a,s.altitudeDeg+(r.altitudeDeg-s.altitudeDeg)*a)}static DEFAULT_DISTANCE_M=1e3;static RATE_WINDOW_MS=500;static lays(t){return t?.kind==="fixed-in-frame"||t?.kind==="driven-one-way"||t?.kind==="real-object"}bestSceneOf(t,e){const n=Ze.strip(e).recording.interpretation?.mechanism;if(!ee.lays(n))return;const s=ee.settingOf(t,n.explains);if(!s)return;const r=structuredClone(e);if(n.kind==="fixed-in-frame"||n.kind==="real-object"){const a=r.interpretation??{bodies:[]},c=a.bodies??[],l=c.findIndex(d=>d.explains?.includes(n.explains)),h=l>=0?c[l]:void 0,u=n.kind==="fixed-in-frame"?ee.stillBody(s,n.explains,h):ee.sightLineBody(s,n.explains,h);r.interpretation={...a,bodies:l>=0?c.map((d,f)=>f===l?u:d):[...c,u]}}else{const{track:a}=ee.oneWay(s.samples),c=r.lens?.placedDrops?.[0],l=s.samples[0],h=c?.radius??ee.round(s.sizeDeg/l.frame.fovDeg,4),u=s.samples.map((d,f)=>{const p=Math.tan(d.frame.fovDeg/2*Ln);return{t:d.t,x:ee.round(.5+a[f].x/(2*p*s.aspect),4),y:ee.round(.5-a[f].y/(2*p),4)}});r.lens={...r.lens,placedDrops:[{radius:h,track:u}]}}return r}static stillBody(t,e,i){const n=ee.fixedPoint(t.samples),s=t.samples[0].t,r=t.samples[t.samples.length-1].t,a=[...new Set([...t.samples.map(c=>c.t),...t.keyframes.map(c=>c.t).filter(c=>c>s&&c<r)])].sort((c,l)=>c-l);return ee.bodyAlong(t,e,i,a,()=>n)}static sightLineBody(t,e,i){return ee.bodyAlong(t,e,i,t.samples.map(n=>n.t),(n,s)=>t.samples[s].at)}static bodyAlong(t,e,i,n,s){const r=n[n.length-1],a=i?.track[0],c=a?.distanceM??ee.DEFAULT_DISTANCE_M,l=a?.sizeM??(()=>{const f=ee.round(c*t.sizeDeg*Ln,4);return{widthM:f,lengthM:f,heightM:f}})(),h=a?.appearance??{color:"#f4f6f5"},u=n.map((f,p)=>{const m=s(f,p),g=new T(m.x,m.y,-1).normalize().applyQuaternion(ee.frameAt(t.keyframes,f).rotation);return{t:f,...p===0?{present:!0,sizeM:l,appearance:h}:{},azimuthDeg:ee.round((Math.atan2(g.x,-g.z)/Ln+360)%360,3),altitudeDeg:ee.round(Math.asin(Math.min(1,Math.max(-1,g.y)))/Ln,3),distanceM:c}}),d=n.length>1?n[n.length-1]-n[n.length-2]:40;return{...i??{id:e,explains:[e],model:{id:"sphere"}},track:[...u,{t:r+d,present:!1}]}}static round(t,e){return Math.round(t*10**e)/10**e}lensGhostFindings(t,e,i){const n=ke.of(_i.byId(e.instrument)).filter(l=>!ke.scatters(l)).map(l=>l.scale),s=e.lens?.reachDeg??ke.OFF_FRAME_REACH_DEG,r=l=>{const h=ee.sunTrack(t,l,s);if(!h)return;let u;for(const d of n){const f=ee.missOfTrack(t.samples,h.map(p=>({x:d*p.x,y:d*p.y})));(!u||f.medianDeg<u.miss.medianDeg)&&(u={miss:f,k:d})}return u},a=ee.bestSun(t,!0,r),c=[];if(a?c.push(this.finding(this.words.bestGhost,a.result.miss,t,{...this.sunWords(a.sun),k:this.number(a.result.k)},t.lightingGround,i)):c.push({text:this.words.bestNoGhost,outcome:"fails",against:t.lightingGround,path:i}),t.lighting&&(!a||a.result.miss.medianDeg>t.sizeDeg)){const l=ee.bestSun(t,!1,r);l&&(!a||l.result.miss.medianDeg<a.result.miss.medianDeg-1e-6)&&c.push({text:this.fill(this.words.bestGhostNeeds,l.result.miss,t,{...this.sunWords(l.sun),k:this.number(l.result.k)}),outcome:"fails",against:t.lightingGround,path:"lighting"})}return c}statedGhostFindings(t,e,i){const n=e.lens?.reachDeg??ke.OFF_FRAME_REACH_DEG,s=c=>{const l=ee.sunTrack(t,c,n);if(!l)return;const h=ee.linearFit(l,t.samples.map(d=>d.at)),u=l.map(d=>({x:h.k*d.x+h.offset.x,y:h.k*d.y+h.offset.y}));return{miss:ee.missOfTrack(t.samples,u),...h}},r=ee.bestSun(t,!0,s);if(!r)return[{text:this.words.bestNoGhost,outcome:"fails",against:t.lightingGround,path:i}];const a=Math.atan(Math.hypot(r.result.offset.x,r.result.offset.y))/Ln;return[this.finding(this.words.bestStatedGhost,r.result.miss,t,{...this.sunWords(r.sun),k:this.number(r.result.k),offset:this.number(a)},t.lightingGround,i)]}finding(t,e,i,n,s,r){return{text:this.fill(t,e,i,n),outcome:e.medianDeg<=i.sizeDeg?"holds":"fails",against:s,path:r}}fill(t,e,i,n){const s={median:this.number(e.medianDeg),max:this.number(e.maxDeg),size:this.number(i.sizeDeg),travel:this.number(i.travelDeg),...n};return t.replace(/\{(\w+)\}/g,(r,a)=>a in s?String(s[a]):r)}sunWords(t){return{bearing:Math.round(t.bearing),altitude:this.number(t.altitudeDeg)}}number(t){const e=Math.abs(t)<1?2:1;return t.toFixed(e).replace(".",this.words.decimal)}static settingOf(t,e){const{recording:i,provenance:n}=Ze.strip(t),s=i.observerTrack?.keyframes??[];if(s.length===0)return;const r=_i.aspectOf(_i.byId(i.instrument)),a=[],c=[];for(const d of i.timeline?.keyframes??[])for(const f of d.shapes??[]){const p=f.shape;if(f.sourceId!==e||!p.aim)continue;const m=ee.frameAt(s,d.t),g=ee.direction(p.aim.azimuthDeg,p.aim.altitudeDeg).applyQuaternion(m.inverse);g.z>=0||(a.push({t:d.t,at:{x:g.x/-g.z,y:g.y/-g.z},frame:m}),p.angular?.widthDeg&&c.push(p.angular.widthDeg))}if(a.length===0)return;c.sort((d,f)=>d-f);let l=0;for(const d of a)for(const f of a)l=Math.max(l,ee.angleDeg(d.at,f.at));const h=s[0].pose,u=h.lat??0;return{samples:a,keyframes:s,sizeDeg:c.length>0?c[Math.floor(c.length/2)]:.5,travelDeg:l,aspect:r,headingDeg:h.headingDeg??0,lighting:i.lighting,lightingGround:Ze.free(n.at("lighting"))?"supposed":"established",altitudes:{minDeg:-Math.acos(6371e3/(6371e3+Math.max(h.elevationM??0,0)))/Ln,maxDeg:ee.highestSun(i.time,n.at("time")?.range,u,h.lng??0)}}}static highestSun(t,e,i,n){const[s,r]=(typeof e=="string"?e:t??"").split("/"),a=s?Xs(s):void 0,c=r?Xs(r):a;if(!a||!c)return 90;const l=or.earliestOf(a),h=or.latestOf(c),u=864e5;let d=-90;for(let f=Math.floor(l/u)*u;f<=h;f+=u){const p=f+(12-n/15)*36e5;for(let m=-60;m<=60;m+=10)d=Math.max(d,Sh("Sun",new Date(p+m*6e4),{lat:i,lng:n,elevationM:0}).altitudeDeg)}return d}static frameAt(t,e){const i=t.findIndex(u=>u.t>e),n=t[i<=0?i===0?0:t.length-1:i-1],s=i<=0?n:t[i],r=s.t>n.t?(e-n.t)/(s.t-n.t):0,a=(u,d,f)=>(u??f)+((d??u??f)-(u??f))*r,c=(((s.pose.headingDeg??0)-(n.pose.headingDeg??0))%360+540)%360-180,l=(n.pose.headingDeg??0)+c*r,h=new es().setFromEuler(new Yr(a(n.pose.pitchDeg,s.pose.pitchDeg,0)*Ln,-l*Ln,a(n.pose.rollDeg,s.pose.rollDeg,0)*Ln,"YXZ"));return{rotation:h,inverse:h.clone().invert(),fovDeg:a(n.pose.fovDeg,s.pose.fovDeg,50)}}static direction(t,e){const i=t*Ln,n=e*Ln;return new T(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}static angleDeg(t,e){const i=(t.x*e.x+t.y*e.y+1)/Math.sqrt((t.x*t.x+t.y*t.y+1)*(e.x*e.x+e.y*e.y+1));return Math.acos(Math.min(1,Math.max(-1,i)))/Ln}static missOf(t,e){return ee.missOfTrack(t,t.map(()=>e))}static missOfTrack(t,e){const i=t.map((n,s)=>e[s]?ee.angleDeg(n.at,e[s]):180).sort((n,s)=>n-s);return{medianDeg:i[Math.floor(i.length/2)],maxDeg:i[i.length-1]}}static fixedPoint(t){let e={x:t.reduce((i,n)=>i+n.at.x,0)/t.length,y:t.reduce((i,n)=>i+n.at.y,0)/t.length};for(let i=0;i<100;i++){let n=0,s=0,r=0;for(const a of t){const c=1/Math.max(Math.hypot(a.at.x-e.x,a.at.y-e.y),1e-9);n+=a.at.x*c,s+=a.at.y*c,r+=c}e={x:n/r,y:s/r}}return e}static oneWay(t){let e;for(let i=0;i<360;i+=5){const n={x:Math.sin(i*Ln),y:Math.cos(i*Ln)},s={x:n.y,y:-n.x},r=t.map(d=>d.at.x*n.x+d.at.y*n.y),a=t.map(d=>d.at.x*s.x+d.at.y*s.y).sort((d,f)=>d-f),c=a[Math.floor(a.length/2)],h=ee.neverBack(r).map(d=>({x:d*n.x+c*s.x,y:d*n.y+c*s.y})),u=ee.missOfTrack(t,h);(!e||u.medianDeg<e.miss.medianDeg||u.medianDeg===e.miss.medianDeg&&u.maxDeg<e.miss.maxDeg)&&(e={miss:u,directionDeg:i,track:h})}return e}static neverBack(t){const e=[];for(const i of t)for(e.push({sum:i,count:1});e.length>1&&e[e.length-2].sum/e[e.length-2].count>e[e.length-1].sum/e[e.length-1].count;){const n=e.pop();e[e.length-1].sum+=n.sum,e[e.length-1].count+=n.count}return e.flatMap(i=>new Array(i.count).fill(i.sum/i.count))}static sunTrack(t,e,i){const n=ee.direction(t.headingDeg+e.bearing,e.altitudeDeg),s=[];for(const r of t.samples){const a=n.clone().applyQuaternion(r.frame.inverse),c=Math.acos(Math.min(1,Math.max(-1,-a.z)))/Ln,l=Math.tan(r.frame.fovDeg/2*Ln),h=Math.atan(l*Math.hypot(1,t.aspect))/Ln;if(a.z>=0||c>=h+i)return;s.push({x:a.x/-a.z,y:a.y/-a.z})}return s}static linearFit(t,e){const i=t.length,n=h=>({x:h.reduce((u,d)=>u+d.x,0)/i,y:h.reduce((u,d)=>u+d.y,0)/i}),s=n(t),r=n(e);let a=0,c=0;for(let h=0;h<i;h++)a+=(t[h].x-s.x)*(e[h].x-r.x)+(t[h].y-s.y)*(e[h].y-r.y),c+=(t[h].x-s.x)**2+(t[h].y-s.y)**2;const l=c>1e-12?a/c:0;return{k:l,offset:{x:r.x-l*s.x,y:r.y-l*s.y}}}static bestSun(t,e,i){const n=h=>h.altitudeDeg>=t.altitudes.minDeg&&h.altitudeDeg<=t.altitudes.maxDeg&&(!e||!t.lighting||ee.lights(t.lighting,h));let s;const r=h=>{if(!n(h))return;const u=i(h);u&&(!s||u.miss.medianDeg<s.result.miss.medianDeg)&&(s={sun:h,result:u})},{minDeg:a,maxDeg:c}=t.altitudes;for(let h=0;h<360;h+=ee.COARSE_DEG){for(let u=a;u<=c;u+=ee.COARSE_DEG/2)r({bearing:h,altitudeDeg:u});r({bearing:h,altitudeDeg:c})}if(!s)return;const l=s.sun;for(let h=-2;h<=ee.COARSE_DEG;h+=ee.FINE_DEG)for(let u=-2;u<=ee.COARSE_DEG;u+=ee.FINE_DEG)r({bearing:((l.bearing+h)%360+360)%360,altitudeDeg:l.altitudeDeg+u});return s}static lights(t,e){const i=t.sunFromViewDeg,n=i?((e.bearing-i.fromDeg)%360+360)%360:0,s=i?((i.toDeg-i.fromDeg)%360+360)%360:360,r=!t.sunAltitudeDeg||e.altitudeDeg>=t.sunAltitudeDeg.minDeg&&e.altitudeDeg<=t.sunAltitudeDeg.maxDeg;return n<=s&&r}}const s8=[{path:"place.locations.0.lat",what:"latitude"},{path:"place.locations.0.lng",what:"longitude"}];class fn{constructor(t){this.words=t,this.bestCases=new ee(t)}bestCases;found=new WeakMap;findingsOf(t,e){const i=Ze.strip(t),n=Ze.strip(e).recording,s=[],r=this.timeFinding(i.recording.time,i.provenance.at("time"),n.time);r&&s.push(r);for(const{path:c,what:l}of s8){const h=this.numberFinding(fn.at(i.recording,c),i.provenance.at(c),fn.at(n,c),this.words[l]);h&&s.push({...h,path:c})}const a=i.recording.lighting;if(a&&fn.movesTheSun(i.recording,n)){const c=this.lightingFinding(a,i.provenance.at("lighting"),n);c&&s.push(c)}return s.push(...this.bestCasesOf(t,e)),s}bestCasesOf(t,e){const i=JSON.stringify([e.interpretation?.mechanism,e.lens,e.instrument]),n=this.found.get(e);if(n&&n.account===t&&n.key===i)return n.findings;const s=this.bestCases.findingsOf(t,e);return this.found.set(e,{account:t,key:i,findings:s}),s}static withinInterval(t,e){const[i,n]=e.split("/"),s=i?Xs(i):void 0,r=n?Xs(n):void 0;if(!(!s&&!r))return!(s&&t.getTime()<or.earliestOf(s)||r&&t.getTime()>or.latestOf(r))}timeFinding(t,e,i){if(t===void 0||i===void 0||t===i)return;const n=Xs(i),s=n?so(n,0,0):void 0;if(typeof e?.range=="string"&&s){const r=fn.withinInterval(s,e.range);if(r===void 0)return;const a=r?this.words.timeWithin:this.words.timeOutside;return{text:fn.fill(a,{time:i,range:e.range}),outcome:r?"holds":"fails",against:"established",path:"time"}}if(!Ze.free(e))return{text:fn.fill(this.words.timeChanged,{from:t,time:i}),outcome:"fails",against:"established",path:"time"}}numberFinding(t,e,i,n){if(!(typeof t!="number"||typeof i!="number"||Math.abs(t-i)<1e-9)){if(Array.isArray(e?.range)){const[s,r]=e.range,a=i>=s&&i<=r;return{text:fn.fill(a?this.words.valueWithin:this.words.valueOutside,{what:n,value:i,min:s,max:r}),outcome:a?"holds":"fails",against:"established"}}if(!Ze.free(e))return{text:fn.fill(this.words.valueChanged,{what:n,from:t,value:i}),outcome:"fails",against:"established"}}}static movesTheSun(t,e){const i=r=>r.observerTrack?.keyframes?.[0]?.pose,n=i(t),s=i(e);return t.time!==e.time||t.utcOffsetHours!==e.utcOffsetHours||JSON.stringify(t.place)!==JSON.stringify(e.place)||n?.lat!==s?.lat||n?.lng!==s?.lng||n?.headingDeg!==s?.headingDeg}lightingFinding(t,e,i){const n=i.time?Xs(i.time):void 0,s=n?fn.sunOf(n,i):void 0;if(!s)return;const{bearing:r}=s,{fromDeg:a,toDeg:c}=t.sunFromViewDeg??{fromDeg:0,toDeg:360},{minDeg:l,maxDeg:h}=t.sunAltitudeDeg??{minDeg:-90,maxDeg:90},u=fn.lights(t,s),d=Ze.free(e)?"supposed":"established",f=p=>Math.round(p);return{text:fn.fill(u?this.words.lightingHolds:this.words.lightingFails,{bearing:f(r),altitude:f(s.altitudeDeg),from:a,to:c,altitudes:t.sunAltitudeDeg?fn.fill(this.words.altitudes,{min:l,max:h}):""}),outcome:u?"holds":"fails",against:d,path:"lighting",...e?.rationale?{rationale:e.rationale}:{}}}static standOf(t){const e=Ze.strip(t).recording,i=e.observerTrack?.keyframes?.[0]?.pose,n=e.place?.locations?.[0],s=i?.lat??n?.lat,r=i?.lng??n?.lng;if(!(s===void 0||r===void 0||i?.headingDeg===void 0))return{lat:s,lng:r,elevationM:i.elevationM??0,headingDeg:i.headingDeg,utcOffsetHours:e.utcOffsetHours}}static sunOf(t,e){const i=fn.standOf(e);return i?fn.sunFrom(t,i):void 0}static sunFrom(t,e){if(t.hour===void 0)return;const i=so(t,e.lng,e.utcOffsetHours);if(!i)return;const n=Sh("Sun",i,e);return{bearing:((n.azimuthDeg-e.headingDeg)%360+360)%360,altitudeDeg:n.altitudeDeg}}static lights(t,e){const i=t.sunFromViewDeg?fn.onArc(e.bearing,t.sunFromViewDeg.fromDeg,t.sunFromViewDeg.toDeg):!0,n=!t.sunAltitudeDeg||e.altitudeDeg>=t.sunAltitudeDeg.minDeg&&e.altitudeDeg<=t.sunAltitudeDeg.maxDeg;return i&&n}static nearestLit(t,e,i){const n=u=>({...e,hour:Math.floor(u/60),minute:u%60,second:void 0,raw:void 0}),s=fn.standOf(i);if(!s)return;const r=u=>{const d=fn.sunFrom(n(u),s);return d!==void 0&&fn.lights(t,d)};if(e.hour===void 0)return;const a=e.hour*60+(e.minute??0);if(r(a))return e;const c=5;let l;for(let u=0;u<1440;u+=c)r(u)&&(l===void 0||Math.abs(u-a)<Math.abs(l-a))&&(l=u);if(l===void 0)return;const h=a<l?-1:1;for(;l+h>=0&&l+h<1440&&r(l+h)&&Math.abs(l+h-a)<Math.abs(l-a);)l+=h;return n(l)}static onArc(t,e,i){const n=((i-e)%360+360)%360;return((t-e)%360+360)%360<=n}static at(t,e){return e.split(".").reduce((i,n)=>i?.[n],t)}static fill(t,e){return t.replace(/\{(\w+)\}/g,(i,n)=>n in e?String(e[n]):i)}}const r8=Xn.catalog({en:()=>at(()=>import("./ReadingCheckTexts_en-eq6teExJ.js"),[],import.meta.url).then(o=>o.readingCheckTexts_en),fr:()=>at(()=>import("./ReadingCheckTexts_fr-pcDleIvY.js"),[],import.meta.url).then(o=>o.readingCheckTexts_fr),es:()=>at(()=>import("./ReadingCheckTexts_es-CR_JJZMV.js"),[],import.meta.url).then(o=>o.readingCheckTexts_es),it:()=>at(()=>import("./ReadingCheckTexts_it-MFKeoXnq.js"),[],import.meta.url).then(o=>o.readingCheckTexts_it)});class a8{static of(t){if(!(!t||t.length===0))return t.some(e=>e.outcome==="fails"&&e.against!=="supposed")?"incompatible":t.some(e=>e.outcome!=="holds")?"unsettled":"compatible"}}class xs{constructor(t,e,i,n="en"){this.parts=t,this.messages=e,this.onChange=i,this.locale=n,e&&this.setMessages(e),t.text.addEventListener("input",()=>{this.readText(),this.showDeduction()}),t.picker.addEventListener("change",()=>this.writeFromPicker()),t.mode.addEventListener("click",()=>this.setPrecise(!this.precise)),t.text.addEventListener("blur",()=>this.validate()),t.text.addEventListener("focus",()=>this.showDeduction())}precise=!0;hint="";setBounds(t){this.bounds=t;const{picker:e}=this.parts;e.min=t?xs.pickerValueOf(t.min):"",e.max=t?xs.pickerValueOf(t.max):""}bounds;bounded(t){if(!this.bounds)return t;const e=or.latestOf(t)<or.earliestOf(this.bounds.min)?this.bounds.min:or.earliestOf(t)>or.earliestOf(this.bounds.max)?this.bounds.max:t;return this.bounds.adjust?.(e)??e}get isPrecise(){return this.precise}setMessages(t,e=this.locale){this.messages=t,this.locale=e,t.edtfPlaceholder!==void 0&&(this.parts.text.placeholder=t.edtfPlaceholder),this.parts.mode.title=t.edtfModeTitle,this.parts.mode.setAttribute("aria-label",t.edtfModeTitle),this.setPrecise(this.precise)}setPrecise(t){this.precise=t,this.parts.picker.hidden=!t,this.parts.text.hidden=t,this.parts.mode.textContent=(t?this.messages?.datePrecise:this.messages?.dateEdtf)??"",this.parts.mode.setAttribute("aria-pressed",String(!t)),this.parts.help&&(this.parts.help.hidden=t),this.showDeduction()}set(t){const{text:e,picker:i}=this.parts;e.value=t?wh(t):"",i.type!=="date"&&(i.step=xs.stepFor(t)),i.value=i.type==="date"?xs.pickerDateOf(t):xs.pickerValueOf(t),e.setCustomValidity(""),e.classList.remove("invalid"),this.showDeduction()}static opensPrecise(...t){return t.every(e=>e===void 0||xs.isPickable(e)&&xs.qualifierOf(wh(e))==="")}static opensPreciseDate(...t){return t.every(e=>e===void 0||xs.isFullDate(e)&&xs.qualifierOf(wh(e))==="")}static isFullDate(t){return!!t&&t.year!==void 0&&t.month!==void 0&&t.day!==void 0}static pickerDateOf(t){if(!xs.isFullDate(t))return"";const e=(i,n=2)=>String(i).padStart(n,"0");return`${e(t.year,4)}-${e(t.month)}-${e(t.day)}`}static isPickable(t){return!!t&&t.year!==void 0&&t.month!==void 0&&t.day!==void 0&&t.hour!==void 0&&t.minute!==void 0}static pickerValueOf(t){if(!xs.isPickable(t))return"";const e=(n,s=2)=>String(n).padStart(s,"0"),i=t.second?`:${e(t.second)}`:"";return`${e(t.year,4)}-${e(t.month)}-${e(t.day)}T${e(t.hour)}:${e(t.minute)}${i}`}static stepFor(t){return t?.second?"1":"60"}static qualifierOf(t){const e=/[?%]/.test(t),i=/[~%]/.test(t);return e&&i?"%":e?"?":i?"~":""}describe(t){return this.messages?xs.describeTime(t,this.messages,this.locale):""}static describeTime(t,e,i){const n=wh(t),s=xs.qualifierOf(n),r=h=>String(h).padStart(2,"0"),a=[];if(t.season!==void 0){const h={spring:e.timeSeasonSpring,summer:e.timeSeasonSummer,autumn:e.timeSeasonAutumn,winter:e.timeSeasonWinter}[t.season];a.push(t.year!==void 0?`${h} ${t.year}`:h)}else if(t.year!==void 0){const h=t.day!==void 0?{...t.year>=1583?{weekday:"long"}:{},year:"numeric",month:"long",day:"numeric"}:t.month!==void 0?{year:"numeric",month:"long"}:{year:"numeric"},u=new Date(Date.UTC(t.year,(t.month??1)-1,t.day??1));a.push(new Intl.DateTimeFormat(i,{...h,timeZone:"UTC"}).format(u))}t.hour!==void 0&&a.push(`${r(t.hour)}:${r(t.minute??0)}${t.second!==void 0?`:${r(t.second)}`:""}`);const c=a.join(", "),l=s==="~"?e.timeQualifierApproximate:s==="?"?e.timeQualifierUncertain:s==="%"?e.timeQualifierBoth:"";return l?`${c} — ${l.toLowerCase()}`:c}setHint(t){this.hint=t,this.showDeduction()}showDeduction(){const{text:t}=this.parts,e=t.value.trim();if(this.precise||e===""){t.title=this.hint;return}const i=Xs(e);t.title=i?`→ ${this.describe(i)}`:this.messages?.edtfInvalid??""}readText(){const t=this.parts.text.value.trim();if(t===""){this.clean(),this.onChange(void 0);return}const e=Xs(t);if(!e)return;this.clean();const i=this.bounded(e);i!==e&&this.set(i),this.onChange(i)}clean(){this.parts.text.setCustomValidity(""),this.parts.text.classList.remove("invalid")}writeFromPicker(){const{picker:t,text:e}=this.parts;t.value===""&&t.validity.badInput||(e.value=t.value===""?"":t.value.replace(/\.\d+$/,""),this.readText())}validate(){const{text:t}=this.parts,e=t.value.trim();e===""||Xs(e)||(t.setCustomValidity(this.messages?.edtfInvalid??""),t.classList.add("invalid"))}}class Oa{static read(t,e){let i=t;for(const n of e.split(".")){if(i=Oa.bare(i),i===null||typeof i!="object")return;i=i[n]}return Oa.bare(i)}static write(t,e,i){const n=e.split("."),s=[];let r=t;for(let c=0;c<n.length-1;c++){let l=Oa.bare(r[n[c]]);if(l===null||typeof l!="object"||Array.isArray(l)){if(i===void 0)return;l={}}r[n[c]]=l,s.push({owner:r,part:n[c]}),r=l}const a=n[n.length-1];i===void 0?delete r[a]:r[a]=i;for(let c=s.length-1;c>=0;c--){const l=s[c].owner[s[c].part];if(Object.keys(l).length>0)break;delete s[c].owner[s[c].part]}}static stated(t,e){return Oa.read(t,e)!==void 0}static bare(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&"value"in t&&"basis"in t?t.value:t}}class u0{static sets=new Map;static publish(t){u0.sets.set(t.kind,t)}static of(t){return u0.sets.get(t)}static kinds(){return[...u0.sets.keys()]}}class Z0{static resolved=new WeakMap;static resolve(t,e){let i=Z0.resolved.get(t);i||Z0.resolved.set(t,i=new WeakMap);let n=i.get(e);if(!n){const s=e,r=c=>{if(typeof c!="string")return c;if(typeof s[c]=="string")return s[c];const l=c.split(" ");return l.length>1&&l.every(h=>typeof s[h]=="string")?l.map(h=>s[h]).join(" "):c},a=c=>c.map(l=>({...l,label:r(l.label)}));n={...t,title:r(t.title),parameters:t.parameters.map(c=>{const l={...c,label:r(c.label),hint:r(c.hint),summary:r(c.summary),group:r(c.group),..."placeholder"in c?{placeholder:r(c.placeholder)}:{},..."empty"in c?{empty:r(c.empty)}:{}};if(l.type==="choice"){const h=l.optionsOf;return{...l,choices:a(l.choices),...h?{optionsOf:(u,d)=>a(h(u,d))}:{}}}if(l.type==="set"){const h=l.options;return{...l,options:(u,d)=>a(h(u,d))}}return l})},i.set(e,n)}return n}static missing(t,e){const i=e,n=new Set,s=r=>{if(typeof r=="string")for(const a of r.split(" "))/^[a-z][A-Za-z0-9]*$/.test(a)&&i[a]===void 0&&n.add(a)};s(t.title);for(const r of t.parameters)if(s(r.label),s(r.hint),s(r.summary),s(r.group),"placeholder"in r&&s(r.placeholder),"empty"in r&&s(r.empty),r.type==="choice")for(const a of r.choices)s(a.label);return[...n]}}const Xx="#ff2200",$x="#00ff44",Pc="#ffffff",wp="#ffa500",eh="#ff0000",o8="#2244ff",cM=[{id:"airliner",name:"Airliner",kinds:["aircraft"],referenceSizeM:{widthM:34,heightM:12,lengthM:36},create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Xx,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:$x,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Pc,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Pc,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Pc,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],referenceSizeM:{widthM:10,heightM:4,lengthM:14},create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Xx,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:$x,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Pc,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Pc,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Pc,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Pc,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:eh,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:eh,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:o8,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:eh,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"traffic-signal",name:"Traffic light",kinds:["trafficlight"],create:()=>me.vehicleLights(0)},{id:"pedestrian-signal",name:"Pedestrian light",kinds:["trafficlight"],create:()=>me.pedestrianLights(0)},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],referenceSizeM:{widthM:1,heightM:5,lengthM:1},create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class J0{static forKind(t){return cM.filter(e=>e.kinds.includes(t))}static byId(t){return cM.find(e=>e.id===t)}}class me{static CYCLE_S=90;static GREEN_S=41;static AMBER_S=3;static PEDESTRIAN_DELAY_S=2;static PEDESTRIAN_GREEN_S=30;static VEHICLE_INTENSITY=3;static PEDESTRIAN_INTENSITY=1.5;static LENS_RADIUS_M=.1;static BEAM_DEG=30;static VEHICLE_HEAD_Y_M=2.9;static PEDESTRIAN_HEAD_Y_M=2.6;static LENS_SPACING_M=.3;static LENS_FRONT_M=.13;static RED="#ff1e00";static AMBER="#ffa200";static GREEN="#00ff8c";static phaseOf(t){const e=(t%180+180)%180;return e>=45&&e<135?1:0}static vehicleLights(t){const e=t*me.CYCLE_S/2,i=me.VEHICLE_HEAD_Y_M,n=me.LENS_SPACING_M;return[me.lamp("red",me.RED,i+n,e+me.GREEN_S+me.AMBER_S,me.CYCLE_S-me.GREEN_S-me.AMBER_S,me.VEHICLE_INTENSITY),me.lamp("amber",me.AMBER,i,e+me.GREEN_S,me.AMBER_S,me.VEHICLE_INTENSITY),me.lamp("green",me.GREEN,i-n,e,me.GREEN_S,me.VEHICLE_INTENSITY)]}static pedestrianLights(t){const e=t*me.CYCLE_S/2+me.GREEN_S+me.AMBER_S+me.PEDESTRIAN_DELAY_S,i=me.PEDESTRIAN_HEAD_Y_M,n=me.LENS_SPACING_M/2;return[me.lamp("ped-red",me.RED,i+n,e+me.PEDESTRIAN_GREEN_S,me.CYCLE_S-me.PEDESTRIAN_GREEN_S,me.PEDESTRIAN_INTENSITY),me.lamp("ped-green",me.GREEN,i-n,e,me.PEDESTRIAN_GREEN_S,me.PEDESTRIAN_INTENSITY)]}static isPedestrian(t){return t?.some(e=>e.id==="ped-green")??!1}static figureOf(t){return t.id==="ped-red"?"standing":t.id==="ped-green"?"walking":void 0}static lamp(t,e,i,n,s,r){const a=me.CYCLE_S,c=Math.round(((1-n/a)%1+1)%1*1e6)/1e6;return{id:t,color:e,intensity:r,radiusM:me.LENS_RADIUS_M,beamDeg:me.BEAM_DEG,offsetM:{x:0,y:i,z:-.13},pattern:{kind:"flash",perMinute:60/a,dutyCycle:Math.round(s/a*1e6)/1e6,...c?{phase:c}:{}}}}}class Md{static of(t,e){const i=Md.drawnAsModel(t);return{color:e?.color??!i,lit:e?.lit??Md.litByDefault(t.kind,i),headlights:t.kind==="vehicle",lights:(e?.lights??!0)&&Md.rigsFor(t.kind,e).length>0,windows:!i&&oE(t.kind),floors:!i&&t.kind==="building",observerSide:du(t.kind)}}static rigsFor(t,e){return J0.forKind(t).filter(i=>e?.lightRigs===void 0||e.lightRigs.includes(i.id))}static drawnAsModel(t){return _0(t)!==void 0&&!(t.observerSide!==void 0&&du(t.kind))}static litByDefault(t,e){return t==="streetlight"||t==="vehicle"&&!e}}class bi{static sideLabel(t){return bi.SIDE_LABELS[t]}static SIDE_LABELS={front:"front",behind:"behind",left:"left",right:"right","front-left":"frontLeft","front-right":"frontRight","behind-left":"behindLeft","behind-right":"behindRight"};static WINDOWS="windows";static BUILDING="building";static BRIDGE="bridge";static RAILING="railing";static WIRE="overheadLine";static together(t,e){return`${t} ${e}`}static of(t,e){const i=[],n=Md.drawnAsModel(t);if(!n&&t.kind==="building"&&i.push(...bi.floors(),...bi.walls(),...bi.roof()),!n&&oE(t.kind)&&i.push(...bi.windows(t.kind)),t.kind==="vehicle"&&i.push(...bi.engine()),t.kind==="observer"&&i.push(...bi.observerRecording()),t.kind==="aircraft"&&i.push(...bi.aircraftSound(e)),t.kind==="bridge"&&i.push(...bi.bridge()),t.kind==="wire"&&i.push(...bi.wire()),e?.parameters&&i.push(...e.parameters.map(s=>({...s,key:`modelParameters.${s.key}`}))),i.length!==0)return{kind:`decor-${t.kind}`,title:"properties",parameters:i}}static floors(){const t=e=>Oa.read(e,"floors")??A0;return[{type:"number",key:"floors",min:0,max:20,step:1,effective:()=>A0,label:"floors",hint:"upperStoriesAboveTheGround",group:bi.BUILDING},{type:"number",key:"occupiedFloor",min:0,max:20,step:1,effective:()=>0,bounds:e=>({max:t(e)}),label:"occupiedFloor",hint:"theFloorTheWitnessIs",group:bi.BUILDING}]}static walls(){const t="walls";return[{type:"colour",key:"facade.color",group:t,fallback:"#d3cab8",label:"wallColour",hint:"theColourOfTheWalls"},{type:"choice",key:"facade.openings",group:t,label:"facade",empty:"aHouseS",hint:"aHouseSAWindowEvery",choices:[{value:"tall",label:"oldBuilding"},{value:"lancet",label:"church"},{value:"plain",label:"bareWall"},{value:"none",label:"noFacade"}]}]}static roof(){const t="roof";return[{type:"choice",key:"roof.shape",group:t,label:"roof",empty:"flat",hint:"flatTheBoxTwoSlopes",choices:[{value:"flat",label:"flat"},{value:"gable",label:"twoSlopes"},{value:"hip",label:"fourSlopes"},{value:"dome",label:"dome"}]},{type:"number",key:"roof.riseM",min:0,max:15,step:.1,unit:"m",group:t,effective:()=>3,label:"rise",hint:"howFarTheRidgeStands",visibleWhen:i=>["gable","hip","dome"].includes(String(Oa.read(i,"roof.shape")))},{type:"choice",key:"roof.ridge",group:t,required:!1,label:"ridgeAlong",empty:"theWidth",choices:[{value:"width",label:"theWidth"},{value:"depth",label:"theDepth"}],visibleWhen:i=>Oa.read(i,"roof.shape")==="gable"},{type:"colour",key:"roof.color",group:t,fallback:"#7a5a4a",label:"roofColour"}]}static windows(t){return uT(t).map(e=>({type:"number",key:`windows.${e}`,step:5,unit:"%",min:fT(t,e)?0:dT,max:100,label:bi.SIDE_LABELS[e],summary:bi.together(bi.WINDOWS,bi.SIDE_LABELS[e]),hint:"opacityOfTheWindowOn",group:bi.WINDOWS}))}static engine(){const t="engineSound";return[{type:"choice",key:"engine.kind",group:t,label:"engine",hint:"whetherTheVehicleIsHeard",empty:"silentParked",choices:[{value:"car",label:"car"},{value:"van",label:"van"},{value:"truck",label:"truck"},{value:"motorcycle",label:"motorcycle"},{value:"generic",label:"unknown"}]},{type:"number",key:"engine.noise",min:.1,max:3,step:.1,group:t,effective:()=>1,label:"loudness",hint:"againstAnOrdinaryOneOf",visibleWhen:e=>Oa.read(e,"engine.kind")!==void 0||e.engine!==void 0}]}static observerRecording(){return[{type:"text",key:"sightingUrl",placeholder:"https://…/sighting.json",label:"theirOwnRecordingURL"}]}static aircraftSound(t){return[{type:"choice",key:"aircraftSound",group:"sound",label:"noiseInFlight",hint:"whatItSoundsLikeWhile",empty:t?.sound==="silent"?"silentAsTheModel":"asTheModel",choices:[{value:"airliner-narrow",label:"aircraftNarrowBodyAirliner"},{value:"airliner-wide",label:"aircraftWideBodyAirliner"},{value:"regional-jet",label:"aircraftRegionalJet"},{value:"regional-turboprop",label:"aircraftTurboprop"},{value:"business-jet",label:"aircraftBusinessJet"},{value:"light-piston",label:"aircraftLightPistonAircraft"},{value:"helicopter-light",label:"aircraftLightHelicopter"},{value:"helicopter-medium",label:"aircraftMediumHelicopter"},{value:"helicopter-heavy",label:"aircraftHeavyHelicopter"},{value:"military-jet",label:"aircraftMilitaryJet"},{value:"ultralight",label:"aircraftUltralight"},{value:"unmanned",label:"aircraftDrone"},{value:"glider",label:"aircraftGlider"},{value:"silent",label:"aircraftSilent"}]}]}static bridge(){const t=(e,i,n,s,r,a,c,l,h)=>({type:"number",key:e,label:i,min:n,max:s,step:r,unit:a,group:l,hint:h,effective:c===void 0?void 0:()=>c});return[t("bridge.spanM","span",.1,5e3,.1,"m",void 0,bi.BRIDGE,"metresOfOpenSpanUnder"),t("bridge.deckThicknessM","deckThickness",.1,20,.1,"m",1.2,bi.BRIDGE),t("bridge.railing.heightM","height",.1,5,.05,"m",1.05,bi.RAILING),t("bridge.railing.postSpacingM","postSpacing",.2,20,.1,"m",1.5,bi.RAILING),t("bridge.railing.rails","rails",0,8,1,"",2,bi.RAILING)]}static wire(){return[{type:"choice",key:"wire.poles",group:bi.WIRE,label:"poles",hint:"whichEndsStandOnA",choices:[{value:"both",label:"both"},{value:"start",label:"start"},{value:"end",label:"end"},{value:"none",label:"noPoles"}],effective:()=>"both"},{type:"number",key:"wire.diameterM",min:.001,max:.2,step:.001,unit:"m",effective:()=>.008,group:bi.WIRE,label:"strandThickness"},{type:"number",key:"wire.poleHeightM",min:.5,max:100,step:.1,unit:"m",group:bi.WIRE,label:"poleHeight",hint:"emptyHalfAMetreOver"}]}}class Vr{static NONE={id:"none",name:"No filter",opticalDensity:0};static SOLAR_VISUAL={id:"solar-visual",name:"Solar filter for the eye (OD 5)",opticalDensity:5,usableWith:["eye","binoculars","telescope"]};static SOLAR_PHOTO={id:"solar-photo",name:"Solar film for a camera (OD 3.8)",opticalDensity:3.8,usableWith:["camera","dslr","phone","telescope"]};static ALL=[Vr.NONE,Vr.SOLAR_VISUAL,Vr.SOLAR_PHOTO];static usableWith(t,e){return!t.usableWith||t.usableWith.includes(e.category)}static byId(t){return Vr.ALL.find(e=>e.id===t)??Vr.NONE}static transmittance(t){return 10**-t.opticalDensity}static magnitudes(t){return 2.5*t.opticalDensity}}class lM{constructor(t){this.names=t}name(t){return this.names[t.toLowerCase()]??t}stored(t){const e=t.trim().toLowerCase();for(const[i,n]of Object.entries(this.names))if(n.toLowerCase()===e)return i;return t.trim()}}class Vc{constructor(t,e,i,n=new lM({}),s,r={}){this.labels=t,this.naming=e,this.said=i,this.tags=n,this.timeWords=s,this.decorParameterTexts=r}entriesFor(t,e,i={}){const n=[];return this.addSummary(n,t),this.addObservation(n,t),this.addObserver(n,t,e),this.addLocation(n,t,e,i.groundElevationM,i.roadGradeDeg??0),this.addDecor(n,t,e,i),i.phenomena===!0&&this.addPhenomena(n,t,e),this.addTemporal(n,t),this.addWeather(n,t,e),this.addSound(n,t,e),n}push(t,e,i,n,s,r="",a={}){s===void 0||s===""||t.push({group:e,field:i,label:n,value:String(s),unit:r,color:a.color,fromSource:a.fromSource===!0})}percent(t){return t===void 0?void 0:`${Math.round(t*100)} %`}rounded(t,e=0){return t===void 0?void 0:String(Number(t.toFixed(e)))}shows(t,e=0){return t!==void 0&&Number(t.toFixed(e))!==0}showsPercent(t){return this.shows(t===void 0?void 0:t*100)}percentShown(t){return this.showsPercent(t)?this.percent(t):void 0}roundedShown(t,e=0){return this.shows(t,e)?this.rounded(t,e):void 0}static DESCRIPTION_WORDS=3;addSummary(t,e){const i=this.said.read(e.event.description)?.trim();if(!i)return;const n=i.split(/\s+/),s=n.length>Vc.DESCRIPTION_WORDS?`${n.slice(0,Vc.DESCRIPTION_WORDS).join(" ")}…`:i;this.push(t,"summary","description",this.labels.summaryDescription,s),t[t.length-1].full=i}addObservation(t,e){const i=e.event.tags;this.push(t,"observation","tags",this.labels.tags,i&&i.length>0?i.map(n=>this.tags.name(n)).join(", "):void 0)}filterName(t){return t===Vr.SOLAR_VISUAL?this.labels.filterSolarVisual:t===Vr.SOLAR_PHOTO?this.labels.filterSolarPhoto:t.name}addObserver(t,e,i){const n=e.observer;this.push(t,"observer","observerId",this.labels.observerId,n?.id),this.push(t,"observer","observerTitle",this.labels.observerTitle,this.said.read(n?.title)),this.push(t,"observer","observerLastName",this.labels.observerLastName,n?.lastName);const s=n?.firstNames;this.push(t,"observer","observerFirstNames",this.labels.observerFirstNames,s&&s.length>0?s.join(", "):void 0);const r=e.instrument;this.push(t,"observer","instrument",this.labels.instrument,this.naming.instrument(r));const a=e.exposure;this.push(t,"observer","exposureSeconds",this.labels.exposure,a===void 0?void 0:a<1?`1/${Math.round(1/a)}`:this.rounded(a,2),"s");const c=Pe(e,i);if(c){const l=_i.focalLengthMmFor(r,c.fovDeg);l===void 0?this.push(t,"observer","focalLength",this.labels.fieldOfView,this.rounded(c.fovDeg,1),"°"):this.push(t,"observer","focalLength",this.labels.focalLength,this.rounded(l,1),"mm"),this.push(t,"observer","fNumber",this.labels.aperture,this.rounded(c.fNumber??r.fNumber,1)),this.push(t,"observer","focusDistance",this.labels.focusDistance,this.rounded(c.focusDistanceM,1),"m"),this.push(t,"observer","roll",this.labels.roll,this.roundedShown(c.rollDeg),"°");const h=Vr.byId(c.filter);h!==Vr.NONE&&this.push(t,"observer","filter",this.labels.filter,this.filterName(h))}}degreesMinutesSeconds(t,e,i){if(t===void 0||!Number.isFinite(t))return;const n=Math.round(Math.abs(t)*3600),s=Math.floor(n/3600),r=Math.floor(n%3600/60),a=n%60;return`${s}°${String(r).padStart(2,"0")}′${String(a).padStart(2,"0")}″ ${this.naming.point(t<0?i:e)}`}static WALK_KMH=7;static SPEED_SPAN_MS=1e3;static speedKmhAt(t,e){const i=Vc.SPEED_SPAN_MS/2,n=Math.max(0,e-i),s=Pe(t,n),r=Pe(t,n+2*i);if(s?.lat===void 0||s.lng===void 0||r?.lat===void 0||r.lng===void 0)return;const a=(r.lat-s.lat)*111320,c=(r.lng-s.lng)*111320*Math.cos(s.lat*Math.PI/180);return Math.hypot(a,c)/(2*i/1e3)*3.6}addLocation(t,e,i,n,s){const r=e.event.place?.[0];this.push(t,"location","placeName",this.labels.placeName,r?.name);const a=Pe(e,i);if(!a)return;this.push(t,"location","lat",this.labels.latitude,this.degreesMinutesSeconds(a.lat,0,180)),this.push(t,"location","lng",this.labels.longitude,this.degreesMinutesSeconds(a.lng,90,270));const c=this.rounded(a.headingDeg);this.push(t,"location","heading",this.labels.heading,c,a.headingDeg===void 0?"°":`° (${this.naming.point(a.headingDeg)})`),this.push(t,"location","pitch",this.labels.pitch,a.pitchDeg===void 0?void 0:this.rounded(a.pitchDeg+s),"°");const l=Vc.speedKmhAt(e,i);l!==void 0&&l>Vc.WALK_KMH&&this.push(t,"location","speed",this.labels.speed,Math.round(l),"km/h"),n===void 0?this.push(t,"location","elevation",this.labels.heightAboveGround,this.roundedShown(a.elevationM),"m"):this.push(t,"location","elevation",this.labels.elevation,this.rounded(n+a.elevationM),"m")}addDecor(t,e,i,n){const s=e.decor.find(h=>h.id===n.decorId);if(!s){if(n.decorPicker===!0)for(const h of e.decor)this.push(t,"decor",`decor:${h.id}`,this.decorLabel(h),this.decorKindName(h.kind));return}this.push(t,"decor","decorBase.title",this.labels.decorTitle,this.said.read(s.title));const r=Xr(s,i);this.push(t,"decor","decorBase.eastM",this.labels.decorEast,this.rounded(r.eastM,1),"m"),this.push(t,"decor","decorBase.northM",this.labels.decorNorth,this.rounded(r.northM,1),"m"),this.push(t,"decor","decorBase.altitudeM",this.labels.decorAltitude,this.roundedShown(r.altitudeM),"m"),this.push(t,"decor","decorBase.headingDeg",this.labels.decorHeading,this.rounded(r.headingDeg),"°"),Sm(s,i)&&this.push(t,"decor","decorState.lit",this.labels.decorLit,"✓");const a=s.lights?.map(h=>h.id).join()??"",c=a===""?void 0:cM.find(h=>h.create().map(u=>u.id).join()===a);this.push(t,"decor","decorState.lightRig",this.labels.decorLights,c&&this.naming.lightRig(c)),this.push(t,"decor","decorState.observerSide",this.labels.decorObserverSide,this.decorSideName(s.observerSide));const l=bi.of(s);for(const h of(l&&Z0.resolve(l,this.decorParameterTexts))?.parameters??[]){const u=Oa.read(s,h.key);if(u==null)continue;const d=h.type==="choice"?this.said.read(h.choices.find(f=>f.value===u)?.label)??String(u):u;this.push(t,"decor",`decorParam.${h.key}`,this.said.read(h.summary??h.label)??h.key,typeof d=="boolean"?d?"✓":"":d,h.type==="number"?h.unit:void 0)}}timeText(t){return this.timeWords?xs.describeTime(t,this.timeWords.messages,this.timeWords.locale):wh(t)}addTemporal(t,e){const i=e.event;this.push(t,"temporal","obs-time",this.labels.observationTime,i.time&&this.timeText(i.time)),this.push(t,"temporal","obs-end-time",this.labels.observationEndTime,i.endTime&&this.timeText(i.endTime));const n=rE(i);this.push(t,"temporal","durationSeconds",this.labels.duration,this.roundedShown(n&&n/1e3,1),"s"),this.push(t,"temporal","timeZone",this.labels.utcOffset,i.timeZone),this.push(t,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(i.utcOffsetHours,1),"UTC±h")}addWeather(t,e,i){const n=ph(e,i),r={fromSource:e.weatherSource!==void 0},a=this.showsPercent(n.cloudCover)||this.showsPercent(n.lowerCloudCover)||this.showsPercent(n.highCloudCover);this.push(t,"weather","cloudCover",this.labels.cloudCover,this.percentShown(n.cloudCover),"",r),this.push(t,"weather","highCloudCover",this.labels.highCloudCover,this.percentShown(n.highCloudCover),"",r),this.push(t,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.showsPercent(n.highCloudCover)?this.percent(n.iceCrystalAlignment):void 0),this.push(t,"weather","rareIceCrystals",this.labels.rareIceCrystals,this.showsPercent(n.highCloudCover)?this.percent(n.rareIceCrystals):void 0),this.push(t,"weather","cloudDarkness",this.labels.cloudDarkness,a?this.percent(n.cloudDarkness):void 0,"",r),this.push(t,"weather","cloudBase",this.labels.cloudBase,a?this.rounded(n.cloudBaseM):void 0,"m",r);const c=n.precipitationType!=="none"&&this.showsPercent(n.precipitationIntensity);this.push(t,"weather","precipitationType",this.labels.precipitationType,c?this.precipitationName(n.precipitationType):void 0,"",r),this.push(t,"weather","precipitationIntensity",this.labels.precipitationIntensity,c?this.percent(n.precipitationIntensity):void 0,"",r),this.push(t,"weather","windDirection",this.labels.windDirection,this.shows(n.windSpeed,2)?this.rounded(n.windDirectionDeg):void 0,"°",r),this.push(t,"weather","windSpeed",this.labels.windSpeed,this.roundedShown(n.windSpeed,2),"m/s",r),n.storm&&this.push(t,"weather","storm",this.labels.storm,"✓","",r)}addSound(t,e,i){const n=aE(e,i);n.kind!=="none"&&(this.push(t,"sound","soundKind",this.labels.soundKind,this.soundKindName(n.kind)),this.push(t,"sound","soundVolume",this.labels.soundVolume,this.percentShown(n.volume)),this.push(t,"sound","soundPitch",this.labels.soundPitch,this.roundedShown(n.pitchHz),"Hz"),this.push(t,"sound","soundSrc",this.labels.soundSrc,n.src))}addPhenomena(t,e,i){for(const n of e.timeline.sourceIds){const s=e.timeline.getInterpolatedShapeAt(i,n),r=s?.angular,a=r?`${this.rounded(r.widthDeg,2)} × ${this.rounded(r.heightDeg,2)}°`:void 0;this.push(t,"phenomenon",`shape:${n}`,this.said.read(s?.title)??n,a)}for(const n of e.interpretation?.bodies??[]){const s=n.track.find(a=>a.sizeM?.widthM!==void 0)?.sizeM?.widthM,r=n.model.id??n.model.url?.replace(/^.*\//,"");this.push(t,"phenomenon",`body:${n.id}`,this.said.read(n.title)??n.id,[r,s!==void 0?`${this.rounded(s,2)} m`:void 0].filter(Boolean).join(", "))}}decorLabel(t){return this.said.read(t.title)??this.decorKindName(t.kind)}decorKindName(t){switch(t){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"shrub":return this.labels.decorShrub;case"bridge":return this.labels.decorBridge;case"wire":return this.labels.decorWire;case"crop":return this.labels.decorCrop;case"terrace":return this.labels.decorTerrace;case"mound":return this.labels.decorMound;case"wall":return this.labels.decorWall;case"streetlight":return this.labels.decorStreetlight;case"trafficlight":return this.labels.decorTrafficLight;case"crossing":return this.labels.decorCrossing;case"roadsign":return this.labels.decorRoadSign;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorObserver}}decorSideName(t){switch(t){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(t){switch(t){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(t){switch(t){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}}const c8="Global Meteor Network",l8="https://globalmeteornetwork.org/data/",h8="“Thunder” by Jerimee",u8="https://creativecommons.org/licenses/by/3.0/",d8="CC BY 3.0";class Yn{static fill(t,e){t.innerHTML="";const i=d=>t.appendChild(d),n=e.currentTerrainAttribution;n&&i(Yn.text(n));const s=e.currentRoadAttribution;s&&i(Yn.text(s));const r=e.currentWaterAttribution;r&&i(Yn.text(r));const a=e.currentRailwayAttribution;a&&i(Yn.text(a));const c=e.ufoElement.observerMapCredit;c&&!n?.includes(c)&&i(Yn.text(c));for(const d of e.decorModelCredits){const f=d.author?` — ${d.author}`:"",p=document.createElement("li");d.sourceUrl?p.append(Yn.link(d.sourceUrl,d.title),document.createTextNode(`${f} (${d.license})`)):p.textContent=`${d.title}${f} (${d.license})`,i(p)}for(const d of e.ufoElement.sighting.references){if(!d.credit)continue;const f=document.createElement("li");d.creditUrl?f.appendChild(Yn.link(d.creditUrl,d.credit)):f.textContent=d.credit,i(f)}if(e.ufoElement.sighting.traces.length>0){const d=new Qn(Ws.preferencesFor(e)),f=new Set(e.ufoElement.sighting.traces.map(p=>d.read(p.source)).filter(p=>!!p));for(const p of f)i(Yn.text(p))}const l=e.satelliteState;if(l.status==="ready"&&l.credit){const d=document.createElement("li");d.appendChild(Yn.link(l.creditUrl??"",l.credit)),i(d)}if(e.fireballState.status==="ready"&&e.fireballState.records.length>0){const d=document.createElement("li");d.append(Yn.link(l8,c8),document.createTextNode(" (CC BY 4.0)")),i(d)}const h=e.aircraftState;if(h.status==="ready"&&h.shown>0){const d=document.createElement("li");if(d.appendChild(Yn.link(h.creditUrl,h.credit)),i(d),h.trailCredit){const f=document.createElement("li");f.appendChild(Yn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(f)}}const u=Yn.text(`${h8} (`);u.append(Yn.link(u8,d8),document.createTextNode(")")),i(u)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const f8=Re.point("assessment").provide(Re.BUILT_IN,[{id:"coverage",name:"Coverage",credit:"UFO@home",creditUrl:"https://ufoathome.org",create:()=>({about:"observer",assess:async o=>{const{CoverageAssessor:t}=await at(async()=>{const{CoverageAssessor:e}=await import("./CoverageAssessor-BSoRnjHD.js");return{CoverageAssessor:e}},[],import.meta.url);return new t().assess(o)}})},{id:"hynek",name:"Hynek",credit:"J. Allen Hynek",creditUrl:"https://rr0.org/science/crypto/ufo/observation/classification/hynek/",create:()=>({about:"temporal",assess:async o=>{const{HynekAssessor:t}=await at(async()=>{const{HynekAssessor:e}=await import("./HynekAssessor-CJ9APziM.js");return{HynekAssessor:e}},__vite__mapDeps([2,3]),import.meta.url);return new t().assess(o)}})},{id:"ballester-guasp",name:"Ballester-Guasp",credit:"V.-J. Ballester-Olmos & M. Guasp",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/Ballester-Guasp.html",create:()=>({about:"observer",assess:async o=>{const{BallesterGuaspAssessor:t}=await at(async()=>{const{BallesterGuaspAssessor:e}=await import("./BallesterGuaspAssessor-CLQvJKlm.js");return{BallesterGuaspAssessor:e}},__vite__mapDeps([4,3,5]),import.meta.url);return new t().assess(o)}})},{id:"poher",name:"Poher",credit:"Claude Poher",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/Poher-Criteres.html",create:()=>({about:"shape",assess:async o=>{const{PoherAssessor:t}=await at(async()=>{const{PoherAssessor:e}=await import("./PoherAssessor-DDRUgnRW.js");return{PoherAssessor:e}},[],import.meta.url);return new t().assess(o)}})}]);class Oy{constructor(t){this.labels=t}async read(t){const e=[],i=new Set;for(const n of f8){let s;try{s=await n.create().assess(t)}catch{continue}for(const a of s.criteria)a.basis===void 0&&!a.unsupported&&i.add(a.id);const r=s.score===void 0?s.verdict===void 0?"":this.verdictName(n.id,s.verdict):`${Math.round(s.score*100)}%`;r!==""&&e.push({group:"assessment",field:n.id,label:this.labels.assessmentNames[n.id]??n.name,value:r,unit:"",fromSource:!1,about:n.create().about,...s.factors?{detail:Oy.factorsText(s.factors)}:{}})}return{entries:e,unanswered:i}}static factorsText(t){const e={q:"Q",sigma:"Σ",pi:"Π"};return Object.entries(t).map(([i,n])=>`${e[i]??i} ${n.toFixed(2)}`).join(" × ")}verdictName(t,e){return this.labels.assessmentVerdicts[`${t}.${e}`]??e.toUpperCase()}}class _h{static HALF_SPAN_MS=2e3;static MIN_SPEED_MS=1;static at(t,e,i){const n=t.event.place?.[0],s=t.observerTrack;if(!n)return 0;const r=m=>{const g=s.getInterpolatedPoseAt(Math.max(0,m));if(!g||g.lat===void 0||g.lng===void 0)return;const v=re(g.lat,g.lng,n.lat,n.lng);return{eastM:v.x,northM:-v.z,heading:g.headingDeg}},a=r(e-_h.HALF_SPAN_MS),c=r(e+_h.HALF_SPAN_MS),l=r(e);if(!a||!c||!l)return 0;const h=Math.hypot(c.eastM-a.eastM,c.northM-a.northM),u=2*_h.HALF_SPAN_MS/1e3;if(h/u<_h.MIN_SPEED_MS)return 0;const d=i.heightAt(c.eastM,c.northM)-i.heightAt(a.eastM,a.northM),f=Math.atan2(d,h)*180/Math.PI;if(l.heading===void 0)return f;const p=Math.atan2(c.eastM-a.eastM,c.northM-a.northM)*180/Math.PI;return f*Math.max(0,Math.cos((l.heading-p)*Math.PI/180))}}class lr{static sessionDeclared=!1;static isLive(t){return t!==void 0&&typeof AudioContext<"u"&&t instanceof AudioContext}static unlock(t){if(lr.declarePlayback(),t.state!=="running")try{Promise.resolve(t.resume()).catch(()=>{});const e=t.createBufferSource();e.buffer=t.createBuffer(1,1,22050),e.connect(t.destination),e.start(0)}catch{}}static declarePlayback(){if(!(lr.sessionDeclared||typeof navigator>"u")){lr.sessionDeclared=!0;try{const t=navigator.audioSession;t&&(t.type="playback")}catch{}}}}const p8=.08,Yx=.15,Kx=2,m8=2e3;class qx{context;constructor(t){this.context=t}noiseBuffer;voices=new Map;level=1;master;paused=!0;requested=[];resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("VehicleAudio: Web Audio unavailable, vehicles stay silent:",t);return}}lr.isLive(this.context)&&lr.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t){this.requested=t,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);lr.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0}masterOf(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested.filter(n=>n.inside||n.distanceM<m8),i=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])i.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n.id);this.retarget(t,s,n)}}build(t,e){const i=t.createGain();i.gain.value=0;const n=t.createBiquadFilter();n.type="lowpass",n.connect(i).connect(this.masterOf(t));const s=t.createOscillator();s.type="sawtooth";const r=t.createOscillator();r.type="sine";const a=t.createGain(),c=t.createBiquadFilter();c.type="lowpass",c.frequency.value=900,s.connect(c),r.connect(c),c.connect(a).connect(n);const l=()=>{const x=t.createBufferSource();return x.buffer=this.noise(t),x.loop=!0,x.loopStart=Math.random()*Kx*.5,x},h=l(),u=t.createBiquadFilter();u.type="bandpass",u.Q.value=4;const d=t.createGain();h.connect(u).connect(d).connect(n);const f=l(),p=t.createBiquadFilter();p.type="lowpass",p.frequency.value=600;const m=t.createGain();f.connect(p).connect(m).connect(n);const g=l(),v=t.createBiquadFilter();v.type="bandpass",v.frequency.value=1400,v.Q.value=.7;const M=t.createGain();g.connect(v).connect(M).connect(n);const w=[s,r,h,f,g];for(const x of w)x.start();const y={nodes:[i,n,a,c,u,d,p,m,v,M,...w],sources:w,firing:s,crank:r,knock:u,engineGain:a,knockGain:d,roadGain:m,windGain:M,cabin:n,output:i};return this.voices.set(e,y),y}retarget(t,e,{profile:i,state:n,noise:s,inside:r,windowsOpen:a,distanceM:c}){const l=t.currentTime,h=(M,w)=>M.setTargetAtTime(w,l,p8),u=n.rpm/60,d=u*i.cylinders/2,f=Math.min(1,n.rpm/i.shiftUpRpm),p=Math.min(1.5,n.speedMps/30);h(e.firing.frequency,d),h(e.crank.frequency,u),h(e.knock.frequency,d*3),h(e.engineGain.gain,i.engineGain*(.25+.75*n.load)*(.5+.5*f)*.3),h(e.knockGain.gain,i.roughness*(.2+.8*n.load)*.4),h(e.roadGain.gain,i.roadGain*p**1.5*.8);const m=!r||a;h(e.windGain.gain,p**2*(m?.5:.06));const g=r?a?3500:700:8e3/(1+c/60);h(e.cabin.frequency,g);const v=r?.5:Math.min(1,8/Math.max(c,1));h(e.output.gain,v*s)}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const i=this.context;i&&(e.output.gain.setTargetAtTime(0,i.currentTime,Yx/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},Yx*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*Kx,t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class mf{static BY_KIND={car:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},generic:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},van:{cylinders:4,idleRpm:750,kmhPer1000Rpm:[7,12,19,27,35,42],shiftUpRpm:2600,shiftDownRpm:1200,engineGain:.8,roadGain:.7,roughness:.45},truck:{cylinders:6,idleRpm:600,kmhPer1000Rpm:[5,8,12,17,23,30,38,48],shiftUpRpm:1900,shiftDownRpm:1e3,engineGain:1,roadGain:.9,roughness:.55},motorcycle:{cylinders:2,idleRpm:1100,kmhPer1000Rpm:[12,18,24,30,35,40],shiftUpRpm:6e3,shiftDownRpm:2500,engineGain:.9,roadGain:.3,roughness:.3}};static of(t){return mf.BY_KIND[t??"generic"]??mf.BY_KIND.generic}}class Jn{static ROAD_KINDS=["car","van","truck","motorcycle","generic"];static OPEN_AIR=[0,0,0,0,0,0,0,0];static ROAD_CLOSED_DB=[10,14,18,22,25,28,30,32];static WINDOWS_OPEN_DB=[2,3,4,5,6,7,8,9];static FUSELAGE_DB=[14,18,23,28,32,36,38,40];static CANOPY_DB=[3,4,6,8,10,12,14,16];static CANOPIED=["glider","balloon","ultralight"];static isRoad(t){return Jn.ROAD_KINDS.includes(t)}static roadOf(t){return t&&Jn.isRoad(t.kind)?t.kind:void 0}static aircraftOf(t){return t&&!Jn.isRoad(t.kind)?t.kind:void 0}static transmission(t){const e=Jn.insulationDb(t),i=[3,4,5].map(n=>e[n]);return 10**(-(i.reduce((n,s)=>n+s,0)/i.length)/20)}static insulationDb(t){return t?t.windowsOpen===!0?Jn.WINDOWS_OPEN_DB:Jn.isRoad(t.kind)?Jn.ROAD_CLOSED_DB:Jn.CANOPIED.includes(t.kind)?Jn.CANOPY_DB:Jn.FUSELAGE_DB:Jn.OPEN_AIR}}class il{constructor(t,e){this.samples=t,this.startMs=e}static SAMPLE_MS=100;static STANDING_MPS=.3;static of(t,e,i,n){const s=il.SAMPLE_MS,r=[];for(let l=i;l<=n+s/2;l+=s){const h=e(l-s/2),u=e(l+s/2);if(!h||!u)return;r.push(Math.hypot(u.eastM-h.eastM,u.northM-h.northM)/(s/1e3))}const a=[];let c=1;for(let l=0;l<r.length;l++){const h=r[l],u=(r[Math.min(l+1,r.length-1)]-r[Math.max(l-1,0)])/(2*s/1e3);if(h<il.STANDING_MPS){c=1,a.push({speedMps:h,rpm:t.idleRpm,load:.1,gear:0});continue}const d=h*3.6,f=v=>d/t.kmhPer1000Rpm[v-1]*1e3;for(;c<t.kmhPer1000Rpm.length&&f(c)>t.shiftUpRpm;)c++;for(;c>1&&f(c)<t.shiftDownRpm;)c--;const p=Math.max(f(c),t.idleRpm*(1+.3*Math.min(1,h/3))),m=.15+.5*Math.min(1,(h/35)**2),g=u>.15?Math.min(1,m+u/2.5):u<-.3?.05:m;a.push({speedMps:h,rpm:p,load:g,gear:c})}return new il(a,i)}at(t){const e=(t-this.startMs)/il.SAMPLE_MS,i=Math.min(Math.max(Math.floor(e),0),this.samples.length-1),n=this.samples[i],s=this.samples[Math.min(i+1,this.samples.length-1)],r=Math.min(Math.max(e-i,0),1);return{speedMps:n.speedMps+(s.speedMps-n.speedMps)*r,rpm:n.rpm+(s.rpm-n.rpm)*r,load:n.load+(s.load-n.load)*r,gear:r<.5?n.gear:s.gear}}}class j0{drives=new Map;at(t,e){const i=[],n=t.event.place?.[0],s=h=>{const u=t.observerTrack.getInterpolatedPoseAt(h),d=u?.lat??n?.lat,f=u?.lng??n?.lng;if(d===void 0||f===void 0||!n)return;const p=re(d,f,n.lat,n.lng);return{eastM:p.x,northM:-p.z}},r=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),a=t.vehicle,c=Jn.roadOf(a);if(a&&c){const h=mf.of(c),u=this.drive(`observer:${c}`,j0.trackKey(t),()=>il.of(h,s,0,r));u&&i.push({id:"observer",profile:h,state:u.at(e),noise:a.noise??1,inside:!0,windowsOpen:a.windowsOpen===!0,distanceM:0})}const l=s(e);for(const h of t.decor){if(!h.engine||!l)continue;const u=mf.of(h.engine.kind),d=g=>{const v=Xr(h,g);return{eastM:v.eastM,northM:v.northM}},f=this.drive(`decor:${h.id}`,j0.decorKey(h,r),()=>il.of(u,d,0,r));if(!f)continue;const p=Xr(h,e),m=Math.hypot(p.eastM-l.eastM,p.northM-l.northM,p.altitudeM);i.push({id:`decor:${h.id}`,profile:u,state:f.at(e),noise:h.engine.noise??1,inside:!1,windowsOpen:!0,distanceM:m})}return i}drive(t,e,i){const n=this.drives.get(t);if(n&&n.key===e)return n.drive;const s=i();return this.drives.set(t,{key:e,drive:s}),s}static trackKey(t){return t.observerTrack.allKeyframes.map(i=>`${i.t}:${i.pose.lat}:${i.pose.lng}`).join(";")}static decorKey(t,e){return`${e}|${t.eastM},${t.northM}|`+(t.track??[]).map(i=>`${i.t}:${i.eastM}:${i.northM}`).join(";")}}const Zx=864e5,Jx=4e4;function g8(o){const t=Math.floor(o.getTime()/Zx);return{elapsedMs:o.getTime()-t*Zx,shiftM:{x:jx.unit(t,2654435761)*Jx,z:jx.unit(t,2246822507)*Jx}}}class jx{static unit(t,e){let i=Math.imul(t|0,e)^e;return i=Math.imul(i^i>>>15,739982445),i=Math.imul(i^i>>>12,695872825),i^=i>>>15,(i>>>0)/4294967295*2-1}}function Qx(o,t,e,i,n,s,r){const a=i?.lat!==void 0&&i.lng!==void 0&&n?.lat!==void 0&&n.lng!==void 0?re(n.lat,n.lng,i.lat,i.lng):{x:0,z:0};if(r){const h=t.getInterpolatedWeatherAt(0)??e,u=s===void 0?void 0:h.cloudLayers?.find(p=>p.id===s),d=(u?.windDirectionDeg??h.windDirectionDeg)*Math.PI/180,f=(u?.windSpeed??h.windSpeed)*r.elapsedMs/1e3;a.x+=r.shiftM.x-Math.sin(d)*f,a.z+=r.shiftM.z+Math.cos(d)*f}const c=Math.max(0,o),l=[0,...t.allKeyframes.map(h=>h.t).filter(h=>h>0&&h<c),c];for(let h=1;h<l.length;h++){const u=l[h-1],d=l[h]-u;if(d===0)continue;const f=32;for(let p=0;p<=f;p++){const m=t.getInterpolatedWeatherAt(u+d*p/f)??e,g=s===void 0?void 0:m.cloudLayers?.find(y=>y.id===s),v=(g?.windDirectionDeg??m.windDirectionDeg)*Math.PI/180,M=p===0||p===f?1:p%2===0?2:4,w=(g?.windSpeed??m.windSpeed)*d/1e3/f/3*M;a.x-=Math.sin(v)*w,a.z+=Math.cos(v)*w}}return a}const v8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAARVBMVEX9sST/uyTfoCjNlSikfCqRcCx8Yy21hipTSi4TITEMHTEuMzBqWC3/wSRUX207SFj8/PyaoakmNUd5gYxBPy90fIfMz9RsB4kZAAACEUlEQVRo3u2XyXbDIAxFLeapjts6/f9PrQA3JymT25Cd3iY5xtYVIB6wLCQSiUQikUgk0nzBoVdFZ1xIpaTQbJnPACaNdYeskWwuAhaZoltnUemfnNkL4N49KEI8n0YAEXMvEWISAWQZPw2Xk1MIoF1dSNAzCMy6JsGyCR0wrkMwT3cBeDt+FH8aEHoA68LbM8HRHXQ3f0RE3/jXOOFX+s4djrKpIbzS7K+MmLrxlWCNR8mczjMw92Ar4dZLDXG4kzXinAECcOUPL3jMdN2294/GQGVG4EMHxORNJXoCfG6oT1trvDGM7iIA9N6aTOuuEbB9ra6FyCYr2gjge+fjA4CIi2uujYRoOBSw0A5/D0hT0X4PW0xtuotNpQPYtkt/fdtyM0LP6ZvOI2DtvoxtJWHvx38AxIkevLwXQ2TOA66DziYfLwC4r5wbIlwJo1ys8+VOBMy7/sxdjwIap49lVC3UePZp1mmyit4SuGUf11pjoTHVRVzXUaXFVt87kuEBsWZ055Q+2sXA76LbZYsvKR1ubvJqbKd5swl+GPI31p6L/sNYuDTe3jo+GBdr1J+P9PGawbRUw9VhleD/3ffT9uZ7DhtX1JNHL2CmNRXxYZhwSwBd3aJTyU85/GKOwhxBf5RnVk+75OSiuu+Ax4PQ3Jsg1hTeMUMwJgQp+PKCe2a+JuefFwQnkUgkEolEIpFerW8TL0hlNl2QVAAAAABJRU5ErkJggg==",M8=`
|
|
4894
|
+
}`;class ZP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new gA(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new De({vertexShader:KP,fragmentShader:qP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new vs(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class JP extends _c{constructor(t,e){super();const i=this;let n=null,s=1,r=null,a="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const m=typeof XRWebGLBinding<"u",g=new ZP,v={},M=e.getContextAttributes();let w=null,y=null;const x=[],b=[],E=new tt;let S=null;const A=new jn;A.viewport=new Ie;const _=new jn;_.viewport=new Ie;const I=[A,_],D=new $I;let O=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getTargetRaySpace()},this.getControllerGrip=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getGripSpace()},this.getHand=function(K){let lt=x[K];return lt===void 0&&(lt=new mg,x[K]=lt),lt.getHandSpace()};function N(K){const lt=b.indexOf(K.inputSource);if(lt===-1)return;const ct=x[lt];ct!==void 0&&(ct.update(K.inputSource,K.frame,l||r),ct.dispatchEvent({type:K.type,data:K.inputSource}))}function k(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",k),n.removeEventListener("inputsourceschange",B);for(let K=0;K<x.length;K++){const lt=b[K];lt!==null&&(b[K]=null,x[K].disconnect(lt))}O=null,P=null,g.reset();for(const K in v)delete v[K];t.setRenderTarget(w),f=null,d=null,u=null,n=null,y=null,jt.stop(),i.isPresenting=!1,t.setPixelRatio(S),t.setSize(E.width,E.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){s=K,i.isPresenting===!0&&Ht("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){a=K,i.isPresenting===!0&&Ht("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(K){if(n=K,n!==null){if(w=t.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",k),n.addEventListener("inputsourceschange",B),M.xrCompatible!==!0&&await e.makeXRCompatible(),S=t.getPixelRatio(),t.getSize(E),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let ct=null,V=null,Lt=null;M.depth&&(Lt=M.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ct=M.stencil?tl:So,V=M.stencil?cf:_r);const Xt={colorFormat:e.RGBA8,depthFormat:Lt,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Xt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new Qe(d.textureWidth,d.textureHeight,{format:tn,type:fs,depthTexture:new Sc(d.textureWidth,d.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,ct),stencilBuffer:M.stencil,colorSpace:t.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ct={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,ct),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Qe(f.framebufferWidth,f.framebufferHeight,{format:tn,type:fs,colorSpace:t.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(a),jt.setContext(n),jt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function B(K){for(let lt=0;lt<K.removed.length;lt++){const ct=K.removed[lt],V=b.indexOf(ct);V>=0&&(b[V]=null,x[V].disconnect(ct))}for(let lt=0;lt<K.added.length;lt++){const ct=K.added[lt];let V=b.indexOf(ct);if(V===-1){for(let Xt=0;Xt<x.length;Xt++)if(Xt>=b.length){b.push(ct),V=Xt;break}else if(b[Xt]===null){b[Xt]=ct,V=Xt;break}if(V===-1)break}const Lt=x[V];Lt&&Lt.connect(ct)}}const W=new T,Q=new T;function Z(K,lt,ct){W.setFromMatrixPosition(lt.matrixWorld),Q.setFromMatrixPosition(ct.matrixWorld);const V=W.distanceTo(Q),Lt=lt.projectionMatrix.elements,Xt=ct.projectionMatrix.elements,kt=Lt[14]/(Lt[10]-1),Rt=Lt[14]/(Lt[10]+1),te=(Lt[9]+1)/Lt[5],ne=(Lt[9]-1)/Lt[5],se=(Lt[8]-1)/Lt[0],ri=(Xt[8]+1)/Xt[0],ai=kt*se,$i=kt*ri,Gi=V/(-se+ri),Yi=Gi*-se;if(lt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Yi),K.translateZ(Gi),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Lt[10]===-1)K.projectionMatrix.copy(lt.projectionMatrix),K.projectionMatrixInverse.copy(lt.projectionMatrixInverse);else{const un=kt+Gi,z=Rt+Gi,Os=ai-Yi,oi=$i+(V-Yi),L=te*Rt/z*un,R=ne*Rt/z*un;K.projectionMatrix.makePerspective(Os,oi,L,R,un,z),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function nt(K,lt){lt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(lt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(n===null)return;let lt=K.near,ct=K.far;g.texture!==null&&(g.depthNear>0&&(lt=g.depthNear),g.depthFar>0&&(ct=g.depthFar)),D.near=_.near=A.near=lt,D.far=_.far=A.far=ct,(O!==D.near||P!==D.far)&&(n.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,P=D.far),D.layers.mask=K.layers.mask|6,A.layers.mask=D.layers.mask&-5,_.layers.mask=D.layers.mask&-3;const V=K.parent,Lt=D.cameras;nt(D,V);for(let Xt=0;Xt<Lt.length;Xt++)nt(Lt[Xt],V);Lt.length===2?Z(D,A,_):D.projectionMatrix.copy(A.projectionMatrix),ot(K,D,V)};function ot(K,lt,ct){ct===null?K.matrix.copy(lt.matrixWorld):(K.matrix.copy(ct.matrixWorld),K.matrix.invert(),K.matrix.multiply(lt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(lt.projectionMatrix),K.projectionMatrixInverse.copy(lt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=gu*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(D)},this.getCameraTexture=function(K){return v[K]};let Ut=null;function Zt(K,lt){if(h=lt.getViewerPose(l||r),p=lt,h!==null){const ct=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let V=!1;ct.length!==D.cameras.length&&(D.cameras.length=0,V=!0);for(let Rt=0;Rt<ct.length;Rt++){const te=ct[Rt];let ne=null;if(f!==null)ne=f.getViewport(te);else{const ri=u.getViewSubImage(d,te);ne=ri.viewport,Rt===0&&(t.setRenderTargetTextures(y,ri.colorTexture,ri.depthStencilTexture),t.setRenderTarget(y))}let se=I[Rt];se===void 0&&(se=new jn,se.layers.enable(Rt),se.viewport=new Ie,I[Rt]=se),se.matrix.fromArray(te.transform.matrix),se.matrix.decompose(se.position,se.quaternion,se.scale),se.projectionMatrix.fromArray(te.projectionMatrix),se.projectionMatrixInverse.copy(se.projectionMatrix).invert(),se.viewport.set(ne.x,ne.y,ne.width,ne.height),Rt===0&&(D.matrix.copy(se.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),V===!0&&D.cameras.push(se)}const Lt=n.enabledFeatures;if(Lt&&Lt.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&m){u=i.getBinding();const Rt=u.getDepthInformation(ct[0]);Rt&&Rt.isValid&&Rt.texture&&g.init(Rt,n.renderState)}if(Lt&&Lt.includes("camera-access")&&m){t.state.unbindTexture(),u=i.getBinding();for(let Rt=0;Rt<ct.length;Rt++){const te=ct[Rt].camera;if(te){let ne=v[te];ne||(ne=new gA,v[te]=ne);const se=u.getCameraImage(te);ne.sourceTexture=se}}}}for(let ct=0;ct<x.length;ct++){const V=b[ct],Lt=x[ct];V!==null&&Lt!==void 0&&Lt.update(V,lt,l||r)}Ut&&Ut(K,lt),lt.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:lt}),p=null}const jt=new PA;jt.setAnimationLoop(Zt),this.setAnimationLoop=function(K){Ut=K},this.dispose=function(){}}}const jP=new Gt,zA=new de;zA.set(-1,0,0,0,1,0,0,0,1);function QP(o,t){function e(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function i(g,v){v.color.getRGB(g.fogColor.value,AA(o)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function n(g,v,M,w,y){v.isNodeMaterial?v.uniformsNeedUpdate=!1:v.isMeshBasicMaterial?s(g,v):v.isMeshLambertMaterial?(s(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshToonMaterial?(s(g,v),u(g,v)):v.isMeshPhongMaterial?(s(g,v),h(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshStandardMaterial?(s(g,v),d(g,v),v.isMeshPhysicalMaterial&&f(g,v,y)):v.isMeshMatcapMaterial?(s(g,v),p(g,v)):v.isMeshDepthMaterial?s(g,v):v.isMeshDistanceMaterial?(s(g,v),m(g,v)):v.isMeshNormalMaterial?s(g,v):v.isLineBasicMaterial?(r(g,v),v.isLineDashedMaterial&&a(g,v)):v.isPointsMaterial?c(g,v,M,w):v.isSpriteMaterial?l(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,e(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,e(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===zi&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,e(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===zi&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,e(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,e(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,e(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);const M=t.get(v),w=M.envMap,y=M.envMapRotation;w&&(g.envMap.value=w,g.envMapRotation.value.setFromMatrix4(jP.makeRotationFromEuler(y)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(zA),g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap&&(g.lightMap.value=v.lightMap,g.lightMapIntensity.value=v.lightMapIntensity,e(v.lightMap,g.lightMapTransform)),v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,e(v.aoMap,g.aoMapTransform))}function r(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,e(v.map,g.mapTransform))}function a(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function c(g,v,M,w){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*M,g.scale.value=w*.5,v.map&&(g.map.value=v.map,e(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function l(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,e(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,e(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function h(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function u(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function d(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,e(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,e(v.roughnessMap,g.roughnessMapTransform)),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function f(g,v,M){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,e(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,e(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,e(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,e(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,e(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===zi&&g.clearcoatNormalScale.value.negate())),v.dispersion>0&&(g.dispersion.value=v.dispersion),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,e(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,e(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=M.texture,g.transmissionSamplerSize.value.set(M.width,M.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,e(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,e(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,e(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,e(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,e(v.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,v){v.matcap&&(g.matcap.value=v.matcap)}function m(g,v){const M=t.get(v).light;g.referencePosition.value.setFromMatrixPosition(M.matrixWorld),g.nearDistance.value=M.shadow.camera.near,g.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function t8(o,t,e,i){let n={},s={},r=[];const a=o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,x){const b=x.program;i.uniformBlockBinding(y,b)}function l(y,x){let b=n[y.id];b===void 0&&(g(y),b=h(y),n[y.id]=b,y.addEventListener("dispose",M));const E=x.program;i.updateUBOMapping(y,E);const S=t.render.frame;s[y.id]!==S&&(d(y),s[y.id]=S)}function h(y){const x=u();y.__bindingPointIndex=x;const b=o.createBuffer(),E=y.__size,S=y.usage;return o.bindBuffer(o.UNIFORM_BUFFER,b),o.bufferData(o.UNIFORM_BUFFER,E,S),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,x,b),b}function u(){for(let y=0;y<a;y++)if(r.indexOf(y)===-1)return r.push(y),y;return le("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=n[y.id],b=y.uniforms,E=y.__cache;o.bindBuffer(o.UNIFORM_BUFFER,x);for(let S=0,A=b.length;S<A;S++){const _=b[S];if(Array.isArray(_))for(let I=0,D=_.length;I<D;I++)f(_[I],S,I,E);else f(_,S,0,E)}o.bindBuffer(o.UNIFORM_BUFFER,null)}function f(y,x,b,E){if(m(y,x,b,E)===!0){const S=y.__offset,A=y.value;if(Array.isArray(A)){let _=0;for(let I=0;I<A.length;I++){const D=A[I],O=v(D);p(D,y.__data,_),typeof D!="number"&&typeof D!="boolean"&&!D.isMatrix3&&!ArrayBuffer.isView(D)&&(_+=O.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,y.__data,0);o.bufferSubData(o.UNIFORM_BUFFER,S,y.__data)}}function p(y,x,b){typeof y=="number"||typeof y=="boolean"?x[0]=y:y.isMatrix3?(x[0]=y.elements[0],x[1]=y.elements[1],x[2]=y.elements[2],x[3]=0,x[4]=y.elements[3],x[5]=y.elements[4],x[6]=y.elements[5],x[7]=0,x[8]=y.elements[6],x[9]=y.elements[7],x[10]=y.elements[8],x[11]=0):ArrayBuffer.isView(y)?x.set(new y.constructor(y.buffer,y.byteOffset,x.length)):y.toArray(x,b)}function m(y,x,b,E){const S=y.value,A=x+"_"+b;if(E[A]===void 0)return typeof S=="number"||typeof S=="boolean"?E[A]=S:ArrayBuffer.isView(S)?E[A]=S.slice():E[A]=S.clone(),!0;{const _=E[A];if(typeof S=="number"||typeof S=="boolean"){if(_!==S)return E[A]=S,!0}else{if(ArrayBuffer.isView(S))return!0;if(_.equals(S)===!1)return _.copy(S),!0}}return!1}function g(y){const x=y.uniforms;let b=0;const E=16;for(let A=0,_=x.length;A<_;A++){const I=Array.isArray(x[A])?x[A]:[x[A]];for(let D=0,O=I.length;D<O;D++){const P=I[D],N=Array.isArray(P.value)?P.value:[P.value];for(let k=0,B=N.length;k<B;k++){const W=N[k],Q=v(W),Z=b%E,nt=Z%Q.boundary,ot=Z+nt;b+=nt,ot!==0&&E-ot<Q.storage&&(b+=E-ot),P.__data=new Float32Array(Q.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=b,b+=Q.storage}}}const S=b%E;return S>0&&(b+=E-S),y.__size=b,y.__cache={},this}function v(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?Ht("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(x.boundary=16,x.storage=y.byteLength):Ht("WebGLRenderer: Unsupported uniform value type.",y),x}function M(y){const x=y.target;x.removeEventListener("dispose",M);const b=r.indexOf(x.__bindingPointIndex);r.splice(b,1),o.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function w(){for(const y in n)o.deleteBuffer(n[y]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const e8=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let ta=null;function i8(){return ta===null&&(ta=new Ds(e8,16,16,xl,Ye),ta.name="DFG_LUT",ta.minFilter=Me,ta.magFilter=Me,ta.wrapS=Qi,ta.wrapT=Qi,ta.generateMipmaps=!1,ta.needsUpdate=!0),ta}class n8{constructor(t={}){const{canvas:e=J4(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=fs}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const m=f,g=new Set([dy,uy,hy]),v=new Set([fs,_r,of,cf,cy,ly]),M=new Uint32Array(4),w=new Int32Array(4),y=new T;let x=null,b=null;const E=[],S=[];let A=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ka,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let I=!1,D=null,O=null,P=null,N=null;this._outputColorSpace=Bn;let k=0,B=0,W=null,Q=-1,Z=null;const nt=new Ie,ot=new Ie;let Ut=null;const Zt=new rt(0);let jt=0,K=e.width,lt=e.height,ct=1,V=null,Lt=null;const Xt=new Ie(0,0,K,lt),kt=new Ie(0,0,K,lt);let Rt=!1;const te=new Cm;let ne=!1,se=!1;const ri=new Gt,ai=new T,$i=new Ie,Gi={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Yi=!1;function un(){return W===null?ct:1}let z=i;function Os(C,H){return e.getContext(C,H)}try{const C={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_f}`),e.addEventListener("webglcontextlost",Ki,!1),e.addEventListener("webglcontextrestored",Ti,!1),e.addEventListener("webglcontextcreationerror",Zr,!1),z===null){const H="webgl2";if(z=Os(H,C),z===null)throw Os(H)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw le("WebGLRenderer: "+C.message),C}let oi,L,R,G,Y,J,ut,pt,j,it,gt,$t,xt,vt,Qt,ae,Ae,U,ft,et,Mt,At,st;function Wt(){oi=new iO(z),oi.init(),Mt=new YP(z,oi),L=new KC(z,oi,t,Mt),R=new XP(z,oi),L.reversedDepthBuffer&&d&&R.buffers.depth.setReversed(!0),O=z.createFramebuffer(),P=z.createFramebuffer(),N=z.createFramebuffer(),G=new rO(z),Y=new CP,J=new $P(z,oi,R,Y,L,Mt,G),ut=new eO(_),pt=new lD(z),At=new $C(z,pt),j=new nO(z,pt,G,At),it=new oO(z,j,pt,At,G),U=new aO(z,L,J),Qt=new qC(Y),gt=new DP(_,ut,oi,L,At,Qt),$t=new QP(_,Y),xt=new PP,vt=new zP(oi),Ae=new XC(_,ut,R,it,p,c),ae=new WP(_,it,L),st=new t8(z,G,L,R),ft=new YC(z,oi,G),et=new sO(z,oi,G),G.programs=gt.programs,_.capabilities=L,_.extensions=oi,_.properties=Y,_.renderLists=xt,_.shadowMap=ae,_.state=R,_.info=G}Wt(),m!==fs&&(A=new lO(m,e.width,e.height,a,n,s));const Ft=new JP(_,z);this.xr=Ft,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const C=oi.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=oi.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ct},this.setPixelRatio=function(C){C!==void 0&&(ct=C,this.setSize(K,lt,!1))},this.getSize=function(C){return C.set(K,lt)},this.setSize=function(C,H,q=!0){if(Ft.isPresenting){Ht("WebGLRenderer: Can't change size while VR device is presenting.");return}K=C,lt=H,e.width=Math.floor(C*ct),e.height=Math.floor(H*ct),q===!0&&(e.style.width=C+"px",e.style.height=H+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,C,H)},this.getDrawingBufferSize=function(C){return C.set(K*ct,lt*ct).floor()},this.setDrawingBufferSize=function(C,H,q){K=C,lt=H,ct=q,e.width=Math.floor(C*q),e.height=Math.floor(H*q),this.setViewport(0,0,C,H)},this.setEffects=function(C){if(m===fs){le("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let H=0;H<C.length;H++)if(C[H].isOutputPass===!0){Ht("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(C||[])},this.getCurrentViewport=function(C){return C.copy(nt)},this.getViewport=function(C){return C.copy(Xt)},this.setViewport=function(C,H,q,X){C.isVector4?Xt.set(C.x,C.y,C.z,C.w):Xt.set(C,H,q,X),R.viewport(nt.copy(Xt).multiplyScalar(ct).round())},this.getScissor=function(C){return C.copy(kt)},this.setScissor=function(C,H,q,X){C.isVector4?kt.set(C.x,C.y,C.z,C.w):kt.set(C,H,q,X),R.scissor(ot.copy(kt).multiplyScalar(ct).round())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(C){R.setScissorTest(Rt=C)},this.setOpaqueSort=function(C){V=C},this.setTransparentSort=function(C){Lt=C},this.getClearColor=function(C){return C.copy(Ae.getClearColor())},this.setClearColor=function(){Ae.setClearColor(...arguments)},this.getClearAlpha=function(){return Ae.getClearAlpha()},this.setClearAlpha=function(){Ae.setClearAlpha(...arguments)},this.clear=function(C=!0,H=!0,q=!0){let X=0;if(C){let $=!1;if(W!==null){const Et=W.texture.format;$=g.has(Et)}if($){const Et=W.texture.type,It=v.has(Et),St=Ae.getClearColor(),zt=Ae.getClearAlpha(),Yt=St.r,_e=St.g,Ce=St.b;It?(M[0]=Yt,M[1]=_e,M[2]=Ce,M[3]=zt,z.clearBufferuiv(z.COLOR,0,M)):(w[0]=Yt,w[1]=_e,w[2]=Ce,w[3]=zt,z.clearBufferiv(z.COLOR,0,w))}else X|=z.COLOR_BUFFER_BIT}H&&(X|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(X|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),X!==0&&z.clear(X)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(C){C.setRenderer(this),D=C},this.dispose=function(){e.removeEventListener("webglcontextlost",Ki,!1),e.removeEventListener("webglcontextrestored",Ti,!1),e.removeEventListener("webglcontextcreationerror",Zr,!1),Ae.dispose(),xt.dispose(),vt.dispose(),Y.dispose(),ut.dispose(),it.dispose(),At.dispose(),st.dispose(),gt.dispose(),Ft.dispose(),Ft.removeEventListener("sessionstart",qy),Ft.removeEventListener("sessionend",Zy),Rc.stop()};function Ki(C){C.preventDefault(),X0("WebGLRenderer: Context Lost."),I=!0}function Ti(){X0("WebGLRenderer: Context Restored."),I=!1;const C=G.autoReset,H=ae.enabled,q=ae.autoUpdate,X=ae.needsUpdate,$=ae.type;Wt(),G.autoReset=C,ae.enabled=H,ae.autoUpdate=q,ae.needsUpdate=X,ae.type=$}function Zr(C){le("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Jr(C){const H=C.target;H.removeEventListener("dispose",Jr),B3(H)}function B3(C){H3(C),Y.remove(C)}function H3(C){const H=Y.get(C).programs;H!==void 0&&(H.forEach(function(q){gt.releaseProgram(q)}),C.isShaderMaterial&>.releaseShaderCache(C))}this.renderBufferDirect=function(C,H,q,X,$,Et){H===null&&(H=Gi);const It=$.isMesh&&$.matrixWorld.determinantAffine()<0,St=W3(C,H,q,X,$);R.setMaterial(X,It);let zt=q.index,Yt=1;if(X.wireframe===!0){if(zt=j.getWireframeAttribute(q),zt===void 0)return;Yt=2}const _e=q.drawRange,Ce=q.attributes.position;let qt=_e.start*Yt,gi=(_e.start+_e.count)*Yt;Et!==null&&(qt=Math.max(qt,Et.start*Yt),gi=Math.min(gi,(Et.start+Et.count)*Yt)),zt!==null?(qt=Math.max(qt,0),gi=Math.min(gi,zt.count)):Ce!=null&&(qt=Math.max(qt,0),gi=Math.min(gi,Ce.count));const nn=gi-qt;if(nn<0||nn===1/0)return;At.setup($,X,St,q,zt);let qi,wi=ft;if(zt!==null&&(qi=pt.get(zt),wi=et,wi.setIndex(qi)),$.isMesh)X.wireframe===!0?(R.setLineWidth(X.wireframeLinewidth*un()),wi.setMode(z.LINES)):wi.setMode(z.TRIANGLES);else if($.isLine){let is=X.linewidth;is===void 0&&(is=1),R.setLineWidth(is*un()),$.isLineSegments?wi.setMode(z.LINES):$.isLineLoop?wi.setMode(z.LINE_LOOP):wi.setMode(z.LINE_STRIP)}else $.isPoints?wi.setMode(z.POINTS):$.isSprite&&wi.setMode(z.TRIANGLES);if($.isBatchedMesh)if(oi.get("WEBGL_multi_draw"))wi.renderMultiDraw($._multiDrawStarts,$._multiDrawCounts,$._multiDrawCount);else{const is=$._multiDrawStarts,Tt=$._multiDrawCounts,Zs=$._multiDrawCount,Xe=zt?pt.get(zt).bytesPerElement:1,dr=Y.get(X).currentProgram.getUniforms();for(let jr=0;jr<Zs;jr++)dr.setValue(z,"_gl_DrawID",jr),wi.render(is[jr]/Xe,Tt[jr])}else if($.isInstancedMesh)wi.renderInstances(qt,nn,$.count);else if(q.isInstancedBufferGeometry){const is=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Tt=Math.min(q.instanceCount,is);wi.renderInstances(qt,nn,Tt)}else wi.render(qt,nn)};function Ky(C,H,q){C.transparent===!0&&C.side===Tn&&C.forceSinglePass===!1?(C.side=zi,C.needsUpdate=!0,Df(C,H,q),C.side=Ba,C.needsUpdate=!0,Df(C,H,q),C.side=Tn):Df(C,H,q)}this.compile=function(C,H,q=null){q===null&&(q=C),b=vt.get(q),b.init(H),S.push(b),q.traverseVisible(function($){$.isLight&&$.layers.test(H.layers)&&(b.pushLight($),$.castShadow&&b.pushShadow($))}),C!==q&&C.traverseVisible(function($){$.isLight&&$.layers.test(H.layers)&&(b.pushLight($),$.castShadow&&b.pushShadow($))}),b.setupLights();const X=new Set;return C.traverse(function($){if(!($.isMesh||$.isPoints||$.isLine||$.isSprite))return;const Et=$.material;if(Et)if(Array.isArray(Et))for(let It=0;It<Et.length;It++){const St=Et[It];Ky(St,q,$),X.add(St)}else Ky(Et,q,$),X.add(Et)}),b=S.pop(),X},this.compileAsync=function(C,H,q=null){const X=this.compile(C,H,q);return new Promise($=>{function Et(){if(X.forEach(function(It){Y.get(It).currentProgram.isReady()&&X.delete(It)}),X.size===0){$(C);return}setTimeout(Et,10)}oi.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let Gm=null;function G3(C){Gm&&Gm(C)}function qy(){Rc.stop()}function Zy(){Rc.start()}const Rc=new PA;Rc.setAnimationLoop(G3),typeof self<"u"&&Rc.setContext(self),this.setAnimationLoop=function(C){Gm=C,Ft.setAnimationLoop(C),C===null?Rc.stop():Rc.start()},Ft.addEventListener("sessionstart",qy),Ft.addEventListener("sessionend",Zy),this.render=function(C,H){if(H!==void 0&&H.isCamera!==!0){le("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;D!==null&&D.renderStart(C,H);const q=Ft.enabled===!0&&Ft.isPresenting===!0,X=A!==null&&(W===null||q)&&A.begin(_,W);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Ft.enabled===!0&&Ft.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Ft.cameraAutoUpdate===!0&&Ft.updateCamera(H),H=Ft.getCamera()),C.isScene===!0&&C.onBeforeRender(_,C,H,W),b=vt.get(C,S.length),b.init(H),b.state.textureUnits=J.getTextureUnits(),S.push(b),ri.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),te.setFromProjectionMatrix(ri,Ca,H.reversedDepth),se=this.localClippingEnabled,ne=Qt.init(this.clippingPlanes,se),x=xt.get(C,E.length),x.init(),E.push(x),Ft.enabled===!0&&Ft.isPresenting===!0){const It=_.xr.getDepthSensingMesh();It!==null&&Vm(It,H,-1/0,_.sortObjects)}Vm(C,H,0,_.sortObjects),x.finish(),_.sortObjects===!0&&x.sort(V,Lt,H.reversedDepth),Yi=Ft.enabled===!1||Ft.isPresenting===!1||Ft.hasDepthSensing()===!1,Yi&&Ae.addToRenderList(x,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ne===!0&&Qt.beginShadows();const $=b.state.shadowsArray;if(ae.render($,C,H),ne===!0&&Qt.endShadows(),(X&&A.hasRenderPass())===!1){const It=x.opaque,St=x.transmissive;if(b.setupLights(),H.isArrayCamera){const zt=H.cameras;if(St.length>0)for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt];jy(It,St,C,Ce)}Yi&&Ae.render(C);for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt];Jy(x,C,Ce,Ce.viewport)}}else St.length>0&&jy(It,St,C,H),Yi&&Ae.render(C),Jy(x,C,H)}W!==null&&B===0&&(J.updateMultisampleRenderTarget(W),J.updateRenderTargetMipmap(W)),X&&A.end(_),C.isScene===!0&&C.onAfterRender(_,C,H),At.resetDefaultState(),Q=-1,Z=null,S.pop(),S.length>0?(b=S[S.length-1],J.setTextureUnits(b.state.textureUnits),ne===!0&&Qt.setGlobalState(_.clippingPlanes,b.state.camera)):b=null,E.pop(),E.length>0?x=E[E.length-1]:x=null,D!==null&&D.renderEnd()};function Vm(C,H,q,X){if(C.visible===!1)return;if(C.layers.test(H.layers)){if(C.isGroup)q=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(H);else if(C.isLightProbeGrid)b.pushLightProbeGrid(C);else if(C.isLight)b.pushLight(C),C.castShadow&&b.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||te.intersectsSprite(C)){X&&$i.setFromMatrixPosition(C.matrixWorld).applyMatrix4(ri);const It=it.update(C),St=C.material;St.visible&&x.push(C,It,St,q,$i.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||te.intersectsObject(C))){const It=it.update(C),St=C.material;if(X&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),$i.copy(C.boundingSphere.center)):(It.boundingSphere===null&&It.computeBoundingSphere(),$i.copy(It.boundingSphere.center)),$i.applyMatrix4(C.matrixWorld).applyMatrix4(ri)),Array.isArray(St)){const zt=It.groups;for(let Yt=0,_e=zt.length;Yt<_e;Yt++){const Ce=zt[Yt],qt=St[Ce.materialIndex];qt&&qt.visible&&x.push(C,It,qt,q,$i.z,Ce)}}else St.visible&&x.push(C,It,St,q,$i.z,null)}}const Et=C.children;for(let It=0,St=Et.length;It<St;It++)Vm(Et[It],H,q,X)}function Jy(C,H,q,X){const{opaque:$,transmissive:Et,transparent:It}=C;b.setupLightsView(q),ne===!0&&Qt.setGlobalState(_.clippingPlanes,q),X&&R.viewport(nt.copy(X)),$.length>0&&If($,H,q),Et.length>0&&If(Et,H,q),It.length>0&&If(It,H,q),R.buffers.depth.setTest(!0),R.buffers.depth.setMask(!0),R.buffers.color.setMask(!0),R.setPolygonOffset(!1)}function jy(C,H,q,X){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[X.id]===void 0){const qt=oi.has("EXT_color_buffer_half_float")||oi.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[X.id]=new Qe(1,1,{generateMipmaps:!0,type:qt?Ye:fs,minFilter:cr,samples:Math.max(4,L.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:He.workingColorSpace})}const Et=b.state.transmissionRenderTarget[X.id],It=X.viewport||nt;Et.setSize(It.z*_.transmissionResolutionScale,It.w*_.transmissionResolutionScale);const St=_.getRenderTarget(),zt=_.getActiveCubeFace(),Yt=_.getActiveMipmapLevel();_.setRenderTarget(Et),_.getClearColor(Zt),jt=_.getClearAlpha(),jt<1&&_.setClearColor(16777215,.5),_.clear(),Yi&&Ae.render(q);const _e=_.toneMapping;_.toneMapping=ka;const Ce=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),b.setupLightsView(X),ne===!0&&Qt.setGlobalState(_.clippingPlanes,X),If(C,q,X),J.updateMultisampleRenderTarget(Et),J.updateRenderTargetMipmap(Et),oi.has("WEBGL_multisampled_render_to_texture")===!1){let qt=!1;for(let gi=0,nn=H.length;gi<nn;gi++){const qi=H[gi],{object:wi,geometry:is,material:Tt,group:Zs}=qi;if(Tt.side===Tn&&wi.layers.test(X.layers)){const Xe=Tt.side;Tt.side=zi,Tt.needsUpdate=!0,Qy(wi,q,X,is,Tt,Zs),Tt.side=Xe,Tt.needsUpdate=!0,qt=!0}}qt===!0&&(J.updateMultisampleRenderTarget(Et),J.updateRenderTargetMipmap(Et))}_.setRenderTarget(St,zt,Yt),_.setClearColor(Zt,jt),Ce!==void 0&&(X.viewport=Ce),_.toneMapping=_e}function If(C,H,q){const X=H.isScene===!0?H.overrideMaterial:null;for(let $=0,Et=C.length;$<Et;$++){const It=C[$],{object:St,geometry:zt,group:Yt}=It;let _e=It.material;_e.allowOverride===!0&&X!==null&&(_e=X),St.layers.test(q.layers)&&Qy(St,H,q,zt,_e,Yt)}}function Qy(C,H,q,X,$,Et){C.onBeforeRender(_,H,q,X,$,Et),C.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),$.onBeforeRender(_,H,q,X,C,Et),$.transparent===!0&&$.side===Tn&&$.forceSinglePass===!1?($.side=zi,$.needsUpdate=!0,_.renderBufferDirect(q,H,X,$,C,Et),$.side=Ba,$.needsUpdate=!0,_.renderBufferDirect(q,H,X,$,C,Et),$.side=Tn):_.renderBufferDirect(q,H,X,$,C,Et),C.onAfterRender(_,H,q,X,$,Et)}function Df(C,H,q){H.isScene!==!0&&(H=Gi);const X=Y.get(C),$=b.state.lights,Et=b.state.shadowsArray,It=$.state.version,St=gt.getParameters(C,$.state,Et,H,q,b.state.lightProbeGridArray),zt=gt.getProgramCacheKey(St);let Yt=X.programs;X.environment=C.isMeshStandardMaterial||C.isMeshLambertMaterial||C.isMeshPhongMaterial?H.environment:null,X.fog=H.fog;const _e=C.isMeshStandardMaterial||C.isMeshLambertMaterial&&!C.envMap||C.isMeshPhongMaterial&&!C.envMap;X.envMap=ut.get(C.envMap||X.environment,_e),X.envMapRotation=X.environment!==null&&C.envMap===null?H.environmentRotation:C.envMapRotation,Yt===void 0&&(C.addEventListener("dispose",Jr),Yt=new Map,X.programs=Yt);let Ce=Yt.get(zt);if(Ce!==void 0){if(X.currentProgram===Ce&&X.lightsStateVersion===It)return e2(C,St),Ce}else St.uniforms=gt.getUniforms(C),D!==null&&C.isNodeMaterial&&D.build(C,q,St),C.onBeforeCompile(St,_),Ce=gt.acquireProgram(St,zt),Yt.set(zt,Ce),X.uniforms=St.uniforms;const qt=X.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(qt.clippingPlanes=Qt.uniform),e2(C,St),X.needsLights=$3(C),X.lightsStateVersion=It,X.needsLights&&(qt.ambientLightColor.value=$.state.ambient,qt.lightProbe.value=$.state.probe,qt.directionalLights.value=$.state.directional,qt.directionalLightShadows.value=$.state.directionalShadow,qt.spotLights.value=$.state.spot,qt.spotLightShadows.value=$.state.spotShadow,qt.rectAreaLights.value=$.state.rectArea,qt.ltc_1.value=$.state.rectAreaLTC1,qt.ltc_2.value=$.state.rectAreaLTC2,qt.pointLights.value=$.state.point,qt.pointLightShadows.value=$.state.pointShadow,qt.hemisphereLights.value=$.state.hemi,qt.directionalShadowMatrix.value=$.state.directionalShadowMatrix,qt.spotLightMatrix.value=$.state.spotLightMatrix,qt.spotLightMap.value=$.state.spotLightMap,qt.pointShadowMatrix.value=$.state.pointShadowMatrix),X.lightProbeGrid=b.state.lightProbeGridArray.length>0,X.currentProgram=Ce,X.uniformsList=null,Ce}function t2(C){if(C.uniformsList===null){const H=C.currentProgram.getUniforms();C.uniformsList=h0.seqWithValue(H.seq,C.uniforms)}return C.uniformsList}function e2(C,H){const q=Y.get(C);q.outputColorSpace=H.outputColorSpace,q.batching=H.batching,q.batchingColor=H.batchingColor,q.instancing=H.instancing,q.instancingColor=H.instancingColor,q.instancingMorph=H.instancingMorph,q.skinning=H.skinning,q.morphTargets=H.morphTargets,q.morphNormals=H.morphNormals,q.morphColors=H.morphColors,q.morphTargetsCount=H.morphTargetsCount,q.numClippingPlanes=H.numClippingPlanes,q.numIntersection=H.numClipIntersection,q.vertexAlphas=H.vertexAlphas,q.vertexTangents=H.vertexTangents,q.toneMapping=H.toneMapping}function V3(C,H){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(H.matrixWorld);for(let q=0,X=C.length;q<X;q++){const $=C[q];if($.texture!==null&&$.boundingBox.containsPoint(y))return $}return null}function W3(C,H,q,X,$){H.isScene!==!0&&(H=Gi),J.resetTextureUnits();const Et=H.fog,It=X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial?H.environment:null,St=W===null?_.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:He.workingColorSpace,zt=X.isMeshStandardMaterial||X.isMeshLambertMaterial&&!X.envMap||X.isMeshPhongMaterial&&!X.envMap,Yt=ut.get(X.envMap||It,zt),_e=X.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Ce=!!q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),qt=!!q.morphAttributes.position,gi=!!q.morphAttributes.normal,nn=!!q.morphAttributes.color;let qi=ka;X.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(qi=_.toneMapping);const wi=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,is=wi!==void 0?wi.length:0,Tt=Y.get(X),Zs=b.state.lights;if(ne===!0&&(se===!0||C!==Z)){const Ri=C===Z&&X.id===Q;Qt.setState(X,C,Ri)}let Xe=!1;X.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==Zs.state.version||Tt.outputColorSpace!==St||$.isBatchedMesh&&Tt.batching===!1||!$.isBatchedMesh&&Tt.batching===!0||$.isBatchedMesh&&Tt.batchingColor===!0&&$.colorTexture===null||$.isBatchedMesh&&Tt.batchingColor===!1&&$.colorTexture!==null||$.isInstancedMesh&&Tt.instancing===!1||!$.isInstancedMesh&&Tt.instancing===!0||$.isSkinnedMesh&&Tt.skinning===!1||!$.isSkinnedMesh&&Tt.skinning===!0||$.isInstancedMesh&&Tt.instancingColor===!0&&$.instanceColor===null||$.isInstancedMesh&&Tt.instancingColor===!1&&$.instanceColor!==null||$.isInstancedMesh&&Tt.instancingMorph===!0&&$.morphTexture===null||$.isInstancedMesh&&Tt.instancingMorph===!1&&$.morphTexture!==null||Tt.envMap!==Yt||X.fog===!0&&Tt.fog!==Et||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==Qt.numPlanes||Tt.numIntersection!==Qt.numIntersection)||Tt.vertexAlphas!==_e||Tt.vertexTangents!==Ce||Tt.morphTargets!==qt||Tt.morphNormals!==gi||Tt.morphColors!==nn||Tt.toneMapping!==qi||Tt.morphTargetsCount!==is||!!Tt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Xe=!0):(Xe=!0,Tt.__version=X.version);let dr=Tt.currentProgram;Xe===!0&&(dr=Df(X,H,$),D&&X.isNodeMaterial&&D.onUpdateProgram(X,dr,Tt));let jr=!1,Ro=!1,Al=!1;const xi=dr.getUniforms(),sn=Tt.uniforms;if(R.useProgram(dr.program)&&(jr=!0,Ro=!0,Al=!0),X.id!==Q&&(Q=X.id,Ro=!0),Tt.needsLights){const Ri=V3(b.state.lightProbeGridArray,$);Tt.lightProbeGrid!==Ri&&(Tt.lightProbeGrid=Ri,Ro=!0)}if(jr||Z!==C){R.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),xi.setValue(z,"projectionMatrix",C.projectionMatrix),xi.setValue(z,"viewMatrix",C.matrixWorldInverse);const Do=xi.map.cameraPosition;Do!==void 0&&Do.setValue(z,ai.setFromMatrixPosition(C.matrixWorld)),L.logarithmicDepthBuffer&&xi.setValue(z,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&xi.setValue(z,"isOrthographic",C.isOrthographicCamera===!0),Z!==C&&(Z=C,Ro=!0,Al=!0)}if(Tt.needsLights&&(Zs.state.directionalShadowMap.length>0&&xi.setValue(z,"directionalShadowMap",Zs.state.directionalShadowMap,J),Zs.state.spotShadowMap.length>0&&xi.setValue(z,"spotShadowMap",Zs.state.spotShadowMap,J),Zs.state.pointShadowMap.length>0&&xi.setValue(z,"pointShadowMap",Zs.state.pointShadowMap,J)),$.isSkinnedMesh){xi.setOptional(z,$,"bindMatrix"),xi.setOptional(z,$,"bindMatrixInverse");const Ri=$.skeleton;Ri&&(Ri.boneTexture===null&&Ri.computeBoneTexture(),xi.setValue(z,"boneTexture",Ri.boneTexture,J))}$.isBatchedMesh&&(xi.setOptional(z,$,"batchingTexture"),xi.setValue(z,"batchingTexture",$._matricesTexture,J),xi.setOptional(z,$,"batchingIdTexture"),xi.setValue(z,"batchingIdTexture",$._indirectTexture,J),xi.setOptional(z,$,"batchingColorTexture"),$._colorsTexture!==null&&xi.setValue(z,"batchingColorTexture",$._colorsTexture,J));const Io=q.morphAttributes;if((Io.position!==void 0||Io.normal!==void 0||Io.color!==void 0)&&U.update($,q,dr),(Ro||Tt.receiveShadow!==$.receiveShadow)&&(Tt.receiveShadow=$.receiveShadow,xi.setValue(z,"receiveShadow",$.receiveShadow)),(X.isMeshStandardMaterial||X.isMeshLambertMaterial||X.isMeshPhongMaterial)&&X.envMap===null&&H.environment!==null&&(sn.envMapIntensity.value=H.environmentIntensity),sn.dfgLUT!==void 0&&(sn.dfgLUT.value=i8()),Ro){if(xi.setValue(z,"toneMappingExposure",_.toneMappingExposure),Tt.needsLights&&X3(sn,Al),Et&&X.fog===!0&&$t.refreshFogUniforms(sn,Et),$t.refreshMaterialUniforms(sn,X,ct,lt,b.state.transmissionRenderTarget[C.id]),Tt.needsLights&&Tt.lightProbeGrid){const Ri=Tt.lightProbeGrid;sn.probesSH.value=Ri.texture,sn.probesMin.value.copy(Ri.boundingBox.min),sn.probesMax.value.copy(Ri.boundingBox.max),sn.probesResolution.value.copy(Ri.resolution)}h0.upload(z,t2(Tt),sn,J)}if(X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(h0.upload(z,t2(Tt),sn,J),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&xi.setValue(z,"center",$.center),xi.setValue(z,"modelViewMatrix",$.modelViewMatrix),xi.setValue(z,"normalMatrix",$.normalMatrix),xi.setValue(z,"modelMatrix",$.matrixWorld),X.uniformsGroups!==void 0){const Ri=X.uniformsGroups;for(let Do=0,_l=Ri.length;Do<_l;Do++){const i2=Ri[Do];st.update(i2,dr),st.bind(i2,dr)}}return dr}function X3(C,H){C.ambientLightColor.needsUpdate=H,C.lightProbe.needsUpdate=H,C.directionalLights.needsUpdate=H,C.directionalLightShadows.needsUpdate=H,C.pointLights.needsUpdate=H,C.pointLightShadows.needsUpdate=H,C.spotLights.needsUpdate=H,C.spotLightShadows.needsUpdate=H,C.rectAreaLights.needsUpdate=H,C.hemisphereLights.needsUpdate=H}function $3(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return W},this.setRenderTargetTextures=function(C,H,q){const X=Y.get(C);X.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1&&(X.__useRenderToTexture=!1),Y.get(C.texture).__webglTexture=H,Y.get(C.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:q,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,H){const q=Y.get(C);q.__webglFramebuffer=H,q.__useDefaultFramebuffer=H===void 0},this.setRenderTarget=function(C,H=0,q=0){W=C,k=H,B=q;let X=null,$=!1,Et=!1;if(C){const St=Y.get(C);if(St.__useDefaultFramebuffer!==void 0){R.bindFramebuffer(z.FRAMEBUFFER,St.__webglFramebuffer),nt.copy(C.viewport),ot.copy(C.scissor),Ut=C.scissorTest,R.viewport(nt),R.scissor(ot),R.setScissorTest(Ut),Q=-1;return}else if(St.__webglFramebuffer===void 0)J.setupRenderTarget(C);else if(St.__hasExternalTextures)J.rebindTextures(C,Y.get(C.texture).__webglTexture,Y.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const _e=C.depthTexture;if(St.__boundDepthTexture!==_e){if(_e!==null&&Y.has(_e)&&(C.width!==_e.image.width||C.height!==_e.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(C)}}const zt=C.texture;(zt.isData3DTexture||zt.isDataArrayTexture||zt.isCompressedArrayTexture)&&(Et=!0);const Yt=Y.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Yt[H])?X=Yt[H][q]:X=Yt[H],$=!0):C.samples>0&&J.useMultisampledRTT(C)===!1?X=Y.get(C).__webglMultisampledFramebuffer:Array.isArray(Yt)?X=Yt[q]:X=Yt,nt.copy(C.viewport),ot.copy(C.scissor),Ut=C.scissorTest}else nt.copy(Xt).multiplyScalar(ct).floor(),ot.copy(kt).multiplyScalar(ct).floor(),Ut=Rt;if(q!==0&&(X=O),R.bindFramebuffer(z.FRAMEBUFFER,X)&&R.drawBuffers(C,X),R.viewport(nt),R.scissor(ot),R.setScissorTest(Ut),$){const St=Y.get(C.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+H,St.__webglTexture,q)}else if(Et){const St=H;for(let zt=0;zt<C.textures.length;zt++){const Yt=Y.get(C.textures[zt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+zt,Yt.__webglTexture,q,St)}}else if(C!==null&&q!==0){const St=Y.get(C.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,St.__webglTexture,q)}Q=-1},this.readRenderTargetPixels=function(C,H,q,X,$,Et,It,St=0){if(!(C&&C.isWebGLRenderTarget)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let zt=Y.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&It!==void 0&&(zt=zt[It]),zt){R.bindFramebuffer(z.FRAMEBUFFER,zt);try{const Yt=C.textures[St],_e=Yt.format,Ce=Yt.type;if(C.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+St),!L.textureFormatReadable(_e)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!L.textureTypeReadable(Ce)){le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=C.width-X&&q>=0&&q<=C.height-$&&z.readPixels(H,q,X,$,Mt.convert(_e),Mt.convert(Ce),Et)}finally{const Yt=W!==null?Y.get(W).__webglFramebuffer:null;R.bindFramebuffer(z.FRAMEBUFFER,Yt)}}},this.readRenderTargetPixelsAsync=async function(C,H,q,X,$,Et,It,St=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let zt=Y.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&It!==void 0&&(zt=zt[It]),zt)if(H>=0&&H<=C.width-X&&q>=0&&q<=C.height-$){R.bindFramebuffer(z.FRAMEBUFFER,zt);const Yt=C.textures[St],_e=Yt.format,Ce=Yt.type;if(C.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+St),!L.textureFormatReadable(_e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!L.textureTypeReadable(Ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.bufferData(z.PIXEL_PACK_BUFFER,Et.byteLength,z.STREAM_READ),z.readPixels(H,q,X,$,Mt.convert(_e),Mt.convert(Ce),0);const gi=W!==null?Y.get(W).__webglFramebuffer:null;R.bindFramebuffer(z.FRAMEBUFFER,gi);const nn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await j4(z,nn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,Et),z.deleteBuffer(qt),z.deleteSync(nn),Et}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,H=null,q=0){const X=Math.pow(2,-q),$=Math.floor(C.image.width*X),Et=Math.floor(C.image.height*X),It=H!==null?H.x:0,St=H!==null?H.y:0;J.setTexture2D(C,0),z.copyTexSubImage2D(z.TEXTURE_2D,q,0,0,It,St,$,Et),R.unbindTexture()},this.copyTextureToTexture=function(C,H,q=null,X=null,$=0,Et=0){let It,St,zt,Yt,_e,Ce,qt,gi,nn;const qi=C.isCompressedTexture?C.mipmaps[Et]:C.image;if(q!==null)It=q.max.x-q.min.x,St=q.max.y-q.min.y,zt=q.isBox3?q.max.z-q.min.z:1,Yt=q.min.x,_e=q.min.y,Ce=q.isBox3?q.min.z:0;else{const sn=Math.pow(2,-$);It=Math.floor(qi.width*sn),St=Math.floor(qi.height*sn),C.isDataArrayTexture?zt=qi.depth:C.isData3DTexture?zt=Math.floor(qi.depth*sn):zt=1,Yt=0,_e=0,Ce=0}X!==null?(qt=X.x,gi=X.y,nn=X.z):(qt=0,gi=0,nn=0);const wi=Mt.convert(H.format),is=Mt.convert(H.type);let Tt;H.isData3DTexture?(J.setTexture3D(H,0),Tt=z.TEXTURE_3D):H.isDataArrayTexture||H.isCompressedArrayTexture?(J.setTexture2DArray(H,0),Tt=z.TEXTURE_2D_ARRAY):(J.setTexture2D(H,0),Tt=z.TEXTURE_2D),R.activeTexture(z.TEXTURE0),R.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,H.flipY),R.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),R.pixelStorei(z.UNPACK_ALIGNMENT,H.unpackAlignment);const Zs=R.getParameter(z.UNPACK_ROW_LENGTH),Xe=R.getParameter(z.UNPACK_IMAGE_HEIGHT),dr=R.getParameter(z.UNPACK_SKIP_PIXELS),jr=R.getParameter(z.UNPACK_SKIP_ROWS),Ro=R.getParameter(z.UNPACK_SKIP_IMAGES);R.pixelStorei(z.UNPACK_ROW_LENGTH,qi.width),R.pixelStorei(z.UNPACK_IMAGE_HEIGHT,qi.height),R.pixelStorei(z.UNPACK_SKIP_PIXELS,Yt),R.pixelStorei(z.UNPACK_SKIP_ROWS,_e),R.pixelStorei(z.UNPACK_SKIP_IMAGES,Ce);const Al=C.isDataArrayTexture||C.isData3DTexture,xi=H.isDataArrayTexture||H.isData3DTexture;if(C.isDepthTexture){const sn=Y.get(C),Io=Y.get(H),Ri=Y.get(sn.__renderTarget),Do=Y.get(Io.__renderTarget);R.bindFramebuffer(z.READ_FRAMEBUFFER,Ri.__webglFramebuffer),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,Do.__webglFramebuffer);for(let _l=0;_l<zt;_l++)Al&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Y.get(C).__webglTexture,$,Ce+_l),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Y.get(H).__webglTexture,Et,nn+_l)),z.blitFramebuffer(Yt,_e,It,St,qt,gi,It,St,z.DEPTH_BUFFER_BIT,z.NEAREST);R.bindFramebuffer(z.READ_FRAMEBUFFER,null),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if($!==0||C.isRenderTargetTexture||Y.has(C)){const sn=Y.get(C),Io=Y.get(H);R.bindFramebuffer(z.READ_FRAMEBUFFER,P),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,N);for(let Ri=0;Ri<zt;Ri++)Al?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,sn.__webglTexture,$,Ce+Ri):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,sn.__webglTexture,$),xi?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Io.__webglTexture,Et,nn+Ri):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Io.__webglTexture,Et),$!==0?z.blitFramebuffer(Yt,_e,It,St,qt,gi,It,St,z.COLOR_BUFFER_BIT,z.NEAREST):xi?z.copyTexSubImage3D(Tt,Et,qt,gi,nn+Ri,Yt,_e,It,St):z.copyTexSubImage2D(Tt,Et,qt,gi,Yt,_e,It,St);R.bindFramebuffer(z.READ_FRAMEBUFFER,null),R.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else xi?C.isDataTexture||C.isData3DTexture?z.texSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,is,qi.data):H.isCompressedArrayTexture?z.compressedTexSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,qi.data):z.texSubImage3D(Tt,Et,qt,gi,nn,It,St,zt,wi,is,qi):C.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,Et,qt,gi,It,St,wi,is,qi.data):C.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,Et,qt,gi,qi.width,qi.height,wi,qi.data):z.texSubImage2D(z.TEXTURE_2D,Et,qt,gi,It,St,wi,is,qi);R.pixelStorei(z.UNPACK_ROW_LENGTH,Zs),R.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Xe),R.pixelStorei(z.UNPACK_SKIP_PIXELS,dr),R.pixelStorei(z.UNPACK_SKIP_ROWS,jr),R.pixelStorei(z.UNPACK_SKIP_IMAGES,Ro),Et===0&&H.generateMipmaps&&z.generateMipmap(Tt),R.unbindTexture()},this.initRenderTarget=function(C){Y.get(C).__webglFramebuffer===void 0&&J.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?J.setTextureCube(C,0):C.isData3DTexture?J.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?J.setTexture2DArray(C,0):J.setTexture2D(C,0),R.unbindTexture()},this.resetState=function(){k=0,B=0,W=null,R.reset(),At.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ca}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=He._getDrawingBufferColorSpace(t),e.unpackColorSpace=He._getUnpackColorSpace()}}class el{constructor(t){this.rateAt=t}static HISTORY_S=20;sums=[0];at(t){if(!(t>0))return 0;const e=Math.floor(t);for(;this.sums.length<=e+1;){const i=this.sums.length-1;this.sums.push(this.sums[i]+(this.rateAt(i)+this.rateAt(i+1))/2)}return this.sums[e]+(this.sums[e+1]-this.sums[e])*(t-e)}stateAt(t){return{impacts:this.at(t),history:Array.from({length:el.HISTORY_S},(e,i)=>this.at(t-i-1))}}}class ke{static NONE={ghosts:[],blades:0,bladeAngleRad:0,scattered:0,drops:0,impacts:0,history:[],still:!1,running:0,reachDeg:30,placed:[]};static PHONE=[{scale:-1,share:5e-5,blur:.006,cause:"sensor",tint:[.41,1,.83]},{scale:-.45,share:5e-6,blur:.02,tint:[.7,1,.8]},{scale:.55,share:375e-8,blur:.035,tint:[1,.75,1]}];static CAMERA=[{scale:-1.4,share:3e-4,blur:.045,tint:[1,.8,1]},{scale:-.8,share:4e-4,blur:.02,tint:[.75,1,.8]},{scale:-.35,share:25e-5,blur:.012,tint:[1,.9,.7]},{scale:.3,share:2e-4,blur:.03,tint:[.8,.9,1]},{scale:.65,share:15e-5,blur:.06,tint:[1,.85,1]}];static FILTER={scale:-1,share:.001,blur:.004,cause:"filter"};static WINDOW={scale:1,share:.0016,blur:.002,offset:[0,.006],cause:"glass"};static WINDSCREEN={scale:1,share:.02,blur:.003,offset:[0,.025],cause:"glass"};static OFF_FRAME_REACH_DEG=30;static offFrameShare(t,e,i=ke.OFF_FRAME_REACH_DEG){const n=Math.min(Math.max((t-e)/i,0),1);return 1-n*n*(3-2*n)}static REFERENCE_F_NUMBER=4;static of(t){return t.ghosts?t.ghosts:ke.records(t)?t.category==="phone"?ke.PHONE:ke.CAMERA:[]}static records(t){return t.medium!==void 0||t.category==="camera"||t.category==="dslr"||t.category==="phone"}static optics(t,e,i,n,s=0){const r=ke.of(t);if(r.length===0)return ke.NONE;const a=t.fNumber??ke.REFERENCE_F_NUMBER,c=e??a,l=[...r,...i?.ghosts??[]].map(y=>({...y,blur:y.blur*a/c}));i?.glass==="filter"?l.push({...ke.FILTER}):i?.glass==="window"?l.push({...ke.WINDOW}):i?.glass==="windscreen"&&l.push({...ke.WINDSCREEN});const h=ke.share(i?.condensation),u=ke.share(i?.dirt),d=ke.falling(i),f=d?n?.impacts??0:0,p=d?n?.history??[]:[],m=f-(p[ke.DROP_LIFE_S-1]??0),g=i?.drops!==void 0?ke.share(i.drops):d?Math.min(1,m):0;h>0&&(l.push({scale:1,share:.25*h,blur:.03,cause:"condensation"}),l.push({scale:1,share:.15*h,blur:.12,cause:"condensation"})),u>0&&(l.push({scale:1,share:.03*u,blur:.04,cause:"dirt"}),l.push({scale:1,share:.02*u,blur:.15,cause:"dirt"})),g>0&&l.push({scale:1,share:.12*g,blur:.025,cause:"drops"});const v=l.filter(y=>ke.scatters(y)).reduce((y,x)=>y+x.share,0),M=_i.bladesShowing(t,e)>=.5?t.apertureBlades??0:0,w=i?.glass==="window"||i?.glass==="windscreen"?1:.25;return{ghosts:l,blades:M,bladeAngleRad:.3,scattered:Math.min(.9,v),drops:g,impacts:f,history:p,still:i?.drops!==void 0,running:w,reachDeg:i?.reachDeg??ke.OFF_FRAME_REACH_DEG,placed:(i?.placedDrops??[]).map(y=>ke.placedAt(y,s))}}static placedAt(t,e){const i=t.track,n=i.findIndex(c=>c.t>e);if(n===0)return{x:i[0].x,y:i[0].y,radius:t.radius};if(n===-1){const c=i[i.length-1];return{x:c.x,y:c.y,radius:t.radius}}const s=i[n-1],r=i[n],a=(e-s.t)/(r.t-s.t);return{x:s.x+(r.x-s.x)*a,y:s.y+(r.y-s.y)*a,radius:t.radius}}static falling(t){return t?.drops===void 0&&!t?.sheltered}static DROP_LIFE_S=8;static impactRate(t,e,i){const n=ke.dropsFrom(t);if(n===0)return 0;const s=t.precipitationType==="snow"?1:6.5,r=((i?.windFromDeg??0)+180)*Math.PI/180,a=i?.windSpeedMS??0,c=[Math.sin(r)*a,Math.cos(r)*a,-s],l=(i?.headingDeg??0)*Math.PI/180,h=(e==="window"?0:e==="windscreen"?60:i?.pitchDeg??0)*Math.PI/180,u=[Math.sin(l)*Math.cos(h),Math.cos(l)*Math.cos(h),Math.sin(h)],d=Math.hypot(c[0],c[1],c[2]),f=Math.max(0,-(c[0]*u[0]+c[1]*u[1]+c[2]*u[2])/d);return n*.4*(.02+.98*f)}static scatters(t){return t.cause==="condensation"||t.cause==="dirt"||t.cause==="drops"}static dropsFrom(t){if(!t||t.precipitationType==="none"||t.precipitationType==="hail")return 0;const e=ke.share(t.precipitationIntensity);return e===0?0:t.precipitationType==="snow"?.5*e:Math.min(1,.3+.7*e)}static positionOf(t,e){return{x:e.x*t.scale+2*(t.offset?.[0]??0),y:e.y*t.scale+2*(t.offset?.[1]??0)}}static sourceOf(t,e){return{x:(e.x-2*(t.offset?.[0]??0))/t.scale,y:(e.y-2*(t.offset?.[1]??0))/t.scale}}static share(t){return Math.max(0,Math.min(1,t??0))}}const Ln=Math.PI/180;class ee{constructor(t){this.words=t}static COARSE_DEG=2;static FINE_DEG=.25;findingsOf(t,e){const i=Ze.strip(e).recording,n=i.interpretation?.mechanism;if(!n)return[];const s=ee.settingOf(t,n.explains);if(!s)return[];const r="interpretation.mechanism";switch(n.kind){case"fixed-in-frame":{const a=ee.missOf(s.samples,ee.fixedPoint(s.samples));return[this.finding(this.words.bestFixed,a,s,{},"established",r)]}case"driven-one-way":{const{miss:a,directionDeg:c}=ee.oneWay(s.samples);return[this.finding(this.words.bestOneWay,a,s,{direction:Math.round(c)},"established",r)]}case"lens-ghost":return this.lensGhostFindings(s,i,r);case"stated-ghost":return this.statedGhostFindings(s,i,r);case"ghost-of":return this.ghostOfFindings(s,i,n.of,r);case"real-object":return[this.realObjectFinding(s,i,n.explains,r)]}}ghostOfFindings(t,e,i,n){const s=e.interpretation?.bodies?.find(u=>u.id===i);if(!s)return[];const r=t.samples.map(u=>{const d=ee.bodyDirectionAt(s,u.t);if(!d)return;const f=d.applyQuaternion(u.frame.inverse);return f.z<0?{x:f.x/-f.z,y:f.y/-f.z}:void 0}),a=ke.of(_i.byId(e.instrument)).filter(u=>!ke.scatters(u)).map(u=>u.scale);let c;for(const u of a){const d=r.map(p=>p?{x:u*p.x,y:u*p.y}:void 0),f=ee.missOfTrack(t.samples,d);(!c||f.medianDeg<c.miss.medianDeg)&&(c={miss:f,k:u,track:d})}if(!c)return[];const l=c.track.filter(u=>u!==void 0);let h=0;for(const u of l)for(const d of l)h=Math.max(h,ee.angleDeg(u,d));return[this.finding(this.words.bestGhostOf,c.miss,t,{k:this.number(c.k),ghostTravel:this.number(h)},"established",n)]}realObjectFinding(t,e,i,n){const r=e.interpretation?.bodies?.find(l=>l.explains?.includes(i))?.track[0]?.distanceM??ee.DEFAULT_DISTANCE_M,a=t.samples.map(l=>new T(l.at.x,l.at.y,-1).normalize().applyQuaternion(l.frame.rotation));let c=0;for(let l=0;l<a.length;l++){const h=t.samples.findIndex(u=>u.t>=t.samples[l].t+ee.RATE_WINDOW_MS);if(h<0)break;c=Math.max(c,a[l].angleTo(a[h])/((t.samples[h].t-t.samples[l].t)/1e3))}return{text:this.fill(this.words.bestRealObject,{medianDeg:0,maxDeg:0},t,{distance:Math.round(r),width:this.number(r*t.sizeDeg*Ln),speed:Math.round(r*c)}),outcome:"holds",against:"established",path:n}}static bodyDirectionAt(t,e){const i=t.track.filter(l=>l.azimuthDeg!==void 0&&l.altitudeDeg!==void 0);if(i.length===0)return;const n=i.findIndex(l=>l.t>e),s=i[n<=0?n===0?0:i.length-1:n-1],r=n<=0?s:i[n],a=r.t>s.t?(e-s.t)/(r.t-s.t):0,c=((r.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return ee.direction(s.azimuthDeg+c*a,s.altitudeDeg+(r.altitudeDeg-s.altitudeDeg)*a)}static DEFAULT_DISTANCE_M=1e3;static RATE_WINDOW_MS=500;static lays(t){return t?.kind==="fixed-in-frame"||t?.kind==="driven-one-way"||t?.kind==="real-object"}bestSceneOf(t,e){const n=Ze.strip(e).recording.interpretation?.mechanism;if(!ee.lays(n))return;const s=ee.settingOf(t,n.explains);if(!s)return;const r=structuredClone(e);if(n.kind==="fixed-in-frame"||n.kind==="real-object"){const a=r.interpretation??{bodies:[]},c=a.bodies??[],l=c.findIndex(d=>d.explains?.includes(n.explains)),h=l>=0?c[l]:void 0,u=n.kind==="fixed-in-frame"?ee.stillBody(s,n.explains,h):ee.sightLineBody(s,n.explains,h);r.interpretation={...a,bodies:l>=0?c.map((d,f)=>f===l?u:d):[...c,u]}}else{const{track:a}=ee.oneWay(s.samples),c=r.lens?.placedDrops?.[0],l=s.samples[0],h=c?.radius??ee.round(s.sizeDeg/l.frame.fovDeg,4),u=s.samples.map((d,f)=>{const p=Math.tan(d.frame.fovDeg/2*Ln);return{t:d.t,x:ee.round(.5+a[f].x/(2*p*s.aspect),4),y:ee.round(.5-a[f].y/(2*p),4)}});r.lens={...r.lens,placedDrops:[{radius:h,track:u}]}}return r}static stillBody(t,e,i){const n=ee.fixedPoint(t.samples),s=t.samples[0].t,r=t.samples[t.samples.length-1].t,a=[...new Set([...t.samples.map(c=>c.t),...t.keyframes.map(c=>c.t).filter(c=>c>s&&c<r)])].sort((c,l)=>c-l);return ee.bodyAlong(t,e,i,a,()=>n)}static sightLineBody(t,e,i){return ee.bodyAlong(t,e,i,t.samples.map(n=>n.t),(n,s)=>t.samples[s].at)}static bodyAlong(t,e,i,n,s){const r=n[n.length-1],a=i?.track[0],c=a?.distanceM??ee.DEFAULT_DISTANCE_M,l=a?.sizeM??(()=>{const f=ee.round(c*t.sizeDeg*Ln,4);return{widthM:f,lengthM:f,heightM:f}})(),h=a?.appearance??{color:"#f4f6f5"},u=n.map((f,p)=>{const m=s(f,p),g=new T(m.x,m.y,-1).normalize().applyQuaternion(ee.frameAt(t.keyframes,f).rotation);return{t:f,...p===0?{present:!0,sizeM:l,appearance:h}:{},azimuthDeg:ee.round((Math.atan2(g.x,-g.z)/Ln+360)%360,3),altitudeDeg:ee.round(Math.asin(Math.min(1,Math.max(-1,g.y)))/Ln,3),distanceM:c}}),d=n.length>1?n[n.length-1]-n[n.length-2]:40;return{...i??{id:e,explains:[e],model:{id:"sphere"}},track:[...u,{t:r+d,present:!1}]}}static round(t,e){return Math.round(t*10**e)/10**e}lensGhostFindings(t,e,i){const n=ke.of(_i.byId(e.instrument)).filter(l=>!ke.scatters(l)).map(l=>l.scale),s=e.lens?.reachDeg??ke.OFF_FRAME_REACH_DEG,r=l=>{const h=ee.sunTrack(t,l,s);if(!h)return;let u;for(const d of n){const f=ee.missOfTrack(t.samples,h.map(p=>({x:d*p.x,y:d*p.y})));(!u||f.medianDeg<u.miss.medianDeg)&&(u={miss:f,k:d})}return u},a=ee.bestSun(t,!0,r),c=[];if(a?c.push(this.finding(this.words.bestGhost,a.result.miss,t,{...this.sunWords(a.sun),k:this.number(a.result.k)},t.lightingGround,i)):c.push({text:this.words.bestNoGhost,outcome:"fails",against:t.lightingGround,path:i}),t.lighting&&(!a||a.result.miss.medianDeg>t.sizeDeg)){const l=ee.bestSun(t,!1,r);l&&(!a||l.result.miss.medianDeg<a.result.miss.medianDeg-1e-6)&&c.push({text:this.fill(this.words.bestGhostNeeds,l.result.miss,t,{...this.sunWords(l.sun),k:this.number(l.result.k)}),outcome:"fails",against:t.lightingGround,path:"lighting"})}return c}statedGhostFindings(t,e,i){const n=e.lens?.reachDeg??ke.OFF_FRAME_REACH_DEG,s=c=>{const l=ee.sunTrack(t,c,n);if(!l)return;const h=ee.linearFit(l,t.samples.map(d=>d.at)),u=l.map(d=>({x:h.k*d.x+h.offset.x,y:h.k*d.y+h.offset.y}));return{miss:ee.missOfTrack(t.samples,u),...h}},r=ee.bestSun(t,!0,s);if(!r)return[{text:this.words.bestNoGhost,outcome:"fails",against:t.lightingGround,path:i}];const a=Math.atan(Math.hypot(r.result.offset.x,r.result.offset.y))/Ln;return[this.finding(this.words.bestStatedGhost,r.result.miss,t,{...this.sunWords(r.sun),k:this.number(r.result.k),offset:this.number(a)},t.lightingGround,i)]}finding(t,e,i,n,s,r){return{text:this.fill(t,e,i,n),outcome:e.medianDeg<=i.sizeDeg?"holds":"fails",against:s,path:r}}fill(t,e,i,n){const s={median:this.number(e.medianDeg),max:this.number(e.maxDeg),size:this.number(i.sizeDeg),travel:this.number(i.travelDeg),...n};return t.replace(/\{(\w+)\}/g,(r,a)=>a in s?String(s[a]):r)}sunWords(t){return{bearing:Math.round(t.bearing),altitude:this.number(t.altitudeDeg)}}number(t){const e=Math.abs(t)<1?2:1;return t.toFixed(e).replace(".",this.words.decimal)}static settingOf(t,e){const{recording:i,provenance:n}=Ze.strip(t),s=i.observerTrack?.keyframes??[];if(s.length===0)return;const r=_i.aspectOf(_i.byId(i.instrument)),a=[],c=[];for(const d of i.timeline?.keyframes??[])for(const f of d.shapes??[]){const p=f.shape;if(f.sourceId!==e||!p.aim)continue;const m=ee.frameAt(s,d.t),g=ee.direction(p.aim.azimuthDeg,p.aim.altitudeDeg).applyQuaternion(m.inverse);g.z>=0||(a.push({t:d.t,at:{x:g.x/-g.z,y:g.y/-g.z},frame:m}),p.angular?.widthDeg&&c.push(p.angular.widthDeg))}if(a.length===0)return;c.sort((d,f)=>d-f);let l=0;for(const d of a)for(const f of a)l=Math.max(l,ee.angleDeg(d.at,f.at));const h=s[0].pose,u=h.lat??0;return{samples:a,keyframes:s,sizeDeg:c.length>0?c[Math.floor(c.length/2)]:.5,travelDeg:l,aspect:r,headingDeg:h.headingDeg??0,lighting:i.lighting,lightingGround:Ze.free(n.at("lighting"))?"supposed":"established",altitudes:{minDeg:-Math.acos(6371e3/(6371e3+Math.max(h.elevationM??0,0)))/Ln,maxDeg:ee.highestSun(i.time,n.at("time")?.range,u,h.lng??0)}}}static highestSun(t,e,i,n){const[s,r]=(typeof e=="string"?e:t??"").split("/"),a=s?Xs(s):void 0,c=r?Xs(r):a;if(!a||!c)return 90;const l=or.earliestOf(a),h=or.latestOf(c),u=864e5;let d=-90;for(let f=Math.floor(l/u)*u;f<=h;f+=u){const p=f+(12-n/15)*36e5;for(let m=-60;m<=60;m+=10)d=Math.max(d,Sh("Sun",new Date(p+m*6e4),{lat:i,lng:n,elevationM:0}).altitudeDeg)}return d}static frameAt(t,e){const i=t.findIndex(u=>u.t>e),n=t[i<=0?i===0?0:t.length-1:i-1],s=i<=0?n:t[i],r=s.t>n.t?(e-n.t)/(s.t-n.t):0,a=(u,d,f)=>(u??f)+((d??u??f)-(u??f))*r,c=(((s.pose.headingDeg??0)-(n.pose.headingDeg??0))%360+540)%360-180,l=(n.pose.headingDeg??0)+c*r,h=new es().setFromEuler(new Yr(a(n.pose.pitchDeg,s.pose.pitchDeg,0)*Ln,-l*Ln,a(n.pose.rollDeg,s.pose.rollDeg,0)*Ln,"YXZ"));return{rotation:h,inverse:h.clone().invert(),fovDeg:a(n.pose.fovDeg,s.pose.fovDeg,50)}}static direction(t,e){const i=t*Ln,n=e*Ln;return new T(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}static angleDeg(t,e){const i=(t.x*e.x+t.y*e.y+1)/Math.sqrt((t.x*t.x+t.y*t.y+1)*(e.x*e.x+e.y*e.y+1));return Math.acos(Math.min(1,Math.max(-1,i)))/Ln}static missOf(t,e){return ee.missOfTrack(t,t.map(()=>e))}static missOfTrack(t,e){const i=t.map((n,s)=>e[s]?ee.angleDeg(n.at,e[s]):180).sort((n,s)=>n-s);return{medianDeg:i[Math.floor(i.length/2)],maxDeg:i[i.length-1]}}static fixedPoint(t){let e={x:t.reduce((i,n)=>i+n.at.x,0)/t.length,y:t.reduce((i,n)=>i+n.at.y,0)/t.length};for(let i=0;i<100;i++){let n=0,s=0,r=0;for(const a of t){const c=1/Math.max(Math.hypot(a.at.x-e.x,a.at.y-e.y),1e-9);n+=a.at.x*c,s+=a.at.y*c,r+=c}e={x:n/r,y:s/r}}return e}static oneWay(t){let e;for(let i=0;i<360;i+=5){const n={x:Math.sin(i*Ln),y:Math.cos(i*Ln)},s={x:n.y,y:-n.x},r=t.map(d=>d.at.x*n.x+d.at.y*n.y),a=t.map(d=>d.at.x*s.x+d.at.y*s.y).sort((d,f)=>d-f),c=a[Math.floor(a.length/2)],h=ee.neverBack(r).map(d=>({x:d*n.x+c*s.x,y:d*n.y+c*s.y})),u=ee.missOfTrack(t,h);(!e||u.medianDeg<e.miss.medianDeg||u.medianDeg===e.miss.medianDeg&&u.maxDeg<e.miss.maxDeg)&&(e={miss:u,directionDeg:i,track:h})}return e}static neverBack(t){const e=[];for(const i of t)for(e.push({sum:i,count:1});e.length>1&&e[e.length-2].sum/e[e.length-2].count>e[e.length-1].sum/e[e.length-1].count;){const n=e.pop();e[e.length-1].sum+=n.sum,e[e.length-1].count+=n.count}return e.flatMap(i=>new Array(i.count).fill(i.sum/i.count))}static sunTrack(t,e,i){const n=ee.direction(t.headingDeg+e.bearing,e.altitudeDeg),s=[];for(const r of t.samples){const a=n.clone().applyQuaternion(r.frame.inverse),c=Math.acos(Math.min(1,Math.max(-1,-a.z)))/Ln,l=Math.tan(r.frame.fovDeg/2*Ln),h=Math.atan(l*Math.hypot(1,t.aspect))/Ln;if(a.z>=0||c>=h+i)return;s.push({x:a.x/-a.z,y:a.y/-a.z})}return s}static linearFit(t,e){const i=t.length,n=h=>({x:h.reduce((u,d)=>u+d.x,0)/i,y:h.reduce((u,d)=>u+d.y,0)/i}),s=n(t),r=n(e);let a=0,c=0;for(let h=0;h<i;h++)a+=(t[h].x-s.x)*(e[h].x-r.x)+(t[h].y-s.y)*(e[h].y-r.y),c+=(t[h].x-s.x)**2+(t[h].y-s.y)**2;const l=c>1e-12?a/c:0;return{k:l,offset:{x:r.x-l*s.x,y:r.y-l*s.y}}}static bestSun(t,e,i){const n=h=>h.altitudeDeg>=t.altitudes.minDeg&&h.altitudeDeg<=t.altitudes.maxDeg&&(!e||!t.lighting||ee.lights(t.lighting,h));let s;const r=h=>{if(!n(h))return;const u=i(h);u&&(!s||u.miss.medianDeg<s.result.miss.medianDeg)&&(s={sun:h,result:u})},{minDeg:a,maxDeg:c}=t.altitudes;for(let h=0;h<360;h+=ee.COARSE_DEG){for(let u=a;u<=c;u+=ee.COARSE_DEG/2)r({bearing:h,altitudeDeg:u});r({bearing:h,altitudeDeg:c})}if(!s)return;const l=s.sun;for(let h=-2;h<=ee.COARSE_DEG;h+=ee.FINE_DEG)for(let u=-2;u<=ee.COARSE_DEG;u+=ee.FINE_DEG)r({bearing:((l.bearing+h)%360+360)%360,altitudeDeg:l.altitudeDeg+u});return s}static lights(t,e){const i=t.sunFromViewDeg,n=i?((e.bearing-i.fromDeg)%360+360)%360:0,s=i?((i.toDeg-i.fromDeg)%360+360)%360:360,r=!t.sunAltitudeDeg||e.altitudeDeg>=t.sunAltitudeDeg.minDeg&&e.altitudeDeg<=t.sunAltitudeDeg.maxDeg;return n<=s&&r}}const s8=[{path:"place.locations.0.lat",what:"latitude"},{path:"place.locations.0.lng",what:"longitude"}];class fn{constructor(t){this.words=t,this.bestCases=new ee(t)}bestCases;found=new WeakMap;findingsOf(t,e){const i=Ze.strip(t),n=Ze.strip(e).recording,s=[],r=this.timeFinding(i.recording.time,i.provenance.at("time"),n.time);r&&s.push(r);for(const{path:c,what:l}of s8){const h=this.numberFinding(fn.at(i.recording,c),i.provenance.at(c),fn.at(n,c),this.words[l]);h&&s.push({...h,path:c})}const a=i.recording.lighting;if(a&&fn.movesTheSun(i.recording,n)){const c=this.lightingFinding(a,i.provenance.at("lighting"),n);c&&s.push(c)}return s.push(...this.bestCasesOf(t,e)),s}bestCasesOf(t,e){const i=JSON.stringify([e.interpretation?.mechanism,e.lens,e.instrument]),n=this.found.get(e);if(n&&n.account===t&&n.key===i)return n.findings;const s=this.bestCases.findingsOf(t,e);return this.found.set(e,{account:t,key:i,findings:s}),s}static withinInterval(t,e){const[i,n]=e.split("/"),s=i?Xs(i):void 0,r=n?Xs(n):void 0;if(!(!s&&!r))return!(s&&t.getTime()<or.earliestOf(s)||r&&t.getTime()>or.latestOf(r))}timeFinding(t,e,i){if(t===void 0||i===void 0||t===i)return;const n=Xs(i),s=n?so(n,0,0):void 0;if(typeof e?.range=="string"&&s){const r=fn.withinInterval(s,e.range);if(r===void 0)return;const a=r?this.words.timeWithin:this.words.timeOutside;return{text:fn.fill(a,{time:i,range:e.range}),outcome:r?"holds":"fails",against:"established",path:"time"}}if(!Ze.free(e))return{text:fn.fill(this.words.timeChanged,{from:t,time:i}),outcome:"fails",against:"established",path:"time"}}numberFinding(t,e,i,n){if(!(typeof t!="number"||typeof i!="number"||Math.abs(t-i)<1e-9)){if(Array.isArray(e?.range)){const[s,r]=e.range,a=i>=s&&i<=r;return{text:fn.fill(a?this.words.valueWithin:this.words.valueOutside,{what:n,value:i,min:s,max:r}),outcome:a?"holds":"fails",against:"established"}}if(!Ze.free(e))return{text:fn.fill(this.words.valueChanged,{what:n,from:t,value:i}),outcome:"fails",against:"established"}}}static movesTheSun(t,e){const i=r=>r.observerTrack?.keyframes?.[0]?.pose,n=i(t),s=i(e);return t.time!==e.time||t.utcOffsetHours!==e.utcOffsetHours||JSON.stringify(t.place)!==JSON.stringify(e.place)||n?.lat!==s?.lat||n?.lng!==s?.lng||n?.headingDeg!==s?.headingDeg}lightingFinding(t,e,i){const n=i.time?Xs(i.time):void 0,s=n?fn.sunOf(n,i):void 0;if(!s)return;const{bearing:r}=s,{fromDeg:a,toDeg:c}=t.sunFromViewDeg??{fromDeg:0,toDeg:360},{minDeg:l,maxDeg:h}=t.sunAltitudeDeg??{minDeg:-90,maxDeg:90},u=fn.lights(t,s),d=Ze.free(e)?"supposed":"established",f=p=>Math.round(p);return{text:fn.fill(u?this.words.lightingHolds:this.words.lightingFails,{bearing:f(r),altitude:f(s.altitudeDeg),from:a,to:c,altitudes:t.sunAltitudeDeg?fn.fill(this.words.altitudes,{min:l,max:h}):""}),outcome:u?"holds":"fails",against:d,path:"lighting",...e?.rationale?{rationale:e.rationale}:{}}}static standOf(t){const e=Ze.strip(t).recording,i=e.observerTrack?.keyframes?.[0]?.pose,n=e.place?.locations?.[0],s=i?.lat??n?.lat,r=i?.lng??n?.lng;if(!(s===void 0||r===void 0||i?.headingDeg===void 0))return{lat:s,lng:r,elevationM:i.elevationM??0,headingDeg:i.headingDeg,utcOffsetHours:e.utcOffsetHours}}static sunOf(t,e){const i=fn.standOf(e);return i?fn.sunFrom(t,i):void 0}static sunFrom(t,e){if(t.hour===void 0)return;const i=so(t,e.lng,e.utcOffsetHours);if(!i)return;const n=Sh("Sun",i,e);return{bearing:((n.azimuthDeg-e.headingDeg)%360+360)%360,altitudeDeg:n.altitudeDeg}}static lights(t,e){const i=t.sunFromViewDeg?fn.onArc(e.bearing,t.sunFromViewDeg.fromDeg,t.sunFromViewDeg.toDeg):!0,n=!t.sunAltitudeDeg||e.altitudeDeg>=t.sunAltitudeDeg.minDeg&&e.altitudeDeg<=t.sunAltitudeDeg.maxDeg;return i&&n}static nearestLit(t,e,i){const n=u=>({...e,hour:Math.floor(u/60),minute:u%60,second:void 0,raw:void 0}),s=fn.standOf(i);if(!s)return;const r=u=>{const d=fn.sunFrom(n(u),s);return d!==void 0&&fn.lights(t,d)};if(e.hour===void 0)return;const a=e.hour*60+(e.minute??0);if(r(a))return e;const c=5;let l;for(let u=0;u<1440;u+=c)r(u)&&(l===void 0||Math.abs(u-a)<Math.abs(l-a))&&(l=u);if(l===void 0)return;const h=a<l?-1:1;for(;l+h>=0&&l+h<1440&&r(l+h)&&Math.abs(l+h-a)<Math.abs(l-a);)l+=h;return n(l)}static onArc(t,e,i){const n=((i-e)%360+360)%360;return((t-e)%360+360)%360<=n}static at(t,e){return e.split(".").reduce((i,n)=>i?.[n],t)}static fill(t,e){return t.replace(/\{(\w+)\}/g,(i,n)=>n in e?String(e[n]):i)}}const r8=Xn.catalog({en:()=>at(()=>import("./ReadingCheckTexts_en-eq6teExJ.js"),[],import.meta.url).then(o=>o.readingCheckTexts_en),fr:()=>at(()=>import("./ReadingCheckTexts_fr-pcDleIvY.js"),[],import.meta.url).then(o=>o.readingCheckTexts_fr),es:()=>at(()=>import("./ReadingCheckTexts_es-CR_JJZMV.js"),[],import.meta.url).then(o=>o.readingCheckTexts_es),it:()=>at(()=>import("./ReadingCheckTexts_it-MFKeoXnq.js"),[],import.meta.url).then(o=>o.readingCheckTexts_it)});class a8{static of(t){if(!(!t||t.length===0))return t.some(e=>e.outcome==="fails"&&e.against!=="supposed")?"incompatible":t.some(e=>e.outcome!=="holds")?"unsettled":"compatible"}}class xs{constructor(t,e,i,n="en"){this.parts=t,this.messages=e,this.onChange=i,this.locale=n,e&&this.setMessages(e),t.text.addEventListener("input",()=>{this.readText(),this.showDeduction()}),t.picker.addEventListener("change",()=>this.writeFromPicker()),t.mode.addEventListener("click",()=>this.setPrecise(!this.precise)),t.text.addEventListener("blur",()=>this.validate()),t.text.addEventListener("focus",()=>this.showDeduction())}precise=!0;hint="";setBounds(t){this.bounds=t;const{picker:e}=this.parts;e.min=t?xs.pickerValueOf(t.min):"",e.max=t?xs.pickerValueOf(t.max):""}bounds;bounded(t){if(!this.bounds)return t;const e=or.latestOf(t)<or.earliestOf(this.bounds.min)?this.bounds.min:or.earliestOf(t)>or.earliestOf(this.bounds.max)?this.bounds.max:t;return this.bounds.adjust?.(e)??e}get isPrecise(){return this.precise}setMessages(t,e=this.locale){this.messages=t,this.locale=e,t.edtfPlaceholder!==void 0&&(this.parts.text.placeholder=t.edtfPlaceholder),this.parts.mode.title=t.edtfModeTitle,this.parts.mode.setAttribute("aria-label",t.edtfModeTitle),this.setPrecise(this.precise)}setPrecise(t){this.precise=t,this.parts.picker.hidden=!t,this.parts.text.hidden=t,this.parts.mode.textContent=(t?this.messages?.datePrecise:this.messages?.dateEdtf)??"",this.parts.mode.setAttribute("aria-pressed",String(!t)),this.parts.help&&(this.parts.help.hidden=t),this.showDeduction()}set(t){const{text:e,picker:i}=this.parts;e.value=t?wh(t):"",i.type!=="date"&&(i.step=xs.stepFor(t)),i.value=i.type==="date"?xs.pickerDateOf(t):xs.pickerValueOf(t),e.setCustomValidity(""),e.classList.remove("invalid"),this.showDeduction()}static opensPrecise(...t){return t.every(e=>e===void 0||xs.isPickable(e)&&xs.qualifierOf(wh(e))==="")}static opensPreciseDate(...t){return t.every(e=>e===void 0||xs.isFullDate(e)&&xs.qualifierOf(wh(e))==="")}static isFullDate(t){return!!t&&t.year!==void 0&&t.month!==void 0&&t.day!==void 0}static pickerDateOf(t){if(!xs.isFullDate(t))return"";const e=(i,n=2)=>String(i).padStart(n,"0");return`${e(t.year,4)}-${e(t.month)}-${e(t.day)}`}static isPickable(t){return!!t&&t.year!==void 0&&t.month!==void 0&&t.day!==void 0&&t.hour!==void 0&&t.minute!==void 0}static pickerValueOf(t){if(!xs.isPickable(t))return"";const e=(n,s=2)=>String(n).padStart(s,"0"),i=t.second?`:${e(t.second)}`:"";return`${e(t.year,4)}-${e(t.month)}-${e(t.day)}T${e(t.hour)}:${e(t.minute)}${i}`}static stepFor(t){return t?.second?"1":"60"}static qualifierOf(t){const e=/[?%]/.test(t),i=/[~%]/.test(t);return e&&i?"%":e?"?":i?"~":""}describe(t){return this.messages?xs.describeTime(t,this.messages,this.locale):""}static describeTime(t,e,i){const n=wh(t),s=xs.qualifierOf(n),r=h=>String(h).padStart(2,"0"),a=[];if(t.season!==void 0){const h={spring:e.timeSeasonSpring,summer:e.timeSeasonSummer,autumn:e.timeSeasonAutumn,winter:e.timeSeasonWinter}[t.season];a.push(t.year!==void 0?`${h} ${t.year}`:h)}else if(t.year!==void 0){const h=t.day!==void 0?{...t.year>=1583?{weekday:"long"}:{},year:"numeric",month:"long",day:"numeric"}:t.month!==void 0?{year:"numeric",month:"long"}:{year:"numeric"},u=new Date(Date.UTC(t.year,(t.month??1)-1,t.day??1));a.push(new Intl.DateTimeFormat(i,{...h,timeZone:"UTC"}).format(u))}t.hour!==void 0&&a.push(`${r(t.hour)}:${r(t.minute??0)}${t.second!==void 0?`:${r(t.second)}`:""}`);const c=a.join(", "),l=s==="~"?e.timeQualifierApproximate:s==="?"?e.timeQualifierUncertain:s==="%"?e.timeQualifierBoth:"";return l?`${c} — ${l.toLowerCase()}`:c}setHint(t){this.hint=t,this.showDeduction()}showDeduction(){const{text:t}=this.parts,e=t.value.trim();if(this.precise||e===""){t.title=this.hint;return}const i=Xs(e);t.title=i?`→ ${this.describe(i)}`:this.messages?.edtfInvalid??""}readText(){const t=this.parts.text.value.trim();if(t===""){this.clean(),this.onChange(void 0);return}const e=Xs(t);if(!e)return;this.clean();const i=this.bounded(e);i!==e&&this.set(i),this.onChange(i)}clean(){this.parts.text.setCustomValidity(""),this.parts.text.classList.remove("invalid")}writeFromPicker(){const{picker:t,text:e}=this.parts;t.value===""&&t.validity.badInput||(e.value=t.value===""?"":t.value.replace(/\.\d+$/,""),this.readText())}validate(){const{text:t}=this.parts,e=t.value.trim();e===""||Xs(e)||(t.setCustomValidity(this.messages?.edtfInvalid??""),t.classList.add("invalid"))}}class Oa{static read(t,e){let i=t;for(const n of e.split(".")){if(i=Oa.bare(i),i===null||typeof i!="object")return;i=i[n]}return Oa.bare(i)}static write(t,e,i){const n=e.split("."),s=[];let r=t;for(let c=0;c<n.length-1;c++){let l=Oa.bare(r[n[c]]);if(l===null||typeof l!="object"||Array.isArray(l)){if(i===void 0)return;l={}}r[n[c]]=l,s.push({owner:r,part:n[c]}),r=l}const a=n[n.length-1];i===void 0?delete r[a]:r[a]=i;for(let c=s.length-1;c>=0;c--){const l=s[c].owner[s[c].part];if(Object.keys(l).length>0)break;delete s[c].owner[s[c].part]}}static stated(t,e){return Oa.read(t,e)!==void 0}static bare(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&"value"in t&&"basis"in t?t.value:t}}class u0{static sets=new Map;static publish(t){u0.sets.set(t.kind,t)}static of(t){return u0.sets.get(t)}static kinds(){return[...u0.sets.keys()]}}class Z0{static resolved=new WeakMap;static resolve(t,e){let i=Z0.resolved.get(t);i||Z0.resolved.set(t,i=new WeakMap);let n=i.get(e);if(!n){const s=e,r=c=>{if(typeof c!="string")return c;if(typeof s[c]=="string")return s[c];const l=c.split(" ");return l.length>1&&l.every(h=>typeof s[h]=="string")?l.map(h=>s[h]).join(" "):c},a=c=>c.map(l=>({...l,label:r(l.label)}));n={...t,title:r(t.title),parameters:t.parameters.map(c=>{const l={...c,label:r(c.label),hint:r(c.hint),summary:r(c.summary),group:r(c.group),..."placeholder"in c?{placeholder:r(c.placeholder)}:{},..."empty"in c?{empty:r(c.empty)}:{}};if(l.type==="choice"){const h=l.optionsOf;return{...l,choices:a(l.choices),...h?{optionsOf:(u,d)=>a(h(u,d))}:{}}}if(l.type==="set"){const h=l.options;return{...l,options:(u,d)=>a(h(u,d))}}return l})},i.set(e,n)}return n}static missing(t,e){const i=e,n=new Set,s=r=>{if(typeof r=="string")for(const a of r.split(" "))/^[a-z][A-Za-z0-9]*$/.test(a)&&i[a]===void 0&&n.add(a)};s(t.title);for(const r of t.parameters)if(s(r.label),s(r.hint),s(r.summary),s(r.group),"placeholder"in r&&s(r.placeholder),"empty"in r&&s(r.empty),r.type==="choice")for(const a of r.choices)s(a.label);return[...n]}}const Xx="#ff2200",$x="#00ff44",Pc="#ffffff",wp="#ffa500",eh="#ff0000",o8="#2244ff",cM=[{id:"airliner",name:"Airliner",kinds:["aircraft"],referenceSizeM:{widthM:34,heightM:12,lengthM:36},create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:Xx,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:$x,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:Pc,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:Pc,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:Pc,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],referenceSizeM:{widthM:10,heightM:4,lengthM:14},create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:Xx,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:$x,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:Pc,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:eh,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:Pc,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:Pc,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:Pc,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:eh,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:eh,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:wp,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],referenceSizeM:{widthM:1.8,heightM:1.5,lengthM:4.5},create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:o8,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:eh,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"traffic-signal",name:"Traffic light",kinds:["trafficlight"],create:()=>me.vehicleLights(0)},{id:"pedestrian-signal",name:"Pedestrian light",kinds:["trafficlight"],create:()=>me.pedestrianLights(0)},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],referenceSizeM:{widthM:1,heightM:5,lengthM:1},create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class J0{static forKind(t){return cM.filter(e=>e.kinds.includes(t))}static byId(t){return cM.find(e=>e.id===t)}}class me{static CYCLE_S=90;static GREEN_S=41;static AMBER_S=3;static PEDESTRIAN_DELAY_S=2;static PEDESTRIAN_GREEN_S=30;static VEHICLE_INTENSITY=3;static PEDESTRIAN_INTENSITY=1.5;static LENS_RADIUS_M=.1;static BEAM_DEG=30;static VEHICLE_HEAD_Y_M=2.9;static PEDESTRIAN_HEAD_Y_M=2.6;static LENS_SPACING_M=.3;static LENS_FRONT_M=.13;static RED="#ff1e00";static AMBER="#ffa200";static GREEN="#00ff8c";static phaseOf(t){const e=(t%180+180)%180;return e>=45&&e<135?1:0}static vehicleLights(t){const e=t*me.CYCLE_S/2,i=me.VEHICLE_HEAD_Y_M,n=me.LENS_SPACING_M;return[me.lamp("red",me.RED,i+n,e+me.GREEN_S+me.AMBER_S,me.CYCLE_S-me.GREEN_S-me.AMBER_S,me.VEHICLE_INTENSITY),me.lamp("amber",me.AMBER,i,e+me.GREEN_S,me.AMBER_S,me.VEHICLE_INTENSITY),me.lamp("green",me.GREEN,i-n,e,me.GREEN_S,me.VEHICLE_INTENSITY)]}static pedestrianLights(t){const e=t*me.CYCLE_S/2+me.GREEN_S+me.AMBER_S+me.PEDESTRIAN_DELAY_S,i=me.PEDESTRIAN_HEAD_Y_M,n=me.LENS_SPACING_M/2;return[me.lamp("ped-red",me.RED,i+n,e+me.PEDESTRIAN_GREEN_S,me.CYCLE_S-me.PEDESTRIAN_GREEN_S,me.PEDESTRIAN_INTENSITY),me.lamp("ped-green",me.GREEN,i-n,e,me.PEDESTRIAN_GREEN_S,me.PEDESTRIAN_INTENSITY)]}static isPedestrian(t){return t?.some(e=>e.id==="ped-green")??!1}static figureOf(t){return t.id==="ped-red"?"standing":t.id==="ped-green"?"walking":void 0}static lamp(t,e,i,n,s,r){const a=me.CYCLE_S,c=Math.round(((1-n/a)%1+1)%1*1e6)/1e6;return{id:t,color:e,intensity:r,radiusM:me.LENS_RADIUS_M,beamDeg:me.BEAM_DEG,offsetM:{x:0,y:i,z:-.13},pattern:{kind:"flash",perMinute:60/a,dutyCycle:Math.round(s/a*1e6)/1e6,...c?{phase:c}:{}}}}}class Md{static of(t,e){const i=Md.drawnAsModel(t);return{color:e?.color??!i,lit:e?.lit??Md.litByDefault(t.kind,i),headlights:t.kind==="vehicle",lights:(e?.lights??!0)&&Md.rigsFor(t.kind,e).length>0,windows:!i&&oE(t.kind),floors:!i&&t.kind==="building",observerSide:du(t.kind)}}static rigsFor(t,e){return J0.forKind(t).filter(i=>e?.lightRigs===void 0||e.lightRigs.includes(i.id))}static drawnAsModel(t){return _0(t)!==void 0&&!(t.observerSide!==void 0&&du(t.kind))}static litByDefault(t,e){return t==="streetlight"||t==="vehicle"&&!e}}class bi{static sideLabel(t){return bi.SIDE_LABELS[t]}static SIDE_LABELS={front:"front",behind:"behind",left:"left",right:"right","front-left":"frontLeft","front-right":"frontRight","behind-left":"behindLeft","behind-right":"behindRight"};static WINDOWS="windows";static BUILDING="building";static BRIDGE="bridge";static RAILING="railing";static WIRE="overheadLine";static together(t,e){return`${t} ${e}`}static of(t,e){const i=[],n=Md.drawnAsModel(t);if(!n&&t.kind==="building"&&i.push(...bi.floors(),...bi.walls(),...bi.roof()),!n&&oE(t.kind)&&i.push(...bi.windows(t.kind)),t.kind==="vehicle"&&i.push(...bi.engine()),t.kind==="observer"&&i.push(...bi.observerRecording()),t.kind==="aircraft"&&i.push(...bi.aircraftSound(e)),t.kind==="bridge"&&i.push(...bi.bridge()),t.kind==="wire"&&i.push(...bi.wire()),e?.parameters&&i.push(...e.parameters.map(s=>({...s,key:`modelParameters.${s.key}`}))),i.length!==0)return{kind:`decor-${t.kind}`,title:"properties",parameters:i}}static floors(){const t=e=>Oa.read(e,"floors")??A0;return[{type:"number",key:"floors",min:0,max:20,step:1,effective:()=>A0,label:"floors",hint:"upperStoriesAboveTheGround",group:bi.BUILDING},{type:"number",key:"occupiedFloor",min:0,max:20,step:1,effective:()=>0,bounds:e=>({max:t(e)}),label:"occupiedFloor",hint:"theFloorTheWitnessIs",group:bi.BUILDING}]}static walls(){const t="walls";return[{type:"colour",key:"facade.color",group:t,fallback:"#d3cab8",label:"wallColour",hint:"theColourOfTheWalls"},{type:"choice",key:"facade.openings",group:t,label:"facade",empty:"aHouseS",hint:"aHouseSAWindowEvery",choices:[{value:"tall",label:"oldBuilding"},{value:"lancet",label:"church"},{value:"plain",label:"bareWall"},{value:"none",label:"noFacade"}]}]}static roof(){const t="roof";return[{type:"choice",key:"roof.shape",group:t,label:"roof",empty:"flat",hint:"flatTheBoxTwoSlopes",choices:[{value:"flat",label:"flat"},{value:"gable",label:"twoSlopes"},{value:"hip",label:"fourSlopes"},{value:"dome",label:"dome"}]},{type:"number",key:"roof.riseM",min:0,max:15,step:.1,unit:"m",group:t,effective:()=>3,label:"rise",hint:"howFarTheRidgeStands",visibleWhen:i=>["gable","hip","dome"].includes(String(Oa.read(i,"roof.shape")))},{type:"choice",key:"roof.ridge",group:t,required:!1,label:"ridgeAlong",empty:"theWidth",choices:[{value:"width",label:"theWidth"},{value:"depth",label:"theDepth"}],visibleWhen:i=>Oa.read(i,"roof.shape")==="gable"},{type:"colour",key:"roof.color",group:t,fallback:"#7a5a4a",label:"roofColour"}]}static windows(t){return uT(t).map(e=>({type:"number",key:`windows.${e}`,step:5,unit:"%",min:fT(t,e)?0:dT,max:100,label:bi.SIDE_LABELS[e],summary:bi.together(bi.WINDOWS,bi.SIDE_LABELS[e]),hint:"opacityOfTheWindowOn",group:bi.WINDOWS}))}static engine(){const t="engineSound";return[{type:"choice",key:"engine.kind",group:t,label:"engine",hint:"whetherTheVehicleIsHeard",empty:"silentParked",choices:[{value:"car",label:"car"},{value:"van",label:"van"},{value:"truck",label:"truck"},{value:"motorcycle",label:"motorcycle"},{value:"generic",label:"unknown"}]},{type:"number",key:"engine.noise",min:.1,max:3,step:.1,group:t,effective:()=>1,label:"loudness",hint:"againstAnOrdinaryOneOf",visibleWhen:e=>Oa.read(e,"engine.kind")!==void 0||e.engine!==void 0}]}static observerRecording(){return[{type:"text",key:"sightingUrl",placeholder:"https://…/sighting.json",label:"theirOwnRecordingURL"}]}static aircraftSound(t){return[{type:"choice",key:"aircraftSound",group:"sound",label:"noiseInFlight",hint:"whatItSoundsLikeWhile",empty:t?.sound==="silent"?"silentAsTheModel":"asTheModel",choices:[{value:"airliner-narrow",label:"aircraftNarrowBodyAirliner"},{value:"airliner-wide",label:"aircraftWideBodyAirliner"},{value:"regional-jet",label:"aircraftRegionalJet"},{value:"regional-turboprop",label:"aircraftTurboprop"},{value:"business-jet",label:"aircraftBusinessJet"},{value:"light-piston",label:"aircraftLightPistonAircraft"},{value:"helicopter-light",label:"aircraftLightHelicopter"},{value:"helicopter-medium",label:"aircraftMediumHelicopter"},{value:"helicopter-heavy",label:"aircraftHeavyHelicopter"},{value:"military-jet",label:"aircraftMilitaryJet"},{value:"ultralight",label:"aircraftUltralight"},{value:"unmanned",label:"aircraftDrone"},{value:"glider",label:"aircraftGlider"},{value:"silent",label:"aircraftSilent"}]}]}static bridge(){const t=(e,i,n,s,r,a,c,l,h)=>({type:"number",key:e,label:i,min:n,max:s,step:r,unit:a,group:l,hint:h,effective:c===void 0?void 0:()=>c});return[t("bridge.spanM","span",.1,5e3,.1,"m",void 0,bi.BRIDGE,"metresOfOpenSpanUnder"),t("bridge.deckThicknessM","deckThickness",.1,20,.1,"m",1.2,bi.BRIDGE),t("bridge.railing.heightM","height",.1,5,.05,"m",1.05,bi.RAILING),t("bridge.railing.postSpacingM","postSpacing",.2,20,.1,"m",1.5,bi.RAILING),t("bridge.railing.rails","rails",0,8,1,"",2,bi.RAILING)]}static wire(){return[{type:"choice",key:"wire.poles",group:bi.WIRE,label:"poles",hint:"whichEndsStandOnA",choices:[{value:"both",label:"both"},{value:"start",label:"start"},{value:"end",label:"end"},{value:"none",label:"noPoles"}],effective:()=>"both"},{type:"number",key:"wire.diameterM",min:.001,max:.2,step:.001,unit:"m",effective:()=>.008,group:bi.WIRE,label:"strandThickness"},{type:"number",key:"wire.poleHeightM",min:.5,max:100,step:.1,unit:"m",group:bi.WIRE,label:"poleHeight",hint:"emptyHalfAMetreOver"}]}}class Vr{static NONE={id:"none",name:"No filter",opticalDensity:0};static SOLAR_VISUAL={id:"solar-visual",name:"Solar filter for the eye (OD 5)",opticalDensity:5,usableWith:["eye","binoculars","telescope"]};static SOLAR_PHOTO={id:"solar-photo",name:"Solar film for a camera (OD 3.8)",opticalDensity:3.8,usableWith:["camera","dslr","phone","telescope"]};static ALL=[Vr.NONE,Vr.SOLAR_VISUAL,Vr.SOLAR_PHOTO];static usableWith(t,e){return!t.usableWith||t.usableWith.includes(e.category)}static byId(t){return Vr.ALL.find(e=>e.id===t)??Vr.NONE}static transmittance(t){return 10**-t.opticalDensity}static magnitudes(t){return 2.5*t.opticalDensity}}class lM{constructor(t){this.names=t}name(t){return this.names[t.toLowerCase()]??t}stored(t){const e=t.trim().toLowerCase();for(const[i,n]of Object.entries(this.names))if(n.toLowerCase()===e)return i;return t.trim()}}class Vc{constructor(t,e,i,n=new lM({}),s,r={}){this.labels=t,this.naming=e,this.said=i,this.tags=n,this.timeWords=s,this.decorParameterTexts=r}entriesFor(t,e,i={}){const n=[];return this.addSummary(n,t),this.addObservation(n,t),this.addObserver(n,t,e),this.addLocation(n,t,e,i.groundElevationM,i.roadGradeDeg??0),this.addDecor(n,t,e,i),i.phenomena===!0&&this.addPhenomena(n,t,e),this.addTemporal(n,t),this.addWeather(n,t,e),this.addSound(n,t,e),n}push(t,e,i,n,s,r="",a={}){s===void 0||s===""||t.push({group:e,field:i,label:n,value:String(s),unit:r,color:a.color,fromSource:a.fromSource===!0})}percent(t){return t===void 0?void 0:`${Math.round(t*100)} %`}rounded(t,e=0){return t===void 0?void 0:String(Number(t.toFixed(e)))}shows(t,e=0){return t!==void 0&&Number(t.toFixed(e))!==0}showsPercent(t){return this.shows(t===void 0?void 0:t*100)}percentShown(t){return this.showsPercent(t)?this.percent(t):void 0}roundedShown(t,e=0){return this.shows(t,e)?this.rounded(t,e):void 0}static DESCRIPTION_WORDS=3;addSummary(t,e){const i=this.said.read(e.event.description)?.trim();if(!i)return;const n=i.split(/\s+/),s=n.length>Vc.DESCRIPTION_WORDS?`${n.slice(0,Vc.DESCRIPTION_WORDS).join(" ")}…`:i;this.push(t,"summary","description",this.labels.summaryDescription,s),t[t.length-1].full=i}addObservation(t,e){const i=e.event.tags;this.push(t,"observation","tags",this.labels.tags,i&&i.length>0?i.map(n=>this.tags.name(n)).join(", "):void 0)}filterName(t){return t===Vr.SOLAR_VISUAL?this.labels.filterSolarVisual:t===Vr.SOLAR_PHOTO?this.labels.filterSolarPhoto:t.name}addObserver(t,e,i){const n=e.observer;this.push(t,"observer","observerId",this.labels.observerId,n?.id),this.push(t,"observer","observerTitle",this.labels.observerTitle,this.said.read(n?.title)),this.push(t,"observer","observerLastName",this.labels.observerLastName,n?.lastName);const s=n?.firstNames;this.push(t,"observer","observerFirstNames",this.labels.observerFirstNames,s&&s.length>0?s.join(", "):void 0);const r=e.instrument;this.push(t,"observer","instrument",this.labels.instrument,this.naming.instrument(r));const a=e.exposure;this.push(t,"observer","exposureSeconds",this.labels.exposure,a===void 0?void 0:a<1?`1/${Math.round(1/a)}`:this.rounded(a,2),"s");const c=Pe(e,i);if(c){const l=_i.focalLengthMmFor(r,c.fovDeg);l===void 0?this.push(t,"observer","focalLength",this.labels.fieldOfView,this.rounded(c.fovDeg,1),"°"):this.push(t,"observer","focalLength",this.labels.focalLength,this.rounded(l,1),"mm"),this.push(t,"observer","fNumber",this.labels.aperture,this.rounded(c.fNumber??r.fNumber,1)),this.push(t,"observer","focusDistance",this.labels.focusDistance,this.rounded(c.focusDistanceM,1),"m"),this.push(t,"observer","roll",this.labels.roll,this.roundedShown(c.rollDeg),"°");const h=Vr.byId(c.filter);h!==Vr.NONE&&this.push(t,"observer","filter",this.labels.filter,this.filterName(h))}}degreesMinutesSeconds(t,e,i){if(t===void 0||!Number.isFinite(t))return;const n=Math.round(Math.abs(t)*3600),s=Math.floor(n/3600),r=Math.floor(n%3600/60),a=n%60;return`${s}°${String(r).padStart(2,"0")}′${String(a).padStart(2,"0")}″ ${this.naming.point(t<0?i:e)}`}static WALK_KMH=7;static SPEED_SPAN_MS=1e3;static speedKmhAt(t,e){const i=Vc.SPEED_SPAN_MS/2,n=Math.max(0,e-i),s=Pe(t,n),r=Pe(t,n+2*i);if(s?.lat===void 0||s.lng===void 0||r?.lat===void 0||r.lng===void 0)return;const a=(r.lat-s.lat)*111320,c=(r.lng-s.lng)*111320*Math.cos(s.lat*Math.PI/180);return Math.hypot(a,c)/(2*i/1e3)*3.6}addLocation(t,e,i,n,s){const r=e.event.place?.[0];this.push(t,"location","placeName",this.labels.placeName,r?.name);const a=Pe(e,i);if(!a)return;this.push(t,"location","lat",this.labels.latitude,this.degreesMinutesSeconds(a.lat,0,180)),this.push(t,"location","lng",this.labels.longitude,this.degreesMinutesSeconds(a.lng,90,270));const c=this.rounded(a.headingDeg);this.push(t,"location","heading",this.labels.heading,c,a.headingDeg===void 0?"°":`° (${this.naming.point(a.headingDeg)})`),this.push(t,"location","pitch",this.labels.pitch,a.pitchDeg===void 0?void 0:this.rounded(a.pitchDeg+s),"°");const l=Vc.speedKmhAt(e,i);l!==void 0&&l>Vc.WALK_KMH&&this.push(t,"location","speed",this.labels.speed,Math.round(l),"km/h"),n===void 0?this.push(t,"location","elevation",this.labels.heightAboveGround,this.roundedShown(a.elevationM),"m"):this.push(t,"location","elevation",this.labels.elevation,this.rounded(n+a.elevationM),"m")}addDecor(t,e,i,n){const s=e.decor.find(h=>h.id===n.decorId);if(!s){if(n.decorPicker===!0)for(const h of e.decor)this.push(t,"decor",`decor:${h.id}`,this.decorLabel(h),this.decorKindName(h.kind));return}this.push(t,"decor","decorBase.title",this.labels.decorTitle,this.said.read(s.title));const r=Xr(s,i);this.push(t,"decor","decorBase.eastM",this.labels.decorEast,this.rounded(r.eastM,1),"m"),this.push(t,"decor","decorBase.northM",this.labels.decorNorth,this.rounded(r.northM,1),"m"),this.push(t,"decor","decorBase.altitudeM",this.labels.decorAltitude,this.roundedShown(r.altitudeM),"m"),this.push(t,"decor","decorBase.headingDeg",this.labels.decorHeading,this.rounded(r.headingDeg),"°"),Sm(s,i)&&this.push(t,"decor","decorState.lit",this.labels.decorLit,"✓");const a=s.lights?.map(h=>h.id).join()??"",c=a===""?void 0:cM.find(h=>h.create().map(u=>u.id).join()===a);this.push(t,"decor","decorState.lightRig",this.labels.decorLights,c&&this.naming.lightRig(c)),this.push(t,"decor","decorState.observerSide",this.labels.decorObserverSide,this.decorSideName(s.observerSide));const l=bi.of(s);for(const h of(l&&Z0.resolve(l,this.decorParameterTexts))?.parameters??[]){const u=Oa.read(s,h.key);if(u==null)continue;const d=h.type==="choice"?this.said.read(h.choices.find(f=>f.value===u)?.label)??String(u):u;this.push(t,"decor",`decorParam.${h.key}`,this.said.read(h.summary??h.label)??h.key,typeof d=="boolean"?d?"✓":"":d,h.type==="number"?h.unit:void 0)}}timeText(t){return this.timeWords?xs.describeTime(t,this.timeWords.messages,this.timeWords.locale):wh(t)}addTemporal(t,e){const i=e.event;this.push(t,"temporal","obs-time",this.labels.observationTime,i.time&&this.timeText(i.time)),this.push(t,"temporal","obs-end-time",this.labels.observationEndTime,i.endTime&&this.timeText(i.endTime));const n=rE(i);this.push(t,"temporal","durationSeconds",this.labels.duration,this.roundedShown(n&&n/1e3,1),"s"),this.push(t,"temporal","timeZone",this.labels.utcOffset,i.timeZone),this.push(t,"temporal","utcOffsetHours",this.labels.utcOffset,this.rounded(i.utcOffsetHours,1),"UTC±h")}addWeather(t,e,i){const n=ph(e,i),r={fromSource:e.weatherSource!==void 0},a=this.showsPercent(n.cloudCover)||this.showsPercent(n.lowerCloudCover)||this.showsPercent(n.highCloudCover);this.push(t,"weather","cloudCover",this.labels.cloudCover,this.percentShown(n.cloudCover),"",r),this.push(t,"weather","highCloudCover",this.labels.highCloudCover,this.percentShown(n.highCloudCover),"",r),this.push(t,"weather","iceCrystalAlignment",this.labels.iceCrystalAlignment,this.showsPercent(n.highCloudCover)?this.percent(n.iceCrystalAlignment):void 0),this.push(t,"weather","rareIceCrystals",this.labels.rareIceCrystals,this.showsPercent(n.highCloudCover)?this.percent(n.rareIceCrystals):void 0),this.push(t,"weather","cloudDarkness",this.labels.cloudDarkness,a?this.percent(n.cloudDarkness):void 0,"",r),this.push(t,"weather","cloudBase",this.labels.cloudBase,a?this.rounded(n.cloudBaseM):void 0,"m",r);const c=n.precipitationType!=="none"&&this.showsPercent(n.precipitationIntensity);this.push(t,"weather","precipitationType",this.labels.precipitationType,c?this.precipitationName(n.precipitationType):void 0,"",r),this.push(t,"weather","precipitationIntensity",this.labels.precipitationIntensity,c?this.percent(n.precipitationIntensity):void 0,"",r),this.push(t,"weather","windDirection",this.labels.windDirection,this.shows(n.windSpeed,2)?this.rounded(n.windDirectionDeg):void 0,"°",r),this.push(t,"weather","windSpeed",this.labels.windSpeed,this.roundedShown(n.windSpeed,2),"m/s",r),n.storm&&this.push(t,"weather","storm",this.labels.storm,"✓","",r)}addSound(t,e,i){const n=aE(e,i);n.kind!=="none"&&(this.push(t,"sound","soundKind",this.labels.soundKind,this.soundKindName(n.kind)),this.push(t,"sound","soundVolume",this.labels.soundVolume,this.percentShown(n.volume)),this.push(t,"sound","soundPitch",this.labels.soundPitch,this.roundedShown(n.pitchHz),"Hz"),this.push(t,"sound","soundSrc",this.labels.soundSrc,n.src))}addPhenomena(t,e,i){for(const n of e.timeline.sourceIds){const s=e.timeline.getInterpolatedShapeAt(i,n),r=s?.angular,a=r?`${this.rounded(r.widthDeg,2)} × ${this.rounded(r.heightDeg,2)}°`:void 0;this.push(t,"phenomenon",`shape:${n}`,this.said.read(s?.title)??n,a)}for(const n of e.interpretation?.bodies??[]){const s=n.track.find(a=>a.sizeM?.widthM!==void 0)?.sizeM?.widthM,r=n.model.id??n.model.url?.replace(/^.*\//,"");this.push(t,"phenomenon",`body:${n.id}`,this.said.read(n.title)??n.id,[r,s!==void 0?`${this.rounded(s,2)} m`:void 0].filter(Boolean).join(", "))}}decorLabel(t){return this.said.read(t.title)??this.decorKindName(t.kind)}decorKindName(t){switch(t){case"building":return this.labels.decorBuilding;case"tree":return this.labels.decorTree;case"shrub":return this.labels.decorShrub;case"bridge":return this.labels.decorBridge;case"wire":return this.labels.decorWire;case"crop":return this.labels.decorCrop;case"terrace":return this.labels.decorTerrace;case"mound":return this.labels.decorMound;case"wall":return this.labels.decorWall;case"streetlight":return this.labels.decorStreetlight;case"trafficlight":return this.labels.decorTrafficLight;case"crossing":return this.labels.decorCrossing;case"roadsign":return this.labels.decorRoadSign;case"vehicle":return this.labels.decorVehicle;case"aircraft":return this.labels.decorAircraft;default:return this.labels.decorObserver}}decorSideName(t){switch(t){case"front":return this.labels.decorSideFront;case"behind":return this.labels.decorSideBehind;case"left":return this.labels.decorSideLeft;case"right":return this.labels.decorSideRight;case"front-left":return this.labels.decorSideFrontLeft;case"front-right":return this.labels.decorSideFrontRight;case"behind-left":return this.labels.decorSideBehindLeft;case"behind-right":return this.labels.decorSideBehindRight;default:return}}precipitationName(t){switch(t){case"rain":return this.labels.precipitationRain;case"snow":return this.labels.precipitationSnow;case"hail":return this.labels.precipitationHail;default:return this.labels.precipitationNone}}soundKindName(t){switch(t){case"hum":return this.labels.soundHum;case"whistle":return this.labels.soundWhistle;case"rumble":return this.labels.soundRumble;case"crackle":return this.labels.soundCrackle;default:return this.labels.soundNone}}}const c8="Global Meteor Network",l8="https://globalmeteornetwork.org/data/",h8="“Thunder” by Jerimee",u8="https://creativecommons.org/licenses/by/3.0/",d8="CC BY 3.0";class Yn{static fill(t,e){t.innerHTML="";const i=d=>t.appendChild(d),n=e.currentTerrainAttribution;n&&i(Yn.text(n));const s=e.currentRoadAttribution;s&&i(Yn.text(s));const r=e.currentWaterAttribution;r&&i(Yn.text(r));const a=e.currentRailwayAttribution;a&&i(Yn.text(a));const c=e.ufoElement.observerMapCredit;c&&!n?.includes(c)&&i(Yn.text(c));for(const d of e.decorModelCredits){const f=d.author?` — ${d.author}`:"",p=document.createElement("li");d.sourceUrl?p.append(Yn.link(d.sourceUrl,d.title),document.createTextNode(`${f} (${d.license})`)):p.textContent=`${d.title}${f} (${d.license})`,i(p)}for(const d of e.ufoElement.sighting.references){if(!d.credit)continue;const f=document.createElement("li");d.creditUrl?f.appendChild(Yn.link(d.creditUrl,d.credit)):f.textContent=d.credit,i(f)}if(e.ufoElement.sighting.traces.length>0){const d=new Qn(Ws.preferencesFor(e)),f=new Set(e.ufoElement.sighting.traces.map(p=>d.read(p.source)).filter(p=>!!p));for(const p of f)i(Yn.text(p))}const l=e.satelliteState;if(l.status==="ready"&&l.credit){const d=document.createElement("li");d.appendChild(Yn.link(l.creditUrl??"",l.credit)),i(d)}if(e.fireballState.status==="ready"&&e.fireballState.records.length>0){const d=document.createElement("li");d.append(Yn.link(l8,c8),document.createTextNode(" (CC BY 4.0)")),i(d)}const h=e.aircraftState;if(h.status==="ready"&&h.shown>0){const d=document.createElement("li");if(d.appendChild(Yn.link(h.creditUrl,h.credit)),i(d),h.trailCredit){const f=document.createElement("li");f.appendChild(Yn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(f)}}const u=Yn.text(`${h8} (`);u.append(Yn.link(u8,d8),document.createTextNode(")")),i(u)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const f8=Re.point("assessment").provide(Re.BUILT_IN,[{id:"coverage",name:"Coverage",credit:"UFO@home",creditUrl:"https://ufoathome.org",create:()=>({about:"observer",assess:async o=>{const{CoverageAssessor:t}=await at(async()=>{const{CoverageAssessor:e}=await import("./CoverageAssessor-BSoRnjHD.js");return{CoverageAssessor:e}},[],import.meta.url);return new t().assess(o)}})},{id:"hynek",name:"Hynek",credit:"J. Allen Hynek",creditUrl:"https://rr0.org/science/crypto/ufo/observation/classification/hynek/",create:()=>({about:"temporal",assess:async o=>{const{HynekAssessor:t}=await at(async()=>{const{HynekAssessor:e}=await import("./HynekAssessor-CJ9APziM.js");return{HynekAssessor:e}},__vite__mapDeps([2,3]),import.meta.url);return new t().assess(o)}})},{id:"ballester-guasp",name:"Ballester-Guasp",credit:"V.-J. Ballester-Olmos & M. Guasp",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/Ballester-Guasp.html",create:()=>({about:"observer",assess:async o=>{const{BallesterGuaspAssessor:t}=await at(async()=>{const{BallesterGuaspAssessor:e}=await import("./BallesterGuaspAssessor-CLQvJKlm.js");return{BallesterGuaspAssessor:e}},__vite__mapDeps([4,3,5]),import.meta.url);return new t().assess(o)}})},{id:"poher",name:"Poher",credit:"Claude Poher",creditUrl:"https://rr0.org/science/crypto/ufo/enquete/methode/Poher-Criteres.html",create:()=>({about:"shape",assess:async o=>{const{PoherAssessor:t}=await at(async()=>{const{PoherAssessor:e}=await import("./PoherAssessor-DDRUgnRW.js");return{PoherAssessor:e}},[],import.meta.url);return new t().assess(o)}})}]);class Oy{constructor(t){this.labels=t}async read(t){const e=[],i=new Set;for(const n of f8){let s;try{s=await n.create().assess(t)}catch{continue}for(const a of s.criteria)a.basis===void 0&&!a.unsupported&&i.add(a.id);const r=s.score===void 0?s.verdict===void 0?"":this.verdictName(n.id,s.verdict):`${Math.round(s.score*100)}%`;r!==""&&e.push({group:"assessment",field:n.id,label:this.labels.assessmentNames[n.id]??n.name,value:r,unit:"",fromSource:!1,about:n.create().about,...s.factors?{detail:Oy.factorsText(s.factors)}:{}})}return{entries:e,unanswered:i}}static factorsText(t){const e={q:"Q",sigma:"Σ",pi:"Π"};return Object.entries(t).map(([i,n])=>`${e[i]??i} ${n.toFixed(2)}`).join(" × ")}verdictName(t,e){return this.labels.assessmentVerdicts[`${t}.${e}`]??e.toUpperCase()}}class _h{static HALF_SPAN_MS=2e3;static MIN_SPEED_MS=1;static at(t,e,i){const n=t.event.place?.[0],s=t.observerTrack;if(!n)return 0;const r=m=>{const g=s.getInterpolatedPoseAt(Math.max(0,m));if(!g||g.lat===void 0||g.lng===void 0)return;const v=re(g.lat,g.lng,n.lat,n.lng);return{eastM:v.x,northM:-v.z,heading:g.headingDeg}},a=r(e-_h.HALF_SPAN_MS),c=r(e+_h.HALF_SPAN_MS),l=r(e);if(!a||!c||!l)return 0;const h=Math.hypot(c.eastM-a.eastM,c.northM-a.northM),u=2*_h.HALF_SPAN_MS/1e3;if(h/u<_h.MIN_SPEED_MS)return 0;const d=i.heightAt(c.eastM,c.northM)-i.heightAt(a.eastM,a.northM),f=Math.atan2(d,h)*180/Math.PI;if(l.heading===void 0)return f;const p=Math.atan2(c.eastM-a.eastM,c.northM-a.northM)*180/Math.PI;return f*Math.max(0,Math.cos((l.heading-p)*Math.PI/180))}}class lr{static sessionDeclared=!1;static isLive(t){return t!==void 0&&typeof AudioContext<"u"&&t instanceof AudioContext}static unlock(t){if(lr.declarePlayback(),t.state!=="running")try{Promise.resolve(t.resume()).catch(()=>{});const e=t.createBufferSource();e.buffer=t.createBuffer(1,1,22050),e.connect(t.destination),e.start(0)}catch{}}static declarePlayback(){if(!(lr.sessionDeclared||typeof navigator>"u")){lr.sessionDeclared=!0;try{const t=navigator.audioSession;t&&(t.type="playback")}catch{}}}}const p8=.08,Yx=.15,Kx=2,m8=2e3;class qx{context;constructor(t){this.context=t}noiseBuffer;voices=new Map;level=1;master;paused=!0;requested=[];resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("VehicleAudio: Web Audio unavailable, vehicles stay silent:",t);return}}lr.isLive(this.context)&&lr.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t){this.requested=t,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);lr.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0}masterOf(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested.filter(n=>n.inside||n.distanceM<m8),i=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])i.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n.id);this.retarget(t,s,n)}}build(t,e){const i=t.createGain();i.gain.value=0;const n=t.createBiquadFilter();n.type="lowpass",n.connect(i).connect(this.masterOf(t));const s=t.createOscillator();s.type="sawtooth";const r=t.createOscillator();r.type="sine";const a=t.createGain(),c=t.createBiquadFilter();c.type="lowpass",c.frequency.value=900,s.connect(c),r.connect(c),c.connect(a).connect(n);const l=()=>{const x=t.createBufferSource();return x.buffer=this.noise(t),x.loop=!0,x.loopStart=Math.random()*Kx*.5,x},h=l(),u=t.createBiquadFilter();u.type="bandpass",u.Q.value=4;const d=t.createGain();h.connect(u).connect(d).connect(n);const f=l(),p=t.createBiquadFilter();p.type="lowpass",p.frequency.value=600;const m=t.createGain();f.connect(p).connect(m).connect(n);const g=l(),v=t.createBiquadFilter();v.type="bandpass",v.frequency.value=1400,v.Q.value=.7;const M=t.createGain();g.connect(v).connect(M).connect(n);const w=[s,r,h,f,g];for(const x of w)x.start();const y={nodes:[i,n,a,c,u,d,p,m,v,M,...w],sources:w,firing:s,crank:r,knock:u,engineGain:a,knockGain:d,roadGain:m,windGain:M,cabin:n,output:i};return this.voices.set(e,y),y}retarget(t,e,{profile:i,state:n,noise:s,inside:r,windowsOpen:a,distanceM:c}){const l=t.currentTime,h=(M,w)=>M.setTargetAtTime(w,l,p8),u=n.rpm/60,d=u*i.cylinders/2,f=Math.min(1,n.rpm/i.shiftUpRpm),p=Math.min(1.5,n.speedMps/30);h(e.firing.frequency,d),h(e.crank.frequency,u),h(e.knock.frequency,d*3),h(e.engineGain.gain,i.engineGain*(.25+.75*n.load)*(.5+.5*f)*.3),h(e.knockGain.gain,i.roughness*(.2+.8*n.load)*.4),h(e.roadGain.gain,i.roadGain*p**1.5*.8);const m=!r||a;h(e.windGain.gain,p**2*(m?.5:.06));const g=r?a?3500:700:8e3/(1+c/60);h(e.cabin.frequency,g);const v=r?.5:Math.min(1,8/Math.max(c,1));h(e.output.gain,v*s)}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const i=this.context;i&&(e.output.gain.setTargetAtTime(0,i.currentTime,Yx/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},Yx*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*Kx,t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class mf{static BY_KIND={car:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},generic:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},van:{cylinders:4,idleRpm:750,kmhPer1000Rpm:[7,12,19,27,35,42],shiftUpRpm:2600,shiftDownRpm:1200,engineGain:.8,roadGain:.7,roughness:.45},truck:{cylinders:6,idleRpm:600,kmhPer1000Rpm:[5,8,12,17,23,30,38,48],shiftUpRpm:1900,shiftDownRpm:1e3,engineGain:1,roadGain:.9,roughness:.55},motorcycle:{cylinders:2,idleRpm:1100,kmhPer1000Rpm:[12,18,24,30,35,40],shiftUpRpm:6e3,shiftDownRpm:2500,engineGain:.9,roadGain:.3,roughness:.3}};static of(t){return mf.BY_KIND[t??"generic"]??mf.BY_KIND.generic}}class Jn{static ROAD_KINDS=["car","van","truck","motorcycle","generic"];static OPEN_AIR=[0,0,0,0,0,0,0,0];static ROAD_CLOSED_DB=[10,14,18,22,25,28,30,32];static WINDOWS_OPEN_DB=[2,3,4,5,6,7,8,9];static FUSELAGE_DB=[14,18,23,28,32,36,38,40];static CANOPY_DB=[3,4,6,8,10,12,14,16];static CANOPIED=["glider","balloon","ultralight"];static isRoad(t){return Jn.ROAD_KINDS.includes(t)}static roadOf(t){return t&&Jn.isRoad(t.kind)?t.kind:void 0}static aircraftOf(t){return t&&!Jn.isRoad(t.kind)?t.kind:void 0}static transmission(t){const e=Jn.insulationDb(t),i=[3,4,5].map(n=>e[n]);return 10**(-(i.reduce((n,s)=>n+s,0)/i.length)/20)}static insulationDb(t){return t?t.windowsOpen===!0?Jn.WINDOWS_OPEN_DB:Jn.isRoad(t.kind)?Jn.ROAD_CLOSED_DB:Jn.CANOPIED.includes(t.kind)?Jn.CANOPY_DB:Jn.FUSELAGE_DB:Jn.OPEN_AIR}}class il{constructor(t,e){this.samples=t,this.startMs=e}static SAMPLE_MS=100;static STANDING_MPS=.3;static of(t,e,i,n){const s=il.SAMPLE_MS,r=[];for(let l=i;l<=n+s/2;l+=s){const h=e(l-s/2),u=e(l+s/2);if(!h||!u)return;r.push(Math.hypot(u.eastM-h.eastM,u.northM-h.northM)/(s/1e3))}const a=[];let c=1;for(let l=0;l<r.length;l++){const h=r[l],u=(r[Math.min(l+1,r.length-1)]-r[Math.max(l-1,0)])/(2*s/1e3);if(h<il.STANDING_MPS){c=1,a.push({speedMps:h,rpm:t.idleRpm,load:.1,gear:0});continue}const d=h*3.6,f=v=>d/t.kmhPer1000Rpm[v-1]*1e3;for(;c<t.kmhPer1000Rpm.length&&f(c)>t.shiftUpRpm;)c++;for(;c>1&&f(c)<t.shiftDownRpm;)c--;const p=Math.max(f(c),t.idleRpm*(1+.3*Math.min(1,h/3))),m=.15+.5*Math.min(1,(h/35)**2),g=u>.15?Math.min(1,m+u/2.5):u<-.3?.05:m;a.push({speedMps:h,rpm:p,load:g,gear:c})}return new il(a,i)}at(t){const e=(t-this.startMs)/il.SAMPLE_MS,i=Math.min(Math.max(Math.floor(e),0),this.samples.length-1),n=this.samples[i],s=this.samples[Math.min(i+1,this.samples.length-1)],r=Math.min(Math.max(e-i,0),1);return{speedMps:n.speedMps+(s.speedMps-n.speedMps)*r,rpm:n.rpm+(s.rpm-n.rpm)*r,load:n.load+(s.load-n.load)*r,gear:r<.5?n.gear:s.gear}}}class j0{drives=new Map;at(t,e){const i=[],n=t.event.place?.[0],s=h=>{const u=t.observerTrack.getInterpolatedPoseAt(h),d=u?.lat??n?.lat,f=u?.lng??n?.lng;if(d===void 0||f===void 0||!n)return;const p=re(d,f,n.lat,n.lng);return{eastM:p.x,northM:-p.z}},r=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),a=t.vehicle,c=Jn.roadOf(a);if(a&&c){const h=mf.of(c),u=this.drive(`observer:${c}`,j0.trackKey(t),()=>il.of(h,s,0,r));u&&i.push({id:"observer",profile:h,state:u.at(e),noise:a.noise??1,inside:!0,windowsOpen:a.windowsOpen===!0,distanceM:0})}const l=s(e);for(const h of t.decor){if(!h.engine||!l)continue;const u=mf.of(h.engine.kind),d=g=>{const v=Xr(h,g);return{eastM:v.eastM,northM:v.northM}},f=this.drive(`decor:${h.id}`,j0.decorKey(h,r),()=>il.of(u,d,0,r));if(!f)continue;const p=Xr(h,e),m=Math.hypot(p.eastM-l.eastM,p.northM-l.northM,p.altitudeM);i.push({id:`decor:${h.id}`,profile:u,state:f.at(e),noise:h.engine.noise??1,inside:!1,windowsOpen:!0,distanceM:m})}return i}drive(t,e,i){const n=this.drives.get(t);if(n&&n.key===e)return n.drive;const s=i();return this.drives.set(t,{key:e,drive:s}),s}static trackKey(t){return t.observerTrack.allKeyframes.map(i=>`${i.t}:${i.pose.lat}:${i.pose.lng}`).join(";")}static decorKey(t,e){return`${e}|${t.eastM},${t.northM}|`+(t.track??[]).map(i=>`${i.t}:${i.eastM}:${i.northM}`).join(";")}}const Zx=864e5,Jx=4e4;function g8(o){const t=Math.floor(o.getTime()/Zx);return{elapsedMs:o.getTime()-t*Zx,shiftM:{x:jx.unit(t,2654435761)*Jx,z:jx.unit(t,2246822507)*Jx}}}class jx{static unit(t,e){let i=Math.imul(t|0,e)^e;return i=Math.imul(i^i>>>15,739982445),i=Math.imul(i^i>>>12,695872825),i^=i>>>15,(i>>>0)/4294967295*2-1}}function Qx(o,t,e,i,n,s,r){const a=i?.lat!==void 0&&i.lng!==void 0&&n?.lat!==void 0&&n.lng!==void 0?re(n.lat,n.lng,i.lat,i.lng):{x:0,z:0};if(r){const h=t.getInterpolatedWeatherAt(0)??e,u=s===void 0?void 0:h.cloudLayers?.find(p=>p.id===s),d=(u?.windDirectionDeg??h.windDirectionDeg)*Math.PI/180,f=(u?.windSpeed??h.windSpeed)*r.elapsedMs/1e3;a.x+=r.shiftM.x-Math.sin(d)*f,a.z+=r.shiftM.z+Math.cos(d)*f}const c=Math.max(0,o),l=[0,...t.allKeyframes.map(h=>h.t).filter(h=>h>0&&h<c),c];for(let h=1;h<l.length;h++){const u=l[h-1],d=l[h]-u;if(d===0)continue;const f=32;for(let p=0;p<=f;p++){const m=t.getInterpolatedWeatherAt(u+d*p/f)??e,g=s===void 0?void 0:m.cloudLayers?.find(y=>y.id===s),v=(g?.windDirectionDeg??m.windDirectionDeg)*Math.PI/180,M=p===0||p===f?1:p%2===0?2:4,w=(g?.windSpeed??m.windSpeed)*d/1e3/f/3*M;a.x-=Math.sin(v)*w,a.z+=Math.cos(v)*w}}return a}const v8="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAARVBMVEX9sST/uyTfoCjNlSikfCqRcCx8Yy21hipTSi4TITEMHTEuMzBqWC3/wSRUX207SFj8/PyaoakmNUd5gYxBPy90fIfMz9RsB4kZAAACEUlEQVRo3u2XyXbDIAxFLeapjts6/f9PrQA3JymT25Cd3iY5xtYVIB6wLCQSiUQikUgk0nzBoVdFZ1xIpaTQbJnPACaNdYeskWwuAhaZoltnUemfnNkL4N49KEI8n0YAEXMvEWISAWQZPw2Xk1MIoF1dSNAzCMy6JsGyCR0wrkMwT3cBeDt+FH8aEHoA68LbM8HRHXQ3f0RE3/jXOOFX+s4djrKpIbzS7K+MmLrxlWCNR8mczjMw92Ar4dZLDXG4kzXinAECcOUPL3jMdN2294/GQGVG4EMHxORNJXoCfG6oT1trvDGM7iIA9N6aTOuuEbB9ra6FyCYr2gjge+fjA4CIi2uujYRoOBSw0A5/D0hT0X4PW0xtuotNpQPYtkt/fdtyM0LP6ZvOI2DtvoxtJWHvx38AxIkevLwXQ2TOA66DziYfLwC4r5wbIlwJo1ys8+VOBMy7/sxdjwIap49lVC3UePZp1mmyit4SuGUf11pjoTHVRVzXUaXFVt87kuEBsWZ055Q+2sXA76LbZYsvKR1ubvJqbKd5swl+GPI31p6L/sNYuDTe3jo+GBdr1J+P9PGawbRUw9VhleD/3ffT9uZ7DhtX1JNHL2CmNRXxYZhwSwBd3aJTyU85/GKOwhxBf5RnVk+75OSiuu+Ax4PQ3Jsg1hTeMUMwJgQp+PKCe2a+JuefFwQnkUgkEolEIpFerW8TL0hlNl2QVAAAAABJRU5ErkJggg==",M8=`
|
|
4895
4895
|
<div class="stage" id="stage">
|
|
4896
4896
|
<div class="frame" id="frame">
|
|
4897
4897
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -6813,9 +6813,9 @@ canvas[data-cursor="rotate"] {
|
|
|
6813
6813
|
`;class Qh{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.observerTrack.allKeyframes){const{lat:n,lng:s,headingDeg:r}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:r})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new Qh(e)}static TRAVEL_M=50;get travels(){return this.spanM>Qh.TRAVEL_M}get moved(){return this.spanM>Qh.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(re(e,t.east,e,t.west).x),Math.abs(re(t.north,i,t.south,i).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:$s(0,-s,i,n).lat,south:$s(0,s,i,n).lat,east:$s(s,0,i,n).lng,west:$s(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class gr{constructor(t,e){this.rotationPassed=t,this.scale=e}static SWAY_M=.012;static BREATH_M=.003;static DRIFT_YAW_DEG=.5;static DRIFT_PITCH_DEG=.4;static DRIFT_ROLL_DEG=.3;static GAZE_DRIFT_SHARE=.35;static HAND_HELD_S=.5;static HZ=[.11,.23,.17,.29,.37,.07];static of(t){if(t.instrument.mounted)return;const e=t.event.tags?.includes("paralysis")||(t.exposure??0)>gr.HAND_HELD_S,i=t.sway??(e?0:1);if(i>0)return new gr(Math.max(1-(t.instrument.stabilization??0),gr.GAZE_DRIFT_SHARE),i)}offsetAt(t){const e=t/1e3,i=this.scale,n=(u,d)=>Math.sin(2*Math.PI*u*e+d),[s,r,a,c,l,h]=gr.HZ;return{eastM:i*gr.SWAY_M*(.7*n(s,.3)+.3*n(c,1.9)),northM:i*gr.SWAY_M*(.6*n(a,2.2)+.4*n(l,.8)),upM:i*gr.BREATH_M*n(r,0),yawDeg:i*this.rotationPassed*gr.DRIFT_YAW_DEG*(.6*n(h,1.1)+.4*n(c,2.7)),pitchDeg:i*this.rotationPassed*gr.DRIFT_PITCH_DEG*(.5*n(r,1.6)+.5*n(a,.4)),rollDeg:i*this.rotationPassed*gr.DRIFT_ROLL_DEG*n(s,2.9)}}}class li{constructor(t,e){this.stretches=t,this.rotationPassed=e}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STOP_LURCH_M=.035;static STOP_PITCH_DEG=3;static START_LURCH_M=.015;static START_PITCH_DEG=1.2;static JOLT_HZ=1.4;static JOLT_DECAY_S=.35;static JOLT_LASTS_MS=1500;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(t){const e=Qh.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const r=e.points[s-1],a=e.points[s],c=(a.t-r.t)/1e3;if(c<=0)continue;const l=re(a.lat,a.lng,r.lat,r.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=li.stepHzFor(f);i.push({startMs:r.t,endMs:a.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const r=i[s-1],a=i[s+1];i[s].rampsIn=r===void 0||r.stepHz===0,i[s].rampsOut=a===void 0||a.stepHz===0}if(i.some(s=>s.stepHz>0))return new li(i,1-(t.instrument.stabilization??0))}static bodyAt(t,e,i=!1){const n=li.of(t)?.offsetAt(e)??li.STILL;return i?n:li.add(n,gr.of(t)?.offsetAt(e))}static stepHzFor(t){return t<li.SLOWEST_WALK_M_PER_S||t>li.FASTEST_WALK_M_PER_S?0:li.REFERENCE_STEP_HZ*Math.pow(t/li.REFERENCE_SPEED_M_PER_S,li.CADENCE_EXPONENT)}offsetAt(t){return li.add(this.cycleAt(t),this.joltAt(t))}joltAt(t){for(const e of this.stretches){if(e.stepHz===0)continue;const i=e.speedMPerS/li.REFERENCE_SPEED_M_PER_S,n=(a,c,l,h)=>{if(a<0||a>li.JOLT_LASTS_MS)return;const u=a/1e3,d=Math.exp(-u/li.JOLT_DECAY_S)*Math.sin(2*Math.PI*li.JOLT_HZ*u),f=h*c*i*d;return{eastM:f*e.eastUnit,northM:f*e.northUnit,upM:-Math.abs(f)*.3,rollDeg:0,pitchDeg:-h*l*i*d*this.rotationPassed,yawDeg:0}},s=e.rampsOut?n(t-e.endMs,li.STOP_LURCH_M,li.STOP_PITCH_DEG,1):void 0;if(s)return s;const r=e.rampsIn?n(t-e.startMs,li.START_LURCH_M,li.START_PITCH_DEG,-1):void 0;if(r)return r}}static add(t,e){return e?{eastM:t.eastM+e.eastM,northM:t.northM+e.northM,upM:t.upM+e.upM,rollDeg:t.rollDeg+e.rollDeg,pitchDeg:t.pitchDeg+e.pitchDeg,yawDeg:t.yawDeg+e.yawDeg}:t}cycleAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return li.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),r=li.SWAY_M*s*Math.cos(n/2),a=s*this.rotationPassed*e.speedMPerS/li.REFERENCE_SPEED_M_PER_S;return{eastM:r*e.northUnit,northM:-r*e.eastUnit,upM:li.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:li.HEAD_ROLL_DEG*a*Math.cos(n/2),pitchDeg:-1.25*a*Math.cos(n),yawDeg:li.HEAD_YAW_DEG*a*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,r=t.endMs-e,a=Math.min(t.rampsIn?s/n:1,t.rampsOut?r/n:1,1);return(1-Math.cos(Math.PI*Math.max(a,0)))/2}}class b8{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const BA=["nw","n","ne","e","se","s","sw","w"],S8=24,xp=8,E8=3,A8=8;function bp(o,t,e){const i=o.x-t.x,n=o.y-t.y,s=Math.cos(e),r=Math.sin(e);return{x:t.x+i*s-n*r,y:t.y+i*r+n*s}}function Xu(o){return{x:o.x+o.width/2,y:o.y+o.height/2}}const _8={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class nr{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,r={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-S8}},a=Xu(t.bounds),c={};for(const l of Object.keys(r))c[l]=bp(r[l],a,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...BA,"rotate"]){const s=nr.handlePointsFor(t);for(const r of n)if(Math.hypot(e.x-s[r].x,e.y-s[r].y)<=i)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((nr.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Xu(t),r=bp(n,s,-e),{x:a,y:c,width:l,height:h}=t,u=_8[i];let d=a,f=c,p=a+l,m=c+h;return u.left&&(d=Math.min(r.x,p-xp)),u.right&&(p=Math.max(r.x,d+xp)),u.top&&(f=Math.min(r.y,m-xp)),u.bottom&&(m=Math.max(r.y,f+xp)),{x:d,y:f,width:p-d,height:m-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,r=nr.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:r};const a=n===0?1:r.width/n,c=s===0?1:r.height/s;return{...t,bounds:r,points:t.points.map(l=>({x:l.x*a,y:l.y*c}))}}static rotateShape(t,e){const i=Xu(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),n=Math.max(...t.map(r=>r.x+r.width)),s=Math.max(...t.map(r=>r.y+r.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Xu(t.bounds);return t.points.map(i=>bp({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=A8){const n=nr.vertexPointsFor(t);let s,r=i;return n.forEach((a,c)=>{const l=Math.hypot(e.x-a.x,e.y-a.y);l<=r&&(r=l,s=c)}),s}static toLocalPoint(t,e){const i=Xu(t.bounds),n=bp(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?nr.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),r=Math.min(...n.map(u=>u.y)),a=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+r,width:a-s,height:c-r},h=n.map(u=>({x:u.x-s,y:u.y-r}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=nr.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,r=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=nr.distanceToSegment(i,l,h);u<r&&(r=u,s=c)}const a=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:a}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,r=n*n+s*s,a=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/r)),c=e.x+a*n,l=e.y+a*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=E8?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const hM=6,Sp=hM/2,tb=20,eb=24,ib=9,nb=6,sb=7,rb=6,ea=4;class yu{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:i,width:n,height:s}=t.bounds,r=e+n/2,a=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+ib*f),rb*f)-d:0,m=f>0?d*(1+sb*f)-d:0,g=3*eb*(t.blur??0)+1.5*tb*t.haloScale,v=Math.max(p,m,0)+g+2;return{x:r-h-v,y:a-u-v,width:2*(h+v),height:2*(u+v)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(eb*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:i,y:n,width:s,height:r}=t.bounds,a=i+s/2,c=n+r/2,l=Math.max(s,r)/2,h=Math.max(l*(1+ib*e),rb*e);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(a,c,0,a,c,h);for(let d=0;d<=nb;d++){const f=d/nb,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(a,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+sb*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,m=a+Math.cos(p)*d,g=c+Math.sin(p)*d,v=this.ctx.createLinearGradient(a,c,m,g);v.addColorStop(0,this.withAlpha(t.color,e*.55)),v.addColorStop(.35,this.withAlpha(t.color,e*.22)),v.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=v,this.ctx.beginPath(),this.ctx.moveTo(a,c),this.ctx.lineTo(m,g),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=r=>Math.round(r+(255-r)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,r=n/2,a=s/2;this.ctx.ellipse(e+r,i+a,r,a,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((r,a)=>{a===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=tb*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(nr.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of nr.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,ea,ea,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(nr.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const r=yu.landmarkColour(s.residualDeg),a=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=a+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,ea+2,ea+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=r,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=r,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,ea,ea,0,0,2*Math.PI),n.fill()),n.strokeStyle=r,n.lineWidth=a,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,ea+2,ea+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+ea+5,s.picture.y-ea-2,r)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}paintGhosts(t,e,i){const n=this.ctx;n.save();const s=(c,l,h,u=[])=>{n.setLineDash(u),n.lineWidth=h+2,n.strokeStyle="rgba(0, 0, 0, 0.6)",c(),n.lineWidth=h,n.strokeStyle=l,c(),n.setLineDash([])},r=(c,l)=>()=>{n.beginPath(),n.arc(c.x,c.y,l,0,2*Math.PI),n.stroke()},a=(c,l,h)=>()=>{const[u,d]=h?[l,l]:[l,0];n.beginPath(),n.moveTo(c.x-u,c.y-d),n.lineTo(c.x+u,c.y+d),n.moveTo(c.x+d,c.y-u),n.lineTo(c.x-d,c.y+u),n.stroke()};for(const c of t)s(()=>{n.beginPath(),n.moveTo(c.ghost.x,c.ghost.y),n.lineTo(c.light.x,c.light.y),n.stroke()},"rgba(255, 255, 255, 0.85)",1,[4,4]),s(r(c.light,7),"#ffffff",1.5),s(r(c.ghost,Math.max(9,c.ghostRadius)),"#ffd23f",2);e&&s(a(e,8,!1),"#ffd23f",2),i&&s(a(i,5,!0),"rgba(255, 255, 255, 0.7)",1),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const r=this.ctx;r.save(),r.font=`${s}px system-ui, sans-serif`,r.textBaseline="top";const a=r.measureText(t).width;r.fillStyle="rgba(0, 0, 0, 0.6)",r.fillRect(e-3,i-2,a+6,s+4),r.fillStyle=n,r.fillText(t,e,i),r.restore()}paintGroupHandles(t){this.paintHandleFrame(nr.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const i of BA){const n=t[i];this.ctx.fillRect(n.x-Sp,n.y-Sp,hM,hM)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Sp+1,Sp+1,0,0,2*Math.PI),this.ctx.fill())}}const ab=.05,ob=.08,cb=2,lb=3,T8=14,R8=.02;class hb{context;constructor(t){this.context=t}voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}lr.isLive(this.context)&&lr.unlock(this.context)}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),lr.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,ab);for(const{param:s,ratio:r}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*r,i.sampleRate/2-1),n,ab)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const r=t.createGain();return r.gain.value=0,i.connect(s),n.connect(s),s.connect(r).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),r=t.createGain();return r.gain.value=0,n.connect(s).connect(i.frequency),i.connect(r).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(this.output(t)),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const r=t.createBufferSource();r.buffer=this.crackleEnvelope(t),r.loop=!0;const a=t.createGain();return a.gain.value=0,r.connect(a).connect(s.gain),i.connect(n).connect(s).connect(this.output(t)),i.start(),r.start(),{key:e,nodes:[n,s,a],sources:[i,r],volumeParam:a.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();a.gain.value=0,r.connect(a).connect(this.output(n)),r.start(),this.voice={key:e,nodes:[a],sources:[r],volumeParam:a.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*cb),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*cb),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let r=0;r<i.length;r++)n=(n+.02*(Math.random()*2-1))/1.02,i[r]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let r=0;r<i.length;r++)i[r]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*lb),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(R8*t.sampleRate)),s=Math.round(lb*T8);for(let r=0;r<s;r++){const a=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&a+l<i.length;l++)i[a+l]=Math.max(i[a+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,ob/3);const n=i+ob;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const r of t.nodes)r.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const r of t.nodes)r.disconnect()}}}}class gf{static EN={"unknown-key":"{path}: unknown key, ignored","wrong-type":"{path}: expected {expected}, found {found}","not-in-list":"{path}: {found} is not one of {expected}","out-of-range":"{path}: {found} is outside {expected}",defaulted:"{path}: missing, {expected} used",unplaced:"{path}: no aim (and no bounds), drawn at the middle of the view",unsized:"{path}: no angular size (and no bounds), drawn one pixel wide","pixels-over-angles":"{path}: bounds restated without aim or angular, so the shape follows the pixels"};static text(t,e=gf.EN){return e[t.kind].replace("{path}",t.path).replace("{expected}",t.expected??"").replace("{found}",t.found??"")}static warn(t,e){if(t.length===0)return;const i=t.map(n=>` ${gf.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
|
|
6814
6814
|
${i.join(`
|
|
6815
6815
|
`)}`)}}class vr{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!vr.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:vr.typeOf(t)});return}for(const[s,r]of Object.entries(t)){const a=i?`${i}.${s}`:s,c=e[s];c?this.field(r,c,a,n):n.push({kind:"unknown-key",path:a})}}field(t,e,i,n){if(vr.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):vr.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:vr.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,r)=>{const a=vr.isStated(s)?s.value:s;this.object(a,e.fields,`${i}.${r}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:vr.typeOf(t)});return;default:typeof t!==e.type?n.push({kind:"wrong-type",path:i,expected:e.type,found:vr.typeOf(t)}):typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&n.push({kind:"out-of-range",path:i,expected:`${e.minimum??"−∞"}–${e.maximum??"∞"}`,found:String(t)})}}static STATED_KEYS=new Set(["value","basis","rationale","how","range","source"]);static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return vr.isObject(t)&&"value"in t&&Object.keys(t).every(e=>vr.STATED_KEYS.has(e))}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class Ur{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const r=s>0?Ur.travelDegOver(t,e,i,i+n*1e3)/s/Ur.PIXELS_PER_INSTANT:0,a=Ur.flashesOver(t,n)*Ur.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,a));return c<2?1:Math.min(Ur.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const r of t){if(!r.track||r.track.length<2)continue;const a=Ur.directionAt(r,e,i),c=Ur.directionAt(r,e,n),l=Math.min(1,Math.max(-1,a.x*c.x+a.y*c.y+a.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Xr(t,i),s=n.eastM,r=n.altitudeM-e,a=n.northM,c=Math.hypot(s,r,a);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:a/c}}}const HA=Math.PI/180,I8=180/Math.PI,D8=256,GA=19,C8=1.25;function VA(o,t){return 156543.03392*Math.cos(o*HA)/2**t}function WA(o,t){return VA(o,t)*D8}function O8(o,t){let e=0;for(;e<GA&&WA(o,e+1)>=t;)e++;return e}function XA(o,t){return WA(o,t)}function P8(o,t){const e=t*C8;let i=0;for(;i<GA&&VA(o,i)>e;)i++;return i}function d0(o){const t=o*HA;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function $A(o,t,e){const i=2**e;return{x:(o+180)/360*i,y:d0(t)*i}}function YA(o,t,e){const i=d0(o.north),n=d0(o.south);return{x:(t-o.west)/(o.east-o.west),y:(d0(e)-i)/(n-i)}}function N8(o,t,e){const{x:i,y:n}=$A(o,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function L8(o){const t=2**o.z,e=o.x/t*360-180,i=(o.x+1)/t*360-180,n=ub(o.y,t);return{south:ub(o.y+1,t),north:n,west:e,east:i}}function ub(o,t){const e=o/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*I8}function KA(o,t,e,i){const n=N8(o,t,e),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:e});const a=r.map(L8),c={south:Math.min(...a.map(l=>l.south)),north:Math.max(...a.map(l=>l.north)),west:Math.min(...a.map(l=>l.west)),east:Math.max(...a.map(l=>l.east))};return{tiles:r,bounds:c}}const k8="#2ec4ff";class Wc{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-t,s.y-e);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),this.paintTraces(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=YA(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintTraces(t){const{ctx:e}=this;for(const i of t.traces??[]){const n=i.points.map(r=>this.toCanvas(t.bounds,r.lat,r.lng));if(n.length===0)continue;const s=i.color??k8;if(i.kind==="point")e.beginPath(),e.moveTo(n[0].x,n[0].y-6),e.lineTo(n[0].x+6,n[0].y),e.lineTo(n[0].x,n[0].y+6),e.lineTo(n[0].x-6,n[0].y),e.closePath(),e.fillStyle=s,e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.8)",e.stroke();else{e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const r of n.slice(1))e.lineTo(r.x,r.y);i.kind==="polygon"&&e.closePath(),e.lineJoin="round",e.setLineDash([]),e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=4.5,e.stroke(),e.setLineDash([9,5]),e.strokeStyle=s,e.lineWidth=2.5,e.stroke(),e.setLineDash([])}if(i.label){e.font="11px sans-serif",e.textAlign="left",e.textBaseline="middle";let r=n[0];if(i.kind==="line"&&t.position){const a=this.toCanvas(t.bounds,t.position.lat,t.position.lng);r=n.reduce((c,l)=>Math.hypot(l.x-a.x,l.y-a.y)>Math.hypot(c.x-a.x,c.y-a.y)?l:c)}this.paintOutlinedText(i.label,r.x+9,r.y-9)}}}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),a=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,a,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,a);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:Wc.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,Wc.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(r=>{if(!r.current)return!1;const a=re(r.lat,r.lng,e.lat,e.lng);return Math.hypot(a.x,a.z)<=Wc.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?Wc.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(t.south+t.north)/2,c=Math.abs(re(r,t.east,r,t.west).x)/this.width,l=Wc.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>e?(i.push(n),n=s):n=r}return n&&i.push(n),i}}class vi{static MIN_ZOOM=.25;static MAX_ZOOM=64;static MIN_SPAN_M=400;static MARGIN=.6;static IMAGERY_PX=768;static fitted(t,e){return vi.including(t.boundsAround(vi.MIN_SPAN_M,vi.MARGIN),e)}zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(vi.MAX_ZOOM,Math.max(vi.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,r=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=r-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=vi.mercatorY01(e.north),s=vi.mercatorY01(e.south),r=vi.mercatorY01(i.north),a=vi.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((r+a)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=vi.mercatorY01(n.north),r=vi.mercatorY01(n.south),a=(e.lng-n.west)/(n.east-n.west),c=(vi.mercatorY01(e.lat)-s)/(r-s);return a>=i&&a<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-a,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=vi.mercatorY01(t.north),n=vi.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:vi.latitudeAt(i+(this.centerY-e)*(n-i)),south:vi.latitudeAt(i+(this.centerY+e)*(n-i))}}static including(t,e,i=3){const n=(t.north+t.south)/2,s=(t.east+t.west)/2,r=re(n,t.east,n,s).x;let a=r;for(const c of e){const{x:l,z:h}=re(c.lat,c.lng,n,s),u=Math.max(Math.abs(l),Math.abs(h));u<=r*i&&(a=Math.max(a,u*1.15))}return a<=r?t:{north:$s(0,-a,n,s).lat,south:$s(0,a,n,s).lat,east:$s(a,0,n,s).lng,west:$s(-a,0,n,s).lng}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=vi.mercatorY01(t.north),s=vi.mercatorY01(t.south);return{lat:vi.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const pr=256,db=3,F8=32768;class qA{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(re(i,t.east,i,t.west).x),r=Math.abs(re(t.north,n,t.south,n).z),a=O8(i,Math.max(s,r)),{tiles:c}=KA(n,i,a,db),l=db*pr,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let m=0;m<e.width;m++){const g=t.west+(t.east-t.west)*(m/(e.width-1));d[f*e.width+m]=this.sampleAt(p,g,a,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const a=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=pr,c.height=pr;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(a,0,0);const{data:h}=l.getImageData(0,0,pr,pr),u=(t.x-e.x)*pr,d=(t.y-e.y)*pr;for(let f=0;f<pr;f++)for(let p=0;p<pr;p++){const m=(f*pr+p)*4,g=h[m]*256+h[m+1]+h[m+2]/256-F8,v=u+p,M=d+f;i[M*n+v]=g}}sampleAt(t,e,i,n,s,r){const{x:a,y:c}=$A(e,t,i),l=(a-n.x)*pr,h=(c-n.y)*pr,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),m=l-u,g=h-d,v=s[d*r+u],M=s[d*r+f],w=s[p*r+u],y=s[p*r+f],x=v+(M-v)*m,b=w+(y-w)*m;return x+(b-x)*g}}class km{constructor(t,e,i,n){this.width=t,this.height=e,this.samples=i,this.values=n}at(t,e,i=0){return this.values[(e*this.width+t)*this.samples+i]}static parse(t){const e=new DataView(t);if(t.byteLength<8||e.getUint16(0)!==18761||e.getUint16(2,!0)!==42)throw new Error("Not a little-endian TIFF");const i=e.getUint32(4,!0),n=e.getUint16(i,!0),s=new Map;for(let v=0;v<n;v++){const M=i+2+v*12;s.set(e.getUint16(M,!0),{type:e.getUint16(M+2,!0),count:e.getUint32(M+4,!0),value:e.getUint32(M+8,!0)})}const r=(v,M)=>{const w=s.get(v);if(w===void 0){if(M===void 0)throw new Error(`TIFF without tag ${v}`);return M}return w.type===3?w.value&65535:w.value},a=v=>{const M=s.get(v);if(M===void 0)throw new Error(`TIFF without tag ${v}`);const w=M.type===3?2:4,y=[];if(M.count*w<=4){const x=new DataView(new ArrayBuffer(4));x.setUint32(0,M.value,!0);for(let b=0;b<M.count;b++)y.push(w===2?x.getUint16(b*2,!0):x.getUint32(0,!0))}else for(let x=0;x<M.count;x++)y.push(w===2?e.getUint16(M.value+x*2,!0):e.getUint32(M.value+x*4,!0));return y};if(r(259,1)!==1)throw new Error("Compressed TIFF");if(s.has(322))throw new Error("Tiled TIFF");const c=r(256),l=r(257),h=r(277,1),u=a(258)[0],d=r(339,1)===3;if(!(d&&u===32||!d&&u===8))throw new Error(`Unsupported TIFF samples: ${u} bits`);const f=a(273),p=a(279),m=new Uint8Array(c*l*h*(u/8));let g=0;for(let v=0;v<f.length&&g<m.length;v++){const M=Math.min(p[v],m.length-g);m.set(new Uint8Array(t,f[v],M),g),g+=M}if(g<m.length)throw new Error("Truncated TIFF");return new km(c,l,h,d?new Float32Array(m.buffer):m)}}class Uo extends Error{constructor(t,e){super(e),this.reason=t,this.name="SurroundingsUnavailableError"}}class U8{constructor(t,e,i,n,s){this.heights=t,this.plants=e,this.buildings=i,this.size=n,this.metresPerPixel=s}structureAt(t,e){const i=Math.floor(t/this.metresPerPixel+this.size/2),n=Math.floor(this.size/2-e/this.metresPerPixel);if(i<0||n<0||i>=this.size||n>=this.size)return;const s=n*this.size+i;if(!(this.plants[s]||this.buildings[s]))return this.heights[s]}tallestStructureNear(t,e,i){let n;const s=Math.ceil(i/this.metresPerPixel);for(let r=-s;r<=s;r++)for(let a=-s;a<=s;a++){if(Math.hypot(a,r)*this.metresPerPixel>i)continue;const c=this.structureAt(t+a*this.metresPerPixel,e+r*this.metresPerPixel);c!==void 0&&(n===void 0||c>n)&&(n=c)}return n}}class ze{static covers(t,e){return t>=41.2&&t<=51.3&&e>=-5.4&&e<=9.8}static WMS="https://data.geopf.fr/wms-r/wms";static WFS="https://data.geopf.fr/wfs/ows";static HEIGHT_LAYER="IGNF_LIDAR-HD_MNH_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static PHOTO_LAYER="ORTHOIMAGERY.ORTHOPHOTOS";static MAX_PHOTO_PIXELS=1e3;static METRES_PER_PIXEL=.5;static MAX_RADIUS_M=3e3;static MAX_LIDAR_RADIUS_M=150;static NO_DATA=-9999;static METRES_PER_DEGREE=111320;fetchImpl;wms;wfs;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??ze.WMS,this.wfs=t.wfsEndpoint??ze.WFS}static radius(t){return Math.min(t,ze.MAX_RADIUS_M)}static lidarRadius(t){return Math.min(t,ze.MAX_LIDAR_RADIUS_M)}async lidar(t,e){const i=ze.lidarRadius(e),n=Math.ceil(2*i/ze.METRES_PER_PIXEL),[s,r]=await Promise.all([this.raster(t,i,n,ze.HEIGHT_LAYER),this.raster(t,i,n,ze.CLASS_LAYER)]);if(s.samples!==1||r.samples<3)throw new Uo("unreachable","The survey answered in a layout this does not read");const a=s.values;if(a.every(u=>u===ze.NO_DATA))throw new Uo("no-coverage","No LiDAR HD survey here yet");const c=new Uint8Array(n*n),l=new Uint8Array(n*n);for(let u=0;u<n*n;u++){const d=r.values[u*r.samples],f=r.values[u*r.samples+1],p=r.values[u*r.samples+2];c[u]=f>d&&f>p?1:0,l[u]=d>120&&f<90&&p<90?1:0}const h=2*i/n;return{size:n,metresPerPixel:h,heights:a,vegetation:c,building:l,structures:new U8(a,c,l,n,h)}}async laserDate(t){return ze.latest(await this.dated("IGNF_LIDAR-HD_METADONNEE:metadata","geom","date_fin_acquisition",t))}async photoDate(t){return ze.latest(await this.dated("ORTHOIMAGERY.ORTHOPHOTOS.GRAPHE-MOSAIQUAGE:graphe_bdortho","geom","date_vol",t))}static latest(t){return t.map(i=>/^\d{4}-\d{2}-\d{2}/.exec(String(i??""))?.[0]).filter(i=>i!==void 0).sort().at(-1)}async dated(t,e,i,n){const r=[n.lng-1e-4,n.lat-1e-4,n.lng+1e-4,n.lat+1e-4].map(a=>a.toFixed(6)).join(",");try{return(await this.features(t,`BBOX(${e},${r},'EPSG:4326')`,i,20)).map(a=>a.properties[i])}catch{return[]}}async photo(t,e){const i=ze.radius(e),n=Math.min(ze.MAX_PHOTO_PIXELS,Math.ceil(2*i/ze.METRES_PER_PIXEL)),s=await this.raster(t,i,n,ze.PHOTO_LAYER);if(s.samples<3)throw new Uo("unreachable","The photograph came in a layout this does not read");return{size:n,metresPerPixel:2*i/n,samples:s.samples,values:s.values}}async vectors(t,e,i){const n=ze.radius(e),s=n/ze.METRES_PER_DEGREE,r=n/(ze.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),c=`BBOX(geometrie,${[t.lng-r,t.lat-s,t.lng+r,t.lat+s].map(v=>v.toFixed(6)).join(",")},'EPSG:4326')`,[l,h,u,d,f,p]=await Promise.all([this.features("construction_lineaire",`${c} AND nature='Pont'`,"nature,geometrie"),this.features("troncon_de_route",`${c} AND position_par_rapport_au_sol>'0'`,"nature,largeur_de_chaussee,position_par_rapport_au_sol,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie"),this.features("troncon_de_voie_ferree",`${c} AND position_par_rapport_au_sol>'0'`,"position_par_rapport_au_sol,geometrie").catch(()=>[]),this.features("ligne_electrique",c,"voltage,geometrie"),i?this.features("batiment",c,ze.BUILDING_PROPERTIES,5e3):Promise.resolve([]),i?this.features("zone_d_activite_ou_d_interet",c,"toponyme,categorie,geometrie",100).catch(()=>[]):Promise.resolve([])]),m=i?await this.wholeWorship(p,f,[t.lng-r,t.lat-s,t.lng+r,t.lat+s]):[],g=[...f,...m];return{bridges:l,elevatedRoads:h,elevatedRailways:u,lines:d,buildings:g,zones:p,mapDate:ze.latest(g.map(v=>v.properties.date_modification))}}static BUILDING_PROPERTIES="cleabs,nature,usage_1,hauteur,nombre_d_etages,materiaux_des_murs,materiaux_de_la_toiture,date_d_apparition,date_modification,geometrie";static MAX_WHOLE_M=300;async wholeWorship(t,e,i){const[n,s,r,a]=i,c=ze.MAX_WHOLE_M/ze.METRES_PER_DEGREE;let l;for(const u of t){if(u.properties.categorie!=="Religieux")continue;const[d,f,p,m]=ze.extent(u);if(d>=n&&f>=s&&p<=r&&m<=a)continue;const g=[Math.max(d,n-c),Math.max(f,s-c),Math.min(p,r+c),Math.min(m,a+c)];l=l?[Math.min(l[0],g[0]),Math.min(l[1],g[1]),Math.max(l[2],g[2]),Math.max(l[3],g[3])]:g}if(!l)return[];const h=new Set(e.map(u=>u.properties.cleabs));try{return(await this.features("batiment",`BBOX(geometrie,${l.map(d=>d.toFixed(6)).join(",")},'EPSG:4326')`,ze.BUILDING_PROPERTIES,1e3)).filter(d=>!h.has(d.properties.cleabs))}catch{return[]}}static extent(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;const r=a=>{Array.isArray(a)&&typeof a[0]=="number"?(e=Math.min(e,a[0]),n=Math.max(n,a[0]),i=Math.min(i,a[1]),s=Math.max(s,a[1])):Array.isArray(a)&&a.forEach(r)};return r(t.geometry.coordinates),[e,i,n,s]}async elevatedRoadLines(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(s=>s.toFixed(6)).join(",")},'EPSG:4326')`,i=await this.features("troncon_de_route",`${e} AND position_par_rapport_au_sol>'0'`,"geometrie",300),n=[];for(const s of i){const{type:r,coordinates:a}=s.geometry,c=r==="LineString"?[a]:r==="MultiLineString"?a:[];for(const l of c)n.push(l.map(h=>({lat:h[1],lng:h[0]})))}return n}async waterSurfaces(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("surface_hydrographique",`${e} AND position_par_rapport_au_sol='0' AND persistance='Permanent'`,"cleabs,nature,geometrie",500)}async roads(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_route",`${e} AND nature<>'Sentier' AND nature<>'Escalier' AND position_par_rapport_au_sol>='0'`,"cleabs,nature,largeur_de_chaussee,nombre_de_voies,sens_de_circulation,vitesse_moyenne_vl,urbain,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie",3e3)}async railways(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_voie_ferree",`${e} AND etat_de_l_objet='En service'`,"cleabs,nature,electrifie,largeur,nombre_de_voies,position_par_rapport_au_sol,cpx_toponyme,geometrie",3e3)}async raster(t,e,i,n){const s=e/ze.METRES_PER_DEGREE,r=e/(ze.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),a=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:n,STYLES:"",CRS:"EPSG:4326",BBOX:[t.lat-s,t.lng-r,t.lat+s,t.lng+r].map(l=>l.toFixed(6)).join(","),WIDTH:String(i),HEIGHT:String(i),FORMAT:"image/geotiff"});let c;try{c=await this.fetchImpl(`${this.wms}?${a}`)}catch(l){throw new Uo("unreachable",l instanceof Error?l.message:String(l))}if(!c.ok)throw new Uo("unreachable",`The survey answered ${c.status}`);try{return km.parse(await c.arrayBuffer())}catch(l){throw new Uo("unreachable",l instanceof Error?l.message:String(l))}}async features(t,e,i,n=200){const s=new URLSearchParams({SERVICE:"WFS",VERSION:"2.0.0",REQUEST:"GetFeature",TYPENAMES:t.includes(":")?t:`BDTOPO_V3:${t}`,SRSNAME:"EPSG:4326",OUTPUTFORMAT:"application/json",COUNT:String(n),CQL_FILTER:e,PROPERTYNAME:i});let r;try{r=await this.fetchImpl(`${this.wfs}?${s}`)}catch(c){throw new Uo("unreachable",c instanceof Error?c.message:String(c))}if(!r.ok)throw new Uo("unreachable",`The map answered ${r.status}`);return(await r.json()).features??[]}}class Yo{static NEAR_M=15;static ALIGNED_DEG=30;static LONG_ENOUGH_M=15;static SAMPLE_M=5;static follows(t,e){if(t.length<2||e.length<2)return!1;const i=e[0],n=e.map(a=>re(a.lat,a.lng,i.lat,i.lng)),s=t.map(a=>re(a.lat,a.lng,i.lat,i.lng));let r=0;for(let a=0;a<s.length-1;a++){const c=s[a],l=s[a+1],h=Math.hypot(l.x-c.x,l.z-c.z);if(h<1e-6)continue;const u=Math.max(1,Math.ceil(h/Yo.SAMPLE_M)),d=Math.atan2(l.x-c.x,-(l.z-c.z));for(let f=0;f<=u;f++){const p=f/u,m=Yo.nearest(n,c.x+(l.x-c.x)*p,c.z+(l.z-c.z)*p);m.distanceM>Yo.NEAR_M||Yo.angleBetween(d,m.heading)<=Yo.ALIGNED_DEG&&(r+=h/u)}}return r>=Yo.LONG_ENOUGH_M}static nearest(t,e,i){let n={distanceM:1/0,heading:0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.z-r.z,h=c*c+l*l,u=h<1e-9?0:Math.max(0,Math.min(1,((e-r.x)*c+(i-r.z)*l)/h)),d=Math.hypot(e-(r.x+c*u),i-(r.z+l*u));d<n.distanceM&&(n={distanceM:d,heading:Math.atan2(c,-l)})}return n}static angleBetween(t,e){const i=Math.abs((t-e)*180/Math.PI%180);return Math.min(i,180-i)}}class Ne{static WMS="https://data.geopf.fr/wms-r/wms";static LAYERS=["IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93","ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES"];static METRES_PER_PIXEL=4;static METRES_PER_DEGREE=111320;static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static SURFACE_LAYER="IGNF_LIDAR-HD_MNS_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static DECK=[240,240,0];static NO_CLASS=[0,0,0];static DECK_END_PIXELS=3;static DECK_HALF_WIDTH_M=8;static DECK_APPROACH_M=10;static DECK_STRAIGHT_MAX_M=200;static MIN_PIXELS=8;static MAX_PIXELS=700;static NO_DATA_BELOW=-100;static COARSE_METRES_PER_PIXEL=20;static MESH_FROM_VERTICES=33;static FINE_SPACING_M=7;static MAX_SEGMENTS=256;static MAX_HOLE_SHARE=.05;static DEFAULT_TIMEOUT_MS=12e3;static MAX_WINDOW_M=50;fetchImpl;wms;timeoutMs;maxWindowM;geoplatform;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??Ne.WMS,this.timeoutMs=t.timeoutMs??Ne.DEFAULT_TIMEOUT_MS,this.maxWindowM=t.maxWindowM??Ne.MAX_WINDOW_M,this.geoplatform=new ze({fetchImpl:this.fetchImpl,wmsEndpoint:this.wms,wfsEndpoint:t.wfsEndpoint})}async getElevationGrid(t,e,i){const n={lat:(t.south+t.north)/2,lng:(t.west+t.east)/2};if(!ze.covers(n.lat,n.lng))throw new Error("The IGN's relief covers France only");const s=Math.abs(re(n.lat,t.east,n.lat,t.west).x),r=Math.abs(re(t.north,n.lng,t.south,n.lng).z);e=this.finer(e,s,r);const a={x:s/Math.max(1,e.width-1),y:r/Math.max(1,e.height-1)},c={x:Math.min(a.x,this.maxWindowM),y:Math.min(a.y,this.maxWindowM)},l={south:t.south-c.y/Ne.METRES_PER_DEGREE,north:t.north+c.y/Ne.METRES_PER_DEGREE,west:t.west-c.x/(Ne.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180)),east:t.east+c.x/(Ne.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180))},h=m=>Math.min(Ne.MAX_PIXELS,Math.max(Ne.MIN_PIXELS,Math.ceil(m/Ne.METRES_PER_PIXEL))),u={width:h(s+2*c.x),height:h(r+2*c.y)},d={x:(s+2*c.x)/u.width,y:(r+2*c.y)/u.height};let f=new Error("No layer of the IGN's relief answered");const p=Math.max(d.x,d.y)>Ne.COARSE_METRES_PER_PIXEL;for(const m of p?[...Ne.LAYERS].reverse():Ne.LAYERS)try{const g=await this.heights(l,u,m);m===Ne.LAYERS[0]&&await this.layBridgeDecks(g,l,u,i?.route);const v=this.sample(g,e,t,l,d,a);if(v)return{heights:v,width:e.width,height:e.height,bounds:t};f=new Error(`${m} does not cover this place`)}catch(g){f=g}throw f}finer(t,e,i){if(t.width<Ne.MESH_FROM_VERTICES||t.height<Ne.MESH_FROM_VERTICES)return t;const n=(s,r)=>{const a=Math.ceil(s/Ne.FINE_SPACING_M),c=Math.max(r-1,Math.min(Ne.MAX_SEGMENTS,a));return c%2===0?c:c+1};return{width:n(e,t.width)+1,height:n(i,t.height)+1}}async raster(t,e,i){const n=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:i,STYLES:"",CRS:"EPSG:4326",BBOX:[t.south,t.west,t.north,t.east].map(r=>r.toFixed(6)).join(","),WIDTH:String(e.width),HEIGHT:String(e.height),FORMAT:"image/geotiff"}),s=await this.fetchImpl(`${this.wms}?${n}`,{signal:AbortSignal.timeout(this.timeoutMs)});if(!s.ok)throw new Error(`The IGN's relief answered ${s.status}`);return km.parse(await s.arrayBuffer())}async heights(t,e,i){const n=await this.raster(t,e,i);if(n.samples!==1||!(n.values instanceof Float32Array))throw new Error("The IGN's relief came in a layout this does not read");return n}async layBridgeDecks(t,e,i,n){if(!(!n||n.length<2)&&!(!(t.values instanceof Float32Array)||!t.values.some(s=>s>Ne.NO_DATA_BELOW)))try{const s=(await this.geoplatform.elevatedRoadLines({west:e.west,south:e.south,east:e.east,north:e.north})).filter(a=>Yo.follows(n,a));if(s.length===0)return;const r=Float32Array.from(t.values);await this.layClassifiedDecks(t,e,i,s),this.layRouteDecks(t,r,e,s)}catch{}}async layClassifiedDecks(t,e,i,n){try{const s=await this.raster(e,i,Ne.CLASS_LAYER);if(s.samples<3||s.width!==t.width||s.height!==t.height)return;const r=(g,[v,M,w])=>s.values[g*s.samples]===v&&s.values[g*s.samples+1]===M&&s.values[g*s.samples+2]===w,a=t.width,c=t.height,l=new Uint8Array(a*c);let h=!1;for(let g=0;g<l.length;g++)r(g,Ne.DECK)&&(l[g]=1,h=!0);if(!h)return;const u=Ne.DECK_END_PIXELS,d=[];for(let g=0;g<l.length;g++){if(l[g]!==1)continue;const v=g%a,M=(g-v)/a;for(let w=-u;w<=u;w++)for(let y=-u;y<=u;y++){const x=v+y,b=M+w;if(x<0||b<0||x>=a||b>=c)continue;const E=b*a+x;l[E]===0&&r(E,Ne.NO_CLASS)&&d.push(E)}}for(const g of d)l[g]=1;const f=this.paint(n,e,a,c),p=this.touching(l,f,a,c);if(p.every(g=>g===0))return;const m=await this.heights(e,i,Ne.SURFACE_LAYER);if(m.width!==a||m.height!==c)return;for(let g=0;g<p.length;g++){if(p[g]===0)continue;const v=m.values[g];Number.isFinite(v)&&v>Ne.NO_DATA_BELOW&&v>t.values[g]&&(t.values[g]=v)}}catch{}}layRouteDecks(t,e,i,n){const{width:s,height:r}=t,a=(i.north+i.south)/2,c=(i.east-i.west)*Ne.METRES_PER_DEGREE*Math.cos(a*Math.PI/180),l=(i.north-i.south)*Ne.METRES_PER_DEGREE,h=c/s,u=l/r,d=v=>({x:(v.lng-i.west)/(i.east-i.west)*c,y:(i.north-v.lat)/(i.north-i.south)*l}),f=(v,M)=>{const w=Math.floor(v/h),y=Math.floor(M/u);if(w<0||y<0||w>=s||y>=r)return;const x=e[y*s+w];return Number.isFinite(x)&&x>Ne.NO_DATA_BELOW?x:void 0},p=Ne.DECK_HALF_WIDTH_M,m=Ne.DECK_APPROACH_M,g=(v,M)=>{const w=Math.hypot(v.x-M.x,v.y-M.y)||1,y={x:(v.x-M.x)/w,y:(v.y-M.y)/w},x=[0,m/2,m].map(b=>f(v.x+y.x*b,v.y+y.y*b)).filter(b=>b!==void 0);return x.length>0?Math.max(...x):void 0};for(const v of Ne.chains(n.map(M=>M.map(d)))){const M=[0];for(let I=1;I<v.length;I++)M.push(M[I-1]+Math.hypot(v[I].x-v[I-1].x,v[I].y-v[I-1].y));const w=M[M.length-1];if(w<1||w>Ne.DECK_STRAIGHT_MAX_M)continue;const y=g(v[0],v[1]),x=g(v[v.length-1],v[v.length-2]);if(y===void 0||x===void 0)continue;const b=p+m,E=Math.max(0,Math.floor((Math.min(...v.map(I=>I.x))-b)/h)),S=Math.min(s-1,Math.ceil((Math.max(...v.map(I=>I.x))+b)/h)),A=Math.max(0,Math.floor((Math.min(...v.map(I=>I.y))-b)/u)),_=Math.min(r-1,Math.ceil((Math.max(...v.map(I=>I.y))+b)/u));for(let I=A;I<=_;I++)for(let D=E;D<=S;D++){const O=Ne.nearestAlong(v,M,{x:(D+.5)*h,y:(I+.5)*u});if(O.distance>p||O.s<-m||O.s>w+m)continue;const P=y+(x-y)*Math.min(1,Math.max(0,O.s/w)),N=I*s+D;e[N]>=P||(t.values[N]=P)}}}static chains(t){const e=t.filter(s=>s.length>=2).map(s=>[...s]),i=[],n=(s,r)=>Math.hypot(s.x-r.x,s.y-r.y)<=1;for(;e.length>0;){let s=e.shift(),r=!0;for(;r;){r=!1;for(let a=0;a<e.length;a++){const c=e[a],l=s[0],h=s[s.length-1];if(n(h,c[0]))s=[...s,...c.slice(1)];else if(n(h,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else if(n(l,c[c.length-1]))s=[...c.slice(0,-1),...s];else if(n(l,c[0]))s=[...[...c].reverse().slice(0,-1),...s];else continue;e.splice(a,1),r=!0;break}}i.push(s)}return i}static nearestAlong(t,e,i){let n={s:0,distance:1/0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.y-r.y,h=c*c+l*l;if(h<1e-9)continue;let u=((i.x-r.x)*c+(i.y-r.y)*l)/h;s>0&&(u=Math.max(0,u)),s<t.length-2&&(u=Math.min(1,u));const d=Math.hypot(i.x-(r.x+c*u),i.y-(r.y+l*u));d<n.distance&&(n={s:e[s]+u*Math.sqrt(h),distance:d})}return n}paint(t,e,i,n){const s=new Uint8Array(i*n),r=c=>(c-e.west)/(e.east-e.west)*i,a=c=>(e.north-c)/(e.north-e.south)*n;for(const c of t)for(let l=0;l<c.length-1;l++){const h=r(c[l].lng),u=a(c[l].lat),d=r(c[l+1].lng),f=a(c[l+1].lat),p=Math.max(1,Math.ceil(Math.hypot(d-h,f-u)*2));for(let m=0;m<=p;m++){const g=Math.floor(h+(d-h)*m/p),v=Math.floor(u+(f-u)*m/p);for(let M=-1;M<=1;M++)for(let w=-1;w<=1;w++){const y=g+w,x=v+M;y>=0&&x>=0&&y<i&&x<n&&(s[x*i+y]=1)}}}return s}touching(t,e,i,n){const s=new Uint8Array(t.length),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++){if(t[a]===0||r[a]===1)continue;const c=[],l=[a];r[a]=1;let h=!1;for(;l.length>0;){const u=l.pop();c.push(u),e[u]===1&&(h=!0);const d=u%i,f=(u-d)/i;for(let p=-1;p<=1;p++)for(let m=-1;m<=1;m++){const g=d+m,v=f+p;if(g<0||v<0||g>=i||v>=n)continue;const M=v*i+g;t[M]===1&&r[M]===0&&(r[M]=1,l.push(M))}}if(h)for(const u of c)s[u]=1}return s}sample(t,e,i,n,s,r){const{width:a,height:c}=e,l=new Float32Array(a*c),h=new Uint8Array(a*c),u=Math.min(r.x,this.maxWindowM)/s.x,d=Math.min(r.y,this.maxWindowM)/s.y;let f=0;for(let p=0;p<c;p++){const m=i.north+(i.south-i.north)*(c===1?.5:p/(c-1)),g=(n.north-m)/(n.north-n.south)*t.height-.5;for(let v=0;v<a;v++){const w=(i.west+(i.east-i.west)*(a===1?.5:v/(a-1))-n.west)/(n.east-n.west)*t.width-.5,y=u>1||d>1?this.tent(t,w,g,Math.max(1,u),Math.max(1,d)):this.bilinear(t,w,g),x=p*a+v;y===void 0?f++:(l[x]=y,h[x]=1)}}if(!(f===a*c||f/(a*c)>Ne.MAX_HOLE_SHARE))return this.fill(l,h,a,c),l}tent(t,e,i,n,s){let r=0,a=0,c=0;const l=Math.max(0,Math.ceil(i-s)),h=Math.min(t.height-1,Math.floor(i+s)),u=Math.max(0,Math.ceil(e-n)),d=Math.min(t.width-1,Math.floor(e+n));for(let f=l;f<=h;f++){const p=1-Math.abs(f-i)/s;if(!(p<=0))for(let m=u;m<=d;m++){const g=p*(1-Math.abs(m-e)/n);if(g<=0)continue;c+=g;const v=t.at(m,f);!Number.isFinite(v)||v<Ne.NO_DATA_BELOW||(r+=g*v,a+=g)}}return c>0&&a>=c*.5?r/a:void 0}bilinear(t,e,i){const n=Math.max(0,Math.min(t.width-1,Math.floor(e))),s=Math.max(0,Math.min(t.height-1,Math.floor(i))),r=Math.min(t.width-1,n+1),a=Math.min(t.height-1,s+1),c=Math.max(0,Math.min(1,e-n)),l=Math.max(0,Math.min(1,i-s)),h=t.at(n,s),u=t.at(r,s),d=t.at(n,a),f=t.at(r,a);for(const g of[h,u,d,f])if(!Number.isFinite(g)||g<Ne.NO_DATA_BELOW)return;const p=h+(u-h)*c,m=d+(f-d)*c;return p+(m-p)*l}fill(t,e,i,n){let s=e.reduce((r,a)=>r+(a?0:1),0);for(;s>0;){const r=[];for(let a=0;a<n;a++)for(let c=0;c<i;c++){const l=a*i+c;if(e[l])continue;let h=0,u=0;for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const p=a+d,m=c+f;p<0||m<0||p>=n||m>=i||!e[p*i+m]||(h+=t[p*i+m],u++)}u>0&&r.push([l,h/u])}if(r.length===0)return;for(const[a,c]of r)t[a]=c,e[a]=1;s-=r.length}}}class z8{providers;constructor(...t){this.providers=t}async getElevationGrid(t,e,i){let n=new Error("No source of relief to ask");for(const s of this.providers)try{return await s.getElevationGrid(t,e,i)}catch(r){n=r}throw n}}const f0=256,B8=5;async function ZA(o,t,e,i){const n=(o.south+o.north)/2,s=(o.west+o.east)/2,r=Math.abs(re(n,o.east,n,o.west).x),a=Math.abs(re(o.north,s,o.south,s).z),c=Math.max(r,a),{zoom:l,gridSize:h}=H8(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=KA(s,n,l,h),f=h*f0,p=document.createElement("canvas");p.width=f,p.height=f;const m=p.getContext("2d");if(!m)throw new Error("2D canvas context unavailable");const g=u[0];await Promise.all(u.map(async y=>{const x=e(y),b=await i(x);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${x}`);const E=await createImageBitmap(await b.blob());m.drawImage(E,(y.x-g.x)*f0,(y.y-g.y)*f0)}));const v=Math.min(Math.max(t.width,t.height),f);if(v===f)return{source:p,width:f,height:f,bounds:d};const M=document.createElement("canvas");M.width=v,M.height=v;const w=M.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,v,v),{source:M,width:v,height:v,bounds:d}}function H8(o,t,e){let i=P8(o,t/Math.max(1,e)),n=fb(o,i,t);for(;n>B8&&i>0;)i--,n=fb(o,i,t);return{zoom:i,gridSize:n,mPerPixel:XA(o,i)/f0}}function fb(o,t,e){const i=Math.ceil(e/2/XA(o,t));return Math.max(3,2*i+1)}class JA{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return ZA(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Hs{static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];static FRANCE_ENDPOINT="https://overpass.openstreetmap.fr/api/interpreter";static FRANCE={south:41.3,west:-5.2,north:51.1,east:9.6};static endpointsFor(t,e=Hs.ENDPOINTS){const i=/\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/.exec(t);if(!i)return[...e];const[n,s,r,a]=i.slice(1).map(Number),c=(n+r)/2,l=(s+a)/2,h=Hs.FRANCE;return c>=h.south&&c<=h.north&&l>=h.west&&l<=h.east?[Hs.FRANCE_ENDPOINT,...e.filter(d=>d!==Hs.FRANCE_ENDPOINT)]:[...e]}fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints}static queue=Promise.resolve();static HANG_MS=4e4;static RETRY_MS=4e3;query(t){return this.queued(()=>this.ask(t))}queued(t){const e=Hs.queue.then(t,t);return Hs.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints??Hs.endpointsFor(t))for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(Hs.HANG_MS)});if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Hs.RETRY_MS))}throw e??new Error("No Overpass instance answered")}}class Ko{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;client;constructor(t={}){this.client=new Hs(t)}async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Ko.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.client.query(i))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Ko.surfaceOf(s),widthM:Ko.widthOf(s),...Ko.paintOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return e}static paintOf(t){const e=t.highway??"",i=t.junction==="roundabout"||t.junction==="circular",n=t.oneway,s=n==="yes"||n==="1"||n==="true"||n===void 0&&(e==="motorway"||i),r=n==="-1"||n==="reverse",a=Number.parseInt(t.lanes??"",10),c=Number.parseInt(t.maxspeed??"",10),l=i?"roundabout":e==="motorway"?"motorway":e.endsWith("_link")?"slip":(e==="trunk"||e==="primary")&&(s||r)?"dual":e?"road":void 0;return{...l?{kind:l}:{},...Number.isFinite(a)&&a>0?{lanes:a}:{},...n!==void 0||e==="motorway"||i?{direction:r?"backward":s?"forward":"both"}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{}}}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Ko.WIDTH_M[t.highway]??Ko.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const Kg="https://ufoathome.org/roads/index.json";class Th{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Th.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
6816
|
-
`);let e=Th.shared.get(t);return e||(e=this.fetchFirstAvailable(),Th.shared.set(t,e),e.then(i=>{i.length===0&&Th.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.
|
|
6817
|
-
`);let e=Rh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Rh.shared.set(t,e),e.then(i=>{i.length===0&&Rh.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.2")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==qg?[e,qg]:[qg]).map(i=>i+t)}}class Ns{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=Ns.key(t);let i=Ns.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Ns.asked.set(e,i),i.catch(()=>Ns.asked.delete(e))),structuredClone(await i)}static forget(){Ns.asked.clear()}static key(t){return`v${Ns.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Ns.openCache(),n=Ns.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<Ns.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Ns.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-Ns.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Ns.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class nc{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>nc.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=nc.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=nc.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=nc.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const m=f.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>nc.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:m}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class qn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new Hs(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${qn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${qn.ROUTES})$"];out body;`;return qn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=qn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(v=>re(v.lat,v.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(v=>v.service===!!r.service);for(const v of qn.samples(a)){u++;const M=qn.waysAt(d,v);if(M.length===0)continue;const[w]=M;w.name&&c.set(w.name,(c.get(w.name)??0)+1),w.voltageV&&l.set(w.voltageV,(l.get(w.voltageV)??0)+1);for(const y of new Set(M.flatMap(x=>x.services)))h.set(y,(h.get(y)??0)+1)}const f=v=>[...v.entries()].sort((M,w)=>w[1]-M[1])[0]?.[0],p=r.name??f(c),m=r.voltageV??(r.electrification==="none"?void 0:f(l)),g=[...h.entries()].filter(([,v])=>v*4>=u).sort((v,M)=>M[1]-v[1]||v[0].localeCompare(M[0])).map(([v])=>v);return{...r,...p?{name:p}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=qn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=qn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=qn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>re(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=qn.SAMPLE_M/2;a<n;a+=qn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(qn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=qn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class Ih{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new Hs(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Ih.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${qn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=qn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=qn.voltageOf(r),l=Ih.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Ih.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:Ih.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class W8{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!nc.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class pn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=pn.key(t);let i=pn.asked.get(e)??pn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},pn.asked.set(e,i),n.catch(()=>pn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){pn.asked.clear(),pn.failedAt=-1/0}static key(t){return`v${pn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of pn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await pn.openCache(),n=pn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<pn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-pn.failedAt<pn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(pn.failedAt=this.now(),s)return s;throw a}return i&&pn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-pn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(pn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const Zg="https://ufoathome.org/railways/index.json";class Dh{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Dh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
6818
|
-
`);let e=Dh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Dh.shared.set(t,e),e.then(i=>{i.length===0&&Dh.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.2")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==Zg?[e,Zg]:[Zg]).map(i=>i+t)}}function jA(){return{elevation:QA(),imagery:t3(),roads:X8(),water:$8(),railways:Y8()}}function QA(){return new z8(new Ne,new qA)}function t3(){return new JA}function X8(){return new Th({fallback:new G8(new ic,new Ko)})}function $8(){return new Rh({fallback:new Ns(new V8(new vf,new Xc))})}function Y8(){return new Dh({fallback:new pn(new W8(new nc,new Ih))})}const K8=new Set,Pa="show-observer-map",Na="hide-milestones",nl="minified";class Ve extends HTMLElement{static get observedAttributes(){return["src",Pa,Na,nl]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new vi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=bm.create();issues=[];issueCheck=0;sightingAudio=new hb;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new hb(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>Ve.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");Ve.setIcon(this.moreButton,t?Kt.UNFOLDED:Kt.FOLDED);const e=t?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Kt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await at(async()=>{const{VideoButton:s}=await import("./VideoButton-C62NkJrH.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?Of(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<Ve.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=vi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=vi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Ve.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=vi.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${x8}</style>${w8}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new yu(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",a=>{a.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new Wc(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.citedMarks=this.shadow.getElementById("cited-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.playerTitleBox=this.shadow.getElementById("player-title"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.tracesButton.addEventListener("click",()=>this.toggleTraces()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>{this.player.seek(this.snapSeekToMark(Number(this.seekInput.value))),this.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.chromeResizeObserver?.observe(this.chromeCanvas),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===Pa&&this.applyObserverMapDefault(),t===Na&&this.setMilestonesShown(!this.hasAttribute(Na)),t===nl){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(nl)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(n3)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await Sr.recording(t)}get sightingData(){return dE(this.currentSighting)}set sightingData(t){const e=ar.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=YM(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await at(async()=>{const{default:r}=await import("./sightingSchema-pBDQNwMz.js");return{default:r}},[],import.meta.url);n=new vr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],gf.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(q8,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=(this.messages?.recordingIssues??"").replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=gf.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<Ve.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(i3,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get playbackRate(){return this.player.playbackRate}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),Ve.setIcon(this.referencesButton,i?Kt.PICTURES_ON:Kt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),Ve.setIcon(this.tracesButton,this.tracesShownState?Kt.TRACES_ON:Kt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?ud(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=Ve.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=Ve.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?Of(a,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new yu(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=Ve.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?Of(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Ur.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ve.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ve.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ve.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ve.EXPOSURE_STEP_PX),s=Math.min(Ve.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=_i.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:K8;this.canvasRenderer.setStarPoints(_i.starPointsOf(this.sighting.instrument,Pe(this.sighting,t)?.fNumber));const n=(Pe(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?nr.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(aE(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new b8(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*Ve.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Kt.PLAY:Kt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){Ve.icons.get(t)!==e&&(Ve.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(t){this.quietControlsValue=t,this.stageElement.classList.toggle("quiet",t)}tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},Ve.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),Ve.setIcon(this.playPauseButton,t?Kt.PAUSE:Kt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages?.pause??"":this.messages?.play??"":this.messages?.noDuration??"";this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(Pa),e=t===null?this.sighting.observerMap??this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;Ve.setIcon(this.observerMapButton,t?Kt.MAP_ON:Kt.MAP_OFF);const e=t?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=Qh.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=vi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?vi.expand(t,Ve.OBSERVER_MAP_IMAGERY_AHEAD):t,n=vi.IMAGERY_PX*(e?1+2*Ve.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:t3();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??s).attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?vi.expand(t,Ve.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages?.mapImageryUnavailable??"":this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=Ve.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=Pe(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},Ve.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?Of(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?ud(this.currentSighting.milestones):[]){const a=Pe(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Aa.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(_i.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,ud(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages?.moments??"",Ve.setIcon(this.milestonesButton,this.milestonesShown?Kt.MILESTONES_ON:Kt.MILESTONES_OFF);const t=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=Pe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Xr(i,t),{lat:s,lng:r}=$s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=Pe(this.currentSighting,this.currentTime),s=Aa.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return li.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=Ve.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),Ve.setIcon(this.miniMuteButton,this.mutedState?Kt.MUTED:Kt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){Ve.setIcon(this.muteButton,Kt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}Ve.setIcon(this.muteButton,this.mutedState?Kt.MUTED:Kt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;Ve.setIcon(this.fullscreenButton,t?Kt.EXIT_FULLSCREEN:Kt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Qn(Ws.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=vo(Ws.preferencesFor(this),Mo);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await IT.load(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+e,this.timeEndLabel.title=(this.messages?.duration??"")+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=rE(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?K1(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return zo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?mb(pb(this.realStartMs+i)):zo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?zo(t):zo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return zo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return zo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?zo(this.currentSighting.timeline.duration):this.canShowClockTime?mb(pb(this.realStartMs+this.realDurationMs)):zo(this.realDurationMs)}}function pb(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function mb(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function zo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const uM="rr0-ufo";function e3(){customElements.get(uM)||customElements.define(uM,Ve)}const i3="timechange",q8="recordingissues",n3="minifiedreset",Z8=`
|
|
6816
|
+
`);let e=Th.shared.get(t);return e||(e=this.fetchFirstAvailable(),Th.shared.set(t,e),e.then(i=>{i.length===0&&Th.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.4")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==Kg?[e,Kg]:[Kg]).map(i=>i+t)}}class ic{attribution="Roads © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Type autoroutier":{surface:"paved",widthM:11},"Route à 2 chaussées":{surface:"paved",widthM:7},"Route à 1 chaussée":{surface:"paved",widthM:5.5},"Rond-point":{surface:"paved",widthM:6},Bretelle:{surface:"paved",widthM:5},"Route empierrée":{surface:"gravel",widthM:3.5},Chemin:{surface:"dirt",widthM:3},"Piste cyclable":{surface:"paved",widthM:2.5}};static DEFAULT={surface:"paved",widthM:5};static KINDS={"Type autoroutier":"motorway","Route à 2 chaussées":"dual","Route à 1 chaussée":"road","Rond-point":"roundabout",Bretelle:"slip"};static DIRECTIONS={"Double sens":"both","Sens direct":"forward","Sens inverse":"backward"};platform;constructor(t={}){this.platform=new ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRoads(t){return(await this.platform.roads(t)).flatMap((i,n)=>ic.wayOf(i,n))}static wayOf(t,e){if(t.geometry.type!=="LineString")return[];const i=t.geometry.coordinates.map(([d,f])=>({lat:f,lng:d}));if(i.length<2)return[];const n=String(t.properties.nature??""),s=ic.BY_NATURE[n]??ic.DEFAULT,r=Number(t.properties.largeur_de_chaussee),a=Number(t.properties.nombre_de_voies),c=Number(t.properties.vitesse_moyenne_vl),l=ic.DIRECTIONS[String(t.properties.sens_de_circulation??"")],h=ic.KINDS[n],u=[t.properties.cpx_toponyme_route_nommee,t.properties.nom_voie_ban_gauche,t.properties.nom_voie_ban_droite].find(d=>typeof d=="string"&&d.length>0);return[{id:String(t.properties.cleabs??`ign-${e}`),...u?{name:u}:{},surface:s.surface,widthM:Number.isFinite(r)&&r>0?r:s.widthM,...t.properties.urbain===!0?{urban:!0}:{},...h?{kind:h}:{},...Number.isInteger(a)&&a>0?{lanes:a}:{},...l?{direction:l}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{},points:i}]}}class G8{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Roads © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRoads(t){if(ic.covers(t))try{const e=await this.regional.getRoads(t);if(e.length>0)return e}catch{}return this.worldwide.getRoads(t)}}class vf{attribution="Water © IGN, BD TOPO (Licence Ouverte 2.0)";platform;constructor(t={}){this.platform=new ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getWater(t){return(await this.platform.waterSurfaces(t)).flatMap((i,n)=>vf.surfacesOf(i,n))}static surfacesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="Polygon"?[n]:i==="MultiPolygon"?n:[],r=String(t.properties.cleabs??`ign-water-${e}`);return s.flatMap((a,c)=>{const l=a.map(h=>vf.open(h.map(u=>({lat:u[1],lng:u[0]})))).filter(h=>h.length>=3);return l.length>0?[{id:s.length>1?`${r}-${c}`:r,rings:l}]:[]})}static open(t){const e=t[0],i=t[t.length-1];return t.length>1&&e.lat===i.lat&&e.lng===i.lng?t.slice(0,-1):t}}class Xc{attribution="Water © OpenStreetMap contributors";client;constructor(t={}){this.client=new Hs(t)}async getWater(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];(way["natural"="water"](${e});way["waterway"="riverbank"](${e});)->.w;(relation["natural"="water"](${e});relation["waterway"="riverbank"](${e});)->.r;.w out geom;.r out body;way(r.r)(${e});out geom;`;return Xc.surfacesFrom(await this.client.query(i))}static surfacesFrom(t){const e=t.elements??[],i=new Map;for(const r of e)r.type==="way"&&r.id!==void 0&&r.geometry&&i.set(r.id,r.geometry.map(a=>({lat:a.lat,lng:a.lon})));const n=[],s=new Set;for(const r of e){if(r.type!=="relation")continue;const a=l=>(r.members??[]).filter(h=>h.type==="way"&&h.role===l&&h.ref!==void 0&&i.has(h.ref)).map(h=>(s.add(h.ref),i.get(h.ref))),c=Xc.rings(a("inner"));for(const[l,h]of Xc.rings(a("outer")).entries()){const u=c.filter(d=>Xc.contains(h,d[0]));n.push({id:`osm-r${r.id}-${l}`,rings:[h,...u]})}}for(const r of e)if(!(r.type!=="way"||!r.tags||r.id===void 0||s.has(r.id))&&!(r.tags.natural!=="water"&&r.tags.waterway!=="riverbank"))for(const a of Xc.rings([i.get(r.id)??[]]))n.push({id:`osm-w${r.id}`,rings:[a]});return n}static rings(t){const e=(s,r)=>s.lat===r.lat&&s.lng===r.lng,i=t.filter(s=>s.length>=2).map(s=>[...s]),n=[];for(;i.length>0;){let s=i.pop(),r=!0;for(;!e(s[0],s[s.length-1])&&r;){r=!1;for(let a=0;a<i.length;a++){const c=i[a],l=s[s.length-1];if(e(l,c[0]))s=[...s,...c.slice(1)];else if(e(l,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else continue;i.splice(a,1),r=!0;break}}s.length>=4&&e(s[0],s[s.length-1])&&n.push(s.slice(0,-1))}return n}static contains(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const r=t[n],a=t[s];r.lat>e.lat!=a.lat>e.lat&&e.lng<(a.lng-r.lng)*(e.lat-r.lat)/(a.lat-r.lat)+r.lng&&(i=!i)}return i}}class V8{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Water © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere";async getWater(t){if(vf.covers(t))try{const e=await this.regional.getWater(t);if(e.length>0)return e}catch{}return this.worldwide.getWater(t)}}const qg="https://ufoathome.org/water/index.json";class Rh{attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Rh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Water © OpenStreetMap contributors"}async getWater(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getWater(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.surfaces)?(this.attributionRead=s.attribution,s.surfaces):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
6817
|
+
`);let e=Rh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Rh.shared.set(t,e),e.then(i=>{i.length===0&&Rh.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.4")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==qg?[e,qg]:[qg]).map(i=>i+t)}}class Ns{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=Ns.key(t);let i=Ns.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Ns.asked.set(e,i),i.catch(()=>Ns.asked.delete(e))),structuredClone(await i)}static forget(){Ns.asked.clear()}static key(t){return`v${Ns.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Ns.openCache(),n=Ns.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<Ns.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Ns.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-Ns.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Ns.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class nc{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>nc.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=nc.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=nc.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=nc.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const m=f.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>nc.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:m}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class qn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new Hs(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${qn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${qn.ROUTES})$"];out body;`;return qn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=qn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(v=>re(v.lat,v.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(v=>v.service===!!r.service);for(const v of qn.samples(a)){u++;const M=qn.waysAt(d,v);if(M.length===0)continue;const[w]=M;w.name&&c.set(w.name,(c.get(w.name)??0)+1),w.voltageV&&l.set(w.voltageV,(l.get(w.voltageV)??0)+1);for(const y of new Set(M.flatMap(x=>x.services)))h.set(y,(h.get(y)??0)+1)}const f=v=>[...v.entries()].sort((M,w)=>w[1]-M[1])[0]?.[0],p=r.name??f(c),m=r.voltageV??(r.electrification==="none"?void 0:f(l)),g=[...h.entries()].filter(([,v])=>v*4>=u).sort((v,M)=>M[1]-v[1]||v[0].localeCompare(M[0])).map(([v])=>v);return{...r,...p?{name:p}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=qn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=qn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=qn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>re(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=qn.SAMPLE_M/2;a<n;a+=qn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(qn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=qn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class Ih{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new Hs(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Ih.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${qn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=qn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=qn.voltageOf(r),l=Ih.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Ih.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:Ih.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class W8{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!nc.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class pn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=pn.key(t);let i=pn.asked.get(e)??pn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},pn.asked.set(e,i),n.catch(()=>pn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){pn.asked.clear(),pn.failedAt=-1/0}static key(t){return`v${pn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of pn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await pn.openCache(),n=pn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<pn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-pn.failedAt<pn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(pn.failedAt=this.now(),s)return s;throw a}return i&&pn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-pn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(pn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const Zg="https://ufoathome.org/railways/index.json";class Dh{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Dh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
6818
|
+
`);let e=Dh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Dh.shared.set(t,e),e.then(i=>{i.length===0&&Dh.shared.delete(t)})),this.index=e}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.178.4")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==Zg?[e,Zg]:[Zg]).map(i=>i+t)}}function jA(){return{elevation:QA(),imagery:t3(),roads:X8(),water:$8(),railways:Y8()}}function QA(){return new z8(new Ne,new qA)}function t3(){return new JA}function X8(){return new Th({fallback:new G8(new ic,new Ko)})}function $8(){return new Rh({fallback:new Ns(new V8(new vf,new Xc))})}function Y8(){return new Dh({fallback:new pn(new W8(new nc,new Ih))})}const K8=new Set,Pa="show-observer-map",Na="hide-milestones",nl="minified";class Ve extends HTMLElement{static get observedAttributes(){return["src",Pa,Na,nl]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new vi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=bm.create();issues=[];issueCheck=0;sightingAudio=new hb;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new hb(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>Ve.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");Ve.setIcon(this.moreButton,t?Kt.UNFOLDED:Kt.FOLDED);const e=t?this.messages?.fewerControls??"":this.messages?.moreControls??"";this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Kt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await at(async()=>{const{VideoButton:s}=await import("./VideoButton-C62NkJrH.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?Of(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages?.placeObserverHere??"");return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<Ve.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=vi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=vi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Ve.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=vi.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${x8}</style>${w8}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new yu(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",a=>{a.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new Wc(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.citedMarks=this.shadow.getElementById("cited-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.playerTitleBox=this.shadow.getElementById("player-title"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",a=>{a.key!=="Enter"&&a.key!==" "||(a.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.tracesButton.addEventListener("click",()=>this.toggleTraces()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>{this.player.seek(this.snapSeekToMark(Number(this.seekInput.value))),this.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.seekPreview.hidden=!0,this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.chromeResizeObserver?.observe(this.chromeCanvas),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===Pa&&this.applyObserverMapDefault(),t===Na&&this.setMilestonesShown(!this.hasAttribute(Na)),t===nl){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(nl)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(n3)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await Sr.recording(t)}get sightingData(){return dE(this.currentSighting)}set sightingData(t){const e=ar.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=YM(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await at(async()=>{const{default:r}=await import("./sightingSchema-pBDQNwMz.js");return{default:r}},[],import.meta.url);n=new vr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],gf.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(q8,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=(this.messages?.recordingIssues??"").replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=gf.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<Ve.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(i3,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get playbackRate(){return this.player.playbackRate}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),Ve.setIcon(this.referencesButton,i?Kt.PICTURES_ON:Kt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),Ve.setIcon(this.tracesButton,this.tracesShownState?Kt.TRACES_ON:Kt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?ud(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages?.moments??"",this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||(this.messages?.moments??"");this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=Ve.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){if(t.buttons!==0){this.seekPreview.hidden=!0;return}const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=Ve.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?Of(a,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new yu(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=Ve.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?Of(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Ur.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ve.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ve.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ve.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ve.EXPOSURE_STEP_PX),s=Math.min(Ve.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=_i.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:K8;this.canvasRenderer.setStarPoints(_i.starPointsOf(this.sighting.instrument,Pe(this.sighting,t)?.fNumber));const n=(Pe(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?nr.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(aE(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new b8(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*Ve.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Kt.PLAY:Kt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){Ve.icons.get(t)!==e&&(Ve.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(t){this.quietControlsValue=t,this.stageElement.classList.toggle("quiet",t)}tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},Ve.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&(!this.quietControlsValue||this.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),Ve.setIcon(this.playPauseButton,t?Kt.PAUSE:Kt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages?.pause??"":this.messages?.play??"":this.messages?.noDuration??"";this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(Pa),e=t===null?this.sighting.observerMap??this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;Ve.setIcon(this.observerMapButton,t?Kt.MAP_ON:Kt.MAP_OFF);const e=t?this.messages?.hideObserverMap??"":this.messages?.showObserverMap??"";this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages?.zoomMapIn??""],[this.mapZoomOutButton,this.messages?.zoomMapOut??""],[this.mapFitButton,this.messages?.fitMap??""]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=Qh.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=vi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||(this.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?vi.expand(t,Ve.OBSERVER_MAP_IMAGERY_AHEAD):t,n=vi.IMAGERY_PX*(e?1+2*Ve.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:t3();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??s).attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?vi.expand(t,Ve.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages?.mapImageryUnavailable??"":this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=Ve.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=Pe(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},Ve.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?Of(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?ud(this.currentSighting.milestones):[]){const a=Pe(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Aa.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(_i.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages?.observerHere??"",nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,ud(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages?.moments??"",Ve.setIcon(this.milestonesButton,this.milestonesShown?Kt.MILESTONES_ON:Kt.MILESTONES_OFF);const t=this.milestonesShown?this.messages?.hideMilestones??"":this.messages?.showMilestones??"";this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=Pe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Xr(i,t),{lat:s,lng:r}=$s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages?.decorHere??""}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=Pe(this.currentSighting,this.currentTime),s=Aa.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return li.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=Ve.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),Ve.setIcon(this.miniMuteButton,this.mutedState?Kt.MUTED:Kt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){Ve.setIcon(this.muteButton,Kt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}Ve.setIcon(this.muteButton,this.mutedState?Kt.MUTED:Kt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;Ve.setIcon(this.fullscreenButton,t?Kt.EXIT_FULLSCREEN:Kt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages?.exitFullscreen??"":this.messages?.fullscreen??"",this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Qn(Ws.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=vo(Ws.preferencesFor(this),Mo);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await IT.load(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages?.switchToElapsed??"":this.messages?.switchToClockTime??"",e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=(this.messages?.currentPosition??"")+e,this.timeEndLabel.title=(this.messages?.duration??"")+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=rE(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?K1(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return zo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?mb(pb(this.realStartMs+i)):zo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?zo(t):zo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return zo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return zo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?zo(this.currentSighting.timeline.duration):this.canShowClockTime?mb(pb(this.realStartMs+this.realDurationMs)):zo(this.realDurationMs)}}function pb(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function mb(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function zo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const uM="rr0-ufo";function e3(){customElements.get(uM)||customElements.define(uM,Ve)}const i3="timechange",q8="recordingissues",n3="minifiedreset",Z8=`
|
|
6819
6819
|
varying vec3 vDir;
|
|
6820
6820
|
varying vec3 vWorldDir;
|
|
6821
6821
|
|
|
@@ -9002,7 +9002,7 @@ ${l.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissive
|
|
|
9002
9002
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
9003
9003
|
}
|
|
9004
9004
|
`,transparent:!0,depthWrite:!1,side:Tn,fog:!1,blending:Ml,blendSrc:yl,blendDst:af})}static wallReflectance(t,e,i){const n=i(t,1,e);return 2*n/(1+n)}setSurroundings(t){this.uniforms.uSurroundings.value=t}static reflectedResponse(t,e){return Bt.respond(e*Bt.relativeOfResponse(Math.max(t,1e-5)))}}class ks{static SIZE=64;static MOVE_M=.01;holder=new Bi;cameras=[];faces=[];target=new Qe(ks.SIZE,ks.SIZE);white=new Is({color:new rt(1,1,1),side:Tn});scene=new hr;cabin;meshes=0;eye=new T;scratch=new T;constructor(){const t=[[new T(1,0,0),new T(0,1,0)],[new T(-1,0,0),new T(0,1,0)],[new T(0,1,0),new T(0,0,1)],[new T(0,-1,0),new T(0,0,-1)],[new T(0,0,1),new T(0,1,0)],[new T(0,0,-1),new T(0,1,0)]];for(const[e,i]of t){const n=new jn(90,1,.02,20);n.up.copy(i),n.lookAt(e),this.holder.add(n),this.cameras.push(n),this.faces.push(new Uint8Array(ks.SIZE*ks.SIZE*4))}this.scene.background=new rt(0,0,0)}get any(){return this.cabin!==void 0}update(t,e,i){if(!e){this.forget();return}e.updateWorldMatrix(!0,!0);const n=this.scratch.copy(i);e.worldToLocal(n);let s=0;e.traverse(r=>{r.isMesh&&s++}),!(e===this.cabin&&s===this.meshes&&n.distanceTo(this.eye)<ks.MOVE_M)&&(this.cabin=e,this.meshes=s,this.eye.copy(n),this.draw(t,e))}hides(t){if(!this.cabin)return!1;this.holder.updateWorldMatrix(!0,!0);for(let e=0;e<6;e++){const i=this.cameras[e],n=this.scratch.copy(t).transformDirection(i.matrixWorldInverse);if(n.z>=0)continue;const s=n.x/-n.z,r=n.y/-n.z;if(Math.abs(s)>1||Math.abs(r)>1)continue;const a=Math.min(ks.SIZE-1,Math.floor((s+1)/2*ks.SIZE)),c=Math.min(ks.SIZE-1,Math.floor((r+1)/2*ks.SIZE));return this.faces[e][(c*ks.SIZE+a)*4]>127}return!1}forget(){this.holder.removeFromParent(),this.cabin=void 0,this.meshes=0}dispose(){this.forget(),this.target.dispose(),this.white.dispose()}draw(t,e){e.add(this.holder),this.holder.position.copy(this.eye),this.holder.updateWorldMatrix(!0,!0);const i=[];e.traverse(r=>{const a=r;if(!a.isMesh||!a.visible||(Array.isArray(a.material)?a.material:[a.material]).every(h=>h instanceof xo))return;const l=new yt(a.geometry,this.white);l.matrixAutoUpdate=!1,l.matrix.copy(a.matrixWorld),l.matrixWorld.copy(a.matrixWorld),i.push(l)});for(const r of i)this.scene.add(r);const n=t.getRenderTarget(),s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;for(let r=0;r<6;r++){const a=this.cameras[r];a.updateMatrixWorld(!0),t.setRenderTarget(this.target),t.clear(),t.render(this.scene,a),t.readRenderTargetPixels(this.target,0,0,ks.SIZE,ks.SIZE,this.faces[r])}t.setRenderTarget(n),t.shadowMap.autoUpdate=s;for(const r of i)r.removeFromParent()}}const c1="https://ufoathome.org/models/index.json";class _d{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??wL()}async entries(t){const e=await this.load();return t?e.filter(i=>[i.kind].flat().includes(t)):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){if(this.loading)return this.loading;if(!this.sharing)return this.loading=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
9005
|
-
`);let e=_d.shared.get(t);return e||(e=this.fetchFirstAvailable(),_d.shared.set(t,e),e.then(i=>{i.length===0&&_d.shared.delete(t)})),this.loading=e}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function wL(){const o=`?v=${encodeURIComponent("0.178.
|
|
9005
|
+
`);let e=_d.shared.get(t);return e||(e=this.fetchFirstAvailable(),_d.shared.set(t,e),e.then(i=>{i.length===0&&_d.shared.delete(t)})),this.loading=e}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function wL(){const o=`?v=${encodeURIComponent("0.178.4")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==c1?[t,c1]:[c1]).map(e=>e+o)}const xL=Re.point("decorModels").provide(Re.BUILT_IN,[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new _d}]);class S3{constructor(t,e=xL){this.preferredId=t,this.sources=e}attribution="3D models, each under its own author's licence";built=new Map;catalogues(){const t=this.sources.find(i=>i.id===this.preferredId)??this.sources[0];return(t?[t,...this.sources.filter(i=>i!==t)]:[]).map(i=>{let n=this.built.get(i);return n||(n=i.create(),this.built.set(i,n)),n})}entries(t){const e=this.catalogues()[0];return e?e.entries(t):Promise.resolve([])}async entry(t){for(const e of this.catalogues()){const i=await e.entry(t).catch(()=>{});if(i)return i}}async moduleOf(t){const e=Re.point("decorModels");for(const i of this.sources){const n=e.ownerOf(i.id);if(!(n===void 0||n===Re.BUILT_IN)&&await this.catalogueOf(i).entry(t).catch(()=>{}))return n}}catalogueOf(t){return this.catalogues(),this.built.get(t)}}async function l1(o){const{GLTFLoader:t}=await at(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-VIIHsteW.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(o,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${o}: ${s instanceof Error?s.message:String(s)}`)))})}class sr{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new yt(new vs(2,2),new De({uniforms:{uColor:{value:new rt(0,0,0)},uRadius:{value:1}},vertexShader:sr.VERTEX,fragmentShader:sr.FRAGMENT,transparent:!0,depthWrite:!1,blending:Cn,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*sr.MIN_ANGLE_RAD),r=sr.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(sr.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(sr.MAX_SHARE*sr.FILL*Math.PI))}static VERTEX=`
|
|
9006
9006
|
uniform float uRadius;
|
|
9007
9007
|
varying vec2 vOffset;
|
|
9008
9008
|
void main() {
|
|
@@ -9868,9 +9868,9 @@ ${Mi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,ima
|
|
|
9868
9868
|
<button id="copy" class="share-copy" type="button"></button>
|
|
9869
9869
|
</div>
|
|
9870
9870
|
</dialog>
|
|
9871
|
-
`;class fl extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get(fl.TAG)||customElements.define(fl.TAG,fl)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=$7;const t=e=>this.shadow.getElementById(e);this.dialog=t("dialog"),this.linkField=t("link"),this.copyButton=t("copy"),this.linkBox=t("link-box"),this.embedBox=t("embed-box"),this.linkOption=t("link-option"),this.embedOption=t("embed-option"),this.pin=t("pin"),this.embedMarkup=t("embed-markup"),this.noteElement=t("note"),t("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",e=>{e.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(t){const e=++this.languageToken,i=await kT.load(t);if(e===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(t){this.noteElement.textContent=t??"",this.noteElement.hidden=t===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const t=this.subject;if(!t)return;const e=this.pin.checked;this.linkField.value=e?ba.pinnedLink(t.link(),"0.178.
|
|
9872
|
-
${t.element()}`;this.embedMarkup.value=n,this.codeEditor&&(this.codeEditor.text=n)}applyMessages(){const t=this.messages;if(!t)return;const e=(i,n)=>{this.shadow.getElementById(i).textContent=n};e("title",t.share),e("link-label",t.link),e("embed-label",t.embed),e("copy",t.copy),e("pin-label",t.pin.replace("{version}","0.178.2")),this.pin.parentElement.title=t.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",t.close),this.linkField.setAttribute("aria-label",t.link)}show(t){this.linkBox.hidden=t!=="link",this.embedBox.hidden=t!=="embed",this.linkOption.setAttribute("aria-pressed",String(t==="link")),this.embedOption.setAttribute("aria-pressed",String(t==="embed")),t==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=at(async()=>{const{ShareCodeEditor:t}=await import("./ShareCodeEditor-C53SBK2N.js");return{ShareCodeEditor:t}},[],import.meta.url).then(({ShareCodeEditor:t})=>{this.codeEditor=new t(this.shadow.getElementById("embed-code"),this.embedMarkup.value,e=>{this.embedMarkup.value=e},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(t,e){try{await navigator.clipboard.writeText(t),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{e.select()}}}class Zn{static PLAIN=/^\d+(?:[.,]\d+)?$/;static COLONS=/^(?:(\d+):)?(\d{1,2}):(\d{1,2}(?:[.,]\d+)?)$/;static UNITS=/^(?:(\d+(?:[.,]\d+)?)h)?(?:(\d+(?:[.,]\d+)?)m)?(?:(\d+(?:[.,]\d+)?)s)?$/i;static CLOCK=/^(?:(\d{4})-(\d{2})-(\d{2})[T ])?T?(\d{1,2}):(\d{2})(?::(\d{2}(?:[.,]\d+)?))?$/;static num(t){return t===void 0?0:Number(t.replace(",","."))}static delta(t){const e=(t??"").trim();if(e==="")return;if(Zn.PLAIN.test(e))return Zn.num(e);const i=Zn.COLONS.exec(e);if(i){const[,s,r,a]=i;return Number(r)>=60||Zn.num(a)>=60?void 0:Zn.num(s)*3600+Number(r)*60+Zn.num(a)}const n=Zn.UNITS.exec(e);return n&&(n[1]!==void 0||n[2]!==void 0||n[3]!==void 0)?Zn.num(n[1])*3600+Zn.num(n[2])*60+Zn.num(n[3]):/^P/i.test(e)?Gh.seconds(e.toUpperCase()):void 0}static isClock(t){return Zn.clock(t)!==void 0}static clock(t){const e=Zn.CLOCK.exec((t??"").trim());if(!e)return;const[,i,n,s,r,a,c]=e,l={hour:Number(r),minute:Number(a),second:Zn.num(c)};if(!(l.hour>=24||l.minute>=60||l.second>=60)){if(i!==void 0){const h={year:Number(i),month:Number(n),day:Number(s)};if(h.month<1||h.month>12||h.day<1||h.day>31)return;l.date=h}return l}}static elapsedSince(t,e){if(!t||t.hour===void 0||t.minute===void 0)return;const i=t.hour*3600+t.minute*60+(t.second??0),n=e.hour*3600+e.minute*60+e.second;if(e.date){if(t.year===void 0||t.month===void 0||t.day===void 0)return;const r=Date.UTC(e.date.year,e.date.month-1,e.date.day)/1e3+n,a=Date.UTC(t.year,t.month-1,t.day)/1e3+i;return Math.max(0,r-a)}let s=n-i;return s<=-43200&&(s+=86400),Math.max(0,s)}}Yy();fl.register();const w0=wu.home(),Qp="compare-account",G1="start-time",KS="start-clock",Kc="observer",x0="case-named",Od="show-info",b0="interpretation",Bh="hide-pickers",t0="case",e0="account",i0="variant-",V1=`${w0}/edit/`;class qc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Od,Bh,b0,x0,G1,KS,Kc,Pa,Na,Qp]}shadow;sceneElement;toolbarElement;accountElement;accountPrefix;caseOfElement;observerText;observerSelect;infoButton;infoPanel;infoAppLink;editLink;readingFindingsElement;readingSensible=!1;readingCheck;bestCases;readingScene=!1;readingEntry;static VERDICT_COLOURS={incompatible:"#e04848",unsettled:"#e08a2c",compatible:"#2e9d5b"};infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;shareButton;shareDialog;shareStartOn;shareStart;shareScopeRow;shareScopeLabel;shareScope;shareOpensRow;shareOpensLabel;shareOpens;shareStartLabel;shareOptions;labelsToggle;paramSummary;summaryBuilder;summarySignature="";assessmentEntries=[];assessmentToken=0;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];caseSource;interpretationChoice;interpretationLabel;interpretationSelect;confrontationElement;confrontationHeading;confrontationList;compareButton;variantChips;variantMoved;interpretationLoaders=new Map;interpretationToken=0;offeredFor;currentSrc;infoOpen=!1;creditsOpen=!1;labelsShown=!1;language="en";messages;ready=Promise.resolve();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${WT}</style>${VT}`,this.shadow.appendChild(t.content.cloneNode(!0)),customElements.upgrade(this.shadow),this.sceneElement=document.createElement(wf),this.forwardPlayerAttributes(),this.sceneElement.ufoElement.creditShownExternally=!0,this.sceneElement.ownCredits=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.accountElement=this.shadow.getElementById("account"),this.accountPrefix=this.shadow.getElementById("account-prefix"),this.caseOfElement=this.shadow.getElementById("case-of"),this.observerText=this.shadow.getElementById("observer-text"),this.observerSelect=this.shadow.getElementById("observer"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.editLink=this.shadow.getElementById("edit-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("labels-button"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.shareButton=document.createElement("button"),this.shareButton.type="button",this.shareButton.id="share-button",this.shareButton.setAttribute("aria-haspopup","dialog"),this.shareButton.innerHTML=Kt.SHARE,this.sceneElement.ufoElement.addControl(this.shareButton),this.shareDialog=this.shadow.getElementById("share-dialog"),this.shareDialog.subject=this.shareSubject,this.shareStartOn=this.shadow.getElementById("share-start-on"),this.shareStart=this.shadow.getElementById("share-start"),this.shareStartLabel=this.shadow.getElementById("share-start-label"),this.shareScopeRow=this.shadow.getElementById("share-scope-row"),this.shareScopeLabel=this.shadow.getElementById("share-scope-label"),this.shareScope=this.shadow.getElementById("share-scope"),this.shareOpensRow=this.shadow.getElementById("share-opens-row"),this.shareOpensLabel=this.shadow.getElementById("share-opens-label"),this.shareOpens=this.shadow.getElementById("share-opens");const e=n=>({input:this.shadow.getElementById(`share-opt-${n}`),label:this.shadow.getElementById(`share-opt-${n}-label`)});this.shareOptions={labels:e("labels"),map:e("map"),milestones:e("milestones"),compare:e("compare")},this.interpretationChoice=this.shadow.getElementById("interpretation-choice"),this.interpretationLabel=this.shadow.getElementById("interpretation-label"),this.interpretationSelect=this.shadow.getElementById("interpretation"),this.confrontationElement=this.shadow.getElementById("confrontation"),this.confrontationHeading=this.shadow.getElementById("confrontation-heading"),this.confrontationList=this.shadow.getElementById("confrontation-list"),As.register(),this.readingFindingsElement=this.shadow.getElementById("reading-findings");const i=this.shadow.getElementById("reading-chip");i.addEventListener("click",()=>{const n=i.getAttribute("aria-expanded")!=="true";i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById("reading-findings-list").hidden=!n}),this.compareButton=this.shadow.getElementById("compare-account"),this.variantChips=this.shadow.getElementById("variant-chips"),this.variantMoved=this.shadow.getElementById("variant-moved"),this.compareButton.addEventListener("click",()=>this.setComparing(!this.sceneElement.compareAccount)),this.observerSelect.addEventListener("change",()=>this.selectObserver(this.observerSelect.value)),this.interpretationSelect.addEventListener("change",()=>void this.chooseInterpretation(this.interpretationSelect.value)),this.sceneElement.addEventListener($y,n=>this.showConfrontation(n.detail)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",n=>{n.newState==="open"&&(this.populateInfoPanel(),this.bringInfoButtonIntoView())}),this.infoPanel.addEventListener("toggle",n=>this.syncInfoOpen(n.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.shareButton.addEventListener("click",()=>this.openShare());for(const n of[this.shareStartOn,this.shareStart,...Object.values(this.shareOptions).map(s=>s.input)])n.addEventListener("input",()=>this.refreshShareLinks());for(const n of[this.shareScope,this.shareOpens])n.addEventListener("change",()=>this.refreshShareLinks());this.isConnected&&(this.ready=this.loadLocaleMessages())}get scene(){return this.sceneElement}async loadLocaleMessages(){const t=++this.localeToken,e=Ws.preferencesFor(this);this.preferences=e;const i=vo(e,Mo),[n,s,r,a]=await Promise.all([CT.load(i),FT(i),ME(i),r8.load(i)]);if(t!==this.localeToken)return;const c=i!==this.language||this.messages===void 0;this.language=i,this.messages=n,this.readingCheck=new fn(a),this.bestCases=new ee(a),this.tags=new lM(s),this.said=new Qn(e),this.summaryBuilder=new Vc(this.messages,new kM(r),this.said,this.tags,{messages:this.messages,locale:i}),this.accountPrefix.textContent=this.messages?.accountBy??"",this.interpretationLabel.textContent=this.messages?.interpretation??"",this.confrontationHeading.textContent=this.messages?.confrontation??"";const l=this.entries.find(h=>h.src===this.currentSrc);l&&this.offerInterpretations(l),this.updateCompareButton(),this.infoButton.title=this.messages?.about??"",this.infoButton.setAttribute("aria-label",this.messages?.about??""),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??""),this.infoCloseButton.setAttribute("aria-label",this.messages?.close??""),this.infoObservationHeading.textContent=this.messages?.observation??"",this.infoCreditsToggle.textContent=this.messages?.credits??"",this.syncLabelsToggle(),this.refreshParamSummary(),c&&this.currentSrc&&this.runAssessments(),this.shareButton.title=this.messages?.share??"",this.shareButton.setAttribute("aria-label",this.messages?.share??""),this.shareStartLabel.textContent=this.messages?.shareStartAt??"",this.shareScopeLabel.textContent=this.messages?.shareScope??"",this.shareOpensLabel.textContent=this.messages?.shareOpensOn??"",this.shareOptions.labels.label.textContent=this.messages?.shareOptionLabels??"",this.shareOptions.map.label.textContent=this.messages?.shareOptionMap??"",this.shareOptions.milestones.label.textContent=this.messages?.shareOptionMilestones??"",this.shareOptions.compare.label.textContent=this.messages?.shareOptionCompare??"",this.shareStart.setAttribute("aria-label",this.messages?.shareStartAt??""),this.shareDialog.useLanguage(i),this.infoOpen&&this.populateInfoPanel(),this.updateAccountLine()}preferences=[];localeToken=0;said=new Qn(["en"]);tags=new lM({});connectedCallback(){Ws.preferencesFor(this).join()!==this.preferences.join()&&(this.ready=this.loadLocaleMessages()),this.applyAskedInfo();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}applyAskedInfo(){this.isConnected&&this.hasAttribute(Od)!==this.infoOpen&&this.toggleInfoPanel()}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===b0){const n=this.entries.find(s=>s.src===this.currentSrc);n&&this.offerInterpretations(n)}if(t===Bh){const n=this.entries.find(s=>s.src===this.currentSrc);this.setEntries(this.entries,this.caseSource),n&&this.offerInterpretations(n)}if(t===Od&&this.applyAskedInfo(),t==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels")),(t===Pa||t===Na)&&this.forwardPlayerAttributes(),t===Kc&&this.entries.length>1){const n=this.entryAsked(this.entries);n&&n.src!==this.currentSrc&&this.selectObserver(n.src)}t===Qp&&this.setComparing(this.hasAttribute(Qp))}forwardPlayerAttributes(){for(const t of[Pa,Na]){const e=this.getAttribute(t);e===null?this.sceneElement.removeAttribute(t):this.sceneElement.setAttribute(t,e)}}async loadFromSrc(t){this.startPending=!0;const e=Sr.recording(t);this.sceneElement.holdForNewScene(e);const i=await e;if(Array.isArray(i))throw new Error(`${t} is a bare list of recordings, which is no longer read: list them as the sighting events of a case.json`);if(Ui.isCase(i)){Ui.check(i);const n=Ui.sightingUrls(i,new URL(t,location.href).href);if(n.length===0)throw new Error(`${t} is a case with no sighting event: no recording to show`);await this.loadObserverUrls(n,{json:i,url:new URL(t,location.href).href})}else this.setEntries([{src:t,sighting:i}],void 0)}get sightingData(){return this.entries.find(t=>t.src===this.currentSrc)?.sighting}set sightingData(t){const e=ar.recording(t);this.startPending=!0,this.currentSrc="",this.setEntries([{src:"",sighting:e}],void 0)}seekTo(t,e){const i=this.caseSource,n=e===void 0?void 0:this.entries.find(s=>{const r=this.plain(s).id;return(i?Ui.accountIds(i.json,i.url,s.src,r):[r]).includes(e)});n&&n.src!==this.currentSrc&&this.selectObserver(n.src),this.sceneElement.ufoElement.currentTime=Math.max(0,t)*1e3}set citedMoments(t){this.sceneElement.ufoElement.citedMoments=t}get playedSeconds(){return this.sceneElement.ufoElement.currentTime/1e3}get observerUrls(){return this.entries.map(t=>t.src)}set observerUrls(t){this.loadObserverUrls(t)}async loadObserverUrls(t,e){const i=await Promise.all(t.map(async n=>({src:n,sighting:await Sr.recording(n)})));this.setEntries(i,e)}reportCaseProblems(t,e){const{duplicateIds:i,unresolved:n}=Ui.problems(t,e.map(s=>this.plain(s).id).filter(s=>s!==void 0));for(const s of i)console.warn(`The case ${t.id??""} gives the id "${s}" to more than one event: a reference to it is ambiguous.`);for(const{reading:s,reference:r}of n)console.warn(`The reading ${s} of the case ${t.id??""} is "interpretationOf" "${r}", which no event of the case has as its id, nor any recording it lists.`)}setEntries(t,e){this.entries=t.map(r=>({...r,sighting:ar.recording(r.sighting)})),this.caseSource=e,e&&this.reportCaseProblems(e.json,t),this.toolbarElement.hidden=t.length===0;const i=t.length>1&&!this.hasAttribute(Bh);this.observerSelect.hidden=!i,this.observerText.hidden=i,this.observerSelect.innerHTML="";const n=t.map((r,a)=>this.observerDisplayName(this.plain(r).observer)??this.caseTitleOf(r)??(this.messages?.unnamedObserver??"").replace("{n}",String(a+1)));for(const[r,a]of t.entries()){const c=document.createElement("option");c.value=a.src;const l=n.filter(h=>h===n[r]).length>1;c.textContent=(l?this.caseTitleOf(a):void 0)??n[r],this.observerSelect.appendChild(c)}const s=t.find(r=>r.src===this.currentSrc)??this.entryAsked(t)??t[0];s?this.selectObserver(s.src):this.updateAccountLine()}entryAsked(t){const e=this.getAttribute(Kc)?.trim();if(!e)return;const i=t.find(r=>this.plain(r).observer?.id===e);if(i)return i;const n=this.caseSource;if(n){const r=t.find(a=>Ui.accountIds(n.json,n.url,a.src,this.plain(a).id).includes(e));if(r)return r}const s=t.find(r=>r.src.split("/").pop()===e.split("/").pop());return s||(/^\d+$/.test(e)?t[Number(e)-1]:void 0)}observerKeyOf(t){return this.plain(t).observer?.id??String(this.entries.indexOf(t)+1)}sharedEntry(){const t=this.shareScope.value;if(!(!this.caseSource||t===t0))return this.entries.find(e=>e.src===t)}get sharesCase(){return this.caseSource!==void 0&&!this.shareScopeRow.hidden&&this.shareScope.value===t0}editorUrl(){if(!this.currentSrc)return V1;const t=new URL(this.currentSrc,location.href),e=this.caseSource;return e?`${V1}?file=${encodeURIComponent(e.url)}&track=${encodeURIComponent(this.shownTrackUrl()??t.href)}`:`${V1}?file=${encodeURIComponent(t.href)}`}get editorHref(){return this.editorUrl()}shownTrackUrl(){return this.readingUrlOf(this.interpretationSelect.value)}shareSubject={module:"rr0-sighting",link:()=>this.playUrl(),element:()=>this.replayElement()};replayElement(){const t=this.sharedAddress(),i=[...t.observer?[[Kc,t.observer]]:[],...this.replayAttributes()].map(([n,s])=>s===""?` ${n}`:` ${n}="${s}"`).join("");return`<rr0-sighting src="${t.src}"${i}></rr0-sighting>`}playUrl(){const t=this.sharedAddress(),e=[...t.observer?[`${Kc}=${encodeURIComponent(t.observer)}`]:[],...this.replayQuery()].join("&");return t.src?`${w0}/play/?file=${encodeURIComponent(t.src)}${e&&"&"+e}`:`${w0}/play/${e&&"?"+e}`}sharedAddress(){const t=e=>e?new URL(e,location.href).href:"";if(this.sharesCase){const e=this.entries.find(i=>i.src===this.shareOpens.value)??this.entries.find(i=>i.src===this.currentSrc);return{src:this.caseSource.url,observer:e?this.observerKeyOf(e):void 0}}return{src:t(this.sharedEntry()?.src??this.currentSrc??"")}}replayAttributes(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push([G1,String(this.shareStartSeconds)]),t.labels.input.checked&&e.push(["show-labels",""]),t.map.input.checked&&e.push([Pa,""]),t.milestones.input.checked||e.push([Na,""]),t.compare.input.checked&&e.push([Qp,""]),e}replayQuery(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push(`d=${this.shareStartSeconds}`),t.labels.input.checked||e.push("labels=0"),t.map.input.checked&&e.push("map=1"),t.milestones.input.checked||e.push("moments=0"),t.compare.input.checked&&e.push("compare=1"),e}get shareStartSeconds(){const t=Math.floor(Number(this.shareStart.value));return this.shareStartOn.checked&&Number.isFinite(t)&&t>=0?t:void 0}refreshShareLinks(){this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.refresh()}openShare(){const t=this.sceneElement.ufoElement;this.shareStart.max=String(Math.floor(t.seekableDuration/1e3)),this.shareStart.value=String(Math.floor(t.currentTime/1e3)),this.shareStartOn.checked=!1,this.shareOptions.labels.input.checked=this.labelsShown,this.shareOptions.map.input.checked=t.observerMapOpen,this.shareOptions.milestones.input.checked=t.milestonesVisible,this.shareOptions.compare.input.checked=this.sceneElement.compareAccount,this.offerShareScope(),this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.open()}offerShareScope(){const t=this.caseSource!==void 0&&this.entries.length>1&&!this.hasAttribute(x0);if(this.shareScopeRow.hidden=!t,this.shareScope.innerHTML="",this.shareOpens.innerHTML="",!t)return;const e=(i,n,s)=>{const r=document.createElement("option");r.value=n,r.textContent=s,i.appendChild(r)};e(this.shareScope,t0,this.messages?.shareScopeCase??"");for(const i of this.entries){const n=this.observerDisplayName(this.plain(i).observer)??this.caseTitleOf(i)??(this.messages?.unnamedObserver??"").replace("{n}",String(this.entries.indexOf(i)+1));e(this.shareScope,i.src,n),e(this.shareOpens,i.src,n)}this.shareScope.value=t0,this.shareOpens.value=this.currentSrc??this.entries[0].src}offerInterpretations(t){const e=this.offeredFor===t.sighting,i=this.interpretationSelect.value;this.offeredFor=t.sighting,this.interpretationToken++,this.interpretationLoaders=new Map,this.interpretationSelect.innerHTML="";const n=(u,d,f)=>{const p=document.createElement("option");p.value=u,p.textContent=d,this.interpretationSelect.appendChild(p),this.interpretationLoaders.set(u,f)},s=t===this.entries.find(u=>u.src===this.currentSrc),r=s?this.sceneElement.ufoElement.sighting.interpretation:void 0;n(e0,this.messages?.account??"",()=>Promise.resolve(r));const a=this.caseSource;a&&Ui.interpretationEvents(a.json,Ui.accountIds(a.json,a.url,t.src,this.plain(t).id)).forEach((u,d)=>{const f=this.said.read(u.title)??`#${d+1}`,p=(u.by??[]).map(m=>this.agentName(m)).filter(Boolean).join(", ");n(`case-${d}`,p?(this.messages?.interpretationBy??"").replace("{title}",f).replace("{by}",p):f,()=>Ui.interpretationOf(u,a.url,m=>Sr.recording(m)))});const c=s?this.keptVariants(t):[];for(const{index:u,kept:d}of c)n(`${i0}${u}`,`${this.variantLabel(d)} (${this.messages?.verdicts[d.variant.verdict]??""})`,()=>Promise.resolve(d.bodies.length>0?d:void 0));const l=e&&[...this.interpretationSelect.options].some(u=>u.value===i),h=this.askedInterpretation()??(l?i:e0);this.interpretationSelect.value=h,h===e0?this.sceneElement.interpretation!==r&&(this.sceneElement.interpretation=r):this.sceneElement.interpretation||this.chooseInterpretation(h),this.interpretationChoice.hidden=this.interpretationSelect.options.length<2||this.hasAttribute(Bh),this.showConfrontation(this.sceneElement.confrontation),this.updateCompareButton(),this.showVariants(c)}keptVariants(t){const e={consolidated:0,contested:1,incompatible:2};return(t.sighting.variants??[]).map((i,n)=>({index:n,kept:i})).filter(({kept:i})=>i.variant).sort((i,n)=>e[i.kept.variant.verdict]-e[n.kept.variant.verdict]||i.kept.variant.cost-n.kept.variant.cost)}variantLabel(t){return(this.messages?.variant??"").replace("{name}",t.variant.label??t.variant.candidate)}showVariants(t){if(!this.messages)return;if(this.variantChips.innerHTML="",this.variantChips.hidden=t.length===0,t.length===0){this.showVariantMoved();return}const e=(i,n,s)=>{const r=document.createElement("button");r.type="button",r.dataset.value=i,s&&(r.dataset.verdict=s,r.title=this.messages.verdicts[s],r.append(Object.assign(document.createElement("span"),{className:"dot"}))),r.append(n),r.addEventListener("click",()=>{this.interpretationSelect.value!==i&&(this.interpretationSelect.value=i,this.chooseInterpretation(i))}),this.variantChips.append(r)};e(e0,this.messages?.account??"");for(const{index:i,kept:n}of t)e(`${i0}${i}`,n.variant.label??n.variant.candidate,n.variant.verdict);this.showVariantMoved()}showVariantMoved(){if(!this.messages)return;const t=this.interpretationSelect.value;for(const s of this.variantChips.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s.dataset.value===t));this.variantMoved.innerHTML="";const e=t.startsWith(i0)?Number(t.slice(i0.length)):-1,i=this.sceneElement.ufoElement.sighting.variants?.[e]?.variant;if(this.variantMoved.hidden=!i||i.moved.length+(i.readings?.length??0)===0,!i)return;const n=new Intl.NumberFormat(this.language,{maximumFractionDigits:1});for(const s of i.moved){const[r,a]=s.field==="time"?["0 min",`${s.variant>0?"+":""}${n.format(s.variant)} min`]:s.field==="duration"?[`${n.format(s.stated)} s`,`${n.format(s.variant)} s`]:[`${n.format(s.stated)}°`,`${n.format(s.variant)}°`],c=document.createElement("span");c.append(`${this.messages.variantFields[s.field]}${this.colon}`,Object.assign(document.createElement("s"),{textContent:r})," → ",Object.assign(document.createElement("b"),{textContent:a})),this.variantMoved.append(c)}for(const s of i.readings??[]){const r=this.messages.variantReadings[s.reading];r&&this.variantMoved.append(Object.assign(document.createElement("span"),{className:"reading",textContent:r}))}}setComparing(t){this.sceneElement.compareAccount=t,this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation)}updateCompareButton(){const t=this.sceneElement.compareAccount;this.compareButton.hidden=!this.sceneElement.interpretation,this.compareButton.setAttribute("aria-pressed",String(t));const e=t?this.messages?.hideComparison??"":this.messages?.showComparison??"";this.compareButton.title=e,this.compareButton.setAttribute("aria-label",e)}get colon(){return this.language==="fr"?" : ":": "}askedInterpretation(){const t=this.getAttribute(b0)?.trim(),e=this.caseSource;if(!t||!e)return;const i=this.entries.find(r=>r.src===this.currentSrc);if(!i)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id)).findIndex(r=>r.id===t||typeof r.url=="string"&&new URL(r.url,e.url).href===new URL(t,location.href).href);return s>=0?`case-${s}`:void 0}async chooseInterpretation(t){const e=++this.interpretationToken,i=this.interpretationLoaders.get(t),n=i?await i().catch(d=>{console.warn(`<rr0-sighting>: could not read interpretation "${t}":`,d)}):void 0,s=this.readingUrlOf(t),r=s?await Sr.recording(s).catch(()=>{}):void 0;if(e!==this.interpretationToken)return;const a=this.entries.find(d=>d.src===this.currentSrc),c=a&&r&&"timeline"in r?this.bestCases?.bestSceneOf(a.sighting,r):void 0,l=c??r,h=c?.interpretation&&n?{...n,bodies:[...n.bodies.map(d=>{const f=c.interpretation.bodies.find(p=>p.id===d.id);return f?{...d,track:f.track}:d}),...c.interpretation.bodies.filter(d=>!n.bodies.some(f=>f.id===d.id))]}:n,u=a&&l&&"timeline"in l&&qc.changesTheScene(a.sighting,l)?{...l,timeline:l.timeline.keyframes?.length?l.timeline:a.sighting.timeline}:void 0;u&&s?this.showScene(u,s):this.readingScene&&a&&this.showScene(a.sighting,a.src,!0),this.readingScene=u!==void 0,this.sceneElement.interpretation=h,this.showReadingFindings(a,l),this.editLink.href=this.editorUrl(),this.dispatchEvent(new CustomEvent("interpretationchange",{detail:{track:this.shownTrackUrl()}})),this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation),this.showVariantMoved()}readingUrlOf(t){const e=this.caseSource,i=this.entries.find(r=>r.src===this.currentSrc),n=/^case-(\d+)$/.exec(t);if(!e||!i||!n)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id))[Number(n[1])];return s?.url?new URL(s.url,e.url).href:void 0}static SCENE_FIELDS=["time","utcOffsetHours","place","observerTrack","weatherTrack","decor","instrument","lens","film","exposureSeconds","iso","references","lighting","lightPollution","vehicle"];static changesTheScene(t,e){const i=n=>JSON.stringify(qc.SCENE_FIELDS.map(s=>n[s]));return i(t)!==i(e)}showScene(t,e,i=!1){const n=this.sceneElement.ufoElement.currentTime;this.sceneElement.documentUrl=e?new URL(e,location.href).href:void 0;const s=!this.sceneElement.ufoElement.playRequested,r=e?new URL(e,location.href).href:void 0;t.image?this.sceneElement.showPoster(t.image,r,s):i?this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,s):this.sceneElement.showPoster(void 0,void 0,s),this.sceneElement.sightingData=t,this.sceneElement.ufoElement.currentTime=n}showReadingFindings(t,e){const i=this.readingFindingsElement,n=this.messages,s=e?.interpretation?.findings??[],r=t&&e&&this.readingCheck?this.readingCheck.findingsOf(t.sighting,e):[],a=[...s,...r],c=a8.of(a);this.readingEntry=n&&c?{group:"summary",field:"reading",label:n.readingLabel,unit:"",fromSource:!1,value:(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length)),color:qc.VERDICT_COLOURS[c],full:a.map(u=>`${{holds:"✓",fails:"✗",untested:"?"}[u.outcome]} ${this.said.read(u.text)??""}`+(u.outcome==="fails"?` (${n.findingAgainst[u.against??"established"]})`:"")).join(`
|
|
9873
|
-
`)}:void 0,this.summarySignature="\0",this.refreshParamSummary();const l=i.querySelector("#reading-sensitivity");if(this.readingSensible=t&&e?As.resultOf(t.sighting,e)!==void 0:!1,l.show(t?.sighting,e),this.showReadingBox(),!n||!c){i.querySelector("#reading-findings-list").hidden=!0,delete i.dataset.verdict;return}i.dataset.verdict=c,i.querySelector("#reading-verdict").textContent=(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length));const h=i.querySelector("#reading-findings-list");i.querySelector("#reading-chip").setAttribute("aria-expanded","false"),h.hidden=!0,h.replaceChildren(...a.map(u=>{const d=document.createElement("li");d.dataset.outcome=u.outcome;const f=document.createElement("span");f.className="finding-mark",f.textContent={holds:"✓",fails:"✗",untested:"?"}[u.outcome],f.title=n.findingOutcome[u.outcome],f.setAttribute("aria-label",n.findingOutcome[u.outcome]);const p=document.createElement("span");if(p.textContent=this.said.read(u.text)??"",d.append(f,p),u.outcome==="fails"){const m=document.createElement("span");m.className="finding-against",m.textContent=`(${n.findingAgainst[u.against??"established"]})`,d.append(m)}return d}))}agentName(t){if("people"in t){const[e,...i]=t.people.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ");return[...i,e].join(" ")}return"org"in t?t.org.replace(/([a-z])([A-Z])/g,"$1 $2"):this.observerDisplayName(t)??""}showConfrontation(t){this.confrontationList.innerHTML="",this.confrontationElement.hidden=!this.sceneElement.interpretation||!this.sceneElement.compareAccount;const e=new Intl.NumberFormat(this.language,{maximumFractionDigits:1,minimumFractionDigits:1}),i=new Intl.NumberFormat(this.language,{maximumFractionDigits:2,minimumFractionDigits:2});for(const n of t){const s=document.createElement("li");s.append(`${this.said.read(n.title)??n.sourceId}${this.colon}`);const r=[];n.separationDeg!==void 0&&r.push([(this.messages?.confrontationDirection??"").replace("{deg}",e.format(n.separationDeg)),n.disagreements.includes("direction")]),n.widthRatio!==void 0&&r.push([(this.messages?.confrontationWidth??"").replace("{ratio}",i.format(n.widthRatio)),n.disagreements.includes("width")]),n.heightRatio!==void 0&&r.push([(this.messages?.confrontationHeight??"").replace("{ratio}",i.format(n.heightRatio)),n.disagreements.includes("height")]),r.forEach(([a,c],l)=>{l>0&&s.append(" · ");const h=document.createElement("span");h.textContent=a,c&&(h.className="disagrees"),s.append(h)}),this.confrontationList.appendChild(s)}}startPending=!1;startSeconds(t){const e=Zn.clock(this.getAttribute(KS)),i=this.plain(t).time;return(e?Zn.elapsedSince(i===void 0?void 0:Xs(i),e):void 0)??Zn.delta(this.getAttribute(G1))}selectObserver(t){const e=this.entries.find(n=>n.src===t);if(!e)return;this.currentSrc=t,this.observerSelect.value=t,this.sceneElement.documentUrl=e.src?new URL(e.src,location.href).href:void 0;const i=!this.sceneElement.ufoElement.playRequested;if(e.sighting.image?this.sceneElement.showPoster(e.sighting.image,e.src?new URL(e.src,location.href).href:void 0,i):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,i),this.sceneElement.holdForNewScene(),this.sceneElement.sightingData=e.sighting,this.readingScene=!1,this.startPending){this.startPending=!1;const n=this.startSeconds(e);n!==void 0&&(this.sceneElement.ufoElement.currentTime=Math.max(0,n)*1e3)}this.offerInterpretations(e),this.updateAccountLine(),this.refreshParamSummary(),this.runAssessments(),this.infoOpen&&this.populateInfoPanel(),this.dispatchEvent(new CustomEvent(FM,{detail:{src:t}}))}async runAssessments(){if(!this.messages)return;const t=++this.assessmentToken,e=await new Oy(this.messages).read(this.sceneElement.ufoElement.sighting);t===this.assessmentToken&&(this.assessmentEntries=e.entries,this.refreshParamSummary())}updateAccountLine(){const t=this.entries.find(a=>a.src===this.currentSrc),e=t?this.observerDisplayName(this.plain(t).observer):void 0,i=e!==void 0||this.entries.length>1;this.accountElement.hidden=!i,this.observerText.textContent=e??"";const s=!this.hasAttribute(x0)&&this.caseSource&&(this.said.read(this.caseSource.json.title)??this.caseSource.json.id);this.caseOfElement.hidden=!s,this.caseOfElement.textContent=s?`${this.messages?.case??""} ${s}`:"";const r=e!==void 0?`${this.messages?.accountBy??""} ${e}`.trim():void 0;this.sceneElement.filmName=[s||void 0,r].filter(Boolean).join(" - ")||void 0,this.editLink.hidden=!this.currentSrc,this.editLink.href=this.editorUrl(),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??"")}caseTitleOf(t){const e=this.caseSource;if(!e)return;const i=e.json.events?.find(n=>n.url!==void 0&&!n.interpretationOf&&new URL(n.url,e.url).href===new URL(t.src,location.href).href);return i?this.said.read(i.title):void 0}observerDisplayName(t){if(!t)return;const e=[...t.firstNames??[],t.lastName].filter(Boolean).join(" ");return this.said.read(t.title)||e||t.id}plainRecordings=new WeakMap;plain(t){return this.stripped(t).recording}stripped(t){let e=this.plainRecordings.get(t.sighting);return e||(e=Ze.strip(t.sighting),this.plainRecordings.set(t.sighting,e)),e}basisOf(t,e){const i=this.stripped(t).provenance,n={established:-2,measured:-1,stated:0,derived:1,assumed:2,fitted:3},s=i.paths().filter(c=>e.some(l=>c===l||c.startsWith(`${l}.`))).map(c=>i.at(c)),r=s.reduce((c,l)=>n[l.basis]>n[c]?l.basis:c,"stated"),a=s.filter(c=>c.basis===r&&c.rationale).map(c=>this.said.read(c.rationale)??"").filter(c=>c!=="");return{basis:r,rationales:a}}formatDate(t){const e=t.place?.locations?.[0],i=so((t.time?Xs(t.time):void 0)??{},e?.lng??0,t.utcOffsetHours);if(!i)return;const n=i.getTime()+this.utcOffsetHoursOf(t,e?.lng??0)*36e5;if(Number.isFinite(n))return new Intl.DateTimeFormat(this.language,{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(n))}utcOffsetHoursOf(t,e){return t.utcOffsetHours??Math.round(e/15)}formatLocation(t){const e=t.place?.locations?.[0];if(e)return`${e.lat.toFixed(4)}, ${e.lng.toFixed(4)}`}toggleInfoPanel(){const t=!this.infoOpen;if(this.supportsPopover){const e=this.infoPanel.matches(":popover-open");t&&!e?this.infoPanel.showPopover():!t&&e&&this.infoPanel.hidePopover();return}t&&this.bringInfoButtonIntoView(),this.syncInfoOpen(t),this.infoPanel.hidden=!t,t?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}bringInfoButtonIntoView(){const t=this.infoButton.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;t.top>=0&&t.bottom<=e||this.infoButton.scrollIntoView({block:"center"})}syncInfoOpen(t){t!==this.infoOpen&&(this.infoOpen=t,this.infoButton.setAttribute("aria-expanded",String(t)),t?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=t=>{const e=t.composedPath();!e.includes(this.infoPanel)&&!e.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}revealInPanel(t){t.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(t){this.toggleAttribute("show-labels",t)}applyLabels(t){this.labelsShown=t,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){const t=this.labelsShown?this.messages?.hideLabels??"":this.messages?.showLabels??"";this.labelsToggle.title=t,this.labelsToggle.setAttribute("aria-label",t),this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}showReadingBox(){const t=this.readingFindingsElement,e=this.readingEntry!==void 0&&!this.labelsShown;t.hidden=!e&&!this.readingSensible,t.querySelector("#reading-chip").hidden=!e,e||(t.querySelector("#reading-findings-list").hidden=!0)}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,this.showReadingBox(),!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const t=this.sceneElement.ufoElement.sighting,e=this.summaryBuilder?.entriesFor(t,this.sceneElement.ufoElement.currentTime,{roadGradeDeg:this.sceneElement.roadGradeDeg})??[],i=e.map(l=>l.group).lastIndexOf("summary"),n=this.readingEntry?[this.readingEntry]:[],s=[...e.slice(0,i+1),...n,...e.slice(i+1),...this.assessmentEntries],r=s.map(l=>`${l.field}=${l.label}=${l.value}${l.unit}${l.full??""}${l.fromSource?"*":""}`).join("|");if(r===this.summarySignature)return;this.summarySignature=r;const a=[];let c;for(const l of s){c&&c.group!==l.group&&(c=void 0);const h=l.group==="summary"?this.messages?.summaryGroup??"":l.group==="observer"?this.messages?.observerGroup??"":this.messages&&l.group in this.messages.summaryGroups?this.messages.summaryGroups[l.group]:l.group==="assessment"?this.messages?.assessmentGroup??"":void 0;if(h!==void 0&&!c){const d=document.createElement("span");d.className="param-nest";const f=document.createElement("span");f.className="param-nest-label",f.textContent=h,d.append(f),c={group:l.group,element:d},a.push(d)}const u=this.paramItem(l);c?c.element.append(u):a.push(u)}this.paramSummary.replaceChildren(...a),this.syncDescription(s)}openDescription;openDescriptionTitle;syncDescription(t){this.openDescription!==void 0&&!t.some(e=>e.full===this.openDescription)&&(this.openDescription=void 0),yE.sync(this.paramSummary,this.openDescription,this.openDescriptionTitle??this.messages?.summaryDescription??"",this.messages?.closeDescription??"",()=>{this.openDescription=void 0,this.syncDescription(t)})}paramItem(t){const e=document.createElement("span");if(e.className=t.fromSource?"param-label from-source":"param-label",t.detail&&(e.title=t.detail),t.full!==void 0){e.classList.add("describable"),e.tabIndex=0,e.setAttribute("role","button");const s=()=>{this.openDescription=t.full,this.openDescriptionTitle=t.label,this.syncDescription([t])};e.addEventListener("click",s),e.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())})}const i=document.createElement("span");if(i.className="param-label-label",i.textContent=`${t.label} `,e.append(i),t.color!==void 0){const s=document.createElement("span");s.className="param-label-swatch",s.style.background=t.color,e.append(s)}const n=document.createElement("span");return n.className="param-label-value",n.textContent=t.unit===""?t.value:`${t.value} ${t.unit}`,e.append(n),e}populateInfoPanel(){const t=this.entries.find(e=>e.src===this.currentSrc);if(this.infoObservationList.innerHTML="",t){const e=this.caseSource&&(this.caseSource.json.title??this.caseSource.json.id);if(e&&this.appendInfoRow(this.infoObservationList,this.messages?.case??"",e),!this.labelsShown){const s=this.formatDate(this.plain(t));s&&this.appendInfoRow(this.infoObservationList,this.messages?.date??"",s,this.basisOf(t,qc.DATE_PATHS));const r=this.formatLocation(this.plain(t));r&&this.appendInfoRow(this.infoObservationList,this.messages?.location??"",r,this.basisOf(t,qc.PLACE_PATHS))}const i=this.said.read(this.plain(t).description);i&&!this.labelsShown&&this.appendInfoRow(this.infoObservationList,this.messages?.description??"",i);for(const s of this.plain(t).sources??[])this.appendInfoSource(this.infoObservationList,this.messages?.source??"",s);const n=this.plain(t).tags;!this.labelsShown&&n&&n.length>0&&this.appendInfoRow(this.infoObservationList,this.messages?.tags??"",n.map(s=>this.tags.name(s)).join(", "))}this.infoAppLink.href=w0,this.infoAppLink.textContent="UFO@home v0.178.2",Yn.fill(this.infoCreditsList,this.sceneElement)}appendInfoSource(t,e,i){const n=document.createElement("dt");n.textContent=e;const s=document.createElement("dd"),r=this.said.read(i.title)??i.url??"";if(i.url&&/^https?:\/\//i.test(i.url)){const c=document.createElement("a");c.href=i.url,c.target="_blank",c.rel="noopener noreferrer",c.textContent=r,s.appendChild(c)}else s.append(r);const a=[i.authors?.join(", "),i.publication?.publisher,i.publication?.time,i.index].filter(Boolean);a.length>0&&s.append(`, ${a.join(", ")}`),t.append(n,s)}static DATE_PATHS=["time","utcOffsetHours","timeZone"];static PLACE_PATHS=["place"];appendInfoRow(t,e,i,n){if(!this.messages)return;const s=document.createElement("dt");s.textContent=e;const r=document.createElement("dd");if(r.textContent=i,n){const a=document.createElement("span");a.className=`basis basis-${n.basis}`,a.textContent=this.messages.basis[n.basis],n.rationales.length>0&&(a.title=n.rationales.join(`
|
|
9871
|
+
`;class fl extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get(fl.TAG)||customElements.define(fl.TAG,fl)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=$7;const t=e=>this.shadow.getElementById(e);this.dialog=t("dialog"),this.linkField=t("link"),this.copyButton=t("copy"),this.linkBox=t("link-box"),this.embedBox=t("embed-box"),this.linkOption=t("link-option"),this.embedOption=t("embed-option"),this.pin=t("pin"),this.embedMarkup=t("embed-markup"),this.noteElement=t("note"),t("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",e=>{e.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(t){const e=++this.languageToken,i=await kT.load(t);if(e===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(t){this.noteElement.textContent=t??"",this.noteElement.hidden=t===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const t=this.subject;if(!t)return;const e=this.pin.checked;this.linkField.value=e?ba.pinnedLink(t.link(),"0.178.4"):t.link(),this.fitLink();const n=`<script type="module" src="${e?ba.pinned(t.module,"0.178.4"):ba.current(t.module,import.meta.url,wu.home())}"><\/script>
|
|
9872
|
+
${t.element()}`;this.embedMarkup.value=n,this.codeEditor&&(this.codeEditor.text=n)}applyMessages(){const t=this.messages;if(!t)return;const e=(i,n)=>{this.shadow.getElementById(i).textContent=n};e("title",t.share),e("link-label",t.link),e("embed-label",t.embed),e("copy",t.copy),e("pin-label",t.pin.replace("{version}","0.178.4")),this.pin.parentElement.title=t.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",t.close),this.linkField.setAttribute("aria-label",t.link)}show(t){this.linkBox.hidden=t!=="link",this.embedBox.hidden=t!=="embed",this.linkOption.setAttribute("aria-pressed",String(t==="link")),this.embedOption.setAttribute("aria-pressed",String(t==="embed")),t==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=at(async()=>{const{ShareCodeEditor:t}=await import("./ShareCodeEditor-C53SBK2N.js");return{ShareCodeEditor:t}},[],import.meta.url).then(({ShareCodeEditor:t})=>{this.codeEditor=new t(this.shadow.getElementById("embed-code"),this.embedMarkup.value,e=>{this.embedMarkup.value=e},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(t,e){try{await navigator.clipboard.writeText(t),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{e.select()}}}class Zn{static PLAIN=/^\d+(?:[.,]\d+)?$/;static COLONS=/^(?:(\d+):)?(\d{1,2}):(\d{1,2}(?:[.,]\d+)?)$/;static UNITS=/^(?:(\d+(?:[.,]\d+)?)h)?(?:(\d+(?:[.,]\d+)?)m)?(?:(\d+(?:[.,]\d+)?)s)?$/i;static CLOCK=/^(?:(\d{4})-(\d{2})-(\d{2})[T ])?T?(\d{1,2}):(\d{2})(?::(\d{2}(?:[.,]\d+)?))?$/;static num(t){return t===void 0?0:Number(t.replace(",","."))}static delta(t){const e=(t??"").trim();if(e==="")return;if(Zn.PLAIN.test(e))return Zn.num(e);const i=Zn.COLONS.exec(e);if(i){const[,s,r,a]=i;return Number(r)>=60||Zn.num(a)>=60?void 0:Zn.num(s)*3600+Number(r)*60+Zn.num(a)}const n=Zn.UNITS.exec(e);return n&&(n[1]!==void 0||n[2]!==void 0||n[3]!==void 0)?Zn.num(n[1])*3600+Zn.num(n[2])*60+Zn.num(n[3]):/^P/i.test(e)?Gh.seconds(e.toUpperCase()):void 0}static isClock(t){return Zn.clock(t)!==void 0}static clock(t){const e=Zn.CLOCK.exec((t??"").trim());if(!e)return;const[,i,n,s,r,a,c]=e,l={hour:Number(r),minute:Number(a),second:Zn.num(c)};if(!(l.hour>=24||l.minute>=60||l.second>=60)){if(i!==void 0){const h={year:Number(i),month:Number(n),day:Number(s)};if(h.month<1||h.month>12||h.day<1||h.day>31)return;l.date=h}return l}}static elapsedSince(t,e){if(!t||t.hour===void 0||t.minute===void 0)return;const i=t.hour*3600+t.minute*60+(t.second??0),n=e.hour*3600+e.minute*60+e.second;if(e.date){if(t.year===void 0||t.month===void 0||t.day===void 0)return;const r=Date.UTC(e.date.year,e.date.month-1,e.date.day)/1e3+n,a=Date.UTC(t.year,t.month-1,t.day)/1e3+i;return Math.max(0,r-a)}let s=n-i;return s<=-43200&&(s+=86400),Math.max(0,s)}}Yy();fl.register();const w0=wu.home(),Qp="compare-account",G1="start-time",KS="start-clock",Kc="observer",x0="case-named",Od="show-info",b0="interpretation",Bh="hide-pickers",t0="case",e0="account",i0="variant-",V1=`${w0}/edit/`;class qc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Od,Bh,b0,x0,G1,KS,Kc,Pa,Na,Qp]}shadow;sceneElement;toolbarElement;accountElement;accountPrefix;caseOfElement;observerText;observerSelect;infoButton;infoPanel;infoAppLink;editLink;readingFindingsElement;readingSensible=!1;readingCheck;bestCases;readingScene=!1;readingEntry;static VERDICT_COLOURS={incompatible:"#e04848",unsettled:"#e08a2c",compatible:"#2e9d5b"};infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;shareButton;shareDialog;shareStartOn;shareStart;shareScopeRow;shareScopeLabel;shareScope;shareOpensRow;shareOpensLabel;shareOpens;shareStartLabel;shareOptions;labelsToggle;paramSummary;summaryBuilder;summarySignature="";assessmentEntries=[];assessmentToken=0;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];caseSource;interpretationChoice;interpretationLabel;interpretationSelect;confrontationElement;confrontationHeading;confrontationList;compareButton;variantChips;variantMoved;interpretationLoaders=new Map;interpretationToken=0;offeredFor;currentSrc;infoOpen=!1;creditsOpen=!1;labelsShown=!1;language="en";messages;ready=Promise.resolve();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${WT}</style>${VT}`,this.shadow.appendChild(t.content.cloneNode(!0)),customElements.upgrade(this.shadow),this.sceneElement=document.createElement(wf),this.forwardPlayerAttributes(),this.sceneElement.ufoElement.creditShownExternally=!0,this.sceneElement.ownCredits=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.accountElement=this.shadow.getElementById("account"),this.accountPrefix=this.shadow.getElementById("account-prefix"),this.caseOfElement=this.shadow.getElementById("case-of"),this.observerText=this.shadow.getElementById("observer-text"),this.observerSelect=this.shadow.getElementById("observer"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.editLink=this.shadow.getElementById("edit-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("labels-button"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.shareButton=document.createElement("button"),this.shareButton.type="button",this.shareButton.id="share-button",this.shareButton.setAttribute("aria-haspopup","dialog"),this.shareButton.innerHTML=Kt.SHARE,this.sceneElement.ufoElement.addControl(this.shareButton),this.shareDialog=this.shadow.getElementById("share-dialog"),this.shareDialog.subject=this.shareSubject,this.shareStartOn=this.shadow.getElementById("share-start-on"),this.shareStart=this.shadow.getElementById("share-start"),this.shareStartLabel=this.shadow.getElementById("share-start-label"),this.shareScopeRow=this.shadow.getElementById("share-scope-row"),this.shareScopeLabel=this.shadow.getElementById("share-scope-label"),this.shareScope=this.shadow.getElementById("share-scope"),this.shareOpensRow=this.shadow.getElementById("share-opens-row"),this.shareOpensLabel=this.shadow.getElementById("share-opens-label"),this.shareOpens=this.shadow.getElementById("share-opens");const e=n=>({input:this.shadow.getElementById(`share-opt-${n}`),label:this.shadow.getElementById(`share-opt-${n}-label`)});this.shareOptions={labels:e("labels"),map:e("map"),milestones:e("milestones"),compare:e("compare")},this.interpretationChoice=this.shadow.getElementById("interpretation-choice"),this.interpretationLabel=this.shadow.getElementById("interpretation-label"),this.interpretationSelect=this.shadow.getElementById("interpretation"),this.confrontationElement=this.shadow.getElementById("confrontation"),this.confrontationHeading=this.shadow.getElementById("confrontation-heading"),this.confrontationList=this.shadow.getElementById("confrontation-list"),As.register(),this.readingFindingsElement=this.shadow.getElementById("reading-findings");const i=this.shadow.getElementById("reading-chip");i.addEventListener("click",()=>{const n=i.getAttribute("aria-expanded")!=="true";i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById("reading-findings-list").hidden=!n}),this.compareButton=this.shadow.getElementById("compare-account"),this.variantChips=this.shadow.getElementById("variant-chips"),this.variantMoved=this.shadow.getElementById("variant-moved"),this.compareButton.addEventListener("click",()=>this.setComparing(!this.sceneElement.compareAccount)),this.observerSelect.addEventListener("change",()=>this.selectObserver(this.observerSelect.value)),this.interpretationSelect.addEventListener("change",()=>void this.chooseInterpretation(this.interpretationSelect.value)),this.sceneElement.addEventListener($y,n=>this.showConfrontation(n.detail)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",n=>{n.newState==="open"&&(this.populateInfoPanel(),this.bringInfoButtonIntoView())}),this.infoPanel.addEventListener("toggle",n=>this.syncInfoOpen(n.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.shareButton.addEventListener("click",()=>this.openShare());for(const n of[this.shareStartOn,this.shareStart,...Object.values(this.shareOptions).map(s=>s.input)])n.addEventListener("input",()=>this.refreshShareLinks());for(const n of[this.shareScope,this.shareOpens])n.addEventListener("change",()=>this.refreshShareLinks());this.isConnected&&(this.ready=this.loadLocaleMessages())}get scene(){return this.sceneElement}async loadLocaleMessages(){const t=++this.localeToken,e=Ws.preferencesFor(this);this.preferences=e;const i=vo(e,Mo),[n,s,r,a]=await Promise.all([CT.load(i),FT(i),ME(i),r8.load(i)]);if(t!==this.localeToken)return;const c=i!==this.language||this.messages===void 0;this.language=i,this.messages=n,this.readingCheck=new fn(a),this.bestCases=new ee(a),this.tags=new lM(s),this.said=new Qn(e),this.summaryBuilder=new Vc(this.messages,new kM(r),this.said,this.tags,{messages:this.messages,locale:i}),this.accountPrefix.textContent=this.messages?.accountBy??"",this.interpretationLabel.textContent=this.messages?.interpretation??"",this.confrontationHeading.textContent=this.messages?.confrontation??"";const l=this.entries.find(h=>h.src===this.currentSrc);l&&this.offerInterpretations(l),this.updateCompareButton(),this.infoButton.title=this.messages?.about??"",this.infoButton.setAttribute("aria-label",this.messages?.about??""),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??""),this.infoCloseButton.setAttribute("aria-label",this.messages?.close??""),this.infoObservationHeading.textContent=this.messages?.observation??"",this.infoCreditsToggle.textContent=this.messages?.credits??"",this.syncLabelsToggle(),this.refreshParamSummary(),c&&this.currentSrc&&this.runAssessments(),this.shareButton.title=this.messages?.share??"",this.shareButton.setAttribute("aria-label",this.messages?.share??""),this.shareStartLabel.textContent=this.messages?.shareStartAt??"",this.shareScopeLabel.textContent=this.messages?.shareScope??"",this.shareOpensLabel.textContent=this.messages?.shareOpensOn??"",this.shareOptions.labels.label.textContent=this.messages?.shareOptionLabels??"",this.shareOptions.map.label.textContent=this.messages?.shareOptionMap??"",this.shareOptions.milestones.label.textContent=this.messages?.shareOptionMilestones??"",this.shareOptions.compare.label.textContent=this.messages?.shareOptionCompare??"",this.shareStart.setAttribute("aria-label",this.messages?.shareStartAt??""),this.shareDialog.useLanguage(i),this.infoOpen&&this.populateInfoPanel(),this.updateAccountLine()}preferences=[];localeToken=0;said=new Qn(["en"]);tags=new lM({});connectedCallback(){Ws.preferencesFor(this).join()!==this.preferences.join()&&(this.ready=this.loadLocaleMessages()),this.applyAskedInfo();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}applyAskedInfo(){this.isConnected&&this.hasAttribute(Od)!==this.infoOpen&&this.toggleInfoPanel()}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===b0){const n=this.entries.find(s=>s.src===this.currentSrc);n&&this.offerInterpretations(n)}if(t===Bh){const n=this.entries.find(s=>s.src===this.currentSrc);this.setEntries(this.entries,this.caseSource),n&&this.offerInterpretations(n)}if(t===Od&&this.applyAskedInfo(),t==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels")),(t===Pa||t===Na)&&this.forwardPlayerAttributes(),t===Kc&&this.entries.length>1){const n=this.entryAsked(this.entries);n&&n.src!==this.currentSrc&&this.selectObserver(n.src)}t===Qp&&this.setComparing(this.hasAttribute(Qp))}forwardPlayerAttributes(){for(const t of[Pa,Na]){const e=this.getAttribute(t);e===null?this.sceneElement.removeAttribute(t):this.sceneElement.setAttribute(t,e)}}async loadFromSrc(t){this.startPending=!0;const e=Sr.recording(t);this.sceneElement.holdForNewScene(e);const i=await e;if(Array.isArray(i))throw new Error(`${t} is a bare list of recordings, which is no longer read: list them as the sighting events of a case.json`);if(Ui.isCase(i)){Ui.check(i);const n=Ui.sightingUrls(i,new URL(t,location.href).href);if(n.length===0)throw new Error(`${t} is a case with no sighting event: no recording to show`);await this.loadObserverUrls(n,{json:i,url:new URL(t,location.href).href})}else this.setEntries([{src:t,sighting:i}],void 0)}get sightingData(){return this.entries.find(t=>t.src===this.currentSrc)?.sighting}set sightingData(t){const e=ar.recording(t);this.startPending=!0,this.currentSrc="",this.setEntries([{src:"",sighting:e}],void 0)}seekTo(t,e){const i=this.caseSource,n=e===void 0?void 0:this.entries.find(s=>{const r=this.plain(s).id;return(i?Ui.accountIds(i.json,i.url,s.src,r):[r]).includes(e)});n&&n.src!==this.currentSrc&&this.selectObserver(n.src),this.sceneElement.ufoElement.currentTime=Math.max(0,t)*1e3}set citedMoments(t){this.sceneElement.ufoElement.citedMoments=t}get playedSeconds(){return this.sceneElement.ufoElement.currentTime/1e3}get observerUrls(){return this.entries.map(t=>t.src)}set observerUrls(t){this.loadObserverUrls(t)}async loadObserverUrls(t,e){const i=await Promise.all(t.map(async n=>({src:n,sighting:await Sr.recording(n)})));this.setEntries(i,e)}reportCaseProblems(t,e){const{duplicateIds:i,unresolved:n}=Ui.problems(t,e.map(s=>this.plain(s).id).filter(s=>s!==void 0));for(const s of i)console.warn(`The case ${t.id??""} gives the id "${s}" to more than one event: a reference to it is ambiguous.`);for(const{reading:s,reference:r}of n)console.warn(`The reading ${s} of the case ${t.id??""} is "interpretationOf" "${r}", which no event of the case has as its id, nor any recording it lists.`)}setEntries(t,e){this.entries=t.map(r=>({...r,sighting:ar.recording(r.sighting)})),this.caseSource=e,e&&this.reportCaseProblems(e.json,t),this.toolbarElement.hidden=t.length===0;const i=t.length>1&&!this.hasAttribute(Bh);this.observerSelect.hidden=!i,this.observerText.hidden=i,this.observerSelect.innerHTML="";const n=t.map((r,a)=>this.observerDisplayName(this.plain(r).observer)??this.caseTitleOf(r)??(this.messages?.unnamedObserver??"").replace("{n}",String(a+1)));for(const[r,a]of t.entries()){const c=document.createElement("option");c.value=a.src;const l=n.filter(h=>h===n[r]).length>1;c.textContent=(l?this.caseTitleOf(a):void 0)??n[r],this.observerSelect.appendChild(c)}const s=t.find(r=>r.src===this.currentSrc)??this.entryAsked(t)??t[0];s?this.selectObserver(s.src):this.updateAccountLine()}entryAsked(t){const e=this.getAttribute(Kc)?.trim();if(!e)return;const i=t.find(r=>this.plain(r).observer?.id===e);if(i)return i;const n=this.caseSource;if(n){const r=t.find(a=>Ui.accountIds(n.json,n.url,a.src,this.plain(a).id).includes(e));if(r)return r}const s=t.find(r=>r.src.split("/").pop()===e.split("/").pop());return s||(/^\d+$/.test(e)?t[Number(e)-1]:void 0)}observerKeyOf(t){return this.plain(t).observer?.id??String(this.entries.indexOf(t)+1)}sharedEntry(){const t=this.shareScope.value;if(!(!this.caseSource||t===t0))return this.entries.find(e=>e.src===t)}get sharesCase(){return this.caseSource!==void 0&&!this.shareScopeRow.hidden&&this.shareScope.value===t0}editorUrl(){if(!this.currentSrc)return V1;const t=new URL(this.currentSrc,location.href),e=this.caseSource;return e?`${V1}?file=${encodeURIComponent(e.url)}&track=${encodeURIComponent(this.shownTrackUrl()??t.href)}`:`${V1}?file=${encodeURIComponent(t.href)}`}get editorHref(){return this.editorUrl()}shownTrackUrl(){return this.readingUrlOf(this.interpretationSelect.value)}shareSubject={module:"rr0-sighting",link:()=>this.playUrl(),element:()=>this.replayElement()};replayElement(){const t=this.sharedAddress(),i=[...t.observer?[[Kc,t.observer]]:[],...this.replayAttributes()].map(([n,s])=>s===""?` ${n}`:` ${n}="${s}"`).join("");return`<rr0-sighting src="${t.src}"${i}></rr0-sighting>`}playUrl(){const t=this.sharedAddress(),e=[...t.observer?[`${Kc}=${encodeURIComponent(t.observer)}`]:[],...this.replayQuery()].join("&");return t.src?`${w0}/play/?file=${encodeURIComponent(t.src)}${e&&"&"+e}`:`${w0}/play/${e&&"?"+e}`}sharedAddress(){const t=e=>e?new URL(e,location.href).href:"";if(this.sharesCase){const e=this.entries.find(i=>i.src===this.shareOpens.value)??this.entries.find(i=>i.src===this.currentSrc);return{src:this.caseSource.url,observer:e?this.observerKeyOf(e):void 0}}return{src:t(this.sharedEntry()?.src??this.currentSrc??"")}}replayAttributes(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push([G1,String(this.shareStartSeconds)]),t.labels.input.checked&&e.push(["show-labels",""]),t.map.input.checked&&e.push([Pa,""]),t.milestones.input.checked||e.push([Na,""]),t.compare.input.checked&&e.push([Qp,""]),e}replayQuery(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push(`d=${this.shareStartSeconds}`),t.labels.input.checked||e.push("labels=0"),t.map.input.checked&&e.push("map=1"),t.milestones.input.checked||e.push("moments=0"),t.compare.input.checked&&e.push("compare=1"),e}get shareStartSeconds(){const t=Math.floor(Number(this.shareStart.value));return this.shareStartOn.checked&&Number.isFinite(t)&&t>=0?t:void 0}refreshShareLinks(){this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.refresh()}openShare(){const t=this.sceneElement.ufoElement;this.shareStart.max=String(Math.floor(t.seekableDuration/1e3)),this.shareStart.value=String(Math.floor(t.currentTime/1e3)),this.shareStartOn.checked=!1,this.shareOptions.labels.input.checked=this.labelsShown,this.shareOptions.map.input.checked=t.observerMapOpen,this.shareOptions.milestones.input.checked=t.milestonesVisible,this.shareOptions.compare.input.checked=this.sceneElement.compareAccount,this.offerShareScope(),this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.open()}offerShareScope(){const t=this.caseSource!==void 0&&this.entries.length>1&&!this.hasAttribute(x0);if(this.shareScopeRow.hidden=!t,this.shareScope.innerHTML="",this.shareOpens.innerHTML="",!t)return;const e=(i,n,s)=>{const r=document.createElement("option");r.value=n,r.textContent=s,i.appendChild(r)};e(this.shareScope,t0,this.messages?.shareScopeCase??"");for(const i of this.entries){const n=this.observerDisplayName(this.plain(i).observer)??this.caseTitleOf(i)??(this.messages?.unnamedObserver??"").replace("{n}",String(this.entries.indexOf(i)+1));e(this.shareScope,i.src,n),e(this.shareOpens,i.src,n)}this.shareScope.value=t0,this.shareOpens.value=this.currentSrc??this.entries[0].src}offerInterpretations(t){const e=this.offeredFor===t.sighting,i=this.interpretationSelect.value;this.offeredFor=t.sighting,this.interpretationToken++,this.interpretationLoaders=new Map,this.interpretationSelect.innerHTML="";const n=(u,d,f)=>{const p=document.createElement("option");p.value=u,p.textContent=d,this.interpretationSelect.appendChild(p),this.interpretationLoaders.set(u,f)},s=t===this.entries.find(u=>u.src===this.currentSrc),r=s?this.sceneElement.ufoElement.sighting.interpretation:void 0;n(e0,this.messages?.account??"",()=>Promise.resolve(r));const a=this.caseSource;a&&Ui.interpretationEvents(a.json,Ui.accountIds(a.json,a.url,t.src,this.plain(t).id)).forEach((u,d)=>{const f=this.said.read(u.title)??`#${d+1}`,p=(u.by??[]).map(m=>this.agentName(m)).filter(Boolean).join(", ");n(`case-${d}`,p?(this.messages?.interpretationBy??"").replace("{title}",f).replace("{by}",p):f,()=>Ui.interpretationOf(u,a.url,m=>Sr.recording(m)))});const c=s?this.keptVariants(t):[];for(const{index:u,kept:d}of c)n(`${i0}${u}`,`${this.variantLabel(d)} (${this.messages?.verdicts[d.variant.verdict]??""})`,()=>Promise.resolve(d.bodies.length>0?d:void 0));const l=e&&[...this.interpretationSelect.options].some(u=>u.value===i),h=this.askedInterpretation()??(l?i:e0);this.interpretationSelect.value=h,h===e0?this.sceneElement.interpretation!==r&&(this.sceneElement.interpretation=r):this.sceneElement.interpretation||this.chooseInterpretation(h),this.interpretationChoice.hidden=this.interpretationSelect.options.length<2||this.hasAttribute(Bh),this.showConfrontation(this.sceneElement.confrontation),this.updateCompareButton(),this.showVariants(c)}keptVariants(t){const e={consolidated:0,contested:1,incompatible:2};return(t.sighting.variants??[]).map((i,n)=>({index:n,kept:i})).filter(({kept:i})=>i.variant).sort((i,n)=>e[i.kept.variant.verdict]-e[n.kept.variant.verdict]||i.kept.variant.cost-n.kept.variant.cost)}variantLabel(t){return(this.messages?.variant??"").replace("{name}",t.variant.label??t.variant.candidate)}showVariants(t){if(!this.messages)return;if(this.variantChips.innerHTML="",this.variantChips.hidden=t.length===0,t.length===0){this.showVariantMoved();return}const e=(i,n,s)=>{const r=document.createElement("button");r.type="button",r.dataset.value=i,s&&(r.dataset.verdict=s,r.title=this.messages.verdicts[s],r.append(Object.assign(document.createElement("span"),{className:"dot"}))),r.append(n),r.addEventListener("click",()=>{this.interpretationSelect.value!==i&&(this.interpretationSelect.value=i,this.chooseInterpretation(i))}),this.variantChips.append(r)};e(e0,this.messages?.account??"");for(const{index:i,kept:n}of t)e(`${i0}${i}`,n.variant.label??n.variant.candidate,n.variant.verdict);this.showVariantMoved()}showVariantMoved(){if(!this.messages)return;const t=this.interpretationSelect.value;for(const s of this.variantChips.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s.dataset.value===t));this.variantMoved.innerHTML="";const e=t.startsWith(i0)?Number(t.slice(i0.length)):-1,i=this.sceneElement.ufoElement.sighting.variants?.[e]?.variant;if(this.variantMoved.hidden=!i||i.moved.length+(i.readings?.length??0)===0,!i)return;const n=new Intl.NumberFormat(this.language,{maximumFractionDigits:1});for(const s of i.moved){const[r,a]=s.field==="time"?["0 min",`${s.variant>0?"+":""}${n.format(s.variant)} min`]:s.field==="duration"?[`${n.format(s.stated)} s`,`${n.format(s.variant)} s`]:[`${n.format(s.stated)}°`,`${n.format(s.variant)}°`],c=document.createElement("span");c.append(`${this.messages.variantFields[s.field]}${this.colon}`,Object.assign(document.createElement("s"),{textContent:r})," → ",Object.assign(document.createElement("b"),{textContent:a})),this.variantMoved.append(c)}for(const s of i.readings??[]){const r=this.messages.variantReadings[s.reading];r&&this.variantMoved.append(Object.assign(document.createElement("span"),{className:"reading",textContent:r}))}}setComparing(t){this.sceneElement.compareAccount=t,this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation)}updateCompareButton(){const t=this.sceneElement.compareAccount;this.compareButton.hidden=!this.sceneElement.interpretation,this.compareButton.setAttribute("aria-pressed",String(t));const e=t?this.messages?.hideComparison??"":this.messages?.showComparison??"";this.compareButton.title=e,this.compareButton.setAttribute("aria-label",e)}get colon(){return this.language==="fr"?" : ":": "}askedInterpretation(){const t=this.getAttribute(b0)?.trim(),e=this.caseSource;if(!t||!e)return;const i=this.entries.find(r=>r.src===this.currentSrc);if(!i)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id)).findIndex(r=>r.id===t||typeof r.url=="string"&&new URL(r.url,e.url).href===new URL(t,location.href).href);return s>=0?`case-${s}`:void 0}async chooseInterpretation(t){const e=++this.interpretationToken,i=this.interpretationLoaders.get(t),n=i?await i().catch(d=>{console.warn(`<rr0-sighting>: could not read interpretation "${t}":`,d)}):void 0,s=this.readingUrlOf(t),r=s?await Sr.recording(s).catch(()=>{}):void 0;if(e!==this.interpretationToken)return;const a=this.entries.find(d=>d.src===this.currentSrc),c=a&&r&&"timeline"in r?this.bestCases?.bestSceneOf(a.sighting,r):void 0,l=c??r,h=c?.interpretation&&n?{...n,bodies:[...n.bodies.map(d=>{const f=c.interpretation.bodies.find(p=>p.id===d.id);return f?{...d,track:f.track}:d}),...c.interpretation.bodies.filter(d=>!n.bodies.some(f=>f.id===d.id))]}:n,u=a&&l&&"timeline"in l&&qc.changesTheScene(a.sighting,l)?{...l,timeline:l.timeline.keyframes?.length?l.timeline:a.sighting.timeline}:void 0;u&&s?this.showScene(u,s):this.readingScene&&a&&this.showScene(a.sighting,a.src,!0),this.readingScene=u!==void 0,this.sceneElement.interpretation=h,this.showReadingFindings(a,l),this.editLink.href=this.editorUrl(),this.dispatchEvent(new CustomEvent("interpretationchange",{detail:{track:this.shownTrackUrl()}})),this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation),this.showVariantMoved()}readingUrlOf(t){const e=this.caseSource,i=this.entries.find(r=>r.src===this.currentSrc),n=/^case-(\d+)$/.exec(t);if(!e||!i||!n)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id))[Number(n[1])];return s?.url?new URL(s.url,e.url).href:void 0}static SCENE_FIELDS=["time","utcOffsetHours","place","observerTrack","weatherTrack","decor","instrument","lens","film","exposureSeconds","iso","references","lighting","lightPollution","vehicle"];static changesTheScene(t,e){const i=n=>JSON.stringify(qc.SCENE_FIELDS.map(s=>n[s]));return i(t)!==i(e)}showScene(t,e,i=!1){const n=this.sceneElement.ufoElement.currentTime;this.sceneElement.documentUrl=e?new URL(e,location.href).href:void 0;const s=!this.sceneElement.ufoElement.playRequested,r=e?new URL(e,location.href).href:void 0;t.image?this.sceneElement.showPoster(t.image,r,s):i?this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,s):this.sceneElement.showPoster(void 0,void 0,s),this.sceneElement.sightingData=t,this.sceneElement.ufoElement.currentTime=n}showReadingFindings(t,e){const i=this.readingFindingsElement,n=this.messages,s=e?.interpretation?.findings??[],r=t&&e&&this.readingCheck?this.readingCheck.findingsOf(t.sighting,e):[],a=[...s,...r],c=a8.of(a);this.readingEntry=n&&c?{group:"summary",field:"reading",label:n.readingLabel,unit:"",fromSource:!1,value:(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length)),color:qc.VERDICT_COLOURS[c],full:a.map(u=>`${{holds:"✓",fails:"✗",untested:"?"}[u.outcome]} ${this.said.read(u.text)??""}`+(u.outcome==="fails"?` (${n.findingAgainst[u.against??"established"]})`:"")).join(`
|
|
9873
|
+
`)}:void 0,this.summarySignature="\0",this.refreshParamSummary();const l=i.querySelector("#reading-sensitivity");if(this.readingSensible=t&&e?As.resultOf(t.sighting,e)!==void 0:!1,l.show(t?.sighting,e),this.showReadingBox(),!n||!c){i.querySelector("#reading-findings-list").hidden=!0,delete i.dataset.verdict;return}i.dataset.verdict=c,i.querySelector("#reading-verdict").textContent=(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length));const h=i.querySelector("#reading-findings-list");i.querySelector("#reading-chip").setAttribute("aria-expanded","false"),h.hidden=!0,h.replaceChildren(...a.map(u=>{const d=document.createElement("li");d.dataset.outcome=u.outcome;const f=document.createElement("span");f.className="finding-mark",f.textContent={holds:"✓",fails:"✗",untested:"?"}[u.outcome],f.title=n.findingOutcome[u.outcome],f.setAttribute("aria-label",n.findingOutcome[u.outcome]);const p=document.createElement("span");if(p.textContent=this.said.read(u.text)??"",d.append(f,p),u.outcome==="fails"){const m=document.createElement("span");m.className="finding-against",m.textContent=`(${n.findingAgainst[u.against??"established"]})`,d.append(m)}return d}))}agentName(t){if("people"in t){const[e,...i]=t.people.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ");return[...i,e].join(" ")}return"org"in t?t.org.replace(/([a-z])([A-Z])/g,"$1 $2"):this.observerDisplayName(t)??""}showConfrontation(t){this.confrontationList.innerHTML="",this.confrontationElement.hidden=!this.sceneElement.interpretation||!this.sceneElement.compareAccount;const e=new Intl.NumberFormat(this.language,{maximumFractionDigits:1,minimumFractionDigits:1}),i=new Intl.NumberFormat(this.language,{maximumFractionDigits:2,minimumFractionDigits:2});for(const n of t){const s=document.createElement("li");s.append(`${this.said.read(n.title)??n.sourceId}${this.colon}`);const r=[];n.separationDeg!==void 0&&r.push([(this.messages?.confrontationDirection??"").replace("{deg}",e.format(n.separationDeg)),n.disagreements.includes("direction")]),n.widthRatio!==void 0&&r.push([(this.messages?.confrontationWidth??"").replace("{ratio}",i.format(n.widthRatio)),n.disagreements.includes("width")]),n.heightRatio!==void 0&&r.push([(this.messages?.confrontationHeight??"").replace("{ratio}",i.format(n.heightRatio)),n.disagreements.includes("height")]),r.forEach(([a,c],l)=>{l>0&&s.append(" · ");const h=document.createElement("span");h.textContent=a,c&&(h.className="disagrees"),s.append(h)}),this.confrontationList.appendChild(s)}}startPending=!1;startSeconds(t){const e=Zn.clock(this.getAttribute(KS)),i=this.plain(t).time;return(e?Zn.elapsedSince(i===void 0?void 0:Xs(i),e):void 0)??Zn.delta(this.getAttribute(G1))}selectObserver(t){const e=this.entries.find(n=>n.src===t);if(!e)return;this.currentSrc=t,this.observerSelect.value=t,this.sceneElement.documentUrl=e.src?new URL(e.src,location.href).href:void 0;const i=!this.sceneElement.ufoElement.playRequested;if(e.sighting.image?this.sceneElement.showPoster(e.sighting.image,e.src?new URL(e.src,location.href).href:void 0,i):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,i),this.sceneElement.holdForNewScene(),this.sceneElement.sightingData=e.sighting,this.readingScene=!1,this.startPending){this.startPending=!1;const n=this.startSeconds(e);n!==void 0&&(this.sceneElement.ufoElement.currentTime=Math.max(0,n)*1e3)}this.offerInterpretations(e),this.updateAccountLine(),this.refreshParamSummary(),this.runAssessments(),this.infoOpen&&this.populateInfoPanel(),this.dispatchEvent(new CustomEvent(FM,{detail:{src:t}}))}async runAssessments(){if(!this.messages)return;const t=++this.assessmentToken,e=await new Oy(this.messages).read(this.sceneElement.ufoElement.sighting);t===this.assessmentToken&&(this.assessmentEntries=e.entries,this.refreshParamSummary())}updateAccountLine(){const t=this.entries.find(a=>a.src===this.currentSrc),e=t?this.observerDisplayName(this.plain(t).observer):void 0,i=e!==void 0||this.entries.length>1;this.accountElement.hidden=!i,this.observerText.textContent=e??"";const s=!this.hasAttribute(x0)&&this.caseSource&&(this.said.read(this.caseSource.json.title)??this.caseSource.json.id);this.caseOfElement.hidden=!s,this.caseOfElement.textContent=s?`${this.messages?.case??""} ${s}`:"";const r=e!==void 0?`${this.messages?.accountBy??""} ${e}`.trim():void 0;this.sceneElement.filmName=[s||void 0,r].filter(Boolean).join(" - ")||void 0,this.editLink.hidden=!this.currentSrc,this.editLink.href=this.editorUrl(),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??"")}caseTitleOf(t){const e=this.caseSource;if(!e)return;const i=e.json.events?.find(n=>n.url!==void 0&&!n.interpretationOf&&new URL(n.url,e.url).href===new URL(t.src,location.href).href);return i?this.said.read(i.title):void 0}observerDisplayName(t){if(!t)return;const e=[...t.firstNames??[],t.lastName].filter(Boolean).join(" ");return this.said.read(t.title)||e||t.id}plainRecordings=new WeakMap;plain(t){return this.stripped(t).recording}stripped(t){let e=this.plainRecordings.get(t.sighting);return e||(e=Ze.strip(t.sighting),this.plainRecordings.set(t.sighting,e)),e}basisOf(t,e){const i=this.stripped(t).provenance,n={established:-2,measured:-1,stated:0,derived:1,assumed:2,fitted:3},s=i.paths().filter(c=>e.some(l=>c===l||c.startsWith(`${l}.`))).map(c=>i.at(c)),r=s.reduce((c,l)=>n[l.basis]>n[c]?l.basis:c,"stated"),a=s.filter(c=>c.basis===r&&c.rationale).map(c=>this.said.read(c.rationale)??"").filter(c=>c!=="");return{basis:r,rationales:a}}formatDate(t){const e=t.place?.locations?.[0],i=so((t.time?Xs(t.time):void 0)??{},e?.lng??0,t.utcOffsetHours);if(!i)return;const n=i.getTime()+this.utcOffsetHoursOf(t,e?.lng??0)*36e5;if(Number.isFinite(n))return new Intl.DateTimeFormat(this.language,{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(n))}utcOffsetHoursOf(t,e){return t.utcOffsetHours??Math.round(e/15)}formatLocation(t){const e=t.place?.locations?.[0];if(e)return`${e.lat.toFixed(4)}, ${e.lng.toFixed(4)}`}toggleInfoPanel(){const t=!this.infoOpen;if(this.supportsPopover){const e=this.infoPanel.matches(":popover-open");t&&!e?this.infoPanel.showPopover():!t&&e&&this.infoPanel.hidePopover();return}t&&this.bringInfoButtonIntoView(),this.syncInfoOpen(t),this.infoPanel.hidden=!t,t?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}bringInfoButtonIntoView(){const t=this.infoButton.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;t.top>=0&&t.bottom<=e||this.infoButton.scrollIntoView({block:"center"})}syncInfoOpen(t){t!==this.infoOpen&&(this.infoOpen=t,this.infoButton.setAttribute("aria-expanded",String(t)),t?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=t=>{const e=t.composedPath();!e.includes(this.infoPanel)&&!e.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}revealInPanel(t){t.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(t){this.toggleAttribute("show-labels",t)}applyLabels(t){this.labelsShown=t,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){const t=this.labelsShown?this.messages?.hideLabels??"":this.messages?.showLabels??"";this.labelsToggle.title=t,this.labelsToggle.setAttribute("aria-label",t),this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}showReadingBox(){const t=this.readingFindingsElement,e=this.readingEntry!==void 0&&!this.labelsShown;t.hidden=!e&&!this.readingSensible,t.querySelector("#reading-chip").hidden=!e,e||(t.querySelector("#reading-findings-list").hidden=!0)}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,this.showReadingBox(),!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const t=this.sceneElement.ufoElement.sighting,e=this.summaryBuilder?.entriesFor(t,this.sceneElement.ufoElement.currentTime,{roadGradeDeg:this.sceneElement.roadGradeDeg})??[],i=e.map(l=>l.group).lastIndexOf("summary"),n=this.readingEntry?[this.readingEntry]:[],s=[...e.slice(0,i+1),...n,...e.slice(i+1),...this.assessmentEntries],r=s.map(l=>`${l.field}=${l.label}=${l.value}${l.unit}${l.full??""}${l.fromSource?"*":""}`).join("|");if(r===this.summarySignature)return;this.summarySignature=r;const a=[];let c;for(const l of s){c&&c.group!==l.group&&(c=void 0);const h=l.group==="summary"?this.messages?.summaryGroup??"":l.group==="observer"?this.messages?.observerGroup??"":this.messages&&l.group in this.messages.summaryGroups?this.messages.summaryGroups[l.group]:l.group==="assessment"?this.messages?.assessmentGroup??"":void 0;if(h!==void 0&&!c){const d=document.createElement("span");d.className="param-nest";const f=document.createElement("span");f.className="param-nest-label",f.textContent=h,d.append(f),c={group:l.group,element:d},a.push(d)}const u=this.paramItem(l);c?c.element.append(u):a.push(u)}this.paramSummary.replaceChildren(...a),this.syncDescription(s)}openDescription;openDescriptionTitle;syncDescription(t){this.openDescription!==void 0&&!t.some(e=>e.full===this.openDescription)&&(this.openDescription=void 0),yE.sync(this.paramSummary,this.openDescription,this.openDescriptionTitle??this.messages?.summaryDescription??"",this.messages?.closeDescription??"",()=>{this.openDescription=void 0,this.syncDescription(t)})}paramItem(t){const e=document.createElement("span");if(e.className=t.fromSource?"param-label from-source":"param-label",t.detail&&(e.title=t.detail),t.full!==void 0){e.classList.add("describable"),e.tabIndex=0,e.setAttribute("role","button");const s=()=>{this.openDescription=t.full,this.openDescriptionTitle=t.label,this.syncDescription([t])};e.addEventListener("click",s),e.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())})}const i=document.createElement("span");if(i.className="param-label-label",i.textContent=`${t.label} `,e.append(i),t.color!==void 0){const s=document.createElement("span");s.className="param-label-swatch",s.style.background=t.color,e.append(s)}const n=document.createElement("span");return n.className="param-label-value",n.textContent=t.unit===""?t.value:`${t.value} ${t.unit}`,e.append(n),e}populateInfoPanel(){const t=this.entries.find(e=>e.src===this.currentSrc);if(this.infoObservationList.innerHTML="",t){const e=this.caseSource&&(this.caseSource.json.title??this.caseSource.json.id);if(e&&this.appendInfoRow(this.infoObservationList,this.messages?.case??"",e),!this.labelsShown){const s=this.formatDate(this.plain(t));s&&this.appendInfoRow(this.infoObservationList,this.messages?.date??"",s,this.basisOf(t,qc.DATE_PATHS));const r=this.formatLocation(this.plain(t));r&&this.appendInfoRow(this.infoObservationList,this.messages?.location??"",r,this.basisOf(t,qc.PLACE_PATHS))}const i=this.said.read(this.plain(t).description);i&&!this.labelsShown&&this.appendInfoRow(this.infoObservationList,this.messages?.description??"",i);for(const s of this.plain(t).sources??[])this.appendInfoSource(this.infoObservationList,this.messages?.source??"",s);const n=this.plain(t).tags;!this.labelsShown&&n&&n.length>0&&this.appendInfoRow(this.infoObservationList,this.messages?.tags??"",n.map(s=>this.tags.name(s)).join(", "))}this.infoAppLink.href=w0,this.infoAppLink.textContent="UFO@home v0.178.4",Yn.fill(this.infoCreditsList,this.sceneElement)}appendInfoSource(t,e,i){const n=document.createElement("dt");n.textContent=e;const s=document.createElement("dd"),r=this.said.read(i.title)??i.url??"";if(i.url&&/^https?:\/\//i.test(i.url)){const c=document.createElement("a");c.href=i.url,c.target="_blank",c.rel="noopener noreferrer",c.textContent=r,s.appendChild(c)}else s.append(r);const a=[i.authors?.join(", "),i.publication?.publisher,i.publication?.time,i.index].filter(Boolean);a.length>0&&s.append(`, ${a.join(", ")}`),t.append(n,s)}static DATE_PATHS=["time","utcOffsetHours","timeZone"];static PLACE_PATHS=["place"];appendInfoRow(t,e,i,n){if(!this.messages)return;const s=document.createElement("dt");s.textContent=e;const r=document.createElement("dd");if(r.textContent=i,n){const a=document.createElement("span");a.className=`basis basis-${n.basis}`,a.textContent=this.messages.basis[n.basis],n.rationales.length>0&&(a.title=n.rationales.join(`
|
|
9874
9874
|
`)),r.append(" ",a)}t.appendChild(s),t.appendChild(r)}}const jo="rr0-sighting",FM="observerchange";function z3(){Yy(),fl.register(),customElements.get(jo)||customElements.define(jo,qc)}class Qo extends HTMLElement{static TAG="rr0-readings-comparison";static CSS=`
|
|
9875
9875
|
:host { display: block; font-size: 13px; line-height: 1.4; }
|
|
9876
9876
|
:host([hidden]) { display: none; }
|
|
@@ -9901,7 +9901,7 @@ button.open { display: inline-flex; align-items: center; gap: 6px; cursor: point
|
|
|
9901
9901
|
.option input { margin: 2px 0 0; }
|
|
9902
9902
|
${Ia.css(".menu")}
|
|
9903
9903
|
.menu:popover-open { position-area: bottom span-left; margin: .35em 0 0; }
|
|
9904
|
-
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Zc.TAG)||customElements.define(Zc.TAG,Zc)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Ws.preferencesFor(this),this.language=vo([...this.preferences],Mo),this.messages=await BT.load(this.language),this.draw()}draw(){const t=this.messages,e=document.createElement("style");e.textContent=Zc.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=t.hint,i.setAttribute("aria-label",t.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Zc.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:t.button}));const n=document.createElement("div");n.className="menu",n.setAttribute("role","menu"),Ia.attach(i,n);const s=[["html",t.html,t.htmlHint],["print",t.print,t.printHint],["json",t.json,t.jsonHint],["csv",t.csv,t.csvHint]];n.append(...s.map(([c,l,h])=>{const u=document.createElement("button");return u.type="button",u.setAttribute("role","menuitem"),u.append(Object.assign(document.createElement("strong"),{textContent:l}),Object.assign(document.createElement("small"),{textContent:h})),u.addEventListener("click",()=>void this.export(c,n)),u}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:t.pictures}),Object.assign(document.createElement("small"),{textContent:t.picturesHint})),r.append(this.withPictures,a),n.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),n.append(this.status),i.addEventListener("click",()=>Ia.show(n,n.hidden)),this.shadowRoot.replaceChildren(e,i,n)}async export(t,e){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:n},s]=await Promise.all([at(()=>import("./CaseReportExport-
|
|
9904
|
+
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Zc.TAG)||customElements.define(Zc.TAG,Zc)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Ws.preferencesFor(this),this.language=vo([...this.preferences],Mo),this.messages=await BT.load(this.language),this.draw()}draw(){const t=this.messages,e=document.createElement("style");e.textContent=Zc.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=t.hint,i.setAttribute("aria-label",t.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Zc.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:t.button}));const n=document.createElement("div");n.className="menu",n.setAttribute("role","menu"),Ia.attach(i,n);const s=[["html",t.html,t.htmlHint],["print",t.print,t.printHint],["json",t.json,t.jsonHint],["csv",t.csv,t.csvHint]];n.append(...s.map(([c,l,h])=>{const u=document.createElement("button");return u.type="button",u.setAttribute("role","menuitem"),u.append(Object.assign(document.createElement("strong"),{textContent:l}),Object.assign(document.createElement("small"),{textContent:h})),u.addEventListener("click",()=>void this.export(c,n)),u}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:t.pictures}),Object.assign(document.createElement("small"),{textContent:t.picturesHint})),r.append(this.withPictures,a),n.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),n.append(this.status),i.addEventListener("click",()=>Ia.show(n,n.hidden)),this.shadowRoot.replaceChildren(e,i,n)}async export(t,e){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:n},s]=await Promise.all([at(()=>import("./CaseReportExport-DHdgnsTQ.js"),[],import.meta.url),this.source()]);await n.make(t,s,this.language,this.preferences,this.withPictures?.checked??!1,(r,a)=>{this.status.textContent=i.drawing.replace("{done}",String(r)).replace("{total}",String(a))}),this.status.hidden=!0,Ia.show(e,!1)}catch{this.status.textContent=i.failed}}}}class xe{static draw(t,e="none"){return`<svg class="icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="${e}" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}static TRASH=xe.draw('<path d="M2.5 4.5h11"/><path d="M6 4.5V3h4v1.5"/><path d="M4 4.5l.7 9h6.6l.7-9"/><path d="M6.8 7v4.5M9.2 7v4.5"/>');static TARGET=xe.draw('<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="1.6"/><path d="M8 1v2.2M8 12.8V15M1 8h2.2M12.8 8H15"/>');static PLAY=xe.draw('<path d="M5 3.2v9.6L12.6 8z"/>',"currentColor");static PAUSE=xe.draw('<path d="M5.5 3.5v9M10.5 3.5v9"/>');static RECORD=xe.draw('<circle cx="8" cy="8" r="4.2" fill="var(--error, #d93025)" stroke="none"/>');static STOP=xe.draw('<rect x="4" y="4" width="8" height="8" rx="1.2"/>',"currentColor");static PREVIOUS_MARK=xe.draw('<path d="M6.5 4 2.5 8l4 4"/><path d="M11 5.2 13.8 8 11 10.8 8.2 8z"/>');static NEXT_MARK=xe.draw('<path d="M9.5 4l4 4-4 4"/><path d="M5 5.2 7.8 8 5 10.8 2.2 8z"/>');static CLOSE=xe.draw('<path d="M4 4l8 8M12 4l-8 8"/>');static PLUS=xe.draw('<path d="M8 3v10M3 8h10"/>');static COPY=xe.draw('<rect x="5.5" y="5.5" width="8" height="8" rx="1.3"/><path d="M10.5 3.2h-7a1.3 1.3 0 0 0-1.3 1.3v7"/>');static CLOCK=xe.draw('<circle cx="8" cy="8" r="6"/><path d="M8 4.6V8l2.4 1.6"/>');static INTERVIEW=xe.draw('<path d="M13.3 9.2a1.6 1.6 0 0 1-1.6 1.6H6.2L3 13.4V4.4a1.6 1.6 0 0 1 1.6-1.6h7.1a1.6 1.6 0 0 1 1.6 1.6z"/><path d="M5.8 6.1h5.1M5.8 8.4h3.2"/>');static LOCK=xe.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.8 0v1.8"/>');static LOCK_OPEN=xe.draw('<rect x="3.2" y="7.2" width="9.6" height="6.4" rx="1.4"/><path d="M5.6 7.2V5.4a2.4 2.4 0 0 1 4.6-.7"/>');static METEOR=xe.draw('<path d="M2.5 2.5l7 7"/><path d="M5.5 2.5l5 5"/><circle cx="11.5" cy="11.5" r="2"/>');static COMET=xe.draw('<circle cx="11" cy="11" r="2.4"/><path d="M9.3 9.3 2.5 2.5M9 11.2 3 7M11.2 9 7 3"/>');static STAR=xe.draw('<path d="M8 2.2l1.7 3.6 3.9.5-2.9 2.7.8 3.9L8 11l-3.5 1.9.8-3.9-2.9-2.7 3.9-.5z"/>');static SATELLITE=xe.draw('<rect x="6.3" y="6.3" width="3.4" height="3.4" transform="rotate(45 8 8)"/><path d="M5.4 5.4 3 3M10.6 10.6 13 13"/><path d="M1.8 4.2 4.2 1.8M11.8 14.2l2.4-2.4"/><path d="M10.5 3.5a3 3 0 0 1 2 2"/>');static FIREBALL=xe.draw('<circle cx="10.5" cy="10.5" r="2.6"/><path d="M8.6 8.6 3 3M8 10.6 4.5 8.5M10.6 8 8.5 4.5"/>');static SUMMARY=xe.draw('<rect x="3" y="2" width="10" height="12" rx="1.5"/><path d="M5.5 5.5h5M5.5 8h5M5.5 10.5h3"/>');static WITNESS=xe.draw('<circle cx="8" cy="5" r="2.6"/><path d="M2.8 14c.6-3 2.6-4.6 5.2-4.6s4.6 1.6 5.2 4.6"/>');static LOCATION=xe.draw('<path d="M8 14.3s4.5-4.3 4.5-7.8a4.5 4.5 0 0 0-9 0c0 3.5 4.5 7.8 4.5 7.8z"/><circle cx="8" cy="6.5" r="1.6"/>');static DATE=xe.draw('<rect x="2.3" y="3.3" width="11.4" height="10.4" rx="1.5"/><path d="M2.3 6.6h11.4M5.3 1.8v2.8M10.7 1.8v2.8"/>');static ENVIRONMENT=xe.draw('<path d="M1.5 14h13"/><path d="M2.8 14V8.3L6.3 5.5l3.5 2.8V14"/><path d="M12.2 14V9.4"/><circle cx="12.2" cy="7.4" r="2.1"/>');static SKY=xe.draw('<path d="M4.6 12.5h7a2.6 2.6 0 0 0 .3-5.2 3.8 3.8 0 0 0-7.3-.6 2.9 2.9 0 0 0 0 5.8z"/>');static PHENOMENON=xe.draw('<ellipse cx="8" cy="9" rx="6.3" ry="2.1"/><path d="M4.6 7.8a3.4 3.4 0 0 1 6.8 0"/><path d="M5 13.4l.6-1.4M11 13.4l-.6-1.4M8 14v-1.4"/>');static SOUND=xe.draw('<path d="M2.5 6.2h2.3L8 3.5v9L4.8 9.8H2.5z"/><path d="M10.5 6a2.8 2.8 0 0 1 0 4M12.3 4.2a5.4 5.4 0 0 1 0 7.6"/>');static PICTURES=xe.draw('<rect x="2" y="3" width="12" height="10" rx="1.5"/><circle cx="5.8" cy="6.4" r="1.2"/><path d="M2.5 12l3.8-3.6 2.4 2.2 2.2-1.8 2.6 2.5"/>');static FILES=xe.draw('<path d="M4 1.8h5.2L12.5 5v9.2H4z"/><path d="M9 1.8V5.2h3.5"/>');static BY_GLYPH={"🗑":xe.TRASH,"🎯":xe.TARGET,"+":xe.PLUS,"✕":xe.CLOSE,"▶":xe.PLAY,"⏸":xe.PAUSE,"⏺":xe.RECORD,"⏹":xe.STOP};static show(t,e){if(t.dataset.icon===e&&t.firstChild)return;const i=xe.BY_GLYPH[e];i?t.innerHTML=i:t.textContent=e,t.dataset.icon=e}static CSS=`
|
|
9905
9905
|
.icon { display: block; flex: none; }
|
|
9906
9906
|
button:has(> .icon:only-child) { display: inline-flex; align-items: center; justify-content: center; }
|
|
9907
9907
|
`}const Y7="interviewseek",K7=`
|
|
@@ -10000,8 +10000,10 @@ button:has(> .icon:only-child) { display: inline-flex; align-items: center; just
|
|
|
10000
10000
|
.event-ref { position: relative; z-index: 1; padding: 0; border: 0; background: none; color: var(--rr0-sky, #7fd4ff); font: inherit;
|
|
10001
10001
|
text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
|
|
10002
10002
|
/* What is open: one block per event, each saying which it is, in the order of time. */
|
|
10003
|
-
|
|
10004
|
-
|
|
10003
|
+
/* One column as wide as the case, never as wide as what is in it: an implicit "auto" column grew to the player's own widest content,
|
|
10004
|
+
McMinnville's longest reading in its choice (228 letters), and the stage, 16:9 of that, put the photograph beyond the case's edge. */
|
|
10005
|
+
.open-events { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
|
|
10006
|
+
.open-event { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
|
|
10005
10007
|
.open-event > .open-title { margin: 0; font: 600 13px/1.4 var(--rr0-sans, system-ui, sans-serif); letter-spacing: .04em; text-transform: uppercase; opacity: .7; }
|
|
10006
10008
|
.open-event rr0-interview { padding: 10px 12px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 10px;
|
|
10007
10009
|
font-size: 14px; line-height: 1.5; max-height: 22em; overflow-y: auto; }
|