worldorbit 3.2.1 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/browser/obsidian-plugin/dist/diagnostics.d.ts +3 -0
  2. package/dist/browser/obsidian-plugin/dist/diagnostics.js +23 -0
  3. package/dist/browser/obsidian-plugin/dist/examples.d.ts +3 -0
  4. package/dist/browser/obsidian-plugin/dist/examples.js +77 -0
  5. package/dist/browser/obsidian-plugin/dist/index.d.ts +9 -0
  6. package/dist/browser/obsidian-plugin/dist/index.js +8 -0
  7. package/dist/browser/obsidian-plugin/dist/main.d.ts +2 -0
  8. package/dist/browser/obsidian-plugin/dist/main.js +2 -0
  9. package/dist/browser/obsidian-plugin/dist/navigation.d.ts +6 -0
  10. package/dist/browser/obsidian-plugin/dist/navigation.js +44 -0
  11. package/dist/browser/obsidian-plugin/dist/plugin.d.ts +8 -0
  12. package/dist/browser/obsidian-plugin/dist/plugin.js +508 -0
  13. package/dist/browser/obsidian-plugin/dist/positions.d.ts +7 -0
  14. package/dist/browser/obsidian-plugin/dist/positions.js +14 -0
  15. package/dist/browser/obsidian-plugin/dist/settings.d.ts +2 -0
  16. package/dist/browser/obsidian-plugin/dist/settings.js +5 -0
  17. package/dist/browser/obsidian-plugin/dist/theme.d.ts +2 -0
  18. package/dist/browser/obsidian-plugin/dist/theme.js +31 -0
  19. package/dist/browser/obsidian-plugin/dist/types.d.ts +42 -0
  20. package/dist/browser/obsidian-plugin/dist/types.js +1 -0
  21. package/dist/browser/obsidian-plugin/dist/viewer-host.d.ts +14 -0
  22. package/dist/browser/obsidian-plugin/dist/viewer-host.js +110 -0
  23. package/dist/browser/viewer/dist/index.d.ts +1 -0
  24. package/dist/browser/viewer/dist/index.js +1 -0
  25. package/dist/browser/viewer/dist/interactive-2d.d.ts +21 -0
  26. package/dist/browser/viewer/dist/interactive-2d.js +201 -0
  27. package/dist/browser/viewer/dist/render.d.ts +1 -1
  28. package/dist/browser/viewer/dist/render.js +2 -1
  29. package/dist/browser/viewer/dist/viewer-state.d.ts +1 -1
  30. package/dist/browser/viewer/dist/viewer-state.js +1 -1
  31. package/dist/obsidian-plugin/LICENSE +21 -0
  32. package/dist/obsidian-plugin/README.md +124 -0
  33. package/dist/obsidian-plugin/main.js +108 -0
  34. package/dist/obsidian-plugin/manifest.json +9 -0
  35. package/dist/obsidian-plugin/obsidian_scsh_1.png +0 -0
  36. package/dist/obsidian-plugin/obsidian_scsh_2.png +0 -0
  37. package/dist/obsidian-plugin/styles.css +164 -0
  38. package/dist/unpkg/obsidian-plugin/dist/diagnostics.d.ts +3 -0
  39. package/dist/unpkg/obsidian-plugin/dist/diagnostics.js +23 -0
  40. package/dist/unpkg/obsidian-plugin/dist/examples.d.ts +3 -0
  41. package/dist/unpkg/obsidian-plugin/dist/examples.js +77 -0
  42. package/dist/unpkg/obsidian-plugin/dist/index.d.ts +9 -0
  43. package/dist/unpkg/obsidian-plugin/dist/index.js +8 -0
  44. package/dist/unpkg/obsidian-plugin/dist/main.d.ts +2 -0
  45. package/dist/unpkg/obsidian-plugin/dist/main.js +2 -0
  46. package/dist/unpkg/obsidian-plugin/dist/navigation.d.ts +6 -0
  47. package/dist/unpkg/obsidian-plugin/dist/navigation.js +44 -0
  48. package/dist/unpkg/obsidian-plugin/dist/plugin.d.ts +8 -0
  49. package/dist/unpkg/obsidian-plugin/dist/plugin.js +508 -0
  50. package/dist/unpkg/obsidian-plugin/dist/positions.d.ts +7 -0
  51. package/dist/unpkg/obsidian-plugin/dist/positions.js +14 -0
  52. package/dist/unpkg/obsidian-plugin/dist/settings.d.ts +2 -0
  53. package/dist/unpkg/obsidian-plugin/dist/settings.js +5 -0
  54. package/dist/unpkg/obsidian-plugin/dist/theme.d.ts +2 -0
  55. package/dist/unpkg/obsidian-plugin/dist/theme.js +31 -0
  56. package/dist/unpkg/obsidian-plugin/dist/types.d.ts +42 -0
  57. package/dist/unpkg/obsidian-plugin/dist/types.js +1 -0
  58. package/dist/unpkg/obsidian-plugin/dist/viewer-host.d.ts +14 -0
  59. package/dist/unpkg/obsidian-plugin/dist/viewer-host.js +110 -0
  60. package/dist/unpkg/viewer/dist/index.d.ts +1 -0
  61. package/dist/unpkg/viewer/dist/index.js +1 -0
  62. package/dist/unpkg/viewer/dist/interactive-2d.d.ts +21 -0
  63. package/dist/unpkg/viewer/dist/interactive-2d.js +201 -0
  64. package/dist/unpkg/viewer/dist/render.d.ts +1 -1
  65. package/dist/unpkg/viewer/dist/render.js +2 -1
  66. package/dist/unpkg/viewer/dist/viewer-state.d.ts +1 -1
  67. package/dist/unpkg/viewer/dist/viewer-state.js +1 -1
  68. package/dist/unpkg/worldorbit-editor.min.js +56 -56
  69. package/dist/unpkg/worldorbit-markdown.min.js +15 -15
  70. package/dist/unpkg/worldorbit-viewer.min.js +207 -207
  71. package/dist/unpkg/worldorbit.js +200 -0
  72. package/dist/unpkg/worldorbit.min.js +210 -210
  73. package/package.json +18 -1
  74. package/packages/viewer/dist/index.d.ts +1 -0
  75. package/packages/viewer/dist/index.js +1 -0
  76. package/packages/viewer/dist/interactive-2d.d.ts +21 -0
  77. package/packages/viewer/dist/interactive-2d.js +201 -0
  78. package/packages/viewer/dist/render.d.ts +1 -1
  79. package/packages/viewer/dist/render.js +2 -1
  80. package/packages/viewer/dist/viewer-state.d.ts +1 -1
  81. package/packages/viewer/dist/viewer-state.js +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";var WorldOrbitEditor=(()=>{var Ku=Object.defineProperty;var fx=Object.getOwnPropertyDescriptor;var px=Object.getOwnPropertyNames;var mx=Object.prototype.hasOwnProperty;var gx=(n,e)=>()=>(n&&(e=n(n=0)),e);var qp=(n,e)=>{for(var t in e)Ku(n,t,{get:e[t],enumerable:!0})},yx=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of px(e))!mx.call(n,r)&&r!==t&&Ku(n,r,{get:()=>e[r],enumerable:!(i=fx(e,r))||i.enumerable});return n};var vx=n=>yx(Ku({},"__esModule",{value:!0}),n);var Rv={};qp(Rv,{ACESFilmicToneMapping:()=>N0,AddEquation:()=>ji,AddOperation:()=>L0,AdditiveAnimationBlendMode:()=>Ip,AdditiveBlending:()=>wh,AgXToneMapping:()=>k0,AlphaFormat:()=>j0,AlwaysCompare:()=>cv,AlwaysDepth:()=>E0,AlwaysStencilFunc:()=>Kh,AmbientLight:()=>Eu,AnimationAction:()=>Uu,AnimationClip:()=>jr,AnimationLoader:()=>Cf,AnimationMixer:()=>Wf,AnimationObjectGroup:()=>Gf,AnimationUtils:()=>n2,ArcCurve:()=>Hl,ArrayCamera:()=>Cl,ArrowHelper:()=>pp,AttachedBindMode:()=>Eh,Audio:()=>Du,AudioAnalyser:()=>Hf,AudioContext:()=>Oa,AudioListener:()=>Vf,AudioLoader:()=>Bf,AxesHelper:()=>mp,BackSide:()=>nn,BasicDepthPacking:()=>Q0,BasicShadowMap:()=>OM,BatchedMesh:()=>kl,Bone:()=>ma,BooleanKeyframeTrack:()=>wi,Box2:()=>tp,Box3:()=>Bt,Box3Helper:()=>hp,BoxGeometry:()=>Ur,BoxHelper:()=>dp,BufferAttribute:()=>ot,BufferGeometry:()=>et,BufferGeometryLoader:()=>Pu,ByteType:()=>V0,Cache:()=>mi,Camera:()=>js,CameraHelper:()=>up,CanvasTexture:()=>Sf,CapsuleGeometry:()=>Yl,CatmullRomCurve3:()=>jl,CineonToneMapping:()=>U0,CircleGeometry:()=>Zl,ClampToEdgeWrapping:()=>Mn,Clock:()=>Lu,Color:()=>Ie,ColorKeyframeTrack:()=>Ra,ColorManagement:()=>dt,CompressedArrayTexture:()=>wf,CompressedCubeTexture:()=>Mf,CompressedTexture:()=>qs,CompressedTextureLoader:()=>Rf,ConeGeometry:()=>Jl,ConstantAlphaFactor:()=>w0,ConstantColorFactor:()=>b0,CubeCamera:()=>Tl,CubeReflectionMapping:()=>bi,CubeRefractionMapping:()=>Wi,CubeTexture:()=>Nr,CubeTextureLoader:()=>Pf,CubeUVReflectionMapping:()=>Js,CubicBezierCurve:()=>ya,CubicBezierCurve3:()=>Gl,CubicInterpolant:()=>vu,CullFaceBack:()=>_h,CullFaceFront:()=>r0,CullFaceFrontBack:()=>DM,CullFaceNone:()=>i0,Curve:()=>mn,CurvePath:()=>ql,CustomBlending:()=>o0,CustomToneMapping:()=>F0,CylinderGeometry:()=>Zs,Cylindrical:()=>ep,Data3DTexture:()=>aa,DataArrayTexture:()=>Vs,DataTexture:()=>Gn,DataTextureLoader:()=>Lf,DataUtils:()=>VS,DecrementStencilOp:()=>GM,DecrementWrapStencilOp:()=>XM,DefaultLoadingManager:()=>Iv,DepthFormat:()=>Lr,DepthStencilFormat:()=>Bs,DepthTexture:()=>da,DetachedBindMode:()=>z0,DirectionalLight:()=>Su,DirectionalLightHelper:()=>lp,DiscreteInterpolant:()=>xu,DisplayP3ColorSpace:()=>ku,DodecahedronGeometry:()=>Kl,DoubleSide:()=>$n,DstAlphaFactor:()=>m0,DstColorFactor:()=>y0,DynamicCopyUsage:()=>cS,DynamicDrawUsage:()=>nS,DynamicReadUsage:()=>sS,EdgesGeometry:()=>Ql,EllipseCurve:()=>Ys,EqualCompare:()=>rv,EqualDepth:()=>T0,EqualStencilFunc:()=>JM,EquirectangularReflectionMapping:()=>qo,EquirectangularRefractionMapping:()=>Yo,Euler:()=>fn,EventDispatcher:()=>On,ExtrudeGeometry:()=>eu,FileLoader:()=>Un,Float16BufferAttribute:()=>cf,Float32BufferAttribute:()=>De,FloatType:()=>Sn,Fog:()=>Pl,FogExp2:()=>Rl,FramebufferTexture:()=>_f,FrontSide:()=>xi,Frustum:()=>Fr,GLBufferAttribute:()=>Zf,GLSL1:()=>uS,GLSL3:()=>Qh,GreaterCompare:()=>sv,GreaterDepth:()=>C0,GreaterEqualCompare:()=>av,GreaterEqualDepth:()=>I0,GreaterEqualStencilFunc:()=>tS,GreaterStencilFunc:()=>QM,GridHelper:()=>ap,Group:()=>Gi,HalfFloatType:()=>Na,HemisphereLight:()=>_u,HemisphereLightHelper:()=>op,IcosahedronGeometry:()=>tu,ImageBitmapLoader:()=>kf,ImageLoader:()=>Gr,ImageUtils:()=>El,IncrementStencilOp:()=>jM,IncrementWrapStencilOp:()=>WM,InstancedBufferAttribute:()=>qi,InstancedBufferGeometry:()=>Ru,InstancedInterleavedBuffer:()=>Yf,InstancedMesh:()=>Fl,Int16BufferAttribute:()=>of,Int32BufferAttribute:()=>af,Int8BufferAttribute:()=>nf,IntType:()=>_p,InterleavedBuffer:()=>Xs,InterleavedBufferAttribute:()=>kr,Interpolant:()=>Vr,InterpolateDiscrete:()=>Ko,InterpolateLinear:()=>Qo,InterpolateSmooth:()=>wl,InvertStencilOp:()=>qM,KeepStencilOp:()=>Er,KeyframeTrack:()=>gn,LOD:()=>Ol,LatheGeometry:()=>wa,Layers:()=>$s,LessCompare:()=>iv,LessDepth:()=>A0,LessEqualCompare:()=>Cp,LessEqualDepth:()=>Xo,LessEqualStencilFunc:()=>KM,LessStencilFunc:()=>ZM,Light:()=>Yn,LightProbe:()=>Iu,Line:()=>qn,Line3:()=>np,LineBasicMaterial:()=>zt,LineCurve:()=>va,LineCurve3:()=>Wl,LineDashedMaterial:()=>yu,LineLoop:()=>Vl,LineSegments:()=>En,LinearDisplayP3ColorSpace:()=>Fa,LinearFilter:()=>It,LinearInterpolant:()=>Ca,LinearMipMapLinearFilter:()=>kM,LinearMipMapNearestFilter:()=>FM,LinearMipmapLinearFilter:()=>Hn,LinearMipmapNearestFilter:()=>$o,LinearSRGBColorSpace:()=>Si,LinearToneMapping:()=>D0,LinearTransfer:()=>ta,Loader:()=>Jt,LoaderUtils:()=>Da,LoadingManager:()=>Pa,LoopOnce:()=>Z0,LoopPingPong:()=>K0,LoopRepeat:()=>J0,LuminanceAlphaFormat:()=>X0,LuminanceFormat:()=>W0,MOUSE:()=>PM,Material:()=>Ft,MaterialLoader:()=>Cu,MathUtils:()=>TS,Matrix3:()=>Ze,Matrix4:()=>Ve,MaxEquation:()=>u0,Mesh:()=>St,MeshBasicMaterial:()=>Xn,MeshDepthMaterial:()=>ha,MeshDistanceMaterial:()=>fa,MeshLambertMaterial:()=>mu,MeshMatcapMaterial:()=>gu,MeshNormalMaterial:()=>pu,MeshPhongMaterial:()=>hu,MeshPhysicalMaterial:()=>du,MeshStandardMaterial:()=>Ia,MeshToonMaterial:()=>fu,MinEquation:()=>l0,MirroredRepeatWrapping:()=>Jo,MixOperation:()=>P0,MultiplyBlending:()=>Sh,MultiplyOperation:()=>Ua,NearestFilter:()=>Ut,NearestMipMapLinearFilter:()=>NM,NearestMipMapNearestFilter:()=>UM,NearestMipmapLinearFilter:()=>Ds,NearestMipmapNearestFilter:()=>xp,NeutralToneMapping:()=>B0,NeverCompare:()=>nv,NeverDepth:()=>S0,NeverStencilFunc:()=>YM,NoBlending:()=>gi,NoColorSpace:()=>di,NoToneMapping:()=>yi,NormalAnimationBlendMode:()=>Fu,NormalBlending:()=>Pr,NotEqualCompare:()=>ov,NotEqualDepth:()=>R0,NotEqualStencilFunc:()=>eS,NumberKeyframeTrack:()=>$r,Object3D:()=>ct,ObjectLoader:()=>Ff,ObjectSpaceNormalMap:()=>tv,OctahedronGeometry:()=>Aa,OneFactor:()=>h0,OneMinusConstantAlphaFactor:()=>M0,OneMinusConstantColorFactor:()=>_0,OneMinusDstAlphaFactor:()=>g0,OneMinusDstColorFactor:()=>v0,OneMinusSrcAlphaFactor:()=>Sl,OneMinusSrcColorFactor:()=>p0,OrthographicCamera:()=>Ws,P3Primaries:()=>ia,PCFShadowMap:()=>vp,PCFSoftShadowMap:()=>s0,PMREMGenerator:()=>ua,Path:()=>Br,PerspectiveCamera:()=>Rt,Plane:()=>Vn,PlaneGeometry:()=>Gs,PlaneHelper:()=>fp,PointLight:()=>Mu,PointLightHelper:()=>sp,Points:()=>$l,PointsMaterial:()=>ga,PolarGridHelper:()=>cp,PolyhedronGeometry:()=>Yi,PositionalAudio:()=>$f,PropertyBinding:()=>ut,PropertyMixer:()=>Ou,QuadraticBezierCurve:()=>xa,QuadraticBezierCurve3:()=>ba,Quaternion:()=>Zt,QuaternionKeyframeTrack:()=>Zi,QuaternionLinearInterpolant:()=>bu,RED_GREEN_RGTC2_Format:()=>Zh,RED_RGTC1_Format:()=>Y0,REVISION:()=>RM,RGBADepthPacking:()=>ev,RGBAFormat:()=>un,RGBAIntegerFormat:()=>Tp,RGBA_ASTC_10x10_Format:()=>jh,RGBA_ASTC_10x5_Format:()=>Vh,RGBA_ASTC_10x6_Format:()=>$h,RGBA_ASTC_10x8_Format:()=>Hh,RGBA_ASTC_12x10_Format:()=>Gh,RGBA_ASTC_12x12_Format:()=>Wh,RGBA_ASTC_4x4_Format:()=>Dh,RGBA_ASTC_5x4_Format:()=>Oh,RGBA_ASTC_5x5_Format:()=>Uh,RGBA_ASTC_6x5_Format:()=>Nh,RGBA_ASTC_6x6_Format:()=>Fh,RGBA_ASTC_8x5_Format:()=>kh,RGBA_ASTC_8x6_Format:()=>Bh,RGBA_ASTC_8x8_Format:()=>zh,RGBA_BPTC_Format:()=>_l,RGBA_ETC2_EAC_Format:()=>Lh,RGBA_PVRTC_2BPPV1_Format:()=>Ch,RGBA_PVRTC_4BPPV1_Format:()=>Ih,RGBA_S3TC_DXT1_Format:()=>vl,RGBA_S3TC_DXT3_Format:()=>xl,RGBA_S3TC_DXT5_Format:()=>bl,RGBFormat:()=>G0,RGB_BPTC_SIGNED_Format:()=>Xh,RGB_BPTC_UNSIGNED_Format:()=>qh,RGB_ETC1_Format:()=>Rh,RGB_ETC2_Format:()=>Ph,RGB_PVRTC_2BPPV1_Format:()=>Th,RGB_PVRTC_4BPPV1_Format:()=>Ah,RGB_S3TC_DXT1_Format:()=>yl,RGFormat:()=>q0,RGIntegerFormat:()=>Ap,RawShaderMaterial:()=>uu,Ray:()=>Xi,Raycaster:()=>Jf,Rec709Primaries:()=>na,RectAreaLight:()=>Au,RedFormat:()=>Sp,RedIntegerFormat:()=>Ep,ReinhardToneMapping:()=>O0,RenderTarget:()=>Al,RepeatWrapping:()=>Zo,ReplaceStencilOp:()=>HM,ReverseSubtractEquation:()=>c0,RingGeometry:()=>nu,SIGNED_RED_GREEN_RGTC2_Format:()=>Jh,SIGNED_RED_RGTC1_Format:()=>Yh,SRGBColorSpace:()=>wn,SRGBTransfer:()=>yt,Scene:()=>Ll,ShaderChunk:()=>Ke,ShaderLib:()=>Dn,ShaderMaterial:()=>pn,ShadowMaterial:()=>lu,Shape:()=>vi,ShapeGeometry:()=>iu,ShapePath:()=>gp,ShapeUtils:()=>Wn,ShortType:()=>$0,Skeleton:()=>Nl,SkeletonHelper:()=>rp,SkinnedMesh:()=>Ul,Source:()=>fi,Sphere:()=>Nt,SphereGeometry:()=>Ta,Spherical:()=>Qf,SphericalHarmonics3:()=>Tu,SplineCurve:()=>_a,SpotLight:()=>wu,SpotLightHelper:()=>ip,Sprite:()=>Dl,SpriteMaterial:()=>pa,SrcAlphaFactor:()=>Ml,SrcAlphaSaturateFactor:()=>x0,SrcColorFactor:()=>f0,StaticCopyUsage:()=>aS,StaticDrawUsage:()=>ra,StaticReadUsage:()=>rS,StereoCamera:()=>zf,StreamCopyUsage:()=>lS,StreamDrawUsage:()=>iS,StreamReadUsage:()=>oS,StringKeyframeTrack:()=>Mi,SubtractEquation:()=>a0,SubtractiveBlending:()=>Mh,TOUCH:()=>LM,TangentSpaceNormalMap:()=>Ji,TetrahedronGeometry:()=>ru,Texture:()=>Ct,TextureLoader:()=>Df,TorusGeometry:()=>su,TorusKnotGeometry:()=>ou,Triangle:()=>pi,TriangleFanDrawMode:()=>VM,TriangleStripDrawMode:()=>zM,TrianglesDrawMode:()=>BM,TubeGeometry:()=>au,UVMapping:()=>Nu,Uint16BufferAttribute:()=>ca,Uint32BufferAttribute:()=>la,Uint8BufferAttribute:()=>rf,Uint8ClampedBufferAttribute:()=>sf,Uniform:()=>Xf,UniformsGroup:()=>qf,UniformsLib:()=>Ee,UniformsUtils:()=>pv,UnsignedByteType:()=>_i,UnsignedInt248Type:()=>Ks,UnsignedInt5999Type:()=>H0,UnsignedIntType:()=>Or,UnsignedShort4444Type:()=>wp,UnsignedShort5551Type:()=>Mp,UnsignedShortType:()=>bp,VSMShadowMap:()=>zn,Vector2:()=>se,Vector3:()=>D,Vector4:()=>ht,VectorKeyframeTrack:()=>Hr,VideoTexture:()=>bf,WebGL3DRenderTarget:()=>tf,WebGLArrayRenderTarget:()=>ef,WebGLCoordinateSystem:()=>jn,WebGLCubeRenderTarget:()=>Il,WebGLMultipleRenderTargets:()=>yp,WebGLRenderTarget:()=>hn,WebGLRenderer:()=>yf,WebGLUtils:()=>_v,WebGPUCoordinateSystem:()=>sa,WireframeGeometry:()=>cu,WrapAroundEnding:()=>ea,ZeroCurvatureEnding:()=>Ir,ZeroFactor:()=>d0,ZeroSlopeEnding:()=>Cr,ZeroStencilOp:()=>$M,createCanvasElement:()=>uv});function dn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xt[n&255]+Xt[n>>8&255]+Xt[n>>16&255]+Xt[n>>24&255]+"-"+Xt[e&255]+Xt[e>>8&255]+"-"+Xt[e>>16&15|64]+Xt[e>>24&255]+"-"+Xt[t&63|128]+Xt[t>>8&255]+"-"+Xt[t>>16&255]+Xt[t>>24&255]+Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]).toLowerCase()}function Mt(n,e,t){return Math.max(e,Math.min(t,n))}function Rp(n,e){return(n%e+e)%e}function dS(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function hS(n,e,t){return n!==e?(t-n)/(e-n):0}function Ho(n,e,t){return(1-t)*n+t*e}function fS(n,e,t,i){return Ho(n,e,1-Math.exp(-t*i))}function pS(n,e=1){return e-Math.abs(Rp(n,e*2)-e)}function mS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function gS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function yS(n,e){return n+Math.floor(Math.random()*(e-n+1))}function vS(n,e){return n+Math.random()*(e-n)}function xS(n){return n*(.5-Math.random())}function bS(n){n!==void 0&&(Eg=n);let e=Eg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function _S(n){return n*Dr}function wS(n){return n*zs}function MS(n){return(n&n-1)===0&&n!==0}function SS(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function ES(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function AS(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),u=o((e+i)/2),d=s((e-i)/2),h=o((e-i)/2),f=s((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":n.set(a*u,c*d,c*h,a*l);break;case"YZY":n.set(c*h,a*u,c*d,a*l);break;case"ZXZ":n.set(c*d,c*h,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function tn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Je(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function lv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Os(n,e){return new IS[n](e)}function oa(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function uv(){let n=oa("canvas");return n.style.display="block",n}function dv(n){n in Ag||(Ag[n]=!0,console.warn(n))}function Fs(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function kd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Bd(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?El.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function Vd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){pr.fromArray(n,s);let a=r.x*Math.abs(pr.x)+r.y*Math.abs(pr.y)+r.z*Math.abs(pr.z),c=e.dot(pr),l=t.dot(pr),u=i.dot(pr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}function Jd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function zS(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function sn(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Mt(n,-65504,65504),hi.floatView[0]=n;let e=hi.uint32View[0],t=e>>23&511;return hi.baseTable[t]+((e&8388607)>>hi.shiftTable[t])}function zo(n){let e=n>>10;return hi.uint32View[0]=hi.mantissaTable[hi.offsetTable[e]+(n&1023)]+hi.exponentTable[e],hi.floatView[0]}function HS(n,e,t,i,r,s,o,a){let c;if(e.side===nn?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===xi,a),c===null)return null;Vc.copy(a),Vc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Vc);return l<t.near||l>t.far?null:{distance:l,point:Vc.clone(),object:n}}function $c(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,_s),n.getVertexPosition(c,ws),n.getVertexPosition(l,Ms);let u=HS(n,e,t,i,_s,ws,Ms,zc);if(u){r&&(Fc.fromBufferAttribute(r,a),kc.fromBufferAttribute(r,c),Bc.fromBufferAttribute(r,l),u.uv=pi.getInterpolation(zc,_s,ws,Ms,Fc,kc,Bc,new se)),s&&(Fc.fromBufferAttribute(s,a),kc.fromBufferAttribute(s,c),Bc.fromBufferAttribute(s,l),u.uv1=pi.getInterpolation(zc,_s,ws,Ms,Fc,kc,Bc,new se)),o&&(zg.fromBufferAttribute(o,a),Vg.fromBufferAttribute(o,c),$g.fromBufferAttribute(o,l),u.normal=pi.getInterpolation(zc,_s,ws,Ms,zg,Vg,$g,new D),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new D,materialIndex:0};pi.getNormal(_s,ws,Ms,d.normal),u.face=d}return u}function Hs(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function en(n){let e={};for(let t=0;t<n.length;t++){let i=Hs(n[t]);for(let r in i)e[r]=i[r]}return e}function jS(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function fv(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:dt.workingColorSpace}function mv(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function YS(n){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,d=l.byteLength,h=n.createBuffer();n.bindBuffer(c,h),n.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=n.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=n.SHORT;else if(l instanceof Uint32Array)f=n.UNSIGNED_INT;else if(l instanceof Int32Array)f=n.INT;else if(l instanceof Int8Array)f=n.BYTE;else if(l instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let u=c.array,d=c._updateRange,h=c.updateRanges;if(n.bindBuffer(l,a),d.count===-1&&h.length===0&&n.bufferSubData(l,0,u),h.length!==0){for(let f=0,p=h.length;f<p;f++){let y=h[f];n.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(l,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(n.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}function RA(n,e,t,i,r,s,o){let a=new Ie(0),c=s===!0?0:1,l,u,d=null,h=0,f=null;function p(x){let v=x.isScene===!0?x.background:null;return v&&v.isTexture&&(v=(x.backgroundBlurriness>0?t:e).get(v)),v}function y(x){let v=!1,w=p(x);w===null?m(a,c):w&&w.isColor&&(m(w,1),v=!0);let N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(x,v){let w=p(v);w&&(w.isCubeTexture||w.mapping===Js)?(u===void 0&&(u=new St(new Ur(1,1,1),new pn({name:"BackgroundCubeMaterial",uniforms:Hs(Dn.backgroundCube.uniforms),vertexShader:Dn.backgroundCube.vertexShader,fragmentShader:Dn.backgroundCube.fragmentShader,side:nn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(N,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),yr.copy(v.backgroundRotation),yr.x*=-1,yr.y*=-1,yr.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(yr.y*=-1,yr.z*=-1),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(CA.makeRotationFromEuler(yr)),u.material.toneMapped=dt.getTransfer(w.colorSpace)!==yt,(d!==w||h!==w.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(l===void 0&&(l=new St(new Gs(2,2),new pn({name:"BackgroundMaterial",uniforms:Hs(Dn.background.uniforms),vertexShader:Dn.background.vertexShader,fragmentShader:Dn.background.fragmentShader,side:xi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=w,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=dt.getTransfer(w.colorSpace)!==yt,w.matrixAutoUpdate===!0&&w.updateMatrix(),l.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||h!==w.version||f!==n.toneMapping)&&(l.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function m(x,v){x.getRGB(jc,fv(n)),i.buffers.color.setClear(jc.r,jc.g,jc.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),c=v,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,m(a,c)},render:y,addToRenderList:g}}function PA(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(S,P,k,O,H){let W=!1,J=d(O,k,P);s!==J&&(s=J,l(s.object)),W=f(S,O,k,H),W&&p(S,O,k,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,w(S,P,k,O),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function c(){return n.createVertexArray()}function l(S){return n.bindVertexArray(S)}function u(S){return n.deleteVertexArray(S)}function d(S,P,k){let O=k.wireframe===!0,H=i[S.id];H===void 0&&(H={},i[S.id]=H);let W=H[P.id];W===void 0&&(W={},H[P.id]=W);let J=W[O];return J===void 0&&(J=h(c()),W[O]=J),J}function h(S){let P=[],k=[],O=[];for(let H=0;H<t;H++)P[H]=0,k[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:k,attributeDivisors:O,object:S,attributes:{},index:null}}function f(S,P,k,O){let H=s.attributes,W=P.attributes,J=0,ae=k.getAttributes();for(let B in ae)if(ae[B].location>=0){let ce=H[B],Me=W[B];if(Me===void 0&&(B==="instanceMatrix"&&S.instanceMatrix&&(Me=S.instanceMatrix),B==="instanceColor"&&S.instanceColor&&(Me=S.instanceColor)),ce===void 0||ce.attribute!==Me||Me&&ce.data!==Me.data)return!0;J++}return s.attributesNum!==J||s.index!==O}function p(S,P,k,O){let H={},W=P.attributes,J=0,ae=k.getAttributes();for(let B in ae)if(ae[B].location>=0){let ce=W[B];ce===void 0&&(B==="instanceMatrix"&&S.instanceMatrix&&(ce=S.instanceMatrix),B==="instanceColor"&&S.instanceColor&&(ce=S.instanceColor));let Me={};Me.attribute=ce,ce&&ce.data&&(Me.data=ce.data),H[B]=Me,J++}s.attributes=H,s.attributesNum=J,s.index=O}function y(){let S=s.newAttributes;for(let P=0,k=S.length;P<k;P++)S[P]=0}function g(S){m(S,0)}function m(S,P){let k=s.newAttributes,O=s.enabledAttributes,H=s.attributeDivisors;k[S]=1,O[S]===0&&(n.enableVertexAttribArray(S),O[S]=1),H[S]!==P&&(n.vertexAttribDivisor(S,P),H[S]=P)}function x(){let S=s.newAttributes,P=s.enabledAttributes;for(let k=0,O=P.length;k<O;k++)P[k]!==S[k]&&(n.disableVertexAttribArray(k),P[k]=0)}function v(S,P,k,O,H,W,J){J===!0?n.vertexAttribIPointer(S,P,k,H,W):n.vertexAttribPointer(S,P,k,O,H,W)}function w(S,P,k,O){y();let H=O.attributes,W=k.getAttributes(),J=P.defaultAttributeValues;for(let ae in W){let B=W[ae];if(B.location>=0){let ne=H[ae];if(ne===void 0&&(ae==="instanceMatrix"&&S.instanceMatrix&&(ne=S.instanceMatrix),ae==="instanceColor"&&S.instanceColor&&(ne=S.instanceColor)),ne!==void 0){let ce=ne.normalized,Me=ne.itemSize,fe=e.get(ne);if(fe===void 0)continue;let $e=fe.buffer,Y=fe.type,me=fe.bytesPerElement,te=Y===n.INT||Y===n.UNSIGNED_INT||ne.gpuType===_p;if(ne.isInterleavedBufferAttribute){let ue=ne.data,Pe=ue.stride,_e=ne.offset;if(ue.isInstancedInterleavedBuffer){for(let z=0;z<B.locationSize;z++)m(B.location+z,ue.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let z=0;z<B.locationSize;z++)g(B.location+z);n.bindBuffer(n.ARRAY_BUFFER,$e);for(let z=0;z<B.locationSize;z++)v(B.location+z,Me/B.locationSize,Y,ce,Pe*me,(_e+Me/B.locationSize*z)*me,te)}else{if(ne.isInstancedBufferAttribute){for(let ue=0;ue<B.locationSize;ue++)m(B.location+ue,ne.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let ue=0;ue<B.locationSize;ue++)g(B.location+ue);n.bindBuffer(n.ARRAY_BUFFER,$e);for(let ue=0;ue<B.locationSize;ue++)v(B.location+ue,Me/B.locationSize,Y,ce,Me*me,Me/B.locationSize*ue*me,te)}}else if(J!==void 0){let ce=J[ae];if(ce!==void 0)switch(ce.length){case 2:n.vertexAttrib2fv(B.location,ce);break;case 3:n.vertexAttrib3fv(B.location,ce);break;case 4:n.vertexAttrib4fv(B.location,ce);break;default:n.vertexAttrib1fv(B.location,ce)}}}}x()}function N(){F();for(let S in i){let P=i[S];for(let k in P){let O=P[k];for(let H in O)u(O[H].object),delete O[H];delete P[k]}delete i[S]}}function C(S){if(i[S.id]===void 0)return;let P=i[S.id];for(let k in P){let O=P[k];for(let H in O)u(O[H].object),delete O[H];delete P[k]}delete i[S.id]}function R(S){for(let P in i){let k=i[P];if(k[S.id]===void 0)continue;let O=k[S.id];for(let H in O)u(O[H].object),delete O[H];delete k[S.id]}}function F(){A(),o=!0,s!==r&&(s=r,l(s.object))}function A(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:F,resetDefaultState:A,dispose:N,releaseStatesOfGeometry:C,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function LA(n,e,t){let i;function r(l){i=l}function s(l,u){n.drawArrays(i,l,u),t.update(u,i,1)}function o(l,u,d){d!==0&&(n.drawArraysInstanced(i,l,u,d),t.update(u,i,d))}function a(l,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(l[f],u[f]);else{h.multiDrawArraysWEBGL(i,l,0,u,0,d);let f=0;for(let p=0;p<d;p++)f+=u[p];t.update(f,i,1)}}function c(l,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<l.length;p++)o(l[p],u[p],h[p]);else{f.multiDrawArraysInstancedWEBGL(i,l,0,u,0,h,0,d);let p=0;for(let y=0;y<d;y++)p+=u[y];for(let y=0;y<h.length;y++)t.update(p,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function DA(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let C=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(C){return!(C!==un&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let R=C===Na&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==_i&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Sn&&!R)}function c(C){if(C==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),m=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),x=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),w=f>0,N=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:m,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:w,maxSamples:N}}function OA(n){let e=this,t=null,i=0,r=!1,s=!1,o=new Vn,a=new Ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let p=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,m=n.get(d);if(!r||p===null||p.length===0||s&&!g)s?u(null):l();else{let x=s?0:i,v=x*4,w=m.clippingState||null;c.value=w,w=u(p,h,v,f);for(let N=0;N!==v;++N)w[N]=t[N];m.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=c.value,p!==!0||g===null){let m=f+y*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,w=f;v!==y;++v,w+=4)o.copy(d[v]).applyMatrix4(x,a),o.normal.toArray(g,w),g[w+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function UA(n){let e=new WeakMap;function t(o,a){return a===qo?o.mapping=bi:a===Yo&&(o.mapping=Wi),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===qo||a===Yo)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Il(c.height);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function NA(n){let e=[],t=[],i=[],r=n,s=n-Us+1+Gg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Us?c=Gg[o-n+Us-1]:o===0&&(c=0),i.push(c);let l=1/(a-2),u=-l,d=1+l,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,y=3,g=2,m=1,x=new Float32Array(y*p*f),v=new Float32Array(g*p*f),w=new Float32Array(m*p*f);for(let C=0;C<f;C++){let R=C%3*2/3-1,F=C>2?0:-1,A=[R,F,0,R+2/3,F,0,R+2/3,F+1,0,R,F,0,R+2/3,F+1,0,R,F+1,0];x.set(A,y*p*C),v.set(h,g*p*C);let S=[C,C,C,C,C,C];w.set(S,m*p*C)}let N=new et;N.setAttribute("position",new ot(x,y)),N.setAttribute("uv",new ot(v,g)),N.setAttribute("faceIndex",new ot(w,m)),e.push(N),r>Us&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function qg(n,e,t){let i=new hn(n,e,t);return i.texture.mapping=Js,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Gc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function FA(n,e,t){let i=new Float32Array(Tr),r=new D(0,1,0);return new pn({name:"SphericalGaussianBlur",defines:{n:Tr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Pp(),fragmentShader:`
1
+ "use strict";var WorldOrbitEditor=(()=>{var ed=Object.defineProperty;var fx=Object.getOwnPropertyDescriptor;var px=Object.getOwnPropertyNames;var mx=Object.prototype.hasOwnProperty;var gx=(n,e)=>()=>(n&&(e=n(n=0)),e);var qp=(n,e)=>{for(var t in e)ed(n,t,{get:e[t],enumerable:!0})},yx=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of px(e))!mx.call(n,r)&&r!==t&&ed(n,r,{get:()=>e[r],enumerable:!(i=fx(e,r))||i.enumerable});return n};var vx=n=>yx(ed({},"__esModule",{value:!0}),n);var Rv={};qp(Rv,{ACESFilmicToneMapping:()=>N0,AddEquation:()=>ji,AddOperation:()=>L0,AdditiveAnimationBlendMode:()=>Ip,AdditiveBlending:()=>wh,AgXToneMapping:()=>k0,AlphaFormat:()=>j0,AlwaysCompare:()=>cv,AlwaysDepth:()=>E0,AlwaysStencilFunc:()=>Kh,AmbientLight:()=>Tu,AnimationAction:()=>Fu,AnimationClip:()=>Xr,AnimationLoader:()=>Cf,AnimationMixer:()=>Wf,AnimationObjectGroup:()=>Gf,AnimationUtils:()=>n2,ArcCurve:()=>Gl,ArrayCamera:()=>Pl,ArrowHelper:()=>pp,AttachedBindMode:()=>Eh,Audio:()=>Uu,AudioAnalyser:()=>Hf,AudioContext:()=>Oa,AudioListener:()=>Vf,AudioLoader:()=>Bf,AxesHelper:()=>mp,BackSide:()=>nn,BasicDepthPacking:()=>Q0,BasicShadowMap:()=>OM,BatchedMesh:()=>zl,Bone:()=>ma,BooleanKeyframeTrack:()=>wi,Box2:()=>tp,Box3:()=>Bt,Box3Helper:()=>hp,BoxGeometry:()=>kr,BoxHelper:()=>dp,BufferAttribute:()=>ot,BufferGeometry:()=>et,BufferGeometryLoader:()=>Du,ByteType:()=>V0,Cache:()=>mi,Camera:()=>Gs,CameraHelper:()=>up,CanvasTexture:()=>Sf,CapsuleGeometry:()=>Jl,CatmullRomCurve3:()=>Wl,CineonToneMapping:()=>U0,CircleGeometry:()=>Kl,ClampToEdgeWrapping:()=>Sn,Clock:()=>Ou,Color:()=>Ie,ColorKeyframeTrack:()=>Ra,ColorManagement:()=>dt,CompressedArrayTexture:()=>wf,CompressedCubeTexture:()=>Mf,CompressedTexture:()=>Ys,CompressedTextureLoader:()=>Rf,ConeGeometry:()=>Ql,ConstantAlphaFactor:()=>w0,ConstantColorFactor:()=>b0,CubeCamera:()=>Cl,CubeReflectionMapping:()=>bi,CubeRefractionMapping:()=>Wi,CubeTexture:()=>Br,CubeTextureLoader:()=>Pf,CubeUVReflectionMapping:()=>Ks,CubicBezierCurve:()=>ya,CubicBezierCurve3:()=>Xl,CubicInterpolant:()=>bu,CullFaceBack:()=>_h,CullFaceFront:()=>r0,CullFaceFrontBack:()=>DM,CullFaceNone:()=>i0,Curve:()=>mn,CurvePath:()=>Zl,CustomBlending:()=>o0,CustomToneMapping:()=>F0,CylinderGeometry:()=>Js,Cylindrical:()=>ep,Data3DTexture:()=>aa,DataArrayTexture:()=>$s,DataTexture:()=>Wn,DataTextureLoader:()=>Lf,DataUtils:()=>VS,DecrementStencilOp:()=>GM,DecrementWrapStencilOp:()=>XM,DefaultLoadingManager:()=>Iv,DepthFormat:()=>Ur,DepthStencilFormat:()=>zs,DepthTexture:()=>da,DetachedBindMode:()=>z0,DirectionalLight:()=>Au,DirectionalLightHelper:()=>lp,DiscreteInterpolant:()=>_u,DisplayP3ColorSpace:()=>zu,DodecahedronGeometry:()=>eu,DoubleSide:()=>Hn,DstAlphaFactor:()=>m0,DstColorFactor:()=>y0,DynamicCopyUsage:()=>cS,DynamicDrawUsage:()=>nS,DynamicReadUsage:()=>sS,EdgesGeometry:()=>tu,EllipseCurve:()=>Zs,EqualCompare:()=>rv,EqualDepth:()=>T0,EqualStencilFunc:()=>JM,EquirectangularReflectionMapping:()=>qo,EquirectangularRefractionMapping:()=>Yo,Euler:()=>fn,EventDispatcher:()=>Un,ExtrudeGeometry:()=>nu,FileLoader:()=>Nn,Float16BufferAttribute:()=>cf,Float32BufferAttribute:()=>De,FloatType:()=>En,Fog:()=>Dl,FogExp2:()=>Ll,FramebufferTexture:()=>_f,FrontSide:()=>xi,Frustum:()=>zr,GLBufferAttribute:()=>Zf,GLSL1:()=>uS,GLSL3:()=>Qh,GreaterCompare:()=>sv,GreaterDepth:()=>C0,GreaterEqualCompare:()=>av,GreaterEqualDepth:()=>I0,GreaterEqualStencilFunc:()=>tS,GreaterStencilFunc:()=>QM,GridHelper:()=>ap,Group:()=>Gi,HalfFloatType:()=>Na,HemisphereLight:()=>Mu,HemisphereLightHelper:()=>op,IcosahedronGeometry:()=>iu,ImageBitmapLoader:()=>kf,ImageLoader:()=>qr,ImageUtils:()=>Tl,IncrementStencilOp:()=>jM,IncrementWrapStencilOp:()=>WM,InstancedBufferAttribute:()=>qi,InstancedBufferGeometry:()=>Lu,InstancedInterleavedBuffer:()=>Yf,InstancedMesh:()=>Bl,Int16BufferAttribute:()=>of,Int32BufferAttribute:()=>af,Int8BufferAttribute:()=>nf,IntType:()=>_p,InterleavedBuffer:()=>qs,InterleavedBufferAttribute:()=>Vr,Interpolant:()=>jr,InterpolateDiscrete:()=>Ko,InterpolateLinear:()=>Qo,InterpolateSmooth:()=>Sl,InvertStencilOp:()=>qM,KeepStencilOp:()=>Ir,KeyframeTrack:()=>gn,LOD:()=>Nl,LatheGeometry:()=>wa,Layers:()=>Hs,LessCompare:()=>iv,LessDepth:()=>A0,LessEqualCompare:()=>Cp,LessEqualDepth:()=>Xo,LessEqualStencilFunc:()=>KM,LessStencilFunc:()=>ZM,Light:()=>Zn,LightProbe:()=>Ru,Line:()=>Yn,Line3:()=>np,LineBasicMaterial:()=>zt,LineCurve:()=>va,LineCurve3:()=>ql,LineDashedMaterial:()=>xu,LineLoop:()=>Hl,LineSegments:()=>An,LinearDisplayP3ColorSpace:()=>Fa,LinearFilter:()=>It,LinearInterpolant:()=>Ca,LinearMipMapLinearFilter:()=>kM,LinearMipMapNearestFilter:()=>FM,LinearMipmapLinearFilter:()=>jn,LinearMipmapNearestFilter:()=>$o,LinearSRGBColorSpace:()=>Si,LinearToneMapping:()=>D0,LinearTransfer:()=>ta,Loader:()=>Jt,LoaderUtils:()=>Da,LoadingManager:()=>Pa,LoopOnce:()=>Z0,LoopPingPong:()=>K0,LoopRepeat:()=>J0,LuminanceAlphaFormat:()=>X0,LuminanceFormat:()=>W0,MOUSE:()=>PM,Material:()=>Ft,MaterialLoader:()=>Pu,MathUtils:()=>TS,Matrix3:()=>Ze,Matrix4:()=>Ve,MaxEquation:()=>u0,Mesh:()=>St,MeshBasicMaterial:()=>qn,MeshDepthMaterial:()=>ha,MeshDistanceMaterial:()=>fa,MeshLambertMaterial:()=>yu,MeshMatcapMaterial:()=>vu,MeshNormalMaterial:()=>gu,MeshPhongMaterial:()=>pu,MeshPhysicalMaterial:()=>fu,MeshStandardMaterial:()=>Ia,MeshToonMaterial:()=>mu,MinEquation:()=>l0,MirroredRepeatWrapping:()=>Jo,MixOperation:()=>P0,MultiplyBlending:()=>Sh,MultiplyOperation:()=>Ua,NearestFilter:()=>Ut,NearestMipMapLinearFilter:()=>NM,NearestMipMapNearestFilter:()=>UM,NearestMipmapLinearFilter:()=>Os,NearestMipmapNearestFilter:()=>xp,NeutralToneMapping:()=>B0,NeverCompare:()=>nv,NeverDepth:()=>S0,NeverStencilFunc:()=>YM,NoBlending:()=>gi,NoColorSpace:()=>di,NoToneMapping:()=>yi,NormalAnimationBlendMode:()=>Bu,NormalBlending:()=>Or,NotEqualCompare:()=>ov,NotEqualDepth:()=>R0,NotEqualStencilFunc:()=>eS,NumberKeyframeTrack:()=>Gr,Object3D:()=>ct,ObjectLoader:()=>Ff,ObjectSpaceNormalMap:()=>tv,OctahedronGeometry:()=>Aa,OneFactor:()=>h0,OneMinusConstantAlphaFactor:()=>M0,OneMinusConstantColorFactor:()=>_0,OneMinusDstAlphaFactor:()=>g0,OneMinusDstColorFactor:()=>v0,OneMinusSrcAlphaFactor:()=>Al,OneMinusSrcColorFactor:()=>p0,OrthographicCamera:()=>Xs,P3Primaries:()=>ia,PCFShadowMap:()=>vp,PCFSoftShadowMap:()=>s0,PMREMGenerator:()=>ua,Path:()=>$r,PerspectiveCamera:()=>Rt,Plane:()=>$n,PlaneGeometry:()=>Ws,PlaneHelper:()=>fp,PointLight:()=>Eu,PointLightHelper:()=>sp,Points:()=>jl,PointsMaterial:()=>ga,PolarGridHelper:()=>cp,PolyhedronGeometry:()=>Yi,PositionalAudio:()=>$f,PropertyBinding:()=>ut,PropertyMixer:()=>Nu,QuadraticBezierCurve:()=>xa,QuadraticBezierCurve3:()=>ba,Quaternion:()=>Zt,QuaternionKeyframeTrack:()=>Zi,QuaternionLinearInterpolant:()=>wu,RED_GREEN_RGTC2_Format:()=>Zh,RED_RGTC1_Format:()=>Y0,REVISION:()=>RM,RGBADepthPacking:()=>ev,RGBAFormat:()=>un,RGBAIntegerFormat:()=>Tp,RGBA_ASTC_10x10_Format:()=>jh,RGBA_ASTC_10x5_Format:()=>Vh,RGBA_ASTC_10x6_Format:()=>$h,RGBA_ASTC_10x8_Format:()=>Hh,RGBA_ASTC_12x10_Format:()=>Gh,RGBA_ASTC_12x12_Format:()=>Wh,RGBA_ASTC_4x4_Format:()=>Dh,RGBA_ASTC_5x4_Format:()=>Oh,RGBA_ASTC_5x5_Format:()=>Uh,RGBA_ASTC_6x5_Format:()=>Nh,RGBA_ASTC_6x6_Format:()=>Fh,RGBA_ASTC_8x5_Format:()=>kh,RGBA_ASTC_8x6_Format:()=>Bh,RGBA_ASTC_8x8_Format:()=>zh,RGBA_BPTC_Format:()=>Ml,RGBA_ETC2_EAC_Format:()=>Lh,RGBA_PVRTC_2BPPV1_Format:()=>Ch,RGBA_PVRTC_4BPPV1_Format:()=>Ih,RGBA_S3TC_DXT1_Format:()=>bl,RGBA_S3TC_DXT3_Format:()=>_l,RGBA_S3TC_DXT5_Format:()=>wl,RGBFormat:()=>G0,RGB_BPTC_SIGNED_Format:()=>Xh,RGB_BPTC_UNSIGNED_Format:()=>qh,RGB_ETC1_Format:()=>Rh,RGB_ETC2_Format:()=>Ph,RGB_PVRTC_2BPPV1_Format:()=>Th,RGB_PVRTC_4BPPV1_Format:()=>Ah,RGB_S3TC_DXT1_Format:()=>xl,RGFormat:()=>q0,RGIntegerFormat:()=>Ap,RawShaderMaterial:()=>hu,Ray:()=>Xi,Raycaster:()=>Jf,Rec709Primaries:()=>na,RectAreaLight:()=>Iu,RedFormat:()=>Sp,RedIntegerFormat:()=>Ep,ReinhardToneMapping:()=>O0,RenderTarget:()=>Il,RepeatWrapping:()=>Zo,ReplaceStencilOp:()=>HM,ReverseSubtractEquation:()=>c0,RingGeometry:()=>ru,SIGNED_RED_GREEN_RGTC2_Format:()=>Jh,SIGNED_RED_RGTC1_Format:()=>Yh,SRGBColorSpace:()=>Mn,SRGBTransfer:()=>yt,Scene:()=>Ol,ShaderChunk:()=>Ke,ShaderLib:()=>On,ShaderMaterial:()=>pn,ShadowMaterial:()=>du,Shape:()=>vi,ShapeGeometry:()=>su,ShapePath:()=>gp,ShapeUtils:()=>Xn,ShortType:()=>$0,Skeleton:()=>kl,SkeletonHelper:()=>rp,SkinnedMesh:()=>Fl,Source:()=>fi,Sphere:()=>Nt,SphereGeometry:()=>Ta,Spherical:()=>Qf,SphericalHarmonics3:()=>Cu,SplineCurve:()=>_a,SpotLight:()=>Su,SpotLightHelper:()=>ip,Sprite:()=>Ul,SpriteMaterial:()=>pa,SrcAlphaFactor:()=>El,SrcAlphaSaturateFactor:()=>x0,SrcColorFactor:()=>f0,StaticCopyUsage:()=>aS,StaticDrawUsage:()=>ra,StaticReadUsage:()=>rS,StereoCamera:()=>zf,StreamCopyUsage:()=>lS,StreamDrawUsage:()=>iS,StreamReadUsage:()=>oS,StringKeyframeTrack:()=>Mi,SubtractEquation:()=>a0,SubtractiveBlending:()=>Mh,TOUCH:()=>LM,TangentSpaceNormalMap:()=>Ji,TetrahedronGeometry:()=>ou,Texture:()=>Ct,TextureLoader:()=>Df,TorusGeometry:()=>au,TorusKnotGeometry:()=>cu,Triangle:()=>pi,TriangleFanDrawMode:()=>VM,TriangleStripDrawMode:()=>zM,TrianglesDrawMode:()=>BM,TubeGeometry:()=>lu,UVMapping:()=>ku,Uint16BufferAttribute:()=>ca,Uint32BufferAttribute:()=>la,Uint8BufferAttribute:()=>rf,Uint8ClampedBufferAttribute:()=>sf,Uniform:()=>Xf,UniformsGroup:()=>qf,UniformsLib:()=>Ee,UniformsUtils:()=>pv,UnsignedByteType:()=>_i,UnsignedInt248Type:()=>Qs,UnsignedInt5999Type:()=>H0,UnsignedIntType:()=>Fr,UnsignedShort4444Type:()=>wp,UnsignedShort5551Type:()=>Mp,UnsignedShortType:()=>bp,VSMShadowMap:()=>Vn,Vector2:()=>se,Vector3:()=>D,Vector4:()=>ht,VectorKeyframeTrack:()=>Wr,VideoTexture:()=>bf,WebGL3DRenderTarget:()=>tf,WebGLArrayRenderTarget:()=>ef,WebGLCoordinateSystem:()=>Gn,WebGLCubeRenderTarget:()=>Rl,WebGLMultipleRenderTargets:()=>yp,WebGLRenderTarget:()=>hn,WebGLRenderer:()=>yf,WebGLUtils:()=>_v,WebGPUCoordinateSystem:()=>sa,WireframeGeometry:()=>uu,WrapAroundEnding:()=>ea,ZeroCurvatureEnding:()=>Pr,ZeroFactor:()=>d0,ZeroSlopeEnding:()=>Lr,ZeroStencilOp:()=>$M,createCanvasElement:()=>uv});function dn(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xt[n&255]+Xt[n>>8&255]+Xt[n>>16&255]+Xt[n>>24&255]+"-"+Xt[e&255]+Xt[e>>8&255]+"-"+Xt[e>>16&15|64]+Xt[e>>24&255]+"-"+Xt[t&63|128]+Xt[t>>8&255]+"-"+Xt[t>>16&255]+Xt[t>>24&255]+Xt[i&255]+Xt[i>>8&255]+Xt[i>>16&255]+Xt[i>>24&255]).toLowerCase()}function Mt(n,e,t){return Math.max(e,Math.min(t,n))}function Rp(n,e){return(n%e+e)%e}function dS(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function hS(n,e,t){return n!==e?(t-n)/(e-n):0}function Ho(n,e,t){return(1-t)*n+t*e}function fS(n,e,t,i){return Ho(n,e,1-Math.exp(-t*i))}function pS(n,e=1){return e-Math.abs(Rp(n,e*2)-e)}function mS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function gS(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function yS(n,e){return n+Math.floor(Math.random()*(e-n+1))}function vS(n,e){return n+Math.random()*(e-n)}function xS(n){return n*(.5-Math.random())}function bS(n){n!==void 0&&(Eg=n);let e=Eg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function _S(n){return n*Nr}function wS(n){return n*Vs}function MS(n){return(n&n-1)===0&&n!==0}function SS(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function ES(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function AS(n,e,t,i,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+i)/2),u=o((e+i)/2),d=s((e-i)/2),h=o((e-i)/2),f=s((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":n.set(a*u,c*d,c*h,a*l);break;case"YZY":n.set(c*h,a*u,c*d,a*l);break;case"ZXZ":n.set(c*d,c*h,a*u,a*l);break;case"XZX":n.set(a*u,c*p,c*f,a*l);break;case"YXY":n.set(c*f,a*u,c*p,a*l);break;case"ZYZ":n.set(c*p,c*f,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function tn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Je(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}function lv(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Us(n,e){return new IS[n](e)}function oa(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function uv(){let n=oa("canvas");return n.style.display="block",n}function dv(n){n in Ag||(Ag[n]=!0,console.warn(n))}function ks(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function kd(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}function Bd(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Tl.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}function Vd(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){yr.fromArray(n,s);let a=r.x*Math.abs(yr.x)+r.y*Math.abs(yr.y)+r.z*Math.abs(yr.z),c=e.dot(yr),l=t.dot(yr),u=i.dot(yr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}function Jd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}function zS(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function sn(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Mt(n,-65504,65504),hi.floatView[0]=n;let e=hi.uint32View[0],t=e>>23&511;return hi.baseTable[t]+((e&8388607)>>hi.shiftTable[t])}function zo(n){let e=n>>10;return hi.uint32View[0]=hi.mantissaTable[hi.offsetTable[e]+(n&1023)]+hi.exponentTable[e],hi.floatView[0]}function HS(n,e,t,i,r,s,o,a){let c;if(e.side===nn?c=i.intersectTriangle(o,s,r,!0,a):c=i.intersectTriangle(r,s,o,e.side===xi,a),c===null)return null;Hc.copy(a),Hc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Hc);return l<t.near||l>t.far?null:{distance:l,point:Hc.clone(),object:n}}function jc(n,e,t,i,r,s,o,a,c,l){n.getVertexPosition(a,ws),n.getVertexPosition(c,Ms),n.getVertexPosition(l,Ss);let u=HS(n,e,t,i,ws,Ms,Ss,$c);if(u){r&&(Bc.fromBufferAttribute(r,a),zc.fromBufferAttribute(r,c),Vc.fromBufferAttribute(r,l),u.uv=pi.getInterpolation($c,ws,Ms,Ss,Bc,zc,Vc,new se)),s&&(Bc.fromBufferAttribute(s,a),zc.fromBufferAttribute(s,c),Vc.fromBufferAttribute(s,l),u.uv1=pi.getInterpolation($c,ws,Ms,Ss,Bc,zc,Vc,new se)),o&&(zg.fromBufferAttribute(o,a),Vg.fromBufferAttribute(o,c),$g.fromBufferAttribute(o,l),u.normal=pi.getInterpolation($c,ws,Ms,Ss,zg,Vg,$g,new D),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new D,materialIndex:0};pi.getNormal(ws,Ms,Ss,d.normal),u.face=d}return u}function js(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function en(n){let e={};for(let t=0;t<n.length;t++){let i=js(n[t]);for(let r in i)e[r]=i[r]}return e}function jS(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function fv(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:dt.workingColorSpace}function mv(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function YS(n){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,d=l.byteLength,h=n.createBuffer();n.bindBuffer(c,h),n.bufferData(c,l,u),a.onUploadCallback();let f;if(l instanceof Float32Array)f=n.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=n.SHORT;else if(l instanceof Uint32Array)f=n.UNSIGNED_INT;else if(l instanceof Int32Array)f=n.INT;else if(l instanceof Int8Array)f=n.BYTE;else if(l instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function i(a,c,l){let u=c.array,d=c._updateRange,h=c.updateRanges;if(n.bindBuffer(l,a),d.count===-1&&h.length===0&&n.bufferSubData(l,0,u),h.length!==0){for(let f=0,p=h.length;f<p;f++){let y=h[f];n.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}d.count!==-1&&(n.bufferSubData(l,d.offset*u.BYTES_PER_ELEMENT,u,d.offset,d.count),d.count=-1),c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(n.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}function RA(n,e,t,i,r,s,o){let a=new Ie(0),c=s===!0?0:1,l,u,d=null,h=0,f=null;function p(x){let v=x.isScene===!0?x.background:null;return v&&v.isTexture&&(v=(x.backgroundBlurriness>0?t:e).get(v)),v}function y(x){let v=!1,w=p(x);w===null?m(a,c):w&&w.isColor&&(m(w,1),v=!0);let N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil)}function g(x,v){let w=p(v);w&&(w.isCubeTexture||w.mapping===Ks)?(u===void 0&&(u=new St(new kr(1,1,1),new pn({name:"BackgroundCubeMaterial",uniforms:js(On.backgroundCube.uniforms),vertexShader:On.backgroundCube.vertexShader,fragmentShader:On.backgroundCube.fragmentShader,side:nn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(N,C,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),br.copy(v.backgroundRotation),br.x*=-1,br.y*=-1,br.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(br.y*=-1,br.z*=-1),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(CA.makeRotationFromEuler(br)),u.material.toneMapped=dt.getTransfer(w.colorSpace)!==yt,(d!==w||h!==w.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(l===void 0&&(l=new St(new Ws(2,2),new pn({name:"BackgroundMaterial",uniforms:js(On.background.uniforms),vertexShader:On.background.vertexShader,fragmentShader:On.background.fragmentShader,side:xi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=w,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=dt.getTransfer(w.colorSpace)!==yt,w.matrixAutoUpdate===!0&&w.updateMatrix(),l.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||h!==w.version||f!==n.toneMapping)&&(l.material.needsUpdate=!0,d=w,h=w.version,f=n.toneMapping),l.layers.enableAll(),x.unshift(l,l.geometry,l.material,0,0,null))}function m(x,v){x.getRGB(Wc,fv(n)),i.buffers.color.setClear(Wc.r,Wc.g,Wc.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(x,v=1){a.set(x),c=v,m(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,m(a,c)},render:y,addToRenderList:g}}function PA(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),s=r,o=!1;function a(S,P,k,O,H){let W=!1,J=d(O,k,P);s!==J&&(s=J,l(s.object)),W=f(S,O,k,H),W&&p(S,O,k,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,w(S,P,k,O),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function c(){return n.createVertexArray()}function l(S){return n.bindVertexArray(S)}function u(S){return n.deleteVertexArray(S)}function d(S,P,k){let O=k.wireframe===!0,H=i[S.id];H===void 0&&(H={},i[S.id]=H);let W=H[P.id];W===void 0&&(W={},H[P.id]=W);let J=W[O];return J===void 0&&(J=h(c()),W[O]=J),J}function h(S){let P=[],k=[],O=[];for(let H=0;H<t;H++)P[H]=0,k[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:k,attributeDivisors:O,object:S,attributes:{},index:null}}function f(S,P,k,O){let H=s.attributes,W=P.attributes,J=0,ae=k.getAttributes();for(let B in ae)if(ae[B].location>=0){let ce=H[B],Me=W[B];if(Me===void 0&&(B==="instanceMatrix"&&S.instanceMatrix&&(Me=S.instanceMatrix),B==="instanceColor"&&S.instanceColor&&(Me=S.instanceColor)),ce===void 0||ce.attribute!==Me||Me&&ce.data!==Me.data)return!0;J++}return s.attributesNum!==J||s.index!==O}function p(S,P,k,O){let H={},W=P.attributes,J=0,ae=k.getAttributes();for(let B in ae)if(ae[B].location>=0){let ce=W[B];ce===void 0&&(B==="instanceMatrix"&&S.instanceMatrix&&(ce=S.instanceMatrix),B==="instanceColor"&&S.instanceColor&&(ce=S.instanceColor));let Me={};Me.attribute=ce,ce&&ce.data&&(Me.data=ce.data),H[B]=Me,J++}s.attributes=H,s.attributesNum=J,s.index=O}function y(){let S=s.newAttributes;for(let P=0,k=S.length;P<k;P++)S[P]=0}function g(S){m(S,0)}function m(S,P){let k=s.newAttributes,O=s.enabledAttributes,H=s.attributeDivisors;k[S]=1,O[S]===0&&(n.enableVertexAttribArray(S),O[S]=1),H[S]!==P&&(n.vertexAttribDivisor(S,P),H[S]=P)}function x(){let S=s.newAttributes,P=s.enabledAttributes;for(let k=0,O=P.length;k<O;k++)P[k]!==S[k]&&(n.disableVertexAttribArray(k),P[k]=0)}function v(S,P,k,O,H,W,J){J===!0?n.vertexAttribIPointer(S,P,k,H,W):n.vertexAttribPointer(S,P,k,O,H,W)}function w(S,P,k,O){y();let H=O.attributes,W=k.getAttributes(),J=P.defaultAttributeValues;for(let ae in W){let B=W[ae];if(B.location>=0){let ne=H[ae];if(ne===void 0&&(ae==="instanceMatrix"&&S.instanceMatrix&&(ne=S.instanceMatrix),ae==="instanceColor"&&S.instanceColor&&(ne=S.instanceColor)),ne!==void 0){let ce=ne.normalized,Me=ne.itemSize,fe=e.get(ne);if(fe===void 0)continue;let $e=fe.buffer,Y=fe.type,me=fe.bytesPerElement,te=Y===n.INT||Y===n.UNSIGNED_INT||ne.gpuType===_p;if(ne.isInterleavedBufferAttribute){let ue=ne.data,Pe=ue.stride,_e=ne.offset;if(ue.isInstancedInterleavedBuffer){for(let z=0;z<B.locationSize;z++)m(B.location+z,ue.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let z=0;z<B.locationSize;z++)g(B.location+z);n.bindBuffer(n.ARRAY_BUFFER,$e);for(let z=0;z<B.locationSize;z++)v(B.location+z,Me/B.locationSize,Y,ce,Pe*me,(_e+Me/B.locationSize*z)*me,te)}else{if(ne.isInstancedBufferAttribute){for(let ue=0;ue<B.locationSize;ue++)m(B.location+ue,ne.meshPerAttribute);S.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let ue=0;ue<B.locationSize;ue++)g(B.location+ue);n.bindBuffer(n.ARRAY_BUFFER,$e);for(let ue=0;ue<B.locationSize;ue++)v(B.location+ue,Me/B.locationSize,Y,ce,Me*me,Me/B.locationSize*ue*me,te)}}else if(J!==void 0){let ce=J[ae];if(ce!==void 0)switch(ce.length){case 2:n.vertexAttrib2fv(B.location,ce);break;case 3:n.vertexAttrib3fv(B.location,ce);break;case 4:n.vertexAttrib4fv(B.location,ce);break;default:n.vertexAttrib1fv(B.location,ce)}}}}x()}function N(){F();for(let S in i){let P=i[S];for(let k in P){let O=P[k];for(let H in O)u(O[H].object),delete O[H];delete P[k]}delete i[S]}}function C(S){if(i[S.id]===void 0)return;let P=i[S.id];for(let k in P){let O=P[k];for(let H in O)u(O[H].object),delete O[H];delete P[k]}delete i[S.id]}function R(S){for(let P in i){let k=i[P];if(k[S.id]===void 0)continue;let O=k[S.id];for(let H in O)u(O[H].object),delete O[H];delete k[S.id]}}function F(){A(),o=!0,s!==r&&(s=r,l(s.object))}function A(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:F,resetDefaultState:A,dispose:N,releaseStatesOfGeometry:C,releaseStatesOfProgram:R,initAttributes:y,enableAttribute:g,disableUnusedAttributes:x}}function LA(n,e,t){let i;function r(l){i=l}function s(l,u){n.drawArrays(i,l,u),t.update(u,i,1)}function o(l,u,d){d!==0&&(n.drawArraysInstanced(i,l,u,d),t.update(u,i,d))}function a(l,u,d){if(d===0)return;let h=e.get("WEBGL_multi_draw");if(h===null)for(let f=0;f<d;f++)this.render(l[f],u[f]);else{h.multiDrawArraysWEBGL(i,l,0,u,0,d);let f=0;for(let p=0;p<d;p++)f+=u[p];t.update(f,i,1)}}function c(l,u,d,h){if(d===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<l.length;p++)o(l[p],u[p],h[p]);else{f.multiDrawArraysInstancedWEBGL(i,l,0,u,0,h,0,d);let p=0;for(let y=0;y<d;y++)p+=u[y];for(let y=0;y<h.length;y++)t.update(p,i,h[y])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function DA(n,e,t,i){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let C=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(C){return!(C!==un&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let R=C===Na&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==_i&&i.convert(C)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==En&&!R)}function c(C){if(C==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let d=t.logarithmicDepthBuffer===!0,h=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),m=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),x=n.getParameter(n.MAX_VARYING_VECTORS),v=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),w=f>0,N=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:y,maxAttributes:g,maxVertexUniforms:m,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:w,maxSamples:N}}function OA(n){let e=this,t=null,i=0,r=!1,s=!1,o=new $n,a=new Ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||i!==0||r;return r=h,i=d.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let p=d.clippingPlanes,y=d.clipIntersection,g=d.clipShadows,m=n.get(d);if(!r||p===null||p.length===0||s&&!g)s?u(null):l();else{let x=s?0:i,v=x*4,w=m.clippingState||null;c.value=w,w=u(p,h,v,f);for(let N=0;N!==v;++N)w[N]=t[N];m.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=x}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){let y=d!==null?d.length:0,g=null;if(y!==0){if(g=c.value,p!==!0||g===null){let m=f+y*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(g===null||g.length<m)&&(g=new Float32Array(m));for(let v=0,w=f;v!==y;++v,w+=4)o.copy(d[v]).applyMatrix4(x,a),o.normal.toArray(g,w),g[w+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}function UA(n){let e=new WeakMap;function t(o,a){return a===qo?o.mapping=bi:a===Yo&&(o.mapping=Wi),o}function i(o){if(o&&o.isTexture){let a=o.mapping;if(a===qo||a===Yo)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Rl(c.height);return l.fromEquirectangularTexture(n,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}function NA(n){let e=[],t=[],i=[],r=n,s=n-Ns+1+Gg.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>n-Ns?c=Gg[o-n+Ns-1]:o===0&&(c=0),i.push(c);let l=1/(a-2),u=-l,d=1+l,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,y=3,g=2,m=1,x=new Float32Array(y*p*f),v=new Float32Array(g*p*f),w=new Float32Array(m*p*f);for(let C=0;C<f;C++){let R=C%3*2/3-1,F=C>2?0:-1,A=[R,F,0,R+2/3,F,0,R+2/3,F+1,0,R,F,0,R+2/3,F+1,0,R,F+1,0];x.set(A,y*p*C),v.set(h,g*p*C);let S=[C,C,C,C,C,C];w.set(S,m*p*C)}let N=new et;N.setAttribute("position",new ot(x,y)),N.setAttribute("uv",new ot(v,g)),N.setAttribute("faceIndex",new ot(w,m)),e.push(N),r>Ns&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function qg(n,e,t){let i=new hn(n,e,t);return i.texture.mapping=Ks,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Xc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function FA(n,e,t){let i=new Float32Array(Rr),r=new D(0,1,0);return new pn({name:"SphericalGaussianBlur",defines:{n:Rr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Pp(),fragmentShader:`
2
2
 
3
3
  precision mediump float;
4
4
  precision mediump int;
@@ -148,9 +148,9 @@
148
148
  gl_Position = vec4( position, 1.0 );
149
149
 
150
150
  }
151
- `}function kA(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let c=a.mapping,l=c===qo||c===Yo,u=c===bi||c===Wi;if(l||u){let d=e.get(a),h=d!==void 0?d.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new ua(n)),d=l?t.fromEquirectangular(a,d):t.fromCubemap(a,d),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),d.texture;if(d!==void 0)return d.texture;{let f=a.image;return l&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new ua(n)),d=l?t.fromEquirectangular(a):t.fromCubemap(a),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),a.addEventListener("dispose",s),d.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function BA(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function zA(n,e,t,i){let r={},s=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let p in h.attributes)e.remove(h.attributes[p]);for(let p in h.morphAttributes){let y=h.morphAttributes[p];for(let g=0,m=y.length;g<m;g++)e.remove(y[g])}h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return r[h.id]===!0||(h.addEventListener("dispose",o),r[h.id]=!0,t.memory.geometries++),h}function c(d){let h=d.attributes;for(let p in h)e.update(h[p],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let p in f){let y=f[p];for(let g=0,m=y.length;g<m;g++)e.update(y[g],n.ARRAY_BUFFER)}}function l(d){let h=[],f=d.index,p=d.attributes.position,y=0;if(f!==null){let x=f.array;y=f.version;for(let v=0,w=x.length;v<w;v+=3){let N=x[v+0],C=x[v+1],R=x[v+2];h.push(N,C,C,R,R,N)}}else if(p!==void 0){let x=p.array;y=p.version;for(let v=0,w=x.length/3-1;v<w;v+=3){let N=v+0,C=v+1,R=v+2;h.push(N,C,C,R,R,N)}}else return;let g=new(lv(h)?la:ca)(h,1);g.version=y;let m=s.get(d);m&&e.remove(m),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&l(d)}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function VA(n,e,t){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,f){n.drawElements(i,f,s,h*o),t.update(f,i,1)}function l(h,f,p){p!==0&&(n.drawElementsInstanced(i,f,s,h*o,p),t.update(f,i,p))}function u(h,f,p){if(p===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<p;g++)this.render(h[g]/o,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];t.update(g,i,1)}}function d(h,f,p,y){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<h.length;m++)l(h[m]/o,f[m],y[m]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,p);let m=0;for(let x=0;x<p;x++)m+=f[x];for(let x=0;x<y.length;x++)t.update(m,i,y[x])}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function $A(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function HA(n,e,t){let i=new WeakMap,r=new ht;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let S=function(){F.dispose(),i.delete(a),a.removeEventListener("dispose",S)};var f=S;h!==void 0&&h.texture.dispose();let p=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],x=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],w=0;p===!0&&(w=1),y===!0&&(w=2),g===!0&&(w=3);let N=a.attributes.position.count*w,C=1;N>e.maxTextureSize&&(C=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);let R=new Float32Array(N*C*4*d),F=new Vs(R,N,C,d);F.type=Sn,F.needsUpdate=!0;let A=w*4;for(let P=0;P<d;P++){let k=m[P],O=x[P],H=v[P],W=N*C*4*P;for(let J=0;J<k.count;J++){let ae=J*A;p===!0&&(r.fromBufferAttribute(k,J),R[W+ae+0]=r.x,R[W+ae+1]=r.y,R[W+ae+2]=r.z,R[W+ae+3]=0),y===!0&&(r.fromBufferAttribute(O,J),R[W+ae+4]=r.x,R[W+ae+5]=r.y,R[W+ae+6]=r.z,R[W+ae+7]=0),g===!0&&(r.fromBufferAttribute(H,J),R[W+ae+8]=r.x,R[W+ae+9]=r.y,R[W+ae+10]=r.z,R[W+ae+11]=H.itemSize===4?r.w:1)}}h={count:d,texture:F,size:new se(N,C)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let g=0;g<l.length;g++)p+=l[g];let y=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(n,"morphTargetBaseInfluence",y),c.getUniforms().setValue(n,"morphTargetInfluences",l)}c.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function jA(n,e,t,i){let r=new WeakMap;function s(c){let l=i.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==l&&(e.update(d),r.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let h=c.skeleton;r.get(h)!==l&&(h.update(),r.set(h,l))}return d}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}function Qs(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Jg[r];if(s===void 0&&(s=new Float32Array(r),Jg[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Pt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Lt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Bu(n,e){let t=Kg[e];t===void 0&&(t=new Int32Array(e),Kg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function GA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function WA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2fv(this.addr,e),Lt(t,e)}}function XA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Pt(t,e))return;n.uniform3fv(this.addr,e),Lt(t,e)}}function qA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4fv(this.addr,e),Lt(t,e)}}function YA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;ty.set(i),n.uniformMatrix2fv(this.addr,!1,ty),Lt(t,i)}}function ZA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;ey.set(i),n.uniformMatrix3fv(this.addr,!1,ey),Lt(t,i)}}function JA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;Qg.set(i),n.uniformMatrix4fv(this.addr,!1,Qg),Lt(t,i)}}function KA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function QA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2iv(this.addr,e),Lt(t,e)}}function eT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;n.uniform3iv(this.addr,e),Lt(t,e)}}function tT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4iv(this.addr,e),Lt(t,e)}}function nT(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function iT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2uiv(this.addr,e),Lt(t,e)}}function rT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;n.uniform3uiv(this.addr,e),Lt(t,e)}}function sT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4uiv(this.addr,e),Lt(t,e)}}function oT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?yv:gv;t.setTexture2D(e||s,r)}function aT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||xv,r)}function cT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||bv,r)}function lT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||vv,r)}function uT(n){switch(n){case 5126:return GA;case 35664:return WA;case 35665:return XA;case 35666:return qA;case 35674:return YA;case 35675:return ZA;case 35676:return JA;case 5124:case 35670:return KA;case 35667:case 35671:return QA;case 35668:case 35672:return eT;case 35669:case 35673:return tT;case 5125:return nT;case 36294:return iT;case 36295:return rT;case 36296:return sT;case 35678:case 36198:case 36298:case 36306:case 35682:return oT;case 35679:case 36299:case 36307:return aT;case 35680:case 36300:case 36308:case 36293:return cT;case 36289:case 36303:case 36311:case 36292:return lT}}function dT(n,e){n.uniform1fv(this.addr,e)}function hT(n,e){let t=Qs(e,this.size,2);n.uniform2fv(this.addr,t)}function fT(n,e){let t=Qs(e,this.size,3);n.uniform3fv(this.addr,t)}function pT(n,e){let t=Qs(e,this.size,4);n.uniform4fv(this.addr,t)}function mT(n,e){let t=Qs(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function gT(n,e){let t=Qs(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function yT(n,e){let t=Qs(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function vT(n,e){n.uniform1iv(this.addr,e)}function xT(n,e){n.uniform2iv(this.addr,e)}function bT(n,e){n.uniform3iv(this.addr,e)}function _T(n,e){n.uniform4iv(this.addr,e)}function wT(n,e){n.uniform1uiv(this.addr,e)}function MT(n,e){n.uniform2uiv(this.addr,e)}function ST(n,e){n.uniform3uiv(this.addr,e)}function ET(n,e){n.uniform4uiv(this.addr,e)}function AT(n,e,t){let i=this.cache,r=e.length,s=Bu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||gv,s[o])}function TT(n,e,t){let i=this.cache,r=e.length,s=Bu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||xv,s[o])}function IT(n,e,t){let i=this.cache,r=e.length,s=Bu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||bv,s[o])}function CT(n,e,t){let i=this.cache,r=e.length,s=Bu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||vv,s[o])}function RT(n){switch(n){case 5126:return dT;case 35664:return hT;case 35665:return fT;case 35666:return pT;case 35674:return mT;case 35675:return gT;case 35676:return yT;case 5124:case 35670:return vT;case 35667:case 35671:return xT;case 35668:case 35672:return bT;case 35669:case 35673:return _T;case 5125:return wT;case 36294:return MT;case 36295:return ST;case 36296:return ET;case 35678:case 36198:case 36298:case 36306:case 35682:return AT;case 35679:case 36299:case 36307:return TT;case 35680:case 36300:case 36308:case 36293:return IT;case 36289:case 36303:case 36311:case 36292:return CT}}function ny(n,e){n.seq.push(e),n.map[e.id]=e}function PT(n,e,t){let i=n.name,r=i.length;for(oh.lastIndex=0;;){let s=oh.exec(i),o=oh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){ny(t,l===void 0?new lf(a,n,e):new uf(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new df(a),ny(t,d)),t=d}}}function iy(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function OT(n,e){let t=n.split(`
151
+ `}function kA(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let c=a.mapping,l=c===qo||c===Yo,u=c===bi||c===Wi;if(l||u){let d=e.get(a),h=d!==void 0?d.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==h)return t===null&&(t=new ua(n)),d=l?t.fromEquirectangular(a,d):t.fromCubemap(a,d),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),d.texture;if(d!==void 0)return d.texture;{let f=a.image;return l&&f&&f.height>0||u&&f&&r(f)?(t===null&&(t=new ua(n)),d=l?t.fromEquirectangular(a):t.fromCubemap(a),d.texture.pmremVersion=a.pmremVersion,e.set(a,d),a.addEventListener("dispose",s),d.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function BA(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function zA(n,e,t,i){let r={},s=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let p in h.attributes)e.remove(h.attributes[p]);for(let p in h.morphAttributes){let y=h.morphAttributes[p];for(let g=0,m=y.length;g<m;g++)e.remove(y[g])}h.removeEventListener("dispose",o),delete r[h.id];let f=s.get(h);f&&(e.remove(f),s.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return r[h.id]===!0||(h.addEventListener("dispose",o),r[h.id]=!0,t.memory.geometries++),h}function c(d){let h=d.attributes;for(let p in h)e.update(h[p],n.ARRAY_BUFFER);let f=d.morphAttributes;for(let p in f){let y=f[p];for(let g=0,m=y.length;g<m;g++)e.update(y[g],n.ARRAY_BUFFER)}}function l(d){let h=[],f=d.index,p=d.attributes.position,y=0;if(f!==null){let x=f.array;y=f.version;for(let v=0,w=x.length;v<w;v+=3){let N=x[v+0],C=x[v+1],R=x[v+2];h.push(N,C,C,R,R,N)}}else if(p!==void 0){let x=p.array;y=p.version;for(let v=0,w=x.length/3-1;v<w;v+=3){let N=v+0,C=v+1,R=v+2;h.push(N,C,C,R,R,N)}}else return;let g=new(lv(h)?la:ca)(h,1);g.version=y;let m=s.get(d);m&&e.remove(m),s.set(d,g)}function u(d){let h=s.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&l(d)}else l(d);return s.get(d)}return{get:a,update:c,getWireframeAttribute:u}}function VA(n,e,t){let i;function r(h){i=h}let s,o;function a(h){s=h.type,o=h.bytesPerElement}function c(h,f){n.drawElements(i,f,s,h*o),t.update(f,i,1)}function l(h,f,p){p!==0&&(n.drawElementsInstanced(i,f,s,h*o,p),t.update(f,i,p))}function u(h,f,p){if(p===0)return;let y=e.get("WEBGL_multi_draw");if(y===null)for(let g=0;g<p;g++)this.render(h[g]/o,f[g]);else{y.multiDrawElementsWEBGL(i,f,0,s,h,0,p);let g=0;for(let m=0;m<p;m++)g+=f[m];t.update(g,i,1)}}function d(h,f,p,y){if(p===0)return;let g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<h.length;m++)l(h[m]/o,f[m],y[m]);else{g.multiDrawElementsInstancedWEBGL(i,f,0,s,h,0,y,0,p);let m=0;for(let x=0;x<p;x++)m+=f[x];for(let x=0;x<y.length;x++)t.update(m,i,y[x])}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function $A(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,o,a){switch(t.calls++,o){case n.TRIANGLES:t.triangles+=a*(s/3);break;case n.LINES:t.lines+=a*(s/2);break;case n.LINE_STRIP:t.lines+=a*(s-1);break;case n.LINE_LOOP:t.lines+=a*s;break;case n.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function HA(n,e,t){let i=new WeakMap,r=new ht;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=i.get(a);if(h===void 0||h.count!==d){let S=function(){F.dispose(),i.delete(a),a.removeEventListener("dispose",S)};var f=S;h!==void 0&&h.texture.dispose();let p=a.morphAttributes.position!==void 0,y=a.morphAttributes.normal!==void 0,g=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],x=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],w=0;p===!0&&(w=1),y===!0&&(w=2),g===!0&&(w=3);let N=a.attributes.position.count*w,C=1;N>e.maxTextureSize&&(C=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);let R=new Float32Array(N*C*4*d),F=new $s(R,N,C,d);F.type=En,F.needsUpdate=!0;let A=w*4;for(let P=0;P<d;P++){let k=m[P],O=x[P],H=v[P],W=N*C*4*P;for(let J=0;J<k.count;J++){let ae=J*A;p===!0&&(r.fromBufferAttribute(k,J),R[W+ae+0]=r.x,R[W+ae+1]=r.y,R[W+ae+2]=r.z,R[W+ae+3]=0),y===!0&&(r.fromBufferAttribute(O,J),R[W+ae+4]=r.x,R[W+ae+5]=r.y,R[W+ae+6]=r.z,R[W+ae+7]=0),g===!0&&(r.fromBufferAttribute(H,J),R[W+ae+8]=r.x,R[W+ae+9]=r.y,R[W+ae+10]=r.z,R[W+ae+11]=H.itemSize===4?r.w:1)}}h={count:d,texture:F,size:new se(N,C)},i.set(a,h),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",o.morphTexture,t);else{let p=0;for(let g=0;g<l.length;g++)p+=l[g];let y=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(n,"morphTargetBaseInfluence",y),c.getUniforms().setValue(n,"morphTargetInfluences",l)}c.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:s}}function jA(n,e,t,i){let r=new WeakMap;function s(c){let l=i.render.frame,u=c.geometry,d=e.get(c,u);if(r.get(d)!==l&&(e.update(d),r.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let h=c.skeleton;r.get(h)!==l&&(h.update(),r.set(h,l))}return d}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}function eo(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,s=Jg[r];if(s===void 0&&(s=new Float32Array(r),Jg[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Pt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Lt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Vu(n,e){let t=Kg[e];t===void 0&&(t=new Int32Array(e),Kg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function GA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function WA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2fv(this.addr,e),Lt(t,e)}}function XA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Pt(t,e))return;n.uniform3fv(this.addr,e),Lt(t,e)}}function qA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4fv(this.addr,e),Lt(t,e)}}function YA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;ty.set(i),n.uniformMatrix2fv(this.addr,!1,ty),Lt(t,i)}}function ZA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;ey.set(i),n.uniformMatrix3fv(this.addr,!1,ey),Lt(t,i)}}function JA(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Pt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Lt(t,e)}else{if(Pt(t,i))return;Qg.set(i),n.uniformMatrix4fv(this.addr,!1,Qg),Lt(t,i)}}function KA(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function QA(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2iv(this.addr,e),Lt(t,e)}}function eT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;n.uniform3iv(this.addr,e),Lt(t,e)}}function tT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4iv(this.addr,e),Lt(t,e)}}function nT(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function iT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Pt(t,e))return;n.uniform2uiv(this.addr,e),Lt(t,e)}}function rT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Pt(t,e))return;n.uniform3uiv(this.addr,e),Lt(t,e)}}function sT(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Pt(t,e))return;n.uniform4uiv(this.addr,e),Lt(t,e)}}function oT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s=this.type===n.SAMPLER_2D_SHADOW?yv:gv;t.setTexture2D(e||s,r)}function aT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||xv,r)}function cT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||bv,r)}function lT(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||vv,r)}function uT(n){switch(n){case 5126:return GA;case 35664:return WA;case 35665:return XA;case 35666:return qA;case 35674:return YA;case 35675:return ZA;case 35676:return JA;case 5124:case 35670:return KA;case 35667:case 35671:return QA;case 35668:case 35672:return eT;case 35669:case 35673:return tT;case 5125:return nT;case 36294:return iT;case 36295:return rT;case 36296:return sT;case 35678:case 36198:case 36298:case 36306:case 35682:return oT;case 35679:case 36299:case 36307:return aT;case 35680:case 36300:case 36308:case 36293:return cT;case 36289:case 36303:case 36311:case 36292:return lT}}function dT(n,e){n.uniform1fv(this.addr,e)}function hT(n,e){let t=eo(e,this.size,2);n.uniform2fv(this.addr,t)}function fT(n,e){let t=eo(e,this.size,3);n.uniform3fv(this.addr,t)}function pT(n,e){let t=eo(e,this.size,4);n.uniform4fv(this.addr,t)}function mT(n,e){let t=eo(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function gT(n,e){let t=eo(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function yT(n,e){let t=eo(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function vT(n,e){n.uniform1iv(this.addr,e)}function xT(n,e){n.uniform2iv(this.addr,e)}function bT(n,e){n.uniform3iv(this.addr,e)}function _T(n,e){n.uniform4iv(this.addr,e)}function wT(n,e){n.uniform1uiv(this.addr,e)}function MT(n,e){n.uniform2uiv(this.addr,e)}function ST(n,e){n.uniform3uiv(this.addr,e)}function ET(n,e){n.uniform4uiv(this.addr,e)}function AT(n,e,t){let i=this.cache,r=e.length,s=Vu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||gv,s[o])}function TT(n,e,t){let i=this.cache,r=e.length,s=Vu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||xv,s[o])}function IT(n,e,t){let i=this.cache,r=e.length,s=Vu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||bv,s[o])}function CT(n,e,t){let i=this.cache,r=e.length,s=Vu(t,r);Pt(i,s)||(n.uniform1iv(this.addr,s),Lt(i,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||vv,s[o])}function RT(n){switch(n){case 5126:return dT;case 35664:return hT;case 35665:return fT;case 35666:return pT;case 35674:return mT;case 35675:return gT;case 35676:return yT;case 5124:case 35670:return vT;case 35667:case 35671:return xT;case 35668:case 35672:return bT;case 35669:case 35673:return _T;case 5125:return wT;case 36294:return MT;case 36295:return ST;case 36296:return ET;case 35678:case 36198:case 36298:case 36306:case 35682:return AT;case 35679:case 36299:case 36307:return TT;case 35680:case 36300:case 36308:case 36293:return IT;case 36289:case 36303:case 36311:case 36292:return CT}}function ny(n,e){n.seq.push(e),n.map[e.id]=e}function PT(n,e,t){let i=n.name,r=i.length;for(oh.lastIndex=0;;){let s=oh.exec(i),o=oh.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){ny(t,l===void 0?new lf(a,n,e):new uf(a,n,e));break}else{let d=t.map[a];d===void 0&&(d=new df(a),ny(t,d)),t=d}}}function iy(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function OT(n,e){let t=n.split(`
152
152
  `),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;i.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return i.join(`
153
- `)}function UT(n){let e=dt.getPrimaries(dt.workingColorSpace),t=dt.getPrimaries(n),i;switch(e===t?i="":e===ia&&t===na?i="LinearDisplayP3ToLinearSRGB":e===na&&t===ia&&(i="LinearSRGBToLinearDisplayP3"),n){case Si:case Fa:return[i,"LinearTransferOETF"];case wn:case ku:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function ry(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
153
+ `)}function UT(n){let e=dt.getPrimaries(dt.workingColorSpace),t=dt.getPrimaries(n),i;switch(e===t?i="":e===ia&&t===na?i="LinearDisplayP3ToLinearSRGB":e===na&&t===ia&&(i="LinearSRGBToLinearDisplayP3"),n){case Si:case Fa:return[i,"LinearTransferOETF"];case Mn:case zu:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function ry(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
154
154
 
155
155
  `+r+`
156
156
 
@@ -176,7 +176,7 @@
176
176
  `;return n.precision==="highp"?e+=`
177
177
  #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
178
178
  #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
179
- #define LOW_PRECISION`),e}function WT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===vp?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===s0?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===zn&&(e="SHADOWMAP_TYPE_VSM"),e}function XT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case bi:case Wi:e="ENVMAP_TYPE_CUBE";break;case Js:e="ENVMAP_TYPE_CUBE_UV";break}return e}function qT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Wi&&(e="ENVMAP_MODE_REFRACTION"),e}function YT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Ua:e="ENVMAP_BLENDING_MULTIPLY";break;case P0:e="ENVMAP_BLENDING_MIX";break;case L0:e="ENVMAP_BLENDING_ADD";break}return e}function ZT(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function JT(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=WT(t),l=XT(t),u=qT(t),d=YT(t),h=ZT(t),f=kT(t),p=BT(s),y=r.createProgram(),g,m,x=t.glslVersion?"#version "+t.glslVersion+`
179
+ #define LOW_PRECISION`),e}function WT(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===vp?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===s0?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Vn&&(e="SHADOWMAP_TYPE_VSM"),e}function XT(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case bi:case Wi:e="ENVMAP_TYPE_CUBE";break;case Ks:e="ENVMAP_TYPE_CUBE_UV";break}return e}function qT(n){let e="ENVMAP_MODE_REFLECTION";return n.envMap&&n.envMapMode===Wi&&(e="ENVMAP_MODE_REFRACTION"),e}function YT(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case Ua:e="ENVMAP_BLENDING_MULTIPLY";break;case P0:e="ENVMAP_BLENDING_MIX";break;case L0:e="ENVMAP_BLENDING_ADD";break}return e}function ZT(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function JT(n,e,t,i){let r=n.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=WT(t),l=XT(t),u=qT(t),d=YT(t),h=ZT(t),f=kT(t),p=BT(s),y=r.createProgram(),g,m,x=t.glslVersion?"#version "+t.glslVersion+`
180
180
  `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Vo).join(`
181
181
  `),g.length>0&&(g+=`
182
182
  `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Vo).join(`
@@ -197,11 +197,11 @@ Material Type: `+P.type+`
197
197
 
198
198
  Program Info Log: `+k+`
199
199
  `+ae+`
200
- `+B)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||H==="")&&(J=!1);J&&(P.diagnostics={runnable:W,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:H,prefix:m}})}r.deleteShader(N),r.deleteShader(C),F=new ks(r,y),A=zT(r,y)}let F;this.getUniforms=function(){return F===void 0&&R(this),F};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let S=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=r.getProgramParameter(y,LT)),S},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=DT++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=C,this}function QT(n,e,t,i,r,s,o){let a=new $s,c=new ff,l=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(A){return l.add(A),A===0?"uv":`uv${A}`}function g(A,S,P,k,O){let H=k.fog,W=O.geometry,J=A.isMeshStandardMaterial?k.environment:null,ae=(A.isMeshStandardMaterial?t:e).get(A.envMap||J),B=ae&&ae.mapping===Js?ae.image.height:null,ne=p[A.type];A.precision!==null&&(f=r.getMaxPrecision(A.precision),f!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",f,"instead."));let ce=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Me=ce!==void 0?ce.length:0,fe=0;W.morphAttributes.position!==void 0&&(fe=1),W.morphAttributes.normal!==void 0&&(fe=2),W.morphAttributes.color!==void 0&&(fe=3);let $e,Y,me,te;if(ne){let rt=Dn[ne];$e=rt.vertexShader,Y=rt.fragmentShader}else $e=A.vertexShader,Y=A.fragmentShader,c.update(A),me=c.getVertexShaderID(A),te=c.getFragmentShaderID(A);let ue=n.getRenderTarget(),Pe=O.isInstancedMesh===!0,_e=O.isBatchedMesh===!0,z=!!A.map,Be=!!A.matcap,X=!!ae,de=!!A.aoMap,Z=!!A.lightMap,he=!!A.bumpMap,ie=!!A.normalMap,ye=!!A.displacementMap,Te=!!A.emissiveMap,U=!!A.metalnessMap,T=!!A.roughnessMap,G=A.anisotropy>0,ee=A.clearcoat>0,oe=A.dispersion>0,re=A.iridescence>0,Ue=A.sheen>0,ve=A.transmission>0,xe=G&&!!A.anisotropyMap,He=ee&&!!A.clearcoatMap,pe=ee&&!!A.clearcoatNormalMap,Oe=ee&&!!A.clearcoatRoughnessMap,qe=re&&!!A.iridescenceMap,Ne=re&&!!A.iridescenceThicknessMap,Ce=Ue&&!!A.sheenColorMap,Fe=Ue&&!!A.sheenRoughnessMap,Qe=!!A.specularMap,pt=!!A.specularColorMap,je=!!A.specularIntensityMap,V=ve&&!!A.transmissionMap,le=ve&&!!A.thicknessMap,K=!!A.gradientMap,we=!!A.alphaMap,Ae=A.alphaTest>0,Re=!!A.alphaHash,tt=!!A.extensions,ft=yi;A.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(ft=n.toneMapping);let vt={shaderID:ne,shaderType:A.type,shaderName:A.name,vertexShader:$e,fragmentShader:Y,defines:A.defines,customVertexShaderID:me,customFragmentShaderID:te,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:f,batching:_e,instancing:Pe,instancingColor:Pe&&O.instanceColor!==null,instancingMorph:Pe&&O.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ue===null?n.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Si,alphaToCoverage:!!A.alphaToCoverage,map:z,matcap:Be,envMap:X,envMapMode:X&&ae.mapping,envMapCubeUVHeight:B,aoMap:de,lightMap:Z,bumpMap:he,normalMap:ie,displacementMap:h&&ye,emissiveMap:Te,normalMapObjectSpace:ie&&A.normalMapType===tv,normalMapTangentSpace:ie&&A.normalMapType===Ji,metalnessMap:U,roughnessMap:T,anisotropy:G,anisotropyMap:xe,clearcoat:ee,clearcoatMap:He,clearcoatNormalMap:pe,clearcoatRoughnessMap:Oe,dispersion:oe,iridescence:re,iridescenceMap:qe,iridescenceThicknessMap:Ne,sheen:Ue,sheenColorMap:Ce,sheenRoughnessMap:Fe,specularMap:Qe,specularColorMap:pt,specularIntensityMap:je,transmission:ve,transmissionMap:V,thicknessMap:le,gradientMap:K,opaque:A.transparent===!1&&A.blending===Pr&&A.alphaToCoverage===!1,alphaMap:we,alphaTest:Ae,alphaHash:Re,combine:A.combine,mapUv:z&&y(A.map.channel),aoMapUv:de&&y(A.aoMap.channel),lightMapUv:Z&&y(A.lightMap.channel),bumpMapUv:he&&y(A.bumpMap.channel),normalMapUv:ie&&y(A.normalMap.channel),displacementMapUv:ye&&y(A.displacementMap.channel),emissiveMapUv:Te&&y(A.emissiveMap.channel),metalnessMapUv:U&&y(A.metalnessMap.channel),roughnessMapUv:T&&y(A.roughnessMap.channel),anisotropyMapUv:xe&&y(A.anisotropyMap.channel),clearcoatMapUv:He&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:pe&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Oe&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:qe&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ce&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(A.sheenRoughnessMap.channel),specularMapUv:Qe&&y(A.specularMap.channel),specularColorMapUv:pt&&y(A.specularColorMap.channel),specularIntensityMapUv:je&&y(A.specularIntensityMap.channel),transmissionMapUv:V&&y(A.transmissionMap.channel),thicknessMapUv:le&&y(A.thicknessMap.channel),alphaMapUv:we&&y(A.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||G),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!W.attributes.uv&&(z||we),fog:!!H,useFog:A.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:O.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:fe,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:n.shadowMap.enabled&&P.length>0,shadowMapType:n.shadowMap.type,toneMapping:ft,useLegacyLights:n._useLegacyLights,decodeVideoTexture:z&&A.map.isVideoTexture===!0&&dt.getTransfer(A.map.colorSpace)===yt,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===$n,flipSided:A.side===nn,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:tt&&A.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:tt&&A.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt}function m(A){let S=[];if(A.shaderID?S.push(A.shaderID):(S.push(A.customVertexShaderID),S.push(A.customFragmentShaderID)),A.defines!==void 0)for(let P in A.defines)S.push(P),S.push(A.defines[P]);return A.isRawShaderMaterial===!1&&(x(S,A),v(S,A),S.push(n.outputColorSpace)),S.push(A.customProgramCacheKey),S.join()}function x(A,S){A.push(S.precision),A.push(S.outputColorSpace),A.push(S.envMapMode),A.push(S.envMapCubeUVHeight),A.push(S.mapUv),A.push(S.alphaMapUv),A.push(S.lightMapUv),A.push(S.aoMapUv),A.push(S.bumpMapUv),A.push(S.normalMapUv),A.push(S.displacementMapUv),A.push(S.emissiveMapUv),A.push(S.metalnessMapUv),A.push(S.roughnessMapUv),A.push(S.anisotropyMapUv),A.push(S.clearcoatMapUv),A.push(S.clearcoatNormalMapUv),A.push(S.clearcoatRoughnessMapUv),A.push(S.iridescenceMapUv),A.push(S.iridescenceThicknessMapUv),A.push(S.sheenColorMapUv),A.push(S.sheenRoughnessMapUv),A.push(S.specularMapUv),A.push(S.specularColorMapUv),A.push(S.specularIntensityMapUv),A.push(S.transmissionMapUv),A.push(S.thicknessMapUv),A.push(S.combine),A.push(S.fogExp2),A.push(S.sizeAttenuation),A.push(S.morphTargetsCount),A.push(S.morphAttributeCount),A.push(S.numDirLights),A.push(S.numPointLights),A.push(S.numSpotLights),A.push(S.numSpotLightMaps),A.push(S.numHemiLights),A.push(S.numRectAreaLights),A.push(S.numDirLightShadows),A.push(S.numPointLightShadows),A.push(S.numSpotLightShadows),A.push(S.numSpotLightShadowsWithMaps),A.push(S.numLightProbes),A.push(S.shadowMapType),A.push(S.toneMapping),A.push(S.numClippingPlanes),A.push(S.numClipIntersection),A.push(S.depthPacking)}function v(A,S){a.disableAll(),S.supportsVertexTextures&&a.enable(0),S.instancing&&a.enable(1),S.instancingColor&&a.enable(2),S.instancingMorph&&a.enable(3),S.matcap&&a.enable(4),S.envMap&&a.enable(5),S.normalMapObjectSpace&&a.enable(6),S.normalMapTangentSpace&&a.enable(7),S.clearcoat&&a.enable(8),S.iridescence&&a.enable(9),S.alphaTest&&a.enable(10),S.vertexColors&&a.enable(11),S.vertexAlphas&&a.enable(12),S.vertexUv1s&&a.enable(13),S.vertexUv2s&&a.enable(14),S.vertexUv3s&&a.enable(15),S.vertexTangents&&a.enable(16),S.anisotropy&&a.enable(17),S.alphaHash&&a.enable(18),S.batching&&a.enable(19),S.dispersion&&a.enable(20),A.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.skinning&&a.enable(4),S.morphTargets&&a.enable(5),S.morphNormals&&a.enable(6),S.morphColors&&a.enable(7),S.premultipliedAlpha&&a.enable(8),S.shadowMapEnabled&&a.enable(9),S.useLegacyLights&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.transmission&&a.enable(15),S.sheen&&a.enable(16),S.opaque&&a.enable(17),S.pointsUvs&&a.enable(18),S.decodeVideoTexture&&a.enable(19),S.alphaToCoverage&&a.enable(20),A.push(a.mask)}function w(A){let S=p[A.type],P;if(S){let k=Dn[S];P=pv.clone(k.uniforms)}else P=A.uniforms;return P}function N(A,S){let P;for(let k=0,O=u.length;k<O;k++){let H=u[k];if(H.cacheKey===S){P=H,++P.usedTimes;break}}return P===void 0&&(P=new JT(n,S,A,s),u.push(P)),P}function C(A){if(--A.usedTimes===0){let S=u.indexOf(A);u[S]=u[u.length-1],u.pop(),A.destroy()}}function R(A){c.remove(A)}function F(){c.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:w,acquireProgram:N,releaseProgram:C,releaseShaderCache:R,programs:u,dispose:F}}function eI(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function tI(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ly(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function uy(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(d,h,f,p,y,g){let m=n[e];return m===void 0?(m={id:d.id,object:d,geometry:h,material:f,groupOrder:p,renderOrder:d.renderOrder,z:y,group:g},n[e]=m):(m.id=d.id,m.object=d,m.geometry=h,m.material=f,m.groupOrder=p,m.renderOrder=d.renderOrder,m.z=y,m.group=g),e++,m}function a(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.push(m):f.transparent===!0?r.push(m):t.push(m)}function c(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.unshift(m):f.transparent===!0?r.unshift(m):t.unshift(m)}function l(d,h){t.length>1&&t.sort(d||tI),i.length>1&&i.sort(h||ly),r.length>1&&r.sort(h||ly)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function nI(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new uy,n.set(i,[o])):r>=s.length?(o=new uy,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function iI(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new Ie};break;case"SpotLight":t={position:new D,direction:new D,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new D,halfWidth:new D,halfHeight:new D};break}return n[e.id]=t,t}}}function rI(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function oI(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function aI(n){let e=new iI,t=rI(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);let r=new D,s=new Ve,o=new Ve;function a(l,u){let d=0,h=0,f=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let p=0,y=0,g=0,m=0,x=0,v=0,w=0,N=0,C=0,R=0,F=0;l.sort(oI);let A=u===!0?Math.PI:1;for(let P=0,k=l.length;P<k;P++){let O=l[P],H=O.color,W=O.intensity,J=O.distance,ae=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)d+=H.r*W*A,h+=H.g*W*A,f+=H.b*W*A;else if(O.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(O.sh.coefficients[B],W);F++}else if(O.isDirectionalLight){let B=e.get(O);if(B.color.copy(O.color).multiplyScalar(O.intensity*A),O.castShadow){let ne=O.shadow,ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,i.directionalShadow[p]=ce,i.directionalShadowMap[p]=ae,i.directionalShadowMatrix[p]=O.shadow.matrix,v++}i.directional[p]=B,p++}else if(O.isSpotLight){let B=e.get(O);B.position.setFromMatrixPosition(O.matrixWorld),B.color.copy(H).multiplyScalar(W*A),B.distance=J,B.coneCos=Math.cos(O.angle),B.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),B.decay=O.decay,i.spot[g]=B;let ne=O.shadow;if(O.map&&(i.spotLightMap[C]=O.map,C++,ne.updateMatrices(O),O.castShadow&&R++),i.spotLightMatrix[g]=ne.matrix,O.castShadow){let ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,i.spotShadow[g]=ce,i.spotShadowMap[g]=ae,N++}g++}else if(O.isRectAreaLight){let B=e.get(O);B.color.copy(H).multiplyScalar(W),B.halfWidth.set(O.width*.5,0,0),B.halfHeight.set(0,O.height*.5,0),i.rectArea[m]=B,m++}else if(O.isPointLight){let B=e.get(O);if(B.color.copy(O.color).multiplyScalar(O.intensity*A),B.distance=O.distance,B.decay=O.decay,O.castShadow){let ne=O.shadow,ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,ce.shadowCameraNear=ne.camera.near,ce.shadowCameraFar=ne.camera.far,i.pointShadow[y]=ce,i.pointShadowMap[y]=ae,i.pointShadowMatrix[y]=O.shadow.matrix,w++}i.point[y]=B,y++}else if(O.isHemisphereLight){let B=e.get(O);B.skyColor.copy(O.color).multiplyScalar(W*A),B.groundColor.copy(O.groundColor).multiplyScalar(W*A),i.hemi[x]=B,x++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ee.LTC_FLOAT_1,i.rectAreaLTC2=Ee.LTC_FLOAT_2):(i.rectAreaLTC1=Ee.LTC_HALF_1,i.rectAreaLTC2=Ee.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let S=i.hash;(S.directionalLength!==p||S.pointLength!==y||S.spotLength!==g||S.rectAreaLength!==m||S.hemiLength!==x||S.numDirectionalShadows!==v||S.numPointShadows!==w||S.numSpotShadows!==N||S.numSpotMaps!==C||S.numLightProbes!==F)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=m,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=N,i.spotShadowMap.length=N,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=N+C-R,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=F,S.directionalLength=p,S.pointLength=y,S.spotLength=g,S.rectAreaLength=m,S.hemiLength=x,S.numDirectionalShadows=v,S.numPointShadows=w,S.numSpotShadows=N,S.numSpotMaps=C,S.numLightProbes=F,i.version=sI++)}function c(l,u){let d=0,h=0,f=0,p=0,y=0,g=u.matrixWorldInverse;for(let m=0,x=l.length;m<x;m++){let v=l[m];if(v.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(v.isSpotLight){let w=i.spot[f];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let w=i.rectArea[p];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(v.width*.5,0,0),w.halfHeight.set(0,v.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){let w=i.point[h];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let w=i.hemi[y];w.direction.setFromMatrixPosition(v.matrixWorld),w.direction.transformDirection(g),y++}}}return{setup:a,setupView:c,state:i}}function dy(n){let e=new aI(n),t=[],i=[];function r(u){l.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(u){e.setup(t,u)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function cI(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new dy(n),e.set(r,[a])):s>=o.length?(a=new dy(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function dI(n,e,t){let i=new Fr,r=new se,s=new se,o=new ht,a=new ha({depthPacking:ev}),c=new fa,l={},u=t.maxTextureSize,d={[xi]:nn,[nn]:xi,[$n]:$n},h=new pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new se},radius:{value:4}},vertexShader:lI,fragmentShader:uI}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new et;p.setAttribute("position",new ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new St(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vp;let m=this.type;this.render=function(C,R,F){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||C.length===0)return;let A=n.getRenderTarget(),S=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),k=n.state;k.setBlending(gi),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);let O=m!==zn&&this.type===zn,H=m===zn&&this.type!==zn;for(let W=0,J=C.length;W<J;W++){let ae=C[W],B=ae.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;r.copy(B.mapSize);let ne=B.getFrameExtents();if(r.multiply(ne),s.copy(B.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ne.x),r.x=s.x*ne.x,B.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ne.y),r.y=s.y*ne.y,B.mapSize.y=s.y)),B.map===null||O===!0||H===!0){let Me=this.type!==zn?{minFilter:Ut,magFilter:Ut}:{};B.map!==null&&B.map.dispose(),B.map=new hn(r.x,r.y,Me),B.map.texture.name=ae.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();let ce=B.getViewportCount();for(let Me=0;Me<ce;Me++){let fe=B.getViewport(Me);o.set(s.x*fe.x,s.y*fe.y,s.x*fe.z,s.y*fe.w),k.viewport(o),B.updateMatrices(ae,Me),i=B.getFrustum(),w(R,F,B.camera,ae,this.type)}B.isPointLightShadow!==!0&&this.type===zn&&x(B,F),B.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(A,S,P)};function x(C,R){let F=e.update(y);h.defines.VSM_SAMPLES!==C.blurSamples&&(h.defines.VSM_SAMPLES=C.blurSamples,f.defines.VSM_SAMPLES=C.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new hn(r.x,r.y)),h.uniforms.shadow_pass.value=C.map.texture,h.uniforms.resolution.value=C.mapSize,h.uniforms.radius.value=C.radius,n.setRenderTarget(C.mapPass),n.clear(),n.renderBufferDirect(R,null,F,h,y,null),f.uniforms.shadow_pass.value=C.mapPass.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,n.setRenderTarget(C.map),n.clear(),n.renderBufferDirect(R,null,F,f,y,null)}function v(C,R,F,A){let S=null,P=F.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(P!==void 0)S=P;else if(S=F.isPointLight===!0?c:a,n.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let k=S.uuid,O=R.uuid,H=l[k];H===void 0&&(H={},l[k]=H);let W=H[O];W===void 0&&(W=S.clone(),H[O]=W,R.addEventListener("dispose",N)),S=W}if(S.visible=R.visible,S.wireframe=R.wireframe,A===zn?S.side=R.shadowSide!==null?R.shadowSide:R.side:S.side=R.shadowSide!==null?R.shadowSide:d[R.side],S.alphaMap=R.alphaMap,S.alphaTest=R.alphaTest,S.map=R.map,S.clipShadows=R.clipShadows,S.clippingPlanes=R.clippingPlanes,S.clipIntersection=R.clipIntersection,S.displacementMap=R.displacementMap,S.displacementScale=R.displacementScale,S.displacementBias=R.displacementBias,S.wireframeLinewidth=R.wireframeLinewidth,S.linewidth=R.linewidth,F.isPointLight===!0&&S.isMeshDistanceMaterial===!0){let k=n.properties.get(S);k.light=F}return S}function w(C,R,F,A,S){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&S===zn)&&(!C.frustumCulled||i.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,C.matrixWorld);let O=e.update(C),H=C.material;if(Array.isArray(H)){let W=O.groups;for(let J=0,ae=W.length;J<ae;J++){let B=W[J],ne=H[B.materialIndex];if(ne&&ne.visible){let ce=v(C,ne,A,S);C.onBeforeShadow(n,C,R,F,O,ce,B),n.renderBufferDirect(F,null,O,ce,C,B),C.onAfterShadow(n,C,R,F,O,ce,B)}}}else if(H.visible){let W=v(C,H,A,S);C.onBeforeShadow(n,C,R,F,O,W,null),n.renderBufferDirect(F,null,O,W,C,null),C.onAfterShadow(n,C,R,F,O,W,null)}}let k=C.children;for(let O=0,H=k.length;O<H;O++)w(k[O],R,F,A,S)}function N(C){C.target.removeEventListener("dispose",N);for(let F in l){let A=l[F],S=C.target.uuid;S in A&&(A[S].dispose(),delete A[S])}}}function hI(n){function e(){let V=!1,le=new ht,K=null,we=new ht(0,0,0,0);return{setMask:function(Ae){K!==Ae&&!V&&(n.colorMask(Ae,Ae,Ae,Ae),K=Ae)},setLocked:function(Ae){V=Ae},setClear:function(Ae,Re,tt,ft,vt){vt===!0&&(Ae*=ft,Re*=ft,tt*=ft),le.set(Ae,Re,tt,ft),we.equals(le)===!1&&(n.clearColor(Ae,Re,tt,ft),we.copy(le))},reset:function(){V=!1,K=null,we.set(-1,0,0,0)}}}function t(){let V=!1,le=null,K=null,we=null;return{setTest:function(Ae){Ae?te(n.DEPTH_TEST):ue(n.DEPTH_TEST)},setMask:function(Ae){le!==Ae&&!V&&(n.depthMask(Ae),le=Ae)},setFunc:function(Ae){if(K!==Ae){switch(Ae){case S0:n.depthFunc(n.NEVER);break;case E0:n.depthFunc(n.ALWAYS);break;case A0:n.depthFunc(n.LESS);break;case Xo:n.depthFunc(n.LEQUAL);break;case T0:n.depthFunc(n.EQUAL);break;case I0:n.depthFunc(n.GEQUAL);break;case C0:n.depthFunc(n.GREATER);break;case R0:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}K=Ae}},setLocked:function(Ae){V=Ae},setClear:function(Ae){we!==Ae&&(n.clearDepth(Ae),we=Ae)},reset:function(){V=!1,le=null,K=null,we=null}}}function i(){let V=!1,le=null,K=null,we=null,Ae=null,Re=null,tt=null,ft=null,vt=null;return{setTest:function(rt){V||(rt?te(n.STENCIL_TEST):ue(n.STENCIL_TEST))},setMask:function(rt){le!==rt&&!V&&(n.stencilMask(rt),le=rt)},setFunc:function(rt,$t,Et){(K!==rt||we!==$t||Ae!==Et)&&(n.stencilFunc(rt,$t,Et),K=rt,we=$t,Ae=Et)},setOp:function(rt,$t,Et){(Re!==rt||tt!==$t||ft!==Et)&&(n.stencilOp(rt,$t,Et),Re=rt,tt=$t,ft=Et)},setLocked:function(rt){V=rt},setClear:function(rt){vt!==rt&&(n.clearStencil(rt),vt=rt)},reset:function(){V=!1,le=null,K=null,we=null,Ae=null,Re=null,tt=null,ft=null,vt=null}}}let r=new e,s=new t,o=new i,a=new WeakMap,c=new WeakMap,l={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,w=null,N=null,C=new Ie(0,0,0),R=0,F=!1,A=null,S=null,P=null,k=null,O=null,H=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,J=0,ae=n.getParameter(n.VERSION);ae.indexOf("WebGL")!==-1?(J=parseFloat(/^WebGL (\d)/.exec(ae)[1]),W=J>=1):ae.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),W=J>=2);let B=null,ne={},ce=n.getParameter(n.SCISSOR_BOX),Me=n.getParameter(n.VIEWPORT),fe=new ht().fromArray(ce),$e=new ht().fromArray(Me);function Y(V,le,K,we){let Ae=new Uint8Array(4),Re=n.createTexture();n.bindTexture(V,Re),n.texParameteri(V,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(V,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let tt=0;tt<K;tt++)V===n.TEXTURE_3D||V===n.TEXTURE_2D_ARRAY?n.texImage3D(le,0,n.RGBA,1,1,we,0,n.RGBA,n.UNSIGNED_BYTE,Ae):n.texImage2D(le+tt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ae);return Re}let me={};me[n.TEXTURE_2D]=Y(n.TEXTURE_2D,n.TEXTURE_2D,1),me[n.TEXTURE_CUBE_MAP]=Y(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[n.TEXTURE_2D_ARRAY]=Y(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),me[n.TEXTURE_3D]=Y(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),te(n.DEPTH_TEST),s.setFunc(Xo),he(!1),ie(_h),te(n.CULL_FACE),de(gi);function te(V){l[V]!==!0&&(n.enable(V),l[V]=!0)}function ue(V){l[V]!==!1&&(n.disable(V),l[V]=!1)}function Pe(V,le){return u[V]!==le?(n.bindFramebuffer(V,le),u[V]=le,V===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=le),V===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=le),!0):!1}function _e(V,le){let K=h,we=!1;if(V){K=d.get(le),K===void 0&&(K=[],d.set(le,K));let Ae=V.textures;if(K.length!==Ae.length||K[0]!==n.COLOR_ATTACHMENT0){for(let Re=0,tt=Ae.length;Re<tt;Re++)K[Re]=n.COLOR_ATTACHMENT0+Re;K.length=Ae.length,we=!0}}else K[0]!==n.BACK&&(K[0]=n.BACK,we=!0);we&&n.drawBuffers(K)}function z(V){return f!==V?(n.useProgram(V),f=V,!0):!1}let Be={[ji]:n.FUNC_ADD,[a0]:n.FUNC_SUBTRACT,[c0]:n.FUNC_REVERSE_SUBTRACT};Be[l0]=n.MIN,Be[u0]=n.MAX;let X={[d0]:n.ZERO,[h0]:n.ONE,[f0]:n.SRC_COLOR,[Ml]:n.SRC_ALPHA,[x0]:n.SRC_ALPHA_SATURATE,[y0]:n.DST_COLOR,[m0]:n.DST_ALPHA,[p0]:n.ONE_MINUS_SRC_COLOR,[Sl]:n.ONE_MINUS_SRC_ALPHA,[v0]:n.ONE_MINUS_DST_COLOR,[g0]:n.ONE_MINUS_DST_ALPHA,[b0]:n.CONSTANT_COLOR,[_0]:n.ONE_MINUS_CONSTANT_COLOR,[w0]:n.CONSTANT_ALPHA,[M0]:n.ONE_MINUS_CONSTANT_ALPHA};function de(V,le,K,we,Ae,Re,tt,ft,vt,rt){if(V===gi){p===!0&&(ue(n.BLEND),p=!1);return}if(p===!1&&(te(n.BLEND),p=!0),V!==o0){if(V!==y||rt!==F){if((g!==ji||v!==ji)&&(n.blendEquation(n.FUNC_ADD),g=ji,v=ji),rt)switch(V){case Pr:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.ONE,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}else switch(V){case Pr:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}m=null,x=null,w=null,N=null,C.set(0,0,0),R=0,y=V,F=rt}return}Ae=Ae||le,Re=Re||K,tt=tt||we,(le!==g||Ae!==v)&&(n.blendEquationSeparate(Be[le],Be[Ae]),g=le,v=Ae),(K!==m||we!==x||Re!==w||tt!==N)&&(n.blendFuncSeparate(X[K],X[we],X[Re],X[tt]),m=K,x=we,w=Re,N=tt),(ft.equals(C)===!1||vt!==R)&&(n.blendColor(ft.r,ft.g,ft.b,vt),C.copy(ft),R=vt),y=V,F=!1}function Z(V,le){V.side===$n?ue(n.CULL_FACE):te(n.CULL_FACE);let K=V.side===nn;le&&(K=!K),he(K),V.blending===Pr&&V.transparent===!1?de(gi):de(V.blending,V.blendEquation,V.blendSrc,V.blendDst,V.blendEquationAlpha,V.blendSrcAlpha,V.blendDstAlpha,V.blendColor,V.blendAlpha,V.premultipliedAlpha),s.setFunc(V.depthFunc),s.setTest(V.depthTest),s.setMask(V.depthWrite),r.setMask(V.colorWrite);let we=V.stencilWrite;o.setTest(we),we&&(o.setMask(V.stencilWriteMask),o.setFunc(V.stencilFunc,V.stencilRef,V.stencilFuncMask),o.setOp(V.stencilFail,V.stencilZFail,V.stencilZPass)),Te(V.polygonOffset,V.polygonOffsetFactor,V.polygonOffsetUnits),V.alphaToCoverage===!0?te(n.SAMPLE_ALPHA_TO_COVERAGE):ue(n.SAMPLE_ALPHA_TO_COVERAGE)}function he(V){A!==V&&(V?n.frontFace(n.CW):n.frontFace(n.CCW),A=V)}function ie(V){V!==i0?(te(n.CULL_FACE),V!==S&&(V===_h?n.cullFace(n.BACK):V===r0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ue(n.CULL_FACE),S=V}function ye(V){V!==P&&(W&&n.lineWidth(V),P=V)}function Te(V,le,K){V?(te(n.POLYGON_OFFSET_FILL),(k!==le||O!==K)&&(n.polygonOffset(le,K),k=le,O=K)):ue(n.POLYGON_OFFSET_FILL)}function U(V){V?te(n.SCISSOR_TEST):ue(n.SCISSOR_TEST)}function T(V){V===void 0&&(V=n.TEXTURE0+H-1),B!==V&&(n.activeTexture(V),B=V)}function G(V,le,K){K===void 0&&(B===null?K=n.TEXTURE0+H-1:K=B);let we=ne[K];we===void 0&&(we={type:void 0,texture:void 0},ne[K]=we),(we.type!==V||we.texture!==le)&&(B!==K&&(n.activeTexture(K),B=K),n.bindTexture(V,le||me[V]),we.type=V,we.texture=le)}function ee(){let V=ne[B];V!==void 0&&V.type!==void 0&&(n.bindTexture(V.type,null),V.type=void 0,V.texture=void 0)}function oe(){try{n.compressedTexImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function re(){try{n.compressedTexImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ue(){try{n.texSubImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function ve(){try{n.texSubImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function xe(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function He(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Oe(){try{n.texStorage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function qe(){try{n.texImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ne(){try{n.texImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ce(V){fe.equals(V)===!1&&(n.scissor(V.x,V.y,V.z,V.w),fe.copy(V))}function Fe(V){$e.equals(V)===!1&&(n.viewport(V.x,V.y,V.z,V.w),$e.copy(V))}function Qe(V,le){let K=c.get(le);K===void 0&&(K=new WeakMap,c.set(le,K));let we=K.get(V);we===void 0&&(we=n.getUniformBlockIndex(le,V.name),K.set(V,we))}function pt(V,le){let we=c.get(le).get(V);a.get(le)!==we&&(n.uniformBlockBinding(le,we,V.__bindingPointIndex),a.set(le,we))}function je(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),l={},B=null,ne={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,w=null,N=null,C=new Ie(0,0,0),R=0,F=!1,A=null,S=null,P=null,k=null,O=null,fe.set(0,0,n.canvas.width,n.canvas.height),$e.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:te,disable:ue,bindFramebuffer:Pe,drawBuffers:_e,useProgram:z,setBlending:de,setMaterial:Z,setFlipSided:he,setCullFace:ie,setLineWidth:ye,setPolygonOffset:Te,setScissorTest:U,activeTexture:T,bindTexture:G,unbindTexture:ee,compressedTexImage2D:oe,compressedTexImage3D:re,texImage2D:qe,texImage3D:Ne,updateUBOMapping:Qe,uniformBlockBinding:pt,texStorage2D:pe,texStorage3D:Oe,texSubImage2D:Ue,texSubImage3D:ve,compressedTexSubImage2D:xe,compressedTexSubImage3D:He,scissor:Ce,viewport:Fe,reset:je}}function fI(n,e,t,i,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new se,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(U,T){return f?new OffscreenCanvas(U,T):oa("canvas")}function y(U,T,G){let ee=1,oe=Te(U);if((oe.width>G||oe.height>G)&&(ee=G/Math.max(oe.width,oe.height)),ee<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){let re=Math.floor(ee*oe.width),Ue=Math.floor(ee*oe.height);d===void 0&&(d=p(re,Ue));let ve=T?p(re,Ue):d;return ve.width=re,ve.height=Ue,ve.getContext("2d").drawImage(U,0,0,re,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+re+"x"+Ue+")."),ve}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),U;return U}function g(U){return U.generateMipmaps&&U.minFilter!==Ut&&U.minFilter!==It}function m(U){n.generateMipmap(U)}function x(U,T,G,ee,oe=!1){if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let re=T;if(T===n.RED&&(G===n.FLOAT&&(re=n.R32F),G===n.HALF_FLOAT&&(re=n.R16F),G===n.UNSIGNED_BYTE&&(re=n.R8)),T===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(re=n.R8UI),G===n.UNSIGNED_SHORT&&(re=n.R16UI),G===n.UNSIGNED_INT&&(re=n.R32UI),G===n.BYTE&&(re=n.R8I),G===n.SHORT&&(re=n.R16I),G===n.INT&&(re=n.R32I)),T===n.RG&&(G===n.FLOAT&&(re=n.RG32F),G===n.HALF_FLOAT&&(re=n.RG16F),G===n.UNSIGNED_BYTE&&(re=n.RG8)),T===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(re=n.RG8UI),G===n.UNSIGNED_SHORT&&(re=n.RG16UI),G===n.UNSIGNED_INT&&(re=n.RG32UI),G===n.BYTE&&(re=n.RG8I),G===n.SHORT&&(re=n.RG16I),G===n.INT&&(re=n.RG32I)),T===n.RGB&&G===n.UNSIGNED_INT_5_9_9_9_REV&&(re=n.RGB9_E5),T===n.RGBA){let Ue=oe?ta:dt.getTransfer(ee);G===n.FLOAT&&(re=n.RGBA32F),G===n.HALF_FLOAT&&(re=n.RGBA16F),G===n.UNSIGNED_BYTE&&(re=Ue===yt?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT_4_4_4_4&&(re=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(re=n.RGB5_A1)}return(re===n.R16F||re===n.R32F||re===n.RG16F||re===n.RG32F||re===n.RGBA16F||re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),re}function v(U,T){return g(U)===!0||U.isFramebufferTexture&&U.minFilter!==Ut&&U.minFilter!==It?Math.log2(Math.max(T.width,T.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?T.mipmaps.length:1}function w(U){let T=U.target;T.removeEventListener("dispose",w),C(T),T.isVideoTexture&&u.delete(T)}function N(U){let T=U.target;T.removeEventListener("dispose",N),F(T)}function C(U){let T=i.get(U);if(T.__webglInit===void 0)return;let G=U.source,ee=h.get(G);if(ee){let oe=ee[T.__cacheKey];oe.usedTimes--,oe.usedTimes===0&&R(U),Object.keys(ee).length===0&&h.delete(G)}i.remove(U)}function R(U){let T=i.get(U);n.deleteTexture(T.__webglTexture);let G=U.source,ee=h.get(G);delete ee[T.__cacheKey],o.memory.textures--}function F(U){let T=i.get(U);if(U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(T.__webglFramebuffer[ee]))for(let oe=0;oe<T.__webglFramebuffer[ee].length;oe++)n.deleteFramebuffer(T.__webglFramebuffer[ee][oe]);else n.deleteFramebuffer(T.__webglFramebuffer[ee]);T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer[ee])}else{if(Array.isArray(T.__webglFramebuffer))for(let ee=0;ee<T.__webglFramebuffer.length;ee++)n.deleteFramebuffer(T.__webglFramebuffer[ee]);else n.deleteFramebuffer(T.__webglFramebuffer);if(T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer),T.__webglMultisampledFramebuffer&&n.deleteFramebuffer(T.__webglMultisampledFramebuffer),T.__webglColorRenderbuffer)for(let ee=0;ee<T.__webglColorRenderbuffer.length;ee++)T.__webglColorRenderbuffer[ee]&&n.deleteRenderbuffer(T.__webglColorRenderbuffer[ee]);T.__webglDepthRenderbuffer&&n.deleteRenderbuffer(T.__webglDepthRenderbuffer)}let G=U.textures;for(let ee=0,oe=G.length;ee<oe;ee++){let re=i.get(G[ee]);re.__webglTexture&&(n.deleteTexture(re.__webglTexture),o.memory.textures--),i.remove(G[ee])}i.remove(U)}let A=0;function S(){A=0}function P(){let U=A;return U>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+r.maxTextures),A+=1,U}function k(U){let T=[];return T.push(U.wrapS),T.push(U.wrapT),T.push(U.wrapR||0),T.push(U.magFilter),T.push(U.minFilter),T.push(U.anisotropy),T.push(U.internalFormat),T.push(U.format),T.push(U.type),T.push(U.generateMipmaps),T.push(U.premultiplyAlpha),T.push(U.flipY),T.push(U.unpackAlignment),T.push(U.colorSpace),T.join()}function O(U,T){let G=i.get(U);if(U.isVideoTexture&&ie(U),U.isRenderTargetTexture===!1&&U.version>0&&G.__version!==U.version){let ee=U.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{fe(G,U,T);return}}t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+T)}function H(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){fe(G,U,T);return}t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+T)}function W(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){fe(G,U,T);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+T)}function J(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){$e(G,U,T);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+T)}let ae={[Zo]:n.REPEAT,[Mn]:n.CLAMP_TO_EDGE,[Jo]:n.MIRRORED_REPEAT},B={[Ut]:n.NEAREST,[xp]:n.NEAREST_MIPMAP_NEAREST,[Ds]:n.NEAREST_MIPMAP_LINEAR,[It]:n.LINEAR,[$o]:n.LINEAR_MIPMAP_NEAREST,[Hn]:n.LINEAR_MIPMAP_LINEAR},ne={[nv]:n.NEVER,[cv]:n.ALWAYS,[iv]:n.LESS,[Cp]:n.LEQUAL,[rv]:n.EQUAL,[av]:n.GEQUAL,[sv]:n.GREATER,[ov]:n.NOTEQUAL};function ce(U,T){if(T.type===Sn&&e.has("OES_texture_float_linear")===!1&&(T.magFilter===It||T.magFilter===$o||T.magFilter===Ds||T.magFilter===Hn||T.minFilter===It||T.minFilter===$o||T.minFilter===Ds||T.minFilter===Hn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(U,n.TEXTURE_WRAP_S,ae[T.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,ae[T.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,ae[T.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,B[T.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,B[T.minFilter]),T.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,ne[T.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(T.magFilter===Ut||T.minFilter!==Ds&&T.minFilter!==Hn||T.type===Sn&&e.has("OES_texture_float_linear")===!1)return;if(T.anisotropy>1||i.get(T).__currentAnisotropy){let G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(U,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(T.anisotropy,r.getMaxAnisotropy())),i.get(T).__currentAnisotropy=T.anisotropy}}}function Me(U,T){let G=!1;U.__webglInit===void 0&&(U.__webglInit=!0,T.addEventListener("dispose",w));let ee=T.source,oe=h.get(ee);oe===void 0&&(oe={},h.set(ee,oe));let re=k(T);if(re!==U.__cacheKey){oe[re]===void 0&&(oe[re]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,G=!0),oe[re].usedTimes++;let Ue=oe[U.__cacheKey];Ue!==void 0&&(oe[U.__cacheKey].usedTimes--,Ue.usedTimes===0&&R(T)),U.__cacheKey=re,U.__webglTexture=oe[re].texture}return G}function fe(U,T,G){let ee=n.TEXTURE_2D;(T.isDataArrayTexture||T.isCompressedArrayTexture)&&(ee=n.TEXTURE_2D_ARRAY),T.isData3DTexture&&(ee=n.TEXTURE_3D);let oe=Me(U,T),re=T.source;t.bindTexture(ee,U.__webglTexture,n.TEXTURE0+G);let Ue=i.get(re);if(re.version!==Ue.__version||oe===!0){t.activeTexture(n.TEXTURE0+G);let ve=dt.getPrimaries(dt.workingColorSpace),xe=T.colorSpace===di?null:dt.getPrimaries(T.colorSpace),He=T.colorSpace===di||ve===xe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,T.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,T.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);let pe=y(T.image,!1,r.maxTextureSize);pe=ye(T,pe);let Oe=s.convert(T.format,T.colorSpace),qe=s.convert(T.type),Ne=x(T.internalFormat,Oe,qe,T.colorSpace,T.isVideoTexture);ce(ee,T);let Ce,Fe=T.mipmaps,Qe=T.isVideoTexture!==!0,pt=Ue.__version===void 0||oe===!0,je=re.dataReady,V=v(T,pe);if(T.isDepthTexture)Ne=n.DEPTH_COMPONENT16,T.type===Sn?Ne=n.DEPTH_COMPONENT32F:T.type===Or?Ne=n.DEPTH_COMPONENT24:T.type===Ks&&(Ne=n.DEPTH24_STENCIL8),pt&&(Qe?t.texStorage2D(n.TEXTURE_2D,1,Ne,pe.width,pe.height):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,null));else if(T.isDataTexture)if(Fe.length>0){Qe&&pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,Fe[0].width,Fe[0].height);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,qe,Ce.data):t.texImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Oe,qe,Ce.data);T.generateMipmaps=!1}else Qe?(pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,pe.width,pe.height),je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,pe.width,pe.height,Oe,qe,pe.data)):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,pe.data);else if(T.isCompressedTexture)if(T.isCompressedArrayTexture){Qe&&pt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,V,Ne,Fe[0].width,Fe[0].height,pe.depth);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],T.format!==un?Oe!==null?Qe?je&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,Ce.width,Ce.height,pe.depth,Oe,Ce.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,le,Ne,Ce.width,Ce.height,pe.depth,0,Ce.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,Ce.width,Ce.height,pe.depth,Oe,qe,Ce.data):t.texImage3D(n.TEXTURE_2D_ARRAY,le,Ne,Ce.width,Ce.height,pe.depth,0,Oe,qe,Ce.data)}else{Qe&&pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,Fe[0].width,Fe[0].height);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],T.format!==un?Oe!==null?Qe?je&&t.compressedTexSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,Ce.data):t.compressedTexImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,qe,Ce.data):t.texImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Oe,qe,Ce.data)}else if(T.isDataArrayTexture)Qe?(pt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,V,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(T.isData3DTexture)Qe?(pt&&t.texStorage3D(n.TEXTURE_3D,V,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_3D,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(T.isFramebufferTexture){if(pt)if(Qe)t.texStorage2D(n.TEXTURE_2D,V,Ne,pe.width,pe.height);else{let le=pe.width,K=pe.height;for(let we=0;we<V;we++)t.texImage2D(n.TEXTURE_2D,we,Ne,le,K,0,Oe,qe,null),le>>=1,K>>=1}}else if(Fe.length>0){if(Qe&&pt){let le=Te(Fe[0]);t.texStorage2D(n.TEXTURE_2D,V,Ne,le.width,le.height)}for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Oe,qe,Ce):t.texImage2D(n.TEXTURE_2D,le,Ne,Oe,qe,Ce);T.generateMipmaps=!1}else if(Qe){if(pt){let le=Te(pe);t.texStorage2D(n.TEXTURE_2D,V,Ne,le.width,le.height)}je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Oe,qe,pe)}else t.texImage2D(n.TEXTURE_2D,0,Ne,Oe,qe,pe);g(T)&&m(ee),Ue.__version=re.version,T.onUpdate&&T.onUpdate(T)}U.__version=T.version}function $e(U,T,G){if(T.image.length!==6)return;let ee=Me(U,T),oe=T.source;t.bindTexture(n.TEXTURE_CUBE_MAP,U.__webglTexture,n.TEXTURE0+G);let re=i.get(oe);if(oe.version!==re.__version||ee===!0){t.activeTexture(n.TEXTURE0+G);let Ue=dt.getPrimaries(dt.workingColorSpace),ve=T.colorSpace===di?null:dt.getPrimaries(T.colorSpace),xe=T.colorSpace===di||Ue===ve?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,T.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,T.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let He=T.isCompressedTexture||T.image[0].isCompressedTexture,pe=T.image[0]&&T.image[0].isDataTexture,Oe=[];for(let K=0;K<6;K++)!He&&!pe?Oe[K]=y(T.image[K],!0,r.maxCubemapSize):Oe[K]=pe?T.image[K].image:T.image[K],Oe[K]=ye(T,Oe[K]);let qe=Oe[0],Ne=s.convert(T.format,T.colorSpace),Ce=s.convert(T.type),Fe=x(T.internalFormat,Ne,Ce,T.colorSpace),Qe=T.isVideoTexture!==!0,pt=re.__version===void 0||ee===!0,je=oe.dataReady,V=v(T,qe);ce(n.TEXTURE_CUBE_MAP,T);let le;if(He){Qe&&pt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,V,Fe,qe.width,qe.height);for(let K=0;K<6;K++){le=Oe[K].mipmaps;for(let we=0;we<le.length;we++){let Ae=le[we];T.format!==un?Ne!==null?Qe?je&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,0,0,Ae.width,Ae.height,Ne,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,Fe,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,0,0,Ae.width,Ae.height,Ne,Ce,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,Fe,Ae.width,Ae.height,0,Ne,Ce,Ae.data)}}}else{if(le=T.mipmaps,Qe&&pt){le.length>0&&V++;let K=Te(Oe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,V,Fe,K.width,K.height)}for(let K=0;K<6;K++)if(pe){Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Oe[K].width,Oe[K].height,Ne,Ce,Oe[K].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Fe,Oe[K].width,Oe[K].height,0,Ne,Ce,Oe[K].data);for(let we=0;we<le.length;we++){let Re=le[we].image[K].image;Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,0,0,Re.width,Re.height,Ne,Ce,Re.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,Fe,Re.width,Re.height,0,Ne,Ce,Re.data)}}else{Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Ne,Ce,Oe[K]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Fe,Ne,Ce,Oe[K]);for(let we=0;we<le.length;we++){let Ae=le[we];Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,0,0,Ne,Ce,Ae.image[K]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,Fe,Ne,Ce,Ae.image[K])}}}g(T)&&m(n.TEXTURE_CUBE_MAP),re.__version=oe.version,T.onUpdate&&T.onUpdate(T)}U.__version=T.version}function Y(U,T,G,ee,oe,re){let Ue=s.convert(G.format,G.colorSpace),ve=s.convert(G.type),xe=x(G.internalFormat,Ue,ve,G.colorSpace);if(!i.get(T).__hasExternalTextures){let pe=Math.max(1,T.width>>re),Oe=Math.max(1,T.height>>re);oe===n.TEXTURE_3D||oe===n.TEXTURE_2D_ARRAY?t.texImage3D(oe,re,xe,pe,Oe,T.depth,0,Ue,ve,null):t.texImage2D(oe,re,xe,pe,Oe,0,Ue,ve,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ee,oe,i.get(G).__webglTexture,0,Z(T)):(oe===n.TEXTURE_2D||oe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&oe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ee,oe,i.get(G).__webglTexture,re),t.bindFramebuffer(n.FRAMEBUFFER,null)}function me(U,T,G){if(n.bindRenderbuffer(n.RENDERBUFFER,U),T.depthBuffer&&!T.stencilBuffer){let ee=n.DEPTH_COMPONENT24;if(G||he(T)){let oe=T.depthTexture;oe&&oe.isDepthTexture&&(oe.type===Sn?ee=n.DEPTH_COMPONENT32F:oe.type===Or&&(ee=n.DEPTH_COMPONENT24));let re=Z(T);he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,ee,T.width,T.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,re,ee,T.width,T.height)}else n.renderbufferStorage(n.RENDERBUFFER,ee,T.width,T.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,U)}else if(T.depthBuffer&&T.stencilBuffer){let ee=Z(T);G&&he(T)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,T.width,T.height):he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,T.width,T.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,T.width,T.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,U)}else{let ee=T.textures;for(let oe=0;oe<ee.length;oe++){let re=ee[oe],Ue=s.convert(re.format,re.colorSpace),ve=s.convert(re.type),xe=x(re.internalFormat,Ue,ve,re.colorSpace),He=Z(T);G&&he(T)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,He,xe,T.width,T.height):he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,He,xe,T.width,T.height):n.renderbufferStorage(n.RENDERBUFFER,xe,T.width,T.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function te(U,T){if(T&&T.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,U),!(T.depthTexture&&T.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(T.depthTexture).__webglTexture||T.depthTexture.image.width!==T.width||T.depthTexture.image.height!==T.height)&&(T.depthTexture.image.width=T.width,T.depthTexture.image.height=T.height,T.depthTexture.needsUpdate=!0),O(T.depthTexture,0);let ee=i.get(T.depthTexture).__webglTexture,oe=Z(T);if(T.depthTexture.format===Lr)he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0);else if(T.depthTexture.format===Bs)he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0);else throw new Error("Unknown depthTexture format")}function ue(U){let T=i.get(U),G=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!T.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");te(T.__webglFramebuffer,U)}else if(G){T.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)t.bindFramebuffer(n.FRAMEBUFFER,T.__webglFramebuffer[ee]),T.__webglDepthbuffer[ee]=n.createRenderbuffer(),me(T.__webglDepthbuffer[ee],U,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,T.__webglFramebuffer),T.__webglDepthbuffer=n.createRenderbuffer(),me(T.__webglDepthbuffer,U,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Pe(U,T,G){let ee=i.get(U);T!==void 0&&Y(ee.__webglFramebuffer,U,U.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&ue(U)}function _e(U){let T=U.texture,G=i.get(U),ee=i.get(T);U.addEventListener("dispose",N);let oe=U.textures,re=U.isWebGLCubeRenderTarget===!0,Ue=oe.length>1;if(Ue||(ee.__webglTexture===void 0&&(ee.__webglTexture=n.createTexture()),ee.__version=T.version,o.memory.textures++),re){G.__webglFramebuffer=[];for(let ve=0;ve<6;ve++)if(T.mipmaps&&T.mipmaps.length>0){G.__webglFramebuffer[ve]=[];for(let xe=0;xe<T.mipmaps.length;xe++)G.__webglFramebuffer[ve][xe]=n.createFramebuffer()}else G.__webglFramebuffer[ve]=n.createFramebuffer()}else{if(T.mipmaps&&T.mipmaps.length>0){G.__webglFramebuffer=[];for(let ve=0;ve<T.mipmaps.length;ve++)G.__webglFramebuffer[ve]=n.createFramebuffer()}else G.__webglFramebuffer=n.createFramebuffer();if(Ue)for(let ve=0,xe=oe.length;ve<xe;ve++){let He=i.get(oe[ve]);He.__webglTexture===void 0&&(He.__webglTexture=n.createTexture(),o.memory.textures++)}if(U.samples>0&&he(U)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let ve=0;ve<oe.length;ve++){let xe=oe[ve];G.__webglColorRenderbuffer[ve]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[ve]);let He=s.convert(xe.format,xe.colorSpace),pe=s.convert(xe.type),Oe=x(xe.internalFormat,He,pe,xe.colorSpace,U.isXRRenderTarget===!0),qe=Z(U);n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,Oe,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ve,n.RENDERBUFFER,G.__webglColorRenderbuffer[ve])}n.bindRenderbuffer(n.RENDERBUFFER,null),U.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),me(G.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(re){t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture),ce(n.TEXTURE_CUBE_MAP,T);for(let ve=0;ve<6;ve++)if(T.mipmaps&&T.mipmaps.length>0)for(let xe=0;xe<T.mipmaps.length;xe++)Y(G.__webglFramebuffer[ve][xe],U,T,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,xe);else Y(G.__webglFramebuffer[ve],U,T,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0);g(T)&&m(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let ve=0,xe=oe.length;ve<xe;ve++){let He=oe[ve],pe=i.get(He);t.bindTexture(n.TEXTURE_2D,pe.__webglTexture),ce(n.TEXTURE_2D,He),Y(G.__webglFramebuffer,U,He,n.COLOR_ATTACHMENT0+ve,n.TEXTURE_2D,0),g(He)&&m(n.TEXTURE_2D)}t.unbindTexture()}else{let ve=n.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ve=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ve,ee.__webglTexture),ce(ve,T),T.mipmaps&&T.mipmaps.length>0)for(let xe=0;xe<T.mipmaps.length;xe++)Y(G.__webglFramebuffer[xe],U,T,n.COLOR_ATTACHMENT0,ve,xe);else Y(G.__webglFramebuffer,U,T,n.COLOR_ATTACHMENT0,ve,0);g(T)&&m(ve),t.unbindTexture()}U.depthBuffer&&ue(U)}function z(U){let T=U.textures;for(let G=0,ee=T.length;G<ee;G++){let oe=T[G];if(g(oe)){let re=U.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ue=i.get(oe).__webglTexture;t.bindTexture(re,Ue),m(re),t.unbindTexture()}}}let Be=[],X=[];function de(U){if(U.samples>0){if(he(U)===!1){let T=U.textures,G=U.width,ee=U.height,oe=n.COLOR_BUFFER_BIT,re=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ue=i.get(U),ve=T.length>1;if(ve)for(let xe=0;xe<T.length;xe++)t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let xe=0;xe<T.length;xe++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(oe|=n.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(oe|=n.STENCIL_BUFFER_BIT)),ve){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[xe]);let He=i.get(T[xe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,He,0)}n.blitFramebuffer(0,0,G,ee,0,0,G,ee,oe,n.NEAREST),c===!0&&(Be.length=0,X.length=0,Be.push(n.COLOR_ATTACHMENT0+xe),U.depthBuffer&&U.resolveDepthBuffer===!1&&(Be.push(re),X.push(re),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,X)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Be))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ve)for(let xe=0;xe<T.length;xe++){t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[xe]);let He=i.get(T[xe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.TEXTURE_2D,He,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){let T=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[T])}}}function Z(U){return Math.min(r.maxSamples,U.samples)}function he(U){let T=i.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&T.__useRenderToTexture!==!1}function ie(U){let T=o.render.frame;u.get(U)!==T&&(u.set(U,T),U.update())}function ye(U,T){let G=U.colorSpace,ee=U.format,oe=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||G!==Si&&G!==di&&(dt.getTransfer(G)===yt?(ee!==un||oe!==_i)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),T}function Te(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(l.width=U.naturalWidth||U.width,l.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(l.width=U.displayWidth,l.height=U.displayHeight):(l.width=U.width,l.height=U.height),l}this.allocateTextureUnit=P,this.resetTextureUnits=S,this.setTexture2D=O,this.setTexture2DArray=H,this.setTexture3D=W,this.setTextureCube=J,this.rebindTextures=Pe,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=ue,this.setupFrameBufferTexture=Y,this.useMultisampledRTT=he}function _v(n,e){function t(i,r=di){let s,o=dt.getTransfer(r);if(i===_i)return n.UNSIGNED_BYTE;if(i===wp)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Mp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===H0)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===V0)return n.BYTE;if(i===$0)return n.SHORT;if(i===bp)return n.UNSIGNED_SHORT;if(i===_p)return n.INT;if(i===Or)return n.UNSIGNED_INT;if(i===Sn)return n.FLOAT;if(i===Na)return n.HALF_FLOAT;if(i===j0)return n.ALPHA;if(i===G0)return n.RGB;if(i===un)return n.RGBA;if(i===W0)return n.LUMINANCE;if(i===X0)return n.LUMINANCE_ALPHA;if(i===Lr)return n.DEPTH_COMPONENT;if(i===Bs)return n.DEPTH_STENCIL;if(i===Sp)return n.RED;if(i===Ep)return n.RED_INTEGER;if(i===q0)return n.RG;if(i===Ap)return n.RG_INTEGER;if(i===Tp)return n.RGBA_INTEGER;if(i===yl||i===vl||i===xl||i===bl)if(o===yt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===yl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===xl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===bl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===yl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===vl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===xl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===bl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ah||i===Th||i===Ih||i===Ch)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Th)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Rh||i===Ph||i===Lh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Rh||i===Ph)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Lh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Dh||i===Oh||i===Uh||i===Nh||i===Fh||i===kh||i===Bh||i===zh||i===Vh||i===$h||i===Hh||i===jh||i===Gh||i===Wh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Dh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Oh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Uh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Nh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===_l||i===Xh||i===qh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===_l)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Xh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===qh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Y0||i===Yh||i===Zh||i===Jh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===_l)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Yh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Jh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ks?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function vI(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,fv(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,x,v,w){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),u(g,m)):m.isMeshStandardMaterial?(s(g,m),h(g,m),m.isMeshPhysicalMaterial&&f(g,m,w)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),y(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?c(g,m,x,v):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===nn&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===nn&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x=e.get(m),v=x.envMap,w=x.envMapRotation;if(v&&(g.envMap.value=v,vr.copy(w),vr.x*=-1,vr.y*=-1,vr.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(vr.y*=-1,vr.z*=-1),g.envMapRotation.value.setFromMatrix4(yI.makeRotationFromEuler(vr)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let N=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*N,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,x,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*x,g.scale.value=v*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function u(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,x){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===nn&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function y(g,m){let x=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function xI(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,v){let w=v.program;i.uniformBlockBinding(x,w)}function l(x,v){let w=r[x.id];w===void 0&&(p(x),w=u(x),r[x.id]=w,x.addEventListener("dispose",g));let N=v.program;i.updateUBOMapping(x,N);let C=e.render.frame;s[x.id]!==C&&(h(x),s[x.id]=C)}function u(x){let v=d();x.__bindingPointIndex=v;let w=n.createBuffer(),N=x.__size,C=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,w),n.bufferData(n.UNIFORM_BUFFER,N,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,w),w}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(x){let v=r[x.id],w=x.uniforms,N=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let C=0,R=w.length;C<R;C++){let F=Array.isArray(w[C])?w[C]:[w[C]];for(let A=0,S=F.length;A<S;A++){let P=F[A];if(f(P,C,A,N)===!0){let k=P.__offset,O=Array.isArray(P.value)?P.value:[P.value],H=0;for(let W=0;W<O.length;W++){let J=O[W],ae=y(J);typeof J=="number"||typeof J=="boolean"?(P.__data[0]=J,n.bufferSubData(n.UNIFORM_BUFFER,k+H,P.__data)):J.isMatrix3?(P.__data[0]=J.elements[0],P.__data[1]=J.elements[1],P.__data[2]=J.elements[2],P.__data[3]=0,P.__data[4]=J.elements[3],P.__data[5]=J.elements[4],P.__data[6]=J.elements[5],P.__data[7]=0,P.__data[8]=J.elements[6],P.__data[9]=J.elements[7],P.__data[10]=J.elements[8],P.__data[11]=0):(J.toArray(P.__data,H),H+=ae.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,P.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,v,w,N){let C=x.value,R=v+"_"+w;if(N[R]===void 0)return typeof C=="number"||typeof C=="boolean"?N[R]=C:N[R]=C.clone(),!0;{let F=N[R];if(typeof C=="number"||typeof C=="boolean"){if(F!==C)return N[R]=C,!0}else if(F.equals(C)===!1)return F.copy(C),!0}return!1}function p(x){let v=x.uniforms,w=0,N=16;for(let R=0,F=v.length;R<F;R++){let A=Array.isArray(v[R])?v[R]:[v[R]];for(let S=0,P=A.length;S<P;S++){let k=A[S],O=Array.isArray(k.value)?k.value:[k.value];for(let H=0,W=O.length;H<W;H++){let J=O[H],ae=y(J),B=w%N;B!==0&&N-B<ae.boundary&&(w+=N-B),k.__data=new Float32Array(ae.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=w,w+=ae.storage}}}let C=w%N;return C>0&&(w+=N-C),x.__size=w,x.__cache={},this}function y(x){let v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let w=o.indexOf(v.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function m(){for(let x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:l,dispose:m}}function qc(n,e,t,i,r,s){Rs.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Do.x=s*Rs.x-r*Rs.y,Do.y=r*Rs.x+s*Rs.y):Do.copy(Rs),n.copy(e),n.x+=Do.x,n.y+=Do.y,n.applyMatrix4(wv)}function MI(n,e){return n.z-e.z}function SI(n,e){return e.z-n.z}function AI(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function tl(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(Bl.fromBufferAttribute(o,r),zl.fromBufferAttribute(o,s),t.distanceSqToSegment(Bl,zl,hh,Ay)>i)return;hh.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(hh);if(!(c<e.near||c>e.far))return{distance:c,point:Ay.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function Ry(n,e,t,i,r,s,o){let a=xf.distanceSqToPoint(n);if(a<t){let c=new D;xf.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}function Lp(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,d){let h=(o-s)/l-(a-s)/(l+u)+(a-o)/u,f=(a-o)/u-(c-o)/(u+d)+(c-a)/d;h*=u,f*=u,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function Py(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function TI(n,e){let t=1-n;return t*t*e}function II(n,e){return 2*(1-n)*n*e}function CI(n,e){return n*n*e}function Go(n,e,t,i){return TI(n,e)+II(n,t)+CI(n,i)}function RI(n,e){let t=1-n;return t*t*t*e}function PI(n,e){let t=1-n;return 3*t*t*n*e}function LI(n,e){return 3*(1-n)*n*n*e}function DI(n,e){return n*n*n*e}function Wo(n,e,t,i,r){return RI(n,e)+PI(n,t)+LI(n,i)+DI(n,r)}function Mv(n,e,t,i,r){let s,o;if(r===ZI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=Ly(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=Ly(s,n[s],n[s+1],o);return o&&zu(o,o.next)&&(Ea(o),o=o.next),o}function zr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(zu(t,t.next)||bt(t.prev,t,t.next)===0)){if(Ea(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ma(n,e,t,i,r,s,o){if(!n)return;!o&&s&&jI(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?NI(n,i,r,s):UI(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Ea(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=FI(zr(n),e,t),Ma(n,e,t,i,r,s,2)):o===2&&kI(n,e,t,i,r,s):Ma(zr(n),e,t,i,r,s,1);break}}}function UI(n){let e=n.prev,t=n,i=n.next;if(bt(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<c?a<l?a:l:c<l?c:l,h=r>s?r>o?r:o:s>o?s:o,f=a>c?a>l?a:l:c>l?c:l,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Ns(r,a,s,c,o,l,p.x,p.y)&&bt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function NI(n,e,t,i){let r=n.prev,s=n,o=n.next;if(bt(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,d=s.y,h=o.y,f=a<c?a<l?a:l:c<l?c:l,p=u<d?u<h?u:h:d<h?d:h,y=a>c?a>l?a:l:c>l?c:l,g=u>d?u>h?u:h:d>h?d:h,m=Ef(f,p,e,t,i),x=Ef(y,g,e,t,i),v=n.prevZ,w=n.nextZ;for(;v&&v.z>=m&&w&&w.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Ns(a,u,c,d,l,h,v.x,v.y)&&bt(v.prev,v,v.next)>=0||(v=v.prevZ,w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Ns(a,u,c,d,l,h,w.x,w.y)&&bt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Ns(a,u,c,d,l,h,v.x,v.y)&&bt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=x;){if(w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Ns(a,u,c,d,l,h,w.x,w.y)&&bt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function FI(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!zu(r,s)&&Sv(r,i,i.next,s)&&Sa(r,s)&&Sa(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Ea(i),Ea(i.next),i=n=s),i=i.next}while(i!==n);return zr(i)}function kI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&XI(o,a)){let c=Ev(o,a);o=zr(o,o.next),c=zr(c,c.next),Ma(o,e,t,i,r,s,0),Ma(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function BI(n,e,t,i){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=Mv(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(WI(l));for(r.sort(zI),s=0;s<r.length;s++)t=VI(r[s],t);return t}function zI(n,e){return n.x-e.x}function VI(n,e){let t=$I(n,e);if(!t)return e;let i=Ev(t,n);return zr(i,i.next),zr(t,t.next)}function $I(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Ns(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),Sa(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&HI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function HI(n,e){return bt(n.prev,n,e.prev)<0&&bt(e.next,n,n.next)<0}function jI(n,e,t,i){let r=n;do r.z===0&&(r.z=Ef(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,GI(r)}function GI(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function Ef(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function WI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Ns(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function XI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!qI(n,e)&&(Sa(n,e)&&Sa(e,n)&&YI(n,e)&&(bt(n.prev,n,e.prev)||bt(n,e.prev,e))||zu(n,e)&&bt(n.prev,n,n.next)>0&&bt(e.prev,e,e.next)>0)}function bt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function zu(n,e){return n.x===e.x&&n.y===e.y}function Sv(n,e,t,i){let r=ll(bt(n,e,t)),s=ll(bt(n,e,i)),o=ll(bt(t,i,n)),a=ll(bt(t,i,e));return!!(r!==s&&o!==a||r===0&&cl(n,t,e)||s===0&&cl(n,i,e)||o===0&&cl(t,n,i)||a===0&&cl(t,e,i))}function cl(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ll(n){return n>0?1:n<0?-1:0}function qI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Sv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sa(n,e){return bt(n.prev,n,n.next)<0?bt(n,e,n.next)>=0&&bt(n,n.prev,e)>=0:bt(n,e,n.prev)<0||bt(n,n.next,e)<0}function YI(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Ev(n,e){let t=new Af(n.i,n.x,n.y),i=new Af(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Ly(n,e,t,i){let r=new Af(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ea(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Af(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ZI(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function Dy(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Oy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function KI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function QI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function Uy(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function Rr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Av(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Tv(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Tf(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function Dp(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function e2(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),d=[],h=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*r;if(!(p<t||p>=i)){d.push(l.times[f]);for(let y=0;y<u;++y)h.push(l.values[f*u+y])}}d.length!==0&&(l.times=Rr(d,l.times.constructor),l.values=Rr(h,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function t2(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let u=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let m=u,x=d-u;y=a.values.slice(m,x)}else if(s>=a.times[p]){let m=p*d+u,x=m+d-u;y=a.values.slice(m,x)}else{let m=a.createInterpolant(),x=u,v=d-u;m.evaluate(s),y=m.resultBuffer.slice(x,v)}c==="quaternion"&&new Zt().fromArray(y).normalize().conjugate().toArray(y);let g=l.times.length;for(let m=0;m<g;++m){let x=m*f+h;if(c==="quaternion")Zt.multiplyQuaternionsFlat(l.values,x,y,0,l.values,x);else{let v=f-h*2;for(let w=0;w<v;++w)l.values[x+w]-=y[w]}}}return n.blendMode=Ip,n}function i2(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $r;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return Ra;case"quaternion":return Zi;case"bool":case"boolean":return wi;case"string":return Mi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function r2(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=i2(n.type);if(n.times===void 0){let t=[],i=[];Dp(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function jy(){return(typeof performance>"u"?Date:performance).now()}function qy(n,e){return n.distance-e.distance}function Kf(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)Kf(r[s],e,t,!0)}}function Cv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Cv(n.children[t]));return e}function At(n,e,t,i,r,s,o){pl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],pl.x,pl.y,pl.z)}}var RM,PM,LM,i0,_h,r0,DM,OM,vp,s0,zn,xi,nn,$n,gi,Pr,wh,Mh,Sh,o0,ji,a0,c0,l0,u0,d0,h0,f0,p0,Ml,Sl,m0,g0,y0,v0,x0,b0,_0,w0,M0,S0,E0,A0,Xo,T0,I0,C0,R0,Ua,P0,L0,yi,D0,O0,U0,N0,F0,k0,B0,Eh,z0,Nu,bi,Wi,qo,Yo,Js,Zo,Mn,Jo,Ut,xp,UM,Ds,NM,It,$o,FM,Hn,kM,_i,V0,$0,bp,_p,Or,Sn,Na,wp,Mp,Ks,H0,j0,G0,un,W0,X0,Lr,Bs,Sp,Ep,q0,Ap,Tp,yl,vl,xl,bl,Ah,Th,Ih,Ch,Rh,Ph,Lh,Dh,Oh,Uh,Nh,Fh,kh,Bh,zh,Vh,$h,Hh,jh,Gh,Wh,_l,Xh,qh,Y0,Yh,Zh,Jh,Z0,J0,K0,Ko,Qo,wl,Ir,Cr,ea,Fu,Ip,BM,zM,VM,Q0,ev,Ji,tv,di,wn,Si,ku,Fa,ta,yt,na,ia,$M,Er,HM,jM,GM,WM,XM,qM,YM,ZM,JM,KM,QM,eS,tS,Kh,nv,iv,rv,Cp,sv,ov,av,cv,ra,nS,iS,rS,sS,oS,aS,cS,lS,uS,Qh,jn,sa,On,Xt,Eg,Dr,zs,TS,se,Ze,Fd,IS,Ag,Tg,Ig,Ec,CS,dt,ds,El,RS,fi,PS,Ct,ht,Al,hn,Vs,ef,aa,tf,Zt,D,zd,Cg,Bt,si,Rn,Ac,hs,fs,ps,Ni,Fi,fr,Io,Tc,Ic,pr,LS,Co,$d,Nt,oi,Hd,Cc,ki,jd,Rc,Gd,Xi,Ve,ms,Pn,DS,OS,Bi,Pc,cn,Rg,Pg,fn,$s,US,Lg,gs,ai,Lc,Ro,NS,FS,Dg,Og,Ug,Ng,kS,ys,Wd,ct,Ln,ci,Xd,li,vs,xs,Fg,qd,Yd,Zd,pi,hv,zi,Dc,Ie,qt,BS,Ft,Xn,hi,VS,Tt,Oc,ot,nf,rf,sf,of,ca,af,la,cf,De,$S,_n,Kd,bs,ln,Po,Ot,et,kg,mr,Uc,Bg,_s,ws,Ms,Qd,Nc,Fc,kc,Bc,zg,Vg,$g,zc,Vc,St,Ur,pv,GS,WS,pn,js,Vi,Hg,jg,Rt,Ss,Es,Tl,Nr,Il,eh,XS,qS,Vn,gr,Hc,Fr,Gs,ZS,JS,KS,QS,e1,t1,n1,i1,r1,s1,o1,a1,c1,l1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,b1,_1,w1,M1,S1,E1,A1,T1,I1,C1,R1,P1,L1,D1,O1,U1,N1,F1,k1,B1,z1,V1,$1,H1,j1,G1,W1,X1,q1,Y1,Z1,J1,K1,Q1,eE,tE,nE,iE,rE,sE,oE,aE,cE,lE,uE,dE,hE,fE,pE,mE,gE,yE,vE,xE,bE,_E,wE,ME,SE,EE,AE,TE,IE,CE,RE,PE,LE,DE,OE,UE,NE,FE,kE,BE,zE,VE,$E,HE,jE,GE,WE,XE,qE,YE,ZE,JE,KE,QE,eA,tA,nA,iA,rA,sA,oA,aA,cA,lA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,bA,_A,wA,MA,SA,EA,AA,TA,IA,Ke,Ee,Dn,jc,yr,CA,Ws,Us,Gg,Tr,th,Wg,nh,ih,rh,sh,Ar,As,Xg,ua,da,gv,yv,vv,xv,bv,Jg,Kg,Qg,ey,ty,lf,uf,df,oh,ks,LT,DT,VT,$T,jT,KT,ff,pf,sI,ha,fa,lI,uI,Cl,Gi,pI,jo,mI,gI,mf,gf,vr,yI,yf,Rl,Pl,Ll,Xs,Qt,kr,pa,Ts,Lo,Is,Cs,Rs,Do,wv,Wc,Oo,Xc,hy,ah,fy,Dl,Yc,py,Ol,my,gy,yy,bI,vy,Zc,ch,xy,lh,Ul,ma,Gn,by,_I,Nl,qi,Ps,_y,Jc,wy,wI,Uo,No,Fl,vf,Ls,$i,My,EI,Sy,uh,Kc,xr,Fo,dh,Yt,Qc,kl,zt,Bl,zl,Ey,ko,el,hh,Ay,qn,Ty,Iy,En,Vl,ga,Cy,xf,nl,il,$l,bf,_f,qs,wf,Mf,Sf,mn,Ys,Hl,rl,fh,ph,mh,jl,ya,Gl,va,Wl,xa,ba,_a,Xl,ql,Br,wa,Yl,Zl,Zs,Jl,Yi,Kl,sl,ol,gh,al,Ql,vi,OI,Wn,eu,JI,tu,Aa,nu,iu,Ta,ru,su,ou,au,cu,Ny,lu,uu,Ia,du,hu,fu,pu,mu,gu,yu,n2,Vr,vu,Ca,xu,gn,wi,Ra,$r,bu,Zi,Mi,Hr,jr,mi,Pa,Iv,Jt,ui,If,Un,Cf,Rf,Gr,Pf,Lf,Df,Yn,_u,yh,Fy,ky,La,Of,wu,By,Bo,vh,Uf,Mu,Nf,Su,Eu,Au,Tu,Iu,Cu,Da,Ru,Pu,Ff,s2,zy,Vy,kf,ul,Oa,Bf,$y,Hy,br,zf,Lu,_r,Gy,o2,wr,Vf,Du,Mr,Wy,a2,Sr,$f,Hf,Ou,Op,c2,Up,l2,u2,d2,h2,f2,p2,m2,jf,ut,Gf,Uu,g2,Wf,Xf,y2,qf,Yf,Zf,Xy,Jf,Qf,ep,Yy,tp,Zy,dl,np,Jy,ip,Hi,hl,xh,rp,sp,v2,Ky,Qy,op,ap,cp,e0,fl,t0,lp,pl,wt,up,ml,dp,hp,fp,n0,gl,bh,pp,mp,gp,yp,Pv=gx(()=>{"use strict";RM="164",PM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},LM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},i0=0,_h=1,r0=2,DM=3,OM=0,vp=1,s0=2,zn=3,xi=0,nn=1,$n=2,gi=0,Pr=1,wh=2,Mh=3,Sh=4,o0=5,ji=100,a0=101,c0=102,l0=103,u0=104,d0=200,h0=201,f0=202,p0=203,Ml=204,Sl=205,m0=206,g0=207,y0=208,v0=209,x0=210,b0=211,_0=212,w0=213,M0=214,S0=0,E0=1,A0=2,Xo=3,T0=4,I0=5,C0=6,R0=7,Ua=0,P0=1,L0=2,yi=0,D0=1,O0=2,U0=3,N0=4,F0=5,k0=6,B0=7,Eh="attached",z0="detached",Nu=300,bi=301,Wi=302,qo=303,Yo=304,Js=306,Zo=1e3,Mn=1001,Jo=1002,Ut=1003,xp=1004,UM=1004,Ds=1005,NM=1005,It=1006,$o=1007,FM=1007,Hn=1008,kM=1008,_i=1009,V0=1010,$0=1011,bp=1012,_p=1013,Or=1014,Sn=1015,Na=1016,wp=1017,Mp=1018,Ks=1020,H0=35902,j0=1021,G0=1022,un=1023,W0=1024,X0=1025,Lr=1026,Bs=1027,Sp=1028,Ep=1029,q0=1030,Ap=1031,Tp=1033,yl=33776,vl=33777,xl=33778,bl=33779,Ah=35840,Th=35841,Ih=35842,Ch=35843,Rh=36196,Ph=37492,Lh=37496,Dh=37808,Oh=37809,Uh=37810,Nh=37811,Fh=37812,kh=37813,Bh=37814,zh=37815,Vh=37816,$h=37817,Hh=37818,jh=37819,Gh=37820,Wh=37821,_l=36492,Xh=36494,qh=36495,Y0=36283,Yh=36284,Zh=36285,Jh=36286,Z0=2200,J0=2201,K0=2202,Ko=2300,Qo=2301,wl=2302,Ir=2400,Cr=2401,ea=2402,Fu=2500,Ip=2501,BM=0,zM=1,VM=2,Q0=3200,ev=3201,Ji=0,tv=1,di="",wn="srgb",Si="srgb-linear",ku="display-p3",Fa="display-p3-linear",ta="linear",yt="srgb",na="rec709",ia="p3",$M=0,Er=7680,HM=7681,jM=7682,GM=7683,WM=34055,XM=34056,qM=5386,YM=512,ZM=513,JM=514,KM=515,QM=516,eS=517,tS=518,Kh=519,nv=512,iv=513,rv=514,Cp=515,sv=516,ov=517,av=518,cv=519,ra=35044,nS=35048,iS=35040,rS=35045,sS=35049,oS=35041,aS=35046,cS=35050,lS=35042,uS="100",Qh="300 es",jn=2e3,sa=2001,On=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},Xt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Eg=1234567,Dr=Math.PI/180,zs=180/Math.PI;TS={DEG2RAD:Dr,RAD2DEG:zs,generateUUID:dn,clamp:Mt,euclideanModulo:Rp,mapLinear:dS,inverseLerp:hS,lerp:Ho,damp:fS,pingpong:pS,smoothstep:mS,smootherstep:gS,randInt:yS,randFloat:vS,randFloatSpread:xS,seededRandom:bS,degToRad:_S,radToDeg:wS,isPowerOfTwo:MS,ceilPowerOfTwo:SS,floorPowerOfTwo:ES,setQuaternionFromProperEuler:AS,normalize:Je,denormalize:tn},se=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ze=class n{constructor(e,t,i,r,s,o,a,c,l){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],y=r[0],g=r[3],m=r[6],x=r[1],v=r[4],w=r[7],N=r[2],C=r[5],R=r[8];return s[0]=o*y+a*x+c*N,s[3]=o*g+a*v+c*C,s[6]=o*m+a*w+c*R,s[1]=l*y+u*x+d*N,s[4]=l*g+u*v+d*C,s[7]=l*m+u*w+d*R,s[2]=h*y+f*x+p*N,s[5]=h*g+f*v+p*C,s[8]=h*m+f*w+p*R,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*s*u+i*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=u*o-a*l,h=a*c-u*s,f=l*s-o*c,p=t*d+i*h+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/p;return e[0]=d*y,e[1]=(r*l-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=f*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Fd=new Ze;IS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};Ag={};Tg=new Ze().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ig=new Ze().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ec={[Si]:{transfer:ta,primaries:na,toReference:n=>n,fromReference:n=>n},[wn]:{transfer:yt,primaries:na,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Fa]:{transfer:ta,primaries:ia,toReference:n=>n.applyMatrix3(Ig),fromReference:n=>n.applyMatrix3(Tg)},[ku]:{transfer:yt,primaries:ia,toReference:n=>n.convertSRGBToLinear().applyMatrix3(Ig),fromReference:n=>n.applyMatrix3(Tg).convertLinearToSRGB()}},CS=new Set([Si,Fa]),dt={enabled:!0,_workingColorSpace:Si,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!CS.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Ec[e].toReference,r=Ec[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Ec[n].primaries},getTransfer:function(n){return n===di?ta:Ec[n].transfer}};El=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{ds===void 0&&(ds=oa("canvas")),ds.width=e.width,ds.height=e.height;let i=ds.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=ds}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=oa("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Fs(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Fs(t[i]/255)*255):t[i]=Fs(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},RS=0,fi=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:RS++}),this.uuid=dn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Bd(r[o].image)):s.push(Bd(r[o]))}else s=Bd(r);i.url=s}return t||(e.images[this.uuid]=i),i}};PS=0,Ct=class n extends On{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Mn,r=Mn,s=It,o=Hn,a=un,c=_i,l=n.DEFAULT_ANISOTROPY,u=di){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:PS++}),this.uuid=dn(),this.name="",this.source=new fi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new se(0,0),this.repeat=new se(1,1),this.center=new se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Nu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zo:e.x=e.x-Math.floor(e.x);break;case Mn:e.x=e.x<0?0:1;break;case Jo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zo:e.y=e.y-Math.floor(e.y);break;case Mn:e.y=e.y<0?0:1;break;case Jo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=Nu;Ct.DEFAULT_ANISOTROPY=1;ht=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,c=e.elements,l=c[0],u=c[4],d=c[8],h=c[1],f=c[5],p=c[9],y=c[2],g=c[6],m=c[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(l+1)/2,w=(f+1)/2,N=(m+1)/2,C=(u+h)/4,R=(d+y)/4,F=(p+g)/4;return v>w&&v>N?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=C/i,s=R/i):w>N?w<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),i=C/r,s=F/r):N<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(N),i=R/s,r=F/s),this.set(i,r,s,t),this}let x=Math.sqrt((g-p)*(g-p)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(g-p)/x,this.y=(d-y)/x,this.z=(h-u)/x,this.w=Math.acos((l+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Al=class extends On{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ht(0,0,e,t),this.scissorTest=!1,this.viewport=new ht(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new Ct(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new fi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},hn=class extends Al{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},Vs=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ef=class extends hn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Vs(null,e,t,i),this.texture.isRenderTargetTexture=!0}},aa=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class extends hn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new aa(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Zt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],d=i[r+3],h=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=p,e[t+3]=y;return}if(d!==y||c!==h||l!==f||u!==p){let g=1-a,m=c*h+l*f+u*p+d*y,x=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){let N=Math.sqrt(v),C=Math.atan2(N,m*x);g=Math.sin(g*C)/N,a=Math.sin(a*C)/N}let w=a*x;if(c=c*g+h*w,l=l*g+f*w,u=u*g+p*w,d=d*g+y*w,g===1-a){let N=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=N,l*=N,u*=N,d*=N}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],d=s[o],h=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*d+c*f-l*h,e[t+1]=c*p+u*h+l*d-a*f,e[t+2]=l*p+u*f+a*h-c*d,e[t+3]=u*p-a*d-c*h-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),d=a(s/2),h=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"YZX":this._x=h*u*d+l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d-h*f*p;break;case"XZY":this._x=h*u*d-l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d+h*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],d=t[10],h=i+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>d){let f=2*Math.sqrt(1+i-a-d);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>d){let f=2*Math.sqrt(1+a-i-d);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+d-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Mt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),d=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=o*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},D=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Cg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Cg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+c*l+o*d-a*u,this.y=i+c*u+a*l-s*d,this.z=r+c*d+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return zd.copy(this).projectOnVector(e),this.sub(zd)}reflect(e){return this.sub(zd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},zd=new D,Cg=new Zt,Bt=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Rn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Rn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Rn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Rn):Rn.fromBufferAttribute(s,o),Rn.applyMatrix4(e.matrixWorld),this.expandByPoint(Rn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ac.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ac.copy(i.boundingBox)),Ac.applyMatrix4(e.matrixWorld),this.union(Ac)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Rn),Rn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Io),Tc.subVectors(this.max,Io),hs.subVectors(e.a,Io),fs.subVectors(e.b,Io),ps.subVectors(e.c,Io),Ni.subVectors(fs,hs),Fi.subVectors(ps,fs),fr.subVectors(hs,ps);let t=[0,-Ni.z,Ni.y,0,-Fi.z,Fi.y,0,-fr.z,fr.y,Ni.z,0,-Ni.x,Fi.z,0,-Fi.x,fr.z,0,-fr.x,-Ni.y,Ni.x,0,-Fi.y,Fi.x,0,-fr.y,fr.x,0];return!Vd(t,hs,fs,ps,Tc)||(t=[1,0,0,0,1,0,0,0,1],!Vd(t,hs,fs,ps,Tc))?!1:(Ic.crossVectors(Ni,Fi),t=[Ic.x,Ic.y,Ic.z],Vd(t,hs,fs,ps,Tc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Rn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Rn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(si[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),si[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),si[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),si[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),si[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),si[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),si[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),si[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(si),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},si=[new D,new D,new D,new D,new D,new D,new D,new D],Rn=new D,Ac=new Bt,hs=new D,fs=new D,ps=new D,Ni=new D,Fi=new D,fr=new D,Io=new D,Tc=new D,Ic=new D,pr=new D;LS=new Bt,Co=new D,$d=new D,Nt=class{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):LS.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Co.subVectors(e,this.center);let t=Co.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Co,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($d.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Co.copy(e.center).add($d)),this.expandByPoint(Co.copy(e.center).sub($d))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},oi=new D,Hd=new D,Cc=new D,ki=new D,jd=new D,Rc=new D,Gd=new D,Xi=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,oi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=oi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(oi.copy(this.origin).addScaledVector(this.direction,t),oi.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Hd.copy(e).add(t).multiplyScalar(.5),Cc.copy(t).sub(e).normalize(),ki.copy(this.origin).sub(Hd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Cc),a=ki.dot(this.direction),c=-ki.dot(Cc),l=ki.lengthSq(),u=Math.abs(1-o*o),d,h,f,p;if(u>0)if(d=o*c-a,h=o*a-c,p=s*u,d>=0)if(h>=-p)if(h<=p){let y=1/u;d*=y,h*=y,f=d*(d+o*h+2*a)+h*(o*d+h+2*c)+l}else h=s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h=-s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h<=-p?(d=Math.max(0,-(-o*s+a)),h=d>0?-s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l):h<=p?(d=0,h=Math.min(Math.max(-s,-c),s),f=h*(h+2*c)+l):(d=Math.max(0,-(o*s+a)),h=d>0?s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l);else h=o>0?-s:s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Hd).addScaledVector(Cc,h),f}intersectSphere(e,t){oi.subVectors(e.center,this.origin);let i=oi.dot(this.direction),r=oi.dot(oi)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-h.z)*d,c=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,c=(e.min.z-h.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,oi)!==null}intersectTriangle(e,t,i,r,s){jd.subVectors(t,e),Rc.subVectors(i,e),Gd.crossVectors(jd,Rc);let o=this.direction.dot(Gd),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ki.subVectors(this.origin,e);let c=a*this.direction.dot(Rc.crossVectors(ki,Rc));if(c<0)return null;let l=a*this.direction.dot(jd.cross(ki));if(l<0||c+l>o)return null;let u=-a*ki.dot(Gd);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ve=class n{constructor(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g)}set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=u,m[10]=d,m[14]=h,m[3]=f,m[7]=p,m[11]=y,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/ms.setFromMatrixColumn(e,0).length(),s=1/ms.setFromMatrixColumn(e,1).length(),o=1/ms.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=f+p*l,t[5]=h-y*l,t[9]=-a*c,t[2]=y-h*l,t[6]=p+f*l,t[10]=o*c}else if(e.order==="YXZ"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h+y*a,t[4]=p*a-f,t[8]=o*l,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=y+h*a,t[10]=o*c}else if(e.order==="ZXY"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h-y*a,t[4]=-o*d,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=y-h*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=p*l-f,t[8]=h*l+y,t[1]=c*d,t[5]=y*l+h,t[9]=f*l-p,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=y-h*d,t[8]=p*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=f*d+p,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=h*d+y,t[5]=o*u,t[9]=f*d-p,t[2]=p*d-f,t[6]=a*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(DS,e,OS)}lookAt(e,t,i){let r=this.elements;return cn.subVectors(e,t),cn.lengthSq()===0&&(cn.z=1),cn.normalize(),Bi.crossVectors(i,cn),Bi.lengthSq()===0&&(Math.abs(i.z)===1?cn.x+=1e-4:cn.z+=1e-4,cn.normalize(),Bi.crossVectors(i,cn)),Bi.normalize(),Pc.crossVectors(cn,Bi),r[0]=Bi.x,r[4]=Pc.x,r[8]=cn.x,r[1]=Bi.y,r[5]=Pc.y,r[9]=cn.y,r[2]=Bi.z,r[6]=Pc.z,r[10]=cn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],d=i[5],h=i[9],f=i[13],p=i[2],y=i[6],g=i[10],m=i[14],x=i[3],v=i[7],w=i[11],N=i[15],C=r[0],R=r[4],F=r[8],A=r[12],S=r[1],P=r[5],k=r[9],O=r[13],H=r[2],W=r[6],J=r[10],ae=r[14],B=r[3],ne=r[7],ce=r[11],Me=r[15];return s[0]=o*C+a*S+c*H+l*B,s[4]=o*R+a*P+c*W+l*ne,s[8]=o*F+a*k+c*J+l*ce,s[12]=o*A+a*O+c*ae+l*Me,s[1]=u*C+d*S+h*H+f*B,s[5]=u*R+d*P+h*W+f*ne,s[9]=u*F+d*k+h*J+f*ce,s[13]=u*A+d*O+h*ae+f*Me,s[2]=p*C+y*S+g*H+m*B,s[6]=p*R+y*P+g*W+m*ne,s[10]=p*F+y*k+g*J+m*ce,s[14]=p*A+y*O+g*ae+m*Me,s[3]=x*C+v*S+w*H+N*B,s[7]=x*R+v*P+w*W+N*ne,s[11]=x*F+v*k+w*J+N*ce,s[15]=x*A+v*O+w*ae+N*Me,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],d=e[6],h=e[10],f=e[14],p=e[3],y=e[7],g=e[11],m=e[15];return p*(+s*c*d-r*l*d-s*a*h+i*l*h+r*a*f-i*c*f)+y*(+t*c*f-t*l*h+s*o*h-r*o*f+r*l*u-s*c*u)+g*(+t*l*d-t*a*f-s*o*d+i*o*f+s*a*u-i*l*u)+m*(-r*a*u-t*c*d+t*a*h+r*o*d-i*o*h+i*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=e[9],h=e[10],f=e[11],p=e[12],y=e[13],g=e[14],m=e[15],x=d*g*l-y*h*l+y*c*f-a*g*f-d*c*m+a*h*m,v=p*h*l-u*g*l-p*c*f+o*g*f+u*c*m-o*h*m,w=u*y*l-p*d*l+p*a*f-o*y*f-u*a*m+o*d*m,N=p*d*c-u*y*c-p*a*h+o*y*h+u*a*g-o*d*g,C=t*x+i*v+r*w+s*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/C;return e[0]=x*R,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*m-i*h*m)*R,e[2]=(a*g*s-y*c*s+y*r*l-i*g*l-a*r*m+i*c*m)*R,e[3]=(d*c*s-a*h*s-d*r*l+i*h*l+a*r*f-i*c*f)*R,e[4]=v*R,e[5]=(u*g*s-p*h*s+p*r*f-t*g*f-u*r*m+t*h*m)*R,e[6]=(p*c*s-o*g*s-p*r*l+t*g*l+o*r*m-t*c*m)*R,e[7]=(o*h*s-u*c*s+u*r*l-t*h*l-o*r*f+t*c*f)*R,e[8]=w*R,e[9]=(p*d*s-u*y*s-p*i*f+t*y*f+u*i*m-t*d*m)*R,e[10]=(o*y*s-p*a*s+p*i*l-t*y*l-o*i*m+t*a*m)*R,e[11]=(u*a*s-o*d*s-u*i*l+t*d*l+o*i*f-t*a*f)*R,e[12]=N*R,e[13]=(u*y*r-p*d*r+p*i*h-t*y*h-u*i*g+t*d*g)*R,e[14]=(p*a*r-o*y*r-p*i*c+t*y*c+o*i*g-t*a*g)*R,e[15]=(o*d*r-u*a*r+u*i*c-t*d*c-o*i*h+t*a*h)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,d=a+a,h=s*l,f=s*u,p=s*d,y=o*u,g=o*d,m=a*d,x=c*l,v=c*u,w=c*d,N=i.x,C=i.y,R=i.z;return r[0]=(1-(y+m))*N,r[1]=(f+w)*N,r[2]=(p-v)*N,r[3]=0,r[4]=(f-w)*C,r[5]=(1-(h+m))*C,r[6]=(g+x)*C,r[7]=0,r[8]=(p+v)*R,r[9]=(g-x)*R,r[10]=(1-(h+y))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=ms.set(r[0],r[1],r[2]).length(),o=ms.set(r[4],r[5],r[6]).length(),a=ms.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Pn.copy(this);let l=1/s,u=1/o,d=1/a;return Pn.elements[0]*=l,Pn.elements[1]*=l,Pn.elements[2]*=l,Pn.elements[4]*=u,Pn.elements[5]*=u,Pn.elements[6]*=u,Pn.elements[8]*=d,Pn.elements[9]*=d,Pn.elements[10]*=d,t.setFromRotationMatrix(Pn),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=jn){let c=this.elements,l=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,p;if(a===jn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===sa)f=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=jn){let c=this.elements,l=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*l,f=(i+r)*u,p,y;if(a===jn)p=(o+s)*d,y=-2*d;else if(a===sa)p=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-h,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=y,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},ms=new D,Pn=new Ve,DS=new D(0,0,0),OS=new D(1,1,1),Bi=new D,Pc=new D,cn=new D,Rg=new Ve,Pg=new Zt,fn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(Mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Mt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Mt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Mt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Rg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Rg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pg.setFromEuler(this),this.setFromQuaternion(Pg,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};fn.DEFAULT_ORDER="XYZ";$s=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},US=0,Lg=new D,gs=new Zt,ai=new Ve,Lc=new D,Ro=new D,NS=new D,FS=new Zt,Dg=new D(1,0,0),Og=new D(0,1,0),Ug=new D(0,0,1),Ng={type:"added"},kS={type:"removed"},ys={type:"childadded",child:null},Wd={type:"childremoved",child:null},ct=class n extends On{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:US++}),this.uuid=dn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new D,t=new fn,i=new Zt,r=new D(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ve},normalMatrix:{value:new Ze}}),this.matrix=new Ve,this.matrixWorld=new Ve,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $s,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return gs.setFromAxisAngle(e,t),this.quaternion.multiply(gs),this}rotateOnWorldAxis(e,t){return gs.setFromAxisAngle(e,t),this.quaternion.premultiply(gs),this}rotateX(e){return this.rotateOnAxis(Dg,e)}rotateY(e){return this.rotateOnAxis(Og,e)}rotateZ(e){return this.rotateOnAxis(Ug,e)}translateOnAxis(e,t){return Lg.copy(e).applyQuaternion(this.quaternion),this.position.add(Lg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dg,e)}translateY(e){return this.translateOnAxis(Og,e)}translateZ(e){return this.translateOnAxis(Ug,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ai.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Lc.copy(e):Lc.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ai.lookAt(Ro,Lc,this.up):ai.lookAt(Lc,Ro,this.up),this.quaternion.setFromRotationMatrix(ai),r&&(ai.extractRotation(r.matrixWorld),gs.setFromRotationMatrix(ai),this.quaternion.premultiply(gs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ng),ys.child=e,this.dispatchEvent(ys),ys.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(kS),Wd.child=e,this.dispatchEvent(Wd),Wd.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ai.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ai.multiply(e.parent.matrixWorld)),e.applyMatrix4(ai),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ng),ys.child=e,this.dispatchEvent(ys),ys.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,e,NS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,FS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let d=c[l];s(e.shapes,d)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),p=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};ct.DEFAULT_UP=new D(0,1,0);ct.DEFAULT_MATRIX_AUTO_UPDATE=!0;ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Ln=new D,ci=new D,Xd=new D,li=new D,vs=new D,xs=new D,Fg=new D,qd=new D,Yd=new D,Zd=new D,pi=class n{constructor(e=new D,t=new D,i=new D){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Ln.subVectors(e,t),r.cross(Ln);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Ln.subVectors(r,t),ci.subVectors(i,t),Xd.subVectors(e,t);let o=Ln.dot(Ln),a=Ln.dot(ci),c=Ln.dot(Xd),l=ci.dot(ci),u=ci.dot(Xd),d=o*l-a*a;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(l*c-a*u)*h,p=(o*u-a*c)*h;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,li)===null?!1:li.x>=0&&li.y>=0&&li.x+li.y<=1}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,li)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,li.x),c.addScaledVector(o,li.y),c.addScaledVector(a,li.z),c)}static isFrontFacing(e,t,i,r){return Ln.subVectors(i,t),ci.subVectors(e,t),Ln.cross(ci).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ln.subVectors(this.c,this.b),ci.subVectors(this.a,this.b),Ln.cross(ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;vs.subVectors(r,i),xs.subVectors(s,i),qd.subVectors(e,i);let c=vs.dot(qd),l=xs.dot(qd);if(c<=0&&l<=0)return t.copy(i);Yd.subVectors(e,r);let u=vs.dot(Yd),d=xs.dot(Yd);if(u>=0&&d<=u)return t.copy(r);let h=c*d-u*l;if(h<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(i).addScaledVector(vs,o);Zd.subVectors(e,s);let f=vs.dot(Zd),p=xs.dot(Zd);if(p>=0&&f<=p)return t.copy(s);let y=f*l-c*p;if(y<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(i).addScaledVector(xs,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return Fg.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(Fg,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(vs,o).addScaledVector(xs,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},hv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zi={h:0,s:0,l:0},Dc={h:0,s:0,l:0};Ie=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,dt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=dt.workingColorSpace){return this.r=e,this.g=t,this.b=i,dt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=dt.workingColorSpace){if(e=Rp(e,1),t=Mt(t,0,1),i=Mt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Jd(o,s,e+1/3),this.g=Jd(o,s,e),this.b=Jd(o,s,e-1/3)}return dt.toWorkingColorSpace(this,r),this}setStyle(e,t=wn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wn){let i=hv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fs(e.r),this.g=Fs(e.g),this.b=Fs(e.b),this}copyLinearToSRGB(e){return this.r=kd(e.r),this.g=kd(e.g),this.b=kd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wn){return dt.fromWorkingColorSpace(qt.copy(this),e),Math.round(Mt(qt.r*255,0,255))*65536+Math.round(Mt(qt.g*255,0,255))*256+Math.round(Mt(qt.b*255,0,255))}getHexString(e=wn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dt.workingColorSpace){dt.fromWorkingColorSpace(qt.copy(this),t);let i=qt.r,r=qt.g,s=qt.b,o=Math.max(i,r,s),a=Math.min(i,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=u<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-i)/d+2;break;case s:c=(i-r)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=dt.workingColorSpace){return dt.fromWorkingColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e=wn){dt.fromWorkingColorSpace(qt.copy(this),e);let t=qt.r,i=qt.g,r=qt.b;return e!==wn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(zi),this.setHSL(zi.h+e,zi.s+t,zi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(zi),e.getHSL(Dc);let i=Ho(zi.h,Dc.h,t),r=Ho(zi.s,Dc.s,t),s=Ho(zi.l,Dc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},qt=new Ie;Ie.NAMES=hv;BS=0,Ft=class extends On{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:BS++}),this.uuid=dn(),this.name="",this.type="Material",this.blending=Pr,this.side=xi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ml,this.blendDst=Sl,this.blendEquation=ji,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=Xo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Er,this.stencilZFail=Er,this.stencilZPass=Er,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Pr&&(i.blending=this.blending),this.side!==xi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Ml&&(i.blendSrc=this.blendSrc),this.blendDst!==Sl&&(i.blendDst=this.blendDst),this.blendEquation!==ji&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xo&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Kh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Er&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Er&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Er&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Xn=class extends Ft{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},hi=zS();VS={toHalfFloat:sn,fromHalfFloat:zo},Tt=new D,Oc=new se,ot=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ra,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Sn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return dv("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Oc.fromBufferAttribute(this,t),Oc.applyMatrix3(e),this.setXY(t,Oc.x,Oc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix3(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix4(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyNormalMatrix(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.transformDirection(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Je(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ra&&(e.usage=this.usage),e}},nf=class extends ot{constructor(e,t,i){super(new Int8Array(e),t,i)}},rf=class extends ot{constructor(e,t,i){super(new Uint8Array(e),t,i)}},sf=class extends ot{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},of=class extends ot{constructor(e,t,i){super(new Int16Array(e),t,i)}},ca=class extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}},af=class extends ot{constructor(e,t,i){super(new Int32Array(e),t,i)}},la=class extends ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}},cf=class extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=zo(this.array[e*this.itemSize]);return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize]=sn(t),this}getY(e){let t=zo(this.array[e*this.itemSize+1]);return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+1]=sn(t),this}getZ(e){let t=zo(this.array[e*this.itemSize+2]);return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+2]=sn(t),this}getW(e){let t=zo(this.array[e*this.itemSize+3]);return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+3]=sn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this.array[e+2]=sn(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this.array[e+2]=sn(r),this.array[e+3]=sn(s),this}},De=class extends ot{constructor(e,t,i){super(new Float32Array(e),t,i)}},$S=0,_n=new Ve,Kd=new ct,bs=new D,ln=new Bt,Po=new Bt,Ot=new D,et=class n extends On{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$S++}),this.uuid=dn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(lv(e)?la:ca)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Ze().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _n.makeRotationFromQuaternion(e),this.applyMatrix4(_n),this}rotateX(e){return _n.makeRotationX(e),this.applyMatrix4(_n),this}rotateY(e){return _n.makeRotationY(e),this.applyMatrix4(_n),this}rotateZ(e){return _n.makeRotationZ(e),this.applyMatrix4(_n),this}translate(e,t,i){return _n.makeTranslation(e,t,i),this.applyMatrix4(_n),this}scale(e,t,i){return _n.makeScale(e,t,i),this.applyMatrix4(_n),this}lookAt(e){return Kd.lookAt(e),Kd.updateMatrix(),this.applyMatrix4(Kd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(bs).negate(),this.translate(bs.x,bs.y,bs.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];ln.setFromBufferAttribute(s),this.morphTargetsRelative?(Ot.addVectors(this.boundingBox.min,ln.min),this.boundingBox.expandByPoint(Ot),Ot.addVectors(this.boundingBox.max,ln.max),this.boundingBox.expandByPoint(Ot)):(this.boundingBox.expandByPoint(ln.min),this.boundingBox.expandByPoint(ln.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){let i=this.boundingSphere.center;if(ln.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Po.setFromBufferAttribute(a),this.morphTargetsRelative?(Ot.addVectors(ln.min,Po.min),ln.expandByPoint(Ot),Ot.addVectors(ln.max,Po.max),ln.expandByPoint(Ot)):(ln.expandByPoint(Po.min),ln.expandByPoint(Po.max))}ln.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Ot.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ot));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Ot.fromBufferAttribute(a,l),c&&(bs.fromBufferAttribute(e,l),Ot.add(bs)),r=Math.max(r,i.distanceToSquared(Ot))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ot(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let F=0;F<i.count;F++)a[F]=new D,c[F]=new D;let l=new D,u=new D,d=new D,h=new se,f=new se,p=new se,y=new D,g=new D;function m(F,A,S){l.fromBufferAttribute(i,F),u.fromBufferAttribute(i,A),d.fromBufferAttribute(i,S),h.fromBufferAttribute(s,F),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,S),u.sub(l),d.sub(l),f.sub(h),p.sub(h);let P=1/(f.x*p.y-p.x*f.y);isFinite(P)&&(y.copy(u).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(P),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(P),a[F].add(y),a[A].add(y),a[S].add(y),c[F].add(g),c[A].add(g),c[S].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let F=0,A=x.length;F<A;++F){let S=x[F],P=S.start,k=S.count;for(let O=P,H=P+k;O<H;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let v=new D,w=new D,N=new D,C=new D;function R(F){N.fromBufferAttribute(r,F),C.copy(N);let A=a[F];v.copy(A),v.sub(N.multiplyScalar(N.dot(A))).normalize(),w.crossVectors(C,A);let P=w.dot(c[F])<0?-1:1;o.setXYZW(F,v.x,v.y,v.z,P)}for(let F=0,A=x.length;F<A;++F){let S=x[F],P=S.start,k=S.count;for(let O=P,H=P+k;O<H;O+=3)R(e.getX(O+0)),R(e.getX(O+1)),R(e.getX(O+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new ot(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new D,s=new D,o=new D,a=new D,c=new D,l=new D,u=new D,d=new D;if(e)for(let h=0,f=e.count;h<f;h+=3){let p=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,g),a.add(u),c.add(u),l.add(u),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ot.fromBufferAttribute(e,t),Ot.normalize(),e.setXYZ(t,Ot.x,Ot.y,Ot.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,d=a.normalized,h=new l.constructor(c.length*u),f=0,p=0;for(let y=0,g=c.length;y<g;y++){a.isInterleavedBufferAttribute?f=c[y]*a.data.stride+a.offset:f=c[y]*u;for(let m=0;m<u;m++)h[p++]=l[f++]}return new ot(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,i);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,d=l.length;u<d;u++){let h=l[u],f=e(h,i);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d];u.push(f.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],d=s[l];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},kg=new Ve,mr=new Xi,Uc=new Nt,Bg=new D,_s=new D,ws=new D,Ms=new D,Qd=new D,Nc=new D,Fc=new se,kc=new se,Bc=new se,zg=new D,Vg=new D,$g=new D,zc=new D,Vc=new D,St=class extends ct{constructor(e=new et,t=new Xn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Nc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],d=s[c];u!==0&&(Qd.fromBufferAttribute(d,e),o?Nc.addScaledVector(Qd,u):Nc.addScaledVector(Qd.sub(t),u))}t.add(Nc)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Uc.copy(i.boundingSphere),Uc.applyMatrix4(s),mr.copy(e.ray).recast(e.near),!(Uc.containsPoint(mr.origin)===!1&&(mr.intersectSphere(Uc,Bg)===null||mr.origin.distanceToSquared(Bg)>(e.far-e.near)**2))&&(kg.copy(s).invert(),mr.copy(e.ray).applyMatrix4(kg),!(i.boundingBox!==null&&mr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,mr)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let w=x,N=v;w<N;w+=3){let C=a.getX(w),R=a.getX(w+1),F=a.getX(w+2);r=$c(this,m,e,i,l,u,d,C,R,F),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=a.getX(g),v=a.getX(g+1),w=a.getX(g+2);r=$c(this,o,e,i,l,u,d,x,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let w=x,N=v;w<N;w+=3){let C=w,R=w+1,F=w+2;r=$c(this,m,e,i,l,u,d,C,R,F),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(c.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=g,v=g+1,w=g+2;r=$c(this,o,e,i,l,u,d,x,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};Ur=class n extends et{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],d=[],h=0,f=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(d,2));function p(y,g,m,x,v,w,N,C,R,F,A){let S=w/R,P=N/F,k=w/2,O=N/2,H=C/2,W=R+1,J=F+1,ae=0,B=0,ne=new D;for(let ce=0;ce<J;ce++){let Me=ce*P-O;for(let fe=0;fe<W;fe++){let $e=fe*S-k;ne[y]=$e*x,ne[g]=Me*v,ne[m]=H,l.push(ne.x,ne.y,ne.z),ne[y]=0,ne[g]=0,ne[m]=C>0?1:-1,u.push(ne.x,ne.y,ne.z),d.push(fe/R),d.push(1-ce/F),ae+=1}}for(let ce=0;ce<F;ce++)for(let Me=0;Me<R;Me++){let fe=h+Me+W*ce,$e=h+Me+W*(ce+1),Y=h+(Me+1)+W*(ce+1),me=h+(Me+1)+W*ce;c.push(fe,$e,me),c.push($e,Y,me),B+=6}a.addGroup(f,B,A),f+=B,h+=ae}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};pv={clone:Hs,merge:en},GS=`void main() {
200
+ `+B)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||H==="")&&(J=!1);J&&(P.diagnostics={runnable:W,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:H,prefix:m}})}r.deleteShader(N),r.deleteShader(C),F=new Bs(r,y),A=zT(r,y)}let F;this.getUniforms=function(){return F===void 0&&R(this),F};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let S=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return S===!1&&(S=r.getProgramParameter(y,LT)),S},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=DT++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=C,this}function QT(n,e,t,i,r,s,o){let a=new Hs,c=new ff,l=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures,f=r.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(A){return l.add(A),A===0?"uv":`uv${A}`}function g(A,S,P,k,O){let H=k.fog,W=O.geometry,J=A.isMeshStandardMaterial?k.environment:null,ae=(A.isMeshStandardMaterial?t:e).get(A.envMap||J),B=ae&&ae.mapping===Ks?ae.image.height:null,ne=p[A.type];A.precision!==null&&(f=r.getMaxPrecision(A.precision),f!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",f,"instead."));let ce=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Me=ce!==void 0?ce.length:0,fe=0;W.morphAttributes.position!==void 0&&(fe=1),W.morphAttributes.normal!==void 0&&(fe=2),W.morphAttributes.color!==void 0&&(fe=3);let $e,Y,me,te;if(ne){let rt=On[ne];$e=rt.vertexShader,Y=rt.fragmentShader}else $e=A.vertexShader,Y=A.fragmentShader,c.update(A),me=c.getVertexShaderID(A),te=c.getFragmentShaderID(A);let ue=n.getRenderTarget(),Pe=O.isInstancedMesh===!0,_e=O.isBatchedMesh===!0,z=!!A.map,Be=!!A.matcap,X=!!ae,de=!!A.aoMap,Z=!!A.lightMap,he=!!A.bumpMap,ie=!!A.normalMap,ye=!!A.displacementMap,Te=!!A.emissiveMap,U=!!A.metalnessMap,T=!!A.roughnessMap,G=A.anisotropy>0,ee=A.clearcoat>0,oe=A.dispersion>0,re=A.iridescence>0,Ue=A.sheen>0,ve=A.transmission>0,xe=G&&!!A.anisotropyMap,He=ee&&!!A.clearcoatMap,pe=ee&&!!A.clearcoatNormalMap,Oe=ee&&!!A.clearcoatRoughnessMap,qe=re&&!!A.iridescenceMap,Ne=re&&!!A.iridescenceThicknessMap,Ce=Ue&&!!A.sheenColorMap,Fe=Ue&&!!A.sheenRoughnessMap,Qe=!!A.specularMap,pt=!!A.specularColorMap,je=!!A.specularIntensityMap,V=ve&&!!A.transmissionMap,le=ve&&!!A.thicknessMap,K=!!A.gradientMap,we=!!A.alphaMap,Ae=A.alphaTest>0,Re=!!A.alphaHash,tt=!!A.extensions,ft=yi;A.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(ft=n.toneMapping);let vt={shaderID:ne,shaderType:A.type,shaderName:A.name,vertexShader:$e,fragmentShader:Y,defines:A.defines,customVertexShaderID:me,customFragmentShaderID:te,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:f,batching:_e,instancing:Pe,instancingColor:Pe&&O.instanceColor!==null,instancingMorph:Pe&&O.morphTexture!==null,supportsVertexTextures:h,outputColorSpace:ue===null?n.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Si,alphaToCoverage:!!A.alphaToCoverage,map:z,matcap:Be,envMap:X,envMapMode:X&&ae.mapping,envMapCubeUVHeight:B,aoMap:de,lightMap:Z,bumpMap:he,normalMap:ie,displacementMap:h&&ye,emissiveMap:Te,normalMapObjectSpace:ie&&A.normalMapType===tv,normalMapTangentSpace:ie&&A.normalMapType===Ji,metalnessMap:U,roughnessMap:T,anisotropy:G,anisotropyMap:xe,clearcoat:ee,clearcoatMap:He,clearcoatNormalMap:pe,clearcoatRoughnessMap:Oe,dispersion:oe,iridescence:re,iridescenceMap:qe,iridescenceThicknessMap:Ne,sheen:Ue,sheenColorMap:Ce,sheenRoughnessMap:Fe,specularMap:Qe,specularColorMap:pt,specularIntensityMap:je,transmission:ve,transmissionMap:V,thicknessMap:le,gradientMap:K,opaque:A.transparent===!1&&A.blending===Or&&A.alphaToCoverage===!1,alphaMap:we,alphaTest:Ae,alphaHash:Re,combine:A.combine,mapUv:z&&y(A.map.channel),aoMapUv:de&&y(A.aoMap.channel),lightMapUv:Z&&y(A.lightMap.channel),bumpMapUv:he&&y(A.bumpMap.channel),normalMapUv:ie&&y(A.normalMap.channel),displacementMapUv:ye&&y(A.displacementMap.channel),emissiveMapUv:Te&&y(A.emissiveMap.channel),metalnessMapUv:U&&y(A.metalnessMap.channel),roughnessMapUv:T&&y(A.roughnessMap.channel),anisotropyMapUv:xe&&y(A.anisotropyMap.channel),clearcoatMapUv:He&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:pe&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Oe&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:qe&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ce&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(A.sheenRoughnessMap.channel),specularMapUv:Qe&&y(A.specularMap.channel),specularColorMapUv:pt&&y(A.specularColorMap.channel),specularIntensityMapUv:je&&y(A.specularIntensityMap.channel),transmissionMapUv:V&&y(A.transmissionMap.channel),thicknessMapUv:le&&y(A.thicknessMap.channel),alphaMapUv:we&&y(A.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||G),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!W.attributes.uv&&(z||we),fog:!!H,useFog:A.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:O.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:fe,numDirLights:S.directional.length,numPointLights:S.point.length,numSpotLights:S.spot.length,numSpotLightMaps:S.spotLightMap.length,numRectAreaLights:S.rectArea.length,numHemiLights:S.hemi.length,numDirLightShadows:S.directionalShadowMap.length,numPointLightShadows:S.pointShadowMap.length,numSpotLightShadows:S.spotShadowMap.length,numSpotLightShadowsWithMaps:S.numSpotLightShadowsWithMaps,numLightProbes:S.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:n.shadowMap.enabled&&P.length>0,shadowMapType:n.shadowMap.type,toneMapping:ft,useLegacyLights:n._useLegacyLights,decodeVideoTexture:z&&A.map.isVideoTexture===!0&&dt.getTransfer(A.map.colorSpace)===yt,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Hn,flipSided:A.side===nn,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:tt&&A.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:tt&&A.extensions.multiDraw===!0&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt}function m(A){let S=[];if(A.shaderID?S.push(A.shaderID):(S.push(A.customVertexShaderID),S.push(A.customFragmentShaderID)),A.defines!==void 0)for(let P in A.defines)S.push(P),S.push(A.defines[P]);return A.isRawShaderMaterial===!1&&(x(S,A),v(S,A),S.push(n.outputColorSpace)),S.push(A.customProgramCacheKey),S.join()}function x(A,S){A.push(S.precision),A.push(S.outputColorSpace),A.push(S.envMapMode),A.push(S.envMapCubeUVHeight),A.push(S.mapUv),A.push(S.alphaMapUv),A.push(S.lightMapUv),A.push(S.aoMapUv),A.push(S.bumpMapUv),A.push(S.normalMapUv),A.push(S.displacementMapUv),A.push(S.emissiveMapUv),A.push(S.metalnessMapUv),A.push(S.roughnessMapUv),A.push(S.anisotropyMapUv),A.push(S.clearcoatMapUv),A.push(S.clearcoatNormalMapUv),A.push(S.clearcoatRoughnessMapUv),A.push(S.iridescenceMapUv),A.push(S.iridescenceThicknessMapUv),A.push(S.sheenColorMapUv),A.push(S.sheenRoughnessMapUv),A.push(S.specularMapUv),A.push(S.specularColorMapUv),A.push(S.specularIntensityMapUv),A.push(S.transmissionMapUv),A.push(S.thicknessMapUv),A.push(S.combine),A.push(S.fogExp2),A.push(S.sizeAttenuation),A.push(S.morphTargetsCount),A.push(S.morphAttributeCount),A.push(S.numDirLights),A.push(S.numPointLights),A.push(S.numSpotLights),A.push(S.numSpotLightMaps),A.push(S.numHemiLights),A.push(S.numRectAreaLights),A.push(S.numDirLightShadows),A.push(S.numPointLightShadows),A.push(S.numSpotLightShadows),A.push(S.numSpotLightShadowsWithMaps),A.push(S.numLightProbes),A.push(S.shadowMapType),A.push(S.toneMapping),A.push(S.numClippingPlanes),A.push(S.numClipIntersection),A.push(S.depthPacking)}function v(A,S){a.disableAll(),S.supportsVertexTextures&&a.enable(0),S.instancing&&a.enable(1),S.instancingColor&&a.enable(2),S.instancingMorph&&a.enable(3),S.matcap&&a.enable(4),S.envMap&&a.enable(5),S.normalMapObjectSpace&&a.enable(6),S.normalMapTangentSpace&&a.enable(7),S.clearcoat&&a.enable(8),S.iridescence&&a.enable(9),S.alphaTest&&a.enable(10),S.vertexColors&&a.enable(11),S.vertexAlphas&&a.enable(12),S.vertexUv1s&&a.enable(13),S.vertexUv2s&&a.enable(14),S.vertexUv3s&&a.enable(15),S.vertexTangents&&a.enable(16),S.anisotropy&&a.enable(17),S.alphaHash&&a.enable(18),S.batching&&a.enable(19),S.dispersion&&a.enable(20),A.push(a.mask),a.disableAll(),S.fog&&a.enable(0),S.useFog&&a.enable(1),S.flatShading&&a.enable(2),S.logarithmicDepthBuffer&&a.enable(3),S.skinning&&a.enable(4),S.morphTargets&&a.enable(5),S.morphNormals&&a.enable(6),S.morphColors&&a.enable(7),S.premultipliedAlpha&&a.enable(8),S.shadowMapEnabled&&a.enable(9),S.useLegacyLights&&a.enable(10),S.doubleSided&&a.enable(11),S.flipSided&&a.enable(12),S.useDepthPacking&&a.enable(13),S.dithering&&a.enable(14),S.transmission&&a.enable(15),S.sheen&&a.enable(16),S.opaque&&a.enable(17),S.pointsUvs&&a.enable(18),S.decodeVideoTexture&&a.enable(19),S.alphaToCoverage&&a.enable(20),A.push(a.mask)}function w(A){let S=p[A.type],P;if(S){let k=On[S];P=pv.clone(k.uniforms)}else P=A.uniforms;return P}function N(A,S){let P;for(let k=0,O=u.length;k<O;k++){let H=u[k];if(H.cacheKey===S){P=H,++P.usedTimes;break}}return P===void 0&&(P=new JT(n,S,A,s),u.push(P)),P}function C(A){if(--A.usedTimes===0){let S=u.indexOf(A);u[S]=u[u.length-1],u.pop(),A.destroy()}}function R(A){c.remove(A)}function F(){c.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:w,acquireProgram:N,releaseProgram:C,releaseShaderCache:R,programs:u,dispose:F}}function eI(){let n=new WeakMap;function e(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function t(s){n.delete(s)}function i(s,o,a){n.get(s)[o]=a}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function tI(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function ly(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function uy(){let n=[],e=0,t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function o(d,h,f,p,y,g){let m=n[e];return m===void 0?(m={id:d.id,object:d,geometry:h,material:f,groupOrder:p,renderOrder:d.renderOrder,z:y,group:g},n[e]=m):(m.id=d.id,m.object=d,m.geometry=h,m.material=f,m.groupOrder=p,m.renderOrder=d.renderOrder,m.z=y,m.group=g),e++,m}function a(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.push(m):f.transparent===!0?r.push(m):t.push(m)}function c(d,h,f,p,y,g){let m=o(d,h,f,p,y,g);f.transmission>0?i.unshift(m):f.transparent===!0?r.unshift(m):t.unshift(m)}function l(d,h){t.length>1&&t.sort(d||tI),i.length>1&&i.sort(h||ly),r.length>1&&r.sort(h||ly)}function u(){for(let d=e,h=n.length;d<h;d++){let f=n[d];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function nI(){let n=new WeakMap;function e(i,r){let s=n.get(i),o;return s===void 0?(o=new uy,n.set(i,[o])):r>=s.length?(o=new uy,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function iI(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new Ie};break;case"SpotLight":t={position:new D,direction:new D,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new D,halfWidth:new D,halfHeight:new D};break}return n[e.id]=t,t}}}function rI(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}function oI(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function aI(n){let e=new iI,t=rI(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);let r=new D,s=new Ve,o=new Ve;function a(l,u){let d=0,h=0,f=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let p=0,y=0,g=0,m=0,x=0,v=0,w=0,N=0,C=0,R=0,F=0;l.sort(oI);let A=u===!0?Math.PI:1;for(let P=0,k=l.length;P<k;P++){let O=l[P],H=O.color,W=O.intensity,J=O.distance,ae=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)d+=H.r*W*A,h+=H.g*W*A,f+=H.b*W*A;else if(O.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(O.sh.coefficients[B],W);F++}else if(O.isDirectionalLight){let B=e.get(O);if(B.color.copy(O.color).multiplyScalar(O.intensity*A),O.castShadow){let ne=O.shadow,ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,i.directionalShadow[p]=ce,i.directionalShadowMap[p]=ae,i.directionalShadowMatrix[p]=O.shadow.matrix,v++}i.directional[p]=B,p++}else if(O.isSpotLight){let B=e.get(O);B.position.setFromMatrixPosition(O.matrixWorld),B.color.copy(H).multiplyScalar(W*A),B.distance=J,B.coneCos=Math.cos(O.angle),B.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),B.decay=O.decay,i.spot[g]=B;let ne=O.shadow;if(O.map&&(i.spotLightMap[C]=O.map,C++,ne.updateMatrices(O),O.castShadow&&R++),i.spotLightMatrix[g]=ne.matrix,O.castShadow){let ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,i.spotShadow[g]=ce,i.spotShadowMap[g]=ae,N++}g++}else if(O.isRectAreaLight){let B=e.get(O);B.color.copy(H).multiplyScalar(W),B.halfWidth.set(O.width*.5,0,0),B.halfHeight.set(0,O.height*.5,0),i.rectArea[m]=B,m++}else if(O.isPointLight){let B=e.get(O);if(B.color.copy(O.color).multiplyScalar(O.intensity*A),B.distance=O.distance,B.decay=O.decay,O.castShadow){let ne=O.shadow,ce=t.get(O);ce.shadowBias=ne.bias,ce.shadowNormalBias=ne.normalBias,ce.shadowRadius=ne.radius,ce.shadowMapSize=ne.mapSize,ce.shadowCameraNear=ne.camera.near,ce.shadowCameraFar=ne.camera.far,i.pointShadow[y]=ce,i.pointShadowMap[y]=ae,i.pointShadowMatrix[y]=O.shadow.matrix,w++}i.point[y]=B,y++}else if(O.isHemisphereLight){let B=e.get(O);B.skyColor.copy(O.color).multiplyScalar(W*A),B.groundColor.copy(O.groundColor).multiplyScalar(W*A),i.hemi[x]=B,x++}}m>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ee.LTC_FLOAT_1,i.rectAreaLTC2=Ee.LTC_FLOAT_2):(i.rectAreaLTC1=Ee.LTC_HALF_1,i.rectAreaLTC2=Ee.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=h,i.ambient[2]=f;let S=i.hash;(S.directionalLength!==p||S.pointLength!==y||S.spotLength!==g||S.rectAreaLength!==m||S.hemiLength!==x||S.numDirectionalShadows!==v||S.numPointShadows!==w||S.numSpotShadows!==N||S.numSpotMaps!==C||S.numLightProbes!==F)&&(i.directional.length=p,i.spot.length=g,i.rectArea.length=m,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=N,i.spotShadowMap.length=N,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=N+C-R,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=F,S.directionalLength=p,S.pointLength=y,S.spotLength=g,S.rectAreaLength=m,S.hemiLength=x,S.numDirectionalShadows=v,S.numPointShadows=w,S.numSpotShadows=N,S.numSpotMaps=C,S.numLightProbes=F,i.version=sI++)}function c(l,u){let d=0,h=0,f=0,p=0,y=0,g=u.matrixWorldInverse;for(let m=0,x=l.length;m<x;m++){let v=l[m];if(v.isDirectionalLight){let w=i.directional[d];w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),d++}else if(v.isSpotLight){let w=i.spot[f];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),w.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(g),f++}else if(v.isRectAreaLight){let w=i.rectArea[p];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),o.identity(),s.copy(v.matrixWorld),s.premultiply(g),o.extractRotation(s),w.halfWidth.set(v.width*.5,0,0),w.halfHeight.set(0,v.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),p++}else if(v.isPointLight){let w=i.point[h];w.position.setFromMatrixPosition(v.matrixWorld),w.position.applyMatrix4(g),h++}else if(v.isHemisphereLight){let w=i.hemi[y];w.direction.setFromMatrixPosition(v.matrixWorld),w.direction.transformDirection(g),y++}}}return{setup:a,setupView:c,state:i}}function dy(n){let e=new aI(n),t=[],i=[];function r(u){l.camera=u,t.length=0,i.length=0}function s(u){t.push(u)}function o(u){i.push(u)}function a(u){e.setup(t,u)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function cI(n){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new dy(n),e.set(r,[a])):s>=o.length?(a=new dy(n),o.push(a)):a=o[s],a}function i(){e=new WeakMap}return{get:t,dispose:i}}function dI(n,e,t){let i=new zr,r=new se,s=new se,o=new ht,a=new ha({depthPacking:ev}),c=new fa,l={},u=t.maxTextureSize,d={[xi]:nn,[nn]:xi,[Hn]:Hn},h=new pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new se},radius:{value:4}},vertexShader:lI,fragmentShader:uI}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let p=new et;p.setAttribute("position",new ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new St(p,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vp;let m=this.type;this.render=function(C,R,F){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||C.length===0)return;let A=n.getRenderTarget(),S=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),k=n.state;k.setBlending(gi),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);let O=m!==Vn&&this.type===Vn,H=m===Vn&&this.type!==Vn;for(let W=0,J=C.length;W<J;W++){let ae=C[W],B=ae.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;r.copy(B.mapSize);let ne=B.getFrameExtents();if(r.multiply(ne),s.copy(B.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ne.x),r.x=s.x*ne.x,B.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ne.y),r.y=s.y*ne.y,B.mapSize.y=s.y)),B.map===null||O===!0||H===!0){let Me=this.type!==Vn?{minFilter:Ut,magFilter:Ut}:{};B.map!==null&&B.map.dispose(),B.map=new hn(r.x,r.y,Me),B.map.texture.name=ae.name+".shadowMap",B.camera.updateProjectionMatrix()}n.setRenderTarget(B.map),n.clear();let ce=B.getViewportCount();for(let Me=0;Me<ce;Me++){let fe=B.getViewport(Me);o.set(s.x*fe.x,s.y*fe.y,s.x*fe.z,s.y*fe.w),k.viewport(o),B.updateMatrices(ae,Me),i=B.getFrustum(),w(R,F,B.camera,ae,this.type)}B.isPointLightShadow!==!0&&this.type===Vn&&x(B,F),B.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(A,S,P)};function x(C,R){let F=e.update(y);h.defines.VSM_SAMPLES!==C.blurSamples&&(h.defines.VSM_SAMPLES=C.blurSamples,f.defines.VSM_SAMPLES=C.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new hn(r.x,r.y)),h.uniforms.shadow_pass.value=C.map.texture,h.uniforms.resolution.value=C.mapSize,h.uniforms.radius.value=C.radius,n.setRenderTarget(C.mapPass),n.clear(),n.renderBufferDirect(R,null,F,h,y,null),f.uniforms.shadow_pass.value=C.mapPass.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,n.setRenderTarget(C.map),n.clear(),n.renderBufferDirect(R,null,F,f,y,null)}function v(C,R,F,A){let S=null,P=F.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(P!==void 0)S=P;else if(S=F.isPointLight===!0?c:a,n.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){let k=S.uuid,O=R.uuid,H=l[k];H===void 0&&(H={},l[k]=H);let W=H[O];W===void 0&&(W=S.clone(),H[O]=W,R.addEventListener("dispose",N)),S=W}if(S.visible=R.visible,S.wireframe=R.wireframe,A===Vn?S.side=R.shadowSide!==null?R.shadowSide:R.side:S.side=R.shadowSide!==null?R.shadowSide:d[R.side],S.alphaMap=R.alphaMap,S.alphaTest=R.alphaTest,S.map=R.map,S.clipShadows=R.clipShadows,S.clippingPlanes=R.clippingPlanes,S.clipIntersection=R.clipIntersection,S.displacementMap=R.displacementMap,S.displacementScale=R.displacementScale,S.displacementBias=R.displacementBias,S.wireframeLinewidth=R.wireframeLinewidth,S.linewidth=R.linewidth,F.isPointLight===!0&&S.isMeshDistanceMaterial===!0){let k=n.properties.get(S);k.light=F}return S}function w(C,R,F,A,S){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&S===Vn)&&(!C.frustumCulled||i.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,C.matrixWorld);let O=e.update(C),H=C.material;if(Array.isArray(H)){let W=O.groups;for(let J=0,ae=W.length;J<ae;J++){let B=W[J],ne=H[B.materialIndex];if(ne&&ne.visible){let ce=v(C,ne,A,S);C.onBeforeShadow(n,C,R,F,O,ce,B),n.renderBufferDirect(F,null,O,ce,C,B),C.onAfterShadow(n,C,R,F,O,ce,B)}}}else if(H.visible){let W=v(C,H,A,S);C.onBeforeShadow(n,C,R,F,O,W,null),n.renderBufferDirect(F,null,O,W,C,null),C.onAfterShadow(n,C,R,F,O,W,null)}}let k=C.children;for(let O=0,H=k.length;O<H;O++)w(k[O],R,F,A,S)}function N(C){C.target.removeEventListener("dispose",N);for(let F in l){let A=l[F],S=C.target.uuid;S in A&&(A[S].dispose(),delete A[S])}}}function hI(n){function e(){let V=!1,le=new ht,K=null,we=new ht(0,0,0,0);return{setMask:function(Ae){K!==Ae&&!V&&(n.colorMask(Ae,Ae,Ae,Ae),K=Ae)},setLocked:function(Ae){V=Ae},setClear:function(Ae,Re,tt,ft,vt){vt===!0&&(Ae*=ft,Re*=ft,tt*=ft),le.set(Ae,Re,tt,ft),we.equals(le)===!1&&(n.clearColor(Ae,Re,tt,ft),we.copy(le))},reset:function(){V=!1,K=null,we.set(-1,0,0,0)}}}function t(){let V=!1,le=null,K=null,we=null;return{setTest:function(Ae){Ae?te(n.DEPTH_TEST):ue(n.DEPTH_TEST)},setMask:function(Ae){le!==Ae&&!V&&(n.depthMask(Ae),le=Ae)},setFunc:function(Ae){if(K!==Ae){switch(Ae){case S0:n.depthFunc(n.NEVER);break;case E0:n.depthFunc(n.ALWAYS);break;case A0:n.depthFunc(n.LESS);break;case Xo:n.depthFunc(n.LEQUAL);break;case T0:n.depthFunc(n.EQUAL);break;case I0:n.depthFunc(n.GEQUAL);break;case C0:n.depthFunc(n.GREATER);break;case R0:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}K=Ae}},setLocked:function(Ae){V=Ae},setClear:function(Ae){we!==Ae&&(n.clearDepth(Ae),we=Ae)},reset:function(){V=!1,le=null,K=null,we=null}}}function i(){let V=!1,le=null,K=null,we=null,Ae=null,Re=null,tt=null,ft=null,vt=null;return{setTest:function(rt){V||(rt?te(n.STENCIL_TEST):ue(n.STENCIL_TEST))},setMask:function(rt){le!==rt&&!V&&(n.stencilMask(rt),le=rt)},setFunc:function(rt,$t,Et){(K!==rt||we!==$t||Ae!==Et)&&(n.stencilFunc(rt,$t,Et),K=rt,we=$t,Ae=Et)},setOp:function(rt,$t,Et){(Re!==rt||tt!==$t||ft!==Et)&&(n.stencilOp(rt,$t,Et),Re=rt,tt=$t,ft=Et)},setLocked:function(rt){V=rt},setClear:function(rt){vt!==rt&&(n.clearStencil(rt),vt=rt)},reset:function(){V=!1,le=null,K=null,we=null,Ae=null,Re=null,tt=null,ft=null,vt=null}}}let r=new e,s=new t,o=new i,a=new WeakMap,c=new WeakMap,l={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,w=null,N=null,C=new Ie(0,0,0),R=0,F=!1,A=null,S=null,P=null,k=null,O=null,H=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,J=0,ae=n.getParameter(n.VERSION);ae.indexOf("WebGL")!==-1?(J=parseFloat(/^WebGL (\d)/.exec(ae)[1]),W=J>=1):ae.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),W=J>=2);let B=null,ne={},ce=n.getParameter(n.SCISSOR_BOX),Me=n.getParameter(n.VIEWPORT),fe=new ht().fromArray(ce),$e=new ht().fromArray(Me);function Y(V,le,K,we){let Ae=new Uint8Array(4),Re=n.createTexture();n.bindTexture(V,Re),n.texParameteri(V,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(V,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let tt=0;tt<K;tt++)V===n.TEXTURE_3D||V===n.TEXTURE_2D_ARRAY?n.texImage3D(le,0,n.RGBA,1,1,we,0,n.RGBA,n.UNSIGNED_BYTE,Ae):n.texImage2D(le+tt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ae);return Re}let me={};me[n.TEXTURE_2D]=Y(n.TEXTURE_2D,n.TEXTURE_2D,1),me[n.TEXTURE_CUBE_MAP]=Y(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[n.TEXTURE_2D_ARRAY]=Y(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),me[n.TEXTURE_3D]=Y(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),te(n.DEPTH_TEST),s.setFunc(Xo),he(!1),ie(_h),te(n.CULL_FACE),de(gi);function te(V){l[V]!==!0&&(n.enable(V),l[V]=!0)}function ue(V){l[V]!==!1&&(n.disable(V),l[V]=!1)}function Pe(V,le){return u[V]!==le?(n.bindFramebuffer(V,le),u[V]=le,V===n.DRAW_FRAMEBUFFER&&(u[n.FRAMEBUFFER]=le),V===n.FRAMEBUFFER&&(u[n.DRAW_FRAMEBUFFER]=le),!0):!1}function _e(V,le){let K=h,we=!1;if(V){K=d.get(le),K===void 0&&(K=[],d.set(le,K));let Ae=V.textures;if(K.length!==Ae.length||K[0]!==n.COLOR_ATTACHMENT0){for(let Re=0,tt=Ae.length;Re<tt;Re++)K[Re]=n.COLOR_ATTACHMENT0+Re;K.length=Ae.length,we=!0}}else K[0]!==n.BACK&&(K[0]=n.BACK,we=!0);we&&n.drawBuffers(K)}function z(V){return f!==V?(n.useProgram(V),f=V,!0):!1}let Be={[ji]:n.FUNC_ADD,[a0]:n.FUNC_SUBTRACT,[c0]:n.FUNC_REVERSE_SUBTRACT};Be[l0]=n.MIN,Be[u0]=n.MAX;let X={[d0]:n.ZERO,[h0]:n.ONE,[f0]:n.SRC_COLOR,[El]:n.SRC_ALPHA,[x0]:n.SRC_ALPHA_SATURATE,[y0]:n.DST_COLOR,[m0]:n.DST_ALPHA,[p0]:n.ONE_MINUS_SRC_COLOR,[Al]:n.ONE_MINUS_SRC_ALPHA,[v0]:n.ONE_MINUS_DST_COLOR,[g0]:n.ONE_MINUS_DST_ALPHA,[b0]:n.CONSTANT_COLOR,[_0]:n.ONE_MINUS_CONSTANT_COLOR,[w0]:n.CONSTANT_ALPHA,[M0]:n.ONE_MINUS_CONSTANT_ALPHA};function de(V,le,K,we,Ae,Re,tt,ft,vt,rt){if(V===gi){p===!0&&(ue(n.BLEND),p=!1);return}if(p===!1&&(te(n.BLEND),p=!0),V!==o0){if(V!==y||rt!==F){if((g!==ji||v!==ji)&&(n.blendEquation(n.FUNC_ADD),g=ji,v=ji),rt)switch(V){case Or:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.ONE,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}else switch(V){case Or:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case wh:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case Mh:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Sh:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",V);break}m=null,x=null,w=null,N=null,C.set(0,0,0),R=0,y=V,F=rt}return}Ae=Ae||le,Re=Re||K,tt=tt||we,(le!==g||Ae!==v)&&(n.blendEquationSeparate(Be[le],Be[Ae]),g=le,v=Ae),(K!==m||we!==x||Re!==w||tt!==N)&&(n.blendFuncSeparate(X[K],X[we],X[Re],X[tt]),m=K,x=we,w=Re,N=tt),(ft.equals(C)===!1||vt!==R)&&(n.blendColor(ft.r,ft.g,ft.b,vt),C.copy(ft),R=vt),y=V,F=!1}function Z(V,le){V.side===Hn?ue(n.CULL_FACE):te(n.CULL_FACE);let K=V.side===nn;le&&(K=!K),he(K),V.blending===Or&&V.transparent===!1?de(gi):de(V.blending,V.blendEquation,V.blendSrc,V.blendDst,V.blendEquationAlpha,V.blendSrcAlpha,V.blendDstAlpha,V.blendColor,V.blendAlpha,V.premultipliedAlpha),s.setFunc(V.depthFunc),s.setTest(V.depthTest),s.setMask(V.depthWrite),r.setMask(V.colorWrite);let we=V.stencilWrite;o.setTest(we),we&&(o.setMask(V.stencilWriteMask),o.setFunc(V.stencilFunc,V.stencilRef,V.stencilFuncMask),o.setOp(V.stencilFail,V.stencilZFail,V.stencilZPass)),Te(V.polygonOffset,V.polygonOffsetFactor,V.polygonOffsetUnits),V.alphaToCoverage===!0?te(n.SAMPLE_ALPHA_TO_COVERAGE):ue(n.SAMPLE_ALPHA_TO_COVERAGE)}function he(V){A!==V&&(V?n.frontFace(n.CW):n.frontFace(n.CCW),A=V)}function ie(V){V!==i0?(te(n.CULL_FACE),V!==S&&(V===_h?n.cullFace(n.BACK):V===r0?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ue(n.CULL_FACE),S=V}function ye(V){V!==P&&(W&&n.lineWidth(V),P=V)}function Te(V,le,K){V?(te(n.POLYGON_OFFSET_FILL),(k!==le||O!==K)&&(n.polygonOffset(le,K),k=le,O=K)):ue(n.POLYGON_OFFSET_FILL)}function U(V){V?te(n.SCISSOR_TEST):ue(n.SCISSOR_TEST)}function T(V){V===void 0&&(V=n.TEXTURE0+H-1),B!==V&&(n.activeTexture(V),B=V)}function G(V,le,K){K===void 0&&(B===null?K=n.TEXTURE0+H-1:K=B);let we=ne[K];we===void 0&&(we={type:void 0,texture:void 0},ne[K]=we),(we.type!==V||we.texture!==le)&&(B!==K&&(n.activeTexture(K),B=K),n.bindTexture(V,le||me[V]),we.type=V,we.texture=le)}function ee(){let V=ne[B];V!==void 0&&V.type!==void 0&&(n.bindTexture(V.type,null),V.type=void 0,V.texture=void 0)}function oe(){try{n.compressedTexImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function re(){try{n.compressedTexImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ue(){try{n.texSubImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function ve(){try{n.texSubImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function xe(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function He(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function pe(){try{n.texStorage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Oe(){try{n.texStorage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function qe(){try{n.texImage2D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ne(){try{n.texImage3D.apply(n,arguments)}catch(V){console.error("THREE.WebGLState:",V)}}function Ce(V){fe.equals(V)===!1&&(n.scissor(V.x,V.y,V.z,V.w),fe.copy(V))}function Fe(V){$e.equals(V)===!1&&(n.viewport(V.x,V.y,V.z,V.w),$e.copy(V))}function Qe(V,le){let K=c.get(le);K===void 0&&(K=new WeakMap,c.set(le,K));let we=K.get(V);we===void 0&&(we=n.getUniformBlockIndex(le,V.name),K.set(V,we))}function pt(V,le){let we=c.get(le).get(V);a.get(le)!==we&&(n.uniformBlockBinding(le,we,V.__bindingPointIndex),a.set(le,we))}function je(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),l={},B=null,ne={},u={},d=new WeakMap,h=[],f=null,p=!1,y=null,g=null,m=null,x=null,v=null,w=null,N=null,C=new Ie(0,0,0),R=0,F=!1,A=null,S=null,P=null,k=null,O=null,fe.set(0,0,n.canvas.width,n.canvas.height),$e.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:te,disable:ue,bindFramebuffer:Pe,drawBuffers:_e,useProgram:z,setBlending:de,setMaterial:Z,setFlipSided:he,setCullFace:ie,setLineWidth:ye,setPolygonOffset:Te,setScissorTest:U,activeTexture:T,bindTexture:G,unbindTexture:ee,compressedTexImage2D:oe,compressedTexImage3D:re,texImage2D:qe,texImage3D:Ne,updateUBOMapping:Qe,uniformBlockBinding:pt,texStorage2D:pe,texStorage3D:Oe,texSubImage2D:Ue,texSubImage3D:ve,compressedTexSubImage2D:xe,compressedTexSubImage3D:He,scissor:Ce,viewport:Fe,reset:je}}function fI(n,e,t,i,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new se,u=new WeakMap,d,h=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(U,T){return f?new OffscreenCanvas(U,T):oa("canvas")}function y(U,T,G){let ee=1,oe=Te(U);if((oe.width>G||oe.height>G)&&(ee=G/Math.max(oe.width,oe.height)),ee<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){let re=Math.floor(ee*oe.width),Ue=Math.floor(ee*oe.height);d===void 0&&(d=p(re,Ue));let ve=T?p(re,Ue):d;return ve.width=re,ve.height=Ue,ve.getContext("2d").drawImage(U,0,0,re,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+oe.width+"x"+oe.height+") to ("+re+"x"+Ue+")."),ve}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+oe.width+"x"+oe.height+")."),U;return U}function g(U){return U.generateMipmaps&&U.minFilter!==Ut&&U.minFilter!==It}function m(U){n.generateMipmap(U)}function x(U,T,G,ee,oe=!1){if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let re=T;if(T===n.RED&&(G===n.FLOAT&&(re=n.R32F),G===n.HALF_FLOAT&&(re=n.R16F),G===n.UNSIGNED_BYTE&&(re=n.R8)),T===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(re=n.R8UI),G===n.UNSIGNED_SHORT&&(re=n.R16UI),G===n.UNSIGNED_INT&&(re=n.R32UI),G===n.BYTE&&(re=n.R8I),G===n.SHORT&&(re=n.R16I),G===n.INT&&(re=n.R32I)),T===n.RG&&(G===n.FLOAT&&(re=n.RG32F),G===n.HALF_FLOAT&&(re=n.RG16F),G===n.UNSIGNED_BYTE&&(re=n.RG8)),T===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(re=n.RG8UI),G===n.UNSIGNED_SHORT&&(re=n.RG16UI),G===n.UNSIGNED_INT&&(re=n.RG32UI),G===n.BYTE&&(re=n.RG8I),G===n.SHORT&&(re=n.RG16I),G===n.INT&&(re=n.RG32I)),T===n.RGB&&G===n.UNSIGNED_INT_5_9_9_9_REV&&(re=n.RGB9_E5),T===n.RGBA){let Ue=oe?ta:dt.getTransfer(ee);G===n.FLOAT&&(re=n.RGBA32F),G===n.HALF_FLOAT&&(re=n.RGBA16F),G===n.UNSIGNED_BYTE&&(re=Ue===yt?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT_4_4_4_4&&(re=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(re=n.RGB5_A1)}return(re===n.R16F||re===n.R32F||re===n.RG16F||re===n.RG32F||re===n.RGBA16F||re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),re}function v(U,T){return g(U)===!0||U.isFramebufferTexture&&U.minFilter!==Ut&&U.minFilter!==It?Math.log2(Math.max(T.width,T.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?T.mipmaps.length:1}function w(U){let T=U.target;T.removeEventListener("dispose",w),C(T),T.isVideoTexture&&u.delete(T)}function N(U){let T=U.target;T.removeEventListener("dispose",N),F(T)}function C(U){let T=i.get(U);if(T.__webglInit===void 0)return;let G=U.source,ee=h.get(G);if(ee){let oe=ee[T.__cacheKey];oe.usedTimes--,oe.usedTimes===0&&R(U),Object.keys(ee).length===0&&h.delete(G)}i.remove(U)}function R(U){let T=i.get(U);n.deleteTexture(T.__webglTexture);let G=U.source,ee=h.get(G);delete ee[T.__cacheKey],o.memory.textures--}function F(U){let T=i.get(U);if(U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(T.__webglFramebuffer[ee]))for(let oe=0;oe<T.__webglFramebuffer[ee].length;oe++)n.deleteFramebuffer(T.__webglFramebuffer[ee][oe]);else n.deleteFramebuffer(T.__webglFramebuffer[ee]);T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer[ee])}else{if(Array.isArray(T.__webglFramebuffer))for(let ee=0;ee<T.__webglFramebuffer.length;ee++)n.deleteFramebuffer(T.__webglFramebuffer[ee]);else n.deleteFramebuffer(T.__webglFramebuffer);if(T.__webglDepthbuffer&&n.deleteRenderbuffer(T.__webglDepthbuffer),T.__webglMultisampledFramebuffer&&n.deleteFramebuffer(T.__webglMultisampledFramebuffer),T.__webglColorRenderbuffer)for(let ee=0;ee<T.__webglColorRenderbuffer.length;ee++)T.__webglColorRenderbuffer[ee]&&n.deleteRenderbuffer(T.__webglColorRenderbuffer[ee]);T.__webglDepthRenderbuffer&&n.deleteRenderbuffer(T.__webglDepthRenderbuffer)}let G=U.textures;for(let ee=0,oe=G.length;ee<oe;ee++){let re=i.get(G[ee]);re.__webglTexture&&(n.deleteTexture(re.__webglTexture),o.memory.textures--),i.remove(G[ee])}i.remove(U)}let A=0;function S(){A=0}function P(){let U=A;return U>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+r.maxTextures),A+=1,U}function k(U){let T=[];return T.push(U.wrapS),T.push(U.wrapT),T.push(U.wrapR||0),T.push(U.magFilter),T.push(U.minFilter),T.push(U.anisotropy),T.push(U.internalFormat),T.push(U.format),T.push(U.type),T.push(U.generateMipmaps),T.push(U.premultiplyAlpha),T.push(U.flipY),T.push(U.unpackAlignment),T.push(U.colorSpace),T.join()}function O(U,T){let G=i.get(U);if(U.isVideoTexture&&ie(U),U.isRenderTargetTexture===!1&&U.version>0&&G.__version!==U.version){let ee=U.image;if(ee===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ee.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{fe(G,U,T);return}}t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+T)}function H(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){fe(G,U,T);return}t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+T)}function W(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){fe(G,U,T);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+T)}function J(U,T){let G=i.get(U);if(U.version>0&&G.__version!==U.version){$e(G,U,T);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+T)}let ae={[Zo]:n.REPEAT,[Sn]:n.CLAMP_TO_EDGE,[Jo]:n.MIRRORED_REPEAT},B={[Ut]:n.NEAREST,[xp]:n.NEAREST_MIPMAP_NEAREST,[Os]:n.NEAREST_MIPMAP_LINEAR,[It]:n.LINEAR,[$o]:n.LINEAR_MIPMAP_NEAREST,[jn]:n.LINEAR_MIPMAP_LINEAR},ne={[nv]:n.NEVER,[cv]:n.ALWAYS,[iv]:n.LESS,[Cp]:n.LEQUAL,[rv]:n.EQUAL,[av]:n.GEQUAL,[sv]:n.GREATER,[ov]:n.NOTEQUAL};function ce(U,T){if(T.type===En&&e.has("OES_texture_float_linear")===!1&&(T.magFilter===It||T.magFilter===$o||T.magFilter===Os||T.magFilter===jn||T.minFilter===It||T.minFilter===$o||T.minFilter===Os||T.minFilter===jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(U,n.TEXTURE_WRAP_S,ae[T.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,ae[T.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,ae[T.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,B[T.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,B[T.minFilter]),T.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,ne[T.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(T.magFilter===Ut||T.minFilter!==Os&&T.minFilter!==jn||T.type===En&&e.has("OES_texture_float_linear")===!1)return;if(T.anisotropy>1||i.get(T).__currentAnisotropy){let G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(U,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(T.anisotropy,r.getMaxAnisotropy())),i.get(T).__currentAnisotropy=T.anisotropy}}}function Me(U,T){let G=!1;U.__webglInit===void 0&&(U.__webglInit=!0,T.addEventListener("dispose",w));let ee=T.source,oe=h.get(ee);oe===void 0&&(oe={},h.set(ee,oe));let re=k(T);if(re!==U.__cacheKey){oe[re]===void 0&&(oe[re]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,G=!0),oe[re].usedTimes++;let Ue=oe[U.__cacheKey];Ue!==void 0&&(oe[U.__cacheKey].usedTimes--,Ue.usedTimes===0&&R(T)),U.__cacheKey=re,U.__webglTexture=oe[re].texture}return G}function fe(U,T,G){let ee=n.TEXTURE_2D;(T.isDataArrayTexture||T.isCompressedArrayTexture)&&(ee=n.TEXTURE_2D_ARRAY),T.isData3DTexture&&(ee=n.TEXTURE_3D);let oe=Me(U,T),re=T.source;t.bindTexture(ee,U.__webglTexture,n.TEXTURE0+G);let Ue=i.get(re);if(re.version!==Ue.__version||oe===!0){t.activeTexture(n.TEXTURE0+G);let ve=dt.getPrimaries(dt.workingColorSpace),xe=T.colorSpace===di?null:dt.getPrimaries(T.colorSpace),He=T.colorSpace===di||ve===xe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,T.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,T.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,He);let pe=y(T.image,!1,r.maxTextureSize);pe=ye(T,pe);let Oe=s.convert(T.format,T.colorSpace),qe=s.convert(T.type),Ne=x(T.internalFormat,Oe,qe,T.colorSpace,T.isVideoTexture);ce(ee,T);let Ce,Fe=T.mipmaps,Qe=T.isVideoTexture!==!0,pt=Ue.__version===void 0||oe===!0,je=re.dataReady,V=v(T,pe);if(T.isDepthTexture)Ne=n.DEPTH_COMPONENT16,T.type===En?Ne=n.DEPTH_COMPONENT32F:T.type===Fr?Ne=n.DEPTH_COMPONENT24:T.type===Qs&&(Ne=n.DEPTH24_STENCIL8),pt&&(Qe?t.texStorage2D(n.TEXTURE_2D,1,Ne,pe.width,pe.height):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,null));else if(T.isDataTexture)if(Fe.length>0){Qe&&pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,Fe[0].width,Fe[0].height);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,qe,Ce.data):t.texImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Oe,qe,Ce.data);T.generateMipmaps=!1}else Qe?(pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,pe.width,pe.height),je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,pe.width,pe.height,Oe,qe,pe.data)):t.texImage2D(n.TEXTURE_2D,0,Ne,pe.width,pe.height,0,Oe,qe,pe.data);else if(T.isCompressedTexture)if(T.isCompressedArrayTexture){Qe&&pt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,V,Ne,Fe[0].width,Fe[0].height,pe.depth);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],T.format!==un?Oe!==null?Qe?je&&t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,Ce.width,Ce.height,pe.depth,Oe,Ce.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,le,Ne,Ce.width,Ce.height,pe.depth,0,Ce.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,le,0,0,0,Ce.width,Ce.height,pe.depth,Oe,qe,Ce.data):t.texImage3D(n.TEXTURE_2D_ARRAY,le,Ne,Ce.width,Ce.height,pe.depth,0,Oe,qe,Ce.data)}else{Qe&&pt&&t.texStorage2D(n.TEXTURE_2D,V,Ne,Fe[0].width,Fe[0].height);for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],T.format!==un?Oe!==null?Qe?je&&t.compressedTexSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,Ce.data):t.compressedTexImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Ce.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Ce.width,Ce.height,Oe,qe,Ce.data):t.texImage2D(n.TEXTURE_2D,le,Ne,Ce.width,Ce.height,0,Oe,qe,Ce.data)}else if(T.isDataArrayTexture)Qe?(pt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,V,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(T.isData3DTexture)Qe?(pt&&t.texStorage3D(n.TEXTURE_3D,V,Ne,pe.width,pe.height,pe.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,pe.width,pe.height,pe.depth,Oe,qe,pe.data)):t.texImage3D(n.TEXTURE_3D,0,Ne,pe.width,pe.height,pe.depth,0,Oe,qe,pe.data);else if(T.isFramebufferTexture){if(pt)if(Qe)t.texStorage2D(n.TEXTURE_2D,V,Ne,pe.width,pe.height);else{let le=pe.width,K=pe.height;for(let we=0;we<V;we++)t.texImage2D(n.TEXTURE_2D,we,Ne,le,K,0,Oe,qe,null),le>>=1,K>>=1}}else if(Fe.length>0){if(Qe&&pt){let le=Te(Fe[0]);t.texStorage2D(n.TEXTURE_2D,V,Ne,le.width,le.height)}for(let le=0,K=Fe.length;le<K;le++)Ce=Fe[le],Qe?je&&t.texSubImage2D(n.TEXTURE_2D,le,0,0,Oe,qe,Ce):t.texImage2D(n.TEXTURE_2D,le,Ne,Oe,qe,Ce);T.generateMipmaps=!1}else if(Qe){if(pt){let le=Te(pe);t.texStorage2D(n.TEXTURE_2D,V,Ne,le.width,le.height)}je&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Oe,qe,pe)}else t.texImage2D(n.TEXTURE_2D,0,Ne,Oe,qe,pe);g(T)&&m(ee),Ue.__version=re.version,T.onUpdate&&T.onUpdate(T)}U.__version=T.version}function $e(U,T,G){if(T.image.length!==6)return;let ee=Me(U,T),oe=T.source;t.bindTexture(n.TEXTURE_CUBE_MAP,U.__webglTexture,n.TEXTURE0+G);let re=i.get(oe);if(oe.version!==re.__version||ee===!0){t.activeTexture(n.TEXTURE0+G);let Ue=dt.getPrimaries(dt.workingColorSpace),ve=T.colorSpace===di?null:dt.getPrimaries(T.colorSpace),xe=T.colorSpace===di||Ue===ve?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,T.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,T.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,T.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let He=T.isCompressedTexture||T.image[0].isCompressedTexture,pe=T.image[0]&&T.image[0].isDataTexture,Oe=[];for(let K=0;K<6;K++)!He&&!pe?Oe[K]=y(T.image[K],!0,r.maxCubemapSize):Oe[K]=pe?T.image[K].image:T.image[K],Oe[K]=ye(T,Oe[K]);let qe=Oe[0],Ne=s.convert(T.format,T.colorSpace),Ce=s.convert(T.type),Fe=x(T.internalFormat,Ne,Ce,T.colorSpace),Qe=T.isVideoTexture!==!0,pt=re.__version===void 0||ee===!0,je=oe.dataReady,V=v(T,qe);ce(n.TEXTURE_CUBE_MAP,T);let le;if(He){Qe&&pt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,V,Fe,qe.width,qe.height);for(let K=0;K<6;K++){le=Oe[K].mipmaps;for(let we=0;we<le.length;we++){let Ae=le[we];T.format!==un?Ne!==null?Qe?je&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,0,0,Ae.width,Ae.height,Ne,Ae.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,Fe,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,0,0,Ae.width,Ae.height,Ne,Ce,Ae.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we,Fe,Ae.width,Ae.height,0,Ne,Ce,Ae.data)}}}else{if(le=T.mipmaps,Qe&&pt){le.length>0&&V++;let K=Te(Oe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,V,Fe,K.width,K.height)}for(let K=0;K<6;K++)if(pe){Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Oe[K].width,Oe[K].height,Ne,Ce,Oe[K].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Fe,Oe[K].width,Oe[K].height,0,Ne,Ce,Oe[K].data);for(let we=0;we<le.length;we++){let Re=le[we].image[K].image;Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,0,0,Re.width,Re.height,Ne,Ce,Re.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,Fe,Re.width,Re.height,0,Ne,Ce,Re.data)}}else{Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Ne,Ce,Oe[K]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Fe,Ne,Ce,Oe[K]);for(let we=0;we<le.length;we++){let Ae=le[we];Qe?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,0,0,Ne,Ce,Ae.image[K]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+K,we+1,Fe,Ne,Ce,Ae.image[K])}}}g(T)&&m(n.TEXTURE_CUBE_MAP),re.__version=oe.version,T.onUpdate&&T.onUpdate(T)}U.__version=T.version}function Y(U,T,G,ee,oe,re){let Ue=s.convert(G.format,G.colorSpace),ve=s.convert(G.type),xe=x(G.internalFormat,Ue,ve,G.colorSpace);if(!i.get(T).__hasExternalTextures){let pe=Math.max(1,T.width>>re),Oe=Math.max(1,T.height>>re);oe===n.TEXTURE_3D||oe===n.TEXTURE_2D_ARRAY?t.texImage3D(oe,re,xe,pe,Oe,T.depth,0,Ue,ve,null):t.texImage2D(oe,re,xe,pe,Oe,0,Ue,ve,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ee,oe,i.get(G).__webglTexture,0,Z(T)):(oe===n.TEXTURE_2D||oe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&oe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ee,oe,i.get(G).__webglTexture,re),t.bindFramebuffer(n.FRAMEBUFFER,null)}function me(U,T,G){if(n.bindRenderbuffer(n.RENDERBUFFER,U),T.depthBuffer&&!T.stencilBuffer){let ee=n.DEPTH_COMPONENT24;if(G||he(T)){let oe=T.depthTexture;oe&&oe.isDepthTexture&&(oe.type===En?ee=n.DEPTH_COMPONENT32F:oe.type===Fr&&(ee=n.DEPTH_COMPONENT24));let re=Z(T);he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,ee,T.width,T.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,re,ee,T.width,T.height)}else n.renderbufferStorage(n.RENDERBUFFER,ee,T.width,T.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,U)}else if(T.depthBuffer&&T.stencilBuffer){let ee=Z(T);G&&he(T)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,T.width,T.height):he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ee,n.DEPTH24_STENCIL8,T.width,T.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,T.width,T.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,U)}else{let ee=T.textures;for(let oe=0;oe<ee.length;oe++){let re=ee[oe],Ue=s.convert(re.format,re.colorSpace),ve=s.convert(re.type),xe=x(re.internalFormat,Ue,ve,re.colorSpace),He=Z(T);G&&he(T)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,He,xe,T.width,T.height):he(T)?a.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,He,xe,T.width,T.height):n.renderbufferStorage(n.RENDERBUFFER,xe,T.width,T.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function te(U,T){if(T&&T.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,U),!(T.depthTexture&&T.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(T.depthTexture).__webglTexture||T.depthTexture.image.width!==T.width||T.depthTexture.image.height!==T.height)&&(T.depthTexture.image.width=T.width,T.depthTexture.image.height=T.height,T.depthTexture.needsUpdate=!0),O(T.depthTexture,0);let ee=i.get(T.depthTexture).__webglTexture,oe=Z(T);if(T.depthTexture.format===Ur)he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,ee,0);else if(T.depthTexture.format===zs)he(T)?a.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0,oe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,ee,0);else throw new Error("Unknown depthTexture format")}function ue(U){let T=i.get(U),G=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!T.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");te(T.__webglFramebuffer,U)}else if(G){T.__webglDepthbuffer=[];for(let ee=0;ee<6;ee++)t.bindFramebuffer(n.FRAMEBUFFER,T.__webglFramebuffer[ee]),T.__webglDepthbuffer[ee]=n.createRenderbuffer(),me(T.__webglDepthbuffer[ee],U,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,T.__webglFramebuffer),T.__webglDepthbuffer=n.createRenderbuffer(),me(T.__webglDepthbuffer,U,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function Pe(U,T,G){let ee=i.get(U);T!==void 0&&Y(ee.__webglFramebuffer,U,U.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&ue(U)}function _e(U){let T=U.texture,G=i.get(U),ee=i.get(T);U.addEventListener("dispose",N);let oe=U.textures,re=U.isWebGLCubeRenderTarget===!0,Ue=oe.length>1;if(Ue||(ee.__webglTexture===void 0&&(ee.__webglTexture=n.createTexture()),ee.__version=T.version,o.memory.textures++),re){G.__webglFramebuffer=[];for(let ve=0;ve<6;ve++)if(T.mipmaps&&T.mipmaps.length>0){G.__webglFramebuffer[ve]=[];for(let xe=0;xe<T.mipmaps.length;xe++)G.__webglFramebuffer[ve][xe]=n.createFramebuffer()}else G.__webglFramebuffer[ve]=n.createFramebuffer()}else{if(T.mipmaps&&T.mipmaps.length>0){G.__webglFramebuffer=[];for(let ve=0;ve<T.mipmaps.length;ve++)G.__webglFramebuffer[ve]=n.createFramebuffer()}else G.__webglFramebuffer=n.createFramebuffer();if(Ue)for(let ve=0,xe=oe.length;ve<xe;ve++){let He=i.get(oe[ve]);He.__webglTexture===void 0&&(He.__webglTexture=n.createTexture(),o.memory.textures++)}if(U.samples>0&&he(U)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let ve=0;ve<oe.length;ve++){let xe=oe[ve];G.__webglColorRenderbuffer[ve]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[ve]);let He=s.convert(xe.format,xe.colorSpace),pe=s.convert(xe.type),Oe=x(xe.internalFormat,He,pe,xe.colorSpace,U.isXRRenderTarget===!0),qe=Z(U);n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,Oe,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ve,n.RENDERBUFFER,G.__webglColorRenderbuffer[ve])}n.bindRenderbuffer(n.RENDERBUFFER,null),U.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),me(G.__webglDepthRenderbuffer,U,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(re){t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture),ce(n.TEXTURE_CUBE_MAP,T);for(let ve=0;ve<6;ve++)if(T.mipmaps&&T.mipmaps.length>0)for(let xe=0;xe<T.mipmaps.length;xe++)Y(G.__webglFramebuffer[ve][xe],U,T,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,xe);else Y(G.__webglFramebuffer[ve],U,T,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0);g(T)&&m(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let ve=0,xe=oe.length;ve<xe;ve++){let He=oe[ve],pe=i.get(He);t.bindTexture(n.TEXTURE_2D,pe.__webglTexture),ce(n.TEXTURE_2D,He),Y(G.__webglFramebuffer,U,He,n.COLOR_ATTACHMENT0+ve,n.TEXTURE_2D,0),g(He)&&m(n.TEXTURE_2D)}t.unbindTexture()}else{let ve=n.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ve=U.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ve,ee.__webglTexture),ce(ve,T),T.mipmaps&&T.mipmaps.length>0)for(let xe=0;xe<T.mipmaps.length;xe++)Y(G.__webglFramebuffer[xe],U,T,n.COLOR_ATTACHMENT0,ve,xe);else Y(G.__webglFramebuffer,U,T,n.COLOR_ATTACHMENT0,ve,0);g(T)&&m(ve),t.unbindTexture()}U.depthBuffer&&ue(U)}function z(U){let T=U.textures;for(let G=0,ee=T.length;G<ee;G++){let oe=T[G];if(g(oe)){let re=U.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ue=i.get(oe).__webglTexture;t.bindTexture(re,Ue),m(re),t.unbindTexture()}}}let Be=[],X=[];function de(U){if(U.samples>0){if(he(U)===!1){let T=U.textures,G=U.width,ee=U.height,oe=n.COLOR_BUFFER_BIT,re=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ue=i.get(U),ve=T.length>1;if(ve)for(let xe=0;xe<T.length;xe++)t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let xe=0;xe<T.length;xe++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(oe|=n.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(oe|=n.STENCIL_BUFFER_BIT)),ve){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[xe]);let He=i.get(T[xe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,He,0)}n.blitFramebuffer(0,0,G,ee,0,0,G,ee,oe,n.NEAREST),c===!0&&(Be.length=0,X.length=0,Be.push(n.COLOR_ATTACHMENT0+xe),U.depthBuffer&&U.resolveDepthBuffer===!1&&(Be.push(re),X.push(re),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,X)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Be))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ve)for(let xe=0;xe<T.length;xe++){t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.RENDERBUFFER,Ue.__webglColorRenderbuffer[xe]);let He=i.get(T[xe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ue.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+xe,n.TEXTURE_2D,He,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){let T=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[T])}}}function Z(U){return Math.min(r.maxSamples,U.samples)}function he(U){let T=i.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&T.__useRenderToTexture!==!1}function ie(U){let T=o.render.frame;u.get(U)!==T&&(u.set(U,T),U.update())}function ye(U,T){let G=U.colorSpace,ee=U.format,oe=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||G!==Si&&G!==di&&(dt.getTransfer(G)===yt?(ee!==un||oe!==_i)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),T}function Te(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(l.width=U.naturalWidth||U.width,l.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(l.width=U.displayWidth,l.height=U.displayHeight):(l.width=U.width,l.height=U.height),l}this.allocateTextureUnit=P,this.resetTextureUnits=S,this.setTexture2D=O,this.setTexture2DArray=H,this.setTexture3D=W,this.setTextureCube=J,this.rebindTextures=Pe,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=ue,this.setupFrameBufferTexture=Y,this.useMultisampledRTT=he}function _v(n,e){function t(i,r=di){let s,o=dt.getTransfer(r);if(i===_i)return n.UNSIGNED_BYTE;if(i===wp)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Mp)return n.UNSIGNED_SHORT_5_5_5_1;if(i===H0)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===V0)return n.BYTE;if(i===$0)return n.SHORT;if(i===bp)return n.UNSIGNED_SHORT;if(i===_p)return n.INT;if(i===Fr)return n.UNSIGNED_INT;if(i===En)return n.FLOAT;if(i===Na)return n.HALF_FLOAT;if(i===j0)return n.ALPHA;if(i===G0)return n.RGB;if(i===un)return n.RGBA;if(i===W0)return n.LUMINANCE;if(i===X0)return n.LUMINANCE_ALPHA;if(i===Ur)return n.DEPTH_COMPONENT;if(i===zs)return n.DEPTH_STENCIL;if(i===Sp)return n.RED;if(i===Ep)return n.RED_INTEGER;if(i===q0)return n.RG;if(i===Ap)return n.RG_INTEGER;if(i===Tp)return n.RGBA_INTEGER;if(i===xl||i===bl||i===_l||i===wl)if(o===yt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===xl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===bl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===_l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===wl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===xl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===bl)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===_l)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===wl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ah||i===Th||i===Ih||i===Ch)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===Ah)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Th)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ih)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ch)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Rh||i===Ph||i===Lh)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===Rh||i===Ph)return o===yt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===Lh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Dh||i===Oh||i===Uh||i===Nh||i===Fh||i===kh||i===Bh||i===zh||i===Vh||i===$h||i===Hh||i===jh||i===Gh||i===Wh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Dh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Oh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Uh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Nh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Fh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===kh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Bh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===zh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Vh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===$h)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Hh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===jh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Gh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Wh)return o===yt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Ml||i===Xh||i===qh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===Ml)return o===yt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Xh)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===qh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Y0||i===Yh||i===Zh||i===Jh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ml)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Yh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Zh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Jh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Qs?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}function vI(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,fv(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,x,v,w){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),d(g,m)):m.isMeshPhongMaterial?(s(g,m),u(g,m)):m.isMeshStandardMaterial?(s(g,m),h(g,m),m.isMeshPhysicalMaterial&&f(g,m,w)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),y(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?c(g,m,x,v):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===nn&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===nn&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x=e.get(m),v=x.envMap,w=x.envMapRotation;if(v&&(g.envMap.value=v,_r.copy(w),_r.x*=-1,_r.y*=-1,_r.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(_r.y*=-1,_r.z*=-1),g.envMapRotation.value.setFromMatrix4(yI.makeRotationFromEuler(_r)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let N=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*N,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,x,v){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*x,g.scale.value=v*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function u(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function d(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,x){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===nn&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=x.texture,g.transmissionSamplerSize.value.set(x.width,x.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function y(g,m){let x=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(x.matrixWorld),g.nearDistance.value=x.shadow.camera.near,g.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function xI(n,e,t,i){let r={},s={},o=[],a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,v){let w=v.program;i.uniformBlockBinding(x,w)}function l(x,v){let w=r[x.id];w===void 0&&(p(x),w=u(x),r[x.id]=w,x.addEventListener("dispose",g));let N=v.program;i.updateUBOMapping(x,N);let C=e.render.frame;s[x.id]!==C&&(h(x),s[x.id]=C)}function u(x){let v=d();x.__bindingPointIndex=v;let w=n.createBuffer(),N=x.__size,C=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,w),n.bufferData(n.UNIFORM_BUFFER,N,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,w),w}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(x){let v=r[x.id],w=x.uniforms,N=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let C=0,R=w.length;C<R;C++){let F=Array.isArray(w[C])?w[C]:[w[C]];for(let A=0,S=F.length;A<S;A++){let P=F[A];if(f(P,C,A,N)===!0){let k=P.__offset,O=Array.isArray(P.value)?P.value:[P.value],H=0;for(let W=0;W<O.length;W++){let J=O[W],ae=y(J);typeof J=="number"||typeof J=="boolean"?(P.__data[0]=J,n.bufferSubData(n.UNIFORM_BUFFER,k+H,P.__data)):J.isMatrix3?(P.__data[0]=J.elements[0],P.__data[1]=J.elements[1],P.__data[2]=J.elements[2],P.__data[3]=0,P.__data[4]=J.elements[3],P.__data[5]=J.elements[4],P.__data[6]=J.elements[5],P.__data[7]=0,P.__data[8]=J.elements[6],P.__data[9]=J.elements[7],P.__data[10]=J.elements[8],P.__data[11]=0):(J.toArray(P.__data,H),H+=ae.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,P.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function f(x,v,w,N){let C=x.value,R=v+"_"+w;if(N[R]===void 0)return typeof C=="number"||typeof C=="boolean"?N[R]=C:N[R]=C.clone(),!0;{let F=N[R];if(typeof C=="number"||typeof C=="boolean"){if(F!==C)return N[R]=C,!0}else if(F.equals(C)===!1)return F.copy(C),!0}return!1}function p(x){let v=x.uniforms,w=0,N=16;for(let R=0,F=v.length;R<F;R++){let A=Array.isArray(v[R])?v[R]:[v[R]];for(let S=0,P=A.length;S<P;S++){let k=A[S],O=Array.isArray(k.value)?k.value:[k.value];for(let H=0,W=O.length;H<W;H++){let J=O[H],ae=y(J),B=w%N;B!==0&&N-B<ae.boundary&&(w+=N-B),k.__data=new Float32Array(ae.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=w,w+=ae.storage}}}let C=w%N;return C>0&&(w+=N-C),x.__size=w,x.__cache={},this}function y(x){let v={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function g(x){let v=x.target;v.removeEventListener("dispose",g);let w=o.indexOf(v.__bindingPointIndex);o.splice(w,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function m(){for(let x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:l,dispose:m}}function Zc(n,e,t,i,r,s){Ps.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Do.x=s*Ps.x-r*Ps.y,Do.y=r*Ps.x+s*Ps.y):Do.copy(Ps),n.copy(e),n.x+=Do.x,n.y+=Do.y,n.applyMatrix4(wv)}function MI(n,e){return n.z-e.z}function SI(n,e){return e.z-n.z}function AI(n,e,t=0){let i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){let r=n.count;for(let s=0;s<r;s++)for(let o=0;o<i;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function il(n,e,t,i,r,s){let o=n.geometry.attributes.position;if(Vl.fromBufferAttribute(o,r),$l.fromBufferAttribute(o,s),t.distanceSqToSegment(Vl,$l,hh,Ay)>i)return;hh.applyMatrix4(n.matrixWorld);let c=e.ray.origin.distanceTo(hh);if(!(c<e.near||c>e.far))return{distance:c,point:Ay.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,object:n}}function Ry(n,e,t,i,r,s,o){let a=xf.distanceSqToPoint(n);if(a<t){let c=new D;xf.closestPointToPoint(n,c),c.applyMatrix4(i);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}function Lp(){let n=0,e=0,t=0,i=0;function r(s,o,a,c){n=s,e=a,t=-3*s+3*o-2*a-c,i=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,d){let h=(o-s)/l-(a-s)/(l+u)+(a-o)/u,f=(a-o)/u-(c-o)/(u+d)+(c-a)/d;h*=u,f*=u,r(o,a,h,f)},calc:function(s){let o=s*s,a=o*s;return n+e*s+t*o+i*a}}}function Py(n,e,t,i,r){let s=(i-e)*.5,o=(r-t)*.5,a=n*n,c=n*a;return(2*t-2*i+s+o)*c+(-3*t+3*i-2*s-o)*a+s*n+t}function TI(n,e){let t=1-n;return t*t*e}function II(n,e){return 2*(1-n)*n*e}function CI(n,e){return n*n*e}function Go(n,e,t,i){return TI(n,e)+II(n,t)+CI(n,i)}function RI(n,e){let t=1-n;return t*t*t*e}function PI(n,e){let t=1-n;return 3*t*t*n*e}function LI(n,e){return 3*(1-n)*n*n*e}function DI(n,e){return n*n*n*e}function Wo(n,e,t,i,r){return RI(n,e)+PI(n,t)+LI(n,i)+DI(n,r)}function Mv(n,e,t,i,r){let s,o;if(r===ZI(n,e,t,i)>0)for(s=e;s<t;s+=i)o=Ly(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=Ly(s,n[s],n[s+1],o);return o&&$u(o,o.next)&&(Ea(o),o=o.next),o}function Hr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&($u(t,t.next)||bt(t.prev,t,t.next)===0)){if(Ea(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ma(n,e,t,i,r,s,o){if(!n)return;!o&&s&&jI(n,i,r,s);let a=n,c,l;for(;n.prev!==n.next;){if(c=n.prev,l=n.next,s?NI(n,i,r,s):UI(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(l.i/t|0),Ea(n),n=l.next,a=l.next;continue}if(n=l,n===a){o?o===1?(n=FI(Hr(n),e,t),Ma(n,e,t,i,r,s,2)):o===2&&kI(n,e,t,i,r,s):Ma(Hr(n),e,t,i,r,s,1);break}}}function UI(n){let e=n.prev,t=n,i=n.next;if(bt(e,t,i)>=0)return!1;let r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,l=i.y,u=r<s?r<o?r:o:s<o?s:o,d=a<c?a<l?a:l:c<l?c:l,h=r>s?r>o?r:o:s>o?s:o,f=a>c?a>l?a:l:c>l?c:l,p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Fs(r,a,s,c,o,l,p.x,p.y)&&bt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function NI(n,e,t,i){let r=n.prev,s=n,o=n.next;if(bt(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,d=s.y,h=o.y,f=a<c?a<l?a:l:c<l?c:l,p=u<d?u<h?u:h:d<h?d:h,y=a>c?a>l?a:l:c>l?c:l,g=u>d?u>h?u:h:d>h?d:h,m=Ef(f,p,e,t,i),x=Ef(y,g,e,t,i),v=n.prevZ,w=n.nextZ;for(;v&&v.z>=m&&w&&w.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Fs(a,u,c,d,l,h,v.x,v.y)&&bt(v.prev,v,v.next)>=0||(v=v.prevZ,w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Fs(a,u,c,d,l,h,w.x,w.y)&&bt(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=y&&v.y>=p&&v.y<=g&&v!==r&&v!==o&&Fs(a,u,c,d,l,h,v.x,v.y)&&bt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=x;){if(w.x>=f&&w.x<=y&&w.y>=p&&w.y<=g&&w!==r&&w!==o&&Fs(a,u,c,d,l,h,w.x,w.y)&&bt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function FI(n,e,t){let i=n;do{let r=i.prev,s=i.next.next;!$u(r,s)&&Sv(r,i,i.next,s)&&Sa(r,s)&&Sa(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Ea(i),Ea(i.next),i=n=s),i=i.next}while(i!==n);return Hr(i)}function kI(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&XI(o,a)){let c=Ev(o,a);o=Hr(o,o.next),c=Hr(c,c.next),Ma(o,e,t,i,r,s,0),Ma(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function BI(n,e,t,i){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*i,c=s<o-1?e[s+1]*i:n.length,l=Mv(n,a,c,i,!1),l===l.next&&(l.steiner=!0),r.push(WI(l));for(r.sort(zI),s=0;s<r.length;s++)t=VI(r[s],t);return t}function zI(n,e){return n.x-e.x}function VI(n,e){let t=$I(n,e);if(!t)return e;let i=Ev(t,n);return Hr(i,i.next),Hr(t,t.next)}function $I(n,e){let t=e,i=-1/0,r,s=n.x,o=n.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let h=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=s&&h>i&&(i=h,r=t.x<t.next.x?t:t.next,h===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,d;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Fs(o<l?s:i,o,c,l,o<l?i:s,o,t.x,t.y)&&(d=Math.abs(o-t.y)/(s-t.x),Sa(t,n)&&(d<u||d===u&&(t.x>r.x||t.x===r.x&&HI(r,t)))&&(r=t,u=d)),t=t.next;while(t!==a);return r}function HI(n,e){return bt(n.prev,n,e.prev)<0&&bt(e.next,n,n.next)<0}function jI(n,e,t,i){let r=n;do r.z===0&&(r.z=Ef(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,GI(r)}function GI(n){let e,t,i,r,s,o,a,c,l=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e<l&&(a++,i=i.nextZ,!!i);e++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,l*=2}while(o>1);return n}function Ef(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function WI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Fs(n,e,t,i,r,s,o,a){return(r-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function XI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!qI(n,e)&&(Sa(n,e)&&Sa(e,n)&&YI(n,e)&&(bt(n.prev,n,e.prev)||bt(n,e.prev,e))||$u(n,e)&&bt(n.prev,n,n.next)>0&&bt(e.prev,e,e.next)>0)}function bt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function $u(n,e){return n.x===e.x&&n.y===e.y}function Sv(n,e,t,i){let r=dl(bt(n,e,t)),s=dl(bt(n,e,i)),o=dl(bt(t,i,n)),a=dl(bt(t,i,e));return!!(r!==s&&o!==a||r===0&&ul(n,t,e)||s===0&&ul(n,i,e)||o===0&&ul(t,n,i)||a===0&&ul(t,e,i))}function ul(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function dl(n){return n>0?1:n<0?-1:0}function qI(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Sv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Sa(n,e){return bt(n.prev,n,n.next)<0?bt(n,e,n.next)>=0&&bt(n,n.prev,e)>=0:bt(n,e,n.prev)<0||bt(n,n.next,e)<0}function YI(n,e){let t=n,i=!1,r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Ev(n,e){let t=new Af(n.i,n.x,n.y),i=new Af(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Ly(n,e,t,i){let r=new Af(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Ea(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Af(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ZI(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}function Dy(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Oy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}function KI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){let s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}function QI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}function Uy(n,e,t){let i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}function Dr(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Av(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Tv(n){function e(r,s){return n[r]-n[s]}let t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Tf(n,e,t){let i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function Dp(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function e2(n,e,t,i,r=30){let s=n.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),d=[],h=[];for(let f=0;f<l.times.length;++f){let p=l.times[f]*r;if(!(p<t||p>=i)){d.push(l.times[f]);for(let y=0;y<u;++y)h.push(l.values[f*u+y])}}d.length!==0&&(l.times=Dr(d,l.times.constructor),l.values=Dr(h,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function t2(n,e=0,t=n,i=30){i<=0&&(i=30);let r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=n.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let u=0,d=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=d/3);let h=0,f=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=f/3);let p=a.times.length-1,y;if(s<=a.times[0]){let m=u,x=d-u;y=a.values.slice(m,x)}else if(s>=a.times[p]){let m=p*d+u,x=m+d-u;y=a.values.slice(m,x)}else{let m=a.createInterpolant(),x=u,v=d-u;m.evaluate(s),y=m.resultBuffer.slice(x,v)}c==="quaternion"&&new Zt().fromArray(y).normalize().conjugate().toArray(y);let g=l.times.length;for(let m=0;m<g;++m){let x=m*f+h;if(c==="quaternion")Zt.multiplyQuaternionsFlat(l.values,x,y,0,l.values,x);else{let v=f-h*2;for(let w=0;w<v;++w)l.values[x+w]-=y[w]}}}return n.blendMode=Ip,n}function i2(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Gr;case"vector":case"vector2":case"vector3":case"vector4":return Wr;case"color":return Ra;case"quaternion":return Zi;case"bool":case"boolean":return wi;case"string":return Mi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function r2(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=i2(n.type);if(n.times===void 0){let t=[],i=[];Dp(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}function jy(){return(typeof performance>"u"?Date:performance).now()}function qy(n,e){return n.distance-e.distance}function Kf(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){let r=n.children;for(let s=0,o=r.length;s<o;s++)Kf(r[s],e,t,!0)}}function Cv(n){let e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Cv(n.children[t]));return e}function At(n,e,t,i,r,s,o){gl.set(r,s,o).unproject(i);let a=e[n];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],gl.x,gl.y,gl.z)}}var RM,PM,LM,i0,_h,r0,DM,OM,vp,s0,Vn,xi,nn,Hn,gi,Or,wh,Mh,Sh,o0,ji,a0,c0,l0,u0,d0,h0,f0,p0,El,Al,m0,g0,y0,v0,x0,b0,_0,w0,M0,S0,E0,A0,Xo,T0,I0,C0,R0,Ua,P0,L0,yi,D0,O0,U0,N0,F0,k0,B0,Eh,z0,ku,bi,Wi,qo,Yo,Ks,Zo,Sn,Jo,Ut,xp,UM,Os,NM,It,$o,FM,jn,kM,_i,V0,$0,bp,_p,Fr,En,Na,wp,Mp,Qs,H0,j0,G0,un,W0,X0,Ur,zs,Sp,Ep,q0,Ap,Tp,xl,bl,_l,wl,Ah,Th,Ih,Ch,Rh,Ph,Lh,Dh,Oh,Uh,Nh,Fh,kh,Bh,zh,Vh,$h,Hh,jh,Gh,Wh,Ml,Xh,qh,Y0,Yh,Zh,Jh,Z0,J0,K0,Ko,Qo,Sl,Pr,Lr,ea,Bu,Ip,BM,zM,VM,Q0,ev,Ji,tv,di,Mn,Si,zu,Fa,ta,yt,na,ia,$M,Ir,HM,jM,GM,WM,XM,qM,YM,ZM,JM,KM,QM,eS,tS,Kh,nv,iv,rv,Cp,sv,ov,av,cv,ra,nS,iS,rS,sS,oS,aS,cS,lS,uS,Qh,Gn,sa,Un,Xt,Eg,Nr,Vs,TS,se,Ze,Fd,IS,Ag,Tg,Ig,Tc,CS,dt,hs,Tl,RS,fi,PS,Ct,ht,Il,hn,$s,ef,aa,tf,Zt,D,zd,Cg,Bt,si,Pn,Ic,fs,ps,ms,Ni,Fi,gr,Io,Cc,Rc,yr,LS,Co,$d,Nt,oi,Hd,Pc,ki,jd,Lc,Gd,Xi,Ve,gs,Ln,DS,OS,Bi,Dc,cn,Rg,Pg,fn,Hs,US,Lg,ys,ai,Oc,Ro,NS,FS,Dg,Og,Ug,Ng,kS,vs,Wd,ct,Dn,ci,Xd,li,xs,bs,Fg,qd,Yd,Zd,pi,hv,zi,Uc,Ie,qt,BS,Ft,qn,hi,VS,Tt,Nc,ot,nf,rf,sf,of,ca,af,la,cf,De,$S,wn,Kd,_s,ln,Po,Ot,et,kg,vr,Fc,Bg,ws,Ms,Ss,Qd,kc,Bc,zc,Vc,zg,Vg,$g,$c,Hc,St,kr,pv,GS,WS,pn,Gs,Vi,Hg,jg,Rt,Es,As,Cl,Br,Rl,eh,XS,qS,$n,xr,Gc,zr,Ws,ZS,JS,KS,QS,e1,t1,n1,i1,r1,s1,o1,a1,c1,l1,u1,d1,h1,f1,p1,m1,g1,y1,v1,x1,b1,_1,w1,M1,S1,E1,A1,T1,I1,C1,R1,P1,L1,D1,O1,U1,N1,F1,k1,B1,z1,V1,$1,H1,j1,G1,W1,X1,q1,Y1,Z1,J1,K1,Q1,eE,tE,nE,iE,rE,sE,oE,aE,cE,lE,uE,dE,hE,fE,pE,mE,gE,yE,vE,xE,bE,_E,wE,ME,SE,EE,AE,TE,IE,CE,RE,PE,LE,DE,OE,UE,NE,FE,kE,BE,zE,VE,$E,HE,jE,GE,WE,XE,qE,YE,ZE,JE,KE,QE,eA,tA,nA,iA,rA,sA,oA,aA,cA,lA,uA,dA,hA,fA,pA,mA,gA,yA,vA,xA,bA,_A,wA,MA,SA,EA,AA,TA,IA,Ke,Ee,On,Wc,br,CA,Xs,Ns,Gg,Rr,th,Wg,nh,ih,rh,sh,Cr,Ts,Xg,ua,da,gv,yv,vv,xv,bv,Jg,Kg,Qg,ey,ty,lf,uf,df,oh,Bs,LT,DT,VT,$T,jT,KT,ff,pf,sI,ha,fa,lI,uI,Pl,Gi,pI,jo,mI,gI,mf,gf,_r,yI,yf,Ll,Dl,Ol,qs,Qt,Vr,pa,Is,Lo,Cs,Rs,Ps,Do,wv,qc,Oo,Yc,hy,ah,fy,Ul,Jc,py,Nl,my,gy,yy,bI,vy,Kc,ch,xy,lh,Fl,ma,Wn,by,_I,kl,qi,Ls,_y,Qc,wy,wI,Uo,No,Bl,vf,Ds,$i,My,EI,Sy,uh,el,wr,Fo,dh,Yt,tl,zl,zt,Vl,$l,Ey,ko,nl,hh,Ay,Yn,Ty,Iy,An,Hl,ga,Cy,xf,rl,sl,jl,bf,_f,Ys,wf,Mf,Sf,mn,Zs,Gl,ol,fh,ph,mh,Wl,ya,Xl,va,ql,xa,ba,_a,Yl,Zl,$r,wa,Jl,Kl,Js,Ql,Yi,eu,al,cl,gh,ll,tu,vi,OI,Xn,nu,JI,iu,Aa,ru,su,Ta,ou,au,cu,lu,uu,Ny,du,hu,Ia,fu,pu,mu,gu,yu,vu,xu,n2,jr,bu,Ca,_u,gn,wi,Ra,Gr,wu,Zi,Mi,Wr,Xr,mi,Pa,Iv,Jt,ui,If,Nn,Cf,Rf,qr,Pf,Lf,Df,Zn,Mu,yh,Fy,ky,La,Of,Su,By,Bo,vh,Uf,Eu,Nf,Au,Tu,Iu,Cu,Ru,Pu,Da,Lu,Du,Ff,s2,zy,Vy,kf,hl,Oa,Bf,$y,Hy,Mr,zf,Ou,Sr,Gy,o2,Er,Vf,Uu,Ar,Wy,a2,Tr,$f,Hf,Nu,Op,c2,Up,l2,u2,d2,h2,f2,p2,m2,jf,ut,Gf,Fu,g2,Wf,Xf,y2,qf,Yf,Zf,Xy,Jf,Qf,ep,Yy,tp,Zy,fl,np,Jy,ip,Hi,pl,xh,rp,sp,v2,Ky,Qy,op,ap,cp,e0,ml,t0,lp,gl,wt,up,yl,dp,hp,fp,n0,vl,bh,pp,mp,gp,yp,Pv=gx(()=>{"use strict";RM="164",PM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},LM={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},i0=0,_h=1,r0=2,DM=3,OM=0,vp=1,s0=2,Vn=3,xi=0,nn=1,Hn=2,gi=0,Or=1,wh=2,Mh=3,Sh=4,o0=5,ji=100,a0=101,c0=102,l0=103,u0=104,d0=200,h0=201,f0=202,p0=203,El=204,Al=205,m0=206,g0=207,y0=208,v0=209,x0=210,b0=211,_0=212,w0=213,M0=214,S0=0,E0=1,A0=2,Xo=3,T0=4,I0=5,C0=6,R0=7,Ua=0,P0=1,L0=2,yi=0,D0=1,O0=2,U0=3,N0=4,F0=5,k0=6,B0=7,Eh="attached",z0="detached",ku=300,bi=301,Wi=302,qo=303,Yo=304,Ks=306,Zo=1e3,Sn=1001,Jo=1002,Ut=1003,xp=1004,UM=1004,Os=1005,NM=1005,It=1006,$o=1007,FM=1007,jn=1008,kM=1008,_i=1009,V0=1010,$0=1011,bp=1012,_p=1013,Fr=1014,En=1015,Na=1016,wp=1017,Mp=1018,Qs=1020,H0=35902,j0=1021,G0=1022,un=1023,W0=1024,X0=1025,Ur=1026,zs=1027,Sp=1028,Ep=1029,q0=1030,Ap=1031,Tp=1033,xl=33776,bl=33777,_l=33778,wl=33779,Ah=35840,Th=35841,Ih=35842,Ch=35843,Rh=36196,Ph=37492,Lh=37496,Dh=37808,Oh=37809,Uh=37810,Nh=37811,Fh=37812,kh=37813,Bh=37814,zh=37815,Vh=37816,$h=37817,Hh=37818,jh=37819,Gh=37820,Wh=37821,Ml=36492,Xh=36494,qh=36495,Y0=36283,Yh=36284,Zh=36285,Jh=36286,Z0=2200,J0=2201,K0=2202,Ko=2300,Qo=2301,Sl=2302,Pr=2400,Lr=2401,ea=2402,Bu=2500,Ip=2501,BM=0,zM=1,VM=2,Q0=3200,ev=3201,Ji=0,tv=1,di="",Mn="srgb",Si="srgb-linear",zu="display-p3",Fa="display-p3-linear",ta="linear",yt="srgb",na="rec709",ia="p3",$M=0,Ir=7680,HM=7681,jM=7682,GM=7683,WM=34055,XM=34056,qM=5386,YM=512,ZM=513,JM=514,KM=515,QM=516,eS=517,tS=518,Kh=519,nv=512,iv=513,rv=514,Cp=515,sv=516,ov=517,av=518,cv=519,ra=35044,nS=35048,iS=35040,rS=35045,sS=35049,oS=35041,aS=35046,cS=35050,lS=35042,uS="100",Qh="300 es",Gn=2e3,sa=2001,Un=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let i=this._listeners[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},Xt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Eg=1234567,Nr=Math.PI/180,Vs=180/Math.PI;TS={DEG2RAD:Nr,RAD2DEG:Vs,generateUUID:dn,clamp:Mt,euclideanModulo:Rp,mapLinear:dS,inverseLerp:hS,lerp:Ho,damp:fS,pingpong:pS,smoothstep:mS,smootherstep:gS,randInt:yS,randFloat:vS,randFloatSpread:xS,seededRandom:bS,degToRad:_S,radToDeg:wS,isPowerOfTwo:MS,ceilPowerOfTwo:SS,floorPowerOfTwo:ES,setQuaternionFromProperEuler:AS,normalize:Je,denormalize:tn},se=class n{constructor(e=0,t=0){n.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ze=class n{constructor(e,t,i,r,s,o,a,c,l){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l)}set(e,t,i,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],y=r[0],g=r[3],m=r[6],x=r[1],v=r[4],w=r[7],N=r[2],C=r[5],R=r[8];return s[0]=o*y+a*x+c*N,s[3]=o*g+a*v+c*C,s[6]=o*m+a*w+c*R,s[1]=l*y+u*x+d*N,s[4]=l*g+u*v+d*C,s[7]=l*m+u*w+d*R,s[2]=h*y+f*x+p*N,s[5]=h*g+f*v+p*C,s[8]=h*m+f*w+p*R,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*s*u+i*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=u*o-a*l,h=a*c-u*s,f=l*s-o*c,p=t*d+i*h+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/p;return e[0]=d*y,e[1]=(r*l-u*i)*y,e[2]=(a*i-r*o)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=f*y,e[7]=(i*c-l*t)*y,e[8]=(o*t-i*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Fd=new Ze;IS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};Ag={};Tg=new Ze().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ig=new Ze().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Tc={[Si]:{transfer:ta,primaries:na,toReference:n=>n,fromReference:n=>n},[Mn]:{transfer:yt,primaries:na,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Fa]:{transfer:ta,primaries:ia,toReference:n=>n.applyMatrix3(Ig),fromReference:n=>n.applyMatrix3(Tg)},[zu]:{transfer:yt,primaries:ia,toReference:n=>n.convertSRGBToLinear().applyMatrix3(Ig),fromReference:n=>n.applyMatrix3(Tg).convertLinearToSRGB()}},CS=new Set([Si,Fa]),dt={enabled:!0,_workingColorSpace:Si,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!CS.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;let i=Tc[e].toReference,r=Tc[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Tc[n].primaries},getTransfer:function(n){return n===di?ta:Tc[n].transfer}};Tl=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{hs===void 0&&(hs=oa("canvas")),hs.width=e.width,hs.height=e.height;let i=hs.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=hs}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=oa("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=ks(s[o]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(ks(t[i]/255)*255):t[i]=ks(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},RS=0,fi=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:RS++}),this.uuid=dn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(Bd(r[o].image)):s.push(Bd(r[o]))}else s=Bd(r);i.url=s}return t||(e.images[this.uuid]=i),i}};PS=0,Ct=class n extends Un{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Sn,r=Sn,s=It,o=jn,a=un,c=_i,l=n.DEFAULT_ANISOTROPY,u=di){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:PS++}),this.uuid=dn(),this.name="",this.source=new fi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new se(0,0),this.repeat=new se(1,1),this.center=new se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ku)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zo:e.x=e.x-Math.floor(e.x);break;case Sn:e.x=e.x<0?0:1;break;case Jo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zo:e.y=e.y-Math.floor(e.y);break;case Sn:e.y=e.y<0?0:1;break;case Jo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=ku;Ct.DEFAULT_ANISOTROPY=1;ht=class n{constructor(e=0,t=0,i=0,r=1){n.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,c=e.elements,l=c[0],u=c[4],d=c[8],h=c[1],f=c[5],p=c[9],y=c[2],g=c[6],m=c[10];if(Math.abs(u-h)<.01&&Math.abs(d-y)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+y)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let v=(l+1)/2,w=(f+1)/2,N=(m+1)/2,C=(u+h)/4,R=(d+y)/4,F=(p+g)/4;return v>w&&v>N?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=C/i,s=R/i):w>N?w<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),i=C/r,s=F/r):N<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(N),i=R/s,r=F/s),this.set(i,r,s,t),this}let x=Math.sqrt((g-p)*(g-p)+(d-y)*(d-y)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(g-p)/x,this.y=(d-y)/x,this.z=(h-u)/x,this.w=Math.acos((l+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Il=class extends Un{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ht(0,0,e,t),this.scissorTest=!1,this.viewport=new ht(0,0,e,t);let r={width:e,height:t,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);let s=new Ct(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);s.flipY=!1,s.generateMipmaps=i.generateMipmaps,s.internalFormat=i.internalFormat,this.textures=[];let o=i.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let i=0,r=e.textures.length;i<r;i++)this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new fi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},hn=class extends Il{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},$s=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ef=class extends hn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new $s(null,e,t,i),this.texture.isRenderTargetTexture=!0}},aa=class extends Ct{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class extends hn{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new aa(null,e,t,i),this.texture.isRenderTargetTexture=!0}},Zt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,o,a){let c=i[r+0],l=i[r+1],u=i[r+2],d=i[r+3],h=s[o+0],f=s[o+1],p=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;return}if(a===1){e[t+0]=h,e[t+1]=f,e[t+2]=p,e[t+3]=y;return}if(d!==y||c!==h||l!==f||u!==p){let g=1-a,m=c*h+l*f+u*p+d*y,x=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){let N=Math.sqrt(v),C=Math.atan2(N,m*x);g=Math.sin(g*C)/N,a=Math.sin(a*C)/N}let w=a*x;if(c=c*g+h*w,l=l*g+f*w,u=u*g+p*w,d=d*g+y*w,g===1-a){let N=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=N,l*=N,u*=N,d*=N}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){let a=i[r],c=i[r+1],l=i[r+2],u=i[r+3],d=s[o],h=s[o+1],f=s[o+2],p=s[o+3];return e[t]=a*p+u*d+c*f-l*h,e[t+1]=c*p+u*h+l*d-a*f,e[t+2]=l*p+u*f+a*h-c*d,e[t+3]=u*p-a*d-c*h-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(r/2),d=a(s/2),h=c(i/2),f=c(r/2),p=c(s/2);switch(o){case"XYZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d+h*f*p;break;case"YZX":this._x=h*u*d+l*f*p,this._y=l*f*d+h*u*p,this._z=l*u*p-h*f*d,this._w=l*u*d-h*f*p;break;case"XZY":this._x=h*u*d-l*f*p,this._y=l*f*d-h*u*p,this._z=l*u*p+h*f*d,this._w=l*u*d+h*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],d=t[10],h=i+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-c)*f,this._y=(s-l)*f,this._z=(o-r)*f}else if(i>a&&i>d){let f=2*Math.sqrt(1+i-a-d);this._w=(u-c)/f,this._x=.25*f,this._y=(r+o)/f,this._z=(s+l)/f}else if(a>d){let f=2*Math.sqrt(1+a-i-d);this._w=(s-l)/f,this._x=(r+o)/f,this._y=.25*f,this._z=(c+u)/f}else{let f=2*Math.sqrt(1+d-i-a);this._w=(o-r)/f,this._x=(s+l)/f,this._y=(c+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Mt(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-i*l,this._z=s*u+o*l+i*c-r*a,this._w=o*u-i*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*i+t*this._x,this._y=f*r+t*this._y,this._z=f*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),d=Math.sin((1-t)*u)/l,h=Math.sin(t*u)/l;return this._w=o*d+this._w*h,this._x=i*d+this._x*h,this._y=r*d+this._y*h,this._z=s*d+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},D=class n{constructor(e=0,t=0,i=0){n.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Cg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Cg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*i),u=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+c*l+o*d-a*u,this.y=i+c*u+a*l-s*d,this.z=r+c*d+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return zd.copy(this).projectOnVector(e),this.sub(zd)}reflect(e){return this.sub(zd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Mt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},zd=new D,Cg=new Zt,Bt=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Pn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Pn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Pn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let s=i.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Pn):Pn.fromBufferAttribute(s,o),Pn.applyMatrix4(e.matrixWorld),this.expandByPoint(Pn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ic.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ic.copy(i.boundingBox)),Ic.applyMatrix4(e.matrixWorld),this.union(Ic)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Pn),Pn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Io),Cc.subVectors(this.max,Io),fs.subVectors(e.a,Io),ps.subVectors(e.b,Io),ms.subVectors(e.c,Io),Ni.subVectors(ps,fs),Fi.subVectors(ms,ps),gr.subVectors(fs,ms);let t=[0,-Ni.z,Ni.y,0,-Fi.z,Fi.y,0,-gr.z,gr.y,Ni.z,0,-Ni.x,Fi.z,0,-Fi.x,gr.z,0,-gr.x,-Ni.y,Ni.x,0,-Fi.y,Fi.x,0,-gr.y,gr.x,0];return!Vd(t,fs,ps,ms,Cc)||(t=[1,0,0,0,1,0,0,0,1],!Vd(t,fs,ps,ms,Cc))?!1:(Rc.crossVectors(Ni,Fi),t=[Rc.x,Rc.y,Rc.z],Vd(t,fs,ps,ms,Cc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Pn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(si[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),si[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),si[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),si[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),si[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),si[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),si[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),si[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(si),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},si=[new D,new D,new D,new D,new D,new D,new D,new D],Pn=new D,Ic=new Bt,fs=new D,ps=new D,ms=new D,Ni=new D,Fi=new D,gr=new D,Io=new D,Cc=new D,Rc=new D,yr=new D;LS=new Bt,Co=new D,$d=new D,Nt=class{constructor(e=new D,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):LS.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Co.subVectors(e,this.center);let t=Co.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Co,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($d.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Co.copy(e.center).add($d)),this.expandByPoint(Co.copy(e.center).sub($d))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},oi=new D,Hd=new D,Pc=new D,ki=new D,jd=new D,Lc=new D,Gd=new D,Xi=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,oi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=oi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(oi.copy(this.origin).addScaledVector(this.direction,t),oi.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Hd.copy(e).add(t).multiplyScalar(.5),Pc.copy(t).sub(e).normalize(),ki.copy(this.origin).sub(Hd);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Pc),a=ki.dot(this.direction),c=-ki.dot(Pc),l=ki.lengthSq(),u=Math.abs(1-o*o),d,h,f,p;if(u>0)if(d=o*c-a,h=o*a-c,p=s*u,d>=0)if(h>=-p)if(h<=p){let y=1/u;d*=y,h*=y,f=d*(d+o*h+2*a)+h*(o*d+h+2*c)+l}else h=s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h=-s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;else h<=-p?(d=Math.max(0,-(-o*s+a)),h=d>0?-s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l):h<=p?(d=0,h=Math.min(Math.max(-s,-c),s),f=h*(h+2*c)+l):(d=Math.max(0,-(o*s+a)),h=d>0?s:Math.min(Math.max(-s,-c),s),f=-d*d+h*(h+2*c)+l);else h=o>0?-s:s,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Hd).addScaledVector(Pc,h),f}intersectSphere(e,t){oi.subVectors(e.center,this.origin);let i=oi.dot(this.direction),r=oi.dot(oi)-i*i,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),d>=0?(a=(e.min.z-h.z)*d,c=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,c=(e.min.z-h.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,oi)!==null}intersectTriangle(e,t,i,r,s){jd.subVectors(t,e),Lc.subVectors(i,e),Gd.crossVectors(jd,Lc);let o=this.direction.dot(Gd),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ki.subVectors(this.origin,e);let c=a*this.direction.dot(Lc.crossVectors(ki,Lc));if(c<0)return null;let l=a*this.direction.dot(jd.cross(ki));if(l<0||c+l>o)return null;let u=-a*ki.dot(Gd);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ve=class n{constructor(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){n.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g)}set(e,t,i,r,s,o,a,c,l,u,d,h,f,p,y,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=u,m[10]=d,m[14]=h,m[3]=f,m[7]=p,m[11]=y,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/gs.setFromMatrixColumn(e,0).length(),s=1/gs.setFromMatrixColumn(e,1).length(),o=1/gs.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=f+p*l,t[5]=h-y*l,t[9]=-a*c,t[2]=y-h*l,t[6]=p+f*l,t[10]=o*c}else if(e.order==="YXZ"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h+y*a,t[4]=p*a-f,t[8]=o*l,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-p,t[6]=y+h*a,t[10]=o*c}else if(e.order==="ZXY"){let h=c*u,f=c*d,p=l*u,y=l*d;t[0]=h-y*a,t[4]=-o*d,t[8]=p+f*a,t[1]=f+p*a,t[5]=o*u,t[9]=y-h*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let h=o*u,f=o*d,p=a*u,y=a*d;t[0]=c*u,t[4]=p*l-f,t[8]=h*l+y,t[1]=c*d,t[5]=y*l+h,t[9]=f*l-p,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=y-h*d,t[8]=p*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=f*d+p,t[10]=h-y*d}else if(e.order==="XZY"){let h=o*c,f=o*l,p=a*c,y=a*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=h*d+y,t[5]=o*u,t[9]=f*d-p,t[2]=p*d-f,t[6]=a*u,t[10]=y*d+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(DS,e,OS)}lookAt(e,t,i){let r=this.elements;return cn.subVectors(e,t),cn.lengthSq()===0&&(cn.z=1),cn.normalize(),Bi.crossVectors(i,cn),Bi.lengthSq()===0&&(Math.abs(i.z)===1?cn.x+=1e-4:cn.z+=1e-4,cn.normalize(),Bi.crossVectors(i,cn)),Bi.normalize(),Dc.crossVectors(cn,Bi),r[0]=Bi.x,r[4]=Dc.x,r[8]=cn.x,r[1]=Bi.y,r[5]=Dc.y,r[9]=cn.y,r[2]=Bi.z,r[6]=Dc.z,r[10]=cn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],d=i[5],h=i[9],f=i[13],p=i[2],y=i[6],g=i[10],m=i[14],x=i[3],v=i[7],w=i[11],N=i[15],C=r[0],R=r[4],F=r[8],A=r[12],S=r[1],P=r[5],k=r[9],O=r[13],H=r[2],W=r[6],J=r[10],ae=r[14],B=r[3],ne=r[7],ce=r[11],Me=r[15];return s[0]=o*C+a*S+c*H+l*B,s[4]=o*R+a*P+c*W+l*ne,s[8]=o*F+a*k+c*J+l*ce,s[12]=o*A+a*O+c*ae+l*Me,s[1]=u*C+d*S+h*H+f*B,s[5]=u*R+d*P+h*W+f*ne,s[9]=u*F+d*k+h*J+f*ce,s[13]=u*A+d*O+h*ae+f*Me,s[2]=p*C+y*S+g*H+m*B,s[6]=p*R+y*P+g*W+m*ne,s[10]=p*F+y*k+g*J+m*ce,s[14]=p*A+y*O+g*ae+m*Me,s[3]=x*C+v*S+w*H+N*B,s[7]=x*R+v*P+w*W+N*ne,s[11]=x*F+v*k+w*J+N*ce,s[15]=x*A+v*O+w*ae+N*Me,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],d=e[6],h=e[10],f=e[14],p=e[3],y=e[7],g=e[11],m=e[15];return p*(+s*c*d-r*l*d-s*a*h+i*l*h+r*a*f-i*c*f)+y*(+t*c*f-t*l*h+s*o*h-r*o*f+r*l*u-s*c*u)+g*(+t*l*d-t*a*f-s*o*d+i*o*f+s*a*u-i*l*u)+m*(-r*a*u-t*c*d+t*a*h+r*o*d-i*o*h+i*c*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=e[9],h=e[10],f=e[11],p=e[12],y=e[13],g=e[14],m=e[15],x=d*g*l-y*h*l+y*c*f-a*g*f-d*c*m+a*h*m,v=p*h*l-u*g*l-p*c*f+o*g*f+u*c*m-o*h*m,w=u*y*l-p*d*l+p*a*f-o*y*f-u*a*m+o*d*m,N=p*d*c-u*y*c-p*a*h+o*y*h+u*a*g-o*d*g,C=t*x+i*v+r*w+s*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/C;return e[0]=x*R,e[1]=(y*h*s-d*g*s-y*r*f+i*g*f+d*r*m-i*h*m)*R,e[2]=(a*g*s-y*c*s+y*r*l-i*g*l-a*r*m+i*c*m)*R,e[3]=(d*c*s-a*h*s-d*r*l+i*h*l+a*r*f-i*c*f)*R,e[4]=v*R,e[5]=(u*g*s-p*h*s+p*r*f-t*g*f-u*r*m+t*h*m)*R,e[6]=(p*c*s-o*g*s-p*r*l+t*g*l+o*r*m-t*c*m)*R,e[7]=(o*h*s-u*c*s+u*r*l-t*h*l-o*r*f+t*c*f)*R,e[8]=w*R,e[9]=(p*d*s-u*y*s-p*i*f+t*y*f+u*i*m-t*d*m)*R,e[10]=(o*y*s-p*a*s+p*i*l-t*y*l-o*i*m+t*a*m)*R,e[11]=(u*a*s-o*d*s-u*i*l+t*d*l+o*i*f-t*a*f)*R,e[12]=N*R,e[13]=(u*y*r-p*d*r+p*i*h-t*y*h-u*i*g+t*d*g)*R,e[14]=(p*a*r-o*y*r-p*i*c+t*y*c+o*i*g-t*a*g)*R,e[15]=(o*d*r-u*a*r+u*i*c-t*d*c-o*i*h+t*a*h)*R,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+i,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,d=a+a,h=s*l,f=s*u,p=s*d,y=o*u,g=o*d,m=a*d,x=c*l,v=c*u,w=c*d,N=i.x,C=i.y,R=i.z;return r[0]=(1-(y+m))*N,r[1]=(f+w)*N,r[2]=(p-v)*N,r[3]=0,r[4]=(f-w)*C,r[5]=(1-(h+m))*C,r[6]=(g+x)*C,r[7]=0,r[8]=(p+v)*R,r[9]=(g-x)*R,r[10]=(1-(h+y))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=gs.set(r[0],r[1],r[2]).length(),o=gs.set(r[4],r[5],r[6]).length(),a=gs.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Ln.copy(this);let l=1/s,u=1/o,d=1/a;return Ln.elements[0]*=l,Ln.elements[1]*=l,Ln.elements[2]*=l,Ln.elements[4]*=u,Ln.elements[5]*=u,Ln.elements[6]*=u,Ln.elements[8]*=d,Ln.elements[9]*=d,Ln.elements[10]*=d,t.setFromRotationMatrix(Ln),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Gn){let c=this.elements,l=2*s/(t-e),u=2*s/(i-r),d=(t+e)/(t-e),h=(i+r)/(i-r),f,p;if(a===Gn)f=-(o+s)/(o-s),p=-2*o*s/(o-s);else if(a===sa)f=-o/(o-s),p=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=h,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Gn){let c=this.elements,l=1/(t-e),u=1/(i-r),d=1/(o-s),h=(t+e)*l,f=(i+r)*u,p,y;if(a===Gn)p=(o+s)*d,y=-2*d;else if(a===sa)p=s*d,y=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-h,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=y,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},gs=new D,Ln=new Ve,DS=new D(0,0,0),OS=new D(1,1,1),Bi=new D,Dc=new D,cn=new D,Rg=new Ve,Pg=new Zt,fn=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],d=r[2],h=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(Mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Mt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Mt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Mt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Rg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Rg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pg.setFromEuler(this),this.setFromQuaternion(Pg,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};fn.DEFAULT_ORDER="XYZ";Hs=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},US=0,Lg=new D,ys=new Zt,ai=new Ve,Oc=new D,Ro=new D,NS=new D,FS=new Zt,Dg=new D(1,0,0),Og=new D(0,1,0),Ug=new D(0,0,1),Ng={type:"added"},kS={type:"removed"},vs={type:"childadded",child:null},Wd={type:"childremoved",child:null},ct=class n extends Un{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:US++}),this.uuid=dn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new D,t=new fn,i=new Zt,r=new D(1,1,1);function s(){i.setFromEuler(t,!1)}function o(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ve},normalMatrix:{value:new Ze}}),this.matrix=new Ve,this.matrixWorld=new Ve,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Hs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ys.setFromAxisAngle(e,t),this.quaternion.multiply(ys),this}rotateOnWorldAxis(e,t){return ys.setFromAxisAngle(e,t),this.quaternion.premultiply(ys),this}rotateX(e){return this.rotateOnAxis(Dg,e)}rotateY(e){return this.rotateOnAxis(Og,e)}rotateZ(e){return this.rotateOnAxis(Ug,e)}translateOnAxis(e,t){return Lg.copy(e).applyQuaternion(this.quaternion),this.position.add(Lg.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dg,e)}translateY(e){return this.translateOnAxis(Og,e)}translateZ(e){return this.translateOnAxis(Ug,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ai.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Oc.copy(e):Oc.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Ro.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ai.lookAt(Ro,Oc,this.up):ai.lookAt(Oc,Ro,this.up),this.quaternion.setFromRotationMatrix(ai),r&&(ai.extractRotation(r.matrixWorld),ys.setFromRotationMatrix(ai),this.quaternion.premultiply(ys.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ng),vs.child=e,this.dispatchEvent(vs),vs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(kS),Wd.child=e,this.dispatchEvent(Wd),Wd.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ai.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ai.multiply(e.parent.matrixWorld)),e.applyMatrix4(ai),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ng),vs.child=e,this.dispatchEvent(vs),vs.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let o=this.children[i].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,e,NS),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ro,FS,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++){let a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let d=c[l];s(e.shapes,d)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),p=o(e.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=r,i;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};ct.DEFAULT_UP=new D(0,1,0);ct.DEFAULT_MATRIX_AUTO_UPDATE=!0;ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;Dn=new D,ci=new D,Xd=new D,li=new D,xs=new D,bs=new D,Fg=new D,qd=new D,Yd=new D,Zd=new D,pi=class n{constructor(e=new D,t=new D,i=new D){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Dn.subVectors(e,t),r.cross(Dn);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Dn.subVectors(r,t),ci.subVectors(i,t),Xd.subVectors(e,t);let o=Dn.dot(Dn),a=Dn.dot(ci),c=Dn.dot(Xd),l=ci.dot(ci),u=ci.dot(Xd),d=o*l-a*a;if(d===0)return s.set(0,0,0),null;let h=1/d,f=(l*c-a*u)*h,p=(o*u-a*c)*h;return s.set(1-f-p,p,f)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,li)===null?!1:li.x>=0&&li.y>=0&&li.x+li.y<=1}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,li)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,li.x),c.addScaledVector(o,li.y),c.addScaledVector(a,li.z),c)}static isFrontFacing(e,t,i,r){return Dn.subVectors(i,t),ci.subVectors(e,t),Dn.cross(ci).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Dn.subVectors(this.c,this.b),ci.subVectors(this.a,this.b),Dn.cross(ci).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,o,a;xs.subVectors(r,i),bs.subVectors(s,i),qd.subVectors(e,i);let c=xs.dot(qd),l=bs.dot(qd);if(c<=0&&l<=0)return t.copy(i);Yd.subVectors(e,r);let u=xs.dot(Yd),d=bs.dot(Yd);if(u>=0&&d<=u)return t.copy(r);let h=c*d-u*l;if(h<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(i).addScaledVector(xs,o);Zd.subVectors(e,s);let f=xs.dot(Zd),p=bs.dot(Zd);if(p>=0&&f<=p)return t.copy(s);let y=f*l-c*p;if(y<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(i).addScaledVector(bs,a);let g=u*p-f*d;if(g<=0&&d-u>=0&&f-p>=0)return Fg.subVectors(s,r),a=(d-u)/(d-u+(f-p)),t.copy(r).addScaledVector(Fg,a);let m=1/(g+y+h);return o=y*m,a=h*m,t.copy(i).addScaledVector(xs,o).addScaledVector(bs,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},hv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zi={h:0,s:0,l:0},Uc={h:0,s:0,l:0};Ie=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Mn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,dt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=dt.workingColorSpace){return this.r=e,this.g=t,this.b=i,dt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=dt.workingColorSpace){if(e=Rp(e,1),t=Mt(t,0,1),i=Mt(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=Jd(o,s,e+1/3),this.g=Jd(o,s,e),this.b=Jd(o,s,e-1/3)}return dt.toWorkingColorSpace(this,r),this}setStyle(e,t=Mn){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Mn){let i=hv[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ks(e.r),this.g=ks(e.g),this.b=ks(e.b),this}copyLinearToSRGB(e){return this.r=kd(e.r),this.g=kd(e.g),this.b=kd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mn){return dt.fromWorkingColorSpace(qt.copy(this),e),Math.round(Mt(qt.r*255,0,255))*65536+Math.round(Mt(qt.g*255,0,255))*256+Math.round(Mt(qt.b*255,0,255))}getHexString(e=Mn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dt.workingColorSpace){dt.fromWorkingColorSpace(qt.copy(this),t);let i=qt.r,r=qt.g,s=qt.b,o=Math.max(i,r,s),a=Math.min(i,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=u<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-i)/d+2;break;case s:c=(i-r)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=dt.workingColorSpace){return dt.fromWorkingColorSpace(qt.copy(this),t),e.r=qt.r,e.g=qt.g,e.b=qt.b,e}getStyle(e=Mn){dt.fromWorkingColorSpace(qt.copy(this),e);let t=qt.r,i=qt.g,r=qt.b;return e!==Mn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(zi),this.setHSL(zi.h+e,zi.s+t,zi.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(zi),e.getHSL(Uc);let i=Ho(zi.h,Uc.h,t),r=Ho(zi.s,Uc.s,t),s=Ho(zi.l,Uc.l,t);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},qt=new Ie;Ie.NAMES=hv;BS=0,Ft=class extends Un{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:BS++}),this.uuid=dn(),this.name="",this.type="Material",this.blending=Or,this.side=xi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=El,this.blendDst=Al,this.blendEquation=ji,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=Xo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ir,this.stencilZFail=Ir,this.stencilZPass=Ir,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Or&&(i.blending=this.blending),this.side!==xi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==El&&(i.blendSrc=this.blendSrc),this.blendDst!==Al&&(i.blendDst=this.blendDst),this.blendEquation!==ji&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xo&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Kh&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ir&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ir&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ir&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},qn=class extends Ft{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},hi=zS();VS={toHalfFloat:sn,fromHalfFloat:zo},Tt=new D,Nc=new se,ot=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ra,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=En,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return dv("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Nc.fromBufferAttribute(this,t),Nc.applyMatrix3(e),this.setXY(t,Nc.x,Nc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix3(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyMatrix4(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.applyNormalMatrix(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Tt.fromBufferAttribute(this,t),Tt.transformDirection(e),this.setXYZ(t,Tt.x,Tt.y,Tt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Je(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ra&&(e.usage=this.usage),e}},nf=class extends ot{constructor(e,t,i){super(new Int8Array(e),t,i)}},rf=class extends ot{constructor(e,t,i){super(new Uint8Array(e),t,i)}},sf=class extends ot{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},of=class extends ot{constructor(e,t,i){super(new Int16Array(e),t,i)}},ca=class extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}},af=class extends ot{constructor(e,t,i){super(new Int32Array(e),t,i)}},la=class extends ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}},cf=class extends ot{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=zo(this.array[e*this.itemSize]);return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize]=sn(t),this}getY(e){let t=zo(this.array[e*this.itemSize+1]);return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+1]=sn(t),this}getZ(e){let t=zo(this.array[e*this.itemSize+2]);return this.normalized&&(t=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+2]=sn(t),this}getW(e){let t=zo(this.array[e*this.itemSize+3]);return this.normalized&&(t=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.array[e*this.itemSize+3]=sn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this.array[e+2]=sn(r),this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.array[e+0]=sn(t),this.array[e+1]=sn(i),this.array[e+2]=sn(r),this.array[e+3]=sn(s),this}},De=class extends ot{constructor(e,t,i){super(new Float32Array(e),t,i)}},$S=0,wn=new Ve,Kd=new ct,_s=new D,ln=new Bt,Po=new Bt,Ot=new D,et=class n extends Un{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$S++}),this.uuid=dn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(lv(e)?la:ca)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Ze().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return wn.makeRotationFromQuaternion(e),this.applyMatrix4(wn),this}rotateX(e){return wn.makeRotationX(e),this.applyMatrix4(wn),this}rotateY(e){return wn.makeRotationY(e),this.applyMatrix4(wn),this}rotateZ(e){return wn.makeRotationZ(e),this.applyMatrix4(wn),this}translate(e,t,i){return wn.makeTranslation(e,t,i),this.applyMatrix4(wn),this}scale(e,t,i){return wn.makeScale(e,t,i),this.applyMatrix4(wn),this}lookAt(e){return Kd.lookAt(e),Kd.updateMatrix(),this.applyMatrix4(Kd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_s).negate(),this.translate(_s.x,_s.y,_s.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new De(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];ln.setFromBufferAttribute(s),this.morphTargetsRelative?(Ot.addVectors(this.boundingBox.min,ln.min),this.boundingBox.expandByPoint(Ot),Ot.addVectors(this.boundingBox.max,ln.max),this.boundingBox.expandByPoint(Ot)):(this.boundingBox.expandByPoint(ln.min),this.boundingBox.expandByPoint(ln.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){let i=this.boundingSphere.center;if(ln.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];Po.setFromBufferAttribute(a),this.morphTargetsRelative?(Ot.addVectors(ln.min,Po.min),ln.expandByPoint(Ot),Ot.addVectors(ln.max,Po.max),ln.expandByPoint(Ot)):(ln.expandByPoint(Po.min),ln.expandByPoint(Po.max))}ln.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)Ot.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Ot));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Ot.fromBufferAttribute(a,l),c&&(_s.fromBufferAttribute(e,l),Ot.add(_s)),r=Math.max(r,i.distanceToSquared(Ot))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ot(new Float32Array(4*i.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let F=0;F<i.count;F++)a[F]=new D,c[F]=new D;let l=new D,u=new D,d=new D,h=new se,f=new se,p=new se,y=new D,g=new D;function m(F,A,S){l.fromBufferAttribute(i,F),u.fromBufferAttribute(i,A),d.fromBufferAttribute(i,S),h.fromBufferAttribute(s,F),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,S),u.sub(l),d.sub(l),f.sub(h),p.sub(h);let P=1/(f.x*p.y-p.x*f.y);isFinite(P)&&(y.copy(u).multiplyScalar(p.y).addScaledVector(d,-f.y).multiplyScalar(P),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-p.x).multiplyScalar(P),a[F].add(y),a[A].add(y),a[S].add(y),c[F].add(g),c[A].add(g),c[S].add(g))}let x=this.groups;x.length===0&&(x=[{start:0,count:e.count}]);for(let F=0,A=x.length;F<A;++F){let S=x[F],P=S.start,k=S.count;for(let O=P,H=P+k;O<H;O+=3)m(e.getX(O+0),e.getX(O+1),e.getX(O+2))}let v=new D,w=new D,N=new D,C=new D;function R(F){N.fromBufferAttribute(r,F),C.copy(N);let A=a[F];v.copy(A),v.sub(N.multiplyScalar(N.dot(A))).normalize(),w.crossVectors(C,A);let P=w.dot(c[F])<0?-1:1;o.setXYZW(F,v.x,v.y,v.z,P)}for(let F=0,A=x.length;F<A;++F){let S=x[F],P=S.start,k=S.count;for(let O=P,H=P+k;O<H;O+=3)R(e.getX(O+0)),R(e.getX(O+1)),R(e.getX(O+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new ot(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,f=i.count;h<f;h++)i.setXYZ(h,0,0,0);let r=new D,s=new D,o=new D,a=new D,c=new D,l=new D,u=new D,d=new D;if(e)for(let h=0,f=e.count;h<f;h+=3){let p=e.getX(h+0),y=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,g),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,y),l.fromBufferAttribute(i,g),a.add(u),c.add(u),l.add(u),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(y,c.x,c.y,c.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,f=t.count;h<f;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,s),d.subVectors(r,s),u.cross(d),i.setXYZ(h+0,u.x,u.y,u.z),i.setXYZ(h+1,u.x,u.y,u.z),i.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ot.fromBufferAttribute(e,t),Ot.normalize(),e.setXYZ(t,Ot.x,Ot.y,Ot.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,d=a.normalized,h=new l.constructor(c.length*u),f=0,p=0;for(let y=0,g=c.length;y<g;y++){a.isInterleavedBufferAttribute?f=c[y]*a.data.stride+a.offset:f=c[y]*u;for(let m=0;m<u;m++)h[p++]=l[f++]}return new ot(h,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,i);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,d=l.length;u<d;u++){let h=l[u],f=e(h,i);c.push(f)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let c in i){let l=i[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d];u.push(f.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],d=s[l];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},kg=new Ve,vr=new Xi,Fc=new Nt,Bg=new D,ws=new D,Ms=new D,Ss=new D,Qd=new D,kc=new D,Bc=new se,zc=new se,Vc=new se,zg=new D,Vg=new D,$g=new D,$c=new D,Hc=new D,St=class extends ct{constructor(e=new et,t=new qn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){kc.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],d=s[c];u!==0&&(Qd.fromBufferAttribute(d,e),o?kc.addScaledVector(Qd,u):kc.addScaledVector(Qd.sub(t),u))}t.add(kc)}return t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Fc.copy(i.boundingSphere),Fc.applyMatrix4(s),vr.copy(e.ray).recast(e.near),!(Fc.containsPoint(vr.origin)===!1&&(vr.intersectSphere(Fc,Bg)===null||vr.origin.distanceToSquared(Bg)>(e.far-e.near)**2))&&(kg.copy(s).invert(),vr.copy(e.ray).applyMatrix4(kg),!(i.boundingBox!==null&&vr.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,vr)))}_computeIntersections(e,t,i){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,f=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let w=x,N=v;w<N;w+=3){let C=a.getX(w),R=a.getX(w+1),F=a.getX(w+2);r=jc(this,m,e,i,l,u,d,C,R,F),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(a.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=a.getX(g),v=a.getX(g+1),w=a.getX(g+2);r=jc(this,o,e,i,l,u,d,x,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let p=0,y=h.length;p<y;p++){let g=h[p],m=o[g.materialIndex],x=Math.max(g.start,f.start),v=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let w=x,N=v;w<N;w+=3){let C=w,R=w+1,F=w+2;r=jc(this,m,e,i,l,u,d,C,R,F),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let p=Math.max(0,f.start),y=Math.min(c.count,f.start+f.count);for(let g=p,m=y;g<m;g+=3){let x=g,v=g+1,w=g+2;r=jc(this,o,e,i,l,u,d,x,v,w),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};kr=class n extends et{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],d=[],h=0,f=0;p("z","y","x",-1,-1,i,t,e,o,s,0),p("z","y","x",1,-1,i,t,-e,o,s,1),p("x","z","y",1,1,e,i,t,r,o,2),p("x","z","y",1,-1,e,i,-t,r,o,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(u,3)),this.setAttribute("uv",new De(d,2));function p(y,g,m,x,v,w,N,C,R,F,A){let S=w/R,P=N/F,k=w/2,O=N/2,H=C/2,W=R+1,J=F+1,ae=0,B=0,ne=new D;for(let ce=0;ce<J;ce++){let Me=ce*P-O;for(let fe=0;fe<W;fe++){let $e=fe*S-k;ne[y]=$e*x,ne[g]=Me*v,ne[m]=H,l.push(ne.x,ne.y,ne.z),ne[y]=0,ne[g]=0,ne[m]=C>0?1:-1,u.push(ne.x,ne.y,ne.z),d.push(fe/R),d.push(1-ce/F),ae+=1}}for(let ce=0;ce<F;ce++)for(let Me=0;Me<R;Me++){let fe=h+Me+W*ce,$e=h+Me+W*(ce+1),Y=h+(Me+1)+W*(ce+1),me=h+(Me+1)+W*ce;c.push(fe,$e,me),c.push($e,Y,me),B+=6}a.addGroup(f,B,A),f+=B,h+=ae}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};pv={clone:js,merge:en},GS=`void main() {
201
201
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
202
202
  }`,WS=`void main() {
203
203
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
204
- }`,pn=class extends Ft{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=GS,this.fragmentShader=WS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Hs(e.uniforms),this.uniformsGroups=jS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},js=class extends ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ve,this.projectionMatrix=new Ve,this.projectionMatrixInverse=new Ve,this.coordinateSystem=jn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Vi=new D,Hg=new se,jg=new se,Rt=class extends js{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=zs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Dr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return zs*2*Math.atan(Math.tan(Dr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Vi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,Hg,jg),t.subVectors(jg,Hg)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Dr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Ss=-90,Es=1,Tl=class extends ct{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Rt(Ss,Es,e,t);r.layers=this.layers,this.add(r);let s=new Rt(Ss,Es,e,t);s.layers=this.layers,this.add(s);let o=new Rt(Ss,Es,e,t);o.layers=this.layers,this.add(o);let a=new Rt(Ss,Es,e,t);a.layers=this.layers,this.add(a);let c=new Rt(Ss,Es,e,t);c.layers=this.layers,this.add(c);let l=new Rt(Ss,Es,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===jn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===sa)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},Nr=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:bi,super(e,t,i,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Il=class extends hn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Nr(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:It}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
204
+ }`,pn=class extends Ft{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=GS,this.fragmentShader=WS,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=js(e.uniforms),this.uniformsGroups=jS(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},Gs=class extends ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ve,this.projectionMatrix=new Ve,this.projectionMatrixInverse=new Ve,this.coordinateSystem=Gn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Vi=new D,Hg=new se,jg=new se,Rt=class extends Gs{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Vs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Nr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Vs*2*Math.atan(Math.tan(Nr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Vi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z),Vi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Vi.x,Vi.y).multiplyScalar(-e/Vi.z)}getViewSize(e,t){return this.getViewBounds(e,Hg,jg),t.subVectors(jg,Hg)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Nr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/l,r*=o.width/c,i*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Es=-90,As=1,Cl=class extends ct{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Rt(Es,As,e,t);r.layers=this.layers,this.add(r);let s=new Rt(Es,As,e,t);s.layers=this.layers,this.add(s);let o=new Rt(Es,As,e,t);o.layers=this.layers,this.add(o);let a=new Rt(Es,As,e,t);a.layers=this.layers,this.add(a);let c=new Rt(Es,As,e,t);c.layers=this.layers,this.add(c);let l=new Rt(Es,As,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===Gn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===sa)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let y=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,l),i.texture.generateMipmaps=y,e.setRenderTarget(i,5,r),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}},Br=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:bi,super(e,t,i,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Rl=class extends hn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Br(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:It}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
205
205
 
206
206
  varying vec3 vWorldDirection;
207
207
 
@@ -236,7 +236,7 @@ Program Info Log: `+k+`
236
236
  gl_FragColor = texture2D( tEquirect, sampleUV );
237
237
 
238
238
  }
239
- `},r=new Ur(5,5,5),s=new pn({name:"CubemapFromEquirect",uniforms:Hs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:nn,blending:gi});s.uniforms.tEquirect.value=t;let o=new St(r,s),a=t.minFilter;return t.minFilter===Hn&&(t.minFilter=It),new Tl(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},eh=new D,XS=new D,qS=new Ze,Vn=class{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=eh.subVectors(i,t).cross(XS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(eh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||qS.getNormalMatrix(e),r=this.coplanarPoint(eh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},gr=new Nt,Hc=new D,Fr=class{constructor(e=new Vn,t=new Vn,i=new Vn,r=new Vn,s=new Vn,o=new Vn){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=jn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],p=r[9],y=r[10],g=r[11],m=r[12],x=r[13],v=r[14],w=r[15];if(i[0].setComponents(c-s,h-l,g-f,w-m).normalize(),i[1].setComponents(c+s,h+l,g+f,w+m).normalize(),i[2].setComponents(c+o,h+u,g+p,w+x).normalize(),i[3].setComponents(c-o,h-u,g-p,w-x).normalize(),i[4].setComponents(c-a,h-d,g-y,w-v).normalize(),t===jn)i[5].setComponents(c+a,h+d,g+y,w+v).normalize();else if(t===sa)i[5].setComponents(a,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gr)}intersectsSprite(e){return gr.center.set(0,0,0),gr.radius=.7071067811865476,gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(gr)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Hc.x=r.normal.x>0?e.max.x:e.min.x,Hc.y=r.normal.y>0?e.max.y:e.min.y,Hc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Hc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};Gs=class n extends et{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,u=c+1,d=e/a,h=t/c,f=[],p=[],y=[],g=[];for(let m=0;m<u;m++){let x=m*h-o;for(let v=0;v<l;v++){let w=v*d-s;p.push(w,-x,0),y.push(0,0,1),g.push(v/a),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let x=0;x<a;x++){let v=x+l*m,w=x+l*(m+1),N=x+1+l*(m+1),C=x+1+l*m;f.push(v,w,C),f.push(w,N,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},ZS=`#ifdef USE_ALPHAHASH
239
+ `},r=new kr(5,5,5),s=new pn({name:"CubemapFromEquirect",uniforms:js(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:nn,blending:gi});s.uniforms.tEquirect.value=t;let o=new St(r,s),a=t.minFilter;return t.minFilter===jn&&(t.minFilter=It),new Cl(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}},eh=new D,XS=new D,qS=new Ze,$n=class{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=eh.subVectors(i,t).cross(XS.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(eh),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||qS.getNormalMatrix(e),r=this.coplanarPoint(eh).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},xr=new Nt,Gc=new D,zr=class{constructor(e=new $n,t=new $n,i=new $n,r=new $n,s=new $n,o=new $n){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Gn){let i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],d=r[6],h=r[7],f=r[8],p=r[9],y=r[10],g=r[11],m=r[12],x=r[13],v=r[14],w=r[15];if(i[0].setComponents(c-s,h-l,g-f,w-m).normalize(),i[1].setComponents(c+s,h+l,g+f,w+m).normalize(),i[2].setComponents(c+o,h+u,g+p,w+x).normalize(),i[3].setComponents(c-o,h-u,g-p,w-x).normalize(),i[4].setComponents(c-a,h-d,g-y,w-v).normalize(),t===Gn)i[5].setComponents(c+a,h+d,g+y,w+v).normalize();else if(t===sa)i[5].setComponents(a,d,y,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),xr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xr)}intersectsSprite(e){return xr.center.set(0,0,0),xr.radius=.7071067811865476,xr.applyMatrix4(e.matrixWorld),this.intersectsSphere(xr)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Gc.x=r.normal.x>0?e.max.x:e.min.x,Gc.y=r.normal.y>0?e.max.y:e.min.y,Gc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};Ws=class n extends et{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(i),c=Math.floor(r),l=a+1,u=c+1,d=e/a,h=t/c,f=[],p=[],y=[],g=[];for(let m=0;m<u;m++){let x=m*h-o;for(let v=0;v<l;v++){let w=v*d-s;p.push(w,-x,0),y.push(0,0,1),g.push(v/a),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let x=0;x<a;x++){let v=x+l*m,w=x+l*(m+1),N=x+1+l*(m+1),C=x+1+l*m;f.push(v,w,C),f.push(w,N,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},ZS=`#ifdef USE_ALPHAHASH
240
240
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
241
241
  #endif`,JS=`#ifdef USE_ALPHAHASH
242
242
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3766,7 +3766,7 @@ void main() {
3766
3766
  #include <tonemapping_fragment>
3767
3767
  #include <colorspace_fragment>
3768
3768
  #include <fog_fragment>
3769
- }`,Ke={alphahash_fragment:ZS,alphahash_pars_fragment:JS,alphamap_fragment:KS,alphamap_pars_fragment:QS,alphatest_fragment:e1,alphatest_pars_fragment:t1,aomap_fragment:n1,aomap_pars_fragment:i1,batching_pars_vertex:r1,batching_vertex:s1,begin_vertex:o1,beginnormal_vertex:a1,bsdfs:c1,iridescence_fragment:l1,bumpmap_pars_fragment:u1,clipping_planes_fragment:d1,clipping_planes_pars_fragment:h1,clipping_planes_pars_vertex:f1,clipping_planes_vertex:p1,color_fragment:m1,color_pars_fragment:g1,color_pars_vertex:y1,color_vertex:v1,common:x1,cube_uv_reflection_fragment:b1,defaultnormal_vertex:_1,displacementmap_pars_vertex:w1,displacementmap_vertex:M1,emissivemap_fragment:S1,emissivemap_pars_fragment:E1,colorspace_fragment:A1,colorspace_pars_fragment:T1,envmap_fragment:I1,envmap_common_pars_fragment:C1,envmap_pars_fragment:R1,envmap_pars_vertex:P1,envmap_physical_pars_fragment:$1,envmap_vertex:L1,fog_vertex:D1,fog_pars_vertex:O1,fog_fragment:U1,fog_pars_fragment:N1,gradientmap_pars_fragment:F1,lightmap_pars_fragment:k1,lights_lambert_fragment:B1,lights_lambert_pars_fragment:z1,lights_pars_begin:V1,lights_toon_fragment:H1,lights_toon_pars_fragment:j1,lights_phong_fragment:G1,lights_phong_pars_fragment:W1,lights_physical_fragment:X1,lights_physical_pars_fragment:q1,lights_fragment_begin:Y1,lights_fragment_maps:Z1,lights_fragment_end:J1,logdepthbuf_fragment:K1,logdepthbuf_pars_fragment:Q1,logdepthbuf_pars_vertex:eE,logdepthbuf_vertex:tE,map_fragment:nE,map_pars_fragment:iE,map_particle_fragment:rE,map_particle_pars_fragment:sE,metalnessmap_fragment:oE,metalnessmap_pars_fragment:aE,morphinstance_vertex:cE,morphcolor_vertex:lE,morphnormal_vertex:uE,morphtarget_pars_vertex:dE,morphtarget_vertex:hE,normal_fragment_begin:fE,normal_fragment_maps:pE,normal_pars_fragment:mE,normal_pars_vertex:gE,normal_vertex:yE,normalmap_pars_fragment:vE,clearcoat_normal_fragment_begin:xE,clearcoat_normal_fragment_maps:bE,clearcoat_pars_fragment:_E,iridescence_pars_fragment:wE,opaque_fragment:ME,packing:SE,premultiplied_alpha_fragment:EE,project_vertex:AE,dithering_fragment:TE,dithering_pars_fragment:IE,roughnessmap_fragment:CE,roughnessmap_pars_fragment:RE,shadowmap_pars_fragment:PE,shadowmap_pars_vertex:LE,shadowmap_vertex:DE,shadowmask_pars_fragment:OE,skinbase_vertex:UE,skinning_pars_vertex:NE,skinning_vertex:FE,skinnormal_vertex:kE,specularmap_fragment:BE,specularmap_pars_fragment:zE,tonemapping_fragment:VE,tonemapping_pars_fragment:$E,transmission_fragment:HE,transmission_pars_fragment:jE,uv_pars_fragment:GE,uv_pars_vertex:WE,uv_vertex:XE,worldpos_vertex:qE,background_vert:YE,background_frag:ZE,backgroundCube_vert:JE,backgroundCube_frag:KE,cube_vert:QE,cube_frag:eA,depth_vert:tA,depth_frag:nA,distanceRGBA_vert:iA,distanceRGBA_frag:rA,equirect_vert:sA,equirect_frag:oA,linedashed_vert:aA,linedashed_frag:cA,meshbasic_vert:lA,meshbasic_frag:uA,meshlambert_vert:dA,meshlambert_frag:hA,meshmatcap_vert:fA,meshmatcap_frag:pA,meshnormal_vert:mA,meshnormal_frag:gA,meshphong_vert:yA,meshphong_frag:vA,meshphysical_vert:xA,meshphysical_frag:bA,meshtoon_vert:_A,meshtoon_frag:wA,points_vert:MA,points_frag:SA,shadow_vert:EA,shadow_frag:AA,sprite_vert:TA,sprite_frag:IA},Ee={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ze}},envmap:{envMap:{value:null},envMapRotation:{value:new Ze},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ze},normalScale:{value:new se(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0},uvTransform:{value:new Ze}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new se(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}}},Dn={basic:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:en([Ee.common,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.roughnessmap,Ee.metalnessmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:en([Ee.common,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.gradientmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:en([Ee.points,Ee.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:en([Ee.common,Ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:en([Ee.common,Ee.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:en([Ee.sprite,Ee.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new Ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ze}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distanceRGBA:{uniforms:en([Ee.common,Ee.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distanceRGBA_vert,fragmentShader:Ke.distanceRGBA_frag},shadow:{uniforms:en([Ee.lights,Ee.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};Dn.physical={uniforms:en([Dn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ze},clearcoatNormalScale:{value:new se(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ze},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ze},transmissionSamplerSize:{value:new se},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ze},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ze},anisotropyVector:{value:new se},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ze}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};jc={r:0,b:0,g:0},yr=new fn,CA=new Ve;Ws=class extends js{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Us=4,Gg=[.125,.215,.35,.446,.526,.582],Tr=20,th=new Ws,Wg=new Ie,nh=null,ih=0,rh=0,sh=!1,Ar=(1+Math.sqrt(5))/2,As=1/Ar,Xg=[new D(-Ar,As,0),new D(Ar,As,0),new D(-As,0,Ar),new D(As,0,Ar),new D(0,Ar,-As),new D(0,Ar,As),new D(-1,1,-1),new D(1,1,-1),new D(-1,1,1),new D(1,1,1)],ua=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Yg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(nh,ih,rh),this._renderer.xr.enabled=sh,e.scissorTest=!1,Gc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===bi||e.mapping===Wi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:It,minFilter:It,generateMipmaps:!1,type:Na,format:un,colorSpace:Si,depthBuffer:!1},r=qg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=qg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=NA(s)),this._blurMaterial=FA(s,e,t)}return r}_compileMaterial(e){let t=new St(this._lodPlanes[0],e);this._renderer.compile(t,th)}_sceneToCubeUV(e,t,i,r){let a=new Rt(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(Wg),u.toneMapping=yi,u.autoClear=!1;let f=new Xn({name:"PMREM.Background",side:nn,depthWrite:!1,depthTest:!1}),p=new St(new Ur,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Wg),y=!0);for(let m=0;m<6;m++){let x=m%3;x===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):x===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m]));let v=this._cubeSize;Gc(r,x*v,m>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===bi||e.mapping===Wi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Yg());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new St(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Gc(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,th)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Xg[(r-s-1)%Xg.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new St(this._lodPlanes[r],l),h=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Tr-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):Tr;g>Tr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Tr}`);let m=[],x=0;for(let R=0;R<Tr;++R){let F=R/y,A=Math.exp(-F*F/2);m.push(A),R===0?x+=A:R<g&&(x+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/x;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=m,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:v}=this;h.dTheta.value=p,h.mipInt.value=v-i;let w=this._sizeLods[r],N=3*w*(r>v-Us?r-v+Us:0),C=4*(this._cubeSize-w);Gc(t,N,C,3*w,2*w),c.setRenderTarget(t),c.render(d,th)}};da=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){if(u=u!==void 0?u:Lr,u!==Lr&&u!==Bs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Lr&&(i=Or),i===void 0&&u===Bs&&(i=Ks),super(null,r,s,o,a,c,u,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ut,this.minFilter=c!==void 0?c:Ut,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},gv=new Ct,yv=new da(1,1);yv.compareFunction=Cp;vv=new Vs,xv=new aa,bv=new Nr,Jg=[],Kg=[],Qg=new Float32Array(16),ey=new Float32Array(9),ty=new Float32Array(4);lf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=uT(t.type)}},uf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=RT(t.type)}},df=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},oh=/(\w+)(\])?(\[|\.)?/g;ks=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);PT(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};LT=37297,DT=0;VT=/^[ \t]*#include +<([\w\d./]+)>/gm;$T=new Map;jT=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;KT=0,ff=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pf(e),t.set(e,i)),i}},pf=class{constructor(e){this.id=KT++,this.code=e,this.usedTimes=0}};sI=0;ha=class extends Ft{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Q0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},fa=class extends Ft{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},lI=`void main() {
3769
+ }`,Ke={alphahash_fragment:ZS,alphahash_pars_fragment:JS,alphamap_fragment:KS,alphamap_pars_fragment:QS,alphatest_fragment:e1,alphatest_pars_fragment:t1,aomap_fragment:n1,aomap_pars_fragment:i1,batching_pars_vertex:r1,batching_vertex:s1,begin_vertex:o1,beginnormal_vertex:a1,bsdfs:c1,iridescence_fragment:l1,bumpmap_pars_fragment:u1,clipping_planes_fragment:d1,clipping_planes_pars_fragment:h1,clipping_planes_pars_vertex:f1,clipping_planes_vertex:p1,color_fragment:m1,color_pars_fragment:g1,color_pars_vertex:y1,color_vertex:v1,common:x1,cube_uv_reflection_fragment:b1,defaultnormal_vertex:_1,displacementmap_pars_vertex:w1,displacementmap_vertex:M1,emissivemap_fragment:S1,emissivemap_pars_fragment:E1,colorspace_fragment:A1,colorspace_pars_fragment:T1,envmap_fragment:I1,envmap_common_pars_fragment:C1,envmap_pars_fragment:R1,envmap_pars_vertex:P1,envmap_physical_pars_fragment:$1,envmap_vertex:L1,fog_vertex:D1,fog_pars_vertex:O1,fog_fragment:U1,fog_pars_fragment:N1,gradientmap_pars_fragment:F1,lightmap_pars_fragment:k1,lights_lambert_fragment:B1,lights_lambert_pars_fragment:z1,lights_pars_begin:V1,lights_toon_fragment:H1,lights_toon_pars_fragment:j1,lights_phong_fragment:G1,lights_phong_pars_fragment:W1,lights_physical_fragment:X1,lights_physical_pars_fragment:q1,lights_fragment_begin:Y1,lights_fragment_maps:Z1,lights_fragment_end:J1,logdepthbuf_fragment:K1,logdepthbuf_pars_fragment:Q1,logdepthbuf_pars_vertex:eE,logdepthbuf_vertex:tE,map_fragment:nE,map_pars_fragment:iE,map_particle_fragment:rE,map_particle_pars_fragment:sE,metalnessmap_fragment:oE,metalnessmap_pars_fragment:aE,morphinstance_vertex:cE,morphcolor_vertex:lE,morphnormal_vertex:uE,morphtarget_pars_vertex:dE,morphtarget_vertex:hE,normal_fragment_begin:fE,normal_fragment_maps:pE,normal_pars_fragment:mE,normal_pars_vertex:gE,normal_vertex:yE,normalmap_pars_fragment:vE,clearcoat_normal_fragment_begin:xE,clearcoat_normal_fragment_maps:bE,clearcoat_pars_fragment:_E,iridescence_pars_fragment:wE,opaque_fragment:ME,packing:SE,premultiplied_alpha_fragment:EE,project_vertex:AE,dithering_fragment:TE,dithering_pars_fragment:IE,roughnessmap_fragment:CE,roughnessmap_pars_fragment:RE,shadowmap_pars_fragment:PE,shadowmap_pars_vertex:LE,shadowmap_vertex:DE,shadowmask_pars_fragment:OE,skinbase_vertex:UE,skinning_pars_vertex:NE,skinning_vertex:FE,skinnormal_vertex:kE,specularmap_fragment:BE,specularmap_pars_fragment:zE,tonemapping_fragment:VE,tonemapping_pars_fragment:$E,transmission_fragment:HE,transmission_pars_fragment:jE,uv_pars_fragment:GE,uv_pars_vertex:WE,uv_vertex:XE,worldpos_vertex:qE,background_vert:YE,background_frag:ZE,backgroundCube_vert:JE,backgroundCube_frag:KE,cube_vert:QE,cube_frag:eA,depth_vert:tA,depth_frag:nA,distanceRGBA_vert:iA,distanceRGBA_frag:rA,equirect_vert:sA,equirect_frag:oA,linedashed_vert:aA,linedashed_frag:cA,meshbasic_vert:lA,meshbasic_frag:uA,meshlambert_vert:dA,meshlambert_frag:hA,meshmatcap_vert:fA,meshmatcap_frag:pA,meshnormal_vert:mA,meshnormal_frag:gA,meshphong_vert:yA,meshphong_frag:vA,meshphysical_vert:xA,meshphysical_frag:bA,meshtoon_vert:_A,meshtoon_frag:wA,points_vert:MA,points_frag:SA,shadow_vert:EA,shadow_frag:AA,sprite_vert:TA,sprite_frag:IA},Ee={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ze}},envmap:{envMap:{value:null},envMapRotation:{value:new Ze},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ze},normalScale:{value:new se(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0},uvTransform:{value:new Ze}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new se(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}}},On={basic:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:en([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:en([Ee.common,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.roughnessmap,Ee.metalnessmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:en([Ee.common,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.gradientmap,Ee.fog,Ee.lights,{emissive:{value:new Ie(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:en([Ee.points,Ee.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:en([Ee.common,Ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:en([Ee.common,Ee.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:en([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:en([Ee.sprite,Ee.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new Ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ze}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distanceRGBA:{uniforms:en([Ee.common,Ee.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distanceRGBA_vert,fragmentShader:Ke.distanceRGBA_frag},shadow:{uniforms:en([Ee.lights,Ee.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};On.physical={uniforms:en([On.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ze},clearcoatNormalScale:{value:new se(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ze},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ze},transmissionSamplerSize:{value:new se},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ze},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ze},anisotropyVector:{value:new se},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ze}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};Wc={r:0,b:0,g:0},br=new fn,CA=new Ve;Xs=class extends Gs{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ns=4,Gg=[.125,.215,.35,.446,.526,.582],Rr=20,th=new Xs,Wg=new Ie,nh=null,ih=0,rh=0,sh=!1,Cr=(1+Math.sqrt(5))/2,Ts=1/Cr,Xg=[new D(-Cr,Ts,0),new D(Cr,Ts,0),new D(-Ts,0,Cr),new D(Ts,0,Cr),new D(0,Cr,-Ts),new D(0,Cr,Ts),new D(-1,1,-1),new D(1,1,-1),new D(-1,1,1),new D(1,1,1)],ua=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Yg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(nh,ih,rh),this._renderer.xr.enabled=sh,e.scissorTest=!1,Xc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===bi||e.mapping===Wi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nh=this._renderer.getRenderTarget(),ih=this._renderer.getActiveCubeFace(),rh=this._renderer.getActiveMipmapLevel(),sh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:It,minFilter:It,generateMipmaps:!1,type:Na,format:un,colorSpace:Si,depthBuffer:!1},r=qg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=qg(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=NA(s)),this._blurMaterial=FA(s,e,t)}return r}_compileMaterial(e){let t=new St(this._lodPlanes[0],e);this._renderer.compile(t,th)}_sceneToCubeUV(e,t,i,r){let a=new Rt(90,1,t,i),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,h=u.toneMapping;u.getClearColor(Wg),u.toneMapping=yi,u.autoClear=!1;let f=new qn({name:"PMREM.Background",side:nn,depthWrite:!1,depthTest:!1}),p=new St(new kr,f),y=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,y=!0):(f.color.copy(Wg),y=!0);for(let m=0;m<6;m++){let x=m%3;x===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):x===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m]));let v=this._cubeSize;Xc(r,x*v,m>2?v:0,v,v),u.setRenderTarget(r),y&&u.render(p,a),u.render(e,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=h,u.autoClear=d,e.background=g}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===bi||e.mapping===Wi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Yg());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new St(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Xc(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,th)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=Xg[(r-s-1)%Xg.length];this._blur(e,s-1,s,o,a)}t.autoClear=i}_blur(e,t,i,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,d=new St(this._lodPlanes[r],l),h=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Rr-1),y=s/p,g=isFinite(s)?1+Math.floor(u*y):Rr;g>Rr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Rr}`);let m=[],x=0;for(let R=0;R<Rr;++R){let F=R/y,A=Math.exp(-F*F/2);m.push(A),R===0?x+=A:R<g&&(x+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/x;h.envMap.value=e.texture,h.samples.value=g,h.weights.value=m,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:v}=this;h.dTheta.value=p,h.mipInt.value=v-i;let w=this._sizeLods[r],N=3*w*(r>v-Ns?r-v+Ns:0),C=4*(this._cubeSize-w);Xc(t,N,C,3*w,2*w),c.setRenderTarget(t),c.render(d,th)}};da=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u){if(u=u!==void 0?u:Ur,u!==Ur&&u!==zs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Ur&&(i=Fr),i===void 0&&u===zs&&(i=Qs),super(null,r,s,o,a,c,u,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ut,this.minFilter=c!==void 0?c:Ut,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},gv=new Ct,yv=new da(1,1);yv.compareFunction=Cp;vv=new $s,xv=new aa,bv=new Br,Jg=[],Kg=[],Qg=new Float32Array(16),ey=new Float32Array(9),ty=new Float32Array(4);lf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=uT(t.type)}},uf=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=RT(t.type)}},df=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],i)}}},oh=/(\w+)(\])?(\[|\.)?/g;Bs=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);PT(s,o,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=i[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&i.push(o)}return i}};LT=37297,DT=0;VT=/^[ \t]*#include +<([\w\d./]+)>/gm;$T=new Map;jT=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;KT=0,ff=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pf(e),t.set(e,i)),i}},pf=class{constructor(e){this.id=KT++,this.code=e,this.usedTimes=0}};sI=0;ha=class extends Ft{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Q0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},fa=class extends Ft{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},lI=`void main() {
3770
3770
  gl_Position = vec4( position, 1.0 );
3771
3771
  }`,uI=`uniform sampler2D shadow_pass;
3772
3772
  uniform vec2 resolution;
@@ -3794,7 +3794,7 @@ void main() {
3794
3794
  squared_mean = squared_mean / samples;
3795
3795
  float std_dev = sqrt( squared_mean - mean * mean );
3796
3796
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3797
- }`;Cl=class extends Rt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Gi=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},pI={type:"move"},jo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),m=this._getHandJoint(l,y);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,p=.005;l.inputState.pinching&&h>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(pI)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Gi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},mI=`
3797
+ }`;Pl=class extends Rt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Gi=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},pI={type:"move"},jo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Gi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),m=this._getHandJoint(l,y);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,p=.005;l.inputState.pinching&&h>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(pI)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Gi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},mI=`
3798
3798
  void main() {
3799
3799
 
3800
3800
  gl_Position = vec4( position, 1.0 );
@@ -3818,17 +3818,17 @@ void main() {
3818
3818
 
3819
3819
  }
3820
3820
 
3821
- }`,mf=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Ct,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new pn({vertexShader:mI,fragmentShader:gI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new St(new Gs(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},gf=class extends On{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,d=null,h=null,f=null,p=null,y=new mf,g=t.getContextAttributes(),m=null,x=null,v=[],w=[],N=new se,C=null,R=new Rt;R.layers.enable(1),R.viewport=new ht;let F=new Rt;F.layers.enable(2),F.viewport=new ht;let A=[R,F],S=new Cl;S.layers.enable(1),S.layers.enable(2);let P=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getTargetRaySpace()},this.getControllerGrip=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getGripSpace()},this.getHand=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getHandSpace()};function O(Y){let me=w.indexOf(Y.inputSource);if(me===-1)return;let te=v[me];te!==void 0&&(te.update(Y.inputSource,Y.frame,l||o),te.dispatchEvent({type:Y.type,data:Y.inputSource}))}function H(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",W);for(let Y=0;Y<v.length;Y++){let me=w[Y];me!==null&&(w[Y]=null,v[Y].disconnect(me))}P=null,k=null,y.reset(),e.setRenderTarget(m),f=null,h=null,d=null,r=null,x=null,$e.stop(),i.isPresenting=!1,e.setPixelRatio(C),e.setSize(N.width,N.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",H),r.addEventListener("inputsourceschange",W),g.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(N),r.renderState.layers===void 0){let me={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,me),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new hn(f.framebufferWidth,f.framebufferHeight,{format:un,type:_i,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let me=null,te=null,ue=null;g.depth&&(ue=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=g.stencil?Bs:Lr,te=g.stencil?Ks:Or);let Pe={colorFormat:t.RGBA8,depthFormat:ue,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(Pe),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),x=new hn(h.textureWidth,h.textureHeight,{format:un,type:_i,depthTexture:new da(h.textureWidth,h.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),$e.setContext(r),$e.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function W(Y){for(let me=0;me<Y.removed.length;me++){let te=Y.removed[me],ue=w.indexOf(te);ue>=0&&(w[ue]=null,v[ue].disconnect(te))}for(let me=0;me<Y.added.length;me++){let te=Y.added[me],ue=w.indexOf(te);if(ue===-1){for(let _e=0;_e<v.length;_e++)if(_e>=w.length){w.push(te),ue=_e;break}else if(w[_e]===null){w[_e]=te,ue=_e;break}if(ue===-1)break}let Pe=v[ue];Pe&&Pe.connect(te)}}let J=new D,ae=new D;function B(Y,me,te){J.setFromMatrixPosition(me.matrixWorld),ae.setFromMatrixPosition(te.matrixWorld);let ue=J.distanceTo(ae),Pe=me.projectionMatrix.elements,_e=te.projectionMatrix.elements,z=Pe[14]/(Pe[10]-1),Be=Pe[14]/(Pe[10]+1),X=(Pe[9]+1)/Pe[5],de=(Pe[9]-1)/Pe[5],Z=(Pe[8]-1)/Pe[0],he=(_e[8]+1)/_e[0],ie=z*Z,ye=z*he,Te=ue/(-Z+he),U=Te*-Z;me.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(U),Y.translateZ(Te),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert();let T=z+Te,G=Be+Te,ee=ie-U,oe=ye+(ue-U),re=X*Be/G*T,Ue=de*Be/G*T;Y.projectionMatrix.makePerspective(ee,oe,re,Ue,T,G),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}function ne(Y,me){me===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(me.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;y.texture!==null&&(Y.near=y.depthNear,Y.far=y.depthFar),S.near=F.near=R.near=Y.near,S.far=F.far=R.far=Y.far,(P!==S.near||k!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),P=S.near,k=S.far,R.near=P,R.far=k,F.near=P,F.far=k,R.updateProjectionMatrix(),F.updateProjectionMatrix(),Y.updateProjectionMatrix());let me=Y.parent,te=S.cameras;ne(S,me);for(let ue=0;ue<te.length;ue++)ne(te[ue],me);te.length===2?B(S,R,F):S.projectionMatrix.copy(R.projectionMatrix),ce(Y,S,me)};function ce(Y,me,te){te===null?Y.matrix.copy(me.matrixWorld):(Y.matrix.copy(te.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(me.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(me.projectionMatrix),Y.projectionMatrixInverse.copy(me.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=zs*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function(Y){c=Y,h!==null&&(h.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return y.texture!==null};let Me=null;function fe(Y,me){if(u=me.getViewerPose(l||o),p=me,u!==null){let te=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let ue=!1;te.length!==S.cameras.length&&(S.cameras.length=0,ue=!0);for(let _e=0;_e<te.length;_e++){let z=te[_e],Be=null;if(f!==null)Be=f.getViewport(z);else{let de=d.getViewSubImage(h,z);Be=de.viewport,_e===0&&(e.setRenderTargetTextures(x,de.colorTexture,h.ignoreDepthValues?void 0:de.depthStencilTexture),e.setRenderTarget(x))}let X=A[_e];X===void 0&&(X=new Rt,X.layers.enable(_e),X.viewport=new ht,A[_e]=X),X.matrix.fromArray(z.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(z.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(Be.x,Be.y,Be.width,Be.height),_e===0&&(S.matrix.copy(X.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),ue===!0&&S.cameras.push(X)}let Pe=r.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")){let _e=d.getDepthInformation(te[0]);_e&&_e.isValid&&_e.texture&&y.init(e,_e,r.renderState)}}for(let te=0;te<v.length;te++){let ue=w[te],Pe=v[te];ue!==null&&Pe!==void 0&&Pe.update(ue,me,l||o)}y.render(e,S),Me&&Me(Y,me),me.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:me}),p=null}let $e=new mv;$e.setAnimationLoop(fe),this.setAnimationLoop=function(Y){Me=Y},this.dispose=function(){}}},vr=new fn,yI=new Ve;yf=class{constructor(e={}){let{canvas:t=uv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;let f=new Uint32Array(4),p=new Int32Array(4),y=null,g=null,m=[],x=[];this.domElement=t,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._outputColorSpace=wn,this._useLegacyLights=!1,this.toneMapping=yi,this.toneMappingExposure=1;let v=this,w=!1,N=0,C=0,R=null,F=-1,A=null,S=new ht,P=new ht,k=null,O=new Ie(0),H=0,W=t.width,J=t.height,ae=1,B=null,ne=null,ce=new ht(0,0,W,J),Me=new ht(0,0,W,J),fe=!1,$e=new Fr,Y=!1,me=!1,te=new Ve,ue=new D,Pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return R===null?ae:1}let z=i;function Be(b,_){return t.getContext(b,_)}try{let b={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",le,!1),t.addEventListener("webglcontextcreationerror",K,!1),z===null){let _="webgl2";if(z=Be(_,b),z===null)throw Be(_)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(b){throw console.error("THREE.WebGLRenderer: "+b.message),b}let X,de,Z,he,ie,ye,Te,U,T,G,ee,oe,re,Ue,ve,xe,He,pe,Oe,qe,Ne,Ce,Fe,Qe;function pt(){X=new BA(z),X.init(),Ce=new _v(z,X),de=new DA(z,X,e,Ce),Z=new hI(z),he=new $A(z),ie=new eI,ye=new fI(z,X,Z,ie,de,Ce,he),Te=new UA(v),U=new kA(v),T=new YS(z),Fe=new PA(z,T),G=new zA(z,T,he,Fe),ee=new jA(z,G,T,he),Oe=new HA(z,de,ye),xe=new OA(ie),oe=new QT(v,Te,U,X,de,Fe,xe),re=new vI(v,ie),Ue=new nI,ve=new cI(X),pe=new RA(v,Te,U,Z,ee,h,c),He=new dI(v,ee,de),Qe=new xI(z,he,de,Z),qe=new LA(z,X,he),Ne=new VA(z,X,he),he.programs=oe.programs,v.capabilities=de,v.extensions=X,v.properties=ie,v.renderLists=Ue,v.shadowMap=He,v.state=Z,v.info=he}pt();let je=new gf(v,z);this.xr=je,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let b=X.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=X.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(b){b!==void 0&&(ae=b,this.setSize(W,J,!1))},this.getSize=function(b){return b.set(W,J)},this.setSize=function(b,_,M=!0){if(je.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=b,J=_,t.width=Math.floor(b*ae),t.height=Math.floor(_*ae),M===!0&&(t.style.width=b+"px",t.style.height=_+"px"),this.setViewport(0,0,b,_)},this.getDrawingBufferSize=function(b){return b.set(W*ae,J*ae).floor()},this.setDrawingBufferSize=function(b,_,M){W=b,J=_,ae=M,t.width=Math.floor(b*M),t.height=Math.floor(_*M),this.setViewport(0,0,b,_)},this.getCurrentViewport=function(b){return b.copy(S)},this.getViewport=function(b){return b.copy(ce)},this.setViewport=function(b,_,M,E){b.isVector4?ce.set(b.x,b.y,b.z,b.w):ce.set(b,_,M,E),Z.viewport(S.copy(ce).multiplyScalar(ae).round())},this.getScissor=function(b){return b.copy(Me)},this.setScissor=function(b,_,M,E){b.isVector4?Me.set(b.x,b.y,b.z,b.w):Me.set(b,_,M,E),Z.scissor(P.copy(Me).multiplyScalar(ae).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(b){Z.setScissorTest(fe=b)},this.setOpaqueSort=function(b){B=b},this.setTransparentSort=function(b){ne=b},this.getClearColor=function(b){return b.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(b=!0,_=!0,M=!0){let E=0;if(b){let I=!1;if(R!==null){let j=R.texture.format;I=j===Tp||j===Ap||j===Ep}if(I){let j=R.texture.type,Q=j===_i||j===Or||j===bp||j===Ks||j===wp||j===Mp,ge=pe.getClearColor(),Se=pe.getClearAlpha(),Le=ge.r,Ge=ge.g,ze=ge.b;Q?(f[0]=Le,f[1]=Ge,f[2]=ze,f[3]=Se,z.clearBufferuiv(z.COLOR,0,f)):(p[0]=Le,p[1]=Ge,p[2]=ze,p[3]=Se,z.clearBufferiv(z.COLOR,0,p))}else E|=z.COLOR_BUFFER_BIT}_&&(E|=z.DEPTH_BUFFER_BIT),M&&(E|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(E)},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.dispose=function(){t.removeEventListener("webglcontextlost",V,!1),t.removeEventListener("webglcontextrestored",le,!1),t.removeEventListener("webglcontextcreationerror",K,!1),Ue.dispose(),ve.dispose(),ie.dispose(),Te.dispose(),U.dispose(),ee.dispose(),Fe.dispose(),Qe.dispose(),oe.dispose(),je.dispose(),je.removeEventListener("sessionstart",rt),je.removeEventListener("sessionend",$t),Et.stop()};function V(b){b.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function le(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;let b=he.autoReset,_=He.enabled,M=He.autoUpdate,E=He.needsUpdate,I=He.type;pt(),he.autoReset=b,He.enabled=_,He.autoUpdate=M,He.needsUpdate=E,He.type=I}function K(b){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function we(b){let _=b.target;_.removeEventListener("dispose",we),Ae(_)}function Ae(b){Re(b),ie.remove(b)}function Re(b){let _=ie.get(b).programs;_!==void 0&&(_.forEach(function(M){oe.releaseProgram(M)}),b.isShaderMaterial&&oe.releaseShaderCache(b))}this.renderBufferDirect=function(b,_,M,E,I,j){_===null&&(_=Pe);let Q=I.isMesh&&I.matrixWorld.determinant()<0,ge=ar(b,_,M,E,I);Z.setMaterial(E,Q);let Se=M.index,Le=1;if(E.wireframe===!0){if(Se=G.getWireframeAttribute(M),Se===void 0)return;Le=2}let Ge=M.drawRange,ze=M.attributes.position,mt=Ge.start*Le,Ht=(Ge.start+Ge.count)*Le;j!==null&&(mt=Math.max(mt,j.start*Le),Ht=Math.min(Ht,(j.start+j.count)*Le)),Se!==null?(mt=Math.max(mt,0),Ht=Math.min(Ht,Se.count)):ze!=null&&(mt=Math.max(mt,0),Ht=Math.min(Ht,ze.count));let on=Ht-mt;if(on<0||on===1/0)return;Fe.setup(I,E,ge,M,Se);let ei,at=qe;if(Se!==null&&(ei=T.get(Se),at=Ne,at.setIndex(ei)),I.isMesh)E.wireframe===!0?(Z.setLineWidth(E.wireframeLinewidth*_e()),at.setMode(z.LINES)):at.setMode(z.TRIANGLES);else if(I.isLine){let Ye=E.linewidth;Ye===void 0&&(Ye=1),Z.setLineWidth(Ye*_e()),I.isLineSegments?at.setMode(z.LINES):I.isLineLoop?at.setMode(z.LINE_LOOP):at.setMode(z.LINE_STRIP)}else I.isPoints?at.setMode(z.POINTS):I.isSprite&&at.setMode(z.TRIANGLES);if(I.isBatchedMesh)I._multiDrawInstances!==null?at.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances):at.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else if(I.isInstancedMesh)at.renderInstances(mt,on,I.count);else if(M.isInstancedBufferGeometry){let Ye=M._maxInstanceCount!==void 0?M._maxInstanceCount:1/0,ro=Math.min(M.instanceCount,Ye);at.renderInstances(mt,on,ro)}else at.render(mt,on)};function tt(b,_,M){b.transparent===!0&&b.side===$n&&b.forceSinglePass===!1?(b.side=nn,b.needsUpdate=!0,Fn(b,_,M),b.side=xi,b.needsUpdate=!0,Fn(b,_,M),b.side=$n):Fn(b,_,M)}this.compile=function(b,_,M=null){M===null&&(M=b),g=ve.get(M),g.init(_),x.push(g),M.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),b!==M&&b.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),g.setupLights(v._useLegacyLights);let E=new Set;return b.traverse(function(I){let j=I.material;if(j)if(Array.isArray(j))for(let Q=0;Q<j.length;Q++){let ge=j[Q];tt(ge,M,I),E.add(ge)}else tt(j,M,I),E.add(j)}),x.pop(),g=null,E},this.compileAsync=function(b,_,M=null){let E=this.compile(b,_,M);return new Promise(I=>{function j(){if(E.forEach(function(Q){ie.get(Q).currentProgram.isReady()&&E.delete(Q)}),E.size===0){I(b);return}setTimeout(j,10)}X.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let ft=null;function vt(b){ft&&ft(b)}function rt(){Et.stop()}function $t(){Et.start()}let Et=new mv;Et.setAnimationLoop(vt),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(b){ft=b,je.setAnimationLoop(b),b===null?Et.stop():Et.start()},je.addEventListener("sessionstart",rt),je.addEventListener("sessionend",$t),this.render=function(b,_){if(_!==void 0&&_.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(_),_=je.getCamera()),b.isScene===!0&&b.onBeforeRender(v,b,_,R),g=ve.get(b,x.length),g.init(_),x.push(g),te.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),$e.setFromProjectionMatrix(te),me=this.localClippingEnabled,Y=xe.init(this.clippingPlanes,me),y=Ue.get(b,m.length),y.init(),m.push(y),Yr(b,_,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(B,ne);let M=je.enabled===!1||je.isPresenting===!1||je.hasDepthSensing()===!1;M&&pe.addToRenderList(y,b),this.info.render.frame++,Y===!0&&xe.beginShadows();let E=g.state.shadowsArray;He.render(E,b,_),Y===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset();let I=y.opaque,j=y.transmissive;if(g.setupLights(v._useLegacyLights),_.isArrayCamera){let Q=_.cameras;if(j.length>0)for(let ge=0,Se=Q.length;ge<Se;ge++){let Le=Q[ge];Nn(I,j,b,Le)}M&&pe.render(b);for(let ge=0,Se=Q.length;ge<Se;ge++){let Le=Q[ge];rr(y,b,Le,Le.viewport)}}else j.length>0&&Nn(I,j,b,_),M&&pe.render(b),rr(y,b,_);R!==null&&(ye.updateMultisampleRenderTarget(R),ye.updateRenderTargetMipmap(R)),b.isScene===!0&&b.onAfterRender(v,b,_),Fe.resetDefaultState(),F=-1,A=null,x.pop(),x.length>0?(g=x[x.length-1],Y===!0&&xe.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,m.pop(),m.length>0?y=m[m.length-1]:y=null};function Yr(b,_,M,E){if(b.visible===!1)return;if(b.layers.test(_.layers)){if(b.isGroup)M=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(_);else if(b.isLight)g.pushLight(b),b.castShadow&&g.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||$e.intersectsSprite(b)){E&&ue.setFromMatrixPosition(b.matrixWorld).applyMatrix4(te);let Q=ee.update(b),ge=b.material;ge.visible&&y.push(b,Q,ge,M,ue.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(!b.frustumCulled||$e.intersectsObject(b))){let Q=ee.update(b),ge=b.material;if(E&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),ue.copy(b.boundingSphere.center)):(Q.boundingSphere===null&&Q.computeBoundingSphere(),ue.copy(Q.boundingSphere.center)),ue.applyMatrix4(b.matrixWorld).applyMatrix4(te)),Array.isArray(ge)){let Se=Q.groups;for(let Le=0,Ge=Se.length;Le<Ge;Le++){let ze=Se[Le],mt=ge[ze.materialIndex];mt&&mt.visible&&y.push(b,Q,mt,M,ue.z,ze)}}else ge.visible&&y.push(b,Q,ge,M,ue.z,null)}}let j=b.children;for(let Q=0,ge=j.length;Q<ge;Q++)Yr(j[Q],_,M,E)}function rr(b,_,M,E){let I=b.opaque,j=b.transmissive,Q=b.transparent;g.setupLightsView(M),Y===!0&&xe.setGlobalState(v.clippingPlanes,M),E&&Z.viewport(S.copy(E)),I.length>0&&An(I,_,M),j.length>0&&An(j,_,M),Q.length>0&&An(Q,_,M),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Nn(b,_,M,E){if((M.isScene===!0?M.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[E.id]===void 0&&(g.state.transmissionRenderTarget[E.id]=new hn(1,1,{generateMipmaps:!0,type:X.has("EXT_color_buffer_half_float")||X.has("EXT_color_buffer_float")?Na:_i,minFilter:Hn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let j=g.state.transmissionRenderTarget[E.id],Q=E.viewport||S;j.setSize(Q.z,Q.w);let ge=v.getRenderTarget();v.setRenderTarget(j),v.getClearColor(O),H=v.getClearAlpha(),H<1&&v.setClearColor(16777215,.5),v.clear();let Se=v.toneMapping;v.toneMapping=yi;let Le=E.viewport;if(E.viewport!==void 0&&(E.viewport=void 0),g.setupLightsView(E),Y===!0&&xe.setGlobalState(v.clippingPlanes,E),An(b,M,E),ye.updateMultisampleRenderTarget(j),ye.updateRenderTargetMipmap(j),X.has("WEBGL_multisampled_render_to_texture")===!1){let Ge=!1;for(let ze=0,mt=_.length;ze<mt;ze++){let Ht=_[ze],on=Ht.object,ei=Ht.geometry,at=Ht.material,Ye=Ht.group;if(at.side===$n&&on.layers.test(E.layers)){let ro=at.side;at.side=nn,at.needsUpdate=!0,sr(on,M,E,ei,at,Ye),at.side=ro,at.needsUpdate=!0,Ge=!0}}Ge===!0&&(ye.updateMultisampleRenderTarget(j),ye.updateRenderTargetMipmap(j))}v.setRenderTarget(ge),v.setClearColor(O,H),Le!==void 0&&(E.viewport=Le),v.toneMapping=Se}function An(b,_,M){let E=_.isScene===!0?_.overrideMaterial:null;for(let I=0,j=b.length;I<j;I++){let Q=b[I],ge=Q.object,Se=Q.geometry,Le=E===null?Q.material:E,Ge=Q.group;ge.layers.test(M.layers)&&sr(ge,_,M,Se,Le,Ge)}}function sr(b,_,M,E,I,j){b.onBeforeRender(v,_,M,E,I,j),b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),I.onBeforeRender(v,_,M,E,b,j),I.transparent===!0&&I.side===$n&&I.forceSinglePass===!1?(I.side=nn,I.needsUpdate=!0,v.renderBufferDirect(M,_,E,I,b,j),I.side=xi,I.needsUpdate=!0,v.renderBufferDirect(M,_,E,I,b,j),I.side=$n):v.renderBufferDirect(M,_,E,I,b,j),b.onAfterRender(v,_,M,E,I,j)}function Fn(b,_,M){_.isScene!==!0&&(_=Pe);let E=ie.get(b),I=g.state.lights,j=g.state.shadowsArray,Q=I.state.version,ge=oe.getParameters(b,I.state,j,_,M),Se=oe.getProgramCacheKey(ge),Le=E.programs;E.environment=b.isMeshStandardMaterial?_.environment:null,E.fog=_.fog,E.envMap=(b.isMeshStandardMaterial?U:Te).get(b.envMap||E.environment),E.envMapRotation=E.environment!==null&&b.envMap===null?_.environmentRotation:b.envMapRotation,Le===void 0&&(b.addEventListener("dispose",we),Le=new Map,E.programs=Le);let Ge=Le.get(Se);if(Ge!==void 0){if(E.currentProgram===Ge&&E.lightsStateVersion===Q)return Zr(b,ge),Ge}else ge.uniforms=oe.getUniforms(b),b.onBuild(M,ge,v),b.onBeforeCompile(ge,v),Ge=oe.acquireProgram(ge,Se),Le.set(Se,Ge),E.uniforms=ge.uniforms;let ze=E.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(ze.clippingPlanes=xe.uniform),Zr(b,ge),E.needsLights=$(b),E.lightsStateVersion=Q,E.needsLights&&(ze.ambientLightColor.value=I.state.ambient,ze.lightProbe.value=I.state.probe,ze.directionalLights.value=I.state.directional,ze.directionalLightShadows.value=I.state.directionalShadow,ze.spotLights.value=I.state.spot,ze.spotLightShadows.value=I.state.spotShadow,ze.rectAreaLights.value=I.state.rectArea,ze.ltc_1.value=I.state.rectAreaLTC1,ze.ltc_2.value=I.state.rectAreaLTC2,ze.pointLights.value=I.state.point,ze.pointLightShadows.value=I.state.pointShadow,ze.hemisphereLights.value=I.state.hemi,ze.directionalShadowMap.value=I.state.directionalShadowMap,ze.directionalShadowMatrix.value=I.state.directionalShadowMatrix,ze.spotShadowMap.value=I.state.spotShadowMap,ze.spotLightMatrix.value=I.state.spotLightMatrix,ze.spotLightMap.value=I.state.spotLightMap,ze.pointShadowMap.value=I.state.pointShadowMap,ze.pointShadowMatrix.value=I.state.pointShadowMatrix),E.currentProgram=Ge,E.uniformsList=null,Ge}function or(b){if(b.uniformsList===null){let _=b.currentProgram.getUniforms();b.uniformsList=ks.seqWithValue(_.seq,b.uniforms)}return b.uniformsList}function Zr(b,_){let M=ie.get(b);M.outputColorSpace=_.outputColorSpace,M.batching=_.batching,M.instancing=_.instancing,M.instancingColor=_.instancingColor,M.instancingMorph=_.instancingMorph,M.skinning=_.skinning,M.morphTargets=_.morphTargets,M.morphNormals=_.morphNormals,M.morphColors=_.morphColors,M.morphTargetsCount=_.morphTargetsCount,M.numClippingPlanes=_.numClippingPlanes,M.numIntersection=_.numClipIntersection,M.vertexAlphas=_.vertexAlphas,M.vertexTangents=_.vertexTangents,M.toneMapping=_.toneMapping}function ar(b,_,M,E,I){_.isScene!==!0&&(_=Pe),ye.resetTextureUnits();let j=_.fog,Q=E.isMeshStandardMaterial?_.environment:null,ge=R===null?v.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Si,Se=(E.isMeshStandardMaterial?U:Te).get(E.envMap||Q),Le=E.vertexColors===!0&&!!M.attributes.color&&M.attributes.color.itemSize===4,Ge=!!M.attributes.tangent&&(!!E.normalMap||E.anisotropy>0),ze=!!M.morphAttributes.position,mt=!!M.morphAttributes.normal,Ht=!!M.morphAttributes.color,on=yi;E.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(on=v.toneMapping);let ei=M.morphAttributes.position||M.morphAttributes.normal||M.morphAttributes.color,at=ei!==void 0?ei.length:0,Ye=ie.get(E),ro=g.state.lights;if(Y===!0&&(me===!0||b!==A)){let vn=b===A&&E.id===F;xe.setState(E,b,vn)}let xt=!1;E.version===Ye.__version?(Ye.needsLights&&Ye.lightsStateVersion!==ro.state.version||Ye.outputColorSpace!==ge||I.isBatchedMesh&&Ye.batching===!1||!I.isBatchedMesh&&Ye.batching===!0||I.isInstancedMesh&&Ye.instancing===!1||!I.isInstancedMesh&&Ye.instancing===!0||I.isSkinnedMesh&&Ye.skinning===!1||!I.isSkinnedMesh&&Ye.skinning===!0||I.isInstancedMesh&&Ye.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&Ye.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&Ye.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&Ye.instancingMorph===!1&&I.morphTexture!==null||Ye.envMap!==Se||E.fog===!0&&Ye.fog!==j||Ye.numClippingPlanes!==void 0&&(Ye.numClippingPlanes!==xe.numPlanes||Ye.numIntersection!==xe.numIntersection)||Ye.vertexAlphas!==Le||Ye.vertexTangents!==Ge||Ye.morphTargets!==ze||Ye.morphNormals!==mt||Ye.morphColors!==Ht||Ye.toneMapping!==on||Ye.morphTargetsCount!==at)&&(xt=!0):(xt=!0,Ye.__version=E.version);let cr=Ye.currentProgram;xt===!0&&(cr=Fn(E,_,I));let Wp=!1,so=!1,Yu=!1,jt=cr.getUniforms(),Ii=Ye.uniforms;if(Z.useProgram(cr.program)&&(Wp=!0,so=!0,Yu=!0),E.id!==F&&(F=E.id,so=!0),Wp||A!==b){jt.setValue(z,"projectionMatrix",b.projectionMatrix),jt.setValue(z,"viewMatrix",b.matrixWorldInverse);let vn=jt.map.cameraPosition;vn!==void 0&&vn.setValue(z,ue.setFromMatrixPosition(b.matrixWorld)),de.logarithmicDepthBuffer&&jt.setValue(z,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(E.isMeshPhongMaterial||E.isMeshToonMaterial||E.isMeshLambertMaterial||E.isMeshBasicMaterial||E.isMeshStandardMaterial||E.isShaderMaterial)&&jt.setValue(z,"isOrthographic",b.isOrthographicCamera===!0),A!==b&&(A=b,so=!0,Yu=!0)}if(I.isSkinnedMesh){jt.setOptional(z,I,"bindMatrix"),jt.setOptional(z,I,"bindMatrixInverse");let vn=I.skeleton;vn&&(vn.boneTexture===null&&vn.computeBoneTexture(),jt.setValue(z,"boneTexture",vn.boneTexture,ye))}I.isBatchedMesh&&(jt.setOptional(z,I,"batchingTexture"),jt.setValue(z,"batchingTexture",I._matricesTexture,ye));let Zu=M.morphAttributes;if((Zu.position!==void 0||Zu.normal!==void 0||Zu.color!==void 0)&&Oe.update(I,M,cr),(so||Ye.receiveShadow!==I.receiveShadow)&&(Ye.receiveShadow=I.receiveShadow,jt.setValue(z,"receiveShadow",I.receiveShadow)),E.isMeshGouraudMaterial&&E.envMap!==null&&(Ii.envMap.value=Se,Ii.flipEnvMap.value=Se.isCubeTexture&&Se.isRenderTargetTexture===!1?-1:1),E.isMeshStandardMaterial&&E.envMap===null&&_.environment!==null&&(Ii.envMapIntensity.value=_.environmentIntensity),so&&(jt.setValue(z,"toneMappingExposure",v.toneMappingExposure),Ye.needsLights&&L(Ii,Yu),j&&E.fog===!0&&re.refreshFogUniforms(Ii,j),re.refreshMaterialUniforms(Ii,E,ae,J,g.state.transmissionRenderTarget[b.id]),ks.upload(z,or(Ye),Ii,ye)),E.isShaderMaterial&&E.uniformsNeedUpdate===!0&&(ks.upload(z,or(Ye),Ii,ye),E.uniformsNeedUpdate=!1),E.isSpriteMaterial&&jt.setValue(z,"center",I.center),jt.setValue(z,"modelViewMatrix",I.modelViewMatrix),jt.setValue(z,"normalMatrix",I.normalMatrix),jt.setValue(z,"modelMatrix",I.matrixWorld),E.isShaderMaterial||E.isRawShaderMaterial){let vn=E.uniformsGroups;for(let Ju=0,hx=vn.length;Ju<hx;Ju++){let Xp=vn[Ju];Qe.update(Xp,cr),Qe.bind(Xp,cr)}}return cr}function L(b,_){b.ambientLightColor.needsUpdate=_,b.lightProbe.needsUpdate=_,b.directionalLights.needsUpdate=_,b.directionalLightShadows.needsUpdate=_,b.pointLights.needsUpdate=_,b.pointLightShadows.needsUpdate=_,b.spotLights.needsUpdate=_,b.spotLightShadows.needsUpdate=_,b.rectAreaLights.needsUpdate=_,b.hemisphereLights.needsUpdate=_}function $(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(b,_,M){ie.get(b.texture).__webglTexture=_,ie.get(b.depthTexture).__webglTexture=M;let E=ie.get(b);E.__hasExternalTextures=!0,E.__autoAllocateDepthBuffer=M===void 0,E.__autoAllocateDepthBuffer||X.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),E.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(b,_){let M=ie.get(b);M.__webglFramebuffer=_,M.__useDefaultFramebuffer=_===void 0},this.setRenderTarget=function(b,_=0,M=0){R=b,N=_,C=M;let E=!0,I=null,j=!1,Q=!1;if(b){let Se=ie.get(b);Se.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(z.FRAMEBUFFER,null),E=!1):Se.__webglFramebuffer===void 0?ye.setupRenderTarget(b):Se.__hasExternalTextures&&ye.rebindTextures(b,ie.get(b.texture).__webglTexture,ie.get(b.depthTexture).__webglTexture);let Le=b.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(Q=!0);let Ge=ie.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Ge[_])?I=Ge[_][M]:I=Ge[_],j=!0):b.samples>0&&ye.useMultisampledRTT(b)===!1?I=ie.get(b).__webglMultisampledFramebuffer:Array.isArray(Ge)?I=Ge[M]:I=Ge,S.copy(b.viewport),P.copy(b.scissor),k=b.scissorTest}else S.copy(ce).multiplyScalar(ae).floor(),P.copy(Me).multiplyScalar(ae).floor(),k=fe;if(Z.bindFramebuffer(z.FRAMEBUFFER,I)&&E&&Z.drawBuffers(b,I),Z.viewport(S),Z.scissor(P),Z.setScissorTest(k),j){let Se=ie.get(b.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+_,Se.__webglTexture,M)}else if(Q){let Se=ie.get(b.texture),Le=_||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,Se.__webglTexture,M||0,Le)}F=-1},this.readRenderTargetPixels=function(b,_,M,E,I,j,Q){if(!(b&&b.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=ie.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Q!==void 0&&(ge=ge[Q]),ge){Z.bindFramebuffer(z.FRAMEBUFFER,ge);try{let Se=b.texture,Le=Se.format,Ge=Se.type;if(!de.textureFormatReadable(Le)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!de.textureTypeReadable(Ge)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_>=0&&_<=b.width-E&&M>=0&&M<=b.height-I&&z.readPixels(_,M,E,I,Ce.convert(Le),Ce.convert(Ge),j)}finally{let Se=R!==null?ie.get(R).__webglFramebuffer:null;Z.bindFramebuffer(z.FRAMEBUFFER,Se)}}},this.copyFramebufferToTexture=function(b,_,M=0){let E=Math.pow(2,-M),I=Math.floor(_.image.width*E),j=Math.floor(_.image.height*E);ye.setTexture2D(_,0),z.copyTexSubImage2D(z.TEXTURE_2D,M,0,0,b.x,b.y,I,j),Z.unbindTexture()},this.copyTextureToTexture=function(b,_,M,E=0){let I=_.image.width,j=_.image.height,Q=Ce.convert(M.format),ge=Ce.convert(M.type);ye.setTexture2D(M,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,M.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,M.unpackAlignment),_.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,E,b.x,b.y,I,j,Q,ge,_.image.data):_.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,E,b.x,b.y,_.mipmaps[0].width,_.mipmaps[0].height,Q,_.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,E,b.x,b.y,Q,ge,_.image),E===0&&M.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(b,_,M,E,I=0){let j=b.max.x-b.min.x,Q=b.max.y-b.min.y,ge=b.max.z-b.min.z,Se=Ce.convert(E.format),Le=Ce.convert(E.type),Ge;if(E.isData3DTexture)ye.setTexture3D(E,0),Ge=z.TEXTURE_3D;else if(E.isDataArrayTexture||E.isCompressedArrayTexture)ye.setTexture2DArray(E,0),Ge=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,E.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,E.unpackAlignment);let ze=z.getParameter(z.UNPACK_ROW_LENGTH),mt=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Ht=z.getParameter(z.UNPACK_SKIP_PIXELS),on=z.getParameter(z.UNPACK_SKIP_ROWS),ei=z.getParameter(z.UNPACK_SKIP_IMAGES),at=M.isCompressedTexture?M.mipmaps[I]:M.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,at.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,at.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,b.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,b.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,b.min.z),M.isDataTexture||M.isData3DTexture?z.texSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,Le,at.data):E.isCompressedArrayTexture?z.compressedTexSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,at.data):z.texSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,Le,at),z.pixelStorei(z.UNPACK_ROW_LENGTH,ze),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,mt),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Ht),z.pixelStorei(z.UNPACK_SKIP_ROWS,on),z.pixelStorei(z.UNPACK_SKIP_IMAGES,ei),I===0&&E.generateMipmaps&&z.generateMipmap(Ge),Z.unbindTexture()},this.initTexture=function(b){b.isCubeTexture?ye.setTextureCube(b,0):b.isData3DTexture?ye.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?ye.setTexture2DArray(b,0):ye.setTexture2D(b,0),Z.unbindTexture()},this.resetState=function(){N=0,C=0,R=null,Z.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return jn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===ku?"display-p3":"srgb",t.unpackColorSpace=dt.workingColorSpace===Fa?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},Rl=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ie(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Pl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ie(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Ll=class extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fn,this.environmentIntensity=1,this.environmentRotation=new fn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Xs=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ra,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=dn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return dv("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Qt=new D,kr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Je(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new ot(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},pa=class extends Ft{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Lo=new D,Is=new D,Cs=new D,Rs=new se,Do=new se,wv=new Ve,Wc=new D,Oo=new D,Xc=new D,hy=new se,ah=new se,fy=new se,Dl=class extends ct{constructor(e=new pa){if(super(),this.isSprite=!0,this.type="Sprite",Ts===void 0){Ts=new et;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Xs(t,5);Ts.setIndex([0,1,2,0,2,3]),Ts.setAttribute("position",new kr(i,3,0,!1)),Ts.setAttribute("uv",new kr(i,2,3,!1))}this.geometry=Ts,this.material=e,this.center=new se(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Is.setFromMatrixScale(this.matrixWorld),wv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Cs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Is.multiplyScalar(-Cs.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;qc(Wc.set(-.5,-.5,0),Cs,o,Is,r,s),qc(Oo.set(.5,-.5,0),Cs,o,Is,r,s),qc(Xc.set(.5,.5,0),Cs,o,Is,r,s),hy.set(0,0),ah.set(1,0),fy.set(1,1);let a=e.ray.intersectTriangle(Wc,Oo,Xc,!1,Lo);if(a===null&&(qc(Oo.set(-.5,.5,0),Cs,o,Is,r,s),ah.set(0,1),a=e.ray.intersectTriangle(Wc,Xc,Oo,!1,Lo),a===null))return;let c=e.ray.origin.distanceTo(Lo);c<e.near||c>e.far||t.push({distance:c,point:Lo.clone(),uv:pi.getInterpolation(Lo,Wc,Oo,Xc,hy,ah,fy,new se),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Yc=new D,py=new D,Ol=class extends ct{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Yc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Yc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Yc.setFromMatrixPosition(e.matrixWorld),py.setFromMatrixPosition(this.matrixWorld);let i=Yc.distanceTo(py)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},my=new D,gy=new ht,yy=new ht,bI=new D,vy=new Ve,Zc=new D,ch=new Nt,xy=new Ve,lh=new Xi,Ul=class extends St{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Eh,this.bindMatrix=new Ve,this.bindMatrixInverse=new Ve,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Zc),this.boundingBox.expandByPoint(Zc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Nt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Zc),this.boundingSphere.expandByPoint(Zc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(r),e.ray.intersectsSphere(ch)!==!1&&(xy.copy(r).invert(),lh.copy(e.ray).applyMatrix4(xy),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ht,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Eh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===z0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;gy.fromBufferAttribute(r.attributes.skinIndex,e),yy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=yy.getComponent(s);if(o!==0){let a=gy.getComponent(s);vy.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(bI.copy(my).applyMatrix4(vy),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},ma=class extends ct{constructor(){super(),this.isBone=!0,this.type="Bone"}},Gn=class extends Ct{constructor(e=null,t=1,i=1,r,s,o,a,c,l=Ut,u=Ut,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},by=new Ve,_I=new Ve,Nl=class n{constructor(e=[],t=[]){this.uuid=dn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ve)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Ve;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:_I;by.multiplyMatrices(a,t[s]),by.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Gn(t,e,e,un,Sn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new ma),this.bones.push(o),this.boneInverses.push(new Ve().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},qi=class extends ot{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ps=new Ve,_y=new Ve,Jc=[],wy=new Bt,wI=new Ve,Uo=new St,No=new Nt,Fl=class extends St{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qi(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,wI)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ps),wy.copy(e.boundingBox).applyMatrix4(Ps),this.boundingBox.union(wy)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Nt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ps),No.copy(e.boundingSphere).applyMatrix4(Ps),this.boundingSphere.union(No)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Uo.geometry=this.geometry,Uo.material=this.material,Uo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),No.copy(this.boundingSphere),No.applyMatrix4(i),e.ray.intersectsSphere(No)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ps),_y.multiplyMatrices(i,Ps),Uo.matrixWorld=_y,Uo.raycast(e,Jc);for(let o=0,a=Jc.length;o<a;o++){let c=Jc[o];c.instanceId=s,c.object=this,t.push(c)}Jc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qi(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Gn(new Float32Array(r*this.count),r,this.count,Sp,Sn));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<i.length;l++)o+=i[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(i,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};vf=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Ls="batchId",$i=new Ve,My=new Ve,EI=new Ve,Sy=new Ve,uh=new Fr,Kc=new Bt,xr=new Nt,Fo=new D,dh=new vf,Yt=new St,Qc=[];kl=class extends St{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new et,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Gn(t,e,e,un,Sn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:d}=c,h=new l.constructor(i*u),f=new ot(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new ot(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Ls,new ot(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ls))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ls}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Ls)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingBoxAt(r,Kc).applyMatrix4($i),t.union(Kc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nt);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingSphereAt(r,xr).applyMatrix4($i),t.union(xr))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,EI.toArray(p,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Bt,sphereInitialized:!1,sphere:new Nt});let g=this.geometry.getAttribute(Ls);for(let m=0;m<r.vertexCount;m++)g.setX(r.vertexStart+m,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let f in i.attributes){if(f===Ls)continue;let p=t.getAttribute(f),y=i.getAttribute(f);AI(p,y,c);let g=p.itemSize;for(let m=p.count,x=l;m<x;m++){let v=c+m;for(let w=0;w<g;w++)y.setComponent(v,w,0)}y.needsUpdate=!0,y.addUpdateRange(c*g,l*g)}if(r){let f=a.indexStart;for(let p=0;p<o.count;p++)s.setX(f+p,c+o.getX(p));for(let p=o.count,y=a.indexCount;p<y;p++)s.setX(f+p,c);s.needsUpdate=!0,s.addUpdateRange(f,a.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,d=l.start+l.count;u<d;u++){let h=u;a&&(h=a.getX(h)),s.expandByPoint(Fo.fromBufferAttribute(c,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Kc),Kc.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let d=l.start,h=l.start+l.count;d<h;d++){let f=d;a&&(f=a.getX(f)),Fo.fromBufferAttribute(c,f),u=Math.max(u,s.center.distanceToSquared(Fo))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;Yt.material=this.material,Yt.geometry.index=c.index,Yt.geometry.attributes=c.attributes,Yt.geometry.boundingBox===null&&(Yt.geometry.boundingBox=new Bt),Yt.geometry.boundingSphere===null&&(Yt.geometry.boundingSphere=new Nt);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];Yt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,Yt.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Yt.geometry.boundingBox),this.getBoundingSphereAt(l,Yt.geometry.boundingSphere),Yt.raycast(e,Qc);for(let d=0,h=Qc.length;d<h;d++){let f=Qc[d];f.object=this,f.batchId=l,t.push(f)}Qc.length=0}Yt.material=null,Yt.geometry.index=null,Yt.geometry.attributes={},Yt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._active,l=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(Sy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),uh.setFromProjectionMatrix(Sy,e.coordinateSystem));let p=0;if(this.sortObjects){My.copy(this.matrixWorld).invert(),Fo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(My);for(let m=0,x=l.length;m<x;m++)if(l[m]&&c[m]){this.getMatrixAt(m,$i),this.getBoundingSphereAt(m,xr).applyMatrix4($i);let v=!1;if(f&&(v=!uh.intersectsSphere(xr)),!v){let w=Fo.distanceTo(xr.center);dh.push(h[m],w)}}let y=dh.list,g=this.customSort;g===null?y.sort(s.transparent?SI:MI):g.call(this,y,i);for(let m=0,x=y.length;m<x;m++){let v=y[m];u[p]=v.start*a,d[p]=v.count,p++}dh.reset()}else for(let y=0,g=l.length;y<g;y++)if(l[y]&&c[y]){let m=!1;if(f&&(this.getMatrixAt(y,$i),this.getBoundingSphereAt(y,xr).applyMatrix4($i),m=!uh.intersectsSphere(xr)),!m){let x=h[y];u[p]=x.start*a,d[p]=x.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},zt=class extends Ft{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Bl=new D,zl=new D,Ey=new Ve,ko=new Xi,el=new Nt,hh=new D,Ay=new D,qn=class extends ct{constructor(e=new et,t=new zt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Bl.fromBufferAttribute(t,r-1),zl.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Bl.distanceTo(zl);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),el.copy(i.boundingSphere),el.applyMatrix4(r),el.radius+=s,e.ray.intersectsSphere(el)===!1)return;Ey.copy(r).invert(),ko.copy(e.ray).applyMatrix4(Ey);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=u.getX(y),x=u.getX(y+1),v=tl(this,e,ko,c,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=tl(this,e,ko,c,y,g);m&&t.push(m)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=tl(this,e,ko,c,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=tl(this,e,ko,c,p-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};Ty=new D,Iy=new D,En=class extends qn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Ty.fromBufferAttribute(t,r),Iy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ty.distanceTo(Iy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Vl=class extends qn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ga=class extends Ft{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Cy=new Ve,xf=new Xi,nl=new Nt,il=new D,$l=class extends ct{constructor(e=new et,t=new ga){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),nl.copy(i.boundingSphere),nl.applyMatrix4(r),nl.radius+=s,e.ray.intersectsSphere(nl)===!1)return;Cy.copy(r).invert(),xf.copy(e.ray).applyMatrix4(Cy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,d=i.attributes.position;if(l!==null){let h=Math.max(0,o.start),f=Math.min(l.count,o.start+o.count);for(let p=h,y=f;p<y;p++){let g=l.getX(p);il.fromBufferAttribute(d,g),Ry(il,g,c,r,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let p=h,y=f;p<y;p++)il.fromBufferAttribute(d,p),Ry(il,p,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};bf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:It,this.magFilter=s!==void 0?s:It,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_f=class extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ut,this.minFilter=Ut,this.generateMipmaps=!1,this.needsUpdate=!0}},qs=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},wf=class extends qs{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Mn}},Mf=class extends qs{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,bi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Sf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},mn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(o-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new se:new D);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new D,r=[],s=[],o=[],a=new D,c=new Ve;for(let f=0;f<=e;f++){let p=f/e;r[f]=this.getTangentAt(p,new D)}s[0]=new D,o[0]=new D;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),h<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Mt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(Mt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ys=class extends mn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new se){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=c-this.aX,f=l-this.aY;c=h*u-f*d+this.aX,l=h*d+f*u+this.aY}return i.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Hl=class extends Ys{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};rl=new D,fh=new Lp,ph=new Lp,mh=new Lp,jl=class extends mn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new D){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(rl.subVectors(r[0],r[1]).add(r[0]),l=rl);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(rl.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=rl),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),p<1e-4&&(p=y),g<1e-4&&(g=y),fh.initNonuniformCatmullRom(l.x,d.x,h.x,u.x,p,y,g),ph.initNonuniformCatmullRom(l.y,d.y,h.y,u.y,p,y,g),mh.initNonuniformCatmullRom(l.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(fh.initCatmullRom(l.x,d.x,h.x,u.x,this.tension),ph.initCatmullRom(l.y,d.y,h.y,u.y,this.tension),mh.initCatmullRom(l.z,d.z,h.z,u.z,this.tension));return i.set(fh.calc(c),ph.calc(c),mh.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new D().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ya=class extends mn{constructor(e=new se,t=new se,i=new se,r=new se){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Wo(e,r.x,s.x,o.x,a.x),Wo(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Gl=class extends mn{constructor(e=new D,t=new D,i=new D,r=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new D){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Wo(e,r.x,s.x,o.x,a.x),Wo(e,r.y,s.y,o.y,a.y),Wo(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},va=class extends mn{constructor(e=new se,t=new se){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new se){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new se){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Wl=class extends mn{constructor(e=new D,t=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new D){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new D){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},xa=class extends mn{constructor(e=new se,t=new se,i=new se){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ba=class extends mn{constructor(e=new D,t=new D,i=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new D){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y),Go(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},_a=class extends mn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new se){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(Py(a,c.x,l.x,u.x,d.x),Py(a,c.y,l.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new se().fromArray(r))}return this}},Xl=Object.freeze({__proto__:null,ArcCurve:Hl,CatmullRomCurve3:jl,CubicBezierCurve:ya,CubicBezierCurve3:Gl,EllipseCurve:Ys,LineCurve:va,LineCurve3:Wl,QuadraticBezierCurve:xa,QuadraticBezierCurve3:ba,SplineCurve:_a}),ql=class extends mn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Xl[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Xl[r.type]().fromJSON(r))}return this}},Br=class extends ql{constructor(e){super(),this.type="Path",this.currentPoint=new se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new va(this.currentPoint.clone(),new se(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new xa(this.currentPoint.clone(),new se(e,t),new se(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new ya(this.currentPoint.clone(),new se(e,t),new se(i,r),new se(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new _a(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new Ys(e,t,i,r,s,o,a,c);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},wa=class n extends et{constructor(e=[new se(0,-.5),new se(.5,0),new se(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Mt(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,d=new D,h=new se,f=new D,p=new D,y=new D,g=0,m=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,y.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),c.push(f.x,f.y,f.z),y.copy(p)}for(let x=0;x<=t;x++){let v=i+x*u*r,w=Math.sin(v),N=Math.cos(v);for(let C=0;C<=e.length-1;C++){d.x=e[C].x*w,d.y=e[C].y,d.z=e[C].x*N,o.push(d.x,d.y,d.z),h.x=x/t,h.y=C/(e.length-1),a.push(h.x,h.y);let R=c[3*C+0]*w,F=c[3*C+1],A=c[3*C+0]*N;l.push(R,F,A)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){let w=v+x*e.length,N=w,C=w+e.length,R=w+e.length+1,F=w+1;s.push(N,C,F),s.push(R,F,C)}this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("uv",new De(a,2)),this.setAttribute("normal",new De(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Yl=class n extends wa{constructor(e=1,t=1,i=4,r=8){let s=new Br;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},Zl=class n extends et{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new D,u=new se;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;l.x=e*Math.cos(f),l.y=e*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,c.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(a,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Zs=class n extends et{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],p=0,y=[],g=i/2,m=0;x(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function x(){let w=new D,N=new D,C=0,R=(t-e)/i;for(let F=0;F<=s;F++){let A=[],S=F/s,P=S*(t-e)+e;for(let k=0;k<=r;k++){let O=k/r,H=O*c+a,W=Math.sin(H),J=Math.cos(H);N.x=P*W,N.y=-S*i+g,N.z=P*J,d.push(N.x,N.y,N.z),w.set(W,R,J).normalize(),h.push(w.x,w.y,w.z),f.push(O,1-S),A.push(p++)}y.push(A)}for(let F=0;F<r;F++)for(let A=0;A<s;A++){let S=y[A][F],P=y[A+1][F],k=y[A+1][F+1],O=y[A][F+1];u.push(S,P,O),u.push(P,k,O),C+=6}l.addGroup(m,C,0),m+=C}function v(w){let N=p,C=new se,R=new D,F=0,A=w===!0?e:t,S=w===!0?1:-1;for(let k=1;k<=r;k++)d.push(0,g*S,0),h.push(0,S,0),f.push(.5,.5),p++;let P=p;for(let k=0;k<=r;k++){let H=k/r*c+a,W=Math.cos(H),J=Math.sin(H);R.x=A*J,R.y=g*S,R.z=A*W,d.push(R.x,R.y,R.z),h.push(0,S,0),C.x=W*.5+.5,C.y=J*.5*S+.5,f.push(C.x,C.y),p++}for(let k=0;k<r;k++){let O=N+k,H=P+k;w===!0?u.push(H,H+1,O):u.push(H+1,H,O),F+=3}l.addGroup(m,F,w===!0?1:2),m+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Jl=class n extends Zs{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Yi=class n extends et{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new D,w=new D,N=new D;for(let C=0;C<t.length;C+=3)f(t[C+0],v),f(t[C+1],w),f(t[C+2],N),c(v,w,N,x)}function c(x,v,w,N){let C=N+1,R=[];for(let F=0;F<=C;F++){R[F]=[];let A=x.clone().lerp(w,F/C),S=v.clone().lerp(w,F/C),P=C-F;for(let k=0;k<=P;k++)k===0&&F===C?R[F][k]=A:R[F][k]=A.clone().lerp(S,k/P)}for(let F=0;F<C;F++)for(let A=0;A<2*(C-F)-1;A++){let S=Math.floor(A/2);A%2===0?(h(R[F][S+1]),h(R[F+1][S]),h(R[F][S])):(h(R[F][S+1]),h(R[F+1][S+1]),h(R[F+1][S]))}}function l(x){let v=new D;for(let w=0;w<s.length;w+=3)v.x=s[w+0],v.y=s[w+1],v.z=s[w+2],v.normalize().multiplyScalar(x),s[w+0]=v.x,s[w+1]=v.y,s[w+2]=v.z}function u(){let x=new D;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let w=g(x)/2/Math.PI+.5,N=m(x)/Math.PI+.5;o.push(w,1-N)}p(),d()}function d(){for(let x=0;x<o.length;x+=6){let v=o[x+0],w=o[x+2],N=o[x+4],C=Math.max(v,w,N),R=Math.min(v,w,N);C>.9&&R<.1&&(v<.2&&(o[x+0]+=1),w<.2&&(o[x+2]+=1),N<.2&&(o[x+4]+=1))}}function h(x){s.push(x.x,x.y,x.z)}function f(x,v){let w=x*3;v.x=e[w+0],v.y=e[w+1],v.z=e[w+2]}function p(){let x=new D,v=new D,w=new D,N=new D,C=new se,R=new se,F=new se;for(let A=0,S=0;A<s.length;A+=9,S+=6){x.set(s[A+0],s[A+1],s[A+2]),v.set(s[A+3],s[A+4],s[A+5]),w.set(s[A+6],s[A+7],s[A+8]),C.set(o[S+0],o[S+1]),R.set(o[S+2],o[S+3]),F.set(o[S+4],o[S+5]),N.copy(x).add(v).add(w).divideScalar(3);let P=g(N);y(C,S+0,x,P),y(R,S+2,v,P),y(F,S+4,w,P)}}function y(x,v,w,N){N<0&&x.x===1&&(o[v]=x.x-1),w.x===0&&w.z===0&&(o[v]=N/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function m(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},Kl=class n extends Yi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},sl=new D,ol=new D,gh=new D,al=new pi,Ql=class extends et{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Dr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let p=0;p<c;p+=3){o?(l[0]=o.getX(p),l[1]=o.getX(p+1),l[2]=o.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);let{a:y,b:g,c:m}=al;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),m.fromBufferAttribute(a,l[2]),al.getNormal(gh),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let x=0;x<3;x++){let v=(x+1)%3,w=d[x],N=d[v],C=al[u[x]],R=al[u[v]],F=`${w}_${N}`,A=`${N}_${w}`;A in h&&h[A]?(gh.dot(h[A].normal)<=s&&(f.push(C.x,C.y,C.z),f.push(R.x,R.y,R.z)),h[A]=null):F in h||(h[F]={index0:l[x],index1:l[v],normal:gh.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];sl.fromBufferAttribute(a,y),ol.fromBufferAttribute(a,g),f.push(sl.x,sl.y,sl.z),f.push(ol.x,ol.y,ol.z)}this.setAttribute("position",new De(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},vi=class extends Br{constructor(e){super(e),this.uuid=dn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Br().fromJSON(r))}return this}},OI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=Mv(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,d,h,f;if(i&&(s=BI(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let p=t;p<r;p+=t)d=n[p],h=n[p+1],d<a&&(a=d),h<c&&(c=h),d>l&&(l=d),h>u&&(u=h);f=Math.max(l-a,u-c),f=f!==0?32767/f:0}return Ma(s,o,t,a,c,f,0),o}};Wn=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Dy(e),Oy(i,e);let o=e.length;t.forEach(Dy);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,Oy(i,t[c]);let a=OI.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};eu=class n extends et{constructor(e=new vi([new se(.5,.5),new se(-.5,.5),new se(-.5,-.5),new se(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:JI,v,w=!1,N,C,R,F;m&&(v=m.getSpacedPoints(u),w=!0,h=!1,N=m.computeFrenetFrames(u,!1),C=new D,R=new D,F=new D),h||(g=0,f=0,p=0,y=0);let A=a.extractPoints(l),S=A.shape,P=A.holes;if(!Wn.isClockWise(S)){S=S.reverse();for(let X=0,de=P.length;X<de;X++){let Z=P[X];Wn.isClockWise(Z)&&(P[X]=Z.reverse())}}let O=Wn.triangulateShape(S,P),H=S;for(let X=0,de=P.length;X<de;X++){let Z=P[X];S=S.concat(Z)}function W(X,de,Z){return de||console.error("THREE.ExtrudeGeometry: vec does not exist"),X.clone().addScaledVector(de,Z)}let J=S.length,ae=O.length;function B(X,de,Z){let he,ie,ye,Te=X.x-de.x,U=X.y-de.y,T=Z.x-X.x,G=Z.y-X.y,ee=Te*Te+U*U,oe=Te*G-U*T;if(Math.abs(oe)>Number.EPSILON){let re=Math.sqrt(ee),Ue=Math.sqrt(T*T+G*G),ve=de.x-U/re,xe=de.y+Te/re,He=Z.x-G/Ue,pe=Z.y+T/Ue,Oe=((He-ve)*G-(pe-xe)*T)/(Te*G-U*T);he=ve+Te*Oe-X.x,ie=xe+U*Oe-X.y;let qe=he*he+ie*ie;if(qe<=2)return new se(he,ie);ye=Math.sqrt(qe/2)}else{let re=!1;Te>Number.EPSILON?T>Number.EPSILON&&(re=!0):Te<-Number.EPSILON?T<-Number.EPSILON&&(re=!0):Math.sign(U)===Math.sign(G)&&(re=!0),re?(he=-U,ie=Te,ye=Math.sqrt(ee)):(he=Te,ie=U,ye=Math.sqrt(ee/2))}return new se(he/ye,ie/ye)}let ne=[];for(let X=0,de=H.length,Z=de-1,he=X+1;X<de;X++,Z++,he++)Z===de&&(Z=0),he===de&&(he=0),ne[X]=B(H[X],H[Z],H[he]);let ce=[],Me,fe=ne.concat();for(let X=0,de=P.length;X<de;X++){let Z=P[X];Me=[];for(let he=0,ie=Z.length,ye=ie-1,Te=he+1;he<ie;he++,ye++,Te++)ye===ie&&(ye=0),Te===ie&&(Te=0),Me[he]=B(Z[he],Z[ye],Z[Te]);ce.push(Me),fe=fe.concat(Me)}for(let X=0;X<g;X++){let de=X/g,Z=f*Math.cos(de*Math.PI/2),he=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ye=H.length;ie<ye;ie++){let Te=W(H[ie],ne[ie],he);ue(Te.x,Te.y,-Z)}for(let ie=0,ye=P.length;ie<ye;ie++){let Te=P[ie];Me=ce[ie];for(let U=0,T=Te.length;U<T;U++){let G=W(Te[U],Me[U],he);ue(G.x,G.y,-Z)}}}let $e=p+y;for(let X=0;X<J;X++){let de=h?W(S[X],fe[X],$e):S[X];w?(R.copy(N.normals[0]).multiplyScalar(de.x),C.copy(N.binormals[0]).multiplyScalar(de.y),F.copy(v[0]).add(R).add(C),ue(F.x,F.y,F.z)):ue(de.x,de.y,0)}for(let X=1;X<=u;X++)for(let de=0;de<J;de++){let Z=h?W(S[de],fe[de],$e):S[de];w?(R.copy(N.normals[X]).multiplyScalar(Z.x),C.copy(N.binormals[X]).multiplyScalar(Z.y),F.copy(v[X]).add(R).add(C),ue(F.x,F.y,F.z)):ue(Z.x,Z.y,d/u*X)}for(let X=g-1;X>=0;X--){let de=X/g,Z=f*Math.cos(de*Math.PI/2),he=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ye=H.length;ie<ye;ie++){let Te=W(H[ie],ne[ie],he);ue(Te.x,Te.y,d+Z)}for(let ie=0,ye=P.length;ie<ye;ie++){let Te=P[ie];Me=ce[ie];for(let U=0,T=Te.length;U<T;U++){let G=W(Te[U],Me[U],he);w?ue(G.x,G.y+v[u-1].y,v[u-1].x+Z):ue(G.x,G.y,d+Z)}}}Y(),me();function Y(){let X=r.length/3;if(h){let de=0,Z=J*de;for(let he=0;he<ae;he++){let ie=O[he];Pe(ie[2]+Z,ie[1]+Z,ie[0]+Z)}de=u+g*2,Z=J*de;for(let he=0;he<ae;he++){let ie=O[he];Pe(ie[0]+Z,ie[1]+Z,ie[2]+Z)}}else{for(let de=0;de<ae;de++){let Z=O[de];Pe(Z[2],Z[1],Z[0])}for(let de=0;de<ae;de++){let Z=O[de];Pe(Z[0]+J*u,Z[1]+J*u,Z[2]+J*u)}}i.addGroup(X,r.length/3-X,0)}function me(){let X=r.length/3,de=0;te(H,de),de+=H.length;for(let Z=0,he=P.length;Z<he;Z++){let ie=P[Z];te(ie,de),de+=ie.length}i.addGroup(X,r.length/3-X,1)}function te(X,de){let Z=X.length;for(;--Z>=0;){let he=Z,ie=Z-1;ie<0&&(ie=X.length-1);for(let ye=0,Te=u+g*2;ye<Te;ye++){let U=J*ye,T=J*(ye+1),G=de+he+U,ee=de+ie+U,oe=de+ie+T,re=de+he+T;_e(G,ee,oe,re)}}}function ue(X,de,Z){c.push(X),c.push(de),c.push(Z)}function Pe(X,de,Z){z(X),z(de),z(Z);let he=r.length/3,ie=x.generateTopUV(i,r,he-3,he-2,he-1);Be(ie[0]),Be(ie[1]),Be(ie[2])}function _e(X,de,Z,he){z(X),z(de),z(he),z(de),z(Z),z(he);let ie=r.length/3,ye=x.generateSideWallUV(i,r,ie-6,ie-3,ie-2,ie-1);Be(ye[0]),Be(ye[1]),Be(ye[3]),Be(ye[1]),Be(ye[2]),Be(ye[3])}function z(X){r.push(c[X*3+0]),r.push(c[X*3+1]),r.push(c[X*3+2])}function Be(X){s.push(X.x),s.push(X.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return KI(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Xl[r.type]().fromJSON(r)),new n(i,e.options)}},JI={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new se(s,o),new se(a,c),new se(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],p=e[r*3+2],y=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new se(o,1-c),new se(l,1-d),new se(h,1-p),new se(y,1-m)]:[new se(a,1-c),new se(u,1-d),new se(f,1-p),new se(g,1-m)]}};tu=class n extends Yi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Aa=class n extends Yi{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},nu=class n extends et{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],d=e,h=(t-e)/r,f=new D,p=new se;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let m=s+g/i*o;f.x=d*Math.cos(m),f.y=d*Math.sin(m),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,u.push(p.x,p.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let m=0;m<i;m++){let x=m+g,v=x,w=x+i+1,N=x+i+2,C=x+1;a.push(v,w,C),a.push(w,N,C)}}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},iu=class n extends et{constructor(e=new vi([new se(0,.5),new se(-.5,-.5),new se(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(o,2));function l(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,p=h.holes;Wn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Wn.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Wn.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){let x=p[g];f=f.concat(x)}for(let g=0,m=f.length;g<m;g++){let x=f[g];r.push(x.x,x.y,0),s.push(0,0,1),o.push(x.x,x.y)}for(let g=0,m=y.length;g<m;g++){let x=y[g],v=x[0]+d,w=x[1]+d,N=x[2]+d;i.push(v,w,N),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return QI(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Ta=class n extends et{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],d=new D,h=new D,f=[],p=[],y=[],g=[];for(let m=0;m<=i;m++){let x=[],v=m/i,w=0;m===0&&o===0?w=.5/t:m===i&&c===Math.PI&&(w=-.5/t);for(let N=0;N<=t;N++){let C=N/t;d.x=-e*Math.cos(r+C*s)*Math.sin(o+v*a),d.y=e*Math.cos(o+v*a),d.z=e*Math.sin(r+C*s)*Math.sin(o+v*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(C+w,1-v),x.push(l++)}u.push(x)}for(let m=0;m<i;m++)for(let x=0;x<t;x++){let v=u[m][x+1],w=u[m][x],N=u[m+1][x],C=u[m+1][x+1];(m!==0||o>0)&&f.push(v,w,C),(m!==i-1||c<Math.PI)&&f.push(w,N,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},ru=class n extends Yi{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},su=class n extends et{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new D,d=new D,h=new D;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),c.push(h.x,h.y,h.z),l.push(p/r),l.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,g=(r+1)*(f-1)+p-1,m=(r+1)*(f-1)+p,x=(r+1)*f+p;o.push(y,g,x),o.push(g,m,x)}this.setIndex(o),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},ou=class n extends et{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],d=new D,h=new D,f=new D,p=new D,y=new D,g=new D,m=new D;for(let v=0;v<=i;++v){let w=v/i*s*Math.PI*2;x(w,s,o,e,f),x(w+.01,s,o,e,p),g.subVectors(p,f),m.addVectors(p,f),y.crossVectors(g,m),m.crossVectors(y,g),y.normalize(),m.normalize();for(let N=0;N<=r;++N){let C=N/r*Math.PI*2,R=-t*Math.cos(C),F=t*Math.sin(C);d.x=f.x+(R*m.x+F*y.x),d.y=f.y+(R*m.y+F*y.y),d.z=f.z+(R*m.z+F*y.z),c.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),l.push(h.x,h.y,h.z),u.push(v/i),u.push(N/r)}}for(let v=1;v<=i;v++)for(let w=1;w<=r;w++){let N=(r+1)*(v-1)+(w-1),C=(r+1)*v+(w-1),R=(r+1)*v+w,F=(r+1)*(v-1)+w;a.push(N,C,F),a.push(C,R,F)}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2));function x(v,w,N,C,R){let F=Math.cos(v),A=Math.sin(v),S=N/w*v,P=Math.cos(S);R.x=C*(2+P)*.5*F,R.y=C*(2+P)*A*.5,R.z=C*Math.sin(S)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},au=class n extends et{constructor(e=new ba(new D(-1,-1,0),new D(-1,1,0),new D(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new D,c=new D,l=new se,u=new D,d=[],h=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function y(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),x(),m()}function g(v){u=e.getPointAt(v/t,u);let w=o.normals[v],N=o.binormals[v];for(let C=0;C<=r;C++){let R=C/r*Math.PI*2,F=Math.sin(R),A=-Math.cos(R);c.x=A*w.x+F*N.x,c.y=A*w.y+F*N.y,c.z=A*w.z+F*N.z,c.normalize(),h.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,d.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=t;v++)for(let w=1;w<=r;w++){let N=(r+1)*(v-1)+(w-1),C=(r+1)*v+(w-1),R=(r+1)*v+w,F=(r+1)*(v-1)+w;p.push(N,C,F),p.push(C,R,F)}}function x(){for(let v=0;v<=t;v++)for(let w=0;w<=r;w++)l.x=v/t,l.y=w/r,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Xl[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},cu=class extends et{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new D,s=new D;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let d=c[l],h=d.start,f=d.count;for(let p=h,y=h+f;p<y;p+=3)for(let g=0;g<3;g++){let m=a.getX(p+g),x=a.getX(p+(g+1)%3);r.fromBufferAttribute(o,m),s.fromBufferAttribute(o,x),Uy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,d=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),Uy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};Ny=Object.freeze({__proto__:null,BoxGeometry:Ur,CapsuleGeometry:Yl,CircleGeometry:Zl,ConeGeometry:Jl,CylinderGeometry:Zs,DodecahedronGeometry:Kl,EdgesGeometry:Ql,ExtrudeGeometry:eu,IcosahedronGeometry:tu,LatheGeometry:wa,OctahedronGeometry:Aa,PlaneGeometry:Gs,PolyhedronGeometry:Yi,RingGeometry:nu,ShapeGeometry:iu,SphereGeometry:Ta,TetrahedronGeometry:ru,TorusGeometry:su,TorusKnotGeometry:ou,TubeGeometry:au,WireframeGeometry:cu}),lu=class extends Ft{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ie(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},uu=class extends pn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ia=class extends Ft{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},du=class extends Ia{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new se(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Mt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},hu=class extends Ft{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ie(16777215),this.specular=new Ie(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},fu=class extends Ft{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ie(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},pu=class extends Ft{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},mu=class extends Ft{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},gu=class extends Ft{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ie(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},yu=class extends zt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};n2={convertArray:Rr,isTypedArray:Av,getKeyframeOrder:Tv,sortedArray:Tf,flattenJSON:Dp,subclip:e2,makeClipAdditive:t2},Vr=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},vu=class extends Vr{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ir,endingEnd:Ir}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Cr:s=e,a=2*t-i;break;case ea:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Cr:o=e,c=2*i-t;break;case ea:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(i-t)/(r-t),y=p*p,g=y*p,m=-h*g+2*h*y-h*p,x=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*p+1,v=(-1-f)*g+(1.5+f)*y+.5*p,w=f*g-f*y;for(let N=0;N!==a;++N)s[N]=m*o[u+N]+x*o[l+N]+v*o[c+N]+w*o[d+N];return s}},Ca=class extends Vr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[l+h]*d+o[c+h]*u;return s}},xu=class extends Vr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},gn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Rr(t,this.TimeBufferType),this.values=Rr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Rr(e.times,Array),values:Rr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new xu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ca(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ko:t=this.InterpolantFactoryMethodDiscrete;break;case Qo:t=this.InterpolantFactoryMethodLinear;break;case wl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ko;case this.InterpolantFactoryMethodLinear:return Qo;case this.InterpolantFactoryMethodSmooth:return wl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Av(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===wl,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let d=a*i,h=d-i,f=d+i;for(let p=0;p!==i;++p){let y=t[d+p];if(y!==t[h+p]||y!==t[f+p]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let d=a*i,h=o*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};gn.prototype.TimeBufferType=Float32Array;gn.prototype.ValueBufferType=Float32Array;gn.prototype.DefaultInterpolation=Qo;wi=class extends gn{};wi.prototype.ValueTypeName="bool";wi.prototype.ValueBufferType=Array;wi.prototype.DefaultInterpolation=Ko;wi.prototype.InterpolantFactoryMethodLinear=void 0;wi.prototype.InterpolantFactoryMethodSmooth=void 0;Ra=class extends gn{};Ra.prototype.ValueTypeName="color";$r=class extends gn{};$r.prototype.ValueTypeName="number";bu=class extends Vr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Zt.slerpFlat(s,0,o,l-a,o,l,c);return s}},Zi=class extends gn{InterpolantFactoryMethodLinear(e){return new bu(this.times,this.values,this.getValueSize(),e)}};Zi.prototype.ValueTypeName="quaternion";Zi.prototype.DefaultInterpolation=Qo;Zi.prototype.InterpolantFactoryMethodSmooth=void 0;Mi=class extends gn{};Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=Ko;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;Hr=class extends gn{};Hr.prototype.ValueTypeName="vector";jr=class{constructor(e="",t=-1,i=[],r=Fu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=dn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(r2(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(gn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Tv(c);c=Tf(c,1,u),l=Tf(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new $r(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,p,y){if(f.length!==0){let g=[],m=[];Dp(f,g,m,p),g.length!==0&&y.push(new d(h,g,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let d=0;d<l.length;d++){let h=l[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let y=0;y<h[p].morphTargets.length;y++)f[h[p].morphTargets[y]]=-1;for(let y in f){let g=[],m=[];for(let x=0;x!==h[p].morphTargets.length;++x){let v=h[p];g.push(v.time),m.push(v.morphTarget===y?1:0)}r.push(new $r(".morphTargetInfluence["+y+"]",g,m))}c=f.length*o}else{let f=".bones["+t[d].name+"]";i(Hr,f+".position",h,"pos",r),i(Zi,f+".quaternion",h,"rot",r),i(Hr,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};mi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Pa=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,d){return l.push(u,d),this},this.removeHandler=function(u){let d=l.indexOf(u);return d!==-1&&l.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=l.length;d<h;d+=2){let f=l[d],p=l[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},Iv=new Pa,Jt=class{constructor(e){this.manager=e!==void 0?e:Iv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Jt.DEFAULT_MATERIAL_NAME="__DEFAULT";ui={},If=class extends Error{constructor(e,t){super(e),this.response=t}},Un=class extends Jt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=mi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ui[e]!==void 0){ui[e].push({onLoad:t,onProgress:i,onError:r});return}ui[e]=[],ui[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=ui[e],d=l.body.getReader(),h=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=h?parseInt(h):0,p=f!==0,y=0,g=new ReadableStream({start(m){x();function x(){d.read().then(({done:v,value:w})=>{if(v)m.close();else{y+=w.byteLength;let N=new ProgressEvent("progress",{lengthComputable:p,loaded:y,total:f});for(let C=0,R=u.length;C<R;C++){let F=u[C];F.onProgress&&F.onProgress(N)}m.enqueue(w),x()}})}}});return new Response(g)}else throw new If(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{mi.add(e,l);let u=ui[e];delete ui[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(l)}}).catch(l=>{let u=ui[e];if(u===void 0)throw this.manager.itemError(e),l;delete ui[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Cf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Un(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=jr.parse(e[i]);t.push(r)}return t}},Rf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new qs,c=new Un(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(d){c.load(e[d],function(h){let f=s.parse(h,!0);o[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},l+=1,l===6&&(f.mipmapCount===1&&(a.minFilter=It),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else c.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[p].mipmaps.push(h.mipmaps[p*h.mipmapCount+y]),o[p].format=h.format,o[p].width=h.width,o[p].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=It),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},Gr=class extends Jt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=mi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=oa("img");function c(){u(),mi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},Pf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Nr;s.colorSpace=wn;let o=new Gr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Lf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Gn,a=new Un(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Mn,o.wrapT=l.wrapT!==void 0?l.wrapT:Mn,o.magFilter=l.magFilter!==void 0?l.magFilter:It,o.minFilter=l.minFilter!==void 0?l.minFilter:It,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Hn),l.mipmapCount===1&&(o.minFilter=It),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},Df=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Ct,o=new Gr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Yn=class extends ct{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},_u=class extends Yn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ie(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},yh=new Ve,Fy=new D,ky=new D,La=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new se(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Fr,this._frameExtents=new se(1,1),this._viewportCount=1,this._viewports=[new ht(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Fy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Fy),ky.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ky),t.updateMatrixWorld(),yh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yh),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(yh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Of=class extends La{constructor(){super(new Rt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=zs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},wu=class extends Yn{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Of}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},By=new Ve,Bo=new D,vh=new D,Uf=class extends La{constructor(){super(new Rt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new se(4,2),this._viewportCount=6,this._viewports=[new ht(2,1,1,1),new ht(0,1,1,1),new ht(3,1,1,1),new ht(1,1,1,1),new ht(3,0,1,1),new ht(1,0,1,1)],this._cubeDirections=[new D(1,0,0),new D(-1,0,0),new D(0,0,1),new D(0,0,-1),new D(0,1,0),new D(0,-1,0)],this._cubeUps=[new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,0,1),new D(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Bo.setFromMatrixPosition(e.matrixWorld),i.position.copy(Bo),vh.copy(i.position),vh.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(vh),i.updateMatrixWorld(),r.makeTranslation(-Bo.x,-Bo.y,-Bo.z),By.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(By)}},Mu=class extends Yn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Uf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Nf=class extends La{constructor(){super(new Ws(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Su=class extends Yn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.shadow=new Nf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Eu=class extends Yn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Au=class extends Yn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Tu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new D)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Iu=class extends Yn{constructor(e=new Tu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Cu=class n extends Jt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Un(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ie().setHex(o.value);break;case"v2":r.uniforms[s].value=new se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new D().fromArray(o.value);break;case"v4":r.uniforms[s].value=new ht().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ze().fromArray(o.value);break;case"m4":r.uniforms[s].value=new Ve().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new se().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new se().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:lu,SpriteMaterial:pa,RawShaderMaterial:uu,ShaderMaterial:pn,PointsMaterial:ga,MeshPhysicalMaterial:du,MeshStandardMaterial:Ia,MeshPhongMaterial:hu,MeshToonMaterial:fu,MeshNormalMaterial:pu,MeshLambertMaterial:mu,MeshDepthMaterial:ha,MeshDistanceMaterial:fa,MeshBasicMaterial:Xn,MeshMatcapMaterial:gu,LineDashedMaterial:yu,LineBasicMaterial:zt,Material:Ft};return new t[e]}},Da=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Ru=class extends et{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Pu=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Un(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,p){if(t[p]!==void 0)return t[p];let g=f.interleavedBuffers[p],m=s(f,g.buffer),x=Os(g.type,m),v=new Xs(x,g.stride);return v.uuid=g.uuid,t[p]=v,v}function s(f,p){if(i[p]!==void 0)return i[p];let g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return i[p]=m,m}let o=e.isInstancedBufferGeometry?new Ru:new et,a=e.data.index;if(a!==void 0){let f=Os(a.type,a.array);o.setIndex(new ot(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],y;if(p.isInterleavedBufferAttribute){let g=r(e.data,p.data);y=new kr(g,p.itemSize,p.offset,p.normalized)}else{let g=Os(p.type,p.array),m=p.isInstancedBufferAttribute?qi:ot;y=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(y.name=p.name),p.usage!==void 0&&y.setUsage(p.usage),o.setAttribute(f,y)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],y=[];for(let g=0,m=p.length;g<m;g++){let x=p[g],v;if(x.isInterleavedBufferAttribute){let w=r(e.data,x.data);v=new kr(w,x.itemSize,x.offset,x.normalized)}else{let w=Os(x.type,x.array);v=new ot(w,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),y.push(v)}o.morphAttributes[f]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let y=d[f];o.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new D;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Nt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Ff=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?Da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Un(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?Da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Un(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let d=!1;for(let h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new vi().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new Nl().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new Pu;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Ny?a=Ny[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new Cu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=jr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Os(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new Pa(t);s=new Gr(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let d=e[l],h=d.url;if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new Gn(m.data,m.width,m.height)))}r[d.uuid]=new fi(f)}else{let f=a(d.url);r[d.uuid]=new fi(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Os(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Gr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d],p=await s(f);p!==null&&(p instanceof HTMLImageElement?u.push(p):u.push(new Gn(p.data,p.width,p.height)))}i[c.uuid]=new fi(u)}else{let u=await s(c.url);i[c.uuid]=new fi(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Nr,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Gn:u=new Ct,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,s2)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],zy),u.wrapT=i(a.wrap[1],zy)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,Vy)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Vy)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function c(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function l(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new Ll,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ie(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Pl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Rl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Rt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Ws(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Eu(e.color,e.intensity);break;case"DirectionalLight":o=new Su(e.color,e.intensity);break;case"PointLight":o=new Mu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Au(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new wu(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new _u(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Iu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=c(e.material),o=new Ul(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=c(e.material),o=new St(u,d);break;case"InstancedMesh":u=a(e.geometry),d=c(e.material);let h=e.count,f=e.instanceMatrix,p=e.instanceColor;o=new Fl(u,d,h),o.instanceMatrix=new qi(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new qi(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=c(e.material),o=new kl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new Bt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let m=new Nt;return m.radius=y.sphereRadius,m.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Ol;break;case"Line":o=new qn(a(e.geometry),c(e.material));break;case"LineLoop":o=new Vl(a(e.geometry),c(e.material));break;case"LineSegments":o=new En(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new $l(a(e.geometry),c(e.material));break;case"Sprite":o=new Dl(c(e.material));break;case"Group":o=new Gi;break;case"Bone":o=new ma;break;default:o=new ct}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)o.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let p=h[f];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let p=h[f],y=o.getObjectByProperty("uuid",p.object);y!==void 0&&o.addLevel(y,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},s2={UVMapping:Nu,CubeReflectionMapping:bi,CubeRefractionMapping:Wi,EquirectangularReflectionMapping:qo,EquirectangularRefractionMapping:Yo,CubeUVReflectionMapping:Js},zy={RepeatWrapping:Zo,ClampToEdgeWrapping:Mn,MirroredRepeatWrapping:Jo},Vy={NearestFilter:Ut,NearestMipmapNearestFilter:xp,NearestMipmapLinearFilter:Ds,LinearFilter:It,LinearMipmapNearestFilter:$o,LinearMipmapLinearFilter:Hn},kf=class extends Jt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=mi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return mi.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),mi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});mi.add(e,c),s.manager.itemStart(e)}},Oa=class{static getContext(){return ul===void 0&&(ul=new(window.AudioContext||window.webkitAudioContext)),ul}static setContext(e){ul=e}},Bf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Un(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Oa.getContext().decodeAudioData(l,function(d){t(d)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},$y=new Ve,Hy=new Ve,br=new Ve,zf=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Rt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Rt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,br.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Dr*t.fov*.5)/t.zoom,a,c;Hy.elements[12]=-r,$y.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,br.elements[0]=2*t.near/(c-a),br.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(br),a=-o*t.aspect-s,c=o*t.aspect-s,br.elements[0]=2*t.near/(c-a),br.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(br)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Hy),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply($y)}},Lu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=jy(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=jy();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};_r=new D,Gy=new Zt,o2=new D,wr=new D,Vf=class extends ct{constructor(){super(),this.type="AudioListener",this.context=Oa.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Lu}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(_r,Gy,o2),wr.set(0,0,-1).applyQuaternion(Gy),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(_r.x,r),t.positionY.linearRampToValueAtTime(_r.y,r),t.positionZ.linearRampToValueAtTime(_r.z,r),t.forwardX.linearRampToValueAtTime(wr.x,r),t.forwardY.linearRampToValueAtTime(wr.y,r),t.forwardZ.linearRampToValueAtTime(wr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(_r.x,_r.y,_r.z),t.setOrientation(wr.x,wr.y,wr.z,i.x,i.y,i.z)}},Du=class extends ct{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Mr=new D,Wy=new Zt,a2=new D,Sr=new D,$f=class extends Du{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Mr,Wy,a2),Sr.set(0,0,1).applyQuaternion(Wy);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Mr.x,i),t.positionY.linearRampToValueAtTime(Mr.y,i),t.positionZ.linearRampToValueAtTime(Mr.z,i),t.orientationX.linearRampToValueAtTime(Sr.x,i),t.orientationY.linearRampToValueAtTime(Sr.y,i),t.orientationZ.linearRampToValueAtTime(Sr.z,i)}else t.setPosition(Mr.x,Mr.y,Mr.z),t.setOrientation(Sr.x,Sr.y,Sr.z)}},Hf=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},Ou=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Zt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Zt.multiplyQuaternionsFlat(e,o,e,t,e,i),Zt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Op="\\[\\]\\.:\\/",c2=new RegExp("["+Op+"]","g"),Up="[^"+Op+"]",l2="[^"+Op.replace("\\.","")+"]",u2=/((?:WC+[\/:])*)/.source.replace("WC",Up),d2=/(WCOD+)?/.source.replace("WCOD",l2),h2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Up),f2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Up),p2=new RegExp("^"+u2+d2+h2+f2+"$"),m2=["material","materials","bones","map"],jf=class{constructor(e,t,i){let r=i||ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},ut=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(c2,"")}static parseTrackName(e){let t=p2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);m2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ut.Composite=jf;ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ut.prototype.GetterByBindingType=[ut.prototype._getValue_direct,ut.prototype._getValue_array,ut.prototype._getValue_arrayElement,ut.prototype._getValue_toArray];ut.prototype.SetterByBindingTypeAndVersioning=[[ut.prototype._setValue_direct,ut.prototype._setValue_direct_setNeedsUpdate,ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_array,ut.prototype._setValue_array_setNeedsUpdate,ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_arrayElement,ut.prototype._setValue_arrayElement_setNeedsUpdate,ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_fromArray,ut.prototype._setValue_fromArray_setNeedsUpdate,ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Gf=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=dn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,p=t[f];if(p===void 0){p=c++,t[f]=p,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new ut(h,i[y],r[y]))}else if(p<l){a=e[p];let y=--l,g=e[y];t[g.uuid]=p,e[p]=g,t[f]=y,e[y]=h;for(let m=0,x=o;m!==x;++m){let v=s[m],w=v[y],N=v[p];v[p]=w,N===void 0&&(N=new ut(h,i[m],r[m])),v[y]=N}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[l]=d,e[d]=c;for(let f=0,p=r;f!==p;++f){let y=i[f],g=y[d],m=y[u];y[u]=g,y[d]=m}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],p=--o,y=e[p];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,m=r;g!==m;++g){let x=i[g],v=x[h],w=x[p];x[d]=v,x[h]=w,x.pop()}}else{let h=--o,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,y=r;p!==y;++p){let g=i[p];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,d=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,f=c.length;h!==f;++h){let p=c[h];d[h]=new ut(p,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},Uu=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Ir,endingEnd:Ir};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=J0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Ip:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Fu:default:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===K0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Z0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Cr,r.endingEnd=Cr):(e?r.endingStart=this.zeroSlopeAtStart?Cr:Ir:r.endingStart=ea,t?r.endingEnd=this.zeroSlopeAtEnd?Cr:Ir:r.endingEnd=ea)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},g2=new Float32Array(1),Wf=class extends On{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=u[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;p=new Ou(ut.create(i,f,y),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Ca(new Float32Array(2),new Float32Array(2),1,g2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?jr.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Fu),c!==void 0){let d=c.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Uu(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?jr.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Xf=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},y2=0,qf=class extends On{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:y2++}),this.name="",this.usage=ra,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Yf=class extends Xs{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Xy=new Ve,Jf=class{constructor(e,t,i=0,r=1/0){this.ray=new Xi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new $s,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Xy.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Xy),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(qy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Kf(e[r],this,i,t);return i.sort(qy),i}};Qf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Mt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},ep=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},Yy=new se,tp=class{constructor(e=new se(1/0,1/0),t=new se(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Yy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yy).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Zy=new D,dl=new D,np=class{constructor(e=new D,t=new D){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Zy.subVectors(e,this.start),dl.subVectors(this.end,this.start);let i=dl.dot(dl),s=dl.dot(Zy)/i;return t&&(s=Mt(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Jy=new D,ip=class extends ct{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new et,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));let s=new zt({fog:!1,toneMapped:!1});this.cone=new En(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Jy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Jy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Hi=new D,hl=new Ve,xh=new Ve,rp=class extends En{constructor(e){let t=Cv(e),i=new et,r=[],s=[],o=new Ie(0,0,1),a=new Ie(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));let c=new zt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");xh.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(hl.multiplyMatrices(xh,a.matrixWorld),Hi.setFromMatrixPosition(hl),r.setXYZ(o,Hi.x,Hi.y,Hi.z),hl.multiplyMatrices(xh,a.parent.matrixWorld),Hi.setFromMatrixPosition(hl),r.setXYZ(o+1,Hi.x,Hi.y,Hi.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};sp=class extends St{constructor(e,t,i){let r=new Ta(t,4,2),s=new Xn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},v2=new D,Ky=new Ie,Qy=new Ie,op=class extends ct{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Aa(t);r.rotateY(Math.PI*.5),this.material=new Xn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new ot(o,3)),this.add(new St(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Ky.copy(this.light.color),Qy.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Ky:Qy;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(v2.setFromMatrixPosition(this.light.matrixWorld).negate())}},ap=class extends En{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ie(i),r=new Ie(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let h=0,f=0,p=-a;h<=t;h++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);let y=h===s?i:r;y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3}let u=new et;u.setAttribute("position",new De(c,3)),u.setAttribute("color",new De(l,3));let d=new zt({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},cp=class extends En{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new Ie(s),o=new Ie(o);let a=[],c=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,p=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,p);let y=d&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:o,f=e-e/i*d;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f;a.push(g,0,m),c.push(h.r,h.g,h.b),y=(p+1)/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f,a.push(g,0,m),c.push(h.r,h.g,h.b)}}let l=new et;l.setAttribute("position",new De(a,3)),l.setAttribute("color",new De(c,3));let u=new zt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},e0=new D,fl=new D,t0=new D,lp=class extends ct{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new et;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zt({fog:!1,toneMapped:!1});this.lightPlane=new qn(r,s),this.add(this.lightPlane),r=new et,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new qn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),e0.setFromMatrixPosition(this.light.matrixWorld),fl.setFromMatrixPosition(this.light.target.matrixWorld),t0.subVectors(fl,e0),this.lightPlane.lookAt(fl),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(fl),this.targetLine.scale.z=t0.length()}},pl=new D,wt=new js,up=class extends En{constructor(e){let t=new et,i=new zt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,y){c(p),c(y)}function c(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Ie(16755200),u=new Ie(16711680),d=new Ie(43775),h=new Ie(16777215),f=new Ie(3355443);this.setColors(l,u,d,h,f)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;wt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),At("c",t,e,wt,0,0,-1),At("t",t,e,wt,0,0,1),At("n1",t,e,wt,-i,-r,-1),At("n2",t,e,wt,i,-r,-1),At("n3",t,e,wt,-i,r,-1),At("n4",t,e,wt,i,r,-1),At("f1",t,e,wt,-i,-r,1),At("f2",t,e,wt,i,-r,1),At("f3",t,e,wt,-i,r,1),At("f4",t,e,wt,i,r,1),At("u1",t,e,wt,i*.7,r*1.1,-1),At("u2",t,e,wt,-i*.7,r*1.1,-1),At("u3",t,e,wt,0,r*2,-1),At("cf1",t,e,wt,-i,0,1),At("cf2",t,e,wt,i,0,1),At("cf3",t,e,wt,0,-r,1),At("cf4",t,e,wt,0,r,1),At("cn1",t,e,wt,-i,0,-1),At("cn2",t,e,wt,i,0,-1),At("cn3",t,e,wt,0,-r,-1),At("cn4",t,e,wt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};ml=new Bt,dp=class extends En{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new et;s.setIndex(new ot(i,1)),s.setAttribute("position",new ot(r,3)),super(s,new zt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&ml.setFromObject(this.object),ml.isEmpty())return;let t=ml.min,i=ml.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},hp=class extends En{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new et;s.setIndex(new ot(i,1)),s.setAttribute("position",new De(r,3)),super(s,new zt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},fp=class extends qn{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new et;o.setAttribute("position",new De(s,3)),o.computeBoundingSphere(),super(o,new zt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new et;c.setAttribute("position",new De(a,3)),c.computeBoundingSphere(),this.add(new St(c,new Xn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},n0=new D,pp=class extends ct{constructor(e=new D(0,0,1),t=new D(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",gl===void 0&&(gl=new et,gl.setAttribute("position",new De([0,0,0,0,1,0],3)),bh=new Zs(0,.5,1,5,1),bh.translate(0,-.5,0)),this.position.copy(t),this.line=new qn(gl,new zt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new St(bh,new Xn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{n0.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(n0,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},mp=class extends En{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new et;r.setAttribute("position",new De(t,3)),r.setAttribute("color",new De(i,3));let s=new zt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ie,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},gp=class{constructor(){this.type="ShapePath",this.color=new Ie,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Br,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let x=[];for(let v=0,w=m.length;v<w;v++){let N=m[v],C=new vi;C.curves=N.curves,x.push(C)}return x}function i(m,x){let v=x.length,w=!1;for(let N=v-1,C=0;C<v;N=C++){let R=x[N],F=x[C],A=F.x-R.x,S=F.y-R.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(R=x[C],A=-A,F=x[N],S=-S),m.y<R.y||m.y>F.y)continue;if(m.y===R.y){if(m.x===R.x)return!0}else{let P=S*(m.x-R.x)-A*(m.y-R.y);if(P===0)return!0;if(P<0)continue;w=!w}}else{if(m.y!==R.y)continue;if(F.x<=m.x&&m.x<=R.x||R.x<=m.x&&m.x<=F.x)return!0}}return w}let r=Wn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new vi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],p=0,y;h[p]=void 0,f[p]=[];for(let m=0,x=s.length;m<x;m++)a=s[m],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[p]&&p++,h[p]={s:new vi,p:y},h[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let m=!1,x=0;for(let v=0,w=h.length;v<w;v++)d[v]=[];for(let v=0,w=h.length;v<w;v++){let N=f[v];for(let C=0;C<N.length;C++){let R=N[C],F=!0;for(let A=0;A<h.length;A++)i(R.p,h[A].p)&&(v!==A&&x++,F?(F=!1,d[A].push(R)):m=!0);F&&d[v].push(R)}}x>0&&m===!1&&(f=d)}let g;for(let m=0,x=h.length;m<x;m++){c=h[m].s,l.push(c),g=f[m];for(let v=0,w=g.length;v<w;v++)c.holes.push(g[v].h)}return l}},yp=class extends hn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var iR={};qp(iR,{createWorldOrbitEditor:()=>ox});var q=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var oo=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],xn=oo.filter(n=>n!=="system"),xx=["star","planet","moon","asteroid","comet","structure","phenomenon"],Yp=["structure","phenomenon"],Ci=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],bx=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function it(n,e){return{key:n,...e}}var Ya=new Set(oo),Zp=new Map([it("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:Ci}),it("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"distance"}),it("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"distance"}),it("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:Ci}),it("period",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"duration"}),it("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("at",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),it("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),it("free",{kind:"string",placement:!0,arity:"single",objectTypes:bx}),it("kind",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("class",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("culture",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:oo}),it("color",{kind:"string",placement:!1,arity:"single",objectTypes:oo}),it("image",{kind:"string",placement:!1,arity:"single",objectTypes:xx}),it("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:oo}),it("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"radius"}),it("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"mass"}),it("density",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:xn}),it("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),it("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),it("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),it("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("on",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("source",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"duration"})].map(n=>[n.key,n])),_x=new Set(Zp.keys());function an(n){return Zp.get(n)}function Jp(n){return _x.has(n)}function Kp(n,e){return n.objectTypes.includes(e)}function Za(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function ao(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,o=!1,a=!1,c=null,l=()=>{s!==null&&(t.push({value:r,column:s,quoted:o}),r="",s=null,o=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(a&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){a?a=!1:(s===null&&(s=h),o=!0,c=h,a=!0);continue}if(!a&&/\s/.test(d)){l();continue}s===null&&(s=h),r+=d}if(a)throw new q("Unclosed quote in line",e.line,c??i+n.length);return l(),t}function Ja(n){return n.match(/^\s*/)?.[0].length??0}function co(n){let e=n.split(/\r?\n/),t=[],i=null,r=null,s=!1,o=!1,a=null,c=null,l=null,u=null;for(let d=0;d<e.length;d++){let h=e[d],f=d+1;if(!h.trim())continue;let p=Ja(h),y=ao(h.slice(p),{line:f,columnOffset:p});if(y.length!==0){if(p===0){if(s=!1,o=!1,a=null,c=null,l=null,u=null,y.length>=1&&y[0].value==="theme"){o=!0,c=0,i={type:"theme",preset:y.length>=2?y[1].value:null,blocks:[],location:{line:f,column:y[0].column}};continue}let g=wx(y,f);t.push(g),r=g;continue}if(o){if(y.length>=2&&y[0].value==="preset"&&(!l||p<=l)){i&&(i.preset=y[1].value);continue}u&&l!==null&&p>l?u.fields.push(Ex(y,f)):(l=p,u={type:"theme-block",target:y[0].value,fields:[],location:{line:f,column:y[0].column}},i?.blocks.push(u));continue}if(!r)throw new q("Indented line without parent object",f,p+1);if(y.length===1&&y[0].value==="info"){s=!0,a=p;continue}s&&p<=(a??0)&&(s=!1),s?r.infoEntries.push(Ax(y,f)):r.blockFields.push(Sx(y,f))}}return{type:"document",theme:i,objects:t}}function wx(n,e){if(n.length<2)throw new q("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Ya.has(t.value))throw new q(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:Mx(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function Mx(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=an(r.value);if(!s)throw new q(`Unknown field "${r.value}"`,e,r.column);i++;let o=[];if(s.arity==="multiple")for(;i<n.length&&!Jp(n[i].value);)o.push(n[i]),i++;else{let a=n[i];a&&(o.push(a),i++)}if(o.length===0)throw new q(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:o.map(a=>a.value),location:{line:e,column:r.column}})}return t}function Sx(n,e){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);if(!an(n[0].value))throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function Ex(n,e){if(n.length<2)throw new q("Invalid theme field line",e,n[0]?.column??1);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function Ax(n,e){if(n.length<2)throw new q("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var Qp=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Tx=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Ix=/^[A-Za-z][A-Za-z0-9+.-]*:/;function lo(n){let e=null,t=[],i=n.theme?Cx(n.theme):null;for(let r of n.objects){let s=Px(r);if(r.objectType==="system"){if(e)throw q.fromLocation("Only one system object is allowed",r.location);e=s}else t.push(s)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",theme:i,system:e,groups:[],relations:[],events:[],objects:t}}function Cx(n){let e={};for(let t of n.blocks){let i=em(t.fields);e[t.target]=Rx(i)}return{preset:n.preset,styles:e}}function Rx(n){let e={};for(let[t,i]of n.entries()){if(i.values.length===1){let r=i.values[0];if(r==="true"){e[t]=!0;continue}if(r==="false"){e[t]=!1;continue}let s=Number(r);if(!Number.isNaN(s)&&r.trim()!==""){e[t]=s;continue}}e[t]=i.values.join(" ")}return e}function Px(n){let e=[...n.inlineFields,...n.blockFields];Lx(n.objectType,e);let t=em(e),i=Dx(n.objectType,t),r=Ox(t),s=Fx(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function Lx(n,e){for(let t of e){let i=an(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(!Kp(i,n))throw q.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function em(n){let e=new Map;for(let t of n){if(e.has(t.key))throw q.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function Dx(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),o=[t,i,r,s].filter(Boolean).length;if(o>1){let a=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw q.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw q.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Ka(e,"orbit"),distance:Jr(e,"distance"),semiMajor:Jr(e,"semiMajor"),eccentricity:zx(e,"eccentricity"),period:Jr(e,"period"),angle:Jr(e,"angle"),inclination:Jr(e,"inclination"),phase:Jr(e,"phase")};if(i){let a=Qa(e,"at"),c=Ka(e,"at");return{mode:"at",target:c,reference:kx(c,a.location)}}if(r)return{mode:"surface",target:Ka(e,"surface")};if(s){let a=Ka(e,"free"),c=Bx(a);return{mode:"free",distance:c??void 0,descriptor:c?void 0:a}}return null}function Ox(n){let e={};for(let[t,i]of n.entries()){let r=an(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=Vx(i);break;case"number":e[t]=nm(Kr(i),t,i.location);break;case"unit":e[t]=tm(Kr(i),i.location,t);break;case"string":e[t]=Ux(t,i);break}}return e}function Ux(n,e){let t=e.values.join(" ").trim();return n==="image"&&Nx(t,e.location),t}function Nx(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Ix);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function Fx(n){let e={};for(let t of n){if(t.key in e)throw q.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function kx(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function tm(n,e,t){let i=n.match(Qp);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=an(t);if(s?.unitFamily&&!Za(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Bx(n){let e=n.match(Qp);return e?{value:Number(e[1]),unit:e[2]??null}:null}function Jr(n,e){if(!n.has(e))return;let t=Qa(n,e);return tm(Kr(t),t.location,e)}function zx(n,e){if(!n.has(e))return;let t=Qa(n,e);return nm(Kr(t),e,t.location)}function nm(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Vx(n){let e=Kr(n).toLowerCase(),t=Tx.get(e);if(t===void 0)throw q.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Qa(n,e){let t=n.get(e);if(!t)throw new q(`Missing value for key "${e}"`);return t}function Ka(n,e){return Kr(Qa(n,e))}function Kr(n){if(n.values.length!==1)throw q.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var $x=new Set(["star","planet","moon","asteroid","comet"]);function uo(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new q(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new q(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!$x.has(r.type))throw new q(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&Hx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&jx(i,i.placement.reference,e))}}function Hx(n,e,t){if(!t.has(e.primary))throw new q(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new q(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function jx(n,e,t){if(!t.has(e.objectId))throw new q(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function lr(n,e,t=`${e}.failed`){return n instanceof q?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var ho=1495978707e-1,Gx=6371,Wx=71492,Xx=695700,qx=63241.077,Yx=206264.806,Zx=206264806,lm=.68,Jx=.2,um=28;function Gt(n,e={}){let t=eb(e),i=t.width,r=t.height,s=t.padding,o=Qx(n),a=nb(n,e.projection),c=id(e.camera??null),l=nd(a,c),u=ab(o),d=sb(o,e.scaleModel,e.bodyScaleMode),h=n.system?.id??null,f=e.activeEventId??null,p=Kx(n.objects,n.events??[],f),y=cb(p,i,r,s,u,d),g=new Map(p.map(te=>[te.id,te])),m=Gb(p,g),x=new Map,v=[],w=[],N=[],C=[],R=[],F=new Map,A=new Map;for(let te of p){let ue=te.placement;if(!ue){N.push(te);continue}if(ue.mode==="orbit"){om(A,ue.target,te);continue}if(ue.mode==="surface"){om(F,ue.target,te);continue}if(ue.mode==="at"){R.push(te);continue}C.push(te)}let S=C.length>0?i*.42:i/2,P=r/2,k={orbitChildren:A,surfaceChildren:F,objectMap:g,spacingFactor:u,projection:l,scaleModel:d,sceneMetricScale:y},O=N.find(te=>te.type==="star")??N[0]??null;O&&ed(O,S,P,0,x,v,w,k);let H=N.filter(te=>te.id!==O?.id);if(H.length>0){let te=Math.min(i,r)*.28*u*d.orbitDistanceMultiplier;H.forEach((ue,Pe)=>{let _e=yo(Pe,H.length,-Math.PI/2),z=vo(_e,te,l,1);ed(ue,S+z.x,P+z.y,0,x,v,w,k)})}C.forEach((te,ue)=>{let Pe=i-s-140-Jb(te.placement?.mode==="free"?te.placement.distance:void 0,d,y),_e=Math.max(76,(r-s*2-180)/Math.max(1,C.length)*u)*d.freePlacementMultiplier,z=s+92+ue*_e;x.set(te.id,{object:te,x:Pe,y:z,radius:rc(te,0,d,y),sortKey:oc(Pe,z,0)}),w.push({object:te,groupId:m.groupIds.get(te.id)??null,x1:Pe-60,y1:z,x2:Pe-18,y2:z,mode:"free"}),nc(te,x,v,w,k,1)}),R.forEach((te,ue)=>{if(x.has(te.id)||!te.placement||te.placement.mode!=="at")return;let Pe=Hb(te.placement.reference,x,g,ue,R.length,i,r,s,k);x.set(te.id,{object:te,x:Pe.x,y:Pe.y,radius:rc(te,2,d,y),sortKey:oc(Pe.x,Pe.y,2),anchorX:Pe.anchorX,anchorY:Pe.anchorY}),Pe.anchorX!==void 0&&Pe.anchorY!==void 0&&w.push({object:te,groupId:m.groupIds.get(te.id)??null,x1:Pe.anchorX,y1:Pe.anchorY,x2:Pe.x,y2:Pe.y,mode:"at"}),nc(te,x,v,w,k,2)});let W=[...x.values()].map(te=>lb(te,d,m)),J=v.map(te=>ub(te,m.groupIds.get(te.object.id)??null)),ae=w.map(te=>db(te)),B=hb(W,i,r,d.labelMultiplier),ne=bb(n,W),ce=_b(n.events??[],W,f),Me=yb(J,ne,ce,ae,W,B),fe=vb(W,J,ae,B,m,d.labelMultiplier),$e=xb(n,W),Y=wb(n,a,t.preset,m,g),me=Ob(i,r,W,J,ae,B,d.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:a,renderProjection:l,camera:c,scaleModel:d,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:rb(a,l,o,c),systemId:h,viewMode:a,layoutPreset:o,metadata:{format:n.format,version:n.version,view:a,renderProjection:l,scale:String(n.system?.properties.scale??o),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom","body.scaleMode":d.bodyScaleMode,...c?.azimuth!==null?{"camera.azimuth":String(c?.azimuth)}:{},...c?.elevation!==null?{"camera.elevation":String(c?.elevation)}:{},...c?.roll!==null?{"camera.roll":String(c?.roll)}:{},...c?.distance!==null?{"camera.distance":String(c?.distance)}:{}},contentBounds:me,layers:Me,groups:fe,semanticGroups:$e,viewpoints:Y,events:ce,activeEventId:f,objects:W,orbitVisuals:J,relations:ne,leaders:ae,labels:B}}function rn(n,e,t){let i=ac(t),r=Math.cos(i),s=Math.sin(i),o=n.x-e.x,a=n.y-e.y;return{x:e.x+o*r-a*s,y:e.y+o*s+a*r}}function Kx(n,e,t){let i=n.map(a=>structuredClone(a));if(!t)return i;let r=e.find(a=>a.id===t);if(!r)return i;let s=new Map(i.map(a=>[a.id,a])),o=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(a=>a.objectId)]);for(let a of o){let c=s.get(a);c&&(r.epoch&&(c.epoch=r.epoch),r.referencePlane&&(c.referencePlane=r.referencePlane))}for(let a of r.positions){let c=s.get(a.objectId);c&&(a.placement&&(c.placement=structuredClone(a.placement)),a.inner&&(c.properties.inner={...a.inner}),a.outer&&(c.properties.outer={...a.outer}),a.epoch&&(c.epoch=a.epoch),a.referencePlane&&(c.referencePlane=a.referencePlane))}return i}function Qx(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function eb(n){let e=tb(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function tb(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function nb(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return fm(t)??"topdown"}function nd(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function id(n){if(!n)return null;let e={azimuth:Qu(n.azimuth),elevation:Qu(n.elevation),roll:Qu(n.roll),distance:ib(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function Qu(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function ib(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function rb(n,e,t,i){let r=[`${am(n)} view`,`${am(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function sb(n,e,t){return{...ob(n),...t?{bodyScaleMode:t}:{},...e}}function ob(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36,bodyScaleMode:"readable"};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48,bodyScaleMode:"readable"};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40,bodyScaleMode:"readable"}}}function ab(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function cb(n,e,t,i,r,s){let o=[],a=[];for(let f of n){let p=Qb(f);p!==null&&p>0&&a.push(p);let y=f.placement;if(y){if(y.mode==="orbit"){let g=Ri(y.semiMajor??y.distance??null);g!==null&&g>0&&o.push(g);continue}if(y.mode==="free"){let g=Ri(y.distance??null);g!==null&&g>0&&o.push(g)}}}let c=Math.max(...o,0),l=Math.max(...a,0),u=Math.max(c,l*6,0),d=u+Math.max(Math.sqrt(u),l*2,c>0?.25:0);return d<=0?{pixelsPerMetric:null,hasExplicitScale:!1}:{pixelsPerMetric:Math.max(Math.min(e,t)/2-i-24,120)*r*s.orbitDistanceMultiplier/d,hasExplicitScale:!0}}function lb(n,e,t){let{object:i,x:r,y:s,radius:o,sortKey:a,anchorX:c,anchorY:l}=n,u=i.renderHints?.renderPriority??0;return{renderId:Qr(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:o,visualRadius:Zb(i,o,e),sortKey:a+u*.001,anchorX:c,anchorY:l,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:e_(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function ub(n,e){return{renderId:`${Qr(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function db(n){return{renderId:`${Qr(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function hb(n,e,t,i){let r=[],s=[],o=new Map(n.map(c=>[c.objectId,c])),a=[...n].filter(c=>!c.hidden&&c.object.renderHints?.renderLabel!==!1).sort(fb);for(let c of a){let l=pb(c,o,s,e,t,i)??hm(c,dm(c,o.get(c.parentId??"")??null,t),0,i);s.push(vm(c,l,i)),r.push({renderId:`${c.renderId}-label`,objectId:c.objectId,object:c.object,groupId:c.groupId,semanticGroupIds:[...c.semanticGroupIds],label:c.label,secondaryLabel:c.secondaryLabel,x:l.x,y:l.labelY,secondaryY:l.secondaryY,textAnchor:l.textAnchor,direction:l.direction,hidden:c.hidden})}return r}function fb(n,e){let t=im(n)-im(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function im(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function pb(n,e,t,i,r,s){for(let o of mb(n,e,i,r)){let a=o==="left"||o==="right"?4:6;for(let c=0;c<=a;c+=1){let l=hm(n,o,c,s),u=vm(n,l,s);if(!t.some(d=>qb(d,u)))return l}}return null}function mb(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=dm(n,r,i),o=s==="below"?"above":"below",a=gb(n,r,t),c=a==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[a,s,c,o]:[s,a,o,c]}function dm(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function gb(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function hm(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"start",direction:e}}}}function yb(n,e,t,i,r,s){let o=n.filter(c=>!c.hidden&&!!c.backArcPath).map(c=>c.renderId),a=n.filter(c=>!c.hidden).map(c=>c.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:a},{id:"relations",renderIds:e.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"events",renderIds:t.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"objects",renderIds:r.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"labels",renderIds:s.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function vb(n,e,t,i,r,s){let o=new Map,a=c=>{if(!c)return null;let l=o.get(c);if(l)return l;let u=r.groupRoots.get(c)??null,d={renderId:c,rootObjectId:u,label:u??c,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:go(0,0,0,0)};return o.set(c,d),d};for(let c of n){let l=a(c.groupId);l&&!c.hidden&&l.objectIds.push(c.objectId)}for(let c of e){let l=a(c.groupId);l&&!c.hidden&&l.orbitIds.push(c.objectId)}for(let c of t){let l=a(c.groupId);l&&!c.hidden&&l.leaderIds.push(c.objectId)}for(let c of i){let l=a(c.groupId);l&&!c.hidden&&l.labelIds.push(c.objectId)}for(let c of o.values())c.contentBounds=Wb(c,n,e,t,i,s);return[...o.values()].sort((c,l)=>c.label.localeCompare(l.label))}function xb(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function bb(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${Qr(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function _b(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],o=s.map(l=>i.get(l)).filter(Boolean),a=o.length>0?o.reduce((l,u)=>l+u.x,0)/o.length:0,c=o.length>0?o.reduce((l,u)=>l+u.y,0)/o.length:0;return{renderId:`${Qr(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:a,y:c,hidden:r.hidden||o.length===0||o.every(l=>l.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function wb(n,e,t,i,r){let s=Mb(n,e,t),o=new Map;for(let[l,u]of Object.entries(n.system?.info??{})){if(!l.startsWith("viewpoint."))continue;let[d,h,...f]=l.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let p=Pb(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};Sb(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(l=>Eb(l,e,t,r)).filter(Boolean),c=a.findIndex(l=>l.id===s.id);return c>=0?a.splice(c,1,{...s,...a[c],layers:{...s.layers,...a[c].layers},filter:a[c].filter??s.filter,generated:!1}):a.unshift(s),a.sort((l,u)=>l.id==="overview"?-1:u.id==="overview"?1:l.label.localeCompare(u.label))}function Mb(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=id(null),o=nd(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:o,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Sb(n,e,t,i,r,s,o,a){let c=t.trim();switch(e){case"label":case"title":c&&(n.label=c);return;case"summary":case"description":c&&(n.summary=c);return;case"focus":case"object":c&&(n.focus=c);return;case"select":case"selection":c&&(n.select=c);return;case"events":n.eventIds=mo(c);return;case"projection":case"view":n.projection=fm(c)??r;return;case"preset":n.preset=Tb(c)??s;return;case"rotation":case"angle":n.rotationDeg=fo(c)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??tc(),azimuth:fo(c)};return;case"camera.elevation":n.camera={...n.camera??tc(),elevation:fo(c)};return;case"camera.roll":n.camera={...n.camera??tc(),roll:fo(c)};return;case"camera.distance":n.camera={...n.camera??tc(),distance:rm(c)};return;case"zoom":case"scale":n.scale=rm(c);return;case"layers":n.layers=Ib(c);return;case"query":n.filter={...n.filter??ec(),query:c||null};return;case"types":case"objecttypes":n.filter={...n.filter??ec(),objectTypes:Cb(c)};return;case"tags":n.filter={...n.filter??ec(),tags:mo(c)};return;case"groups":n.filter={...n.filter??ec(),groupIds:Rb(c,i,o,a)};return}}function Eb(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,o=Ab(n.filter),a=n.label?.trim()||Lb(n.id),c=n.projection??e,l=id(n.camera??null),u=nd(c,l);return{id:n.id,label:a,summary:n.summary?.trim()||Db(a,r,o),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:c,renderProjection:u,camera:l,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:o,generated:!1}}function ec(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function tc(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Ab(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function fm(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Tb(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function fo(n){let e=Number(n);return Number.isFinite(e)?e:null}function rm(n){let e=fo(n);return e!==null&&e>0?e:null}function Ib(n){let e={};for(let t of mo(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function Cb(n){return mo(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function Rb(n,e,t,i){return mo(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.schemaVersion==="2.6"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??po(r):(i.has(r),po(r)))}function mo(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Pb(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Lb(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Db(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function Ob(n,e,t,i,r,s,o){let a=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{a=Math.min(a,h),c=Math.min(c,f),l=Math.max(l,h),u=Math.max(u,f)};for(let h of i)h.hidden||pm(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||mm(h,d);for(let h of s)h.hidden||gm(h,d,o);return!Number.isFinite(a)||!Number.isFinite(c)?go(0,0,n,e):go(a,c,l,u)}function pm(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=bm(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,um*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function go(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function mm(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function gm(n,e,t){let i=xm(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function ed(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:rc(n,i,a.scaleModel,a.sceneMetricScale),sortKey:oc(e,t,i)}),nc(n,r,s,o,a,i+1))}function nc(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(Ub),c=Nb(a,o.radius,r.spacingFactor,r.scaleModel,r.sceneMetricScale),l=Bb(a,c);a.forEach((d,h)=>{let f=Fb(d,h,a.length,o,c,l[h]??c.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),ed(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=yo(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=vo(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=vo(f,o.radius+p,r.projection,r.projection==="isometric"?.9:1),m=o.x+y.x,x=o.y+y.y,v=o.x+g.x,w=o.y+g.y;e.set(d.id,{object:d,x:v,y:w,radius:rc(d,s+1,r.scaleModel,r.sceneMetricScale),sortKey:oc(v,w,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?po(Xb(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:w,mode:"surface"}),nc(d,e,t,i,r,s+1)})}function Ub(n,e){let t=ic(n),i=ic(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function Nb(n,e,t,i,r){let s=n.map(f=>ic(f)),o=s.filter(f=>f!==null),a=i.bodyScaleMode==="strict"?Math.max(2,8*t*i.orbitDistanceMultiplier):(n.length>2?54:64)*t*i.orbitDistanceMultiplier*.42,c=e+Math.max(a*1.2,24*t),l=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(o.length===0)return{metrics:s,minMetric:0,maxMetric:0,metricSpread:0,innerPx:c,stepPx:l,pixelSpread:Math.max(l*Math.max(n.length-1,1),l),minimumGapPx:a,pixelsPerMetric:r.pixelsPerMetric};let u=Math.min(...o),d=Math.max(...o),h=d-u;return{metrics:s,minMetric:u,maxMetric:d,metricSpread:h,innerPx:c,stepPx:l,pixelSpread:Math.max(l*Math.max(n.length-1,1),l),minimumGapPx:a,pixelsPerMetric:r.pixelsPerMetric}}function Fb(n,e,t,i,r,s,o){let a=n.placement,c=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let F=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:F,rotationDeg:0,band:c,bandThickness:c?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-F}}let l=_t(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-l*l),u*.18),h=td(a.inclination)??0,f=o.projection==="isometric"?Math.max(Jx,Math.cos(ac(h)))*lm:1,p=Math.max(d*f,u*.14),y=td(a.angle)??0,g=u*l,m=wm(-g,0,y),x=i.x+m.x,v=i.y+m.y,w=Vb(a.phase,e,t),N=_m(x,v,u,p,y,w),C=o.projection==="topdown"&&l<=1e-4&&Math.abs(y)<=1e-4,R=c?$b(n,u,r,o.scaleModel):void 0;return{kind:C?"circle":"ellipse",cx:C?i.x:x,cy:C?i.y:v,radius:C?u:void 0,rx:C?void 0:u,ry:C?void 0:p,rotationDeg:y,band:c,bandThickness:R,frontArcPath:o.projection==="isometric"||c?sm(x,v,u,p,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||c?sm(x,v,u,p,y,Math.PI,Math.PI*2):void 0,objectX:N.x,objectY:N.y}}function kb(n,e){return e.pixelsPerMetric!==null?n*e.pixelsPerMetric:e.innerPx+e.stepPx*zb(Math.max(n,0)+1)}function Bb(n,e){let t=[];return n.forEach((i,r)=>{let s=ic(i),o=e.innerPx+r*e.stepPx,a=s===null?o:kb(s,e),c=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,c))}),t}function ic(n){return!n.placement||n.placement.mode!=="orbit"?null:Ri(n.placement.semiMajor??n.placement.distance??null)}function zb(n){return Math.log(n)/Math.log(2)}function Vb(n,e,t){let i=n?td(n):null;return i!==null?ac(i-90):yo(e,t,-Math.PI/2)}function $b(n,e,t,i){let r=Ri(sc(n.properties.inner)),s=Ri(sc(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.pixelsPerMetric!==null){let l=a*t.pixelsPerMetric;return i.bodyScaleMode==="strict"?Math.max(l*i.ringThicknessMultiplier,1):_t(Math.max(l*i.ringThicknessMultiplier,8),8,54)}if(t.metricSpread>0)return _t(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let c=Math.max(Math.max(r,s),1e-4);return _t(a/c*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function Hb(n,e,t,i,r,s,o,a,c){if(n.kind==="lagrange")return jb(n,e,t,s,o);if(n.kind==="anchor"){let l=e.get(n.objectId);if(l){let u=yo(i,r,Math.PI/5),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=vo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}if(n.kind==="named"){let l=e.get(n.name);if(l){let u=yo(i,r,Math.PI/6),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=vo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}return{x:s-a-170,y:o-a-86-i*58*c.scaleModel.freePlacementMultiplier}}function jb(n,e,t,i,r){let s=n.secondary?e.get(n.primary):Yb(n.primary,e,t),o=e.get(n.secondary??n.primary);if(!s||!o)return{x:i*.7,y:r*.25};let a=o.x-s.x,c=o.y-s.y,l=Math.hypot(a,c)||1,u=a/l,d=c/l,h=-d,f=u,p=_t(l*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*p,y:o.y-d*p,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*p,y:o.y+d*p,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*p,y:s.y-d*p,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*p,y:o.y+(d*.5-f*.8660254)*p,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*p,y:o.y+(d*.5+f*.8660254)*p,anchorX:o.x,anchorY:o.y}}}function Gb(n,e){let t=new Map,i=new Map;for(let l of n){let u=ym(l,e);if(t.set(l.id,u),u){let d=i.get(u);d?d.push(l.id):i.set(u,[l.id])}i.has(l.id)||i.set(l.id,[])}let r=new Map,s=new Map,o=new Map,a=l=>{let u=r.get(l);if(u)return u;let d=new Set,h=[],f=t.get(l)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(l,h),h},c=l=>{let u=o.get(s.get(l)??"");if(u)return u;let d=t.get(l)??null,h=e.get(l),f=l;return h?.placement&&h.placement.mode!=="free"&&d&&(f=c(d)),f};for(let l of n){a(l.id);let u=c(l.id),d=po(u);s.set(l.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function ym(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function Wb(n,e,t,i,r,s){let o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=(d,h)=>{o=Math.min(o,d),a=Math.min(a,h),c=Math.max(c,d),l=Math.max(l,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&mm(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&pm(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&gm(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?go(0,0,0,0):go(o,a,c,l)}function Xb(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=ym(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function vm(n,e,t){return xm(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function xm(n,e,t,i,r,s,o,a){let c=t_(s,o,a),l=c*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-c,f=n+c;return i==="start"?(h=n,f=n+l):i==="end"&&(h=n-l,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function qb(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function Yb(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function rc(n,e,t,i){let r=Kb(n.properties.radius,t,i);if(r!==null)return r;let s=t.bodyRadiusMultiplier;switch(n.type){case"star":return _t((e===0?28:20)*s,t.minBodyRadius,t.maxBodyRadius);case"planet":return _t(12*s,t.minBodyRadius,t.maxBodyRadius);case"moon":return _t(7*s,t.minBodyRadius,t.maxBodyRadius);case"belt":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"comet":return _t(6*s,t.minBodyRadius,t.maxBodyRadius);case"ring":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"structure":return _t(6*s,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return _t(8*s,t.minBodyRadius,t.maxBodyRadius)}}function Zb(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function Ri(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/ho;case"m":return n.value/1e3/ho;case"ly":return n.value*qx;case"pc":return n.value*Yx;case"kpc":return n.value*Zx;case"re":return n.value*Gx/ho;case"rj":return n.value*Wx/ho;case"sol":return n.value*Xx/ho;default:return n.value}}function Jb(n,e,t){let i=Ri(n??null);if(i===null||i<=0)return 0;if(t.pixelsPerMetric!==null){let r=i*t.pixelsPerMetric*e.freePlacementMultiplier;return e.bodyScaleMode==="strict"?Math.max(r,0):_t(r,0,420)}return _t(i*96*e.freePlacementMultiplier,0,420)}function Kb(n,e,t){let i=sc(n);if(!i)return null;let r=Ri(i);if(t.pixelsPerMetric!==null&&r!==null&&r>0){let o=r*t.pixelsPerMetric*e.bodyRadiusMultiplier;return e.bodyScaleMode==="strict"?Math.max(o,.1):_t(Math.max(o,e.minBodyRadius),e.minBodyRadius,e.maxBodyRadius)}let s;switch(i.unit){case"sol":s=_t(i.value*22,14,40);break;case"re":s=_t(i.value*10,6,18);break;case"km":s=_t(Math.log10(Math.max(i.value,1))*2.6,4,16);break;default:s=_t(i.value*4,4,20);break}return _t(s*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function Qb(n){return Ri(sc(n.properties.radius))}function sc(n){return!n||typeof n!="object"||!("value"in n)?null:n}function td(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function yo(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function sm(n,e,t,i,r,s,o){let a=bm(n,e,t,i,r,s,o,um);return a.length===0?"":a.map((c,l)=>`${l===0?"M":"L"} ${cm(c.x)} ${cm(c.y)}`).join(" ")}function bm(n,e,t,i,r,s,o,a){let c=[];for(let l=0;l<=a;l+=1){let u=s+(o-s)*l/a;c.push(_m(n,e,t,i,r,u))}return c}function _m(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),c=wm(o,a,r);return{x:n+c.x,y:e+c.y}}function wm(n,e,t){let i=ac(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function vo(n,e,t,i){let r=t==="isometric"?lm*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function oc(n,e,t){return e*1e3+n+t*.01}function _t(n,e,t){return Math.min(Math.max(n,e),t)}function om(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function Qr(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function po(n){return`${Qr(n)}-group`}function e_(n){return typeof n=="string"&&n.trim()?n:void 0}function t_(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function am(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function ac(n){return n*Math.PI/180}function cm(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Em=86400,cc=Em*365.25,lc=18,Mm=180;function ts(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,bodyScaleMode:e.bodyScaleMode,activeEventId:e.activeEventId},i=Gt(n,t),r=s_(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},o=new Map(i.objects.map(y=>[y.objectId,y])),a=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),c=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||c.set(y.objectId,sd(g))}let l=Math.min(...[...c.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>n_(y,i,s,o,a,r,u,l)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>i_(y,h,l,i.activeEventId!==null)),p=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:a_(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function n_(n,e,t,i,r,s,o,a){let c=uc(n,e,t,i,r,o),l=ad(n.object,r.get(n.objectId),a,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:c,radius:es(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:es(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:l}}function i_(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??dc(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??ad(n.object,n,t,i)}}function uc(n,e,t,i,r,s){let o=s.get(n.objectId);if(o)return o;let a=n.object.placement,c;if(a?.mode==="orbit"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=ad(n.object,d,1,e.activeEventId!==null),f=h?Am(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};c=Tm(u,f)}else if(a?.mode==="surface"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=l?.visualRadius??16,h=c_(n.objectId),f=h*Math.PI*2;c={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(a?.mode==="at"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??l?.x??t.x,h=n.anchorY??l?.y??t.y;c={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else c={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,c),c}function od(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let o=i.get(s);if(o)return o;let a=t.get(s);if(!a)return{x:0,y:0,z:0};let c={...a.position};if(a.motion&&a.parentId){let l=r(a.parentId),u=Am(a.motion,n.timeFrozen?0:e);c=Tm(l,u)}return i.set(s,c),c};for(let s of n.objects)r(s.objectId);return i}function Am(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=rd(t),r=rd(n.rotationDeg),s=rd(n.inclinationDeg),o=Math.cos(i)*n.semiMajor,a=Math.sin(i)*n.semiMinor,c=o*Math.cos(r)-a*Math.sin(r),l=o*Math.sin(r)+a*Math.cos(r);return{x:c,y:l*Math.sin(s),z:l*Math.cos(s)}}function ad(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??es(sd(r)*48,24,1200),o=e?.radius??e?.ry??s,a=r_(r.period),c=sd(r),l=es(c/Math.max(t,1e-4),1,20),u=es(a?lc*l:lc*Math.pow(l,.75),lc,Mm);return{phase0Deg:dc(r.phase)??0,rotationDeg:dc(r.angle)??e?.rotationDeg??0,inclinationDeg:dc(r.inclination)??0,semiMajor:s,semiMinor:o,eccentricity:r.eccentricity??0,periodSeconds:a,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:a===null,frozen:i}}function sd(n){let e=Sm(n.semiMajor)??Sm(n.distance)??1;return Math.max(e,.01)}function Sm(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function r_(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Em;case"y":return n.value*cc;case"ky":return n.value*cc*1e3;case"my":return n.value*cc*1e6;case"gy":return n.value*cc*1e9;default:return null}}function dc(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function s_(n,e){return{...o_(n),...e}}function o_(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function a_(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of n)e=Math.min(e,a.position.x-a.visualRadius),t=Math.min(t,a.position.y-a.visualRadius),i=Math.min(i,a.position.z-a.visualRadius),r=Math.max(r,a.position.x+a.visualRadius),s=Math.max(s,a.position.y+a.visualRadius),o=Math.max(o,a.position.z+a.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:o,width:r-e,height:s-t,depth:o-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+o)/2}}}function Tm(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function c_(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function es(n,e,t){return Math.min(Math.max(n,e),t)}function rd(n){return n*Math.PI/180}function ur(n,e={}){let t=Gt(n,e),i=[],r=d_(n,i),s=h_(n,i),o=u_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?l_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(c=>!c.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(c=>!c.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.6",schemaVersion:"2.6",sourceVersion:n.version,theme:n.theme??null,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(Cm),diagnostics:i}}function cd(n,e={}){return M_(ur(n,e))}function ns(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:b_(n.system),info:__(n.system)}:null,i=n.objects.map(Cm);return g_(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,theme:n.theme??null,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(p_),objects:i}}function l_(n,e,t,i,r,s){let o=Gt(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(f_),annotations:i}}function u_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function d_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function h_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=Im(s);if(!a)continue;let c=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":c.label=r;break;case"target":case"object":c.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":c.body=r;break;case"tags":c.tags=v_(r);break}t.set(a,c)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=Im(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??x_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function f_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function Cm(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:y_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function p_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(m_)}}function m_(n){return{objectId:n.objectId,placement:Rm(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Rm(n){return n?structuredClone(n):null}function g_(n,e,t){if(!t)return;let i=e.find(o=>o.id===t);if(!i)return;let r=new Map(n.map(o=>[o.id,o])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(o=>o.objectId)]);for(let o of s){let a=r.get(o);a&&(i.epoch&&(a.epoch=i.epoch),i.referencePlane&&(a.referencePlane=i.referencePlane))}for(let o of i.positions){let a=r.get(o.objectId);a&&(o.placement&&(a.placement=Rm(o.placement)),o.inner&&(a.properties.inner={...o.inner}),o.outer&&(a.properties.outer={...o.outer}),o.epoch&&(a.epoch=o.epoch),o.referencePlane&&(a.referencePlane=o.referencePlane))}}function y_(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function v_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Im(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function x_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function b_(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function __(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=w_(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function w_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}function M_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var Pm=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function hc(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"||n.version==="2.0-draft"){if(t==="2.0-draft"){let c=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:cd(n);return Dm(c)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:ur(n);return(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6")&&a.version!==t?ld({...a,version:t,schemaVersion:t}):ld(a)}let r=[],s=n;s.system&&r.push(...S_(s.system));let o=[...s.objects].sort(hd);for(let a of o)r.length>0&&r.push(""),r.push(...A_(a));return r.join(`
3822
- `)}function ld(n){let e=[`schema ${n.version}`,""];n.system&&e.push(...Om(n.system));for(let i of[...n.groups].sort(is))e.push(""),e.push(...km(i));for(let i of[...n.relations].sort(is))e.push(""),e.push(...Bm(i));for(let i of[...n.events].sort(is))e.push(""),e.push(...zm(i));let t=[...n.objects].sort(hd);return t.length>0&&e.at(-1)!==""&&e.push(""),t.forEach((i,r)=>{r>0&&e.push(""),e.push(...Um(i))}),e.join(`
3823
- `)}function Dm(n){let e=n.version==="2.0-draft"?n:{...n,version:"2.0-draft",schemaVersion:"2.0-draft"},t=["schema 2.0-draft",""];e.system&&t.push(...Om(e.system));for(let r of[...e.groups].sort(is))t.push(""),t.push(...km(r));for(let r of[...e.relations].sort(is))t.push(""),t.push(...Bm(r));for(let r of[...e.events].sort(is))t.push(""),t.push(...zm(r));let i=[...e.objects].sort(hd);return i.length>0&&t.at(-1)!==""&&t.push(""),i.forEach((r,s)=>{s>0&&t.push(""),t.push(...Um(r))}),t.join(`
3824
- `)}function S_(n){return E_("system",n.id,n.properties,null,n.info)}function E_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...ud(i),...Fm(t)];for(let c of o)s.push(` ${c}`);let a=Object.entries(r).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[c,l]of a)s.push(` ${c} ${We(l)}`)}return s}function Om(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${We(n.title)}`),n.description&&e.push(` description ${We(n.description)}`),n.epoch&&e.push(` epoch ${We(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${We(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${We(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${We(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${We(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${We(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...I_(t));for(let t of n.annotations)e.push(""),e.push(...C_(t));return e}function A_(n){return Nm(n.type,n.id,n)}function Um(n){return Nm(`object ${n.type}`,n.id,n)}function Nm(n,e,t){let i=[`${n} ${e}`],r=[...ud(t.placement),...Fm(t.properties),...T_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${We(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[c,l]of a)i.push(` ${c} ${We(l)}`)}}return i}function ud(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...Pi("distance",n.distance),...Pi("semiMajor",n.semiMajor),...L_("eccentricity",n.eccentricity),...Pi("period",n.period),...Pi("angle",n.angle),...Pi("inclination",n.inclination),...Pi("phase",n.phase)];case"at":return[`at ${D_(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?dd(n.distance):n.descriptor??""}`.trim()]}}function Fm(n){return Object.keys(n).sort(U_).map(e=>`${e} ${Vm(n[e])}`)}function T_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${We(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${We(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${Vm(t.value)}`);return e}function I_(n){let e=[`viewpoint ${n.id}`,` label ${We(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&P_(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=O_(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${We(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(We).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function C_(n){let e=[`annotation ${n.id}`,` label ${We(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${We(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),e}function km(n){let e=[`group ${n.id}`,` label ${We(n.label)}`];return n.summary&&e.push(` summary ${We(n.summary)}`),n.color&&e.push(` color ${We(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function Bm(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${We(n.from)}`),n.to&&e.push(` to ${We(n.to)}`),n.kind&&e.push(` kind ${We(n.kind)}`),n.label&&e.push(` label ${We(n.label)}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.color&&e.push(` color ${We(n.color)}`),n.hidden&&e.push(" hidden true"),e}function zm(n){let e=[`event ${n.id}`,` kind ${We(n.kind)}`];if(n.label&&e.push(` label ${We(n.label)}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${We(n.timing)}`),n.visibility&&e.push(` visibility ${We(n.visibility)}`),n.epoch&&e.push(` epoch ${We(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${We(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.color&&e.push(` color ${We(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(N_)){e.push(` pose ${t.objectId}`);for(let i of R_(t))e.push(` ${i}`)}}return e}function R_(n){return[...ud(n.placement),...n.epoch?[`epoch ${We(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${We(n.referencePlane)}`]:[],...Pi("inner",n.inner),...Pi("outer",n.outer)]}function P_(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function Vm(n){return Array.isArray(n)?n.map(e=>We(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?We(n):dd(n)}function dd(n){return`${n.value}${n.unit??""}`}function Pi(n,e){return e?[`${n} ${dd(e)}`]:[]}function L_(n,e){return e===void 0?[]:[`${n} ${e}`]}function D_(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function O_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e}function U_(n,e){let t=Pm.indexOf(n),i=Pm.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function hd(n,e){let t=Lm(n.type),i=Lm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function is(n,e){return n.id.localeCompare(e.id)}function N_(n,e){return n.objectId.localeCompare(e.objectId)}function Lm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function We(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var $m=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,F_=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),k_=/^[A-Za-z][A-Za-z0-9+.-]*:/;function rs(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function bo(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function fd(n,e,t){let i=n.match($m);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=an(t);if(s?.unitFamily&&!Za(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function pd(n){let e=n.match($m);return e?{value:Number(e[1]),unit:e[2]??null}:null}function fc(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Li(n,e,t){let i=F_.get(n.toLowerCase());if(i===void 0)throw q.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function Hm(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function B_(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(k_);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function jm(n,e,t){let i=an(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw q.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return Li(xo(e,n,t),n,t);case"number":return fc(xo(e,n,t),n,t);case"unit":return fd(xo(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&B_(r,t),r}}}function md(n,e,t){let i=an(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw q.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function xo(n,e,t){if(n.length!==1)throw q.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Wm=new Set(["star","planet","moon","asteroid","comet"]),z_=332946.0487,V_=1047.3486,pc=1495978707e-1,$_=6371,H_=695700,j_=63241.077,G_=206264.806,W_=206264806;function _o(n,e){let t=[],i=new Map(n.objects.map(a=>[a.id,a])),r=new Set(n.groups.map(a=>a.id)),s=new Set(n.events.map(a=>a.id));n.system||t.push(nt("validate.system.required","Atlas documents must declare exactly one system."));let o=new Map;for(let[a,c]of[["group",n.groups.map(l=>l.id)],["viewpoint",n.system?.viewpoints.map(l=>l.id)??[]],["annotation",n.system?.annotations.map(l=>l.id)??[]],["relation",n.relations.map(l=>l.id)],["event",n.events.map(l=>l.id)],["object",n.objects.map(l=>l.id)]])for(let l of c){let u=o.get(l);u?t.push(nt("validate.id.duplicate",`Duplicate ${a} id "${l}" already used by ${u}.`)):o.set(l,a)}for(let a of n.relations)X_(a,i,t);for(let a of n.system?.viewpoints??[])q_(a,r,s,e,t,i);for(let a of n.objects)Y_(a,n.system,i,r,t);for(let a of n.events)Z_(a,n.system,i,t);return t}function X_(n,e,t){n.from?e.has(n.from)||t.push(nt("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(nt("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(nt("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(nt("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(nt("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function q_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"||i==="2.6"){if(o)for(let a of o.groupIds)e.has(a)||r.push(gt("validate.viewpoint.group.unknown",`Unknown group "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let a of n.events??[])t.has(a)||r.push(gt("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}ew(n.projection,r,`viewpoint.${n.id}.projection`,n.id),tw(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function Y_(n,e,t,i,r){let s=n.placement,o=s?.mode==="orbit"?s:null,a=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let c of n.groups)i.has(c)||r.push(gt("validate.group.unknown",`Unknown group "${c}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(gt("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(gt("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(nt("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(nt("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(gt("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),o.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(gt("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),o.period&&!yd(a?.properties.mass)&&r.push(gt("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let c=t.get(s.target);c?Wm.has(c.type)||r.push(nt("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(nt("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(nt("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),K_(n,t,r)||r.push(nt("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let c=t.get(n.resonance.targetObjectId);c?(n.placement?.mode!=="orbit"||c.placement?.mode!=="orbit"||n.placement.target!==c.placement.target)&&r.push(gt("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(nt("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let c of n.deriveRules??[]){if(c.field!=="period"||c.strategy!=="kepler"){r.push(gt("validate.derive.unsupported",`Unsupported derive rule "${c.field} ${c.strategy}" on "${n.id}".`,n.id,"derive"));continue}let l=Gm(n,a);if(l===null){r.push(gt("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}o?.period||r.push(gd("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${sw(l)}.`,n.id,"derive"))}for(let c of n.validationRules??[]){if(c.rule!=="kepler"){r.push(gt("validate.rule.unsupported",`Unsupported validation rule "${c.rule}" on "${n.id}".`,n.id,"validate"));continue}let l=Xm(o?.period),u=Gm(n,a);if(l===null||u===null)continue;let d=rw(n,"period");Math.abs(l-u)>d&&r.push(nt("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function Z_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(nt("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(gt("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(gt("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(nt("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(nt("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let o=new Set;for(let l of n.participantObjectIds){if(s.add(l),o.has(l)){i.push(gt("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${l}".`,void 0,`${r}.participants`));continue}o.add(l),t.has(l)||i.push(nt("validate.event.participants.unknown",`Unknown event participant "${l}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(gt("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(gt("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(gt("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let a=new Set;for(let l of n.positions){let u=`${r}.pose.${l.objectId}`;if(a.has(l.objectId)){i.push(nt("validate.event.pose.duplicate",`Event "${n.id}" defines "${l.objectId}" more than once in positions.`,void 0,u));continue}a.add(l.objectId);let d=t.get(l.objectId);if(!d){i.push(nt("validate.event.pose.object.unknown",`Unknown event pose object "${l.objectId}" on "${n.id}".`,void 0,u));continue}s.has(l.objectId)||i.push(gt("validate.event.pose.unreferenced",`Event pose "${l.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),J_(l,d,n,e,t,i,u,n.id)}let c=[...s].filter(l=>!a.has(l));n.positions.length>0&&c.length>0&&i.push(gt("validate.event.positions.partial",`Event "${n.id}" leaves ${c.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function J_(n,e,t,i,r,s,o,a){let c=n.placement;if(!c){s.push(nt("validate.event.pose.placement.required",`Event "${a}" pose "${n.objectId}" is missing a placement mode.`,void 0,o));return}if(c.mode==="orbit"){r.has(c.target)||s.push(nt("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.orbit`)),c.distance&&c.semiMajor&&s.push(nt("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),c.phase&&!nw(i,e,t,n)&&s.push(gt("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),c.inclination&&!iw(i,e,t,n)&&s.push(gt("validate.event.pose.inclination.referencePlaneMissing",`Event "${a}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${o}.inclination`)),c.period&&!yd(r.get(c.target)?.properties.mass)&&s.push(gt("validate.event.pose.period.massMissing",`Event "${a}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${o}.period`));return}if(c.mode==="surface"){let l=r.get(c.target);l?Wm.has(l.type)||s.push(nt("validate.event.pose.surface.target.invalid",`Event surface target "${c.target}" on "${a}:${n.objectId}" is not surface-capable.`,void 0,`${o}.surface`)):s.push(nt("validate.event.pose.surface.target.unknown",`Unknown event surface target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.surface`));return}if(c.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(nt("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${a}:${n.objectId}".`,void 0,`${o}.at`));let l=c.reference;l.kind==="named"&&!r.has(l.name)?s.push(nt("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="anchor"&&!r.has(l.objectId)?s.push(nt("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${l.objectId}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="lagrange"&&(r.has(l.primary)?l.secondary&&!r.has(l.secondary)&&s.push(nt("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${l.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(nt("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${l.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function K_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(nt("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(nt("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(nt("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function Gm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=Q_(t.semiMajor??t.distance),r=yd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function Q_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/pc;case"m":return n.value/(pc*1e3);case"ly":return n.value*j_;case"pc":return n.value*G_;case"kpc":return n.value*W_;case"re":return n.value*$_/pc;case"sol":return n.value*H_/pc;default:return null}}function yd(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/z_;case"mj":return e.value/V_;default:return null}}function Xm(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function ew(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(nt("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function tw(n,e,t,i,r,s,o,a,c){if(!n)return;let l=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(nt("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${l}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(gt("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${l}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(gt("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,l)),e==="isometric"&&n.elevation!==null&&i.push(gd("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${l}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(gt("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${l}.azimuth`)),s!==null&&c.has(s)||o!==null&&c.has(o)||a||i.push(gd("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,l))}function nw(n,e,t,i){return Di(i?.epoch)??Di(t?.epoch)??Di(e.epoch)??Di(n?.epoch)??null}function iw(n,e,t,i){return Di(i?.referencePlane)??Di(t?.referencePlane)??Di(e.referencePlane)??Di(n?.referencePlane)??null}function Di(n){return typeof n=="string"&&n.trim()?n.trim():null}function rw(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Xm(t)??0:0}function sw(n){return`${Math.round(n*100)/100}d`}function nt(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function gt(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function gd(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var ow=new Set(["climate","habitability","settlement"]),gc=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=an(n);e&&gc.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])gc.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var aw=new Set(gc.keys()),Ym=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function vd(n){return cw(n)}function cw(n,e){let t=qw(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,c=null,l=[],u=[],d=[],h=[],f=new Map,p=!1,y=!1,g=new Set,m=new Set,x=new Set,v=new Set,w=new Set;for(let S=0;S<i.length;S++){let P=i[S],k=S+1;if(!P.trim())continue;let O=Ja(P),H=ao(P.slice(O),{line:k,columnOffset:O});if(H.length!==0){if(!s){o=lw(H,k),s=!0,t.comments.length>0&&yc(o,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${o}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(O===0){c=uw(H,k,o,r,a,l,u,d,h,f,g,m,x,v,w,{sawDefaults:p,sawAtlas:y}),c.kind==="system"?a=c.system:c.kind==="defaults"?p=!0:c.kind==="atlas"&&(y=!0);continue}if(!c)throw new q("Indented line without parent atlas section",k,O+1);vw(c,O,H,k)}}if(!s)throw new q('Missing required atlas schema header "schema 2.0"');let N=l.map(S=>Fw(S,o,r)),C=h.map(S=>kw(S,f.get(S.id)??[])),R=e??(o==="2.0-draft"?"2.0":o),F={format:"worldorbit",sourceVersion:"1.0",theme:null,system:a,groups:u,relations:d,events:C,objects:N,diagnostics:r};if(R==="2.0-draft"){let S={...F,version:"2.0-draft",schemaVersion:"2.0-draft"};return S.diagnostics.push(..._o(S,o)),S}let A={...F,version:R,schemaVersion:R};return o==="2.0-draft"&&A.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),A.diagnostics.push(..._o(A,o)),A}function lw(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5","2.6"].includes(n[1].value.toLowerCase()))throw new q('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", "schema 2.6", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.6"?"2.6":t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function uw(n,e,t,i,r,s,o,a,c,l,u,d,h,f,p,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new q('Atlas section "system" may only appear once',e,n[0].column);return dw(n,e,t,i);case"defaults":if(!r)throw new q('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new q('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new q('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new q('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new q('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return hw(n,e,r,u,t,i);case"annotation":if(!r)throw new q('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return fw(n,e,r,d);case"group":return bn(t,i,"group",{line:e,column:n[0].column}),pw(n,e,o,h);case"relation":return bn(t,i,"relation",{line:e,column:n[0].column}),mw(n,e,a,f);case"event":return bn(t,i,"event",{line:e,column:n[0].column}),gw(n,e,c,l,p,t,i);case"object":return yw(n,e,t,i,s);default:throw new q(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function dw(n,e,t,i){if(n.length!==2)throw new q("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function hw(n,e,t,i,r,s){if(n.length!==2)throw new q("Invalid viewpoint declaration",e,n[0]?.column??1);let o=rs(n[1].value);if(!o)throw new q("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new q(`Duplicate viewpoint id "${o}"`,e,n[1].column);let a={id:o,label:bo(o),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(a),i.add(o),{kind:"viewpoint",viewpoint:a,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function fw(n,e,t,i){if(n.length!==2)throw new q("Invalid annotation declaration",e,n[0]?.column??1);let r=rs(n[1].value);if(!r)throw new q("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:bo(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function pw(n,e,t,i){if(n.length!==2)throw new q("Invalid group declaration",e,n[0]?.column??1);let r=rs(n[1].value);if(!r)throw new q("Group id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:bo(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function mw(n,e,t,i){if(n.length!==2)throw new q("Invalid relation declaration",e,n[0]?.column??1);let r=rs(n[1].value);if(!r)throw new q("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function gw(n,e,t,i,r,s,o){if(n.length!==2)throw new q("Invalid event declaration",e,n[0]?.column??1);let a=rs(n[1].value);if(!a)throw new q("Event id must not be empty",e,n[1].column);if(r.has(a))throw new q(`Duplicate event id "${a}"`,e,n[1].column);let c={id:a,kind:"",label:bo(a),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},l=[];return t.push(c),i.set(a,l),r.add(a),{kind:"event",event:c,sourceSchemaVersion:s,diagnostics:o,seenFields:new Set,rawPoses:l,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function yw(n,e,t,i,r){if(n.length<3)throw new q("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!Ya.has(a)||a==="system")throw new q(`Unknown object type "${s.value}"`,e,s.column);let c={objectType:a,id:o.value,fields:Uw(n.slice(3),e,a,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(c),{kind:"object",objectNode:c,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function vw(n,e,t,i){switch(n.kind){case"system":xw(n,t,i);return;case"defaults":bw(n,t,i);return;case"atlas":_w(n,e,t,i);return;case"viewpoint":ww(n,e,t,i);return;case"annotation":Ew(n,t,i);return;case"group":Aw(n,t,i);return;case"relation":Tw(n,t,i);return;case"event":Iw(n,e,t,i);return;case"object":Rw(n,e,t,i);return}}function xw(n,e,t){let i=ti(e,n.seenFields,t),r=lt(e,t);switch(i){case"title":n.system.title=r;return;case"description":bn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":bn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":bn(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new q(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function bw(n,e,t){let i=ti(e,n.seenFields,t),r=lt(e,t);switch(i){case"view":Jm(r)&&dr(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Zm(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=Km(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new q(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function _w(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Qm(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new q(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new q(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function ww(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){Mw(n,t,i);return}if(n.inFilter){Sw(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(dr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new q('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??bd();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new q('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=ti(t,n.seenFields,i),s=lt(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":Jm(s)&&dr(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Zm(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Km(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=xd(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=Ui(s,i,t[0].column,"rotation");return;case"camera":dr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=Ow(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=Lw(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":bn(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=kn(t.slice(1),i,"events");return;default:throw new q(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function Mw(n,e,t){let i=ti(e,n.seenCameraFields,t),r=lt(e,t),s=n.viewpoint.camera??bd();switch(i){case"azimuth":s.azimuth=Ui(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=Ui(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=Ui(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=xd(r,t,e[0].column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function Sw(n,e,t){let i=ti(e,n.seenFilterFields,t),r=n.viewpoint.filter??Dw();switch(i){case"query":r.query=lt(e,t);break;case"objecttypes":r.objectTypes=Pw(e.slice(1),t);break;case"tags":r.tags=kn(e.slice(1),t,"tags");break;case"groups":r.groupIds=kn(e.slice(1),t,"groups");break;default:throw new q(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function Ew(n,e,t){switch(ti(e,n.seenFields,t)){case"label":n.annotation.label=lt(e,t);return;case"target":n.annotation.targetObjectId=lt(e,t);return;case"body":n.annotation.body=lt(e,t);return;case"tags":n.annotation.tags=kn(e.slice(1),t,"tags");return;default:throw new q(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function Aw(n,e,t){switch(ti(e,n.seenFields,t)){case"label":n.group.label=lt(e,t);return;case"summary":n.group.summary=lt(e,t);return;case"color":n.group.color=lt(e,t);return;case"tags":n.group.tags=kn(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=Li(lt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function Tw(n,e,t){switch(ti(e,n.seenFields,t)){case"from":n.relation.from=lt(e,t);return;case"to":n.relation.to=lt(e,t);return;case"kind":n.relation.kind=lt(e,t);return;case"label":n.relation.label=lt(e,t);return;case"summary":n.relation.summary=lt(e,t);return;case"tags":n.relation.tags=kn(e.slice(1),t,"tags");return;case"color":n.relation.color=lt(e,t);return;case"hidden":n.relation.hidden=Li(lt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function Iw(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&dr(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(Cw(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new q(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new q("Event pose object id must not be empty",i,t[1].column);let o={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(o),n.activePose=o,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new q('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(ti(t,n.seenFields,i)){case"kind":n.event.kind=lt(t,i);return;case"label":n.event.label=lt(t,i);return;case"summary":n.event.summary=lt(t,i);return;case"target":n.event.targetObjectId=lt(t,i);return;case"participants":n.event.participantObjectIds=kn(t.slice(1),i,"participants");return;case"timing":n.event.timing=lt(t,i);return;case"visibility":n.event.visibility=lt(t,i);return;case"epoch":dr(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=lt(t,i);return;case"referenceplane":dr(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=lt(t,i);return;case"tags":n.event.tags=kn(t.slice(1),i,"tags");return;case"color":n.event.color=lt(t,i);return;case"hidden":n.event.hidden=Li(lt(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new q(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function Cw(n,e,t){if(n.length<2)throw new q("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Ym.has(i))throw new q(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new q(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function Rw(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||ow.has(r)){r!=="info"&&bn(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Qm(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new q(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,o=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(o.has(r.key))throw new q(`Duplicate ${s} key "${r.key}"`,i,t[0].column);o.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(Nw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function ti(n,e,t){if(n.length<2)throw new q("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new q(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function lt(n,e){if(n.length<2)throw new q("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function Pw(n,e){return kn(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Lw(n,e,t,i){let r={};for(let s of kn(n,e,"layers")){let o=!s.startsWith("-")&&!s.startsWith("!"),a=s.replace(/^[-!]+/,"").toLowerCase();if(a==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}(a==="background"||a==="guides"||a==="orbits-back"||a==="orbits-front"||a==="relations"||a==="events"||a==="objects"||a==="labels"||a==="metadata")&&(a==="events"&&t&&i&&bn(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function kn(n,e,t){if(n.length===0)throw new q(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new q(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function Zm(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new q(`Unknown projection "${n}"`,e,t);return i}function Jm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Km(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new q(`Unknown render preset "${n}"`,e,t)}function xd(n,e,t,i){let r=Ui(n,e,t,i);if(r<=0)throw new q(`Field "${i}" must be greater than zero`,e,t);return r}function Ui(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new q(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function Dw(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function bd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Ow(n,e,t){if(n.length===0||n.length%2!==0)throw new q('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:bd(),r=new Set;for(let s=0;s<n.length;s+=2){let o=n[s],a=n[s+1],c=o.value.toLowerCase();if(r.has(c))throw new q(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(c);let l=a.value;switch(c){case"azimuth":i.azimuth=Ui(l,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=Ui(l,e,o.column,"camera.elevation");break;case"roll":i.roll=Ui(l,e,o.column,"camera.roll");break;case"distance":i.distance=xd(l,e,o.column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function Uw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],c=wo(a.value);if(!c)throw new q(`Unknown field "${a.value}"`,e,a.column);c.version==="2.1"&&bn(i,r,a.value,{line:e,column:a.column}),o++;let l=[];if(c.inlineMode==="single"){let u=n[o];u&&(l.push(u),o++)}else if(c.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[o];if(!d)break;l.push(d),o++}else for(;o<n.length&&!aw.has(n[o].value);)l.push(n[o]),o++;if(l.length===0)throw new q(`Missing value for field "${a.value}"`,e,a.column);s.push({type:"field",key:a.value,values:l.map(u=>u.value),location:{line:e,column:a.column}})}return ig(s,t),s}function Nw(n,e,t,i,r){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);let s=wo(n[0].value);if(!s)throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&bn(i,r,n[0].value,{line:e,column:n[0].column});let o={type:"field",key:n[0].value,values:n.slice(1).map(a=>a.value),location:{line:e,column:n[0].column}};return ig([o],t),o}function Qm(n,e,t){if(n.length<2)throw new q(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function Fw(n,e,t){let i=eg(n.fields),r=tg(i),s=zw(n.objectType,i),o=Ww(i.get("groups")?.[0]),a=mc(i.get("epoch")?.[0]),c=mc(i.get("referencePlane")?.[0]),l=i.has("tidalLock")?Li(Tn(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Hw(i.get("resonance")[0]):void 0,d=$w(i),h=i.get("derive")?.map(v=>jw(v)),f=i.get("validate")?.map(v=>({rule:Tn(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>Gw(v)),g=Vw(n.typedBlockEntries),m=ng(n.infoEntries,"info"),x={type:n.objectType,id:n.id,properties:s,placement:r,info:m};return o.length>0&&(x.groups=o),a&&(x.epoch=a),c&&(x.referencePlane=c),l!==void 0&&(x.tidalLock=l),u&&(x.resonance=u),d&&(x.renderHints=d),h?.length&&(x.deriveRules=h),f?.length&&(x.validationRules=f),p?.length&&(x.lockedFields=p),y?.length&&(x.tolerances=y),g&&Object.keys(g).length>0&&(x.typedBlocks=g),yc(e,"2.1")&&(x.groups||x.epoch||x.referencePlane||x.tidalLock!==void 0||x.resonance||x.renderHints||x.deriveRules?.length||x.validationRules?.length||x.lockedFields?.length||x.tolerances?.length||x.typedBlocks)&&bn(e,t,n.id,n.location),x}function kw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>Bw(t))}}function Bw(n){let e=eg(n.fields,"event-pose"),t=tg(e);return{objectId:n.objectId,placement:t,inner:Oi(e.get("inner")?.[0],"inner"),outer:Oi(e.get("outer")?.[0],"outer"),epoch:mc(e.get("epoch")?.[0]),referencePlane:mc(e.get("referencePlane")?.[0])}}function eg(n,e="object"){let t=new Map;for(let i of n){let r=wo(i.key);if(!r&&!Ym.has(i.key))throw q.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw q.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function tg(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let o=e??t??i??r;throw q.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:Tn(e),distance:Oi(n.get("distance")?.[0],"distance"),semiMajor:Oi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:Xw(n.get("eccentricity")?.[0],"eccentricity"),period:Oi(n.get("period")?.[0],"period"),angle:Oi(n.get("angle")?.[0],"angle"),inclination:Oi(n.get("inclination")?.[0],"inclination"),phase:Oi(n.get("phase")?.[0],"phase")};if(t){let o=Tn(t);return{mode:"at",target:o,reference:Hm(o,t.location)}}if(i)return{mode:"surface",target:Tn(i)};if(r){let o=Tn(r),a=pd(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function zw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=wo(i);!s||!o?.legacySchema||o.legacySchema.placement||(md(i,n,s.location),t[i]=jm(i,s.values,s.location))}return t}function ng(n,e){let t={};for(let i of n){if(i.key in t)throw q.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function Vw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=ng(i,t))}return e}function $w(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=Li(Tn(t),"renderLabel",t.location)),i&&(e.renderOrbit=Li(Tn(i),"renderOrbit",i.location)),r&&(e.renderPriority=fc(Tn(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Hw(n){if(n.values.length!==2)throw q.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw q.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function jw(n){if(n.values.length!==2)throw q.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function Gw(n){if(n.values.length!==2)throw q.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=pd(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function Ww(n){return n?[...new Set(n.values)]:[]}function mc(n){return n&&n.values.join(" ").trim()||null}function Oi(n,e){return n?fd(Tn(n),n.location,e):void 0}function Xw(n,e){return n?fc(Tn(n),e,n.location):void 0}function Tn(n){return xo(n.values,n.key,n.location)}function wo(n){return gc.get(n)}function ig(n,e){for(let t of n){let i=wo(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){md(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function bn(n,e,t,i){yc(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function dr(n,e,t,i){yc(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function yc(n,e){return qm(n)<qm(e)}function qm(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3;case"2.6":return 4;default:return 5}}function qw(n){let e=[...n],t=[],i=!1,r=!1,s=null,o=1,a=1;for(let c=0;c<e.length;c++){let l=e[c],u=e[c+1];if(r){if(l==="*"&&u==="/"){e[c]=" ",e[c+1]=" ",r=!1,s=null,c++,a+=2;continue}l!==`
3821
+ }`,mf=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){let r=new Ct,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}render(e,t){if(this.texture!==null){if(this.mesh===null){let i=t.cameras[0].viewport,r=new pn({vertexShader:mI,fragmentShader:gI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new St(new Ws(20,20),r)}e.render(this.mesh,t)}}reset(){this.texture=null,this.mesh=null}},gf=class extends Un{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,d=null,h=null,f=null,p=null,y=new mf,g=t.getContextAttributes(),m=null,x=null,v=[],w=[],N=new se,C=null,R=new Rt;R.layers.enable(1),R.viewport=new ht;let F=new Rt;F.layers.enable(2),F.viewport=new ht;let A=[R,F],S=new Pl;S.layers.enable(1),S.layers.enable(2);let P=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getTargetRaySpace()},this.getControllerGrip=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getGripSpace()},this.getHand=function(Y){let me=v[Y];return me===void 0&&(me=new jo,v[Y]=me),me.getHandSpace()};function O(Y){let me=w.indexOf(Y.inputSource);if(me===-1)return;let te=v[me];te!==void 0&&(te.update(Y.inputSource,Y.frame,l||o),te.dispatchEvent({type:Y.type,data:Y.inputSource}))}function H(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",H),r.removeEventListener("inputsourceschange",W);for(let Y=0;Y<v.length;Y++){let me=w[Y];me!==null&&(w[Y]=null,v[Y].disconnect(me))}P=null,k=null,y.reset(),e.setRenderTarget(m),f=null,h=null,d=null,r=null,x=null,$e.stop(),i.isPresenting=!1,e.setPixelRatio(C),e.setSize(N.width,N.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",H),r.addEventListener("inputsourceschange",W),g.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(N),r.renderState.layers===void 0){let me={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(r,t,me),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),x=new hn(f.framebufferWidth,f.framebufferHeight,{format:un,type:_i,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let me=null,te=null,ue=null;g.depth&&(ue=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,me=g.stencil?zs:Ur,te=g.stencil?Qs:Fr);let Pe={colorFormat:t.RGBA8,depthFormat:ue,scaleFactor:s};d=new XRWebGLBinding(r,t),h=d.createProjectionLayer(Pe),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),x=new hn(h.textureWidth,h.textureHeight,{format:un,type:_i,depthTexture:new da(h.textureWidth,h.textureHeight,te,void 0,void 0,void 0,void 0,void 0,void 0,me),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),$e.setContext(r),$e.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function W(Y){for(let me=0;me<Y.removed.length;me++){let te=Y.removed[me],ue=w.indexOf(te);ue>=0&&(w[ue]=null,v[ue].disconnect(te))}for(let me=0;me<Y.added.length;me++){let te=Y.added[me],ue=w.indexOf(te);if(ue===-1){for(let _e=0;_e<v.length;_e++)if(_e>=w.length){w.push(te),ue=_e;break}else if(w[_e]===null){w[_e]=te,ue=_e;break}if(ue===-1)break}let Pe=v[ue];Pe&&Pe.connect(te)}}let J=new D,ae=new D;function B(Y,me,te){J.setFromMatrixPosition(me.matrixWorld),ae.setFromMatrixPosition(te.matrixWorld);let ue=J.distanceTo(ae),Pe=me.projectionMatrix.elements,_e=te.projectionMatrix.elements,z=Pe[14]/(Pe[10]-1),Be=Pe[14]/(Pe[10]+1),X=(Pe[9]+1)/Pe[5],de=(Pe[9]-1)/Pe[5],Z=(Pe[8]-1)/Pe[0],he=(_e[8]+1)/_e[0],ie=z*Z,ye=z*he,Te=ue/(-Z+he),U=Te*-Z;me.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(U),Y.translateZ(Te),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert();let T=z+Te,G=Be+Te,ee=ie-U,oe=ye+(ue-U),re=X*Be/G*T,Ue=de*Be/G*T;Y.projectionMatrix.makePerspective(ee,oe,re,Ue,T,G),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}function ne(Y,me){me===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(me.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;y.texture!==null&&(Y.near=y.depthNear,Y.far=y.depthFar),S.near=F.near=R.near=Y.near,S.far=F.far=R.far=Y.far,(P!==S.near||k!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),P=S.near,k=S.far,R.near=P,R.far=k,F.near=P,F.far=k,R.updateProjectionMatrix(),F.updateProjectionMatrix(),Y.updateProjectionMatrix());let me=Y.parent,te=S.cameras;ne(S,me);for(let ue=0;ue<te.length;ue++)ne(te[ue],me);te.length===2?B(S,R,F):S.projectionMatrix.copy(R.projectionMatrix),ce(Y,S,me)};function ce(Y,me,te){te===null?Y.matrix.copy(me.matrixWorld):(Y.matrix.copy(te.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(me.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(me.projectionMatrix),Y.projectionMatrixInverse.copy(me.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=Vs*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(h===null&&f===null))return c},this.setFoveation=function(Y){c=Y,h!==null&&(h.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return y.texture!==null};let Me=null;function fe(Y,me){if(u=me.getViewerPose(l||o),p=me,u!==null){let te=u.views;f!==null&&(e.setRenderTargetFramebuffer(x,f.framebuffer),e.setRenderTarget(x));let ue=!1;te.length!==S.cameras.length&&(S.cameras.length=0,ue=!0);for(let _e=0;_e<te.length;_e++){let z=te[_e],Be=null;if(f!==null)Be=f.getViewport(z);else{let de=d.getViewSubImage(h,z);Be=de.viewport,_e===0&&(e.setRenderTargetTextures(x,de.colorTexture,h.ignoreDepthValues?void 0:de.depthStencilTexture),e.setRenderTarget(x))}let X=A[_e];X===void 0&&(X=new Rt,X.layers.enable(_e),X.viewport=new ht,A[_e]=X),X.matrix.fromArray(z.transform.matrix),X.matrix.decompose(X.position,X.quaternion,X.scale),X.projectionMatrix.fromArray(z.projectionMatrix),X.projectionMatrixInverse.copy(X.projectionMatrix).invert(),X.viewport.set(Be.x,Be.y,Be.width,Be.height),_e===0&&(S.matrix.copy(X.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),ue===!0&&S.cameras.push(X)}let Pe=r.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")){let _e=d.getDepthInformation(te[0]);_e&&_e.isValid&&_e.texture&&y.init(e,_e,r.renderState)}}for(let te=0;te<v.length;te++){let ue=w[te],Pe=v[te];ue!==null&&Pe!==void 0&&Pe.update(ue,me,l||o)}y.render(e,S),Me&&Me(Y,me),me.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:me}),p=null}let $e=new mv;$e.setAnimationLoop(fe),this.setAnimationLoop=function(Y){Me=Y},this.dispose=function(){}}},_r=new fn,yI=new Ve;yf=class{constructor(e={}){let{canvas:t=uv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let h;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");h=i.getContextAttributes().alpha}else h=o;let f=new Uint32Array(4),p=new Int32Array(4),y=null,g=null,m=[],x=[];this.domElement=t,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._outputColorSpace=Mn,this._useLegacyLights=!1,this.toneMapping=yi,this.toneMappingExposure=1;let v=this,w=!1,N=0,C=0,R=null,F=-1,A=null,S=new ht,P=new ht,k=null,O=new Ie(0),H=0,W=t.width,J=t.height,ae=1,B=null,ne=null,ce=new ht(0,0,W,J),Me=new ht(0,0,W,J),fe=!1,$e=new zr,Y=!1,me=!1,te=new Ve,ue=new D,Pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return R===null?ae:1}let z=i;function Be(b,_){return t.getContext(b,_)}try{let b={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r164"),t.addEventListener("webglcontextlost",V,!1),t.addEventListener("webglcontextrestored",le,!1),t.addEventListener("webglcontextcreationerror",K,!1),z===null){let _="webgl2";if(z=Be(_,b),z===null)throw Be(_)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(b){throw console.error("THREE.WebGLRenderer: "+b.message),b}let X,de,Z,he,ie,ye,Te,U,T,G,ee,oe,re,Ue,ve,xe,He,pe,Oe,qe,Ne,Ce,Fe,Qe;function pt(){X=new BA(z),X.init(),Ce=new _v(z,X),de=new DA(z,X,e,Ce),Z=new hI(z),he=new $A(z),ie=new eI,ye=new fI(z,X,Z,ie,de,Ce,he),Te=new UA(v),U=new kA(v),T=new YS(z),Fe=new PA(z,T),G=new zA(z,T,he,Fe),ee=new jA(z,G,T,he),Oe=new HA(z,de,ye),xe=new OA(ie),oe=new QT(v,Te,U,X,de,Fe,xe),re=new vI(v,ie),Ue=new nI,ve=new cI(X),pe=new RA(v,Te,U,Z,ee,h,c),He=new dI(v,ee,de),Qe=new xI(z,he,de,Z),qe=new LA(z,X,he),Ne=new VA(z,X,he),he.programs=oe.programs,v.capabilities=de,v.extensions=X,v.properties=ie,v.renderLists=Ue,v.shadowMap=He,v.state=Z,v.info=he}pt();let je=new gf(v,z);this.xr=je,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){let b=X.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=X.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(b){b!==void 0&&(ae=b,this.setSize(W,J,!1))},this.getSize=function(b){return b.set(W,J)},this.setSize=function(b,_,M=!0){if(je.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=b,J=_,t.width=Math.floor(b*ae),t.height=Math.floor(_*ae),M===!0&&(t.style.width=b+"px",t.style.height=_+"px"),this.setViewport(0,0,b,_)},this.getDrawingBufferSize=function(b){return b.set(W*ae,J*ae).floor()},this.setDrawingBufferSize=function(b,_,M){W=b,J=_,ae=M,t.width=Math.floor(b*M),t.height=Math.floor(_*M),this.setViewport(0,0,b,_)},this.getCurrentViewport=function(b){return b.copy(S)},this.getViewport=function(b){return b.copy(ce)},this.setViewport=function(b,_,M,E){b.isVector4?ce.set(b.x,b.y,b.z,b.w):ce.set(b,_,M,E),Z.viewport(S.copy(ce).multiplyScalar(ae).round())},this.getScissor=function(b){return b.copy(Me)},this.setScissor=function(b,_,M,E){b.isVector4?Me.set(b.x,b.y,b.z,b.w):Me.set(b,_,M,E),Z.scissor(P.copy(Me).multiplyScalar(ae).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(b){Z.setScissorTest(fe=b)},this.setOpaqueSort=function(b){B=b},this.setTransparentSort=function(b){ne=b},this.getClearColor=function(b){return b.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(b=!0,_=!0,M=!0){let E=0;if(b){let I=!1;if(R!==null){let j=R.texture.format;I=j===Tp||j===Ap||j===Ep}if(I){let j=R.texture.type,Q=j===_i||j===Fr||j===bp||j===Qs||j===wp||j===Mp,ge=pe.getClearColor(),Se=pe.getClearAlpha(),Le=ge.r,Ge=ge.g,ze=ge.b;Q?(f[0]=Le,f[1]=Ge,f[2]=ze,f[3]=Se,z.clearBufferuiv(z.COLOR,0,f)):(p[0]=Le,p[1]=Ge,p[2]=ze,p[3]=Se,z.clearBufferiv(z.COLOR,0,p))}else E|=z.COLOR_BUFFER_BIT}_&&(E|=z.DEPTH_BUFFER_BIT),M&&(E|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(E)},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.dispose=function(){t.removeEventListener("webglcontextlost",V,!1),t.removeEventListener("webglcontextrestored",le,!1),t.removeEventListener("webglcontextcreationerror",K,!1),Ue.dispose(),ve.dispose(),ie.dispose(),Te.dispose(),U.dispose(),ee.dispose(),Fe.dispose(),Qe.dispose(),oe.dispose(),je.dispose(),je.removeEventListener("sessionstart",rt),je.removeEventListener("sessionend",$t),Et.stop()};function V(b){b.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),w=!0}function le(){console.log("THREE.WebGLRenderer: Context Restored."),w=!1;let b=he.autoReset,_=He.enabled,M=He.autoUpdate,E=He.needsUpdate,I=He.type;pt(),he.autoReset=b,He.enabled=_,He.autoUpdate=M,He.needsUpdate=E,He.type=I}function K(b){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function we(b){let _=b.target;_.removeEventListener("dispose",we),Ae(_)}function Ae(b){Re(b),ie.remove(b)}function Re(b){let _=ie.get(b).programs;_!==void 0&&(_.forEach(function(M){oe.releaseProgram(M)}),b.isShaderMaterial&&oe.releaseShaderCache(b))}this.renderBufferDirect=function(b,_,M,E,I,j){_===null&&(_=Pe);let Q=I.isMesh&&I.matrixWorld.determinant()<0,ge=ar(b,_,M,E,I);Z.setMaterial(E,Q);let Se=M.index,Le=1;if(E.wireframe===!0){if(Se=G.getWireframeAttribute(M),Se===void 0)return;Le=2}let Ge=M.drawRange,ze=M.attributes.position,mt=Ge.start*Le,Ht=(Ge.start+Ge.count)*Le;j!==null&&(mt=Math.max(mt,j.start*Le),Ht=Math.min(Ht,(j.start+j.count)*Le)),Se!==null?(mt=Math.max(mt,0),Ht=Math.min(Ht,Se.count)):ze!=null&&(mt=Math.max(mt,0),Ht=Math.min(Ht,ze.count));let on=Ht-mt;if(on<0||on===1/0)return;Fe.setup(I,E,ge,M,Se);let ti,at=qe;if(Se!==null&&(ti=T.get(Se),at=Ne,at.setIndex(ti)),I.isMesh)E.wireframe===!0?(Z.setLineWidth(E.wireframeLinewidth*_e()),at.setMode(z.LINES)):at.setMode(z.TRIANGLES);else if(I.isLine){let Ye=E.linewidth;Ye===void 0&&(Ye=1),Z.setLineWidth(Ye*_e()),I.isLineSegments?at.setMode(z.LINES):I.isLineLoop?at.setMode(z.LINE_LOOP):at.setMode(z.LINE_STRIP)}else I.isPoints?at.setMode(z.POINTS):I.isSprite&&at.setMode(z.TRIANGLES);if(I.isBatchedMesh)I._multiDrawInstances!==null?at.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances):at.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else if(I.isInstancedMesh)at.renderInstances(mt,on,I.count);else if(M.isInstancedBufferGeometry){let Ye=M._maxInstanceCount!==void 0?M._maxInstanceCount:1/0,so=Math.min(M.instanceCount,Ye);at.renderInstances(mt,on,so)}else at.render(mt,on)};function tt(b,_,M){b.transparent===!0&&b.side===Hn&&b.forceSinglePass===!1?(b.side=nn,b.needsUpdate=!0,kn(b,_,M),b.side=xi,b.needsUpdate=!0,kn(b,_,M),b.side=Hn):kn(b,_,M)}this.compile=function(b,_,M=null){M===null&&(M=b),g=ve.get(M),g.init(_),x.push(g),M.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),b!==M&&b.traverseVisible(function(I){I.isLight&&I.layers.test(_.layers)&&(g.pushLight(I),I.castShadow&&g.pushShadow(I))}),g.setupLights(v._useLegacyLights);let E=new Set;return b.traverse(function(I){let j=I.material;if(j)if(Array.isArray(j))for(let Q=0;Q<j.length;Q++){let ge=j[Q];tt(ge,M,I),E.add(ge)}else tt(j,M,I),E.add(j)}),x.pop(),g=null,E},this.compileAsync=function(b,_,M=null){let E=this.compile(b,_,M);return new Promise(I=>{function j(){if(E.forEach(function(Q){ie.get(Q).currentProgram.isReady()&&E.delete(Q)}),E.size===0){I(b);return}setTimeout(j,10)}X.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let ft=null;function vt(b){ft&&ft(b)}function rt(){Et.stop()}function $t(){Et.start()}let Et=new mv;Et.setAnimationLoop(vt),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(b){ft=b,je.setAnimationLoop(b),b===null?Et.stop():Et.start()},je.addEventListener("sessionstart",rt),je.addEventListener("sessionend",$t),this.render=function(b,_){if(_!==void 0&&_.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(w===!0)return;b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(_),_=je.getCamera()),b.isScene===!0&&b.onBeforeRender(v,b,_,R),g=ve.get(b,x.length),g.init(_),x.push(g),te.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),$e.setFromProjectionMatrix(te),me=this.localClippingEnabled,Y=xe.init(this.clippingPlanes,me),y=Ue.get(b,m.length),y.init(),m.push(y),Kr(b,_,0,v.sortObjects),y.finish(),v.sortObjects===!0&&y.sort(B,ne);let M=je.enabled===!1||je.isPresenting===!1||je.hasDepthSensing()===!1;M&&pe.addToRenderList(y,b),this.info.render.frame++,Y===!0&&xe.beginShadows();let E=g.state.shadowsArray;He.render(E,b,_),Y===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset();let I=y.opaque,j=y.transmissive;if(g.setupLights(v._useLegacyLights),_.isArrayCamera){let Q=_.cameras;if(j.length>0)for(let ge=0,Se=Q.length;ge<Se;ge++){let Le=Q[ge];Fn(I,j,b,Le)}M&&pe.render(b);for(let ge=0,Se=Q.length;ge<Se;ge++){let Le=Q[ge];rr(y,b,Le,Le.viewport)}}else j.length>0&&Fn(I,j,b,_),M&&pe.render(b),rr(y,b,_);R!==null&&(ye.updateMultisampleRenderTarget(R),ye.updateRenderTargetMipmap(R)),b.isScene===!0&&b.onAfterRender(v,b,_),Fe.resetDefaultState(),F=-1,A=null,x.pop(),x.length>0?(g=x[x.length-1],Y===!0&&xe.setGlobalState(v.clippingPlanes,g.state.camera)):g=null,m.pop(),m.length>0?y=m[m.length-1]:y=null};function Kr(b,_,M,E){if(b.visible===!1)return;if(b.layers.test(_.layers)){if(b.isGroup)M=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(_);else if(b.isLight)g.pushLight(b),b.castShadow&&g.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||$e.intersectsSprite(b)){E&&ue.setFromMatrixPosition(b.matrixWorld).applyMatrix4(te);let Q=ee.update(b),ge=b.material;ge.visible&&y.push(b,Q,ge,M,ue.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(!b.frustumCulled||$e.intersectsObject(b))){let Q=ee.update(b),ge=b.material;if(E&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),ue.copy(b.boundingSphere.center)):(Q.boundingSphere===null&&Q.computeBoundingSphere(),ue.copy(Q.boundingSphere.center)),ue.applyMatrix4(b.matrixWorld).applyMatrix4(te)),Array.isArray(ge)){let Se=Q.groups;for(let Le=0,Ge=Se.length;Le<Ge;Le++){let ze=Se[Le],mt=ge[ze.materialIndex];mt&&mt.visible&&y.push(b,Q,mt,M,ue.z,ze)}}else ge.visible&&y.push(b,Q,ge,M,ue.z,null)}}let j=b.children;for(let Q=0,ge=j.length;Q<ge;Q++)Kr(j[Q],_,M,E)}function rr(b,_,M,E){let I=b.opaque,j=b.transmissive,Q=b.transparent;g.setupLightsView(M),Y===!0&&xe.setGlobalState(v.clippingPlanes,M),E&&Z.viewport(S.copy(E)),I.length>0&&Tn(I,_,M),j.length>0&&Tn(j,_,M),Q.length>0&&Tn(Q,_,M),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Fn(b,_,M,E){if((M.isScene===!0?M.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[E.id]===void 0&&(g.state.transmissionRenderTarget[E.id]=new hn(1,1,{generateMipmaps:!0,type:X.has("EXT_color_buffer_half_float")||X.has("EXT_color_buffer_float")?Na:_i,minFilter:jn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1}));let j=g.state.transmissionRenderTarget[E.id],Q=E.viewport||S;j.setSize(Q.z,Q.w);let ge=v.getRenderTarget();v.setRenderTarget(j),v.getClearColor(O),H=v.getClearAlpha(),H<1&&v.setClearColor(16777215,.5),v.clear();let Se=v.toneMapping;v.toneMapping=yi;let Le=E.viewport;if(E.viewport!==void 0&&(E.viewport=void 0),g.setupLightsView(E),Y===!0&&xe.setGlobalState(v.clippingPlanes,E),Tn(b,M,E),ye.updateMultisampleRenderTarget(j),ye.updateRenderTargetMipmap(j),X.has("WEBGL_multisampled_render_to_texture")===!1){let Ge=!1;for(let ze=0,mt=_.length;ze<mt;ze++){let Ht=_[ze],on=Ht.object,ti=Ht.geometry,at=Ht.material,Ye=Ht.group;if(at.side===Hn&&on.layers.test(E.layers)){let so=at.side;at.side=nn,at.needsUpdate=!0,sr(on,M,E,ti,at,Ye),at.side=so,at.needsUpdate=!0,Ge=!0}}Ge===!0&&(ye.updateMultisampleRenderTarget(j),ye.updateRenderTargetMipmap(j))}v.setRenderTarget(ge),v.setClearColor(O,H),Le!==void 0&&(E.viewport=Le),v.toneMapping=Se}function Tn(b,_,M){let E=_.isScene===!0?_.overrideMaterial:null;for(let I=0,j=b.length;I<j;I++){let Q=b[I],ge=Q.object,Se=Q.geometry,Le=E===null?Q.material:E,Ge=Q.group;ge.layers.test(M.layers)&&sr(ge,_,M,Se,Le,Ge)}}function sr(b,_,M,E,I,j){b.onBeforeRender(v,_,M,E,I,j),b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),I.onBeforeRender(v,_,M,E,b,j),I.transparent===!0&&I.side===Hn&&I.forceSinglePass===!1?(I.side=nn,I.needsUpdate=!0,v.renderBufferDirect(M,_,E,I,b,j),I.side=xi,I.needsUpdate=!0,v.renderBufferDirect(M,_,E,I,b,j),I.side=Hn):v.renderBufferDirect(M,_,E,I,b,j),b.onAfterRender(v,_,M,E,I,j)}function kn(b,_,M){_.isScene!==!0&&(_=Pe);let E=ie.get(b),I=g.state.lights,j=g.state.shadowsArray,Q=I.state.version,ge=oe.getParameters(b,I.state,j,_,M),Se=oe.getProgramCacheKey(ge),Le=E.programs;E.environment=b.isMeshStandardMaterial?_.environment:null,E.fog=_.fog,E.envMap=(b.isMeshStandardMaterial?U:Te).get(b.envMap||E.environment),E.envMapRotation=E.environment!==null&&b.envMap===null?_.environmentRotation:b.envMapRotation,Le===void 0&&(b.addEventListener("dispose",we),Le=new Map,E.programs=Le);let Ge=Le.get(Se);if(Ge!==void 0){if(E.currentProgram===Ge&&E.lightsStateVersion===Q)return Qr(b,ge),Ge}else ge.uniforms=oe.getUniforms(b),b.onBuild(M,ge,v),b.onBeforeCompile(ge,v),Ge=oe.acquireProgram(ge,Se),Le.set(Se,Ge),E.uniforms=ge.uniforms;let ze=E.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(ze.clippingPlanes=xe.uniform),Qr(b,ge),E.needsLights=$(b),E.lightsStateVersion=Q,E.needsLights&&(ze.ambientLightColor.value=I.state.ambient,ze.lightProbe.value=I.state.probe,ze.directionalLights.value=I.state.directional,ze.directionalLightShadows.value=I.state.directionalShadow,ze.spotLights.value=I.state.spot,ze.spotLightShadows.value=I.state.spotShadow,ze.rectAreaLights.value=I.state.rectArea,ze.ltc_1.value=I.state.rectAreaLTC1,ze.ltc_2.value=I.state.rectAreaLTC2,ze.pointLights.value=I.state.point,ze.pointLightShadows.value=I.state.pointShadow,ze.hemisphereLights.value=I.state.hemi,ze.directionalShadowMap.value=I.state.directionalShadowMap,ze.directionalShadowMatrix.value=I.state.directionalShadowMatrix,ze.spotShadowMap.value=I.state.spotShadowMap,ze.spotLightMatrix.value=I.state.spotLightMatrix,ze.spotLightMap.value=I.state.spotLightMap,ze.pointShadowMap.value=I.state.pointShadowMap,ze.pointShadowMatrix.value=I.state.pointShadowMatrix),E.currentProgram=Ge,E.uniformsList=null,Ge}function or(b){if(b.uniformsList===null){let _=b.currentProgram.getUniforms();b.uniformsList=Bs.seqWithValue(_.seq,b.uniforms)}return b.uniformsList}function Qr(b,_){let M=ie.get(b);M.outputColorSpace=_.outputColorSpace,M.batching=_.batching,M.instancing=_.instancing,M.instancingColor=_.instancingColor,M.instancingMorph=_.instancingMorph,M.skinning=_.skinning,M.morphTargets=_.morphTargets,M.morphNormals=_.morphNormals,M.morphColors=_.morphColors,M.morphTargetsCount=_.morphTargetsCount,M.numClippingPlanes=_.numClippingPlanes,M.numIntersection=_.numClipIntersection,M.vertexAlphas=_.vertexAlphas,M.vertexTangents=_.vertexTangents,M.toneMapping=_.toneMapping}function ar(b,_,M,E,I){_.isScene!==!0&&(_=Pe),ye.resetTextureUnits();let j=_.fog,Q=E.isMeshStandardMaterial?_.environment:null,ge=R===null?v.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Si,Se=(E.isMeshStandardMaterial?U:Te).get(E.envMap||Q),Le=E.vertexColors===!0&&!!M.attributes.color&&M.attributes.color.itemSize===4,Ge=!!M.attributes.tangent&&(!!E.normalMap||E.anisotropy>0),ze=!!M.morphAttributes.position,mt=!!M.morphAttributes.normal,Ht=!!M.morphAttributes.color,on=yi;E.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(on=v.toneMapping);let ti=M.morphAttributes.position||M.morphAttributes.normal||M.morphAttributes.color,at=ti!==void 0?ti.length:0,Ye=ie.get(E),so=g.state.lights;if(Y===!0&&(me===!0||b!==A)){let vn=b===A&&E.id===F;xe.setState(E,b,vn)}let xt=!1;E.version===Ye.__version?(Ye.needsLights&&Ye.lightsStateVersion!==so.state.version||Ye.outputColorSpace!==ge||I.isBatchedMesh&&Ye.batching===!1||!I.isBatchedMesh&&Ye.batching===!0||I.isInstancedMesh&&Ye.instancing===!1||!I.isInstancedMesh&&Ye.instancing===!0||I.isSkinnedMesh&&Ye.skinning===!1||!I.isSkinnedMesh&&Ye.skinning===!0||I.isInstancedMesh&&Ye.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&Ye.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&Ye.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&Ye.instancingMorph===!1&&I.morphTexture!==null||Ye.envMap!==Se||E.fog===!0&&Ye.fog!==j||Ye.numClippingPlanes!==void 0&&(Ye.numClippingPlanes!==xe.numPlanes||Ye.numIntersection!==xe.numIntersection)||Ye.vertexAlphas!==Le||Ye.vertexTangents!==Ge||Ye.morphTargets!==ze||Ye.morphNormals!==mt||Ye.morphColors!==Ht||Ye.toneMapping!==on||Ye.morphTargetsCount!==at)&&(xt=!0):(xt=!0,Ye.__version=E.version);let cr=Ye.currentProgram;xt===!0&&(cr=kn(E,_,I));let Wp=!1,oo=!1,Ju=!1,jt=cr.getUniforms(),Ii=Ye.uniforms;if(Z.useProgram(cr.program)&&(Wp=!0,oo=!0,Ju=!0),E.id!==F&&(F=E.id,oo=!0),Wp||A!==b){jt.setValue(z,"projectionMatrix",b.projectionMatrix),jt.setValue(z,"viewMatrix",b.matrixWorldInverse);let vn=jt.map.cameraPosition;vn!==void 0&&vn.setValue(z,ue.setFromMatrixPosition(b.matrixWorld)),de.logarithmicDepthBuffer&&jt.setValue(z,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(E.isMeshPhongMaterial||E.isMeshToonMaterial||E.isMeshLambertMaterial||E.isMeshBasicMaterial||E.isMeshStandardMaterial||E.isShaderMaterial)&&jt.setValue(z,"isOrthographic",b.isOrthographicCamera===!0),A!==b&&(A=b,oo=!0,Ju=!0)}if(I.isSkinnedMesh){jt.setOptional(z,I,"bindMatrix"),jt.setOptional(z,I,"bindMatrixInverse");let vn=I.skeleton;vn&&(vn.boneTexture===null&&vn.computeBoneTexture(),jt.setValue(z,"boneTexture",vn.boneTexture,ye))}I.isBatchedMesh&&(jt.setOptional(z,I,"batchingTexture"),jt.setValue(z,"batchingTexture",I._matricesTexture,ye));let Ku=M.morphAttributes;if((Ku.position!==void 0||Ku.normal!==void 0||Ku.color!==void 0)&&Oe.update(I,M,cr),(oo||Ye.receiveShadow!==I.receiveShadow)&&(Ye.receiveShadow=I.receiveShadow,jt.setValue(z,"receiveShadow",I.receiveShadow)),E.isMeshGouraudMaterial&&E.envMap!==null&&(Ii.envMap.value=Se,Ii.flipEnvMap.value=Se.isCubeTexture&&Se.isRenderTargetTexture===!1?-1:1),E.isMeshStandardMaterial&&E.envMap===null&&_.environment!==null&&(Ii.envMapIntensity.value=_.environmentIntensity),oo&&(jt.setValue(z,"toneMappingExposure",v.toneMappingExposure),Ye.needsLights&&L(Ii,Ju),j&&E.fog===!0&&re.refreshFogUniforms(Ii,j),re.refreshMaterialUniforms(Ii,E,ae,J,g.state.transmissionRenderTarget[b.id]),Bs.upload(z,or(Ye),Ii,ye)),E.isShaderMaterial&&E.uniformsNeedUpdate===!0&&(Bs.upload(z,or(Ye),Ii,ye),E.uniformsNeedUpdate=!1),E.isSpriteMaterial&&jt.setValue(z,"center",I.center),jt.setValue(z,"modelViewMatrix",I.modelViewMatrix),jt.setValue(z,"normalMatrix",I.normalMatrix),jt.setValue(z,"modelMatrix",I.matrixWorld),E.isShaderMaterial||E.isRawShaderMaterial){let vn=E.uniformsGroups;for(let Qu=0,hx=vn.length;Qu<hx;Qu++){let Xp=vn[Qu];Qe.update(Xp,cr),Qe.bind(Xp,cr)}}return cr}function L(b,_){b.ambientLightColor.needsUpdate=_,b.lightProbe.needsUpdate=_,b.directionalLights.needsUpdate=_,b.directionalLightShadows.needsUpdate=_,b.pointLights.needsUpdate=_,b.pointLightShadows.needsUpdate=_,b.spotLights.needsUpdate=_,b.spotLightShadows.needsUpdate=_,b.rectAreaLights.needsUpdate=_,b.hemisphereLights.needsUpdate=_}function $(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(b,_,M){ie.get(b.texture).__webglTexture=_,ie.get(b.depthTexture).__webglTexture=M;let E=ie.get(b);E.__hasExternalTextures=!0,E.__autoAllocateDepthBuffer=M===void 0,E.__autoAllocateDepthBuffer||X.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),E.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(b,_){let M=ie.get(b);M.__webglFramebuffer=_,M.__useDefaultFramebuffer=_===void 0},this.setRenderTarget=function(b,_=0,M=0){R=b,N=_,C=M;let E=!0,I=null,j=!1,Q=!1;if(b){let Se=ie.get(b);Se.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(z.FRAMEBUFFER,null),E=!1):Se.__webglFramebuffer===void 0?ye.setupRenderTarget(b):Se.__hasExternalTextures&&ye.rebindTextures(b,ie.get(b.texture).__webglTexture,ie.get(b.depthTexture).__webglTexture);let Le=b.texture;(Le.isData3DTexture||Le.isDataArrayTexture||Le.isCompressedArrayTexture)&&(Q=!0);let Ge=ie.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Ge[_])?I=Ge[_][M]:I=Ge[_],j=!0):b.samples>0&&ye.useMultisampledRTT(b)===!1?I=ie.get(b).__webglMultisampledFramebuffer:Array.isArray(Ge)?I=Ge[M]:I=Ge,S.copy(b.viewport),P.copy(b.scissor),k=b.scissorTest}else S.copy(ce).multiplyScalar(ae).floor(),P.copy(Me).multiplyScalar(ae).floor(),k=fe;if(Z.bindFramebuffer(z.FRAMEBUFFER,I)&&E&&Z.drawBuffers(b,I),Z.viewport(S),Z.scissor(P),Z.setScissorTest(k),j){let Se=ie.get(b.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+_,Se.__webglTexture,M)}else if(Q){let Se=ie.get(b.texture),Le=_||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,Se.__webglTexture,M||0,Le)}F=-1},this.readRenderTargetPixels=function(b,_,M,E,I,j,Q){if(!(b&&b.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=ie.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Q!==void 0&&(ge=ge[Q]),ge){Z.bindFramebuffer(z.FRAMEBUFFER,ge);try{let Se=b.texture,Le=Se.format,Ge=Se.type;if(!de.textureFormatReadable(Le)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!de.textureTypeReadable(Ge)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_>=0&&_<=b.width-E&&M>=0&&M<=b.height-I&&z.readPixels(_,M,E,I,Ce.convert(Le),Ce.convert(Ge),j)}finally{let Se=R!==null?ie.get(R).__webglFramebuffer:null;Z.bindFramebuffer(z.FRAMEBUFFER,Se)}}},this.copyFramebufferToTexture=function(b,_,M=0){let E=Math.pow(2,-M),I=Math.floor(_.image.width*E),j=Math.floor(_.image.height*E);ye.setTexture2D(_,0),z.copyTexSubImage2D(z.TEXTURE_2D,M,0,0,b.x,b.y,I,j),Z.unbindTexture()},this.copyTextureToTexture=function(b,_,M,E=0){let I=_.image.width,j=_.image.height,Q=Ce.convert(M.format),ge=Ce.convert(M.type);ye.setTexture2D(M,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,M.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,M.unpackAlignment),_.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,E,b.x,b.y,I,j,Q,ge,_.image.data):_.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,E,b.x,b.y,_.mipmaps[0].width,_.mipmaps[0].height,Q,_.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,E,b.x,b.y,Q,ge,_.image),E===0&&M.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(b,_,M,E,I=0){let j=b.max.x-b.min.x,Q=b.max.y-b.min.y,ge=b.max.z-b.min.z,Se=Ce.convert(E.format),Le=Ce.convert(E.type),Ge;if(E.isData3DTexture)ye.setTexture3D(E,0),Ge=z.TEXTURE_3D;else if(E.isDataArrayTexture||E.isCompressedArrayTexture)ye.setTexture2DArray(E,0),Ge=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,E.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,E.unpackAlignment);let ze=z.getParameter(z.UNPACK_ROW_LENGTH),mt=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Ht=z.getParameter(z.UNPACK_SKIP_PIXELS),on=z.getParameter(z.UNPACK_SKIP_ROWS),ti=z.getParameter(z.UNPACK_SKIP_IMAGES),at=M.isCompressedTexture?M.mipmaps[I]:M.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,at.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,at.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,b.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,b.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,b.min.z),M.isDataTexture||M.isData3DTexture?z.texSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,Le,at.data):E.isCompressedArrayTexture?z.compressedTexSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,at.data):z.texSubImage3D(Ge,I,_.x,_.y,_.z,j,Q,ge,Se,Le,at),z.pixelStorei(z.UNPACK_ROW_LENGTH,ze),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,mt),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Ht),z.pixelStorei(z.UNPACK_SKIP_ROWS,on),z.pixelStorei(z.UNPACK_SKIP_IMAGES,ti),I===0&&E.generateMipmaps&&z.generateMipmap(Ge),Z.unbindTexture()},this.initTexture=function(b){b.isCubeTexture?ye.setTextureCube(b,0):b.isData3DTexture?ye.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?ye.setTexture2DArray(b,0):ye.setTexture2D(b,0),Z.unbindTexture()},this.resetState=function(){N=0,C=0,R=null,Z.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Gn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===zu?"display-p3":"srgb",t.unpackColorSpace=dt.workingColorSpace===Fa?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},Ll=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ie(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Dl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ie(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Ol=class extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fn,this.environmentIntensity=1,this.environmentRotation=new fn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},qs=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ra,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=dn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return dv("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=dn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Qt=new D,Vr=class n{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyMatrix4(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.applyNormalMatrix(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Qt.fromBufferAttribute(this,t),Qt.transformDirection(e),this.setXYZ(t,Qt.x,Qt.y,Qt.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=tn(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Je(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Je(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Je(t,this.array),i=Je(i,this.array),r=Je(r,this.array),s=Je(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new ot(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new n(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},pa=class extends Ft{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Lo=new D,Cs=new D,Rs=new D,Ps=new se,Do=new se,wv=new Ve,qc=new D,Oo=new D,Yc=new D,hy=new se,ah=new se,fy=new se,Ul=class extends ct{constructor(e=new pa){if(super(),this.isSprite=!0,this.type="Sprite",Is===void 0){Is=new et;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new qs(t,5);Is.setIndex([0,1,2,0,2,3]),Is.setAttribute("position",new Vr(i,3,0,!1)),Is.setAttribute("uv",new Vr(i,2,3,!1))}this.geometry=Is,this.material=e,this.center=new se(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Cs.setFromMatrixScale(this.matrixWorld),wv.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Rs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Cs.multiplyScalar(-Rs.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Zc(qc.set(-.5,-.5,0),Rs,o,Cs,r,s),Zc(Oo.set(.5,-.5,0),Rs,o,Cs,r,s),Zc(Yc.set(.5,.5,0),Rs,o,Cs,r,s),hy.set(0,0),ah.set(1,0),fy.set(1,1);let a=e.ray.intersectTriangle(qc,Oo,Yc,!1,Lo);if(a===null&&(Zc(Oo.set(-.5,.5,0),Rs,o,Cs,r,s),ah.set(0,1),a=e.ray.intersectTriangle(qc,Yc,Oo,!1,Lo),a===null))return;let c=e.ray.origin.distanceTo(Lo);c<e.near||c>e.far||t.push({distance:c,point:Lo.clone(),uv:pi.getInterpolation(Lo,qc,Oo,Yc,hy,ah,fy,new se),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Jc=new D,py=new D,Nl=class extends ct{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Jc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Jc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Jc.setFromMatrixPosition(e.matrixWorld),py.setFromMatrixPosition(this.matrixWorld);let i=Jc.distanceTo(py)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},my=new D,gy=new ht,yy=new ht,bI=new D,vy=new Ve,Kc=new D,ch=new Nt,xy=new Ve,lh=new Xi,Fl=class extends St{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Eh,this.bindMatrix=new Ve,this.bindMatrixInverse=new Ve,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Kc),this.boundingBox.expandByPoint(Kc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Nt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Kc),this.boundingSphere.expandByPoint(Kc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ch.copy(this.boundingSphere),ch.applyMatrix4(r),e.ray.intersectsSphere(ch)!==!1&&(xy.copy(r).invert(),lh.copy(e.ray).applyMatrix4(xy),!(this.boundingBox!==null&&lh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,lh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new ht,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Eh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===z0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;gy.fromBufferAttribute(r.attributes.skinIndex,e),yy.fromBufferAttribute(r.attributes.skinWeight,e),my.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=yy.getComponent(s);if(o!==0){let a=gy.getComponent(s);vy.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(bI.copy(my).applyMatrix4(vy),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},ma=class extends ct{constructor(){super(),this.isBone=!0,this.type="Bone"}},Wn=class extends Ct{constructor(e=null,t=1,i=1,r,s,o,a,c,l=Ut,u=Ut,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},by=new Ve,_I=new Ve,kl=class n{constructor(e=[],t=[]){this.uuid=dn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ve)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Ve;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:_I;by.multiplyMatrices(a,t[s]),by.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Wn(t,e,e,un,En);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new ma),this.bones.push(o),this.boneInverses.push(new Ve().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},qi=class extends ot{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ls=new Ve,_y=new Ve,Qc=[],wy=new Bt,wI=new Ve,Uo=new St,No=new Nt,Bl=class extends St{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new qi(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,wI)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ls),wy.copy(e.boundingBox).applyMatrix4(Ls),this.boundingBox.union(wy)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Nt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ls),No.copy(e.boundingSphere).applyMatrix4(Ls),this.boundingSphere.union(No)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,o=e*s+1;for(let a=0;a<i.length;a++)i[a]=r[o+a]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Uo.geometry=this.geometry,Uo.material=this.material,Uo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),No.copy(this.boundingSphere),No.applyMatrix4(i),e.ray.intersectsSphere(No)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ls),_y.multiplyMatrices(i,Ls),Uo.matrixWorld=_y,Uo.raycast(e,Qc);for(let o=0,a=Qc.length;o<a;o++){let c=Qc[o];c.instanceId=s,c.object=this,t.push(c)}Qc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new qi(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Wn(new Float32Array(r*this.count),r,this.count,Sp,En));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<i.length;l++)o+=i[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(i,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};vf=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Ds="batchId",$i=new Ve,My=new Ve,EI=new Ve,Sy=new Ve,uh=new zr,el=new Bt,wr=new Nt,Fo=new D,dh=new vf,Yt=new St,tl=[];zl=class extends St{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new et,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Wn(t,e,e,un,En);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:d}=c,h=new l.constructor(i*u),f=new ot(h,u,d);t.setAttribute(a,f)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new ot(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Ds,new ot(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ds))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ds}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Ds)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingBoxAt(r,el).applyMatrix4($i),t.union(el))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Nt);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,$i),this.getBoundingSphereAt(r,wr).applyMatrix4($i),t.union(wr))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d=this._visibility,h=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;d.push(!0),h.push(!0);let y=this._geometryCount;this._geometryCount++,EI.toArray(p,y*16),f.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Bt,sphereInitialized:!1,sphere:new Nt});let g=this.geometry.getAttribute(Ds);for(let m=0;m<r.vertexCount;m++)g.setX(r.vertexStart+m,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let f in i.attributes){if(f===Ds)continue;let p=t.getAttribute(f),y=i.getAttribute(f);AI(p,y,c);let g=p.itemSize;for(let m=p.count,x=l;m<x;m++){let v=c+m;for(let w=0;w<g;w++)y.setComponent(v,w,0)}y.needsUpdate=!0,y.addUpdateRange(c*g,l*g)}if(r){let f=a.indexStart;for(let p=0;p<o.count;p++)s.setX(f+p,c+o.getX(p));for(let p=o.count,y=a.indexCount;p<y;p++)s.setX(f+p,c);s.needsUpdate=!0,s.addUpdateRange(f,a.indexCount)}let u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;let d=this._drawRanges[e],h=t.getAttribute("position");return d.count=r?o.count:h.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,d=l.start+l.count;u<d;u++){let h=u;a&&(h=a.getX(h)),s.expandByPoint(Fo.fromBufferAttribute(c,h))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,el),el.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let d=l.start,h=l.start+l.count;d<h;d++){let f=d;a&&(f=a.getX(f)),Fo.fromBufferAttribute(c,f),u=Math.max(u,s.center.distanceToSquared(Fo))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;Yt.material=this.material,Yt.geometry.index=c.index,Yt.geometry.attributes=c.attributes,Yt.geometry.boundingBox===null&&(Yt.geometry.boundingBox=new Bt),Yt.geometry.boundingSphere===null&&(Yt.geometry.boundingSphere=new Nt);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];Yt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,Yt.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Yt.geometry.boundingBox),this.getBoundingSphereAt(l,Yt.geometry.boundingSphere),Yt.raycast(e,tl);for(let d=0,h=tl.length;d<h;d++){let f=tl[d];f.object=this,f.batchId=l,t.push(f)}tl.length=0}Yt.material=null,Yt.geometry.index=null,Yt.geometry.attributes={},Yt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._active,l=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(Sy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),uh.setFromProjectionMatrix(Sy,e.coordinateSystem));let p=0;if(this.sortObjects){My.copy(this.matrixWorld).invert(),Fo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(My);for(let m=0,x=l.length;m<x;m++)if(l[m]&&c[m]){this.getMatrixAt(m,$i),this.getBoundingSphereAt(m,wr).applyMatrix4($i);let v=!1;if(f&&(v=!uh.intersectsSphere(wr)),!v){let w=Fo.distanceTo(wr.center);dh.push(h[m],w)}}let y=dh.list,g=this.customSort;g===null?y.sort(s.transparent?SI:MI):g.call(this,y,i);for(let m=0,x=y.length;m<x;m++){let v=y[m];u[p]=v.start*a,d[p]=v.count,p++}dh.reset()}else for(let y=0,g=l.length;y<g;y++)if(l[y]&&c[y]){let m=!1;if(f&&(this.getMatrixAt(y,$i),this.getBoundingSphereAt(y,wr).applyMatrix4($i),m=!uh.intersectsSphere(wr)),!m){let x=h[y];u[p]=x.start*a,d[p]=x.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},zt=class extends Ft{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Vl=new D,$l=new D,Ey=new Ve,ko=new Xi,nl=new Nt,hh=new D,Ay=new D,Yn=class extends ct{constructor(e=new et,t=new zt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Vl.fromBufferAttribute(t,r-1),$l.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Vl.distanceTo($l);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),nl.copy(i.boundingSphere),nl.applyMatrix4(r),nl.radius+=s,e.ray.intersectsSphere(nl)===!1)return;Ey.copy(r).invert(),ko.copy(e.ray).applyMatrix4(Ey);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){let f=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=u.getX(y),x=u.getX(y+1),v=il(this,e,ko,c,m,x);v&&t.push(v)}if(this.isLineLoop){let y=u.getX(p-1),g=u.getX(f),m=il(this,e,ko,c,y,g);m&&t.push(m)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let y=f,g=p-1;y<g;y+=l){let m=il(this,e,ko,c,y,y+1);m&&t.push(m)}if(this.isLineLoop){let y=il(this,e,ko,c,p-1,f);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};Ty=new D,Iy=new D,An=class extends Yn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Ty.fromBufferAttribute(t,r),Iy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Ty.distanceTo(Iy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Hl=class extends Yn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ga=class extends Ft{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Cy=new Ve,xf=new Xi,rl=new Nt,sl=new D,jl=class extends ct{constructor(e=new et,t=new ga){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),rl.copy(i.boundingSphere),rl.applyMatrix4(r),rl.radius+=s,e.ray.intersectsSphere(rl)===!1)return;Cy.copy(r).invert(),xf.copy(e.ray).applyMatrix4(Cy);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,d=i.attributes.position;if(l!==null){let h=Math.max(0,o.start),f=Math.min(l.count,o.start+o.count);for(let p=h,y=f;p<y;p++){let g=l.getX(p);sl.fromBufferAttribute(d,g),Ry(sl,g,c,r,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let p=h,y=f;p<y;p++)sl.fromBufferAttribute(d,p),Ry(sl,p,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};bf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:It,this.magFilter=s!==void 0?s:It,this.generateMipmaps=!1;let u=this;function d(){u.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_f=class extends Ct{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ut,this.minFilter=Ut,this.generateMipmaps=!1,this.needsUpdate=!0}},Ys=class extends Ct{constructor(e,t,i,r,s,o,a,c,l,u,d,h){super(null,o,a,c,l,u,r,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},wf=class extends Ys{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Sn}},Mf=class extends Ys{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,bi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Sf=class extends Ct{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},mn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],h=i[r+1]-u,f=(o-u)/h;return(r+f)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new se:new D);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new D,r=[],s=[],o=[],a=new D,c=new Ve;for(let f=0;f<=e;f++){let p=f/e;r[f]=this.getTangentAt(p,new D)}s[0]=new D,o[0]=new D;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),d=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),h<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(r[f-1],r[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(Mt(r[f-1].dot(r[f]),-1,1));s[f].applyMatrix4(c.makeRotationAxis(a,p))}o[f].crossVectors(r[f],s[f])}if(t===!0){let f=Math.acos(Mt(s[0].dot(s[e]),-1,1));f/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let p=1;p<=e;p++)s[p].applyMatrix4(c.makeRotationAxis(r[p],f*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Zs=class extends mn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new se){let i=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),d=Math.sin(this.aRotation),h=c-this.aX,f=l-this.aY;c=h*u-f*d+this.aX,l=h*d+f*u+this.aY}return i.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Gl=class extends Zs{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};ol=new D,fh=new Lp,ph=new Lp,mh=new Lp,Wl=class extends mn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new D){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(ol.subVectors(r[0],r[1]).add(r[0]),l=ol);let d=r[a%s],h=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(ol.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=ol),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(u),f);y<1e-4&&(y=1),p<1e-4&&(p=y),g<1e-4&&(g=y),fh.initNonuniformCatmullRom(l.x,d.x,h.x,u.x,p,y,g),ph.initNonuniformCatmullRom(l.y,d.y,h.y,u.y,p,y,g),mh.initNonuniformCatmullRom(l.z,d.z,h.z,u.z,p,y,g)}else this.curveType==="catmullrom"&&(fh.initCatmullRom(l.x,d.x,h.x,u.x,this.tension),ph.initCatmullRom(l.y,d.y,h.y,u.y,this.tension),mh.initCatmullRom(l.z,d.z,h.z,u.z,this.tension));return i.set(fh.calc(c),ph.calc(c),mh.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new D().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};ya=class extends mn{constructor(e=new se,t=new se,i=new se,r=new se){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Wo(e,r.x,s.x,o.x,a.x),Wo(e,r.y,s.y,o.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Xl=class extends mn{constructor(e=new D,t=new D,i=new D,r=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new D){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(Wo(e,r.x,s.x,o.x,a.x),Wo(e,r.y,s.y,o.y,a.y),Wo(e,r.z,s.z,o.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},va=class extends mn{constructor(e=new se,t=new se){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new se){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new se){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ql=class extends mn{constructor(e=new D,t=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new D){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new D){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},xa=class extends mn{constructor(e=new se,t=new se,i=new se){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new se){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ba=class extends mn{constructor(e=new D,t=new D,i=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new D){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Go(e,r.x,s.x,o.x),Go(e,r.y,s.y,o.y),Go(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},_a=class extends mn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new se){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(Py(a,c.x,l.x,u.x,d.x),Py(a,c.y,l.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new se().fromArray(r))}return this}},Yl=Object.freeze({__proto__:null,ArcCurve:Gl,CatmullRomCurve3:Wl,CubicBezierCurve:ya,CubicBezierCurve3:Xl,EllipseCurve:Zs,LineCurve:va,LineCurve3:ql,QuadraticBezierCurve:xa,QuadraticBezierCurve3:ba,SplineCurve:_a}),Zl=class extends mn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Yl[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Yl[r.type]().fromJSON(r))}return this}},$r=class extends Zl{constructor(e){super(),this.type="Path",this.currentPoint=new se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new va(this.currentPoint.clone(),new se(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new xa(this.currentPoint.clone(),new se(e,t),new se(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new ya(this.currentPoint.clone(),new se(e,t),new se(i,r),new se(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new _a(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new Zs(e,t,i,r,s,o,a,c);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},wa=class n extends et{constructor(e=[new se(0,-.5),new se(.5,0),new se(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Mt(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,d=new D,h=new se,f=new D,p=new D,y=new D,g=0,m=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,y.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,f.x=m*1,f.y=-g,f.z=m*0,p.copy(f),f.x+=y.x,f.y+=y.y,f.z+=y.z,f.normalize(),c.push(f.x,f.y,f.z),y.copy(p)}for(let x=0;x<=t;x++){let v=i+x*u*r,w=Math.sin(v),N=Math.cos(v);for(let C=0;C<=e.length-1;C++){d.x=e[C].x*w,d.y=e[C].y,d.z=e[C].x*N,o.push(d.x,d.y,d.z),h.x=x/t,h.y=C/(e.length-1),a.push(h.x,h.y);let R=c[3*C+0]*w,F=c[3*C+1],A=c[3*C+0]*N;l.push(R,F,A)}}for(let x=0;x<t;x++)for(let v=0;v<e.length-1;v++){let w=v+x*e.length,N=w,C=w+e.length,R=w+e.length+1,F=w+1;s.push(N,C,F),s.push(R,F,C)}this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("uv",new De(a,2)),this.setAttribute("normal",new De(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Jl=class n extends wa{constructor(e=1,t=1,i=4,r=8){let s=new $r;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new n(e.radius,e.length,e.capSegments,e.radialSegments)}},Kl=class n extends et{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new D,u=new se;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let d=0,h=3;d<=t;d++,h+=3){let f=i+d/t*r;l.x=e*Math.cos(f),l.y=e*Math.sin(f),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[h]/e+1)/2,u.y=(o[h+1]/e+1)/2,c.push(u.x,u.y)}for(let d=1;d<=t;d++)s.push(d,d+1,0);this.setIndex(s),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(a,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Js=class n extends et{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],d=[],h=[],f=[],p=0,y=[],g=i/2,m=0;x(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function x(){let w=new D,N=new D,C=0,R=(t-e)/i;for(let F=0;F<=s;F++){let A=[],S=F/s,P=S*(t-e)+e;for(let k=0;k<=r;k++){let O=k/r,H=O*c+a,W=Math.sin(H),J=Math.cos(H);N.x=P*W,N.y=-S*i+g,N.z=P*J,d.push(N.x,N.y,N.z),w.set(W,R,J).normalize(),h.push(w.x,w.y,w.z),f.push(O,1-S),A.push(p++)}y.push(A)}for(let F=0;F<r;F++)for(let A=0;A<s;A++){let S=y[A][F],P=y[A+1][F],k=y[A+1][F+1],O=y[A][F+1];u.push(S,P,O),u.push(P,k,O),C+=6}l.addGroup(m,C,0),m+=C}function v(w){let N=p,C=new se,R=new D,F=0,A=w===!0?e:t,S=w===!0?1:-1;for(let k=1;k<=r;k++)d.push(0,g*S,0),h.push(0,S,0),f.push(.5,.5),p++;let P=p;for(let k=0;k<=r;k++){let H=k/r*c+a,W=Math.cos(H),J=Math.sin(H);R.x=A*J,R.y=g*S,R.z=A*W,d.push(R.x,R.y,R.z),h.push(0,S,0),C.x=W*.5+.5,C.y=J*.5*S+.5,f.push(C.x,C.y),p++}for(let k=0;k<r;k++){let O=N+k,H=P+k;w===!0?u.push(H,H+1,O):u.push(H+1,H,O),F+=3}l.addGroup(m,F,w===!0?1:2),m+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ql=class n extends Js{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Yi=class n extends et{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(x){let v=new D,w=new D,N=new D;for(let C=0;C<t.length;C+=3)f(t[C+0],v),f(t[C+1],w),f(t[C+2],N),c(v,w,N,x)}function c(x,v,w,N){let C=N+1,R=[];for(let F=0;F<=C;F++){R[F]=[];let A=x.clone().lerp(w,F/C),S=v.clone().lerp(w,F/C),P=C-F;for(let k=0;k<=P;k++)k===0&&F===C?R[F][k]=A:R[F][k]=A.clone().lerp(S,k/P)}for(let F=0;F<C;F++)for(let A=0;A<2*(C-F)-1;A++){let S=Math.floor(A/2);A%2===0?(h(R[F][S+1]),h(R[F+1][S]),h(R[F][S])):(h(R[F][S+1]),h(R[F+1][S+1]),h(R[F+1][S]))}}function l(x){let v=new D;for(let w=0;w<s.length;w+=3)v.x=s[w+0],v.y=s[w+1],v.z=s[w+2],v.normalize().multiplyScalar(x),s[w+0]=v.x,s[w+1]=v.y,s[w+2]=v.z}function u(){let x=new D;for(let v=0;v<s.length;v+=3){x.x=s[v+0],x.y=s[v+1],x.z=s[v+2];let w=g(x)/2/Math.PI+.5,N=m(x)/Math.PI+.5;o.push(w,1-N)}p(),d()}function d(){for(let x=0;x<o.length;x+=6){let v=o[x+0],w=o[x+2],N=o[x+4],C=Math.max(v,w,N),R=Math.min(v,w,N);C>.9&&R<.1&&(v<.2&&(o[x+0]+=1),w<.2&&(o[x+2]+=1),N<.2&&(o[x+4]+=1))}}function h(x){s.push(x.x,x.y,x.z)}function f(x,v){let w=x*3;v.x=e[w+0],v.y=e[w+1],v.z=e[w+2]}function p(){let x=new D,v=new D,w=new D,N=new D,C=new se,R=new se,F=new se;for(let A=0,S=0;A<s.length;A+=9,S+=6){x.set(s[A+0],s[A+1],s[A+2]),v.set(s[A+3],s[A+4],s[A+5]),w.set(s[A+6],s[A+7],s[A+8]),C.set(o[S+0],o[S+1]),R.set(o[S+2],o[S+3]),F.set(o[S+4],o[S+5]),N.copy(x).add(v).add(w).divideScalar(3);let P=g(N);y(C,S+0,x,P),y(R,S+2,v,P),y(F,S+4,w,P)}}function y(x,v,w,N){N<0&&x.x===1&&(o[v]=x.x-1),w.x===0&&w.z===0&&(o[v]=N/2/Math.PI+.5)}function g(x){return Math.atan2(x.z,-x.x)}function m(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},eu=class n extends Yi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},al=new D,cl=new D,gh=new D,ll=new pi,tu=class extends et{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Nr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],d=new Array(3),h={},f=[];for(let p=0;p<c;p+=3){o?(l[0]=o.getX(p),l[1]=o.getX(p+1),l[2]=o.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);let{a:y,b:g,c:m}=ll;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),m.fromBufferAttribute(a,l[2]),ll.getNormal(gh),d[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,d[2]=`${Math.round(m.x*r)},${Math.round(m.y*r)},${Math.round(m.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let x=0;x<3;x++){let v=(x+1)%3,w=d[x],N=d[v],C=ll[u[x]],R=ll[u[v]],F=`${w}_${N}`,A=`${N}_${w}`;A in h&&h[A]?(gh.dot(h[A].normal)<=s&&(f.push(C.x,C.y,C.z),f.push(R.x,R.y,R.z)),h[A]=null):F in h||(h[F]={index0:l[x],index1:l[v],normal:gh.clone()})}}for(let p in h)if(h[p]){let{index0:y,index1:g}=h[p];al.fromBufferAttribute(a,y),cl.fromBufferAttribute(a,g),f.push(al.x,al.y,al.z),f.push(cl.x,cl.y,cl.z)}this.setAttribute("position",new De(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},vi=class extends $r{constructor(e){super(e),this.uuid=dn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new $r().fromJSON(r))}return this}},OI={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=Mv(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,d,h,f;if(i&&(s=BI(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let p=t;p<r;p+=t)d=n[p],h=n[p+1],d<a&&(a=d),h<c&&(c=h),d>l&&(l=d),h>u&&(u=h);f=Math.max(l-a,u-c),f=f!==0?32767/f:0}return Ma(s,o,t,a,c,f,0),o}};Xn=class n{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Dy(e),Oy(i,e);let o=e.length;t.forEach(Dy);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,Oy(i,t[c]);let a=OI.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};nu=class n extends et{constructor(e=new vi([new se(.5,.5),new se(-.5,.5),new se(-.5,-.5),new se(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1,h=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:f-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,m=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:JI,v,w=!1,N,C,R,F;m&&(v=m.getSpacedPoints(u),w=!0,h=!1,N=m.computeFrenetFrames(u,!1),C=new D,R=new D,F=new D),h||(g=0,f=0,p=0,y=0);let A=a.extractPoints(l),S=A.shape,P=A.holes;if(!Xn.isClockWise(S)){S=S.reverse();for(let X=0,de=P.length;X<de;X++){let Z=P[X];Xn.isClockWise(Z)&&(P[X]=Z.reverse())}}let O=Xn.triangulateShape(S,P),H=S;for(let X=0,de=P.length;X<de;X++){let Z=P[X];S=S.concat(Z)}function W(X,de,Z){return de||console.error("THREE.ExtrudeGeometry: vec does not exist"),X.clone().addScaledVector(de,Z)}let J=S.length,ae=O.length;function B(X,de,Z){let he,ie,ye,Te=X.x-de.x,U=X.y-de.y,T=Z.x-X.x,G=Z.y-X.y,ee=Te*Te+U*U,oe=Te*G-U*T;if(Math.abs(oe)>Number.EPSILON){let re=Math.sqrt(ee),Ue=Math.sqrt(T*T+G*G),ve=de.x-U/re,xe=de.y+Te/re,He=Z.x-G/Ue,pe=Z.y+T/Ue,Oe=((He-ve)*G-(pe-xe)*T)/(Te*G-U*T);he=ve+Te*Oe-X.x,ie=xe+U*Oe-X.y;let qe=he*he+ie*ie;if(qe<=2)return new se(he,ie);ye=Math.sqrt(qe/2)}else{let re=!1;Te>Number.EPSILON?T>Number.EPSILON&&(re=!0):Te<-Number.EPSILON?T<-Number.EPSILON&&(re=!0):Math.sign(U)===Math.sign(G)&&(re=!0),re?(he=-U,ie=Te,ye=Math.sqrt(ee)):(he=Te,ie=U,ye=Math.sqrt(ee/2))}return new se(he/ye,ie/ye)}let ne=[];for(let X=0,de=H.length,Z=de-1,he=X+1;X<de;X++,Z++,he++)Z===de&&(Z=0),he===de&&(he=0),ne[X]=B(H[X],H[Z],H[he]);let ce=[],Me,fe=ne.concat();for(let X=0,de=P.length;X<de;X++){let Z=P[X];Me=[];for(let he=0,ie=Z.length,ye=ie-1,Te=he+1;he<ie;he++,ye++,Te++)ye===ie&&(ye=0),Te===ie&&(Te=0),Me[he]=B(Z[he],Z[ye],Z[Te]);ce.push(Me),fe=fe.concat(Me)}for(let X=0;X<g;X++){let de=X/g,Z=f*Math.cos(de*Math.PI/2),he=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ye=H.length;ie<ye;ie++){let Te=W(H[ie],ne[ie],he);ue(Te.x,Te.y,-Z)}for(let ie=0,ye=P.length;ie<ye;ie++){let Te=P[ie];Me=ce[ie];for(let U=0,T=Te.length;U<T;U++){let G=W(Te[U],Me[U],he);ue(G.x,G.y,-Z)}}}let $e=p+y;for(let X=0;X<J;X++){let de=h?W(S[X],fe[X],$e):S[X];w?(R.copy(N.normals[0]).multiplyScalar(de.x),C.copy(N.binormals[0]).multiplyScalar(de.y),F.copy(v[0]).add(R).add(C),ue(F.x,F.y,F.z)):ue(de.x,de.y,0)}for(let X=1;X<=u;X++)for(let de=0;de<J;de++){let Z=h?W(S[de],fe[de],$e):S[de];w?(R.copy(N.normals[X]).multiplyScalar(Z.x),C.copy(N.binormals[X]).multiplyScalar(Z.y),F.copy(v[X]).add(R).add(C),ue(F.x,F.y,F.z)):ue(Z.x,Z.y,d/u*X)}for(let X=g-1;X>=0;X--){let de=X/g,Z=f*Math.cos(de*Math.PI/2),he=p*Math.sin(de*Math.PI/2)+y;for(let ie=0,ye=H.length;ie<ye;ie++){let Te=W(H[ie],ne[ie],he);ue(Te.x,Te.y,d+Z)}for(let ie=0,ye=P.length;ie<ye;ie++){let Te=P[ie];Me=ce[ie];for(let U=0,T=Te.length;U<T;U++){let G=W(Te[U],Me[U],he);w?ue(G.x,G.y+v[u-1].y,v[u-1].x+Z):ue(G.x,G.y,d+Z)}}}Y(),me();function Y(){let X=r.length/3;if(h){let de=0,Z=J*de;for(let he=0;he<ae;he++){let ie=O[he];Pe(ie[2]+Z,ie[1]+Z,ie[0]+Z)}de=u+g*2,Z=J*de;for(let he=0;he<ae;he++){let ie=O[he];Pe(ie[0]+Z,ie[1]+Z,ie[2]+Z)}}else{for(let de=0;de<ae;de++){let Z=O[de];Pe(Z[2],Z[1],Z[0])}for(let de=0;de<ae;de++){let Z=O[de];Pe(Z[0]+J*u,Z[1]+J*u,Z[2]+J*u)}}i.addGroup(X,r.length/3-X,0)}function me(){let X=r.length/3,de=0;te(H,de),de+=H.length;for(let Z=0,he=P.length;Z<he;Z++){let ie=P[Z];te(ie,de),de+=ie.length}i.addGroup(X,r.length/3-X,1)}function te(X,de){let Z=X.length;for(;--Z>=0;){let he=Z,ie=Z-1;ie<0&&(ie=X.length-1);for(let ye=0,Te=u+g*2;ye<Te;ye++){let U=J*ye,T=J*(ye+1),G=de+he+U,ee=de+ie+U,oe=de+ie+T,re=de+he+T;_e(G,ee,oe,re)}}}function ue(X,de,Z){c.push(X),c.push(de),c.push(Z)}function Pe(X,de,Z){z(X),z(de),z(Z);let he=r.length/3,ie=x.generateTopUV(i,r,he-3,he-2,he-1);Be(ie[0]),Be(ie[1]),Be(ie[2])}function _e(X,de,Z,he){z(X),z(de),z(he),z(de),z(Z),z(he);let ie=r.length/3,ye=x.generateSideWallUV(i,r,ie-6,ie-3,ie-2,ie-1);Be(ye[0]),Be(ye[1]),Be(ye[3]),Be(ye[1]),Be(ye[2]),Be(ye[3])}function z(X){r.push(c[X*3+0]),r.push(c[X*3+1]),r.push(c[X*3+2])}function Be(X){s.push(X.x),s.push(X.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return KI(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Yl[r.type]().fromJSON(r)),new n(i,e.options)}},JI={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new se(s,o),new se(a,c),new se(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],d=e[i*3+2],h=e[r*3],f=e[r*3+1],p=e[r*3+2],y=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new se(o,1-c),new se(l,1-d),new se(h,1-p),new se(y,1-m)]:[new se(a,1-c),new se(u,1-d),new se(f,1-p),new se(g,1-m)]}};iu=class n extends Yi{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Aa=class n extends Yi{constructor(e=1,t=0){let i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},ru=class n extends et{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],d=e,h=(t-e)/r,f=new D,p=new se;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let m=s+g/i*o;f.x=d*Math.cos(m),f.y=d*Math.sin(m),c.push(f.x,f.y,f.z),l.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,u.push(p.x,p.y)}d+=h}for(let y=0;y<r;y++){let g=y*(i+1);for(let m=0;m<i;m++){let x=m+g,v=x,w=x+i+1,N=x+i+2,C=x+1;a.push(v,w,C),a.push(w,N,C)}}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},su=class n extends et{constructor(e=new vi([new se(0,.5),new se(-.5,-.5),new se(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(o,2));function l(u){let d=r.length/3,h=u.extractPoints(t),f=h.shape,p=h.holes;Xn.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,m=p.length;g<m;g++){let x=p[g];Xn.isClockWise(x)===!0&&(p[g]=x.reverse())}let y=Xn.triangulateShape(f,p);for(let g=0,m=p.length;g<m;g++){let x=p[g];f=f.concat(x)}for(let g=0,m=f.length;g<m;g++){let x=f[g];r.push(x.x,x.y,0),s.push(0,0,1),o.push(x.x,x.y)}for(let g=0,m=y.length;g<m;g++){let x=y[g],v=x[0]+d,w=x[1]+d,N=x[2]+d;i.push(v,w,N),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return QI(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Ta=class n extends et{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],d=new D,h=new D,f=[],p=[],y=[],g=[];for(let m=0;m<=i;m++){let x=[],v=m/i,w=0;m===0&&o===0?w=.5/t:m===i&&c===Math.PI&&(w=-.5/t);for(let N=0;N<=t;N++){let C=N/t;d.x=-e*Math.cos(r+C*s)*Math.sin(o+v*a),d.y=e*Math.cos(o+v*a),d.z=e*Math.sin(r+C*s)*Math.sin(o+v*a),p.push(d.x,d.y,d.z),h.copy(d).normalize(),y.push(h.x,h.y,h.z),g.push(C+w,1-v),x.push(l++)}u.push(x)}for(let m=0;m<i;m++)for(let x=0;x<t;x++){let v=u[m][x+1],w=u[m][x],N=u[m+1][x],C=u[m+1][x+1];(m!==0||o>0)&&f.push(v,w,C),(m!==i-1||c<Math.PI)&&f.push(w,N,C)}this.setIndex(f),this.setAttribute("position",new De(p,3)),this.setAttribute("normal",new De(y,3)),this.setAttribute("uv",new De(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},ou=class n extends Yi{constructor(e=1,t=0){let i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},au=class n extends et{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new D,d=new D,h=new D;for(let f=0;f<=i;f++)for(let p=0;p<=r;p++){let y=p/r*s,g=f/i*Math.PI*2;d.x=(e+t*Math.cos(g))*Math.cos(y),d.y=(e+t*Math.cos(g))*Math.sin(y),d.z=t*Math.sin(g),a.push(d.x,d.y,d.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),h.subVectors(d,u).normalize(),c.push(h.x,h.y,h.z),l.push(p/r),l.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=r;p++){let y=(r+1)*f+p-1,g=(r+1)*(f-1)+p-1,m=(r+1)*(f-1)+p,x=(r+1)*f+p;o.push(y,g,x),o.push(g,m,x)}this.setIndex(o),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},cu=class n extends et{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],d=new D,h=new D,f=new D,p=new D,y=new D,g=new D,m=new D;for(let v=0;v<=i;++v){let w=v/i*s*Math.PI*2;x(w,s,o,e,f),x(w+.01,s,o,e,p),g.subVectors(p,f),m.addVectors(p,f),y.crossVectors(g,m),m.crossVectors(y,g),y.normalize(),m.normalize();for(let N=0;N<=r;++N){let C=N/r*Math.PI*2,R=-t*Math.cos(C),F=t*Math.sin(C);d.x=f.x+(R*m.x+F*y.x),d.y=f.y+(R*m.y+F*y.y),d.z=f.z+(R*m.z+F*y.z),c.push(d.x,d.y,d.z),h.subVectors(d,f).normalize(),l.push(h.x,h.y,h.z),u.push(v/i),u.push(N/r)}}for(let v=1;v<=i;v++)for(let w=1;w<=r;w++){let N=(r+1)*(v-1)+(w-1),C=(r+1)*v+(w-1),R=(r+1)*v+w,F=(r+1)*(v-1)+w;a.push(N,C,F),a.push(C,R,F)}this.setIndex(a),this.setAttribute("position",new De(c,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(u,2));function x(v,w,N,C,R){let F=Math.cos(v),A=Math.sin(v),S=N/w*v,P=Math.cos(S);R.x=C*(2+P)*.5*F,R.y=C*(2+P)*A*.5,R.z=C*Math.sin(S)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},lu=class n extends et{constructor(e=new ba(new D(-1,-1,0),new D(-1,1,0),new D(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new D,c=new D,l=new se,u=new D,d=[],h=[],f=[],p=[];y(),this.setIndex(p),this.setAttribute("position",new De(d,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(f,2));function y(){for(let v=0;v<t;v++)g(v);g(s===!1?t:0),x(),m()}function g(v){u=e.getPointAt(v/t,u);let w=o.normals[v],N=o.binormals[v];for(let C=0;C<=r;C++){let R=C/r*Math.PI*2,F=Math.sin(R),A=-Math.cos(R);c.x=A*w.x+F*N.x,c.y=A*w.y+F*N.y,c.z=A*w.z+F*N.z,c.normalize(),h.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,d.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=t;v++)for(let w=1;w<=r;w++){let N=(r+1)*(v-1)+(w-1),C=(r+1)*v+(w-1),R=(r+1)*v+w,F=(r+1)*(v-1)+w;p.push(N,C,F),p.push(C,R,F)}}function x(){for(let v=0;v<=t;v++)for(let w=0;w<=r;w++)l.x=v/t,l.y=w/r,f.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Yl[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},uu=class extends et{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new D,s=new D;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let d=c[l],h=d.start,f=d.count;for(let p=h,y=h+f;p<y;p+=3)for(let g=0;g<3;g++){let m=a.getX(p+g),x=a.getX(p+(g+1)%3);r.fromBufferAttribute(o,m),s.fromBufferAttribute(o,x),Uy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,d=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,d),Uy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};Ny=Object.freeze({__proto__:null,BoxGeometry:kr,CapsuleGeometry:Jl,CircleGeometry:Kl,ConeGeometry:Ql,CylinderGeometry:Js,DodecahedronGeometry:eu,EdgesGeometry:tu,ExtrudeGeometry:nu,IcosahedronGeometry:iu,LatheGeometry:wa,OctahedronGeometry:Aa,PlaneGeometry:Ws,PolyhedronGeometry:Yi,RingGeometry:ru,ShapeGeometry:su,SphereGeometry:Ta,TetrahedronGeometry:ou,TorusGeometry:au,TorusKnotGeometry:cu,TubeGeometry:lu,WireframeGeometry:uu}),du=class extends Ft{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ie(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},hu=class extends pn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ia=class extends Ft{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},fu=class extends Ia{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new se(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Mt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},pu=class extends Ft{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ie(16777215),this.specular=new Ie(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},mu=class extends Ft{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ie(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},gu=class extends Ft{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},yu=class extends Ft{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fn,this.combine=Ua,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},vu=class extends Ft{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ie(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ji,this.normalScale=new se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},xu=class extends zt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};n2={convertArray:Dr,isTypedArray:Av,getKeyframeOrder:Tv,sortedArray:Tf,flattenJSON:Dp,subclip:e2,makeClipAdditive:t2},jr=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},bu=class extends jr{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Pr,endingEnd:Pr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Lr:s=e,a=2*t-i;break;case ea:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Lr:o=e,c=2*i-t;break;case ea:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,p=(i-t)/(r-t),y=p*p,g=y*p,m=-h*g+2*h*y-h*p,x=(1+h)*g+(-1.5-2*h)*y+(-.5+h)*p+1,v=(-1-f)*g+(1.5+f)*y+.5*p,w=f*g-f*y;for(let N=0;N!==a;++N)s[N]=m*o[u+N]+x*o[l+N]+v*o[c+N]+w*o[d+N];return s}},Ca=class extends jr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),d=1-u;for(let h=0;h!==a;++h)s[h]=o[l+h]*d+o[c+h]*u;return s}},_u=class extends jr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},gn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Dr(t,this.TimeBufferType),this.values=Dr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Dr(e.times,Array),values:Dr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new _u(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ca(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new bu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ko:t=this.InterpolantFactoryMethodDiscrete;break;case Qo:t=this.InterpolantFactoryMethodLinear;break;case Sl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ko;case this.InterpolantFactoryMethodLinear:return Qo;case this.InterpolantFactoryMethodSmooth:return Sl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Av(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Sl,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let d=a*i,h=d-i,f=d+i;for(let p=0;p!==i;++p){let y=t[d+p];if(y!==t[h+p]||y!==t[f+p]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let d=a*i,h=o*i;for(let f=0;f!==i;++f)t[h+f]=t[d+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};gn.prototype.TimeBufferType=Float32Array;gn.prototype.ValueBufferType=Float32Array;gn.prototype.DefaultInterpolation=Qo;wi=class extends gn{};wi.prototype.ValueTypeName="bool";wi.prototype.ValueBufferType=Array;wi.prototype.DefaultInterpolation=Ko;wi.prototype.InterpolantFactoryMethodLinear=void 0;wi.prototype.InterpolantFactoryMethodSmooth=void 0;Ra=class extends gn{};Ra.prototype.ValueTypeName="color";Gr=class extends gn{};Gr.prototype.ValueTypeName="number";wu=class extends jr{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Zt.slerpFlat(s,0,o,l-a,o,l,c);return s}},Zi=class extends gn{InterpolantFactoryMethodLinear(e){return new wu(this.times,this.values,this.getValueSize(),e)}};Zi.prototype.ValueTypeName="quaternion";Zi.prototype.DefaultInterpolation=Qo;Zi.prototype.InterpolantFactoryMethodSmooth=void 0;Mi=class extends gn{};Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=Ko;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;Wr=class extends gn{};Wr.prototype.ValueTypeName="vector";Xr=class{constructor(e="",t=-1,i=[],r=Bu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=dn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(r2(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(gn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Tv(c);c=Tf(c,1,u),l=Tf(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new Gr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let d=u[1],h=r[d];h||(r[d]=h=[]),h.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(d,h,f,p,y){if(f.length!==0){let g=[],m=[];Dp(f,g,m,p),g.length!==0&&y.push(new d(h,g,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let d=0;d<l.length;d++){let h=l[d].keys;if(!(!h||h.length===0))if(h[0].morphTargets){let f={},p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let y=0;y<h[p].morphTargets.length;y++)f[h[p].morphTargets[y]]=-1;for(let y in f){let g=[],m=[];for(let x=0;x!==h[p].morphTargets.length;++x){let v=h[p];g.push(v.time),m.push(v.morphTarget===y?1:0)}r.push(new Gr(".morphTargetInfluence["+y+"]",g,m))}c=f.length*o}else{let f=".bones["+t[d].name+"]";i(Wr,f+".position",h,"pos",r),i(Zi,f+".quaternion",h,"rot",r),i(Wr,f+".scale",h,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};mi={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}},Pa=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,d){return l.push(u,d),this},this.removeHandler=function(u){let d=l.indexOf(u);return d!==-1&&l.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=l.length;d<h;d+=2){let f=l[d],p=l[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},Iv=new Pa,Jt=class{constructor(e){this.manager=e!==void 0?e:Iv,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};Jt.DEFAULT_MATERIAL_NAME="__DEFAULT";ui={},If=class extends Error{constructor(e,t){super(e),this.response=t}},Nn=class extends Jt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=mi.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ui[e]!==void 0){ui[e].push({onLoad:t,onProgress:i,onError:r});return}ui[e]=[],ui[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=ui[e],d=l.body.getReader(),h=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=h?parseInt(h):0,p=f!==0,y=0,g=new ReadableStream({start(m){x();function x(){d.read().then(({done:v,value:w})=>{if(v)m.close();else{y+=w.byteLength;let N=new ProgressEvent("progress",{lengthComputable:p,loaded:y,total:f});for(let C=0,R=u.length;C<R;C++){let F=u[C];F.onProgress&&F.onProgress(N)}m.enqueue(w),x()}})}}});return new Response(g)}else throw new If(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),h=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(h);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{mi.add(e,l);let u=ui[e];delete ui[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onLoad&&f.onLoad(l)}}).catch(l=>{let u=ui[e];if(u===void 0)throw this.manager.itemError(e),l;delete ui[e];for(let d=0,h=u.length;d<h;d++){let f=u[d];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Cf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Nn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=Xr.parse(e[i]);t.push(r)}return t}},Rf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new Ys,c=new Nn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(d){c.load(e[d],function(h){let f=s.parse(h,!0);o[d]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},l+=1,l===6&&(f.mipmapCount===1&&(a.minFilter=It),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let d=0,h=e.length;d<h;++d)u(d);else c.load(e,function(d){let h=s.parse(d,!0);if(h.isCubemap){let f=h.mipmaps.length/h.mipmapCount;for(let p=0;p<f;p++){o[p]={mipmaps:[]};for(let y=0;y<h.mipmapCount;y++)o[p].mipmaps.push(h.mipmaps[p*h.mipmapCount+y]),o[p].format=h.format,o[p].width=h.width,o[p].height=h.height}a.image=o}else a.image.width=h.width,a.image.height=h.height,a.mipmaps=h.mipmaps;h.mipmapCount===1&&(a.minFilter=It),a.format=h.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},qr=class extends Jt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=mi.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=oa("img");function c(){u(),mi.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(d){u(),r&&r(d),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},Pf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Br;s.colorSpace=Mn;let o=new qr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Lf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Wn,a=new Nn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Sn,o.wrapT=l.wrapT!==void 0?l.wrapT:Sn,o.magFilter=l.magFilter!==void 0?l.magFilter:It,o.minFilter=l.minFilter!==void 0?l.minFilter:It,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=jn),l.mipmapCount===1&&(o.minFilter=It),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},Df=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=new Ct,o=new qr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Zn=class extends ct{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},Mu=class extends Zn{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ie(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},yh=new Ve,Fy=new D,ky=new D,La=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new se(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zr,this._frameExtents=new se(1,1),this._viewportCount=1,this._viewports=[new ht(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;Fy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Fy),ky.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ky),t.updateMatrixWorld(),yh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yh),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(yh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Of=class extends La{constructor(){super(new Rt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Vs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Su=class extends Zn{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Of}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},By=new Ve,Bo=new D,vh=new D,Uf=class extends La{constructor(){super(new Rt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new se(4,2),this._viewportCount=6,this._viewports=[new ht(2,1,1,1),new ht(0,1,1,1),new ht(3,1,1,1),new ht(1,1,1,1),new ht(3,0,1,1),new ht(1,0,1,1)],this._cubeDirections=[new D(1,0,0),new D(-1,0,0),new D(0,0,1),new D(0,0,-1),new D(0,1,0),new D(0,-1,0)],this._cubeUps=[new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,0,1),new D(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Bo.setFromMatrixPosition(e.matrixWorld),i.position.copy(Bo),vh.copy(i.position),vh.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(vh),i.updateMatrixWorld(),r.makeTranslation(-Bo.x,-Bo.y,-Bo.z),By.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(By)}},Eu=class extends Zn{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Uf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Nf=class extends La{constructor(){super(new Xs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Au=class extends Zn{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DEFAULT_UP),this.updateMatrix(),this.target=new ct,this.shadow=new Nf}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Tu=class extends Zn{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},Iu=class extends Zn{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},Cu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new D)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}},Ru=class extends Zn{constructor(e=new Cu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},Pu=class n extends Jt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Nn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ie().setHex(o.value);break;case"v2":r.uniforms[s].value=new se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new D().fromArray(o.value);break;case"v4":r.uniforms[s].value=new ht().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ze().fromArray(o.value);break;case"m4":r.uniforms[s].value=new Ve().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new se().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new se().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){let t={ShadowMaterial:du,SpriteMaterial:pa,RawShaderMaterial:hu,ShaderMaterial:pn,PointsMaterial:ga,MeshPhysicalMaterial:fu,MeshStandardMaterial:Ia,MeshPhongMaterial:pu,MeshToonMaterial:mu,MeshNormalMaterial:gu,MeshLambertMaterial:yu,MeshDepthMaterial:ha,MeshDistanceMaterial:fa,MeshBasicMaterial:qn,MeshMatcapMaterial:vu,LineDashedMaterial:xu,LineBasicMaterial:zt,Material:Ft};return new t[e]}},Da=class{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},Lu=class extends et{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Du=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Nn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(f,p){if(t[p]!==void 0)return t[p];let g=f.interleavedBuffers[p],m=s(f,g.buffer),x=Us(g.type,m),v=new qs(x,g.stride);return v.uuid=g.uuid,t[p]=v,v}function s(f,p){if(i[p]!==void 0)return i[p];let g=f.arrayBuffers[p],m=new Uint32Array(g).buffer;return i[p]=m,m}let o=e.isInstancedBufferGeometry?new Lu:new et,a=e.data.index;if(a!==void 0){let f=Us(a.type,a.array);o.setIndex(new ot(f,1))}let c=e.data.attributes;for(let f in c){let p=c[f],y;if(p.isInterleavedBufferAttribute){let g=r(e.data,p.data);y=new Vr(g,p.itemSize,p.offset,p.normalized)}else{let g=Us(p.type,p.array),m=p.isInstancedBufferAttribute?qi:ot;y=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(y.name=p.name),p.usage!==void 0&&y.setUsage(p.usage),o.setAttribute(f,y)}let l=e.data.morphAttributes;if(l)for(let f in l){let p=l[f],y=[];for(let g=0,m=p.length;g<m;g++){let x=p[g],v;if(x.isInterleavedBufferAttribute){let w=r(e.data,x.data);v=new Vr(w,x.itemSize,x.offset,x.normalized)}else{let w=Us(x.type,x.array);v=new ot(w,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),y.push(v)}o.morphAttributes[f]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let f=0,p=d.length;f!==p;++f){let y=d[f];o.addGroup(y.start,y.count,y.materialIndex)}let h=e.data.boundingSphere;if(h!==void 0){let f=new D;h.center!==void 0&&f.fromArray(h.center),o.boundingSphere=new Nt(f,h.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Ff=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?Da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Nn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(d){r!==void 0&&r(d),console.error("THREE:ObjectLoader: Can't parse "+e+".",d.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?Da.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Nn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let d=!1;for(let h in o)if(o[h].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new vi().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new kl().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new Du;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Ny?a=Ny[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new Pu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=Xr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Us(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new Pa(t);s=new qr(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let d=e[l],h=d.url;if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new Wn(m.data,m.width,m.height)))}r[d.uuid]=new fi(f)}else{let f=a(d.url);r[d.uuid]=new fi(f)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Us(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new qr(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let d=0,h=l.length;d<h;d++){let f=l[d],p=await s(f);p!==null&&(p instanceof HTMLImageElement?u.push(p):u.push(new Wn(p.data,p.width,p.height)))}i[c.uuid]=new fi(u)}else{let u=await s(c.url);i[c.uuid]=new fi(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Br,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Wn:u=new Ct,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,s2)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],zy),u.wrapT=i(a.wrap[1],zy)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,Vy)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Vy)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(h){return t[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",h),t[h]}function c(h){if(h!==void 0){if(Array.isArray(h)){let f=[];for(let p=0,y=h.length;p<y;p++){let g=h[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",h),i[h]}}function l(h){return r[h]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",h),r[h]}let u,d;switch(e.type){case"Scene":o=new Ol,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ie(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Dl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Ll(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new Rt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Xs(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Tu(e.color,e.intensity);break;case"DirectionalLight":o=new Au(e.color,e.intensity);break;case"PointLight":o=new Eu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Iu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Su(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Mu(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Ru().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),d=c(e.material),o=new Fl(u,d),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),d=c(e.material),o=new St(u,d);break;case"InstancedMesh":u=a(e.geometry),d=c(e.material);let h=e.count,f=e.instanceMatrix,p=e.instanceColor;o=new Bl(u,d,h),o.instanceMatrix=new qi(new Float32Array(f.array),16),p!==void 0&&(o.instanceColor=new qi(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":u=a(e.geometry),d=c(e.material),o=new zl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,d),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new Bt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let m=new Nt;return m.radius=y.sphereRadius,m.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Nl;break;case"Line":o=new Yn(a(e.geometry),c(e.material));break;case"LineLoop":o=new Hl(a(e.geometry),c(e.material));break;case"LineSegments":o=new An(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new jl(a(e.geometry),c(e.material));break;case"Sprite":o=new Ul(c(e.material));break;case"Group":o=new Gi;break;case"Bone":o=new ma;break;default:o=new ct}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let h=e.children;for(let f=0;f<h.length;f++)o.add(this.parseObject(h[f],t,i,r,s))}if(e.animations!==void 0){let h=e.animations;for(let f=0;f<h.length;f++){let p=h[f];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let h=e.levels;for(let f=0;f<h.length;f++){let p=h[f],y=o.getObjectByProperty("uuid",p.object);y!==void 0&&o.addLevel(y,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},s2={UVMapping:ku,CubeReflectionMapping:bi,CubeRefractionMapping:Wi,EquirectangularReflectionMapping:qo,EquirectangularRefractionMapping:Yo,CubeUVReflectionMapping:Ks},zy={RepeatWrapping:Zo,ClampToEdgeWrapping:Sn,MirroredRepeatWrapping:Jo},Vy={NearestFilter:Ut,NearestMipmapNearestFilter:xp,NearestMipmapLinearFilter:Os,LinearFilter:It,LinearMipmapNearestFilter:$o,LinearMipmapLinearFilter:jn},kf=class extends Jt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=mi.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return mi.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),mi.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});mi.add(e,c),s.manager.itemStart(e)}},Oa=class{static getContext(){return hl===void 0&&(hl=new(window.AudioContext||window.webkitAudioContext)),hl}static setContext(e){hl=e}},Bf=class extends Jt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Nn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Oa.getContext().decodeAudioData(l,function(d){t(d)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},$y=new Ve,Hy=new Ve,Mr=new Ve,zf=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Rt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Rt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Mr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Nr*t.fov*.5)/t.zoom,a,c;Hy.elements[12]=-r,$y.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Mr.elements[0]=2*t.near/(c-a),Mr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Mr),a=-o*t.aspect-s,c=o*t.aspect-s,Mr.elements[0]=2*t.near/(c-a),Mr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Mr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Hy),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply($y)}},Ou=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=jy(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=jy();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};Sr=new D,Gy=new Zt,o2=new D,Er=new D,Vf=class extends ct{constructor(){super(),this.type="AudioListener",this.context=Oa.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ou}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Sr,Gy,o2),Er.set(0,0,-1).applyQuaternion(Gy),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Sr.x,r),t.positionY.linearRampToValueAtTime(Sr.y,r),t.positionZ.linearRampToValueAtTime(Sr.z,r),t.forwardX.linearRampToValueAtTime(Er.x,r),t.forwardY.linearRampToValueAtTime(Er.y,r),t.forwardZ.linearRampToValueAtTime(Er.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Sr.x,Sr.y,Sr.z),t.setOrientation(Er.x,Er.y,Er.z,i.x,i.y,i.z)}},Uu=class extends ct{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},Ar=new D,Wy=new Zt,a2=new D,Tr=new D,$f=class extends Uu{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ar,Wy,a2),Tr.set(0,0,1).applyQuaternion(Wy);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ar.x,i),t.positionY.linearRampToValueAtTime(Ar.y,i),t.positionZ.linearRampToValueAtTime(Ar.z,i),t.orientationX.linearRampToValueAtTime(Tr.x,i),t.orientationY.linearRampToValueAtTime(Tr.y,i),t.orientationZ.linearRampToValueAtTime(Tr.z,i)}else t.setPosition(Ar.x,Ar.y,Ar.z),t.setOrientation(Tr.x,Tr.y,Tr.z)}},Hf=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},Nu=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Zt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Zt.multiplyQuaternionsFlat(e,o,e,t,e,i),Zt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Op="\\[\\]\\.:\\/",c2=new RegExp("["+Op+"]","g"),Up="[^"+Op+"]",l2="[^"+Op.replace("\\.","")+"]",u2=/((?:WC+[\/:])*)/.source.replace("WC",Up),d2=/(WCOD+)?/.source.replace("WCOD",l2),h2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Up),f2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Up),p2=new RegExp("^"+u2+d2+h2+f2+"$"),m2=["material","materials","bones","map"],jf=class{constructor(e,t,i){let r=i||ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},ut=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(c2,"")}static parseTrackName(e){let t=p2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);m2.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ut.Composite=jf;ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ut.prototype.GetterByBindingType=[ut.prototype._getValue_direct,ut.prototype._getValue_array,ut.prototype._getValue_arrayElement,ut.prototype._getValue_toArray];ut.prototype.SetterByBindingTypeAndVersioning=[[ut.prototype._setValue_direct,ut.prototype._setValue_direct_setNeedsUpdate,ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_array,ut.prototype._setValue_array_setNeedsUpdate,ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_arrayElement,ut.prototype._setValue_arrayElement_setNeedsUpdate,ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ut.prototype._setValue_fromArray,ut.prototype._setValue_fromArray_setNeedsUpdate,ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Gf=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=dn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,d=arguments.length;u!==d;++u){let h=arguments[u],f=h.uuid,p=t[f];if(p===void 0){p=c++,t[f]=p,e.push(h);for(let y=0,g=o;y!==g;++y)s[y].push(new ut(h,i[y],r[y]))}else if(p<l){a=e[p];let y=--l,g=e[y];t[g.uuid]=p,e[p]=g,t[f]=y,e[y]=h;for(let m=0,x=o;m!==x;++m){let v=s[m],w=v[y],N=v[p];v[p]=w,N===void 0&&(N=new ut(h,i[m],r[m])),v[y]=N}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[l]=d,e[d]=c;for(let f=0,p=r;f!==p;++f){let y=i[f],g=y[d],m=y[u];y[u]=g,y[d]=m}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,d=t[u];if(d!==void 0)if(delete t[u],d<s){let h=--s,f=e[h],p=--o,y=e[p];t[f.uuid]=d,e[d]=f,t[y.uuid]=h,e[h]=y,e.pop();for(let g=0,m=r;g!==m;++g){let x=i[g],v=x[h],w=x[p];x[d]=v,x[h]=w,x.pop()}}else{let h=--o,f=e[h];h>0&&(t[f.uuid]=d),e[d]=f,e.pop();for(let p=0,y=r;p!==y;++p){let g=i[p];g[d]=g[h],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,d=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let h=u,f=c.length;h!==f;++h){let p=c[h];d[h]=new ut(p,e,t)}return d}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},Fu=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Pr,endingEnd:Pr};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=J0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Ip:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Bu:default:for(let u=0,d=c.length;u!==d;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===K0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Z0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Lr,r.endingEnd=Lr):(e?r.endingStart=this.zeroSlopeAtStart?Lr:Pr:r.endingStart=ea,t?r.endingEnd=this.zeroSlopeAtEnd?Lr:Pr:r.endingEnd=ea)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},g2=new Float32Array(1),Wf=class extends Un{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let d=0;d!==s;++d){let h=r[d],f=h.name,p=u[f];if(p!==void 0)++p.referenceCount,o[d]=p;else{if(p=o[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}let y=t&&t._propertyBindings[d].binding.parsedPath;p=new Nu(ut.create(i,f,y),h.ValueTypeName,h.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),o[d]=p}a[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let d=a.actionByRoot,h=(e._localRoot||this._root).uuid;delete d[h],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Ca(new Float32Array(2),new Float32Array(2),1,g2),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Xr.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Bu),c!==void 0){let d=c.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Fu(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Xr.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=u,t[u]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Xf=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},y2=0,qf=class extends Un{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:y2++}),this.name="",this.usage=ra,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Yf=class extends qs{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},Zf=class{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},Xy=new Ve,Jf=class{constructor(e,t,i=0,r=1/0){this.ray=new Xi(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Hs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Xy.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Xy),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(qy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Kf(e[r],this,i,t);return i.sort(qy),i}};Qf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Mt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},ep=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}},Yy=new se,tp=class{constructor(e=new se(1/0,1/0),t=new se(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Yy.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yy).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Zy=new D,fl=new D,np=class{constructor(e=new D,t=new D){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Zy.subVectors(e,this.start),fl.subVectors(this.end,this.start);let i=fl.dot(fl),s=fl.dot(Zy)/i;return t&&(s=Mt(s,0,1)),s}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},Jy=new D,ip=class extends ct{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new et,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));let s=new zt({fog:!1,toneMapped:!1});this.cone=new An(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Jy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Jy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Hi=new D,pl=new Ve,xh=new Ve,rp=class extends An{constructor(e){let t=Cv(e),i=new et,r=[],s=[],o=new Ie(0,0,1),a=new Ie(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));let c=new zt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");xh.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(pl.multiplyMatrices(xh,a.matrixWorld),Hi.setFromMatrixPosition(pl),r.setXYZ(o,Hi.x,Hi.y,Hi.z),pl.multiplyMatrices(xh,a.parent.matrixWorld),Hi.setFromMatrixPosition(pl),r.setXYZ(o+1,Hi.x,Hi.y,Hi.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};sp=class extends St{constructor(e,t,i){let r=new Ta(t,4,2),s=new qn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},v2=new D,Ky=new Ie,Qy=new Ie,op=class extends ct{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Aa(t);r.rotateY(Math.PI*.5),this.material=new qn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new ot(o,3)),this.add(new St(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Ky.copy(this.light.color),Qy.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?Ky:Qy;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(v2.setFromMatrixPosition(this.light.matrixWorld).negate())}},ap=class extends An{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ie(i),r=new Ie(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let h=0,f=0,p=-a;h<=t;h++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);let y=h===s?i:r;y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3,y.toArray(l,f),f+=3}let u=new et;u.setAttribute("position",new De(c,3)),u.setAttribute("color",new De(l,3));let d=new zt({vertexColors:!0,toneMapped:!1});super(u,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},cp=class extends An{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new Ie(s),o=new Ie(o);let a=[],c=[];if(t>1)for(let d=0;d<t;d++){let h=d/t*(Math.PI*2),f=Math.sin(h)*e,p=Math.cos(h)*e;a.push(0,0,0),a.push(f,0,p);let y=d&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let d=0;d<i;d++){let h=d&1?s:o,f=e-e/i*d;for(let p=0;p<r;p++){let y=p/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f;a.push(g,0,m),c.push(h.r,h.g,h.b),y=(p+1)/r*(Math.PI*2),g=Math.sin(y)*f,m=Math.cos(y)*f,a.push(g,0,m),c.push(h.r,h.g,h.b)}}let l=new et;l.setAttribute("position",new De(a,3)),l.setAttribute("color",new De(c,3));let u=new zt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},e0=new D,ml=new D,t0=new D,lp=class extends ct{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new et;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zt({fog:!1,toneMapped:!1});this.lightPlane=new Yn(r,s),this.add(this.lightPlane),r=new et,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Yn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),e0.setFromMatrixPosition(this.light.matrixWorld),ml.setFromMatrixPosition(this.light.target.matrixWorld),t0.subVectors(ml,e0),this.lightPlane.lookAt(ml),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(ml),this.targetLine.scale.z=t0.length()}},gl=new D,wt=new Gs,up=class extends An{constructor(e){let t=new et,i=new zt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,y){c(p),c(y)}function c(p){r.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Ie(16755200),u=new Ie(16711680),d=new Ie(43775),h=new Ie(16777215),f=new Ie(3355443);this.setColors(l,u,d,h,f)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;wt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),At("c",t,e,wt,0,0,-1),At("t",t,e,wt,0,0,1),At("n1",t,e,wt,-i,-r,-1),At("n2",t,e,wt,i,-r,-1),At("n3",t,e,wt,-i,r,-1),At("n4",t,e,wt,i,r,-1),At("f1",t,e,wt,-i,-r,1),At("f2",t,e,wt,i,-r,1),At("f3",t,e,wt,-i,r,1),At("f4",t,e,wt,i,r,1),At("u1",t,e,wt,i*.7,r*1.1,-1),At("u2",t,e,wt,-i*.7,r*1.1,-1),At("u3",t,e,wt,0,r*2,-1),At("cf1",t,e,wt,-i,0,1),At("cf2",t,e,wt,i,0,1),At("cf3",t,e,wt,0,-r,1),At("cf4",t,e,wt,0,r,1),At("cn1",t,e,wt,-i,0,-1),At("cn2",t,e,wt,i,0,-1),At("cn3",t,e,wt,0,-r,-1),At("cn4",t,e,wt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};yl=new Bt,dp=class extends An{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new et;s.setIndex(new ot(i,1)),s.setAttribute("position",new ot(r,3)),super(s,new zt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&yl.setFromObject(this.object),yl.isEmpty())return;let t=yl.min,i=yl.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},hp=class extends An{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new et;s.setIndex(new ot(i,1)),s.setAttribute("position",new De(r,3)),super(s,new zt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},fp=class extends Yn{constructor(e,t=1,i=16776960){let r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new et;o.setAttribute("position",new De(s,3)),o.computeBoundingSphere(),super(o,new zt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new et;c.setAttribute("position",new De(a,3)),c.computeBoundingSphere(),this.add(new St(c,new qn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},n0=new D,pp=class extends ct{constructor(e=new D(0,0,1),t=new D(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",vl===void 0&&(vl=new et,vl.setAttribute("position",new De([0,0,0,0,1,0],3)),bh=new Js(0,.5,1,5,1),bh.translate(0,-.5,0)),this.position.copy(t),this.line=new Yn(vl,new zt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new St(bh,new qn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{n0.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(n0,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},mp=class extends An{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new et;r.setAttribute("position",new De(t,3)),r.setAttribute("color",new De(i,3));let s=new zt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ie,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},gp=class{constructor(){this.type="ShapePath",this.color=new Ie,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new $r,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){let x=[];for(let v=0,w=m.length;v<w;v++){let N=m[v],C=new vi;C.curves=N.curves,x.push(C)}return x}function i(m,x){let v=x.length,w=!1;for(let N=v-1,C=0;C<v;N=C++){let R=x[N],F=x[C],A=F.x-R.x,S=F.y-R.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(R=x[C],A=-A,F=x[N],S=-S),m.y<R.y||m.y>F.y)continue;if(m.y===R.y){if(m.x===R.x)return!0}else{let P=S*(m.x-R.x)-A*(m.y-R.y);if(P===0)return!0;if(P<0)continue;w=!w}}else{if(m.y!==R.y)continue;if(F.x<=m.x&&m.x<=R.x||R.x<=m.x&&m.x<=F.x)return!0}}return w}let r=Xn.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new vi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let d=[],h=[],f=[],p=0,y;h[p]=void 0,f[p]=[];for(let m=0,x=s.length;m<x;m++)a=s[m],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&h[p]&&p++,h[p]={s:new vi,p:y},h[p].s.curves=a.curves,u&&p++,f[p]=[]):f[p].push({h:a,p:y[0]});if(!h[0])return t(s);if(h.length>1){let m=!1,x=0;for(let v=0,w=h.length;v<w;v++)d[v]=[];for(let v=0,w=h.length;v<w;v++){let N=f[v];for(let C=0;C<N.length;C++){let R=N[C],F=!0;for(let A=0;A<h.length;A++)i(R.p,h[A].p)&&(v!==A&&x++,F?(F=!1,d[A].push(R)):m=!0);F&&d[v].push(R)}}x>0&&m===!1&&(f=d)}let g;for(let m=0,x=h.length;m<x;m++){c=h[m].s,l.push(c),g=f[m];for(let v=0,w=g.length;v<w;v++)c.holes.push(g[v].h)}return l}},yp=class extends hn{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"164"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="164")});var iR={};qp(iR,{createWorldOrbitEditor:()=>ox});var q=class n extends Error{line;column;constructor(e,t,i){let r=t===void 0?"":` (line ${t}${i===void 0?"":`, column ${i}`})`;super(`${e}${r}`),this.name="WorldOrbitError",this.line=t,this.column=i}static fromLocation(e,t){return new n(e,t?.line,t?.column)}};var ao=["system","star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],xn=ao.filter(n=>n!=="system"),xx=["star","planet","moon","asteroid","comet","structure","phenomenon"],Yp=["structure","phenomenon"],Ci=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],bx=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"];function it(n,e){return{key:n,...e}}var Ya=new Set(ao),Zp=new Map([it("orbit",{kind:"string",placement:!0,arity:"single",objectTypes:Ci}),it("distance",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"distance"}),it("semiMajor",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"distance"}),it("eccentricity",{kind:"number",placement:!0,arity:"single",objectTypes:Ci}),it("period",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"duration"}),it("angle",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("inclination",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("phase",{kind:"unit",placement:!0,arity:"single",objectTypes:Ci,unitFamily:"angle"}),it("at",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),it("surface",{kind:"string",placement:!0,arity:"single",objectTypes:Yp}),it("free",{kind:"string",placement:!0,arity:"single",objectTypes:bx}),it("kind",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("class",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("culture",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("tags",{kind:"list",placement:!1,arity:"multiple",objectTypes:ao}),it("color",{kind:"string",placement:!1,arity:"single",objectTypes:ao}),it("image",{kind:"string",placement:!1,arity:"single",objectTypes:xx}),it("hidden",{kind:"boolean",placement:!1,arity:"single",objectTypes:ao}),it("radius",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"radius"}),it("mass",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"mass"}),it("density",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("gravity",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("temperature",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"generic"}),it("albedo",{kind:"number",placement:!1,arity:"single",objectTypes:xn}),it("atmosphere",{kind:"string",placement:!1,arity:"single",objectTypes:["planet","moon","asteroid","comet","phenomenon"]}),it("inner",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),it("outer",{kind:"unit",placement:!1,arity:"single",objectTypes:["belt","ring","phenomenon"],unitFamily:"distance"}),it("view",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("scale",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("units",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("title",{kind:"string",placement:!1,arity:"single",objectTypes:["system"]}),it("on",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("source",{kind:"string",placement:!1,arity:"single",objectTypes:xn}),it("cycle",{kind:"unit",placement:!1,arity:"single",objectTypes:xn,unitFamily:"duration"})].map(n=>[n.key,n])),_x=new Set(Zp.keys());function an(n){return Zp.get(n)}function Jp(n){return _x.has(n)}function Kp(n,e){return n.objectTypes.includes(e)}function Za(n,e){switch(n){case"distance":return e===null||["au","km","m","ly","pc","kpc","re","sol"].includes(e);case"radius":return e===null||["km","m","re","rj","sol"].includes(e);case"mass":return e===null||["me","mj","sol"].includes(e);case"duration":return e===null||["s","min","h","d","y","ky","my","gy"].includes(e);case"angle":return e===null||e==="deg";case"generic":return!0}}function co(n,e={}){let t=[],i=e.columnOffset??0,r="",s=null,o=!1,a=!1,c=null,l=()=>{s!==null&&(t.push({value:r,column:s,quoted:o}),r="",s=null,o=!1)};for(let u=0;u<n.length;u++){let d=n[u],h=i+u+1;if(a&&d==="\\"){let f=n[u+1];if(f==='"'||f==="\\"){r+=f,u++;continue}}if(d==='"'){a?a=!1:(s===null&&(s=h),o=!0,c=h,a=!0);continue}if(!a&&/\s/.test(d)){l();continue}s===null&&(s=h),r+=d}if(a)throw new q("Unclosed quote in line",e.line,c??i+n.length);return l(),t}function Ja(n){return n.match(/^\s*/)?.[0].length??0}function lo(n){let e=n.split(/\r?\n/),t=[],i=null,r=null,s=!1,o=!1,a=null,c=null,l=null,u=null;for(let d=0;d<e.length;d++){let h=e[d],f=d+1;if(!h.trim())continue;let p=Ja(h),y=co(h.slice(p),{line:f,columnOffset:p});if(y.length!==0){if(p===0){if(s=!1,o=!1,a=null,c=null,l=null,u=null,y.length>=1&&y[0].value==="theme"){o=!0,c=0,i={type:"theme",preset:y.length>=2?y[1].value:null,blocks:[],location:{line:f,column:y[0].column}};continue}let g=wx(y,f);t.push(g),r=g;continue}if(o){if(y.length>=2&&y[0].value==="preset"&&(!l||p<=l)){i&&(i.preset=y[1].value);continue}u&&l!==null&&p>l?u.fields.push(Ex(y,f)):(l=p,u={type:"theme-block",target:y[0].value,fields:[],location:{line:f,column:y[0].column}},i?.blocks.push(u));continue}if(!r)throw new q("Indented line without parent object",f,p+1);if(y.length===1&&y[0].value==="info"){s=!0,a=p;continue}s&&p<=(a??0)&&(s=!1),s?r.infoEntries.push(Ax(y,f)):r.blockFields.push(Sx(y,f))}}return{type:"document",theme:i,objects:t}}function wx(n,e){if(n.length<2)throw new q("Invalid object declaration",e,n[0]?.column??1);let[t,i,...r]=n;if(!Ya.has(t.value))throw new q(`Unknown object type "${t.value}"`,e,t.column);return{type:"object",objectType:t.value,name:i.value,inlineFields:Mx(r,e),blockFields:[],infoEntries:[],location:{line:e,column:t.column}}}function Mx(n,e){let t=[],i=0;for(;i<n.length;){let r=n[i],s=an(r.value);if(!s)throw new q(`Unknown field "${r.value}"`,e,r.column);i++;let o=[];if(s.arity==="multiple")for(;i<n.length&&!Jp(n[i].value);)o.push(n[i]),i++;else{let a=n[i];a&&(o.push(a),i++)}if(o.length===0)throw new q(`Missing value for field "${r.value}"`,e,r.column);t.push({type:"field",key:r.value,values:o.map(a=>a.value),location:{line:e,column:r.column}})}return t}function Sx(n,e){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);if(!an(n[0].value))throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function Ex(n,e){if(n.length<2)throw new q("Invalid theme field line",e,n[0]?.column??1);return{type:"field",key:n[0].value,values:n.slice(1).map(t=>t.value),location:{line:e,column:n[0].column}}}function Ax(n,e){if(n.length<2)throw new q("Invalid info entry",e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(t=>t.value).join(" "),location:{line:e,column:n[0].column}}}var Qp=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,Tx=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),Ix=/^[A-Za-z][A-Za-z0-9+.-]*:/;function uo(n){let e=null,t=[],i=n.theme?Cx(n.theme):null;for(let r of n.objects){let s=Px(r);if(r.objectType==="system"){if(e)throw q.fromLocation("Only one system object is allowed",r.location);e=s}else t.push(s)}return{format:"worldorbit",version:"1.0",schemaVersion:"1.0",theme:i,system:e,groups:[],relations:[],events:[],objects:t}}function Cx(n){let e={};for(let t of n.blocks){let i=em(t.fields);e[t.target]=Rx(i)}return{preset:n.preset,styles:e}}function Rx(n){let e={};for(let[t,i]of n.entries()){if(i.values.length===1){let r=i.values[0];if(r==="true"){e[t]=!0;continue}if(r==="false"){e[t]=!1;continue}let s=Number(r);if(!Number.isNaN(s)&&r.trim()!==""){e[t]=s;continue}}e[t]=i.values.join(" ")}return e}function Px(n){let e=[...n.inlineFields,...n.blockFields];Lx(n.objectType,e);let t=em(e),i=Dx(n.objectType,t),r=Ox(t),s=Fx(n.infoEntries);return n.objectType==="system"?{type:"system",id:n.name,title:typeof r.title=="string"?r.title:null,description:null,epoch:null,referencePlane:null,properties:r,info:s}:{type:n.objectType,id:n.name,properties:r,placement:i,info:s}}function Lx(n,e){for(let t of e){let i=an(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(!Kp(i,n))throw q.fromLocation(`Field "${t.key}" is not valid on "${n}"`,t.location);if(i.arity==="single"&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function em(n){let e=new Map;for(let t of n){if(e.has(t.key))throw q.fromLocation(`Duplicate field "${t.key}"`,t.location);e.set(t.key,t)}return e}function Dx(n,e){let t=e.has("orbit"),i=e.has("at"),r=e.has("surface"),s=e.has("free"),o=[t,i,r,s].filter(Boolean).length;if(o>1){let a=e.get("orbit")??e.get("at")??e.get("surface")??e.get("free");throw q.fromLocation("Object has multiple placement modes",a?.location)}if(n==="system"&&o>0)throw q.fromLocation("System objects cannot declare placement",[...e.values()][0]?.location);if(t)return{mode:"orbit",target:Ka(e,"orbit"),distance:es(e,"distance"),semiMajor:es(e,"semiMajor"),eccentricity:zx(e,"eccentricity"),period:es(e,"period"),angle:es(e,"angle"),inclination:es(e,"inclination"),phase:es(e,"phase")};if(i){let a=Qa(e,"at"),c=Ka(e,"at");return{mode:"at",target:c,reference:kx(c,a.location)}}if(r)return{mode:"surface",target:Ka(e,"surface")};if(s){let a=Ka(e,"free"),c=Bx(a);return{mode:"free",distance:c??void 0,descriptor:c?void 0:a}}return null}function Ox(n){let e={};for(let[t,i]of n.entries()){let r=an(t);if(!(!r||r.placement))switch(r.kind){case"list":e[t]=i.values;break;case"boolean":e[t]=Vx(i);break;case"number":e[t]=nm(ts(i),t,i.location);break;case"unit":e[t]=tm(ts(i),i.location,t);break;case"string":e[t]=Ux(t,i);break}}return e}function Ux(n,e){let t=e.values.join(" ").trim();return n==="image"&&Nx(t,e.location),t}function Nx(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(Ix);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function Fx(n){let e={};for(let t of n){if(t.key in e)throw q.fromLocation(`Duplicate info key "${t.key}"`,t.location);e[t.key]=t.value}return e}function kx(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function tm(n,e,t){let i=n.match(Qp);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=an(t);if(s?.unitFamily&&!Za(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function Bx(n){let e=n.match(Qp);return e?{value:Number(e[1]),unit:e[2]??null}:null}function es(n,e){if(!n.has(e))return;let t=Qa(n,e);return tm(ts(t),t.location,e)}function zx(n,e){if(!n.has(e))return;let t=Qa(n,e);return nm(ts(t),e,t.location)}function nm(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Vx(n){let e=ts(n).toLowerCase(),t=Tx.get(e);if(t===void 0)throw q.fromLocation(`Invalid boolean value "${e}" for "${n.key}"`,n.location);return t}function Qa(n,e){let t=n.get(e);if(!t)throw new q(`Missing value for key "${e}"`);return t}function Ka(n,e){return ts(Qa(n,e))}function ts(n){if(n.values.length!==1)throw q.fromLocation(`Field "${n.key}" expects exactly one value`,n.location);return n.values[0]}var $x=new Set(["star","planet","moon","asteroid","comet"]);function ho(n){let e=new Set,t=new Map;for(let i of n.objects){if(e.has(i.id))throw new q(`Duplicate object id "${i.id}"`);e.add(i.id),t.set(i.id,i)}for(let i of n.objects)if(i.placement){if((i.placement.mode==="orbit"||i.placement.mode==="surface")&&!e.has(i.placement.target))throw new q(`Unknown placement target "${i.placement.target}" on "${i.id}"`);if(i.placement.mode==="surface"){let r=t.get(i.placement.target);if(!r||!$x.has(r.type))throw new q(`Surface target "${i.placement.target}" on "${i.id}" is not surface-capable`)}i.placement.mode==="at"&&(i.placement.reference.kind==="lagrange"&&Hx(i,i.placement.reference,e),i.placement.reference.kind==="anchor"&&jx(i,i.placement.reference,e))}}function Hx(n,e,t){if(!t.has(e.primary))throw new q(`Unknown Lagrange reference "${e.primary}" on "${n.id}"`);if(e.secondary&&!t.has(e.secondary))throw new q(`Unknown Lagrange reference "${e.secondary}" on "${n.id}"`)}function jx(n,e,t){if(!t.has(e.objectId))throw new q(`Unknown anchor target "${e.objectId}" on "${n.id}"`)}function lr(n,e,t=`${e}.failed`){return n instanceof q?{code:t,severity:"error",source:e,message:n.message,line:n.line,column:n.column}:n instanceof Error?{code:t,severity:"error",source:e,message:n.message}:{code:t,severity:"error",source:e,message:String(n)}}var fo=1495978707e-1,Gx=6371,Wx=71492,Xx=695700,qx=63241.077,Yx=206264.806,Zx=206264806,lm=.68,Jx=.2,um=28;function Gt(n,e={}){let t=eb(e),i=t.width,r=t.height,s=t.padding,o=Qx(n),a=nb(n,e.projection),c=sd(e.camera??null),l=rd(a,c),u=ab(o),d=sb(o,e.scaleModel,e.bodyScaleMode),h=n.system?.id??null,f=e.activeEventId??null,p=Kx(n.objects,n.events??[],f),y=cb(p,i,r,s,u,d),g=new Map(p.map(te=>[te.id,te])),m=Gb(p,g),x=new Map,v=[],w=[],N=[],C=[],R=[],F=new Map,A=new Map;for(let te of p){let ue=te.placement;if(!ue){N.push(te);continue}if(ue.mode==="orbit"){om(A,ue.target,te);continue}if(ue.mode==="surface"){om(F,ue.target,te);continue}if(ue.mode==="at"){R.push(te);continue}C.push(te)}let S=C.length>0?i*.42:i/2,P=r/2,k={orbitChildren:A,surfaceChildren:F,objectMap:g,spacingFactor:u,projection:l,scaleModel:d,sceneMetricScale:y},O=N.find(te=>te.type==="star")??N[0]??null;O&&nd(O,S,P,0,x,v,w,k);let H=N.filter(te=>te.id!==O?.id);if(H.length>0){let te=Math.min(i,r)*.28*u*d.orbitDistanceMultiplier;H.forEach((ue,Pe)=>{let _e=vo(Pe,H.length,-Math.PI/2),z=xo(_e,te,l,1);nd(ue,S+z.x,P+z.y,0,x,v,w,k)})}C.forEach((te,ue)=>{let Pe=i-s-140-Jb(te.placement?.mode==="free"?te.placement.distance:void 0,d,y),_e=Math.max(76,(r-s*2-180)/Math.max(1,C.length)*u)*d.freePlacementMultiplier,z=s+92+ue*_e;x.set(te.id,{object:te,x:Pe,y:z,radius:rc(te,0,d,y),sortKey:oc(Pe,z,0)}),w.push({object:te,groupId:m.groupIds.get(te.id)??null,x1:Pe-60,y1:z,x2:Pe-18,y2:z,mode:"free"}),nc(te,x,v,w,k,1)}),R.forEach((te,ue)=>{if(x.has(te.id)||!te.placement||te.placement.mode!=="at")return;let Pe=Hb(te.placement.reference,x,g,ue,R.length,i,r,s,k);x.set(te.id,{object:te,x:Pe.x,y:Pe.y,radius:rc(te,2,d,y),sortKey:oc(Pe.x,Pe.y,2),anchorX:Pe.anchorX,anchorY:Pe.anchorY}),Pe.anchorX!==void 0&&Pe.anchorY!==void 0&&w.push({object:te,groupId:m.groupIds.get(te.id)??null,x1:Pe.anchorX,y1:Pe.anchorY,x2:Pe.x,y2:Pe.y,mode:"at"}),nc(te,x,v,w,k,2)});let W=[...x.values()].map(te=>lb(te,d,m)),J=v.map(te=>ub(te,m.groupIds.get(te.object.id)??null)),ae=w.map(te=>db(te)),B=hb(W,i,r,d.labelMultiplier),ne=bb(n,W),ce=_b(n.events??[],W,f),Me=yb(J,ne,ce,ae,W,B),fe=vb(W,J,ae,B,m,d.labelMultiplier),$e=xb(n,W),Y=wb(n,a,t.preset,m,g),me=Ob(i,r,W,J,ae,B,d.labelMultiplier);return{width:i,height:r,padding:s,renderPreset:t.preset,projection:a,renderProjection:l,camera:c,scaleModel:d,title:String(n.system?.title??n.system?.properties.title??n.system?.id??"WorldOrbit")||"WorldOrbit",subtitle:rb(a,l,o,c),systemId:h,viewMode:a,layoutPreset:o,metadata:{format:n.format,version:n.version,view:a,renderProjection:l,scale:String(n.system?.properties.scale??o),units:String(n.system?.properties.units??"mixed"),preset:t.preset??"custom","body.scaleMode":d.bodyScaleMode,...c?.azimuth!==null?{"camera.azimuth":String(c?.azimuth)}:{},...c?.elevation!==null?{"camera.elevation":String(c?.elevation)}:{},...c?.roll!==null?{"camera.roll":String(c?.roll)}:{},...c?.distance!==null?{"camera.distance":String(c?.distance)}:{}},contentBounds:me,layers:Me,groups:fe,semanticGroups:$e,viewpoints:Y,events:ce,activeEventId:f,objects:W,orbitVisuals:J,relations:ne,leaders:ae,labels:B}}function rn(n,e,t){let i=ac(t),r=Math.cos(i),s=Math.sin(i),o=n.x-e.x,a=n.y-e.y;return{x:e.x+o*r-a*s,y:e.y+o*s+a*r}}function Kx(n,e,t){let i=n.map(a=>structuredClone(a));if(!t)return i;let r=e.find(a=>a.id===t);if(!r)return i;let s=new Map(i.map(a=>[a.id,a])),o=new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds,...r.positions.map(a=>a.objectId)]);for(let a of o){let c=s.get(a);c&&(r.epoch&&(c.epoch=r.epoch),r.referencePlane&&(c.referencePlane=r.referencePlane))}for(let a of r.positions){let c=s.get(a.objectId);c&&(a.placement&&(c.placement=structuredClone(a.placement)),a.inner&&(c.properties.inner={...a.inner}),a.outer&&(c.properties.outer={...a.outer}),a.epoch&&(c.epoch=a.epoch),a.referencePlane&&(c.referencePlane=a.referencePlane))}return i}function Qx(n){switch(String(n.system?.properties.scale??"balanced").toLowerCase()){case"compressed":case"compact":return"compact";case"expanded":case"presentation":return"presentation";default:return"balanced"}}function eb(n){let e=tb(n.preset);return{width:n.width??e.width,height:n.height??e.height,padding:n.padding??e.padding,preset:n.preset??null}}function tb(n){switch(n){case"presentation":return{width:1440,height:900,padding:88};case"atlas-card":return{width:960,height:560,padding:56};case"markdown":return{width:920,height:540,padding:48};default:return{width:1200,height:780,padding:72}}}function nb(n,e){if(e==="topdown"||e==="isometric"||e==="orthographic"||e==="perspective")return e;let t=String(n.system?.properties.view??"topdown").toLowerCase();return fm(t)??"topdown"}function rd(n,e){switch(n){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return e&&(e.azimuth!==null||e.elevation!==null||e.roll!==null)?"isometric":"topdown";case"perspective":return"isometric"}}function sd(n){if(!n)return null;let e={azimuth:td(n.azimuth),elevation:td(n.elevation),roll:td(n.roll),distance:ib(n.distance)};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function td(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function ib(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:null}function rb(n,e,t,i){let r=[`${am(n)} view`,`${am(t)} layout`];if(n!==e&&r.push(`2D ${e} fallback`),i){let s=[i.azimuth!==null?`az ${i.azimuth}`:null,i.elevation!==null?`el ${i.elevation}`:null,i.roll!==null?`roll ${i.roll}`:null,i.distance!==null?`dist ${i.distance}`:null].filter(Boolean);s.length>0&&r.push(`camera ${s.join(" / ")}`)}return r.join(" - ")}function sb(n,e,t){return{...ob(n),...t?{bodyScaleMode:t}:{},...e}}function ob(n){switch(n){case"compact":return{orbitDistanceMultiplier:.84,bodyRadiusMultiplier:.92,labelMultiplier:.9,freePlacementMultiplier:.9,ringThicknessMultiplier:.92,minBodyRadius:4,maxBodyRadius:36,bodyScaleMode:"readable"};case"presentation":return{orbitDistanceMultiplier:1.2,bodyRadiusMultiplier:1.18,labelMultiplier:1.08,freePlacementMultiplier:1.05,ringThicknessMultiplier:1.16,minBodyRadius:5,maxBodyRadius:48,bodyScaleMode:"readable"};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,labelMultiplier:1,freePlacementMultiplier:1,ringThicknessMultiplier:1,minBodyRadius:4,maxBodyRadius:40,bodyScaleMode:"readable"}}}function ab(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function cb(n,e,t,i,r,s){let o=[],a=[];for(let f of n){let p=Qb(f);p!==null&&p>0&&a.push(p);let y=f.placement;if(y){if(y.mode==="orbit"){let g=Ri(y.semiMajor??y.distance??null);g!==null&&g>0&&o.push(g);continue}if(y.mode==="free"){let g=Ri(y.distance??null);g!==null&&g>0&&o.push(g)}}}let c=Math.max(...o,0),l=Math.max(...a,0),u=Math.max(c,l*6,0),d=u+Math.max(Math.sqrt(u),l*2,c>0?.25:0);return d<=0?{pixelsPerMetric:null,hasExplicitScale:!1}:{pixelsPerMetric:Math.max(Math.min(e,t)/2-i-24,120)*r*s.orbitDistanceMultiplier/d,hasExplicitScale:!0}}function lb(n,e,t){let{object:i,x:r,y:s,radius:o,sortKey:a,anchorX:c,anchorY:l}=n,u=i.renderHints?.renderPriority??0;return{renderId:ns(i.id),objectId:i.id,object:i,parentId:t.parentIds.get(i.id)??null,ancestorIds:t.ancestorIds.get(i.id)??[],childIds:t.childIds.get(i.id)??[],groupId:t.groupIds.get(i.id)??null,semanticGroupIds:[...i.groups??[]],x:r,y:s,radius:o,visualRadius:Zb(i,o,e),sortKey:a+u*.001,anchorX:c,anchorY:l,label:i.id,secondaryLabel:i.type==="structure"?String(i.properties.kind??i.type):i.type,fillColor:e_(i.properties.color),imageHref:typeof i.properties.image=="string"&&i.properties.image.trim()?i.properties.image:void 0,hidden:i.properties.hidden===!0}}function ub(n,e){return{renderId:`${ns(n.object.id)}-orbit`,objectId:n.object.id,object:n.object,parentId:n.parentId,groupId:e,semanticGroupIds:[...n.object.groups??[]],kind:n.kind,cx:n.cx,cy:n.cy,radius:n.radius,rx:n.rx,ry:n.ry,rotationDeg:n.rotationDeg,band:n.band,bandThickness:n.bandThickness,frontArcPath:n.frontArcPath,backArcPath:n.backArcPath,hidden:n.object.properties.hidden===!0||n.object.renderHints?.renderOrbit===!1}}function db(n){return{renderId:`${ns(n.object.id)}-leader-${n.mode}`,objectId:n.object.id,object:n.object,groupId:n.groupId,semanticGroupIds:[...n.object.groups??[]],x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,mode:n.mode,hidden:n.object.properties.hidden===!0}}function hb(n,e,t,i){let r=[],s=[],o=new Map(n.map(c=>[c.objectId,c])),a=[...n].filter(c=>!c.hidden&&c.object.renderHints?.renderLabel!==!1).sort(fb);for(let c of a){let l=pb(c,o,s,e,t,i)??hm(c,dm(c,o.get(c.parentId??"")??null,t),0,i);s.push(vm(c,l,i)),r.push({renderId:`${c.renderId}-label`,objectId:c.objectId,object:c.object,groupId:c.groupId,semanticGroupIds:[...c.semanticGroupIds],label:c.label,secondaryLabel:c.secondaryLabel,x:l.x,y:l.labelY,secondaryY:l.secondaryY,textAnchor:l.textAnchor,direction:l.direction,hidden:c.hidden})}return r}function fb(n,e){let t=im(n)-im(e);if(t!==0)return t;let i=(e.object.renderHints?.renderPriority??0)-(n.object.renderHints?.renderPriority??0);return i!==0?i:n.sortKey-e.sortKey}function im(n){switch(n.object.type){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":case"ring":return 3;case"asteroid":case"comet":return 4;case"structure":case"phenomenon":return 5}}function pb(n,e,t,i,r,s){for(let o of mb(n,e,i,r)){let a=o==="left"||o==="right"?4:6;for(let c=0;c<=a;c+=1){let l=hm(n,o,c,s),u=vm(n,l,s);if(!t.some(d=>qb(d,u)))return l}}return null}function mb(n,e,t,i){let r=n.parentId?e.get(n.parentId)??null:null,s=dm(n,r,i),o=s==="below"?"above":"below",a=gb(n,r,t),c=a==="right"?"left":"right";return n.object.type==="structure"||n.object.type==="phenomenon"||n.object.placement?.mode==="at"||n.object.placement?.mode==="surface"||n.object.placement?.mode==="free"?[a,s,c,o]:[s,a,o,c]}function dm(n,e,t){return e&&Math.abs(n.y-e.y)>6?n.y>=e.y?"below":"above":n.y>t*.62?"above":"below"}function gb(n,e,t){return e&&Math.abs(n.x-e.x)>6?n.x>=e.x?"right":"left":n.x>=t/2?"right":"left"}function hm(n,e,t,i){let r=14*i;switch(e){case"above":{let s=n.y-(n.radius+18*i+t*r);return{x:n.x,labelY:s,secondaryY:s-16*i,textAnchor:"middle",direction:e}}case"below":{let s=n.y+n.radius+18*i+t*r;return{x:n.x,labelY:s,secondaryY:s+16*i,textAnchor:"middle",direction:e}}case"left":{let s=n.x-(n.visualRadius+16*i+t*r),o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"end",direction:e}}case"right":{let s=n.x+n.visualRadius+16*i+t*r,o=n.y-4*i;return{x:s,labelY:o,secondaryY:o+16*i,textAnchor:"start",direction:e}}}}function yb(n,e,t,i,r,s){let o=n.filter(c=>!c.hidden&&!!c.backArcPath).map(c=>c.renderId),a=n.filter(c=>!c.hidden).map(c=>c.renderId);return[{id:"background",renderIds:["wo-bg","wo-bg-glow","wo-grid"]},{id:"guides",renderIds:i.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"orbits-back",renderIds:o},{id:"orbits-front",renderIds:a},{id:"relations",renderIds:e.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"events",renderIds:t.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"objects",renderIds:r.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"labels",renderIds:s.filter(c=>!c.hidden).map(c=>c.renderId)},{id:"metadata",renderIds:["wo-title","wo-subtitle","wo-meta"]}]}function vb(n,e,t,i,r,s){let o=new Map,a=c=>{if(!c)return null;let l=o.get(c);if(l)return l;let u=r.groupRoots.get(c)??null,d={renderId:c,rootObjectId:u,label:u??c,objectIds:[],orbitIds:[],labelIds:[],leaderIds:[],contentBounds:yo(0,0,0,0)};return o.set(c,d),d};for(let c of n){let l=a(c.groupId);l&&!c.hidden&&l.objectIds.push(c.objectId)}for(let c of e){let l=a(c.groupId);l&&!c.hidden&&l.orbitIds.push(c.objectId)}for(let c of t){let l=a(c.groupId);l&&!c.hidden&&l.leaderIds.push(c.objectId)}for(let c of i){let l=a(c.groupId);l&&!c.hidden&&l.labelIds.push(c.objectId)}for(let c of o.values())c.contentBounds=Wb(c,n,e,t,i,s);return[...o.values()].sort((c,l)=>c.label.localeCompare(l.label))}function xb(n,e){return[...n.groups].map(t=>({id:t.id,label:t.label,summary:t.summary,color:t.color,tags:[...t.tags],hidden:t.hidden,objectIds:e.filter(i=>!i.hidden&&i.semanticGroupIds.includes(t.id)).map(i=>i.objectId)})).sort((t,i)=>t.label.localeCompare(i.label))}function bb(n,e){let t=new Map(e.map(i=>[i.objectId,i]));return n.relations.map(i=>{let r=t.get(i.from),s=t.get(i.to);return{renderId:`${ns(i.id)}-relation`,relationId:i.id,relation:i,fromObjectId:i.from,toObjectId:i.to,x1:r?.x??0,y1:r?.y??0,x2:s?.x??0,y2:s?.y??0,hidden:i.hidden||!r||!s||r.hidden||s.hidden}}).sort((i,r)=>i.relation.id.localeCompare(r.relation.id))}function _b(n,e,t){let i=new Map(e.map(r=>[r.objectId,r]));return n.map(r=>{let s=[...new Set([...r.targetObjectId?[r.targetObjectId]:[],...r.participantObjectIds])],o=s.map(l=>i.get(l)).filter(Boolean),a=o.length>0?o.reduce((l,u)=>l+u.x,0)/o.length:0,c=o.length>0?o.reduce((l,u)=>l+u.y,0)/o.length:0;return{renderId:`${ns(r.id)}-event`,eventId:r.id,event:r,objectIds:s,participantIds:[...r.participantObjectIds],targetObjectId:r.targetObjectId,x:a,y:c,hidden:r.hidden||o.length===0||o.every(l=>l.hidden)||t!==null&&r.id!==t}}).sort((r,s)=>r.event.id.localeCompare(s.event.id))}function wb(n,e,t,i,r){let s=Mb(n,e,t),o=new Map;for(let[l,u]of Object.entries(n.system?.info??{})){if(!l.startsWith("viewpoint."))continue;let[d,h,...f]=l.split(".");if(d!=="viewpoint"||!h||f.length===0)continue;let p=Pb(h);if(!p)continue;let y=f.join(".").toLowerCase(),g=o.get(p)??{id:p};Sb(g,y,u,n,e,t,i,r),o.set(p,g)}let a=[...o.values()].map(l=>Eb(l,e,t,r)).filter(Boolean),c=a.findIndex(l=>l.id===s.id);return c>=0?a.splice(c,1,{...s,...a[c],layers:{...s.layers,...a[c].layers},filter:a[c].filter??s.filter,generated:!1}):a.unshift(s),a.sort((l,u)=>l.id==="overview"?-1:u.id==="overview"?1:l.label.localeCompare(u.label))}function Mb(n,e,t){let i=n.system?.title??n.system?.properties.title,r=i?`${String(i)} Overview`:"Overview",s=sd(null),o=rd(e,s);return{id:"overview",label:r,summary:"Fit the whole system with the current atlas defaults.",objectId:null,selectedObjectId:null,eventIds:[],projection:e,renderProjection:o,camera:s,preset:t,rotationDeg:0,scale:null,layers:{},filter:null,generated:!0}}function Sb(n,e,t,i,r,s,o,a){let c=t.trim();switch(e){case"label":case"title":c&&(n.label=c);return;case"summary":case"description":c&&(n.summary=c);return;case"focus":case"object":c&&(n.focus=c);return;case"select":case"selection":c&&(n.select=c);return;case"events":n.eventIds=go(c);return;case"projection":case"view":n.projection=fm(c)??r;return;case"preset":n.preset=Tb(c)??s;return;case"rotation":case"angle":n.rotationDeg=po(c)??n.rotationDeg??0;return;case"camera.azimuth":n.camera={...n.camera??tc(),azimuth:po(c)};return;case"camera.elevation":n.camera={...n.camera??tc(),elevation:po(c)};return;case"camera.roll":n.camera={...n.camera??tc(),roll:po(c)};return;case"camera.distance":n.camera={...n.camera??tc(),distance:rm(c)};return;case"zoom":case"scale":n.scale=rm(c);return;case"layers":n.layers=Ib(c);return;case"query":n.filter={...n.filter??ec(),query:c||null};return;case"types":case"objecttypes":n.filter={...n.filter??ec(),objectTypes:Cb(c)};return;case"tags":n.filter={...n.filter??ec(),tags:go(c)};return;case"groups":n.filter={...n.filter??ec(),groupIds:Rb(c,i,o,a)};return}}function Eb(n,e,t,i){let r=n.focus&&i.has(n.focus)?n.focus:null,s=n.select&&i.has(n.select)?n.select:r,o=Ab(n.filter),a=n.label?.trim()||Lb(n.id),c=n.projection??e,l=sd(n.camera??null),u=rd(c,l);return{id:n.id,label:a,summary:n.summary?.trim()||Db(a,r,o),objectId:r,selectedObjectId:s,eventIds:[...new Set(n.eventIds??[])],projection:c,renderProjection:u,camera:l,preset:n.preset??t,rotationDeg:n.rotationDeg??0,scale:n.scale??null,layers:n.layers??{},filter:o,generated:!1}}function ec(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function tc(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Ab(n){if(!n)return null;let e={query:n.query?.trim()||null,objectTypes:[...new Set(n.objectTypes)],tags:[...new Set(n.tags)],groupIds:[...new Set(n.groupIds)]};return e.query||e.objectTypes.length>0||e.tags.length>0||e.groupIds.length>0?e:null}function fm(n){switch(n.toLowerCase()){case"topdown":return"topdown";case"isometric":return"isometric";case"orthographic":return"orthographic";case"perspective":return"perspective";default:return null}}function Tb(n){let e=n.toLowerCase();return e==="diagram"||e==="presentation"||e==="atlas-card"||e==="markdown"?e:null}function po(n){let e=Number(n);return Number.isFinite(e)?e:null}function rm(n){let e=po(n);return e!==null&&e>0?e:null}function Ib(n){let e={};for(let t of go(n)){let i=!t.startsWith("-")&&!t.startsWith("!"),r=t.replace(/^[-!]+/,"").toLowerCase();if(r==="orbits"){e["orbits-back"]=i,e["orbits-front"]=i;continue}(r==="background"||r==="guides"||r==="orbits-back"||r==="orbits-front"||r==="relations"||r==="events"||r==="objects"||r==="labels"||r==="metadata")&&(e[r]=i)}return e}function Cb(n){return go(n).filter(e=>e==="star"||e==="planet"||e==="moon"||e==="belt"||e==="asteroid"||e==="comet"||e==="ring"||e==="structure"||e==="phenomenon")}function Rb(n,e,t,i){return go(n).map(r=>e.schemaVersion==="2.1"||e.schemaVersion==="2.5"||e.schemaVersion==="2.6"||e.groups.some(s=>s.id===r)||r.startsWith("wo-")&&r.endsWith("-group")?r:t.groupIds.has(r)?t.groupIds.get(r)??mo(r):(i.has(r),mo(r)))}function go(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Pb(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Lb(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Db(n,e,t){let i=[n];return e&&i.push(`focus ${e}`),t?.objectTypes.length&&i.push(t.objectTypes.join("/")),t?.tags.length&&i.push(`tags ${t.tags.join(", ")}`),t?.query&&i.push(`query "${t.query}"`),i.join(" - ")}function Ob(n,e,t,i,r,s,o){let a=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,d=(h,f)=>{a=Math.min(a,h),c=Math.min(c,f),l=Math.max(l,h),u=Math.max(u,f)};for(let h of i)h.hidden||pm(h,d);for(let h of r)h.hidden||(d(h.x1,h.y1),d(h.x2,h.y2));for(let h of t)h.hidden||mm(h,d);for(let h of s)h.hidden||gm(h,d,o);return!Number.isFinite(a)||!Number.isFinite(c)?yo(0,0,n,e):yo(a,c,l,u)}function pm(n,e){let t=n.bandThickness!==void 0?n.bandThickness/2+4:n.band?10:3;if(n.kind==="circle"&&n.radius!==void 0){e(n.cx-n.radius-t,n.cy-n.radius-t),e(n.cx+n.radius+t,n.cy+n.radius+t);return}let i=n.rx??n.radius??0,r=n.ry??n.radius??0,s=bm(n.cx,n.cy,i,r,n.rotationDeg,0,Math.PI*2,um*2);for(let o of s)e(o.x-t,o.y-t),e(o.x+t,o.y+t)}function yo(n,e,t,i){return{minX:n,minY:e,maxX:t,maxY:i,width:t-n,height:i-e,centerX:n+(t-n)/2,centerY:e+(i-e)/2}}function mm(n,e){e(n.x-n.visualRadius-24,n.y-n.visualRadius-16),e(n.x+n.visualRadius+24,n.y+n.visualRadius+36)}function gm(n,e,t){let i=xm(n.x,n.y,n.secondaryY,n.textAnchor,n.direction,n.label,n.secondaryLabel,t);e(i.left,i.top),e(i.right,i.bottom)}function nd(n,e,t,i,r,s,o,a){r.has(n.id)||(r.set(n.id,{object:n,x:e,y:t,radius:rc(n,i,a.scaleModel,a.sceneMetricScale),sortKey:oc(e,t,i)}),nc(n,r,s,o,a,i+1))}function nc(n,e,t,i,r,s){let o=e.get(n.id);if(!o)return;let a=[...r.orbitChildren.get(n.id)??[]].sort(Ub),c=Nb(a,o.radius,r.spacingFactor,r.scaleModel,r.sceneMetricScale),l=Bb(a,c);a.forEach((d,h)=>{let f=Fb(d,h,a.length,o,c,l[h]??c.innerPx,r);t.push({object:d,parentId:n.id,kind:f.kind,cx:f.cx,cy:f.cy,radius:f.radius,rx:f.rx,ry:f.ry,rotationDeg:f.rotationDeg,band:f.band,bandThickness:f.bandThickness,frontArcPath:f.frontArcPath,backArcPath:f.backArcPath}),nd(d,f.objectX,f.objectY,s,e,t,i,r)});let u=[...r.surfaceChildren.get(n.id)??[]];u.forEach((d,h)=>{let f=vo(h,u.length,-Math.PI/3),p=28*r.spacingFactor,y=xo(f,o.radius,r.projection,r.projection==="isometric"?.9:1),g=xo(f,o.radius+p,r.projection,r.projection==="isometric"?.9:1),m=o.x+y.x,x=o.y+y.y,v=o.x+g.x,w=o.y+g.y;e.set(d.id,{object:d,x:v,y:w,radius:rc(d,s+1,r.scaleModel,r.sceneMetricScale),sortKey:oc(v,w,s+1),anchorX:m,anchorY:x}),i.push({object:d,groupId:r.objectMap.has(d.id)?mo(Xb(d,r.objectMap)):null,x1:m,y1:x,x2:v,y2:w,mode:"surface"}),nc(d,e,t,i,r,s+1)})}function Ub(n,e){let t=ic(n),i=ic(e);return t!==null&&i!==null&&t!==i?t-i:t!==null&&i===null?-1:t===null&&i!==null?1:n.id.localeCompare(e.id)}function Nb(n,e,t,i,r){let s=n.map(f=>ic(f)),o=s.filter(f=>f!==null),a=i.bodyScaleMode==="strict"?Math.max(2,8*t*i.orbitDistanceMultiplier):(n.length>2?54:64)*t*i.orbitDistanceMultiplier*.42,c=e+Math.max(a*1.2,24*t),l=(n.length>2?54:64)*t*i.orbitDistanceMultiplier;if(o.length===0)return{metrics:s,minMetric:0,maxMetric:0,metricSpread:0,innerPx:c,stepPx:l,pixelSpread:Math.max(l*Math.max(n.length-1,1),l),minimumGapPx:a,pixelsPerMetric:r.pixelsPerMetric};let u=Math.min(...o),d=Math.max(...o),h=d-u;return{metrics:s,minMetric:u,maxMetric:d,metricSpread:h,innerPx:c,stepPx:l,pixelSpread:Math.max(l*Math.max(n.length-1,1),l),minimumGapPx:a,pixelsPerMetric:r.pixelsPerMetric}}function Fb(n,e,t,i,r,s,o){let a=n.placement,c=n.type==="belt"||n.type==="ring";if(!a||a.mode!=="orbit"){let F=r.innerPx+e*r.stepPx;return{kind:"circle",cx:i.x,cy:i.y,radius:F,rotationDeg:0,band:c,bandThickness:c?12*o.scaleModel.ringThicknessMultiplier:void 0,objectX:i.x,objectY:i.y-F}}let l=_t(typeof a.eccentricity=="number"?a.eccentricity:0,0,.92),u=s,d=Math.max(u*Math.sqrt(1-l*l),u*.18),h=id(a.inclination)??0,f=o.projection==="isometric"?Math.max(Jx,Math.cos(ac(h)))*lm:1,p=Math.max(d*f,u*.14),y=id(a.angle)??0,g=u*l,m=wm(-g,0,y),x=i.x+m.x,v=i.y+m.y,w=Vb(a.phase,e,t),N=_m(x,v,u,p,y,w),C=o.projection==="topdown"&&l<=1e-4&&Math.abs(y)<=1e-4,R=c?$b(n,u,r,o.scaleModel):void 0;return{kind:C?"circle":"ellipse",cx:C?i.x:x,cy:C?i.y:v,radius:C?u:void 0,rx:C?void 0:u,ry:C?void 0:p,rotationDeg:y,band:c,bandThickness:R,frontArcPath:o.projection==="isometric"||c?sm(x,v,u,p,y,0,Math.PI):void 0,backArcPath:o.projection==="isometric"||c?sm(x,v,u,p,y,Math.PI,Math.PI*2):void 0,objectX:N.x,objectY:N.y}}function kb(n,e){return e.pixelsPerMetric!==null?n*e.pixelsPerMetric:e.innerPx+e.stepPx*zb(Math.max(n,0)+1)}function Bb(n,e){let t=[];return n.forEach((i,r)=>{let s=ic(i),o=e.innerPx+r*e.stepPx,a=s===null?o:kb(s,e),c=r===0?e.innerPx:(t[r-1]??e.innerPx)+e.minimumGapPx;t.push(Math.max(a,c))}),t}function ic(n){return!n.placement||n.placement.mode!=="orbit"?null:Ri(n.placement.semiMajor??n.placement.distance??null)}function zb(n){return Math.log(n)/Math.log(2)}function Vb(n,e,t){let i=n?id(n):null;return i!==null?ac(i-90):vo(e,t,-Math.PI/2)}function $b(n,e,t,i){let r=Ri(sc(n.properties.inner)),s=Ri(sc(n.properties.outer));if(r!==null&&s!==null){let a=Math.abs(s-r);if(t.pixelsPerMetric!==null){let l=a*t.pixelsPerMetric;return i.bodyScaleMode==="strict"?Math.max(l*i.ringThicknessMultiplier,1):_t(Math.max(l*i.ringThicknessMultiplier,8),8,54)}if(t.metricSpread>0)return _t(a/t.metricSpread*t.pixelSpread*i.ringThicknessMultiplier,8,54);let c=Math.max(Math.max(r,s),1e-4);return _t(a/c*e*.75*i.ringThicknessMultiplier,8,48)}return(n.type==="belt"?18:12)*i.ringThicknessMultiplier}function Hb(n,e,t,i,r,s,o,a,c){if(n.kind==="lagrange")return jb(n,e,t,s,o);if(n.kind==="anchor"){let l=e.get(n.objectId);if(l){let u=vo(i,r,Math.PI/5),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=xo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}if(n.kind==="named"){let l=e.get(n.name);if(l){let u=vo(i,r,Math.PI/6),d=(l.radius+36)*c.scaleModel.labelMultiplier,h=xo(u,d,c.projection,c.projection==="isometric"?.92:1);return{x:l.x+h.x,y:l.y+h.y,anchorX:l.x,anchorY:l.y}}}return{x:s-a-170,y:o-a-86-i*58*c.scaleModel.freePlacementMultiplier}}function jb(n,e,t,i,r){let s=n.secondary?e.get(n.primary):Yb(n.primary,e,t),o=e.get(n.secondary??n.primary);if(!s||!o)return{x:i*.7,y:r*.25};let a=o.x-s.x,c=o.y-s.y,l=Math.hypot(a,c)||1,u=a/l,d=c/l,h=-d,f=u,p=_t(l*.25,24,68);switch(n.point){case"L1":return{x:o.x-u*p,y:o.y-d*p,anchorX:o.x,anchorY:o.y};case"L2":return{x:o.x+u*p,y:o.y+d*p,anchorX:o.x,anchorY:o.y};case"L3":return{x:s.x-u*p,y:s.y-d*p,anchorX:s.x,anchorY:s.y};case"L4":return{x:o.x+(u*.5-h*.8660254)*p,y:o.y+(d*.5-f*.8660254)*p,anchorX:o.x,anchorY:o.y};case"L5":return{x:o.x+(u*.5+h*.8660254)*p,y:o.y+(d*.5+f*.8660254)*p,anchorX:o.x,anchorY:o.y}}}function Gb(n,e){let t=new Map,i=new Map;for(let l of n){let u=ym(l,e);if(t.set(l.id,u),u){let d=i.get(u);d?d.push(l.id):i.set(u,[l.id])}i.has(l.id)||i.set(l.id,[])}let r=new Map,s=new Map,o=new Map,a=l=>{let u=r.get(l);if(u)return u;let d=new Set,h=[],f=t.get(l)??null;for(;f&&!d.has(f);)h.push(f),d.add(f),f=t.get(f)??null;return r.set(l,h),h},c=l=>{let u=o.get(s.get(l)??"");if(u)return u;let d=t.get(l)??null,h=e.get(l),f=l;return h?.placement&&h.placement.mode!=="free"&&d&&(f=c(d)),f};for(let l of n){a(l.id);let u=c(l.id),d=mo(u);s.set(l.id,d),o.set(d,u)}return{parentIds:t,childIds:i,ancestorIds:r,groupIds:s,groupRoots:o}}function ym(n,e){let t=n.placement;if(!t)return null;switch(t.mode){case"orbit":case"surface":return e.has(t.target)?t.target:null;case"at":switch(t.reference.kind){case"anchor":return e.has(t.reference.objectId)?t.reference.objectId:null;case"named":return e.has(t.reference.name)?t.reference.name:null;case"lagrange":return t.reference.secondary&&e.has(t.reference.secondary)?t.reference.secondary:e.has(t.reference.primary)?t.reference.primary:null}case"free":return null}}function Wb(n,e,t,i,r,s){let o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=(d,h)=>{o=Math.min(o,d),a=Math.min(a,h),c=Math.max(c,d),l=Math.max(l,h)};for(let d of e)!d.hidden&&n.objectIds.includes(d.objectId)&&mm(d,u);for(let d of t)!d.hidden&&n.orbitIds.includes(d.objectId)&&pm(d,u);for(let d of i)!d.hidden&&n.leaderIds.includes(d.objectId)&&(u(d.x1,d.y1),u(d.x2,d.y2));for(let d of r)!d.hidden&&n.labelIds.includes(d.objectId)&&gm(d,u,s);return!Number.isFinite(o)||!Number.isFinite(a)?yo(0,0,0,0):yo(o,a,c,l)}function Xb(n,e){let t=n,i=new Set;for(;t.placement&&t.placement.mode!=="free"&&!i.has(t.id);){i.add(t.id);let r=ym(t,e);if(!r)break;let s=e.get(r);if(!s)break;t=s}return t.id}function vm(n,e,t){return xm(e.x,e.labelY,e.secondaryY,e.textAnchor,e.direction,n.label,n.secondaryLabel,t)}function xm(n,e,t,i,r,s,o,a){let c=t_(s,o,a),l=c*2,u=r==="above"?18:12,d=r==="above"?8:12,h=n-c,f=n+c;return i==="start"?(h=n,f=n+l):i==="end"&&(h=n-l,f=n),{left:h,right:f,top:Math.min(e,t)-u,bottom:Math.max(e,t)+d}}function qb(n,e){return!(n.right<e.left||e.right<n.left||n.bottom<e.top||e.bottom<n.top)}function Yb(n,e,t){let i=t.get(n);return!i?.placement||i.placement.mode!=="orbit"?e.get(n):e.get(i.placement.target)}function rc(n,e,t,i){let r=Kb(n.properties.radius,t,i);if(r!==null)return r;let s=t.bodyRadiusMultiplier;switch(n.type){case"star":return _t((e===0?28:20)*s,t.minBodyRadius,t.maxBodyRadius);case"planet":return _t(12*s,t.minBodyRadius,t.maxBodyRadius);case"moon":return _t(7*s,t.minBodyRadius,t.maxBodyRadius);case"belt":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"asteroid":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"comet":return _t(6*s,t.minBodyRadius,t.maxBodyRadius);case"ring":return _t(5*s,t.minBodyRadius,t.maxBodyRadius);case"structure":return _t(6*s,t.minBodyRadius,t.maxBodyRadius);case"phenomenon":return _t(8*s,t.minBodyRadius,t.maxBodyRadius)}}function Zb(n,e,t){let i=typeof n.properties.atmosphere=="string"?4:0;switch(n.type){case"star":return e*2.4;case"phenomenon":return e*1.25;case"structure":return e+2;default:return Math.min(e+i,t.maxBodyRadius+10)}}function Ri(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/fo;case"m":return n.value/1e3/fo;case"ly":return n.value*qx;case"pc":return n.value*Yx;case"kpc":return n.value*Zx;case"re":return n.value*Gx/fo;case"rj":return n.value*Wx/fo;case"sol":return n.value*Xx/fo;default:return n.value}}function Jb(n,e,t){let i=Ri(n??null);if(i===null||i<=0)return 0;if(t.pixelsPerMetric!==null){let r=i*t.pixelsPerMetric*e.freePlacementMultiplier;return e.bodyScaleMode==="strict"?Math.max(r,0):_t(r,0,420)}return _t(i*96*e.freePlacementMultiplier,0,420)}function Kb(n,e,t){let i=sc(n);if(!i)return null;let r=Ri(i);if(t.pixelsPerMetric!==null&&r!==null&&r>0){let o=r*t.pixelsPerMetric*e.bodyRadiusMultiplier;return e.bodyScaleMode==="strict"?Math.max(o,.1):_t(Math.max(o,e.minBodyRadius),e.minBodyRadius,e.maxBodyRadius)}let s;switch(i.unit){case"sol":s=_t(i.value*22,14,40);break;case"re":s=_t(i.value*10,6,18);break;case"km":s=_t(Math.log10(Math.max(i.value,1))*2.6,4,16);break;default:s=_t(i.value*4,4,20);break}return _t(s*e.bodyRadiusMultiplier,e.minBodyRadius,e.maxBodyRadius)}function Qb(n){return Ri(sc(n.properties.radius))}function sc(n){return!n||typeof n!="object"||!("value"in n)?null:n}function id(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function vo(n,e,t){return e<=1?t:t+n*Math.PI*2/e}function sm(n,e,t,i,r,s,o){let a=bm(n,e,t,i,r,s,o,um);return a.length===0?"":a.map((c,l)=>`${l===0?"M":"L"} ${cm(c.x)} ${cm(c.y)}`).join(" ")}function bm(n,e,t,i,r,s,o,a){let c=[];for(let l=0;l<=a;l+=1){let u=s+(o-s)*l/a;c.push(_m(n,e,t,i,r,u))}return c}function _m(n,e,t,i,r,s){let o=t*Math.cos(s),a=i*Math.sin(s),c=wm(o,a,r);return{x:n+c.x,y:e+c.y}}function wm(n,e,t){let i=ac(t);return{x:n*Math.cos(i)-e*Math.sin(i),y:n*Math.sin(i)+e*Math.cos(i)}}function xo(n,e,t,i){let r=t==="isometric"?lm*i:i;return{x:Math.cos(n)*e,y:Math.sin(n)*e*r}}function oc(n,e,t){return e*1e3+n+t*.01}function _t(n,e,t){return Math.min(Math.max(n,e),t)}function om(n,e,t){let i=n.get(e);i?i.push(t):n.set(e,[t])}function ns(n){return`wo-${n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"object"}`}function mo(n){return`${ns(n)}-group`}function e_(n){return typeof n=="string"&&n.trim()?n:void 0}function t_(n,e,t){let i=n.length*4.6*t+18,r=e.length*3.9*t+18;return Math.max(i,r,24)}function am(n){return n.length>0?n[0].toUpperCase()+n.slice(1):n}function ac(n){return n*Math.PI/180}function cm(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var Em=86400,cc=Em*365.25,lc=18,Mm=180;function rs(n,e={}){let t={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,camera:e.camera,scaleModel:e.scaleModel,bodyScaleMode:e.bodyScaleMode,activeEventId:e.activeEventId},i=Gt(n,t),r=s_(i.layoutPreset,e.spatialScaleModel),s={x:i.contentBounds.centerX,y:i.contentBounds.centerY},o=new Map(i.objects.map(y=>[y.objectId,y])),a=new Map(i.orbitVisuals.map(y=>[y.objectId,y])),c=new Map;for(let y of i.objects){let g=y.object.placement;!g||g.mode!=="orbit"||c.set(y.objectId,ad(g))}let l=Math.min(...[...c.values()].filter(y=>Number.isFinite(y)&&y>0))||1,u=new Map,d=i.objects.map(y=>n_(y,i,s,o,a,r,u,l)),h=new Map(d.map(y=>[y.objectId,y])),f=i.orbitVisuals.map(y=>i_(y,h,l,i.activeEventId!==null)),p=d.map(y=>({objectId:y.objectId,center:{...y.position},radius:y.visualRadius+r.focusPadding}));return{width:i.width,height:i.height,padding:i.padding,renderPreset:i.renderPreset,projection:i.projection,camera:i.camera,scaleModel:r,title:i.title,subtitle:i.subtitle,systemId:i.systemId,viewMode:"3d",layoutPreset:i.layoutPreset,metadata:{...i.metadata,"viewer.mode":"3d"},contentBounds:a_(d),semanticGroups:i.semanticGroups,viewpoints:i.viewpoints,activeEventId:i.activeEventId,timeFrozen:i.activeEventId!==null,objects:d,orbits:f,focusTargets:p}}function n_(n,e,t,i,r,s,o,a){let c=uc(n,e,t,i,r,o),l=ld(n.object,r.get(n.objectId),a,e.activeEventId!==null);return{objectId:n.objectId,object:n.object,parentId:n.parentId,ancestorIds:n.ancestorIds.slice(),childIds:n.childIds.slice(),groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),position:c,radius:is(n.radius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius),visualRadius:is(n.visualRadius*s.bodyRadiusMultiplier,s.minBodyRadius,s.maxBodyRadius+24),label:n.label,secondaryLabel:n.secondaryLabel,fillColor:n.fillColor,imageHref:n.imageHref,hidden:n.hidden,motion:l}}function i_(n,e,t,i){let r=e.get(n.objectId),s=e.get(n.parentId);return{objectId:n.objectId,object:n.object,parentId:n.parentId,groupId:n.groupId,semanticGroupIds:n.semanticGroupIds.slice(),center:s?.position??{x:0,y:0,z:0},kind:n.kind,radius:n.radius,semiMajor:n.radius??n.rx??0,semiMinor:n.radius??n.ry??0,rotationDeg:n.rotationDeg,inclinationDeg:r?.motion?.inclinationDeg??dc(n.object.placement?.mode==="orbit"?n.object.placement.inclination:void 0)??0,band:n.band,bandThickness:n.bandThickness,hidden:n.hidden,motion:r?.motion??ld(n.object,n,t,i)}}function uc(n,e,t,i,r,s){let o=s.get(n.objectId);if(o)return o;let a=n.object.placement,c;if(a?.mode==="orbit"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=r.get(n.objectId),h=ld(n.object,d,1,e.activeEventId!==null),f=h?Am(h,0):{x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};c=Tm(u,f)}else if(a?.mode==="surface"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=l?.visualRadius??16,h=c_(n.objectId),f=h*Math.PI*2;c={x:u.x+Math.cos(f)*(d+n.visualRadius*.9),y:u.y+Math.sin(h*Math.PI)*Math.max(n.visualRadius*.2,2),z:u.z+Math.sin(f)*(d+n.visualRadius*.9)}}else if(a?.mode==="at"&&n.parentId){let l=i.get(n.parentId),u=l?uc(l,e,t,i,r,s):{x:0,y:0,z:0},d=n.anchorX??l?.x??t.x,h=n.anchorY??l?.y??t.y;c={x:u.x+(n.x-d),y:u.y,z:u.z+(n.y-h)}}else c={x:(n.x-t.x)*.8,y:0,z:(n.y-t.y)*.8};return s.set(n.objectId,c),c}function cd(n,e){let t=new Map(n.objects.map(s=>[s.objectId,s])),i=new Map,r=s=>{let o=i.get(s);if(o)return o;let a=t.get(s);if(!a)return{x:0,y:0,z:0};let c={...a.position};if(a.motion&&a.parentId){let l=r(a.parentId),u=Am(a.motion,n.timeFrozen?0:e);c=Tm(l,u)}return i.set(s,c),c};for(let s of n.objects)r(s.objectId);return i}function Am(n,e){let t=n.phase0Deg+n.angularVelocityDegPerSecond*e,i=od(t),r=od(n.rotationDeg),s=od(n.inclinationDeg),o=Math.cos(i)*n.semiMajor,a=Math.sin(i)*n.semiMinor,c=o*Math.cos(r)-a*Math.sin(r),l=o*Math.sin(r)+a*Math.cos(r);return{x:c,y:l*Math.sin(s),z:l*Math.cos(s)}}function ld(n,e,t,i){let r=n.placement;if(!r||r.mode!=="orbit")return null;let s=e?.radius??e?.rx??is(ad(r)*48,24,1200),o=e?.radius??e?.ry??s,a=r_(r.period),c=ad(r),l=is(c/Math.max(t,1e-4),1,20),u=is(a?lc*l:lc*Math.pow(l,.75),lc,Mm);return{phase0Deg:dc(r.phase)??0,rotationDeg:dc(r.angle)??e?.rotationDeg??0,inclinationDeg:dc(r.inclination)??0,semiMajor:s,semiMinor:o,eccentricity:r.eccentricity??0,periodSeconds:a,angularVelocityDegPerSecond:360/Math.max(u,.001),heuristic:a===null,frozen:i}}function ad(n){let e=Sm(n.semiMajor)??Sm(n.distance)??1;return Math.max(e,.01)}function Sm(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/1495978707e-1;case"m":return n.value/149597870700;case"re":return n.value*6371/1495978707e-1;case"rj":return n.value*71492/1495978707e-1;case"sol":return n.value*695700/1495978707e-1;case"ly":return n.value*63241.077;case"pc":return n.value*206264.806;case"kpc":return n.value*206264806;default:return n.value}}function r_(n){if(!n)return null;switch(n.unit){case"s":return n.value;case"min":return n.value*60;case"h":return n.value*3600;case"d":return n.value*Em;case"y":return n.value*cc;case"ky":return n.value*cc*1e3;case"my":return n.value*cc*1e6;case"gy":return n.value*cc*1e9;default:return null}}function dc(n){return n&&(n.unit==="deg"||n.unit===null)?n.value:null}function s_(n,e){return{...o_(n),...e}}function o_(n){switch(n){case"compact":return{orbitDistanceMultiplier:.92,bodyRadiusMultiplier:.92,markerSizeMultiplier:.92,ringThicknessMultiplier:.9,focusPadding:10,minBodyRadius:4,maxBodyRadius:34};case"presentation":return{orbitDistanceMultiplier:1.15,bodyRadiusMultiplier:1.12,markerSizeMultiplier:1.08,ringThicknessMultiplier:1.14,focusPadding:16,minBodyRadius:5,maxBodyRadius:44};default:return{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40}}}function a_(n){if(n.length===0)return{minX:0,minY:0,minZ:0,maxX:0,maxY:0,maxZ:0,width:0,height:0,depth:0,center:{x:0,y:0,z:0}};let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of n)e=Math.min(e,a.position.x-a.visualRadius),t=Math.min(t,a.position.y-a.visualRadius),i=Math.min(i,a.position.z-a.visualRadius),r=Math.max(r,a.position.x+a.visualRadius),s=Math.max(s,a.position.y+a.visualRadius),o=Math.max(o,a.position.z+a.visualRadius);return{minX:e,minY:t,minZ:i,maxX:r,maxY:s,maxZ:o,width:r-e,height:s-t,depth:o-i,center:{x:(e+r)/2,y:(t+s)/2,z:(i+o)/2}}}function Tm(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function c_(n){let e=0;for(let t=0;t<n.length;t+=1)e=e*31+n.charCodeAt(t)>>>0;return e%1e4/1e4}function is(n,e,t){return Math.min(Math.max(n,e),t)}function od(n){return n*Math.PI/180}function ur(n,e={}){let t=Gt(n,e),i=[],r=d_(n,i),s=h_(n,i),o=u_(n,t.renderPreset??e.preset??null,t.projection),a=n.system?l_(n,o,r,s,i,t.renderPreset??e.preset??null):null;return t.viewpoints.some(c=>!c.generated)&&i.push({code:"upgrade.viewpoints.structured",severity:"info",source:"upgrade",message:`Promoted ${t.viewpoints.filter(c=>!c.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`}),{format:"worldorbit",version:"2.6",schemaVersion:"2.6",sourceVersion:n.version,theme:n.theme??null,system:a,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:structuredClone(n.events??[]),objects:n.objects.map(Cm),diagnostics:i}}function ud(n,e={}){return M_(ur(n,e))}function ss(n,e={}){let t=n.system?{type:"system",id:n.system.id,title:n.system.title,description:n.system.description,epoch:n.system.epoch,referencePlane:n.system.referencePlane,properties:b_(n.system),info:__(n.system)}:null,i=n.objects.map(Cm);return g_(i,n.events??[],e.activeEventId??null),{format:"worldorbit",version:"1.0",schemaVersion:n.version,theme:n.theme??null,system:t,groups:structuredClone(n.groups??[]),relations:structuredClone(n.relations??[]),events:n.events.map(p_),objects:i}}function l_(n,e,t,i,r,s){let o=Gt(n,{preset:s??void 0,projection:e.view});return{type:"system",id:n.system?.id??"WorldOrbit",title:n.system?.title??(typeof n.system?.properties.title=="string"?n.system.properties.title:null),description:n.system?.description??null,epoch:n.system?.epoch??null,referencePlane:n.system?.referencePlane??null,defaults:e,atlasMetadata:t,viewpoints:o.viewpoints.map(f_),annotations:i}}function u_(n,e,t){let i=typeof n.system?.properties.view=="string"?n.system.properties.view.toLowerCase():null;return{view:i==="topdown"||i==="isometric"||i==="orthographic"||i==="perspective"?i:t,scale:typeof n.system?.properties.scale=="string"?n.system.properties.scale:null,units:typeof n.system?.properties.units=="string"?n.system.properties.units:null,preset:e,theme:typeof n.system?.info["atlas.theme"]=="string"?n.system.info["atlas.theme"]:null}}function d_(n,e){let t={};for(let[r,s]of Object.entries(n.system?.info??{}))r.startsWith("viewpoint.")||r.startsWith("annotation.")||(t[r]=s);let i=Object.keys(t);return i.length>0&&e.push({code:"upgrade.atlasMetadata.preserved",severity:"warning",source:"upgrade",message:`Preserved ${i.length} system info entr${i.length===1?"y":"ies"} as atlas metadata in the 2.0 atlas document.`}),t}function h_(n,e){let t=new Map;for(let[i,r]of Object.entries(n.system?.info??{})){if(!i.startsWith("annotation."))continue;let[,s,...o]=i.split(".");if(!s||o.length===0)continue;let a=Im(s);if(!a)continue;let c=t.get(a)??{id:a};switch(o.join(".").toLowerCase()){case"label":c.label=r;break;case"target":case"object":c.targetObjectId=r.trim()||null;break;case"body":case"text":case"description":c.body=r;break;case"tags":c.tags=v_(r);break}t.set(a,c)}for(let i of n.objects){let r=i.info.description;if(!r)continue;let s=Im(`${i.id}-notes`);t.has(s)||(t.set(s,{id:s,label:`${i.id} Notes`,targetObjectId:i.id,body:r,tags:Array.isArray(i.properties.tags)?i.properties.tags.filter(o=>typeof o=="string"):[]}),e.push({code:"upgrade.annotation.objectDescription",severity:"info",source:"upgrade",message:`Lifted ${i.id}.info.description into structured atlas annotation "${s}".`,objectId:i.id,field:"description"}))}return[...t.values()].filter(i=>i.body||i.label).map(i=>({id:i.id,label:i.label??x_(i.id),targetObjectId:i.targetObjectId??null,body:i.body??"",tags:i.tags??[],sourceObjectId:i.targetObjectId??null})).sort((i,r)=>i.label.localeCompare(r.label))}function f_(n){return{id:n.id,label:n.label,summary:n.summary,focusObjectId:n.objectId,selectedObjectId:n.selectedObjectId,events:[...n.eventIds],projection:n.projection,preset:n.preset,zoom:n.scale,rotationDeg:n.rotationDeg,camera:n.camera?{...n.camera}:null,layers:{...n.layers},filter:n.filter?{query:n.filter.query,objectTypes:[...n.filter.objectTypes],tags:[...n.filter.tags],groupIds:[...n.filter.groupIds]}:null}}function Cm(n){return{...n,groups:n.groups?[...n.groups]:void 0,resonance:n.resonance?{...n.resonance}:n.resonance,renderHints:n.renderHints?{...n.renderHints}:n.renderHints,deriveRules:n.deriveRules?n.deriveRules.map(e=>({...e})):void 0,validationRules:n.validationRules?n.validationRules.map(e=>({...e})):void 0,lockedFields:n.lockedFields?[...n.lockedFields]:void 0,tolerances:n.tolerances?n.tolerances.map(e=>({field:e.field,value:e.value&&typeof e.value=="object"&&"value"in e.value?{value:e.value.value,unit:e.value.unit}:Array.isArray(e.value)?[...e.value]:e.value})):void 0,typedBlocks:n.typedBlocks?Object.fromEntries(Object.entries(n.typedBlocks).map(([e,t])=>[e,{...t??{}}])):void 0,properties:y_(n.properties),placement:n.placement?structuredClone(n.placement):null,info:{...n.info}}}function p_(n){return{...n,participantObjectIds:[...n.participantObjectIds],tags:[...n.tags],positions:n.positions.map(m_)}}function m_(n){return{objectId:n.objectId,placement:Rm(n.placement),inner:n.inner?{...n.inner}:void 0,outer:n.outer?{...n.outer}:void 0,epoch:n.epoch??null,referencePlane:n.referencePlane??null}}function Rm(n){return n?structuredClone(n):null}function g_(n,e,t){if(!t)return;let i=e.find(o=>o.id===t);if(!i)return;let r=new Map(n.map(o=>[o.id,o])),s=new Set([...i.targetObjectId?[i.targetObjectId]:[],...i.participantObjectIds,...i.positions.map(o=>o.objectId)]);for(let o of s){let a=r.get(o);a&&(i.epoch&&(a.epoch=i.epoch),i.referencePlane&&(a.referencePlane=i.referencePlane))}for(let o of i.positions){let a=r.get(o.objectId);a&&(o.placement&&(a.placement=Rm(o.placement)),o.inner&&(a.properties.inner={...o.inner}),o.outer&&(a.properties.outer={...o.outer}),o.epoch&&(a.epoch=o.epoch),o.referencePlane&&(a.referencePlane=o.referencePlane))}}function y_(n){let e={};for(let[t,i]of Object.entries(n)){if(Array.isArray(i)){e[t]=[...i];continue}if(i&&typeof i=="object"&&"value"in i){e[t]={value:i.value,unit:i.unit};continue}e[t]=i}return e}function v_(n){return n.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function Im(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function x_(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function b_(n){let e={};return n.title&&(e.title=n.title),e.view=n.defaults.view,n.defaults.scale&&(e.scale=n.defaults.scale),n.defaults.units&&(e.units=n.defaults.units),n.description&&(e.description=n.description),n.epoch&&(e.epoch=n.epoch),n.referencePlane&&(e.referencePlane=n.referencePlane),e}function __(n){let e={...n.atlasMetadata};n.defaults.theme&&(e["atlas.theme"]=n.defaults.theme);for(let t of n.viewpoints){let i=`viewpoint.${t.id}`;e[`${i}.label`]=t.label,t.summary&&(e[`${i}.summary`]=t.summary),t.focusObjectId&&(e[`${i}.focus`]=t.focusObjectId),t.selectedObjectId&&(e[`${i}.select`]=t.selectedObjectId),t.projection&&(e[`${i}.projection`]=t.projection),t.preset&&(e[`${i}.preset`]=t.preset),t.zoom!==null&&(e[`${i}.zoom`]=String(t.zoom)),t.rotationDeg!==0&&(e[`${i}.rotation`]=String(t.rotationDeg)),t.camera?.azimuth!==null&&(e[`${i}.camera.azimuth`]=String(t.camera?.azimuth)),t.camera?.elevation!==null&&(e[`${i}.camera.elevation`]=String(t.camera?.elevation)),t.camera?.roll!==null&&(e[`${i}.camera.roll`]=String(t.camera?.roll)),t.camera?.distance!==null&&(e[`${i}.camera.distance`]=String(t.camera?.distance));let r=w_(t.layers);r&&(e[`${i}.layers`]=r),t.filter?.query&&(e[`${i}.query`]=t.filter.query),(t.filter?.objectTypes.length??0)>0&&(e[`${i}.types`]=t.filter?.objectTypes.join(" ")??""),(t.filter?.tags.length??0)>0&&(e[`${i}.tags`]=t.filter?.tags.join(" ")??""),(t.filter?.groupIds.length??0)>0&&(e[`${i}.groups`]=t.filter?.groupIds.join(" ")??""),t.events.length>0&&(e[`${i}.events`]=t.events.join(" "))}for(let t of n.annotations){let i=`annotation.${t.id}`;e[`${i}.label`]=t.label,t.targetObjectId&&(e[`${i}.target`]=t.targetObjectId),e[`${i}.body`]=t.body,t.tags.length>0&&(e[`${i}.tags`]=t.tags.join(" ")),t.sourceObjectId&&(e[`${i}.source`]=t.sourceObjectId)}return e}function w_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e.join(" ")}function M_(n){return{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}}var Pm=["title","view","scale","units","kind","class","tags","color","image","hidden","orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"];function hc(n,e={}){let t=e.schema??"auto";if(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6"||t==="2.0-draft"||n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"||n.version==="2.0-draft"){if(t==="2.0-draft"){let c=n.version==="2.0-draft"?n:n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?{...n,version:"2.0-draft",schemaVersion:"2.0-draft"}:ud(n);return Dm(c)}let a=n.version==="2.0"||n.version==="2.1"||n.version==="2.5"||n.version==="2.6"?n:n.version==="2.0-draft"?{...n,version:"2.0",schemaVersion:"2.0"}:ur(n);return(t==="2.0"||t==="2.1"||t==="2.5"||t==="2.6")&&a.version!==t?dd({...a,version:t,schemaVersion:t}):dd(a)}let r=[],s=n;s.system&&r.push(...S_(s.system));let o=[...s.objects].sort(pd);for(let a of o)r.length>0&&r.push(""),r.push(...A_(a));return r.join(`
3822
+ `)}function dd(n){let e=[`schema ${n.version}`,""];n.system&&e.push(...Om(n.system));for(let i of[...n.groups].sort(os))e.push(""),e.push(...km(i));for(let i of[...n.relations].sort(os))e.push(""),e.push(...Bm(i));for(let i of[...n.events].sort(os))e.push(""),e.push(...zm(i));let t=[...n.objects].sort(pd);return t.length>0&&e.at(-1)!==""&&e.push(""),t.forEach((i,r)=>{r>0&&e.push(""),e.push(...Um(i))}),e.join(`
3823
+ `)}function Dm(n){let e=n.version==="2.0-draft"?n:{...n,version:"2.0-draft",schemaVersion:"2.0-draft"},t=["schema 2.0-draft",""];e.system&&t.push(...Om(e.system));for(let r of[...e.groups].sort(os))t.push(""),t.push(...km(r));for(let r of[...e.relations].sort(os))t.push(""),t.push(...Bm(r));for(let r of[...e.events].sort(os))t.push(""),t.push(...zm(r));let i=[...e.objects].sort(pd);return i.length>0&&t.at(-1)!==""&&t.push(""),i.forEach((r,s)=>{s>0&&t.push(""),t.push(...Um(r))}),t.join(`
3824
+ `)}function S_(n){return E_("system",n.id,n.properties,null,n.info)}function E_(n,e,t,i,r){let s=[`${n} ${e}`],o=[...hd(i),...Fm(t)];for(let c of o)s.push(` ${c}`);let a=Object.entries(r).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){o.length>0&&s.push(""),s.push(" info");for(let[c,l]of a)s.push(` ${c} ${We(l)}`)}return s}function Om(n){let e=[`system ${n.id}`];if(n.title&&e.push(` title ${We(n.title)}`),n.description&&e.push(` description ${We(n.description)}`),n.epoch&&e.push(` epoch ${We(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${We(n.referencePlane)}`),e.push(""),e.push("defaults"),e.push(` view ${n.defaults.view}`),n.defaults.scale&&e.push(` scale ${We(n.defaults.scale)}`),n.defaults.units&&e.push(` units ${We(n.defaults.units)}`),n.defaults.preset&&e.push(` preset ${n.defaults.preset}`),n.defaults.theme&&e.push(` theme ${We(n.defaults.theme)}`),Object.keys(n.atlasMetadata).length>0){e.push(""),e.push("atlas"),e.push(" metadata");for(let[t,i]of Object.entries(n.atlasMetadata).sort(([r],[s])=>r.localeCompare(s)))e.push(` ${t} ${We(i)}`)}for(let t of n.viewpoints)e.push(""),e.push(...I_(t));for(let t of n.annotations)e.push(""),e.push(...C_(t));return e}function A_(n){return Nm(n.type,n.id,n)}function Um(n){return Nm(`object ${n.type}`,n.id,n)}function Nm(n,e,t){let i=[`${n} ${e}`],r=[...hd(t.placement),...Fm(t.properties),...T_(t)];for(let o of r)i.push(` ${o}`);let s=Object.entries(t.info).sort(([o],[a])=>o.localeCompare(a));if(s.length>0){r.length>0&&i.push(""),i.push(" info");for(let[o,a]of s)i.push(` ${o} ${We(a)}`)}for(let o of["climate","habitability","settlement"]){let a=Object.entries(t.typedBlocks?.[o]??{}).sort(([c],[l])=>c.localeCompare(l));if(a.length>0){i.push(""),i.push(` ${o}`);for(let[c,l]of a)i.push(` ${c} ${We(l)}`)}}return i}function hd(n){if(!n)return[];switch(n.mode){case"orbit":return[`orbit ${n.target}`,...Pi("distance",n.distance),...Pi("semiMajor",n.semiMajor),...L_("eccentricity",n.eccentricity),...Pi("period",n.period),...Pi("angle",n.angle),...Pi("inclination",n.inclination),...Pi("phase",n.phase)];case"at":return[`at ${D_(n.reference)}`];case"surface":return[`surface ${n.target}`];case"free":return[`free ${n.distance?fd(n.distance):n.descriptor??""}`.trim()]}}function Fm(n){return Object.keys(n).sort(U_).map(e=>`${e} ${Vm(n[e])}`)}function T_(n){let e=[];n.groups?.length&&e.push(`groups ${n.groups.join(" ")}`),n.epoch&&e.push(`epoch ${We(n.epoch)}`),n.referencePlane&&e.push(`referencePlane ${We(n.referencePlane)}`),n.tidalLock!==void 0&&e.push(`tidalLock ${n.tidalLock?"true":"false"}`),n.renderHints?.renderLabel!==void 0&&e.push(`renderLabel ${n.renderHints.renderLabel?"true":"false"}`),n.renderHints?.renderOrbit!==void 0&&e.push(`renderOrbit ${n.renderHints.renderOrbit?"true":"false"}`),n.renderHints?.renderPriority!==void 0&&e.push(`renderPriority ${n.renderHints.renderPriority}`),n.resonance&&e.push(`resonance ${n.resonance.targetObjectId} ${n.resonance.ratio}`);for(let t of n.deriveRules??[])e.push(`derive ${t.field} ${t.strategy}`);for(let t of n.validationRules??[])e.push(`validate ${t.rule}`);n.lockedFields?.length&&e.push(`locked ${n.lockedFields.join(" ")}`);for(let t of n.tolerances??[])e.push(`tolerance ${t.field} ${Vm(t.value)}`);return e}function I_(n){let e=[`viewpoint ${n.id}`,` label ${We(n.label)}`];n.focusObjectId&&e.push(` focus ${n.focusObjectId}`),n.selectedObjectId&&n.selectedObjectId!==n.focusObjectId&&e.push(` select ${n.selectedObjectId}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.projection&&e.push(` projection ${n.projection}`),n.preset&&e.push(` preset ${n.preset}`),n.zoom!==null&&e.push(` zoom ${n.zoom}`),n.rotationDeg!==0&&e.push(` rotation ${n.rotationDeg}`),n.camera&&P_(n.camera)&&(e.push(" camera"),n.camera.azimuth!==null&&e.push(` azimuth ${n.camera.azimuth}`),n.camera.elevation!==null&&e.push(` elevation ${n.camera.elevation}`),n.camera.roll!==null&&e.push(` roll ${n.camera.roll}`),n.camera.distance!==null&&e.push(` distance ${n.camera.distance}`));let t=O_(n.layers);return t.length>0&&e.push(` layers ${t.join(" ")}`),n.events.length>0&&e.push(` events ${n.events.join(" ")}`),n.filter&&(e.push(" filter"),n.filter.query&&e.push(` query ${We(n.filter.query)}`),n.filter.objectTypes.length>0&&e.push(` objectTypes ${n.filter.objectTypes.join(" ")}`),n.filter.tags.length>0&&e.push(` tags ${n.filter.tags.map(We).join(" ")}`),n.filter.groupIds.length>0&&e.push(` groups ${n.filter.groupIds.join(" ")}`)),e}function C_(n){let e=[`annotation ${n.id}`,` label ${We(n.label)}`];return n.targetObjectId&&e.push(` target ${n.targetObjectId}`),e.push(` body ${We(n.body)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),e}function km(n){let e=[`group ${n.id}`,` label ${We(n.label)}`];return n.summary&&e.push(` summary ${We(n.summary)}`),n.color&&e.push(` color ${We(n.color)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.hidden&&e.push(" hidden true"),e}function Bm(n){let e=[`relation ${n.id}`];return n.from&&e.push(` from ${We(n.from)}`),n.to&&e.push(` to ${We(n.to)}`),n.kind&&e.push(` kind ${We(n.kind)}`),n.label&&e.push(` label ${We(n.label)}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.color&&e.push(` color ${We(n.color)}`),n.hidden&&e.push(" hidden true"),e}function zm(n){let e=[`event ${n.id}`,` kind ${We(n.kind)}`];if(n.label&&e.push(` label ${We(n.label)}`),n.summary&&e.push(` summary ${We(n.summary)}`),n.targetObjectId&&e.push(` target ${n.targetObjectId}`),n.participantObjectIds.length>0&&e.push(` participants ${n.participantObjectIds.join(" ")}`),n.timing&&e.push(` timing ${We(n.timing)}`),n.visibility&&e.push(` visibility ${We(n.visibility)}`),n.epoch&&e.push(` epoch ${We(n.epoch)}`),n.referencePlane&&e.push(` referencePlane ${We(n.referencePlane)}`),n.tags.length>0&&e.push(` tags ${n.tags.map(We).join(" ")}`),n.color&&e.push(` color ${We(n.color)}`),n.hidden&&e.push(" hidden true"),n.positions.length>0){e.push(""),e.push(" positions");for(let t of[...n.positions].sort(N_)){e.push(` pose ${t.objectId}`);for(let i of R_(t))e.push(` ${i}`)}}return e}function R_(n){return[...hd(n.placement),...n.epoch?[`epoch ${We(n.epoch)}`]:[],...n.referencePlane?[`referencePlane ${We(n.referencePlane)}`]:[],...Pi("inner",n.inner),...Pi("outer",n.outer)]}function P_(n){return n.azimuth!==null||n.elevation!==null||n.roll!==null||n.distance!==null}function Vm(n){return Array.isArray(n)?n.map(e=>We(e)).join(" "):typeof n=="boolean"?n?"true":"false":typeof n=="number"?String(n):typeof n=="string"?We(n):fd(n)}function fd(n){return`${n.value}${n.unit??""}`}function Pi(n,e){return e?[`${n} ${fd(e)}`]:[]}function L_(n,e){return e===void 0?[]:[`${n} ${e}`]}function D_(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function O_(n){let e=[],t=n["orbits-front"],i=n["orbits-back"];(t!==void 0||i!==void 0)&&e.push(t!==!1||i!==!1?"orbits":"-orbits");for(let r of["background","guides","relations","events","objects","labels","metadata"])n[r]!==void 0&&e.push(n[r]?r:`-${r}`);return e}function U_(n,e){let t=Pm.indexOf(n),i=Pm.indexOf(e);return t===-1&&i===-1?n.localeCompare(e):t===-1?1:i===-1?-1:t-i}function pd(n,e){let t=Lm(n.type),i=Lm(e.type);return t!==i?t-i:n.id.localeCompare(e.id)}function os(n,e){return n.id.localeCompare(e.id)}function N_(n,e){return n.objectId.localeCompare(e.objectId)}function Lm(n){switch(n){case"star":return 0;case"planet":return 1;case"moon":return 2;case"belt":return 3;case"asteroid":return 4;case"comet":return 5;case"ring":return 6;case"structure":return 7;case"phenomenon":return 8}}function We(n){return!/\s/.test(n)&&!n.includes('"')?n:`"${n.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}var $m=/^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/,F_=new Map([["true",!0],["false",!1],["yes",!0],["no",!1]]),k_=/^[A-Za-z][A-Za-z0-9+.-]*:/;function as(n){return n.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function _o(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function md(n,e,t){let i=n.match($m);if(!i)throw q.fromLocation(`Invalid unit value "${n}"`,e);let r={value:Number(i[1]),unit:i[2]??null};if(t){let s=an(t);if(s?.unitFamily&&!Za(s.unitFamily,r.unit))throw q.fromLocation(`Unit "${r.unit??"none"}" is not valid for "${t}"`,e)}return r}function gd(n){let e=n.match($m);return e?{value:Number(e[1]),unit:e[2]??null}:null}function fc(n,e,t){let i=Number(n);if(!Number.isFinite(i))throw q.fromLocation(`Invalid numeric value "${n}" for "${e}"`,t);return i}function Li(n,e,t){let i=F_.get(n.toLowerCase());if(i===void 0)throw q.fromLocation(`Invalid boolean value "${n}" for "${e}"`,t);return i}function Hm(n,e){if(/^[A-Za-z0-9._-]+-[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let t=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:t[2],point:t[3]};let i=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(i)return{kind:"lagrange",primary:i[1],secondary:null,point:i[2]};if(/^[A-Za-z0-9._-]+:L\d+$/i.test(n))throw q.fromLocation(`Invalid special position "${n}"`,e);let r=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return r?{kind:"anchor",objectId:r[1],anchor:r[2]}:{kind:"named",name:n}}function B_(n,e){if(!n)throw q.fromLocation('Field "image" must not be empty',e);if(n.startsWith("//"))throw q.fromLocation('Field "image" must use a relative path, root-relative path, or an http/https URL',e);let t=n.match(k_);if(!t)return;let i=t[0].slice(0,-1).toLowerCase();if(i!=="http"&&i!=="https")throw q.fromLocation(`Field "image" does not support the "${i}" scheme`,e)}function jm(n,e,t){let i=an(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(i.arity==="single"&&e.length!==1)throw q.fromLocation(`Field "${n}" expects exactly one value`,t);switch(i.kind){case"list":return e;case"boolean":return Li(bo(e,n,t),n,t);case"number":return fc(bo(e,n,t),n,t);case"unit":return md(bo(e,n,t),t,n);case"string":{let r=e.join(" ").trim();return n==="image"&&B_(r,t),r}}}function yd(n,e,t){let i=an(n);if(!i)throw q.fromLocation(`Unknown field "${n}"`,t);if(!i.objectTypes.includes(e))throw q.fromLocation(`Field "${n}" is not valid on "${e}"`,t)}function bo(n,e,t){if(n.length!==1)throw q.fromLocation(`Field "${e}" expects exactly one value`,t);return n[0]}var Wm=new Set(["star","planet","moon","asteroid","comet"]),z_=332946.0487,V_=1047.3486,pc=1495978707e-1,$_=6371,H_=695700,j_=63241.077,G_=206264.806,W_=206264806;function wo(n,e){let t=[],i=new Map(n.objects.map(a=>[a.id,a])),r=new Set(n.groups.map(a=>a.id)),s=new Set(n.events.map(a=>a.id));n.system||t.push(nt("validate.system.required","Atlas documents must declare exactly one system."));let o=new Map;for(let[a,c]of[["group",n.groups.map(l=>l.id)],["viewpoint",n.system?.viewpoints.map(l=>l.id)??[]],["annotation",n.system?.annotations.map(l=>l.id)??[]],["relation",n.relations.map(l=>l.id)],["event",n.events.map(l=>l.id)],["object",n.objects.map(l=>l.id)]])for(let l of c){let u=o.get(l);u?t.push(nt("validate.id.duplicate",`Duplicate ${a} id "${l}" already used by ${u}.`)):o.set(l,a)}for(let a of n.relations)X_(a,i,t);for(let a of n.system?.viewpoints??[])q_(a,r,s,e,t,i);for(let a of n.objects)Y_(a,n.system,i,r,t);for(let a of n.events)Z_(a,n.system,i,t);return t}function X_(n,e,t){n.from?e.has(n.from)||t.push(nt("validate.relation.from.unknown",`Unknown relation source "${n.from}" on "${n.id}".`)):t.push(nt("validate.relation.from.required",`Relation "${n.id}" is missing a "from" target.`)),n.to?e.has(n.to)||t.push(nt("validate.relation.to.unknown",`Unknown relation target "${n.to}" on "${n.id}".`)):t.push(nt("validate.relation.to.required",`Relation "${n.id}" is missing a "to" target.`)),n.kind||t.push(nt("validate.relation.kind.required",`Relation "${n.id}" is missing a "kind" value.`))}function q_(n,e,t,i,r,s){let o=n.filter;if(i==="2.1"||i==="2.5"||i==="2.6"){if(o)for(let a of o.groupIds)e.has(a)||r.push(gt("validate.viewpoint.group.unknown",`Unknown group "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.groups`));for(let a of n.events??[])t.has(a)||r.push(gt("validate.viewpoint.event.unknown",`Unknown event "${a}" in viewpoint "${n.id}".`,void 0,`viewpoint.${n.id}.events`))}ew(n.projection,r,`viewpoint.${n.id}.projection`,n.id),tw(n.camera,n.projection,n.rotationDeg,r,n.id,n.focusObjectId,n.selectedObjectId,o,s)}function Y_(n,e,t,i,r){let s=n.placement,o=s?.mode==="orbit"?s:null,a=s?.mode==="orbit"?t.get(s.target)??null:null;if(n.groups)for(let c of n.groups)i.has(c)||r.push(gt("validate.group.unknown",`Unknown group "${c}" on "${n.id}".`,n.id,"groups"));if(typeof n.epoch=="string"&&!n.epoch.trim()&&r.push(gt("validate.epoch.empty",`Object "${n.id}" defines an empty epoch string.`,n.id,"epoch")),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&r.push(gt("validate.referencePlane.empty",`Object "${n.id}" defines an empty reference plane string.`,n.id,"referencePlane")),o&&(t.has(o.target)||r.push(nt("validate.orbit.target.unknown",`Unknown placement target "${o.target}" on "${n.id}".`,n.id,"orbit")),o.distance&&o.semiMajor&&r.push(nt("validate.orbit.distanceConflict",`Object "${n.id}" cannot declare both "distance" and "semiMajor".`,n.id,"distance")),o.phase&&!n.epoch&&!e?.epoch&&r.push(gt("validate.phase.epochMissing",`Object "${n.id}" sets "phase" without an object or system epoch.`,n.id,"phase")),o.inclination&&!n.referencePlane&&!e?.referencePlane&&r.push(gt("validate.inclination.referencePlaneMissing",`Object "${n.id}" sets "inclination" without an object or system reference plane.`,n.id,"inclination")),o.period&&!xd(a?.properties.mass)&&r.push(gt("validate.period.massMissing",`Object "${n.id}" sets "period" but its central mass cannot be derived.`,n.id,"period"))),s?.mode==="surface"){let c=t.get(s.target);c?Wm.has(c.type)||r.push(nt("validate.surface.target.invalid",`Surface target "${s.target}" on "${n.id}" is not surface-capable.`,n.id,"surface")):r.push(nt("validate.surface.target.unknown",`Unknown placement target "${s.target}" on "${n.id}".`,n.id,"surface"))}if(s?.mode==="at"&&(n.type!=="structure"&&n.type!=="phenomenon"&&r.push(nt("validate.at.objectType",`Only structures and phenomena may use "at" placement; found "${n.type}" on "${n.id}".`,n.id,"at")),K_(n,t,r)||r.push(nt("validate.at.target.unknown",`Unknown at-reference target "${s.target}" on "${n.id}".`,n.id,"at"))),n.resonance){let c=t.get(n.resonance.targetObjectId);c?(n.placement?.mode!=="orbit"||c.placement?.mode!=="orbit"||n.placement.target!==c.placement.target)&&r.push(gt("validate.resonance.orbitMismatch",`Resonance target "${n.resonance.targetObjectId}" on "${n.id}" does not share a compatible orbital parent.`,n.id,"resonance")):r.push(nt("validate.resonance.target.unknown",`Unknown resonance target "${n.resonance.targetObjectId}" on "${n.id}".`,n.id,"resonance"))}for(let c of n.deriveRules??[]){if(c.field!=="period"||c.strategy!=="kepler"){r.push(gt("validate.derive.unsupported",`Unsupported derive rule "${c.field} ${c.strategy}" on "${n.id}".`,n.id,"derive"));continue}let l=Gm(n,a);if(l===null){r.push(gt("validate.derive.inputsMissing",`Object "${n.id}" requests "derive period kepler" but lacks enough input data.`,n.id,"derive"));continue}o?.period||r.push(vd("validate.derive.period.available",`Object "${n.id}" can derive a Kepler period of ${sw(l)}.`,n.id,"derive"))}for(let c of n.validationRules??[]){if(c.rule!=="kepler"){r.push(gt("validate.rule.unsupported",`Unsupported validation rule "${c.rule}" on "${n.id}".`,n.id,"validate"));continue}let l=Xm(o?.period),u=Gm(n,a);if(l===null||u===null)continue;let d=rw(n,"period");Math.abs(l-u)>d&&r.push(nt("validate.kepler.mismatch",`Object "${n.id}" fails Kepler validation for "period".`,n.id,"validate"))}}function Z_(n,e,t,i){let r=`event.${n.id}`,s=new Set;n.kind.trim()||i.push(nt("validate.event.kind.required",`Event "${n.id}" is missing a "kind" value.`,void 0,`${r}.kind`)),typeof n.epoch=="string"&&!n.epoch.trim()&&i.push(gt("validate.event.epoch.empty",`Event "${n.id}" defines an empty epoch string.`,void 0,`${r}.epoch`)),typeof n.referencePlane=="string"&&!n.referencePlane.trim()&&i.push(gt("validate.event.referencePlane.empty",`Event "${n.id}" defines an empty reference plane string.`,void 0,`${r}.referencePlane`)),!n.targetObjectId&&n.participantObjectIds.length===0&&i.push(nt("validate.event.references.required",`Event "${n.id}" must define a "target" or at least one participant.`,void 0,`${r}.participants`)),n.targetObjectId&&(s.add(n.targetObjectId),t.has(n.targetObjectId)||i.push(nt("validate.event.target.unknown",`Unknown event target "${n.targetObjectId}" on "${n.id}".`,void 0,`${r}.target`)));let o=new Set;for(let l of n.participantObjectIds){if(s.add(l),o.has(l)){i.push(gt("validate.event.participants.duplicate",`Event "${n.id}" repeats participant "${l}".`,void 0,`${r}.participants`));continue}o.add(l),t.has(l)||i.push(nt("validate.event.participants.unknown",`Unknown event participant "${l}" on "${n.id}".`,void 0,`${r}.participants`))}n.targetObjectId&&n.participantObjectIds.length>0&&!n.participantObjectIds.includes(n.targetObjectId)&&i.push(gt("validate.event.target.notParticipant",`Event "${n.id}" defines a target outside its participants list.`,void 0,`${r}.target`)),n.positions.length===0&&i.push(gt("validate.event.positions.missing",`Event "${n.id}" has no positions block and cannot drive a scene snapshot.`,void 0,`${r}.positions`)),/(?:^|[-_])(solar-eclipse|lunar-eclipse|transit|occultation)(?:$|[-_])/.test(n.kind)&&s.size<3&&i.push(gt("validate.event.kind.participants",`Event "${n.id}" looks like an eclipse or transit but references fewer than three bodies.`,void 0,`${r}.participants`));let a=new Set;for(let l of n.positions){let u=`${r}.pose.${l.objectId}`;if(a.has(l.objectId)){i.push(nt("validate.event.pose.duplicate",`Event "${n.id}" defines "${l.objectId}" more than once in positions.`,void 0,u));continue}a.add(l.objectId);let d=t.get(l.objectId);if(!d){i.push(nt("validate.event.pose.object.unknown",`Unknown event pose object "${l.objectId}" on "${n.id}".`,void 0,u));continue}s.has(l.objectId)||i.push(gt("validate.event.pose.unreferenced",`Event pose "${l.objectId}" on "${n.id}" is not listed in target/participants.`,void 0,u)),J_(l,d,n,e,t,i,u,n.id)}let c=[...s].filter(l=>!a.has(l));n.positions.length>0&&c.length>0&&i.push(gt("validate.event.positions.partial",`Event "${n.id}" leaves ${c.length} referenced object(s) on their base placement.`,void 0,`${r}.positions`))}function J_(n,e,t,i,r,s,o,a){let c=n.placement;if(!c){s.push(nt("validate.event.pose.placement.required",`Event "${a}" pose "${n.objectId}" is missing a placement mode.`,void 0,o));return}if(c.mode==="orbit"){r.has(c.target)||s.push(nt("validate.event.pose.orbit.target.unknown",`Unknown event orbit target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.orbit`)),c.distance&&c.semiMajor&&s.push(nt("validate.event.pose.orbit.distanceConflict",`Event "${a}" pose "${n.objectId}" cannot declare both "distance" and "semiMajor".`,void 0,`${o}.distance`)),c.phase&&!nw(i,e,t,n)&&s.push(gt("validate.event.pose.phase.epochMissing",`Event "${a}" pose "${n.objectId}" sets "phase" without an effective epoch.`,void 0,`${o}.phase`)),c.inclination&&!iw(i,e,t,n)&&s.push(gt("validate.event.pose.inclination.referencePlaneMissing",`Event "${a}" pose "${n.objectId}" sets "inclination" without an effective reference plane.`,void 0,`${o}.inclination`)),c.period&&!xd(r.get(c.target)?.properties.mass)&&s.push(gt("validate.event.pose.period.massMissing",`Event "${a}" pose "${n.objectId}" sets "period" but its central mass cannot be derived.`,void 0,`${o}.period`));return}if(c.mode==="surface"){let l=r.get(c.target);l?Wm.has(l.type)||s.push(nt("validate.event.pose.surface.target.invalid",`Event surface target "${c.target}" on "${a}:${n.objectId}" is not surface-capable.`,void 0,`${o}.surface`)):s.push(nt("validate.event.pose.surface.target.unknown",`Unknown event surface target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.surface`));return}if(c.mode==="at"){e.type!=="structure"&&e.type!=="phenomenon"&&s.push(nt("validate.event.pose.at.objectType",`Only structures and phenomena may use "at" placement in events; found "${e.type}" on "${a}:${n.objectId}".`,void 0,`${o}.at`));let l=c.reference;l.kind==="named"&&!r.has(l.name)?s.push(nt("validate.event.pose.at.target.unknown",`Unknown event at-reference target "${c.target}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="anchor"&&!r.has(l.objectId)?s.push(nt("validate.event.pose.anchor.target.unknown",`Unknown event anchor target "${l.objectId}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):l.kind==="lagrange"&&(r.has(l.primary)?l.secondary&&!r.has(l.secondary)&&s.push(nt("validate.event.pose.lagrange.secondary.unknown",`Unknown event Lagrange target "${l.secondary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)):s.push(nt("validate.event.pose.lagrange.primary.unknown",`Unknown event Lagrange target "${l.primary}" on "${a}:${n.objectId}".`,void 0,`${o}.at`)))}}function K_(n,e,t){let i=n.placement?.mode==="at"?n.placement.reference:null;return i?i.kind==="named"?e.has(i.name):i.kind==="anchor"?e.has(i.objectId)?!0:(t.push(nt("validate.anchor.target.unknown",`Unknown anchor target "${i.objectId}" on "${n.id}".`,n.id,"at")),!1):e.has(i.primary)?i.secondary&&!e.has(i.secondary)?(t.push(nt("validate.lagrange.secondary.unknown",`Unknown Lagrange reference "${i.secondary}" on "${n.id}".`,n.id,"at")),!1):!0:(t.push(nt("validate.lagrange.primary.unknown",`Unknown Lagrange reference "${i.primary}" on "${n.id}".`,n.id,"at")),!1):!0}function Gm(n,e){let t=n.placement;if(!t||t.mode!=="orbit")return null;let i=Q_(t.semiMajor??t.distance),r=xd(e?.properties.mass);return i===null||r===null||r<=0?null:Math.sqrt(i**3/r)*365.25}function Q_(n){if(!n)return null;switch(n.unit){case null:case"au":return n.value;case"km":return n.value/pc;case"m":return n.value/(pc*1e3);case"ly":return n.value*j_;case"pc":return n.value*G_;case"kpc":return n.value*W_;case"re":return n.value*$_/pc;case"sol":return n.value*H_/pc;default:return null}}function xd(n){if(!n||typeof n!="object"||!("value"in n))return null;let e=n;switch(e.unit){case null:case"sol":return e.value;case"me":return e.value/z_;case"mj":return e.value/V_;default:return null}}function Xm(n){if(!n)return null;switch(n.unit){case null:case"d":return n.value;case"s":return n.value/86400;case"min":return n.value/1440;case"h":return n.value/24;case"y":return n.value*365.25;case"ky":return n.value*365250;case"my":return n.value*36525e4;case"gy":return n.value*36525e7;default:return null}}function ew(n,e,t,i){n!=="topdown"&&n!=="isometric"&&n!=="orthographic"&&n!=="perspective"&&e.push(nt("validate.viewpoint.projection.invalid",`Unknown projection "${String(n)}" in viewpoint "${i}".`,void 0,t))}function tw(n,e,t,i,r,s,o,a,c){if(!n)return;let l=`viewpoint.${r}.camera`;for(let[d,h]of[["azimuth",n.azimuth],["elevation",n.elevation],["roll",n.roll],["distance",n.distance]])h!==null&&(!Number.isFinite(h)||d==="distance"&&h<=0)&&i.push(nt("validate.viewpoint.camera.invalid",`Invalid camera ${d} "${String(h)}" in viewpoint "${r}".`,void 0,`${l}.${d}`));n.distance!==null&&e!=="perspective"&&i.push(gt("validate.viewpoint.camera.distance.partialEffect",`Camera "distance" only has a semantic effect in perspective viewpoints; "${r}" uses "${e}".`,void 0,`${l}.distance`)),e==="topdown"&&(n.elevation!==null||n.roll!==null)&&i.push(gt("validate.viewpoint.camera.topdownPartial",`Camera elevation/roll on topdown viewpoint "${r}" are currently stored for future 3D use and only partially affect 2D rendering.`,void 0,l)),e==="isometric"&&n.elevation!==null&&i.push(vd("validate.viewpoint.camera.isometricStored",`Camera elevation on isometric viewpoint "${r}" is preserved semantically for future 3D rendering.`,void 0,`${l}.elevation`)),n.azimuth!==null&&n.azimuth!==0&&t!==0&&i.push(gt("validate.viewpoint.rotation.cameraOverlap",`Viewpoint "${r}" uses camera.azimuth; keep "rotation" only for 2D screen rotation to avoid ambiguity.`,void 0,`${l}.azimuth`)),s!==null&&c.has(s)||o!==null&&c.has(o)||a||i.push(vd("validate.viewpoint.camera.anchorMissing",`Viewpoint "${r}" stores camera settings without a focus object, selection, or filter anchor.`,void 0,l))}function nw(n,e,t,i){return Di(i?.epoch)??Di(t?.epoch)??Di(e.epoch)??Di(n?.epoch)??null}function iw(n,e,t,i){return Di(i?.referencePlane)??Di(t?.referencePlane)??Di(e.referencePlane)??Di(n?.referencePlane)??null}function Di(n){return typeof n=="string"&&n.trim()?n.trim():null}function rw(n,e){let t=n.tolerances?.find(i=>i.field===e)?.value;return typeof t=="number"?t:t&&typeof t=="object"&&"value"in t?Xm(t)??0:0}function sw(n){return`${Math.round(n*100)/100}d`}function nt(n,e,t,i){return{code:n,severity:"error",source:"validate",message:e,objectId:t,field:i}}function gt(n,e,t,i){return{code:n,severity:"warning",source:"validate",message:e,objectId:t,field:i}}function vd(n,e,t,i){return{code:n,severity:"info",source:"validate",message:e,objectId:t,field:i}}var ow=new Set(["climate","habitability","settlement"]),gc=new Map;for(let n of["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","kind","class","culture","tags","color","image","hidden","radius","mass","density","gravity","temperature","albedo","atmosphere","inner","outer","on","source","cycle"]){let e=an(n);e&&gc.set(n,{key:n,version:"2.0",inlineMode:e.arity==="multiple"?"multiple":"single",allowRepeat:!1,legacySchema:e})}for(let n of[{key:"groups",inlineMode:"multiple",allowRepeat:!1},{key:"epoch",inlineMode:"single",allowRepeat:!1},{key:"referencePlane",inlineMode:"single",allowRepeat:!1},{key:"tidalLock",inlineMode:"single",allowRepeat:!1},{key:"renderLabel",inlineMode:"single",allowRepeat:!1},{key:"renderOrbit",inlineMode:"single",allowRepeat:!1},{key:"renderPriority",inlineMode:"single",allowRepeat:!1},{key:"resonance",inlineMode:"pair",allowRepeat:!1},{key:"derive",inlineMode:"pair",allowRepeat:!0},{key:"validate",inlineMode:"single",allowRepeat:!0},{key:"locked",inlineMode:"multiple",allowRepeat:!1},{key:"tolerance",inlineMode:"pair",allowRepeat:!0}])gc.set(n.key,{key:n.key,version:"2.1",inlineMode:n.inlineMode,allowRepeat:n.allowRepeat});var aw=new Set(gc.keys()),Ym=new Set(["orbit","distance","semiMajor","eccentricity","period","angle","inclination","phase","at","surface","free","inner","outer","epoch","referencePlane"]);function bd(n){return cw(n)}function cw(n,e){let t=qw(n),i=t.source.split(/\r?\n/),r=[],s=!1,o="2.0",a=null,c=null,l=[],u=[],d=[],h=[],f=new Map,p=!1,y=!1,g=new Set,m=new Set,x=new Set,v=new Set,w=new Set;for(let S=0;S<i.length;S++){let P=i[S],k=S+1;if(!P.trim())continue;let O=Ja(P),H=co(P.slice(O),{line:k,columnOffset:O});if(H.length!==0){if(!s){o=lw(H,k),s=!0,t.comments.length>0&&yc(o,"2.1")&&r.push({code:"parse.schema21.commentCompatibility",severity:"warning",source:"parse",message:`Comments require schema 2.1; parsed in compatibility mode because the document header is "schema ${o}".`,line:t.comments[0].line,column:t.comments[0].column});continue}if(O===0){c=uw(H,k,o,r,a,l,u,d,h,f,g,m,x,v,w,{sawDefaults:p,sawAtlas:y}),c.kind==="system"?a=c.system:c.kind==="defaults"?p=!0:c.kind==="atlas"&&(y=!0);continue}if(!c)throw new q("Indented line without parent atlas section",k,O+1);vw(c,O,H,k)}}if(!s)throw new q('Missing required atlas schema header "schema 2.0"');let N=l.map(S=>Fw(S,o,r)),C=h.map(S=>kw(S,f.get(S.id)??[])),R=e??(o==="2.0-draft"?"2.0":o),F={format:"worldorbit",sourceVersion:"1.0",theme:null,system:a,groups:u,relations:d,events:C,objects:N,diagnostics:r};if(R==="2.0-draft"){let S={...F,version:"2.0-draft",schemaVersion:"2.0-draft"};return S.diagnostics.push(...wo(S,o)),S}let A={...F,version:R,schemaVersion:R};return o==="2.0-draft"&&A.diagnostics.push({code:"load.schema.deprecatedDraft",severity:"warning",source:"upgrade",message:'Source header "schema 2.0-draft" is deprecated; canonical v2 documents now use "schema 2.0".'}),A.diagnostics.push(...wo(A,o)),A}function lw(n,e){if(n.length!==2||n[0].value.toLowerCase()!=="schema"||!["2.0-draft","2.0","2.1","2.5","2.6"].includes(n[1].value.toLowerCase()))throw new q('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", "schema 2.6", or legacy "schema 2.0-draft"',e,n[0]?.column??1);let t=n[1].value.toLowerCase();return t==="2.6"?"2.6":t==="2.5"?"2.5":t==="2.1"?"2.1":t==="2.0-draft"?"2.0-draft":"2.0"}function uw(n,e,t,i,r,s,o,a,c,l,u,d,h,f,p,y){switch(n[0]?.value.toLowerCase()){case"system":if(r)throw new q('Atlas section "system" may only appear once',e,n[0].column);return dw(n,e,t,i);case"defaults":if(!r)throw new q('Atlas section "defaults" requires a preceding system declaration',e,n[0].column);if(y.sawDefaults)throw new q('Atlas section "defaults" may only appear once',e,n[0].column);return{kind:"defaults",system:r,sourceSchemaVersion:t,diagnostics:i,seenFields:new Set};case"atlas":if(!r)throw new q('Atlas section "atlas" requires a preceding system declaration',e,n[0].column);if(y.sawAtlas)throw new q('Atlas section "atlas" may only appear once',e,n[0].column);return{kind:"atlas",system:r,inMetadata:!1,metadataIndent:null};case"viewpoint":if(!r)throw new q('Atlas section "viewpoint" requires a preceding system declaration',e,n[0].column);return hw(n,e,r,u,t,i);case"annotation":if(!r)throw new q('Atlas section "annotation" requires a preceding system declaration',e,n[0].column);return fw(n,e,r,d);case"group":return bn(t,i,"group",{line:e,column:n[0].column}),pw(n,e,o,h);case"relation":return bn(t,i,"relation",{line:e,column:n[0].column}),mw(n,e,a,f);case"event":return bn(t,i,"event",{line:e,column:n[0].column}),gw(n,e,c,l,p,t,i);case"object":return yw(n,e,t,i,s);default:throw new q(`Unknown atlas section "${n[0]?.value??""}"`,e,n[0]?.column??1)}}function dw(n,e,t,i){if(n.length!==2)throw new q("Invalid atlas system declaration",e,n[0]?.column??1);return{kind:"system",system:{type:"system",id:n[1].value,title:null,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},sourceSchemaVersion:t,diagnostics:i,seenFields:new Set}}function hw(n,e,t,i,r,s){if(n.length!==2)throw new q("Invalid viewpoint declaration",e,n[0]?.column??1);let o=as(n[1].value);if(!o)throw new q("Viewpoint id must not be empty",e,n[1].column);if(i.has(o))throw new q(`Duplicate viewpoint id "${o}"`,e,n[1].column);let a={id:o,label:_o(o),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:t.defaults.view,preset:t.defaults.preset,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null};return t.viewpoints.push(a),i.add(o),{kind:"viewpoint",viewpoint:a,sourceSchemaVersion:r,diagnostics:s,seenFields:new Set,inFilter:!1,filterIndent:null,seenFilterFields:new Set,inCamera:!1,cameraIndent:null,seenCameraFields:new Set}}function fw(n,e,t,i){if(n.length!==2)throw new q("Invalid annotation declaration",e,n[0]?.column??1);let r=as(n[1].value);if(!r)throw new q("Annotation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate annotation id "${r}"`,e,n[1].column);let s={id:r,label:_o(r),targetObjectId:null,body:"",tags:[],sourceObjectId:null};return t.annotations.push(s),i.add(r),{kind:"annotation",annotation:s,seenFields:new Set}}function pw(n,e,t,i){if(n.length!==2)throw new q("Invalid group declaration",e,n[0]?.column??1);let r=as(n[1].value);if(!r)throw new q("Group id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate group id "${r}"`,e,n[1].column);let s={id:r,label:_o(r),summary:"",color:null,tags:[],hidden:!1};return t.push(s),i.add(r),{kind:"group",group:s,seenFields:new Set}}function mw(n,e,t,i){if(n.length!==2)throw new q("Invalid relation declaration",e,n[0]?.column??1);let r=as(n[1].value);if(!r)throw new q("Relation id must not be empty",e,n[1].column);if(i.has(r))throw new q(`Duplicate relation id "${r}"`,e,n[1].column);let s={id:r,from:"",to:"",kind:"",label:null,summary:null,tags:[],color:null,hidden:!1};return t.push(s),i.add(r),{kind:"relation",relation:s,seenFields:new Set}}function gw(n,e,t,i,r,s,o){if(n.length!==2)throw new q("Invalid event declaration",e,n[0]?.column??1);let a=as(n[1].value);if(!a)throw new q("Event id must not be empty",e,n[1].column);if(r.has(a))throw new q(`Duplicate event id "${a}"`,e,n[1].column);let c={id:a,kind:"",label:_o(a),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},l=[];return t.push(c),i.set(a,l),r.add(a),{kind:"event",event:c,sourceSchemaVersion:s,diagnostics:o,seenFields:new Set,rawPoses:l,inPositions:!1,positionsIndent:null,activePose:null,poseIndent:null,activePoseSeenFields:new Set}}function yw(n,e,t,i,r){if(n.length<3)throw new q("Invalid atlas object declaration",e,n[0]?.column??1);let s=n[1],o=n[2],a=s.value;if(!Ya.has(a)||a==="system")throw new q(`Unknown object type "${s.value}"`,e,s.column);let c={objectType:a,id:o.value,fields:Uw(n.slice(3),e,a,t,i),infoEntries:[],typedBlockEntries:{},location:{line:e,column:s.column}};return r.push(c),{kind:"object",objectNode:c,sourceSchemaVersion:t,diagnostics:i,activeBlock:null,blockIndent:null,seenInfoKeys:new Set,seenTypedBlockKeys:{}}}function vw(n,e,t,i){switch(n.kind){case"system":xw(n,t,i);return;case"defaults":bw(n,t,i);return;case"atlas":_w(n,e,t,i);return;case"viewpoint":ww(n,e,t,i);return;case"annotation":Ew(n,t,i);return;case"group":Aw(n,t,i);return;case"relation":Tw(n,t,i);return;case"event":Iw(n,e,t,i);return;case"object":Rw(n,e,t,i);return}}function xw(n,e,t){let i=ni(e,n.seenFields,t),r=lt(e,t);switch(i){case"title":n.system.title=r;return;case"description":bn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.description=r;return;case"epoch":bn(n.sourceSchemaVersion,n.diagnostics,i,{line:t,column:e[0].column}),n.system.epoch=r;return;case"referenceplane":bn(n.sourceSchemaVersion,n.diagnostics,"referencePlane",{line:t,column:e[0].column}),n.system.referencePlane=r;return;default:throw new q(`Unknown system atlas field "${e[0].value}"`,t,e[0].column)}}function bw(n,e,t){let i=ni(e,n.seenFields,t),r=lt(e,t);switch(i){case"view":Jm(r)&&dr(n.sourceSchemaVersion,n.diagnostics,"defaults.view",{line:t,column:e[0].column}),n.system.defaults.view=Zm(r,t,e[0].column);return;case"scale":n.system.defaults.scale=r;return;case"units":n.system.defaults.units=r;return;case"preset":n.system.defaults.preset=Km(r,t,e[0].column);return;case"theme":n.system.defaults.theme=r;return;default:throw new q(`Unknown defaults field "${e[0].value}"`,t,e[0].column)}}function _w(n,e,t,i){if(n.inMetadata&&e<=(n.metadataIndent??0)&&(n.inMetadata=!1,n.metadataIndent=null),n.inMetadata){let r=Qm(t,i,"Invalid atlas metadata entry");if(r.key in n.system.atlasMetadata)throw new q(`Duplicate atlas metadata key "${r.key}"`,i,t[0].column);n.system.atlasMetadata[r.key]=r.value;return}if(t.length===1&&t[0].value.toLowerCase()==="metadata"){n.inMetadata=!0,n.metadataIndent=e;return}throw new q(`Unknown atlas field "${t[0].value}"`,i,t[0].column)}function ww(n,e,t,i){if(n.inCamera&&e<=(n.cameraIndent??0)&&(n.inCamera=!1,n.cameraIndent=null),n.inFilter&&e<=(n.filterIndent??0)&&(n.inFilter=!1,n.filterIndent=null),n.inCamera){Mw(n,t,i);return}if(n.inFilter){Sw(n,t,i);return}if(t.length===1&&t[0].value.toLowerCase()==="camera"){if(dr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.seenFields.has("camera"))throw new q('Duplicate viewpoint field "camera"',i,t[0].column);n.seenFields.add("camera"),n.inCamera=!0,n.cameraIndent=e,n.viewpoint.camera=n.viewpoint.camera??wd();return}if(t.length===1&&t[0].value.toLowerCase()==="filter"){if(n.seenFields.has("filter"))throw new q('Duplicate viewpoint field "filter"',i,t[0].column);n.seenFields.add("filter"),n.inFilter=!0,n.filterIndent=e;return}let r=ni(t,n.seenFields,i),s=lt(t,i);switch(r){case"label":n.viewpoint.label=s;return;case"summary":n.viewpoint.summary=s;return;case"focus":n.viewpoint.focusObjectId=s;return;case"select":n.viewpoint.selectedObjectId=s;return;case"projection":Jm(s)&&dr(n.sourceSchemaVersion,n.diagnostics,"projection",{line:i,column:t[0].column}),n.viewpoint.projection=Zm(s,i,t[0].column);return;case"preset":n.viewpoint.preset=Km(s,i,t[0].column);return;case"zoom":n.viewpoint.zoom=_d(s,i,t[0].column,"zoom");return;case"rotation":n.viewpoint.rotationDeg=Ui(s,i,t[0].column,"rotation");return;case"camera":dr(n.sourceSchemaVersion,n.diagnostics,"viewpoint.camera",{line:i,column:t[0].column}),n.viewpoint.camera=Ow(t.slice(1),i,n.viewpoint.camera);return;case"layers":n.viewpoint.layers=Lw(t.slice(1),i,n.sourceSchemaVersion,n.diagnostics);return;case"events":bn(n.sourceSchemaVersion,n.diagnostics,"viewpoint.events",{line:i,column:t[0].column}),n.viewpoint.events=Bn(t.slice(1),i,"events");return;default:throw new q(`Unknown viewpoint field "${t[0].value}"`,i,t[0].column)}}function Mw(n,e,t){let i=ni(e,n.seenCameraFields,t),r=lt(e,t),s=n.viewpoint.camera??wd();switch(i){case"azimuth":s.azimuth=Ui(r,t,e[0].column,"camera.azimuth");break;case"elevation":s.elevation=Ui(r,t,e[0].column,"camera.elevation");break;case"roll":s.roll=Ui(r,t,e[0].column,"camera.roll");break;case"distance":s.distance=_d(r,t,e[0].column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${e[0].value}"`,t,e[0].column)}n.viewpoint.camera=s}function Sw(n,e,t){let i=ni(e,n.seenFilterFields,t),r=n.viewpoint.filter??Dw();switch(i){case"query":r.query=lt(e,t);break;case"objecttypes":r.objectTypes=Pw(e.slice(1),t);break;case"tags":r.tags=Bn(e.slice(1),t,"tags");break;case"groups":r.groupIds=Bn(e.slice(1),t,"groups");break;default:throw new q(`Unknown viewpoint filter field "${e[0].value}"`,t,e[0].column)}n.viewpoint.filter=r}function Ew(n,e,t){switch(ni(e,n.seenFields,t)){case"label":n.annotation.label=lt(e,t);return;case"target":n.annotation.targetObjectId=lt(e,t);return;case"body":n.annotation.body=lt(e,t);return;case"tags":n.annotation.tags=Bn(e.slice(1),t,"tags");return;default:throw new q(`Unknown annotation field "${e[0].value}"`,t,e[0].column)}}function Aw(n,e,t){switch(ni(e,n.seenFields,t)){case"label":n.group.label=lt(e,t);return;case"summary":n.group.summary=lt(e,t);return;case"color":n.group.color=lt(e,t);return;case"tags":n.group.tags=Bn(e.slice(1),t,"tags");return;case"hidden":n.group.hidden=Li(lt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown group field "${e[0].value}"`,t,e[0].column)}}function Tw(n,e,t){switch(ni(e,n.seenFields,t)){case"from":n.relation.from=lt(e,t);return;case"to":n.relation.to=lt(e,t);return;case"kind":n.relation.kind=lt(e,t);return;case"label":n.relation.label=lt(e,t);return;case"summary":n.relation.summary=lt(e,t);return;case"tags":n.relation.tags=Bn(e.slice(1),t,"tags");return;case"color":n.relation.color=lt(e,t);return;case"hidden":n.relation.hidden=Li(lt(e,t),"hidden",{line:t,column:e[0].column});return;default:throw new q(`Unknown relation field "${e[0].value}"`,t,e[0].column)}}function Iw(n,e,t,i){if(n.activePose&&e<=(n.poseIndent??0)&&(n.activePose=null,n.poseIndent=null,n.activePoseSeenFields.clear()),!n.activePose&&n.inPositions&&e<=(n.positionsIndent??0)&&(n.inPositions=!1,n.positionsIndent=null),n.activePose){(t[0]?.value==="epoch"||t[0]?.value==="referencePlane")&&dr(n.sourceSchemaVersion,n.diagnostics,`pose.${t[0].value}`,{line:i,column:t[0]?.column??1}),n.activePose.fields.push(Cw(t,i,n.activePoseSeenFields));return}if(n.inPositions){if(t.length!==2||t[0].value.toLowerCase()!=="pose")throw new q(`Unknown event positions field "${t[0].value}"`,i,t[0]?.column??1);let s=t[1].value;if(!s.trim())throw new q("Event pose object id must not be empty",i,t[1].column);let o={objectId:s,fields:[],location:{line:i,column:t[0].column}};n.rawPoses.push(o),n.activePose=o,n.poseIndent=e,n.activePoseSeenFields=new Set;return}if(t.length===1&&t[0].value.toLowerCase()==="positions"){if(n.seenFields.has("positions"))throw new q('Duplicate event field "positions"',i,t[0].column);n.seenFields.add("positions"),n.inPositions=!0,n.positionsIndent=e;return}switch(ni(t,n.seenFields,i)){case"kind":n.event.kind=lt(t,i);return;case"label":n.event.label=lt(t,i);return;case"summary":n.event.summary=lt(t,i);return;case"target":n.event.targetObjectId=lt(t,i);return;case"participants":n.event.participantObjectIds=Bn(t.slice(1),i,"participants");return;case"timing":n.event.timing=lt(t,i);return;case"visibility":n.event.visibility=lt(t,i);return;case"epoch":dr(n.sourceSchemaVersion,n.diagnostics,"event.epoch",{line:i,column:t[0].column}),n.event.epoch=lt(t,i);return;case"referenceplane":dr(n.sourceSchemaVersion,n.diagnostics,"event.referencePlane",{line:i,column:t[0].column}),n.event.referencePlane=lt(t,i);return;case"tags":n.event.tags=Bn(t.slice(1),i,"tags");return;case"color":n.event.color=lt(t,i);return;case"hidden":n.event.hidden=Li(lt(t,i),"hidden",{line:i,column:t[0].column});return;default:throw new q(`Unknown event field "${t[0].value}"`,i,t[0].column)}}function Cw(n,e,t){if(n.length<2)throw new q("Invalid event pose field line",e,n[0]?.column??1);let i=n[0].value;if(!Ym.has(i))throw new q(`Unknown event pose field "${i}"`,e,n[0].column);if(t.has(i))throw new q(`Duplicate event pose field "${i}"`,e,n[0].column);return t.add(i),{type:"field",key:i,values:n.slice(1).map(r=>r.value),location:{line:e,column:n[0].column}}}function Rw(n,e,t,i){if(n.activeBlock&&e<=(n.blockIndent??0)&&(n.activeBlock=null,n.blockIndent=null),t.length===1){let r=t[0].value.toLowerCase();if(r==="info"||ow.has(r)){r!=="info"&&bn(n.sourceSchemaVersion,n.diagnostics,r,{line:i,column:t[0].column}),n.activeBlock=r,n.blockIndent=e;return}}if(n.activeBlock){let r=Qm(t,i,`Invalid ${n.activeBlock} entry`);if(n.activeBlock==="info"){if(n.seenInfoKeys.has(r.key))throw new q(`Duplicate info key "${r.key}"`,i,t[0].column);n.seenInfoKeys.add(r.key),n.objectNode.infoEntries.push(r);return}let s=n.activeBlock,o=n.seenTypedBlockKeys[s]??(n.seenTypedBlockKeys[s]=new Set);if(o.has(r.key))throw new q(`Duplicate ${s} key "${r.key}"`,i,t[0].column);o.add(r.key),(n.objectNode.typedBlockEntries[s]??(n.objectNode.typedBlockEntries[s]=[])).push(r);return}n.objectNode.fields.push(Nw(t,i,n.objectNode.objectType,n.sourceSchemaVersion,n.diagnostics))}function ni(n,e,t){if(n.length<2)throw new q("Invalid atlas field line",t,n[0]?.column??1);let i=n[0].value.toLowerCase();if(e.has(i))throw new q(`Duplicate atlas field "${n[0].value}"`,t,n[0].column);return e.add(i),i}function lt(n,e){if(n.length<2)throw new q("Missing value for atlas field",e,n[0]?.column??1);return n.slice(1).map(t=>t.value).join(" ").trim()}function Pw(n,e){return Bn(n,e,"objectTypes").filter(t=>t==="star"||t==="planet"||t==="moon"||t==="belt"||t==="asteroid"||t==="comet"||t==="ring"||t==="structure"||t==="phenomenon")}function Lw(n,e,t,i){let r={};for(let s of Bn(n,e,"layers")){let o=!s.startsWith("-")&&!s.startsWith("!"),a=s.replace(/^[-!]+/,"").toLowerCase();if(a==="orbits"){r["orbits-back"]=o,r["orbits-front"]=o;continue}(a==="background"||a==="guides"||a==="orbits-back"||a==="orbits-front"||a==="relations"||a==="events"||a==="objects"||a==="labels"||a==="metadata")&&(a==="events"&&t&&i&&bn(t,i,"layers.events",{line:e,column:n[0]?.column??1}),r[a]=o)}return r}function Bn(n,e,t){if(n.length===0)throw new q(`Missing value for atlas field "${t}"`,e,1);let i=n.map(r=>r.value).filter(Boolean);if(i.length===0)throw new q(`Missing value for atlas field "${t}"`,e,n[0]?.column??1);return i}function Zm(n,e,t){let i=n.toLowerCase();if(i!=="topdown"&&i!=="isometric"&&i!=="orthographic"&&i!=="perspective")throw new q(`Unknown projection "${n}"`,e,t);return i}function Jm(n){let e=n.toLowerCase();return e==="orthographic"||e==="perspective"}function Km(n,e,t){let i=n.toLowerCase();if(i==="diagram"||i==="presentation"||i==="atlas-card"||i==="markdown")return i;throw new q(`Unknown render preset "${n}"`,e,t)}function _d(n,e,t,i){let r=Ui(n,e,t,i);if(r<=0)throw new q(`Field "${i}" must be greater than zero`,e,t);return r}function Ui(n,e,t,i){let r=Number(n);if(!Number.isFinite(r))throw new q(`Invalid numeric value "${n}" for "${i}"`,e,t);return r}function Dw(){return{query:null,objectTypes:[],tags:[],groupIds:[]}}function wd(){return{azimuth:null,elevation:null,roll:null,distance:null}}function Ow(n,e,t){if(n.length===0||n.length%2!==0)throw new q('Field "camera" expects "<field> <value>" pairs',e,n[0]?.column??1);let i=t?{...t}:wd(),r=new Set;for(let s=0;s<n.length;s+=2){let o=n[s],a=n[s+1],c=o.value.toLowerCase();if(r.has(c))throw new q(`Duplicate viewpoint camera field "${o.value}"`,e,o.column);r.add(c);let l=a.value;switch(c){case"azimuth":i.azimuth=Ui(l,e,o.column,"camera.azimuth");break;case"elevation":i.elevation=Ui(l,e,o.column,"camera.elevation");break;case"roll":i.roll=Ui(l,e,o.column,"camera.roll");break;case"distance":i.distance=_d(l,e,o.column,"camera.distance");break;default:throw new q(`Unknown viewpoint camera field "${o.value}"`,e,o.column)}}return i}function Uw(n,e,t,i,r){let s=[],o=0;for(;o<n.length;){let a=n[o],c=Mo(a.value);if(!c)throw new q(`Unknown field "${a.value}"`,e,a.column);c.version==="2.1"&&bn(i,r,a.value,{line:e,column:a.column}),o++;let l=[];if(c.inlineMode==="single"){let u=n[o];u&&(l.push(u),o++)}else if(c.inlineMode==="pair")for(let u=0;u<2;u++){let d=n[o];if(!d)break;l.push(d),o++}else for(;o<n.length&&!aw.has(n[o].value);)l.push(n[o]),o++;if(l.length===0)throw new q(`Missing value for field "${a.value}"`,e,a.column);s.push({type:"field",key:a.value,values:l.map(u=>u.value),location:{line:e,column:a.column}})}return ig(s,t),s}function Nw(n,e,t,i,r){if(n.length<2)throw new q("Invalid field line",e,n[0]?.column??1);let s=Mo(n[0].value);if(!s)throw new q(`Unknown field "${n[0].value}"`,e,n[0].column);s.version==="2.1"&&bn(i,r,n[0].value,{line:e,column:n[0].column});let o={type:"field",key:n[0].value,values:n.slice(1).map(a=>a.value),location:{line:e,column:n[0].column}};return ig([o],t),o}function Qm(n,e,t){if(n.length<2)throw new q(t,e,n[0]?.column??1);return{type:"info-entry",key:n[0].value,value:n.slice(1).map(i=>i.value).join(" "),location:{line:e,column:n[0].column}}}function Fw(n,e,t){let i=eg(n.fields),r=tg(i),s=zw(n.objectType,i),o=Ww(i.get("groups")?.[0]),a=mc(i.get("epoch")?.[0]),c=mc(i.get("referencePlane")?.[0]),l=i.has("tidalLock")?Li(In(i.get("tidalLock")[0]),"tidalLock",i.get("tidalLock")[0].location):void 0,u=i.has("resonance")?Hw(i.get("resonance")[0]):void 0,d=$w(i),h=i.get("derive")?.map(v=>jw(v)),f=i.get("validate")?.map(v=>({rule:In(v)})),p=i.has("locked")?[...new Set(i.get("locked").flatMap(v=>v.values))]:void 0,y=i.get("tolerance")?.map(v=>Gw(v)),g=Vw(n.typedBlockEntries),m=ng(n.infoEntries,"info"),x={type:n.objectType,id:n.id,properties:s,placement:r,info:m};return o.length>0&&(x.groups=o),a&&(x.epoch=a),c&&(x.referencePlane=c),l!==void 0&&(x.tidalLock=l),u&&(x.resonance=u),d&&(x.renderHints=d),h?.length&&(x.deriveRules=h),f?.length&&(x.validationRules=f),p?.length&&(x.lockedFields=p),y?.length&&(x.tolerances=y),g&&Object.keys(g).length>0&&(x.typedBlocks=g),yc(e,"2.1")&&(x.groups||x.epoch||x.referencePlane||x.tidalLock!==void 0||x.resonance||x.renderHints||x.deriveRules?.length||x.validationRules?.length||x.lockedFields?.length||x.tolerances?.length||x.typedBlocks)&&bn(e,t,n.id,n.location),x}function kw(n,e){return{...n,participantObjectIds:[...new Set(n.participantObjectIds)],tags:[...new Set(n.tags)],positions:e.map(t=>Bw(t))}}function Bw(n){let e=eg(n.fields,"event-pose"),t=tg(e);return{objectId:n.objectId,placement:t,inner:Oi(e.get("inner")?.[0],"inner"),outer:Oi(e.get("outer")?.[0],"outer"),epoch:mc(e.get("epoch")?.[0]),referencePlane:mc(e.get("referencePlane")?.[0])}}function eg(n,e="object"){let t=new Map;for(let i of n){let r=Mo(i.key);if(!r&&!Ym.has(i.key))throw q.fromLocation(`Unknown field "${i.key}"`,i.location);if(!r?.allowRepeat&&t.has(i.key))throw q.fromLocation(`Duplicate field "${i.key}"`,i.location);let s=t.get(i.key)??[];s.push(i),t.set(i.key,s)}return t}function tg(n){let e=n.get("orbit")?.[0],t=n.get("at")?.[0],i=n.get("surface")?.[0],r=n.get("free")?.[0];if([e,t,i,r].filter(Boolean).length>1){let o=e??t??i??r;throw q.fromLocation("Object has multiple placement modes",o?.location)}if(e)return{mode:"orbit",target:In(e),distance:Oi(n.get("distance")?.[0],"distance"),semiMajor:Oi(n.get("semiMajor")?.[0],"semiMajor"),eccentricity:Xw(n.get("eccentricity")?.[0],"eccentricity"),period:Oi(n.get("period")?.[0],"period"),angle:Oi(n.get("angle")?.[0],"angle"),inclination:Oi(n.get("inclination")?.[0],"inclination"),phase:Oi(n.get("phase")?.[0],"phase")};if(t){let o=In(t);return{mode:"at",target:o,reference:Hm(o,t.location)}}if(i)return{mode:"surface",target:In(i)};if(r){let o=In(r),a=gd(o);return{mode:"free",distance:a??void 0,descriptor:a?void 0:o}}return null}function zw(n,e){let t={};for(let[i,r]of e.entries()){let s=r[0],o=Mo(i);!s||!o?.legacySchema||o.legacySchema.placement||(yd(i,n,s.location),t[i]=jm(i,s.values,s.location))}return t}function ng(n,e){let t={};for(let i of n){if(i.key in t)throw q.fromLocation(`Duplicate ${e} key "${i.key}"`,i.location);t[i.key]=i.value}return t}function Vw(n){let e={};for(let t of Object.keys(n)){let i=n[t];i?.length&&(e[t]=ng(i,t))}return e}function $w(n){let e={},t=n.get("renderLabel")?.[0],i=n.get("renderOrbit")?.[0],r=n.get("renderPriority")?.[0];return t&&(e.renderLabel=Li(In(t),"renderLabel",t.location)),i&&(e.renderOrbit=Li(In(i),"renderOrbit",i.location)),r&&(e.renderPriority=fc(In(r),"renderPriority",r.location)),Object.keys(e).length>0?e:void 0}function Hw(n){if(n.values.length!==2)throw q.fromLocation('Field "resonance" expects "<targetObjectId> <ratio>"',n.location);let e=n.values[1];if(!/^\d+:\d+$/.test(e))throw q.fromLocation(`Invalid resonance ratio "${e}"`,n.location);return{targetObjectId:n.values[0],ratio:e}}function jw(n){if(n.values.length!==2)throw q.fromLocation('Field "derive" expects "<field> <strategy>"',n.location);return{field:n.values[0],strategy:n.values[1]}}function Gw(n){if(n.values.length!==2)throw q.fromLocation('Field "tolerance" expects "<field> <value>"',n.location);let e=n.values[1],t=gd(e),i=Number(e);return{field:n.values[0],value:t??(Number.isFinite(i)?i:e)}}function Ww(n){return n?[...new Set(n.values)]:[]}function mc(n){return n&&n.values.join(" ").trim()||null}function Oi(n,e){return n?md(In(n),n.location,e):void 0}function Xw(n,e){return n?fc(In(n),e,n.location):void 0}function In(n){return bo(n.values,n.key,n.location)}function Mo(n){return gc.get(n)}function ig(n,e){for(let t of n){let i=Mo(t.key);if(!i)throw q.fromLocation(`Unknown field "${t.key}"`,t.location);if(i.legacySchema){yd(t.key,e,t.location);continue}if((t.key==="renderLabel"||t.key==="renderOrbit"||t.key==="tidalLock")&&t.values.length!==1)throw q.fromLocation(`Field "${t.key}" expects exactly one value`,t.location)}}function bn(n,e,t,i){yc(n,"2.1")&&e.push({code:"parse.schema21.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.1; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function dr(n,e,t,i){yc(n,"2.5")&&e.push({code:"parse.schema25.featureCompatibility",severity:"warning",source:"parse",message:`Feature "${t}" requires schema 2.5; parsed in compatibility mode because the document header is "schema ${n}".`,line:i.line,column:i.column})}function yc(n,e){return qm(n)<qm(e)}function qm(n){switch(n){case"2.0-draft":return 0;case"2.0":return 1;case"2.1":return 2;case"2.5":return 3;case"2.6":return 4;default:return 5}}function qw(n){let e=[...n],t=[],i=!1,r=!1,s=null,o=1,a=1;for(let c=0;c<e.length;c++){let l=e[c],u=e[c+1];if(r){if(l==="*"&&u==="/"){e[c]=" ",e[c+1]=" ",r=!1,s=null,c++,a+=2;continue}l!==`
3825
3825
  `&&l!=="\r"&&(e[c]=" "),l===`
3826
3826
  `?(o++,a=1):a++;continue}if(!i&&l==="/"&&u==="*"){t.push({kind:"block",line:o,column:a}),e[c]=" ",e[c+1]=" ",r=!0,s={line:o,column:a},c++,a+=2;continue}if(!i&&l==="#"&&!Yw(e,c)){t.push({kind:"line",line:o,column:a}),e[c]=" ";let d=c+1;for(;d<e.length&&e[d]!==`
3827
3827
  `&&e[d]!=="\r";)e[d]=" ",d++;a+=d-c,c=d-1;continue}l==='"'&&e[c-1]!=="\\"&&(i=!i),l===`
3828
3828
  `?(o++,a=1):a++}if(r)throw q.fromLocation("Unclosed block comment",s??void 0);return{source:e.join(""),comments:t}}function Yw(n,e){let t=e+1,i=0;for(;t<n.length&&/[0-9a-f]/i.test(n[t]??"");)t++,i++;if(![3,4,6,8].includes(i))return!1;let r=n[t];return r===void 0||r===" "||r===" "||r==="\r"||r===`
3829
- `}function vc(n="WorldOrbit",e="2.6"){return{format:"worldorbit",version:e,schemaVersion:e,sourceVersion:"1.0",theme:{preset:"blueprint",styles:{}},system:{type:"system",id:n,title:n,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},groups:[],relations:[],events:[],objects:[],diagnostics:[]}}function st(n){return structuredClone(n)}function _d(n,e){switch(e.kind){case"system":return n.system;case"defaults":return n.system?.defaults??null;case"metadata":return e.key?n.system?.atlasMetadata[e.key]??null:null;case"group":return e.id?ag(n,e.id):null;case"event":return e.id?xc(n,e.id):null;case"event-pose":return e.id&&e.key?lg(n,e.id,e.key):null;case"object":return e.id?og(n,e.id):null;case"viewpoint":return e.id?ug(n.system,e.id):null;case"annotation":return e.id?dg(n.system,e.id):null;case"relation":return e.id?cg(n,e.id):null}}function wd(n,e){let t=st(n),i=sg(t);switch(e.kind){case"metadata":return e.key&&delete i.atlasMetadata[e.key],t;case"object":return e.id&&(t.objects=t.objects.filter(r=>r.id!==e.id)),t;case"group":return e.id&&(t.groups=t.groups.filter(r=>r.id!==e.id)),t;case"event":return e.id&&(t.events=t.events.filter(r=>r.id!==e.id)),t;case"event-pose":if(e.id&&e.key){let r=xc(t,e.id);r&&(r.positions=r.positions.filter(s=>s.objectId!==e.key))}return t;case"viewpoint":return e.id&&(i.viewpoints=i.viewpoints.filter(r=>r.id!==e.id)),t;case"annotation":return e.id&&(i.annotations=i.annotations.filter(r=>r.id!==e.id)),t;case"relation":return e.id&&(t.relations=t.relations.filter(r=>r.id!==e.id)),t;default:return t}}function Mo(n,e){return e.map(t=>({diagnostic:t,path:rg(n,t)}))}function rg(n,e){if(e.objectId&&og(n,e.objectId))return{kind:"object",id:e.objectId};if(e.field?.startsWith("group.")){let t=e.field.split(".");if(t[1]&&ag(n,t[1]))return{kind:"group",id:t[1]}}if(e.field?.startsWith("viewpoint.")){let t=e.field.split(".");if(t[1]&&ug(n.system,t[1]))return{kind:"viewpoint",id:t[1]}}if(e.field?.startsWith("annotation.")){let t=e.field.split(".");if(t[1]&&dg(n.system,t[1]))return{kind:"annotation",id:t[1]}}if(e.field?.startsWith("relation.")){let t=e.field.split(".");if(t[1]&&cg(n,t[1]))return{kind:"relation",id:t[1]}}if(e.field?.startsWith("event.")){let t=e.field.split(".");if(t[1]&&xc(n,t[1]))return t[2]==="pose"&&t[3]&&lg(n,t[1],t[3])?{kind:"event-pose",id:t[1],key:t[3]}:{kind:"event",id:t[1]}}return e.field&&e.field in sg(n).atlasMetadata?{kind:"metadata",key:e.field}:null}function Md(n){let e=[...n.diagnostics,..._o(n,n.version)];return Mo(n,e)}function sg(n){return n.system||(n.system=vc().system),n.system}function og(n,e){return n.objects.find(t=>t.id===e)??null}function ag(n,e){return n.groups.find(t=>t.id===e)??null}function cg(n,e){return n.relations.find(t=>t.id===e)??null}function xc(n,e){return n.events.find(t=>t.id===e)??null}function lg(n,e,t){return xc(n,e)?.positions.find(i=>i.objectId===t)??null}function ug(n,e){return n?.viewpoints.find(t=>t.id===e)??null}function dg(n,e){return n?.annotations.find(t=>t.id===e)??null}var Zw=/^schema\s+2(?:\.0|\.1|\.5|\.6)?$/i,Jw=/^schema\s+2\.1$/i,Kw=/^schema\s+2\.5$/i,Qw=/^schema\s+2\.6$/i,eM=/^schema\s+2\.0-draft$/i;function hg(n){for(let e of tM(n).split(/\r?\n/)){let t=e.trim();if(t)return eM.test(t)?"2.0-draft":Jw.test(t)?"2.1":Kw.test(t)?"2.5":Qw.test(t)?"2.6":Zw.test(t)?"2.0":"1.0"}return"1.0"}function tM(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],o=e[r+1];if(i){if(s==="*"&&o==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3829
+ `}function vc(n="WorldOrbit",e="2.6"){return{format:"worldorbit",version:e,schemaVersion:e,sourceVersion:"1.0",theme:{preset:"blueprint",styles:{}},system:{type:"system",id:n,title:n,description:null,epoch:null,referencePlane:null,defaults:{view:"topdown",scale:null,units:null,preset:null,theme:null},atlasMetadata:{},viewpoints:[],annotations:[]},groups:[],relations:[],events:[],objects:[],diagnostics:[]}}function st(n){return structuredClone(n)}function Md(n,e){switch(e.kind){case"system":return n.system;case"defaults":return n.system?.defaults??null;case"metadata":return e.key?n.system?.atlasMetadata[e.key]??null:null;case"group":return e.id?ag(n,e.id):null;case"event":return e.id?xc(n,e.id):null;case"event-pose":return e.id&&e.key?lg(n,e.id,e.key):null;case"object":return e.id?og(n,e.id):null;case"viewpoint":return e.id?ug(n.system,e.id):null;case"annotation":return e.id?dg(n.system,e.id):null;case"relation":return e.id?cg(n,e.id):null}}function Sd(n,e){let t=st(n),i=sg(t);switch(e.kind){case"metadata":return e.key&&delete i.atlasMetadata[e.key],t;case"object":return e.id&&(t.objects=t.objects.filter(r=>r.id!==e.id)),t;case"group":return e.id&&(t.groups=t.groups.filter(r=>r.id!==e.id)),t;case"event":return e.id&&(t.events=t.events.filter(r=>r.id!==e.id)),t;case"event-pose":if(e.id&&e.key){let r=xc(t,e.id);r&&(r.positions=r.positions.filter(s=>s.objectId!==e.key))}return t;case"viewpoint":return e.id&&(i.viewpoints=i.viewpoints.filter(r=>r.id!==e.id)),t;case"annotation":return e.id&&(i.annotations=i.annotations.filter(r=>r.id!==e.id)),t;case"relation":return e.id&&(t.relations=t.relations.filter(r=>r.id!==e.id)),t;default:return t}}function So(n,e){return e.map(t=>({diagnostic:t,path:rg(n,t)}))}function rg(n,e){if(e.objectId&&og(n,e.objectId))return{kind:"object",id:e.objectId};if(e.field?.startsWith("group.")){let t=e.field.split(".");if(t[1]&&ag(n,t[1]))return{kind:"group",id:t[1]}}if(e.field?.startsWith("viewpoint.")){let t=e.field.split(".");if(t[1]&&ug(n.system,t[1]))return{kind:"viewpoint",id:t[1]}}if(e.field?.startsWith("annotation.")){let t=e.field.split(".");if(t[1]&&dg(n.system,t[1]))return{kind:"annotation",id:t[1]}}if(e.field?.startsWith("relation.")){let t=e.field.split(".");if(t[1]&&cg(n,t[1]))return{kind:"relation",id:t[1]}}if(e.field?.startsWith("event.")){let t=e.field.split(".");if(t[1]&&xc(n,t[1]))return t[2]==="pose"&&t[3]&&lg(n,t[1],t[3])?{kind:"event-pose",id:t[1],key:t[3]}:{kind:"event",id:t[1]}}return e.field&&e.field in sg(n).atlasMetadata?{kind:"metadata",key:e.field}:null}function Ed(n){let e=[...n.diagnostics,...wo(n,n.version)];return So(n,e)}function sg(n){return n.system||(n.system=vc().system),n.system}function og(n,e){return n.objects.find(t=>t.id===e)??null}function ag(n,e){return n.groups.find(t=>t.id===e)??null}function cg(n,e){return n.relations.find(t=>t.id===e)??null}function xc(n,e){return n.events.find(t=>t.id===e)??null}function lg(n,e,t){return xc(n,e)?.positions.find(i=>i.objectId===t)??null}function ug(n,e){return n?.viewpoints.find(t=>t.id===e)??null}function dg(n,e){return n?.annotations.find(t=>t.id===e)??null}var Zw=/^schema\s+2(?:\.0|\.1|\.5|\.6)?$/i,Jw=/^schema\s+2\.1$/i,Kw=/^schema\s+2\.5$/i,Qw=/^schema\s+2\.6$/i,eM=/^schema\s+2\.0-draft$/i;function hg(n){for(let e of tM(n).split(/\r?\n/)){let t=e.trim();if(t)return eM.test(t)?"2.0-draft":Jw.test(t)?"2.1":Kw.test(t)?"2.5":Qw.test(t)?"2.6":Zw.test(t)?"2.0":"1.0"}return"1.0"}function tM(n){let e=[...n],t=!1,i=!1;for(let r=0;r<e.length;r++){let s=e[r],o=e[r+1];if(i){if(s==="*"&&o==="/"){e[r]=" ",e[r+1]=" ",i=!1,r++;continue}s!==`
3830
3830
  `&&s!=="\r"&&(e[r]=" ");continue}if(!t&&s==="/"&&o==="*"){e[r]=" ",e[r+1]=" ",i=!0,r++;continue}if(!t&&s==="#"){e[r]=" ";let a=r+1;for(;a<e.length&&e[a]!==`
3831
- `&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function ni(n){let e=So(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new q(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function So(n){let e=hg(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5"||e==="2.6")return nM(n,e);let t;try{t=co(n)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"parse")]}}let i;try{i=lo(t)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"normalize")]}}try{uo(i)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function nM(n,e){let t;try{t=vd(n)}catch(o){return{ok:!1,value:null,diagnostics:[lr(o,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(o=>o.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=ns(t)}catch(o){return{ok:!1,value:null,diagnostics:[lr(o,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var bc=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},ii=class extends bc{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var rM={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},_c={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",spaceFog:"#07131d",starfield:"rgba(226, 239, 255, 0.9)",starfieldDim:"rgba(164, 194, 228, 0.45)",objectSpecular:"#f5f8ff",orbitOpacity:.34,orbitBandOpacity:.24,selectionHalo:"rgba(255, 214, 139, 0.9)",atmosphere:"rgba(143, 202, 255, 0.4)",cometTail:"rgba(193, 243, 255, 0.7)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",spaceFog:"#071723",starfield:"rgba(220, 255, 245, 0.9)",starfieldDim:"rgba(124, 212, 195, 0.42)",objectSpecular:"#ecfffb",orbitOpacity:.3,orbitBandOpacity:.22,selectionHalo:"rgba(120, 255, 215, 0.85)",atmosphere:"rgba(120, 255, 215, 0.32)",cometTail:"rgba(181, 255, 236, 0.68)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",spaceFog:"#1c0d12",starfield:"rgba(255, 232, 214, 0.88)",starfieldDim:"rgba(255, 176, 138, 0.38)",objectSpecular:"#fff0e6",orbitOpacity:.3,orbitBandOpacity:.24,selectionHalo:"rgba(255, 178, 125, 0.85)",atmosphere:"rgba(255, 190, 140, 0.26)",cometTail:"rgba(255, 214, 173, 0.62)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function ss(n){return n?typeof n=="string"?_c[n]??_c.atlas:{..._c.atlas,...n}:_c.atlas}function Sd(n){return{...rM,...n}}function Bn(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:Ed(n.objectTypes??[]),tags:Ed((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:Ed((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return sM(e)?e:null}function sM(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function wc(n,e){let t=Bn(e),i=new Set;for(let r of n.objects)if(!r.hidden&&oM(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function Ad(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:aM(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>fg(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>fg(r,1))}function pg(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,bodyScaleMode:e.bodyScaleMode,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:Bn(t)}}function Td(n){return encodeURIComponent(JSON.stringify(n))}function Id(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,bodyScaleMode:e.renderOptions?.bodyScaleMode,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:Bn(e.filter??null)}}function mg(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,bodyScaleMode:t.renderOptions.bodyScaleMode,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function Cd(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function Rd(n){return n?.filter?Bn({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function fg(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function oM(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=gg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function aM(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=gg(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(c=>r.includes(c))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(c=>typeof c=="string"):[]).some(c=>c.toLowerCase()===e)&&(s+=18),s}function gg(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function Ed(n){return[...new Set(n)]}var In={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function yg(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function Mc(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function os(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function Pd(n,e){return{...n,rotationDeg:yg(n.rotationDeg+e)}}function Eo(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=cs(n),o=Mc(e.scale*t,r);if(o===e.scale)return e;let a=o/e.scale,c=i.x-s.x,l=i.y-s.y;return{...e,scale:o,translateX:(1-a)*c+a*e.translateX,translateY:(1-a)*l+a*e.translateY}}function as(n,e,t){let i=cs(n),r=cM(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),o=Math.max(n.height-t.fitPadding*2,1),a=Math.max(r.width,1),c=Math.max(r.height,1),l=Mc(Math.min(s/a,o/c),t),u=rn({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:l,translateX:i.x-(i.x+(u.x-i.x)*l),translateY:i.y-(i.y+(u.y-i.y)*l)}}function Ld(n,e,t,i){let r=n.objects.find(c=>c.objectId===t&&!c.hidden);if(!r)return e;let s=cs(n),o=Mc(Math.max(e.scale,1.8),i),a=rn({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:o,translateX:s.x-(s.x+(a.x-s.x)*o),translateY:s.y-(s.y+(a.y-s.y)*o),selectedObjectId:t}}function Dd(n,e){let t=cs(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function hr(n,e,t){let i=cs(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},o={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},a=rn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Ao(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(a=>hr(n,e,a)),i=Math.min(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x)),o=Math.max(...t.map(a=>a.y));return{minX:i,minY:r,maxX:s,maxY:o,width:s-i,height:o-r,centerX:i+(s-i)/2,centerY:r+(o-r)/2}}function cs(n){return{x:n.width/2,y:n.height/2}}function cM(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(c=>rn(c,e,t)),r=Math.min(...i.map(c=>c.x)),s=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),a=Math.max(...i.map(c=>c.y));return{minX:r,minY:s,maxX:o,maxY:a,width:o-r,height:a-s,centerX:r+(o-r)/2,centerY:s+(a-s)/2}}var Od="worldorbit-camera-root";function ri(n,e={}){let t=ss(e.theme),i=SM(e.preset??n.renderPreset??void 0),r=Sd({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=wc(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)).sort((x,v)=>x.sortKey-v.sortKey),c=n.labels.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)),l=dM(a),u=r.orbits?uM(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Sc(x.object)).map(x=>`<line class="wo-leader wo-leader-${x.mode}" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Dt(x.renderId)}" data-group-id="${Wt(x.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(x=>!x.hidden).filter(x=>o.has(x.fromObjectId)&&o.has(x.toObjectId)).map(x=>`<line class="wo-relation" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Dt(x.renderId)}" data-relation-id="${Wt(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>lM(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>hM(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?c.map(x=>fM(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Dt(n.title)}</text>
3831
+ `&&e[a]!=="\r";)e[a]=" ",a++;r=a-1;continue}s==='"'&&e[r-1]!=="\\"&&(t=!t)}return e.join("")}function ii(n){let e=Eo(n);if(!e.ok||!e.value){let t=e.diagnostics[0];throw new q(t?.message??"Failed to load WorldOrbit source",t?.line,t?.column)}return e.value}function Eo(n){let e=hg(n);if(e==="2.0"||e==="2.0-draft"||e==="2.1"||e==="2.5"||e==="2.6")return nM(n,e);let t;try{t=lo(n)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"parse")]}}let i;try{i=uo(t)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"normalize")]}}try{ho(i)}catch(r){return{ok:!1,value:null,diagnostics:[lr(r,"validate")]}}return{ok:!0,value:{schemaVersion:e,ast:t,document:i,atlasDocument:null,draftDocument:null,diagnostics:[]},diagnostics:[]}}function nM(n,e){let t;try{t=bd(n)}catch(o){return{ok:!1,value:null,diagnostics:[lr(o,"parse","load.atlas.failed")]}}let i=[...t.diagnostics];if(i.some(o=>o.severity==="error"))return{ok:!1,value:null,diagnostics:i};let r;try{r=ss(t)}catch(o){return{ok:!1,value:null,diagnostics:[lr(o,"normalize","load.atlas.materialize.failed")]}}return{ok:!0,value:{schemaVersion:e,ast:null,document:r,atlasDocument:t,draftDocument:t,diagnostics:i},diagnostics:i}}var bc=class extends Error{constructor(e){super(e),this.name="WorldOrbitViewerError"}},ri=class extends bc{constructor(e="WorldOrbit 3D is unavailable in this environment."){super(e),this.name="WorldOrbit3DUnavailableError"}};var rM={background:!0,guides:!0,relations:!0,events:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0},_c={atlas:{name:"atlas",backgroundStart:"#041018",backgroundEnd:"#0a2331",backgroundGlow:"rgba(240, 180, 100, 0.18)",panel:"rgba(7, 17, 27, 0.9)",panelLine:"rgba(168, 207, 242, 0.18)",relation:"rgba(240, 180, 100, 0.42)",orbit:"rgba(163, 209, 255, 0.24)",orbitBand:"rgba(255, 190, 120, 0.28)",guide:"rgba(255, 255, 255, 0.04)",leader:"rgba(225, 238, 255, 0.4)",ink:"#e8f0ff",muted:"rgba(232, 240, 255, 0.7)",accent:"#f0b464",accentStrong:"#ff7f5f",selected:"rgba(255, 214, 139, 0.92)",starCore:"#ffcc67",starStroke:"rgba(255, 245, 203, 0.85)",starGlow:"#ffe8a3",spaceFog:"#07131d",starfield:"rgba(226, 239, 255, 0.9)",starfieldDim:"rgba(164, 194, 228, 0.45)",objectSpecular:"#f5f8ff",orbitOpacity:.34,orbitBandOpacity:.24,selectionHalo:"rgba(255, 214, 139, 0.9)",atmosphere:"rgba(143, 202, 255, 0.4)",cometTail:"rgba(193, 243, 255, 0.7)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},nightglass:{name:"nightglass",backgroundStart:"#07131f",backgroundEnd:"#13283a",backgroundGlow:"rgba(120, 255, 215, 0.16)",panel:"rgba(7, 20, 30, 0.9)",panelLine:"rgba(120, 255, 215, 0.16)",relation:"rgba(156, 231, 255, 0.42)",orbit:"rgba(120, 255, 215, 0.2)",orbitBand:"rgba(137, 185, 255, 0.24)",guide:"rgba(255, 255, 255, 0.035)",leader:"rgba(192, 255, 233, 0.42)",ink:"#edfff8",muted:"rgba(237, 255, 248, 0.68)",accent:"#78ffd7",accentStrong:"#9ce7ff",selected:"rgba(120, 255, 215, 0.9)",starCore:"#e5f98c",starStroke:"rgba(246, 255, 217, 0.9)",starGlow:"#fffab4",spaceFog:"#071723",starfield:"rgba(220, 255, 245, 0.9)",starfieldDim:"rgba(124, 212, 195, 0.42)",objectSpecular:"#ecfffb",orbitOpacity:.3,orbitBandOpacity:.22,selectionHalo:"rgba(120, 255, 215, 0.85)",atmosphere:"rgba(120, 255, 215, 0.32)",cometTail:"rgba(181, 255, 236, 0.68)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'},ember:{name:"ember",backgroundStart:"#17090b",backgroundEnd:"#31111a",backgroundGlow:"rgba(255, 127, 95, 0.18)",panel:"rgba(24, 9, 13, 0.9)",panelLine:"rgba(255, 166, 149, 0.16)",relation:"rgba(255, 178, 125, 0.42)",orbit:"rgba(255, 188, 164, 0.22)",orbitBand:"rgba(255, 214, 139, 0.24)",guide:"rgba(255, 255, 255, 0.03)",leader:"rgba(255, 223, 209, 0.42)",ink:"#fff3ee",muted:"rgba(255, 243, 238, 0.68)",accent:"#ffb27d",accentStrong:"#ff7f5f",selected:"rgba(255, 178, 125, 0.9)",starCore:"#ffb766",starStroke:"rgba(255, 236, 205, 0.88)",starGlow:"#ffe2ad",spaceFog:"#1c0d12",starfield:"rgba(255, 232, 214, 0.88)",starfieldDim:"rgba(255, 176, 138, 0.38)",objectSpecular:"#fff0e6",orbitOpacity:.3,orbitBandOpacity:.24,selectionHalo:"rgba(255, 178, 125, 0.85)",atmosphere:"rgba(255, 190, 140, 0.26)",cometTail:"rgba(255, 214, 173, 0.62)",fontFamily:'"Segoe UI Variable", "Bahnschrift", sans-serif',displayFont:'"Bahnschrift", "Segoe UI Variable", sans-serif'}};function hr(n){return n?typeof n=="string"?_c[n]??_c.atlas:{..._c.atlas,...n}:_c.atlas}function Ad(n){return{...rM,...n}}function zn(n){if(!n)return null;let e={query:n.query?.trim()||void 0,objectTypes:Td(n.objectTypes??[]),tags:Td((n.tags??[]).map(t=>t.trim()).filter(Boolean)),groupIds:Td((n.groupIds??[]).map(t=>t.trim()).filter(Boolean)),includeAncestors:n.includeAncestors??!0};return sM(e)?e:null}function sM(n){return!!(n&&(n.query?.trim()||n.objectTypes?.length||n.tags?.length||n.groupIds?.length))}function wc(n,e){let t=zn(e),i=new Set;for(let r of n.objects)if(!r.hidden&&oM(r,t)&&(i.add(r.objectId),t?.includeAncestors!==!1))for(let s of r.ancestorIds)i.add(s);return t?i:new Set(n.objects.filter(r=>!r.hidden).map(r=>r.objectId))}function Id(n,e,t=12){let i=e.trim().toLowerCase();return i?n.objects.filter(r=>!r.hidden).map(r=>({object:r,score:aM(r,i)})).filter(r=>r.score>0).sort((r,s)=>s.score-r.score||r.object.label.localeCompare(s.object.label)).slice(0,t).map(r=>fg(r.object,r.score)):n.objects.filter(r=>!r.hidden).slice().sort((r,s)=>r.label.localeCompare(s.label)).slice(0,t).map(r=>fg(r,1))}function pg(n,e,t,i){return{version:"2.5",viewpointId:i,activeEventId:e.activeEventId??null,viewerState:{...n},renderOptions:{preset:e.preset,projection:e.projection,camera:e.camera?{...e.camera}:null,layers:e.layers?{...e.layers}:void 0,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,bodyScaleMode:e.bodyScaleMode,activeEventId:e.activeEventId??null,viewMode:e.viewMode??"2d"},filter:zn(t)}}function Cd(n){return encodeURIComponent(JSON.stringify(n))}function Rd(n){let e=JSON.parse(decodeURIComponent(n));return{version:e.version==="2.0"?"2.0":"2.5",viewpointId:e.viewpointId??null,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewerState:{scale:e.viewerState?.scale??1,rotationDeg:e.viewerState?.rotationDeg??0,translateX:e.viewerState?.translateX??0,translateY:e.viewerState?.translateY??0,selectedObjectId:e.viewerState?.selectedObjectId??null},renderOptions:{preset:e.renderOptions?.preset,projection:e.renderOptions?.projection,camera:e.renderOptions?.camera?{...e.renderOptions.camera}:null,layers:e.renderOptions?.layers?{...e.renderOptions.layers}:void 0,scaleModel:e.renderOptions?.scaleModel?{...e.renderOptions.scaleModel}:void 0,bodyScaleMode:e.renderOptions?.bodyScaleMode,activeEventId:e.activeEventId??e.renderOptions?.activeEventId??null,viewMode:e.renderOptions?.viewMode??"2d"},filter:zn(e.filter??null)}}function mg(n,e,t){let i=n.trim()||"bookmark";return{id:i.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"bookmark",label:e?.trim()||i,atlasState:{...t,viewerState:{...t.viewerState},renderOptions:{...t.renderOptions,camera:t.renderOptions.camera?{...t.renderOptions.camera}:null,layers:t.renderOptions.layers?{...t.renderOptions.layers}:void 0,scaleModel:t.renderOptions.scaleModel?{...t.renderOptions.scaleModel}:void 0,bodyScaleMode:t.renderOptions.bodyScaleMode,activeEventId:t.renderOptions.activeEventId??null,viewMode:t.renderOptions.viewMode??"2d"},filter:t.filter?{...t.filter}:null}}}function Pd(n){if(!(!n||!(Object.keys(n.layers).length>0)))return{background:n.layers.background,guides:n.layers.guides,relations:n.layers.relations,events:n.layers.events,orbits:n.layers["orbits-front"]===void 0&&n.layers["orbits-back"]===void 0?void 0:n.layers["orbits-front"]!==!1||n.layers["orbits-back"]!==!1,objects:n.layers.objects,labels:n.layers.labels,metadata:n.layers.metadata}}function Ld(n){return n?.filter?zn({query:n.filter.query??void 0,objectTypes:n.filter.objectTypes,tags:n.filter.tags,groupIds:n.filter.groupIds,includeAncestors:!0}):null}function fg(n,e){return{objectId:n.objectId,label:n.label,type:n.object.type,score:e,groupId:n.groupId,parentId:n.parentId,tags:Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(t=>typeof t=="string"):[]}}function oM(n,e){if(!e)return!0;if(e.objectTypes?.length&&!e.objectTypes.includes(n.object.type))return!1;if(e.groupIds?.length&&(!n.groupId||!e.groupIds.includes(n.groupId))){let t=n.semanticGroupIds.length>0&&e.groupIds.some(r=>n.semanticGroupIds.includes(r)),i=!!(n.groupId&&e.groupIds.includes(n.groupId));if(!t&&!i)return!1}if(e.tags?.length){let t=Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(i=>typeof i=="string"):[];if(!e.tags.every(i=>t.includes(i)))return!1}if(e.query?.trim()){let t=gg(n.object,n.label).toLowerCase();if(!e.query.toLowerCase().split(/\s+/).filter(Boolean).every(r=>t.includes(r)))return!1}return!0}function aM(n,e){let t=n.objectId.toLowerCase(),i=n.label.toLowerCase(),r=gg(n.object,n.label).toLowerCase(),s=0;return t===e||i===e?s+=120:t.startsWith(e)||i.startsWith(e)?s+=96:(t.includes(e)||i.includes(e))&&(s+=72),e.split(/\s+/).filter(Boolean).every(c=>r.includes(c))&&(s+=32),n.object.type===e&&(s+=24),(Array.isArray(n.object.properties.tags)?n.object.properties.tags.filter(c=>typeof c=="string"):[]).some(c=>c.toLowerCase()===e)&&(s+=18),s}function gg(n,e){let t=Object.values(n.info),i=Object.values(n.properties).flatMap(r=>Array.isArray(r)?r:typeof r=="object"&&r&&"value"in r?[String(r.value),String(r.unit??"")]:[String(r)]).filter(Boolean);return[n.id,e,n.type,...i,...t].join(" ")}function Td(n){return[...new Set(n)]}var _n={scale:1,rotationDeg:0,translateX:0,translateY:0,selectedObjectId:null};function yg(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function Mc(n,e){return Math.min(Math.max(n,e.minScale),e.maxScale)}function fr(n,e,t){return{...n,translateX:n.translateX+e,translateY:n.translateY+t}}function Dd(n,e){return{...n,rotationDeg:yg(n.rotationDeg+e)}}function cs(n,e,t,i,r){if(!Number.isFinite(t)||t<=0)return e;let s=ls(n),o=Mc(e.scale*t,r);if(o===e.scale)return e;let a=o/e.scale,c=i.x-s.x,l=i.y-s.y;return{...e,scale:o,translateX:(1-a)*c+a*e.translateX,translateY:(1-a)*l+a*e.translateY}}function pr(n,e,t){let i=ls(n),r=cM(n.contentBounds,i,e.rotationDeg),s=Math.max(n.width-t.fitPadding*2,1),o=Math.max(n.height-t.fitPadding*2,1),a=Math.max(r.width,1),c=Math.max(r.height,1),l=Mc(Math.min(s/a,o/c),t),u=rn({x:n.contentBounds.centerX,y:n.contentBounds.centerY},i,e.rotationDeg);return{...e,scale:l,translateX:i.x-(i.x+(u.x-i.x)*l),translateY:i.y-(i.y+(u.y-i.y)*l)}}function Od(n,e,t,i){let r=n.objects.find(c=>c.objectId===t&&!c.hidden);if(!r)return e;let s=ls(n),o=Mc(Math.max(e.scale,1.8),i),a=rn({x:r.x,y:r.y},s,e.rotationDeg);return{...e,scale:o,translateX:s.x-(s.x+(a.x-s.x)*o),translateY:s.y-(s.y+(a.y-s.y)*o),selectedObjectId:t}}function Sc(n,e){let t=ls(n);return`translate(${e.translateX} ${e.translateY}) translate(${t.x} ${t.y}) rotate(${e.rotationDeg}) scale(${e.scale}) translate(${-t.x} ${-t.y})`}function mr(n,e,t){let i=ls(n),r={x:t.x-e.translateX,y:t.y-e.translateY},s={x:r.x-i.x,y:r.y-i.y},o={x:s.x/Math.max(e.scale,1e-4),y:s.y/Math.max(e.scale,1e-4)},a=rn({x:o.x,y:o.y},{x:0,y:0},-e.rotationDeg);return{x:i.x+a.x,y:i.y+a.y}}function Ao(n,e){let t=[{x:0,y:0},{x:n.width,y:0},{x:n.width,y:n.height},{x:0,y:n.height}].map(a=>mr(n,e,a)),i=Math.min(...t.map(a=>a.x)),r=Math.min(...t.map(a=>a.y)),s=Math.max(...t.map(a=>a.x)),o=Math.max(...t.map(a=>a.y));return{minX:i,minY:r,maxX:s,maxY:o,width:s-i,height:o-r,centerX:i+(s-i)/2,centerY:r+(o-r)/2}}function ls(n){return{x:n.width/2,y:n.height/2}}function cM(n,e,t){let i=[{x:n.minX,y:n.minY},{x:n.maxX,y:n.minY},{x:n.maxX,y:n.maxY},{x:n.minX,y:n.maxY}].map(c=>rn(c,e,t)),r=Math.min(...i.map(c=>c.x)),s=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),a=Math.max(...i.map(c=>c.y));return{minX:r,minY:s,maxX:o,maxY:a,width:o-r,height:a-s,centerX:r+(o-r)/2,centerY:s+(a-s)/2}}var Ac="worldorbit-camera-root";function Cn(n,e={}){let t=hr(e.theme),i=SM(e.preset??n.renderPreset??void 0),r=Ad({...i.layers,...e.layers}),s=e.subtitle??n.subtitle,o=wc(n,e.filter??null),a=n.objects.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ec(x.object)).sort((x,v)=>x.sortKey-v.sortKey),c=n.labels.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ec(x.object)),l=dM(a),u=r.orbits?uM(n,o,r.structures):{back:"",front:""},d=r.guides?n.leaders.filter(x=>!x.hidden).filter(x=>o.has(x.objectId)).filter(x=>r.structures||!Ec(x.object)).map(x=>`<line class="wo-leader wo-leader-${x.mode}" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Dt(x.renderId)}" data-group-id="${Wt(x.groupId??"")}" />`).join(""):"",h=r.relations?n.relations.filter(x=>!x.hidden).filter(x=>o.has(x.fromObjectId)&&o.has(x.toObjectId)).map(x=>`<line class="wo-relation" x1="${x.x1}" y1="${x.y1}" x2="${x.x2}" y2="${x.y2}" data-render-id="${Dt(x.renderId)}" data-relation-id="${Wt(x.relationId)}" />`).join(""):"",f=r.events?n.events.filter(x=>!x.hidden).map(x=>lM(n,x,o,t)).join(""):"",p=r.objects?a.map(x=>hM(x,e.selectedObjectId??null,t)).join(""):"",y=r.labels?c.map(x=>fM(n,x,e.selectedObjectId??null)).join(""):"",g=r.metadata?`<text class="wo-title" x="56" y="64">${Dt(n.title)}</text>
3832
3832
  <text class="wo-subtitle" x="56" y="88">${Dt(s)}</text>
3833
3833
  <text class="wo-meta" x="56" y="${n.height-42}">${Dt(AM(n))}</text>`:"",m=r.background?`<rect class="wo-bg" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
3834
3834
  <rect class="wo-bg-glow" x="0" y="0" width="${n.width}" height="${n.height}" rx="28" ry="28" />
@@ -3891,7 +3891,7 @@ void main() {
3891
3891
  ${m}
3892
3892
  ${g}
3893
3893
  <g data-worldorbit-world="true">
3894
- <g data-worldorbit-camera-root="${Od}" id="${Od}">
3894
+ <g data-worldorbit-camera-root="${Ac}" id="${Ac}">
3895
3895
  <g data-worldorbit-world-content="true">
3896
3896
  ${r.orbits?`<g data-layer-id="orbits-back">${u.back}</g>`:""}
3897
3897
  ${r.guides?`<g data-layer-id="guides">${d}</g>`:""}
@@ -3907,7 +3907,7 @@ void main() {
3907
3907
  ${a}
3908
3908
  <circle class="wo-event-node" cx="${e.x}" cy="${e.y}" r="5" fill="${Wt(s)}" />
3909
3909
  <text class="wo-event-label" x="${e.x}" y="${e.y-10}" text-anchor="middle" font-size="10">${Dt(o)}</text>
3910
- </g>`}function uM(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!Sc(o.object)))){let o=s.bandThickness??(s.band?10:1.5),a=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",c=`data-render-id="${Dt(s.renderId)}" data-orbit-object-id="${Wt(s.objectId)}" data-parent-id="${Wt(s.parentId)}" data-group-id="${Wt(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${a} wo-orbit-back" d="${s.backArcPath}" stroke-width="${o}" ${c} />`),s.frontArcPath&&r.push(`<path class="${a} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${o}" ${c} />`);continue}if(s.kind==="ellipse"){let l=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${l}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${o}" ${c} />`);continue}r.push(`<circle class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${o}" ${c} />`)}return{back:i.join(""),front:r.join("")}}function dM(n){return n.filter(e=>!!e.imageHref).map(e=>gM(e)).join("")}function hM(n,e,t){let{object:i,x:r,y:s,radius:o,visualRadius:a}=n,c=e===n.objectId?" wo-object-selected":"",l=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=vM(n,t),d=mM(n),h=d?vg(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${l}${c}" data-object-id="${Dt(n.objectId)}" data-parent-id="${Wt(n.parentId??"")}" data-group-id="${Wt(n.groupId??"")}" data-render-id="${Dt(n.renderId)}" tabindex="0" role="button" aria-label="${Dt(`${i.type} ${n.objectId}`)}">
3910
+ </g>`}function uM(n,e,t){let i=[],r=[];for(let s of n.orbitVisuals.filter(o=>!o.hidden&&e.has(o.objectId)&&(t||!Ec(o.object)))){let o=s.bandThickness??(s.band?10:1.5),a=s.band?"wo-orbit wo-orbit-band wo-orbit-node":"wo-orbit wo-orbit-node",c=`data-render-id="${Dt(s.renderId)}" data-orbit-object-id="${Wt(s.objectId)}" data-parent-id="${Wt(s.parentId)}" data-group-id="${Wt(s.groupId??"")}"`;if(s.backArcPath||s.frontArcPath){s.backArcPath&&i.push(`<path class="${a} wo-orbit-back" d="${s.backArcPath}" stroke-width="${o}" ${c} />`),s.frontArcPath&&r.push(`<path class="${a} wo-orbit-front" d="${s.frontArcPath}" stroke-width="${o}" ${c} />`);continue}if(s.kind==="ellipse"){let l=s.rx??s.radius??0,u=s.ry??s.radius??0;r.push(`<ellipse class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" rx="${l}" ry="${u}" transform="rotate(${s.rotationDeg} ${s.cx} ${s.cy})" stroke-width="${o}" ${c} />`);continue}r.push(`<circle class="${a} wo-orbit-front" cx="${s.cx}" cy="${s.cy}" r="${s.radius??0}" stroke-width="${o}" ${c} />`)}return{back:i.join(""),front:r.join("")}}function dM(n){return n.filter(e=>!!e.imageHref).map(e=>gM(e)).join("")}function hM(n,e,t){let{object:i,x:r,y:s,radius:o,visualRadius:a}=n,c=e===n.objectId?" wo-object-selected":"",l=i.properties.kind?` wo-kind-${String(i.properties.kind).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`:"",u=vM(n,t),d=mM(n),h=d?vg(i,r,s,o,u,{outlineOnly:!0}):"";return`<g class="wo-object wo-object-${i.type}${l}${c}" data-object-id="${Dt(n.objectId)}" data-parent-id="${Wt(n.parentId??"")}" data-group-id="${Wt(n.groupId??"")}" data-render-id="${Dt(n.renderId)}" tabindex="0" role="button" aria-label="${Dt(`${i.type} ${n.objectId}`)}">
3911
3911
  <circle class="wo-selection-ring" cx="${r}" cy="${s}" r="${a+8}" />
3912
3912
  ${pM(n,u)}
3913
3913
  ${vg(i,r,s,o,u)}
@@ -3923,26 +3923,26 @@ void main() {
3923
3923
  <ellipse cx="${e}" cy="${t}" rx="${i*1.5}" ry="${i*.42}" fill="${o}" stroke="${r.stroke}" stroke-width="1.2" />
3924
3924
  <circle cx="${e}" cy="${t}" r="${i*.28}" fill="${r.core??"#fff"}" stroke="none" />`:c==="dwarf-galaxy"?`<ellipse cx="${e}" cy="${t}" rx="${i*1.6}" ry="${i*.55}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />
3925
3925
  <circle cx="${e}" cy="${t}" r="${i*.25}" fill="${r.core??"#fff"}" stroke="none" />`:c==="nebula"?`<circle cx="${e}" cy="${t}" r="${i*2.2}" fill="${r.halo??"none"}" stroke="none" />
3926
- <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Ud(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function pM(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function mM(n){if(!n.imageHref)return"";let e=yM(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Wt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Wt(_g(n))})" />`}function gM(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${wg(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Ud(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Wt(_g(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function yM(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function vM(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=xM(n.object.type,t,e),r=n.fillColor&&IM(n.fillColor)?n.fillColor:i.fill,s=xg(n.object.properties.albedo),o=xg(n.object.properties.temperature),a=_M(r,o,s,n.object.type),c=To(a,"#ffffff",.4)??i.stroke,l=MM(n.object.properties.atmosphere),u=n.object.type==="star"?bg(To(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:c,glow:u,atmosphere:l,tail:n.object.type==="comet"?bg(To(a,"#ffffff",.5)??a,.72):void 0}}function xM(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return bM(e)}}function bM(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function _M(n,e,t,i){let r=n;if(e!==null){let s=wM(e,i);r=To(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=To(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function wM(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function MM(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function SM(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function xg(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function _g(n){return`${n.renderId}-clip`}function wg(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Ud(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function EM(n,e){let t=Array.from({length:10},(r,s)=>{let o=90+s*((n-180)/9);return`<line class="wo-grid" x1="${o}" y1="120" x2="${o}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let o=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${o}" x2="${n-56}" y2="${o}" />`}).join("");return`${t}${i}`}function AM(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Sc(n){return n.type==="structure"||n.type==="phenomenon"}function To(n,e,t){let i=Nd(n),r=Nd(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return TM({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function bg(n,e){let t=Nd(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Nd(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function TM(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function IM(n){return!!n.trim()}function Dt(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Wt(n){return Dt(n)}var ls=180,us=120,Mg=10;function Sg(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((ls-Mg*2)/Math.max(i.width,1),(us-Mg*2)/Math.max(i.height,1)),s=(ls-i.width*r)/2-i.minX*r,o=(us-i.height*r)/2-i.minY*r,a=Ao(n,e),c=t.map(l=>{let u=l.x*r+s,d=l.y*r+o,h=Math.max(1.4,Math.min(l.visualRadius*r,5.2)),f=l.fillColor??CM(l.object.type);return`<circle cx="${Cn(u)}" cy="${Cn(d)}" r="${Cn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${ls}px;height:${us}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3927
- <svg width="${ls}" height="${us}" viewBox="0 0 ${ls} ${us}" role="presentation" aria-hidden="true">
3928
- <rect x="0.5" y="0.5" width="${ls-1}" height="${us-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3929
- <rect x="${Cn(i.minX*r+s)}" y="${Cn(i.minY*r+o)}" width="${Cn(i.width*r)}" height="${Cn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3926
+ <circle cx="${e}" cy="${t}" r="${i}" fill="${o}" stroke="${r.stroke}" stroke-width="1" />`:`<polygon points="${Ud(e,t,i)}" fill="${o}" stroke="${r.stroke}" stroke-width="1.4" />`}}}function pM(n,e){if(!e.atmosphere)return"";let{object:t,x:i,y:r,radius:s}=n;return t.type!=="planet"&&t.type!=="moon"&&t.type!=="asteroid"?"":`<circle cx="${i}" cy="${r}" r="${s+4}" fill="none" stroke="${e.atmosphere}" stroke-width="4" opacity="0.45" />`}function mM(n){if(!n.imageHref)return"";let e=yM(n);return`<image class="wo-object-image" x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" href="${Wt(n.imageHref)}" preserveAspectRatio="xMidYMid slice" clip-path="url(#${Wt(_g(n))})" />`}function gM(n){let{x:e,y:t,radius:i}=n,r="";switch(n.object.type){case"star":case"planet":case"moon":case"asteroid":case"comet":r=`<circle cx="${e}" cy="${t}" r="${i}" />`;break;case"structure":r=`<polygon points="${wg(e,t,i)}" />`;break;case"phenomenon":r=`<polygon points="${Ud(e,t,i)}" />`;break;default:return""}return`<clipPath id="${Wt(_g(n))}" clipPathUnits="userSpaceOnUse">${r}</clipPath>`}function yM(n){let{object:e,x:t,y:i,radius:r}=n;switch(e.type){case"structure":return{x:t-r,y:i-r,width:r*2,height:r*2};case"phenomenon":return{x:t-r*1.2,y:i-r*1.2,width:r*2.4,height:r*2.4};default:return{x:t-r,y:i-r,width:r*2,height:r*2}}}function vM(n,e){let t=String(n.object.properties.kind??"").toLowerCase().replace(/_/g,"-"),i=xM(n.object.type,t,e),r=n.fillColor&&IM(n.fillColor)?n.fillColor:i.fill,s=xg(n.object.properties.albedo),o=xg(n.object.properties.temperature),a=_M(r,o,s,n.object.type),c=To(a,"#ffffff",.4)??i.stroke,l=MM(n.object.properties.atmosphere),u=n.object.type==="star"?bg(To(a,"#fff2cb",.4)??a,.82):void 0;return{fill:a,stroke:c,glow:u,atmosphere:l,tail:n.object.type==="comet"?bg(To(a,"#ffffff",.5)??a,.72):void 0}}function xM(n,e,t){switch(n){case"star":return{fill:t.starCore,stroke:t.starStroke};case"planet":return{fill:"#72b7ff",stroke:"#d8efff"};case"moon":return{fill:"#c7d7ea",stroke:"#f2f8ff"};case"belt":return{fill:"#d9aa74",stroke:"#f7d5aa"};case"asteroid":return{fill:"#a7a5b8",stroke:"#ebe5ff"};case"comet":return{fill:"#9ce7ff",stroke:"#e7fbff"};case"ring":return{fill:"#e59f7d",stroke:"#fff0d3"};case"structure":return{fill:t.accentStrong,stroke:"#fff2ea"};case"phenomenon":return bM(e)}}function bM(n){return n==="galaxy"?{fill:"rgba(165,125,255,0.55)",stroke:"rgba(210,185,255,0.75)",halo:"rgba(160,120,255,0.10)",core:"#ede0ff"}:n==="dwarf-galaxy"?{fill:"rgba(190,165,255,0.45)",stroke:"rgba(220,205,255,0.75)",core:"#ddd0ff"}:n==="black-hole"?{fill:"#040408",stroke:"#ff6a00",accentRing:"rgba(255,140,20,0.72)"}:n==="nebula"?{fill:"rgba(105,205,255,0.45)",stroke:"rgba(180,235,255,0.72)",halo:"rgba(100,200,255,0.08)"}:n==="void"?{fill:"#05080f",stroke:"rgba(130,160,255,0.4)"}:{fill:"#78ffd7",stroke:"#e9fff7"}}function _M(n,e,t,i){let r=n;if(e!==null){let s=wM(e,i);r=To(r,s,i==="star"?.42:.2)??r}if(t!==null){let s=Math.min(Math.max(t,0),1);r=To(r,s>=.5?"#ffffff":"#0f1520",Math.abs(s-.5)*.7)??r}return r}function wM(n,e){return e==="star"?n>=8e3?"#d7ebff":n>=6e3?"#fff3d8":n>=4e3?"#ffd39a":"#ff9d76":n<=180?"#8fd8ff":n>=600?"#ffb56e":"#fff1c4"}function MM(n){if(typeof n!="string"||!n.trim())return;let e=n.trim().toLowerCase();return e.includes("methane")?"rgba(134, 236, 255, 0.75)":e.includes("nitrogen")||e.includes("oxygen")||e.includes("air")?"rgba(122, 194, 255, 0.75)":e.includes("carbon")||e.includes("co2")?"rgba(255, 198, 138, 0.75)":e.includes("sulfur")?"rgba(255, 233, 138, 0.75)":"rgba(180, 222, 255, 0.68)"}function SM(n){switch(n){case"presentation":return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"atlas-card":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}};case"markdown":return{layers:{background:!0,guides:!1,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!1}};default:return{layers:{background:!0,guides:!0,orbits:!0,objects:!0,labels:!0,structures:!0,metadata:!0}}}}function xg(n){return typeof n=="number"?n:n&&typeof n=="object"&&"value"in n?n.value:null}function _g(n){return`${n.renderId}-clip`}function wg(n,e,t){return`${n},${e-t} ${n+t},${e} ${n},${e+t} ${n-t},${e}`}function Ud(n,e,t){return`${n},${e-t*1.2} ${n+t*.9},${e-t*.3} ${n+t*1.2},${e+t*.8} ${n},${e+t*1.2} ${n-t*1.1},${e+t*.3} ${n-t*.8},${e-t*.8}`}function EM(n,e){let t=Array.from({length:10},(r,s)=>{let o=90+s*((n-180)/9);return`<line class="wo-grid" x1="${o}" y1="120" x2="${o}" y2="${e-70}" />`}).join(""),i=Array.from({length:6},(r,s)=>{let o=150+s*((e-240)/5);return`<line class="wo-grid" x1="56" y1="${o}" x2="${n-56}" y2="${o}" />`}).join("");return`${t}${i}`}function AM(n){return[`${n.layoutPreset} layout`,`${n.viewMode} view`,`${n.renderPreset??"custom"} preset`,`schema ${n.metadata.version??"1.0"}`].join(" - ")}function Ec(n){return n.type==="structure"||n.type==="phenomenon"}function To(n,e,t){let i=Nd(n),r=Nd(e);if(!i||!r)return;let s=Math.min(Math.max(t,0),1);return TM({r:Math.round(i.r+(r.r-i.r)*s),g:Math.round(i.g+(r.g-i.g)*s),b:Math.round(i.b+(r.b-i.b)*s)})}function bg(n,e){let t=Nd(n);return t?`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`:n}function Nd(n){let e=n.trim();return/^#[0-9a-f]{6}$/i.test(e)?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:/^#[0-9a-f]{3}$/i.test(e)?{r:Number.parseInt(e[1]+e[1],16),g:Number.parseInt(e[2]+e[2],16),b:Number.parseInt(e[3]+e[3],16)}:null}function TM(n){let e=t=>t.toString(16).padStart(2,"0");return`#${e(n.r)}${e(n.g)}${e(n.b)}`}function IM(n){return!!n.trim()}function Dt(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;")}function Wt(n){return Dt(n)}var us=180,ds=120,Mg=10;function Sg(n,e,t){let i=n.contentBounds.width>0&&n.contentBounds.height>0?n.contentBounds:{minX:0,minY:0,maxX:n.width,maxY:n.height,width:n.width,height:n.height,centerX:n.width/2,centerY:n.height/2},r=Math.min((us-Mg*2)/Math.max(i.width,1),(ds-Mg*2)/Math.max(i.height,1)),s=(us-i.width*r)/2-i.minX*r,o=(ds-i.height*r)/2-i.minY*r,a=Ao(n,e),c=t.map(l=>{let u=l.x*r+s,d=l.y*r+o,h=Math.max(1.4,Math.min(l.visualRadius*r,5.2)),f=l.fillColor??CM(l.object.type);return`<circle cx="${Rn(u)}" cy="${Rn(d)}" r="${Rn(h)}" fill="${f}" fill-opacity="0.92" />`}).join("");return`<div data-worldorbit-minimap="true" style="position:absolute;right:16px;bottom:16px;width:${us}px;height:${ds}px;padding:8px;border-radius:16px;background:rgba(5, 14, 22, 0.78);border:1px solid rgba(179, 216, 255, 0.16);box-shadow:0 14px 28px rgba(0, 0, 0, 0.24);backdrop-filter:blur(8px);pointer-events:none;">
3927
+ <svg width="${us}" height="${ds}" viewBox="0 0 ${us} ${ds}" role="presentation" aria-hidden="true">
3928
+ <rect x="0.5" y="0.5" width="${us-1}" height="${ds-1}" rx="12" ry="12" fill="rgba(7, 17, 27, 0.85)" stroke="rgba(179, 216, 255, 0.18)" />
3929
+ <rect x="${Rn(i.minX*r+s)}" y="${Rn(i.minY*r+o)}" width="${Rn(i.width*r)}" height="${Rn(i.height*r)}" rx="10" ry="10" fill="rgba(163, 209, 255, 0.04)" stroke="rgba(163, 209, 255, 0.16)" />
3930
3930
  ${c}
3931
- <rect x="${Cn(a.minX*r+s)}" y="${Cn(a.minY*r+o)}" width="${Cn(a.width*r)}" height="${Cn(a.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3931
+ <rect x="${Rn(a.minX*r+s)}" y="${Rn(a.minY*r+o)}" width="${Rn(a.width*r)}" height="${Rn(a.height*r)}" rx="8" ry="8" fill="rgba(255, 180, 100, 0.09)" stroke="rgba(255, 180, 100, 0.88)" stroke-width="1.4" />
3932
3932
  </svg>
3933
- </div>`}function CM(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function Cn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var x2="wo-viewer-3d-root",Np=null;function Nv(n){P2();let e=document.createElement("div");e.className=x2,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,o=new Set,a=null,c=null,l=new Map,u=null,d=!1,h=null,f=null,p="",y=new Map,g=new Map,m=[];return O2().then(P=>{if(d)return;let k=new P.Scene,O=new P.PerspectiveCamera(46,1,.1,24e3),H=new P.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});H.domElement.classList.add("wo-viewer-3d-canvas"),H.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(H.domElement);let W=new P.AmbientLight(16777215,.24),J=new P.DirectionalLight(13625855,.36),ae=new P.DirectionalLight(8304895,.24),B=new P.PointLight(16773327,2.6,0,2);J.position.set(-360,260,220),ae.position.set(340,180,-280);let ne=new P.Group,ce=new P.Group,Me=I2(P,320),fe=new P.Raycaster;fe.params.Line={threshold:7},k.add(W),k.add(J),k.add(ae),k.add(B),k.add(Me),k.add(ne),k.add(ce),t={THREE:P,scene3d:k,camera:O,renderer:H,ambientLight:W,fillLight:J,rimLight:ae,keyLight:B,starfield:Me,orbitLayer:ne,objectLayer:ce,raycaster:fe,pointer:new P.Vector2},Lv(H,P,"balanced"),u&&x(u)}).catch(P=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${D2(P instanceof Error?P.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(P){u=P,x(P)},hitTest(P,k){if(!t||!i)return null;let O=t.renderer.domElement.getBoundingClientRect();if(!O.width||!O.height)return null;t.pointer.x=(P-O.left)/O.width*2-1,t.pointer.y=-((k-O.top)/O.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let H=t.raycaster.intersectObjects(m,!0);for(let W of H){let J=L2(W.object);if(J)return J}return null},projectObjectToContainer(P){if(!t)return null;let k=l.get(P);if(!k)return null;let O=new t.THREE.Vector3(k.x,k.y,k.z);if(O.project(t.camera),O.z>1)return null;let H=t.renderer.domElement.getBoundingClientRect(),W=n.getBoundingClientRect();return{x:H.left-W.left+(O.x+1)/2*H.width,y:H.top-W.top+(1-O.y)/2*H.height}},destroy(){d=!0,u=null,t?.renderer.dispose(),t?.starfield?.geometry?.dispose?.(),t?.starfield?.material?.dispose?.(),e.remove(),y.clear(),g.clear(),m.length=0,t=null}};function x(P){if(!t)return;let k=i!==P.spatialScene;i=P.spatialScene,r=P.renderOptions,s=P.state,o=P.visibleObjectIds,a=P.selectedObjectId,c=P.hoveredObjectId,Lv(t.renderer,t.THREE,r?.quality??"balanced");let O=JSON.stringify({theme:r?.theme??null,quality:r?.quality??"balanced",style3d:r?.style3d??"symbolic"});O!==p&&(C2(t,r),p=O),k&&v(P.spatialScene),S(P.spatialScene),l=od(P.spatialScene,P.timeSeconds),w(),N(),C(),R(),F(),A(),t.renderer.render(t.scene3d,t.camera)}function v(P){if(!t)return;Uv(t.orbitLayer),Uv(t.objectLayer),y.clear(),g.clear(),m.length=0,h=null,f=null;let k=ss(r?.theme);for(let O of P.orbits){let H=_2(t.THREE,O,k);t.orbitLayer.add(H.root),g.set(O.objectId,H),m.push(H.root)}for(let O of P.objects){let H=b2(t.THREE,O,k);t.objectLayer.add(H.root),y.set(O.objectId,H),m.push(H.root)}}function w(){for(let P of i?.objects??[]){let k=y.get(P.objectId),O=l.get(P.objectId);k&&O&&k.root.position.set(O.x,O.y,O.z)}}function N(){for(let P of i?.orbits??[]){let k=g.get(P.objectId);if(!k)continue;let O=l.get(P.parentId);k.root.position.set(O?.x??P.center.x,O?.y??P.center.y,O?.z??P.center.z)}}function C(){let P=r?.layers??{};for(let k of i?.objects??[]){let O=y.get(k.objectId);if(!O)continue;let H=P.structures===!1&&(k.object.type==="structure"||k.object.type==="phenomenon");O.root.visible=!k.hidden&&o.has(k.objectId)&&P.objects!==!1&&!H}for(let k of i?.orbits??[]){let O=g.get(k.objectId);if(!O)continue;let H=P.structures===!1&&(k.object.type==="structure"||k.object.type==="phenomenon");O.root.visible=!k.hidden&&o.has(k.objectId)&&P.orbits!==!1&&!H}}function R(){if(t){for(let P of y.values()){let k=a===P.objectId,O=c===P.objectId;Dv(t.THREE,P.materials,k,O);let H=k?1.16:O?1.08:1;P.root.scale.set(H,H,H),P.halo&&(P.halo.visible=k||O)}for(let P of g.values())Dv(t.THREE,P.materials,a===P.objectId,c===P.objectId)}}function F(){if(!t||!i)return;let P=i.objects.find(O=>O.object.type==="star"&&!O.hidden)??null,k=P?l.get(P.objectId)??P.position:{x:0,y:40,z:0};t.keyLight.position.set(k.x,k.y+20,k.z)}function A(){if(!t||!i||!s)return;let P=r?.camera??i.camera,k=i.contentBounds,O=Math.max(k.width,k.depth,k.height,160),H=ka((P?.azimuth??30)+s.rotationDeg),W=ka(Vu(P?.elevation??22,-75,75)),J=Vu(2.2/Math.max(s.scale,.1),.35,7.2),ae=Vu(P?.distance??5.4,2,24),B=Vu(O*J*(ae/5.4),24,8e3),ne=Math.max(O/900,.12),ce=new t.THREE.Vector3(k.center.x-s.translateX*ne,k.center.y,k.center.z-s.translateY*ne),Me=new t.THREE.Vector3(ce.x+B*Math.cos(W)*Math.sin(H),ce.y+B*Math.sin(W),ce.z+B*Math.cos(W)*Math.cos(H)),fe=(r?.style3d??"symbolic")==="cinematic"?.16:.32;!h||!f?(h=Me.clone(),f=ce.clone()):(h.lerp(Me,fe),f.lerp(ce,fe)),t.camera.position.copy(h),t.camera.lookAt(f),P?.roll&&(t.camera.rotation.z=ka(P.roll))}function S(P){if(!t)return;let k=Math.max(1,Math.round(n.clientWidth||P.width||960)),O=Math.max(1,Math.round(n.clientHeight||P.height||560));t.renderer.setSize(k,O,!1),t.camera.aspect=k/O,t.camera.updateProjectionMatrix()}}function b2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??R2(e),s=[],o=w2(n,e,r,t),a=new n.Mesh(M2(n,e),o.material);if(a.userData.objectId=e.objectId,i.add(a),s.push(o),A2(e)){let l={material:new n.MeshBasicMaterial({color:t.atmosphere,transparent:!0,opacity:.24,depthWrite:!1,side:2}),baseColor:t.atmosphere,baseOpacity:.24,hoveredOpacity:.34,selectedOpacity:.42},u=new n.Mesh(new n.SphereGeometry(Math.max(e.visualRadius,2)*1.16,20,14),l.material);u.userData.objectId=e.objectId,i.add(u),s.push(l)}if(e.object.type==="comet"){let l={material:new n.MeshBasicMaterial({color:t.cometTail,transparent:!0,opacity:.36,depthWrite:!1}),baseColor:t.cometTail,baseOpacity:.36,hoveredOpacity:.48,selectedOpacity:.56},u=new n.Mesh(new n.ConeGeometry(Math.max(e.visualRadius*.55,2),Math.max(e.visualRadius*2.8,8),12,1,!0),l.material);u.position.set(-Math.max(e.visualRadius*1.4,4),0,0),u.rotation.z=-Math.PI/2,u.userData.objectId=e.objectId,i.add(u),s.push(l)}let c=E2(n,e,t);return c&&(c.visible=!1,c.userData.objectId=e.objectId,i.add(c)),{objectId:e.objectId,root:i,halo:c,materials:s}}function _2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=ka(e.rotationDeg),i.rotation.x=ka(e.inclinationDeg);let r=e.object.properties.color??t.orbit;if(e.band){let c={material:new n.MeshBasicMaterial({color:r,transparent:!0,opacity:t.orbitBandOpacity,side:2,depthWrite:!1}),baseColor:r,baseOpacity:t.orbitBandOpacity,hoveredOpacity:Math.min(t.orbitBandOpacity+.1,.58),selectedOpacity:Math.min(t.orbitBandOpacity+.18,.72),hoveredColor:t.accent,selectedColor:t.accentStrong},l=new n.Mesh(T2(n,e),c.material);return l.userData.objectId=e.objectId,i.add(l),{objectId:e.objectId,root:i,materials:[c]}}let s={material:new n.LineBasicMaterial({color:r,transparent:!0,opacity:t.orbitOpacity}),baseColor:r,baseOpacity:t.orbitOpacity,hoveredOpacity:Math.min(t.orbitOpacity+.18,.72),selectedOpacity:Math.min(t.orbitOpacity+.3,.88),hoveredColor:t.accent,selectedColor:t.accentStrong},o=new n.BufferGeometry().setFromPoints(Fv(n,e,120)),a=new n.LineLoop(o,s.material);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,materials:[s]}}function w2(n,e,t,i){if(e.object.type==="star")return{material:new n.MeshStandardMaterial({color:t,emissive:new n.Color(i.starGlow),emissiveIntensity:1.2,roughness:.35,metalness:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:i.starCore,selectedColor:"#fff2c4",baseEmissive:i.starGlow,hoveredEmissive:i.starGlow,selectedEmissive:"#fff6cc",baseEmissiveIntensity:1.2,hoveredEmissiveIntensity:1.5,selectedEmissiveIntensity:1.8};if(e.object.type==="phenomenon")return{material:new n.MeshPhongMaterial({color:t,transparent:!0,opacity:.7,emissive:new n.Color(t),emissiveIntensity:.32,shininess:90}),baseColor:t,baseOpacity:.7,hoveredOpacity:.82,selectedOpacity:.9,hoveredColor:i.accent,selectedColor:i.selectionHalo,baseEmissive:t,hoveredEmissive:i.accent,selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.32,hoveredEmissiveIntensity:.52,selectedEmissiveIntensity:.74};let r=e.object.type==="structure"?70:e.object.type==="ring"?42:e.object.type==="belt"?26:36;return{material:new n.MeshPhongMaterial({color:t,specular:new n.Color(i.objectSpecular),shininess:r,transparent:!1,opacity:1,emissive:new n.Color(0),emissiveIntensity:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:Ov(n,t,.08),selectedColor:Ov(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function M2(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.14,34,24);case"structure":return S2(n,e,t);case"phenomenon":return new n.IcosahedronGeometry(t*1.12,1);case"belt":return new n.TorusGeometry(Math.max(t*1.15,4),Math.max(t*.28,1),10,24);case"ring":return new n.TorusGeometry(Math.max(t,4),Math.max(t*.18,.8),10,30);case"asteroid":return new n.DodecahedronGeometry(t,0);case"comet":return new n.SphereGeometry(t*.94,18,14);default:return new n.SphereGeometry(t,24,18)}}function S2(n,e,t){let i=String(e.object.properties.kind??"").toLowerCase();return i.includes("relay")?new n.OctahedronGeometry(t*1.15,0):i.includes("elevator")||i.includes("skyhook")?new n.CylinderGeometry(t*.36,t*.52,t*2.4,10):i.includes("station")?new n.TorusKnotGeometry(t*.6,Math.max(t*.18,.6),42,8):new n.BoxGeometry(t*1.45,t*1.2,t*1.45)}function E2(n,e,t){let i=Math.max(e.visualRadius,2),r=e.object.type==="structure"?new n.BoxGeometry(i*2.2,i*2.2,i*2.2):new n.SphereGeometry(i*1.38,18,14);return new n.Mesh(r,new n.MeshBasicMaterial({color:t.selectionHalo,transparent:!0,opacity:.18,depthWrite:!1,side:1}))}function A2(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function T2(n,e){let t=Math.max(e.bandThickness??8,3),i=Fv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function Fv(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let o=0;o<t;o+=1){let a=o/t*Math.PI*2;i.push(new n.Vector3(Math.cos(a)*r,0,Math.sin(a)*s))}return i}function I2(n,e){let t=new n.BufferGeometry,i=new Float32Array(e*3),r=new Float32Array(e*3);for(let s=0;s<e;s+=1){let o=s*3,a=1800+Math.random()*2600,c=Math.random()*Math.PI*2,l=Math.acos(2*Math.random()-1);i[o]=a*Math.sin(l)*Math.cos(c),i[o+1]=a*Math.cos(l)*.45,i[o+2]=a*Math.sin(l)*Math.sin(c)}return t.setAttribute("position",new n.BufferAttribute(i,3)),t.setAttribute("color",new n.BufferAttribute(r,3)),new n.Points(t,new n.PointsMaterial({size:5,transparent:!0,opacity:.84,depthWrite:!1,vertexColors:!0,sizeAttenuation:!0}))}function Lv(n,e,t){let i=t==="high"?2.4:t==="low"?1.2:1.8;n.setPixelRatio?.(Math.min(globalThis.window?.devicePixelRatio??1,i)),"outputColorSpace"in n&&"SRGBColorSpace"in e?n.outputColorSpace=e.SRGBColorSpace:"outputEncoding"in n&&"sRGBEncoding"in e&&(n.outputEncoding=e.sRGBEncoding),"ACESFilmicToneMapping"in e&&(n.toneMapping=e.ACESFilmicToneMapping)}function C2(n,e){let t=ss(e?.theme),i=e?.quality??"balanced",r=e?.style3d??"symbolic",s=i==="high"?520:i==="low"?180:320,o=new Float32Array(s*3),a=new Float32Array(s*3),c=new n.THREE.Color(t.starfield),l=new n.THREE.Color(t.starfieldDim);for(let u=0;u<s;u+=1){let d=u*3,h=1800+Math.random()*2600,f=Math.random()*Math.PI*2,p=Math.acos(2*Math.random()-1);o[d]=h*Math.sin(p)*Math.cos(f),o[d+1]=h*Math.cos(p)*.45,o[d+2]=h*Math.sin(p)*Math.sin(f);let y=Math.random()>.72?c:l;a[d]=y.r,a[d+1]=y.g,a[d+2]=y.b}n.scene3d.background=new n.THREE.Color(t.backgroundStart),n.scene3d.fog=new n.THREE.FogExp2(t.spaceFog,85e-5),n.ambientLight.intensity=r==="cinematic"?.18:.26,n.fillLight.intensity=r==="cinematic"?.32:.4,n.rimLight.intensity=r==="cinematic"?.28:.22,n.renderer.toneMappingExposure=r==="cinematic"?1.18:1.08,n.starfield.geometry.setAttribute("position",new n.THREE.BufferAttribute(o,3)),n.starfield.geometry.setAttribute("color",new n.THREE.BufferAttribute(a,3)),n.starfield.material.opacity=i==="high"?.96:i==="low"?.72:.84,n.starfield.material.size=i==="high"?5.5:i==="low"?4.25:5}function Dv(n,e,t,i){for(let r of e){let s=r.material;if(!s)continue;let o=t?r.selectedColor??r.baseColor:i?r.hoveredColor??r.baseColor:r.baseColor;s.color?.set?.(new n.Color(o)),typeof s.opacity=="number"&&(s.opacity=t?r.selectedOpacity:i?r.hoveredOpacity:r.baseOpacity,s.transparent=s.opacity<.999);let a=t?r.selectedEmissive??r.baseEmissive:i?r.hoveredEmissive??r.baseEmissive:r.baseEmissive;s.emissive?.set?.(a?new n.Color(a):new n.Color(0)),"emissiveIntensity"in s&&(s.emissiveIntensity=t?r.selectedEmissiveIntensity??r.baseEmissiveIntensity??0:i?r.hoveredEmissiveIntensity??r.baseEmissiveIntensity??0:r.baseEmissiveIntensity??0)}}function R2(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function Ov(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function Uv(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.traverse?.(t=>{t.geometry?.dispose?.(),Array.isArray(t.material)?t.material.forEach(i=>i?.dispose?.()):t.material?.dispose?.()})}}function P2(){if(typeof document>"u")throw new ii;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new ii("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new ii("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function L2(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function Vu(n,e,t){return Math.min(Math.max(n,e),t)}function ka(n){return n*Math.PI/180}function D2(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function O2(){return Np||(Np=Promise.resolve().then(()=>(Pv(),Rv))),Np}var U2=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Bv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:z2(n.object.type),imageHref:n.renderObject.imageHref??null,description:k2(n),tags:F2(n.object.properties.tags),fields:N2(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function zv(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Zn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Zn(s.label)}</dt><dd>${Zn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Zn(n.objectId)}">
3933
+ </div>`}function CM(n){switch(n){case"star":return"#ffcc67";case"planet":return"#72b7ff";case"moon":return"#c7d7ea";case"belt":case"ring":return"#d9aa74";case"asteroid":return"#a7a5b8";case"comet":return"#9ce7ff";case"structure":return"#ff7f5f";case"phenomenon":return"#78ffd7"}}function Rn(n){return Number.isInteger(n)?String(n):n.toFixed(2)}var x2="wo-viewer-3d-root",Np=null;function Nv(n){P2();let e=document.createElement("div");e.className=x2,e.dataset.worldorbit3d="true",e.innerHTML='<div class="wo-viewer-3d-loading">Loading 3D view...</div>',n.innerHTML="",n.append(e);let t=null,i=null,r=null,s=null,o=new Set,a=null,c=null,l=new Map,u=null,d=!1,h=null,f=null,p="",y=new Map,g=new Map,m=[];return O2().then(P=>{if(d)return;let k=new P.Scene,O=new P.PerspectiveCamera(46,1,.1,24e3),H=new P.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});H.domElement.classList.add("wo-viewer-3d-canvas"),H.domElement.dataset.worldorbit3dCanvas="true",e.innerHTML="",e.append(H.domElement);let W=new P.AmbientLight(16777215,.24),J=new P.DirectionalLight(13625855,.36),ae=new P.DirectionalLight(8304895,.24),B=new P.PointLight(16773327,2.6,0,2);J.position.set(-360,260,220),ae.position.set(340,180,-280);let ne=new P.Group,ce=new P.Group,Me=I2(P,320),fe=new P.Raycaster;fe.params.Line={threshold:7},k.add(W),k.add(J),k.add(ae),k.add(B),k.add(Me),k.add(ne),k.add(ce),t={THREE:P,scene3d:k,camera:O,renderer:H,ambientLight:W,fillLight:J,rimLight:ae,keyLight:B,starfield:Me,orbitLayer:ne,objectLayer:ce,raycaster:fe,pointer:new P.Vector2},Lv(H,P,"balanced"),u&&x(u)}).catch(P=>{d||(e.innerHTML=`<div class="wo-viewer-3d-loading is-error">${D2(P instanceof Error?P.message:"WorldOrbit 3D could not be initialized.")}</div>`)}),{update(P){u=P,x(P)},hitTest(P,k){if(!t||!i)return null;let O=t.renderer.domElement.getBoundingClientRect();if(!O.width||!O.height)return null;t.pointer.x=(P-O.left)/O.width*2-1,t.pointer.y=-((k-O.top)/O.height)*2+1,t.raycaster.setFromCamera(t.pointer,t.camera);let H=t.raycaster.intersectObjects(m,!0);for(let W of H){let J=L2(W.object);if(J)return J}return null},projectObjectToContainer(P){if(!t)return null;let k=l.get(P);if(!k)return null;let O=new t.THREE.Vector3(k.x,k.y,k.z);if(O.project(t.camera),O.z>1)return null;let H=t.renderer.domElement.getBoundingClientRect(),W=n.getBoundingClientRect();return{x:H.left-W.left+(O.x+1)/2*H.width,y:H.top-W.top+(1-O.y)/2*H.height}},destroy(){d=!0,u=null,t?.renderer.dispose(),t?.starfield?.geometry?.dispose?.(),t?.starfield?.material?.dispose?.(),e.remove(),y.clear(),g.clear(),m.length=0,t=null}};function x(P){if(!t)return;let k=i!==P.spatialScene;i=P.spatialScene,r=P.renderOptions,s=P.state,o=P.visibleObjectIds,a=P.selectedObjectId,c=P.hoveredObjectId,Lv(t.renderer,t.THREE,r?.quality??"balanced");let O=JSON.stringify({theme:r?.theme??null,quality:r?.quality??"balanced",style3d:r?.style3d??"symbolic"});O!==p&&(C2(t,r),p=O),k&&v(P.spatialScene),S(P.spatialScene),l=cd(P.spatialScene,P.timeSeconds),w(),N(),C(),R(),F(),A(),t.renderer.render(t.scene3d,t.camera)}function v(P){if(!t)return;Uv(t.orbitLayer),Uv(t.objectLayer),y.clear(),g.clear(),m.length=0,h=null,f=null;let k=hr(r?.theme);for(let O of P.orbits){let H=_2(t.THREE,O,k);t.orbitLayer.add(H.root),g.set(O.objectId,H),m.push(H.root)}for(let O of P.objects){let H=b2(t.THREE,O,k);t.objectLayer.add(H.root),y.set(O.objectId,H),m.push(H.root)}}function w(){for(let P of i?.objects??[]){let k=y.get(P.objectId),O=l.get(P.objectId);k&&O&&k.root.position.set(O.x,O.y,O.z)}}function N(){for(let P of i?.orbits??[]){let k=g.get(P.objectId);if(!k)continue;let O=l.get(P.parentId);k.root.position.set(O?.x??P.center.x,O?.y??P.center.y,O?.z??P.center.z)}}function C(){let P=r?.layers??{};for(let k of i?.objects??[]){let O=y.get(k.objectId);if(!O)continue;let H=P.structures===!1&&(k.object.type==="structure"||k.object.type==="phenomenon");O.root.visible=!k.hidden&&o.has(k.objectId)&&P.objects!==!1&&!H}for(let k of i?.orbits??[]){let O=g.get(k.objectId);if(!O)continue;let H=P.structures===!1&&(k.object.type==="structure"||k.object.type==="phenomenon");O.root.visible=!k.hidden&&o.has(k.objectId)&&P.orbits!==!1&&!H}}function R(){if(t){for(let P of y.values()){let k=a===P.objectId,O=c===P.objectId;Dv(t.THREE,P.materials,k,O);let H=k?1.16:O?1.08:1;P.root.scale.set(H,H,H),P.halo&&(P.halo.visible=k||O)}for(let P of g.values())Dv(t.THREE,P.materials,a===P.objectId,c===P.objectId)}}function F(){if(!t||!i)return;let P=i.objects.find(O=>O.object.type==="star"&&!O.hidden)??null,k=P?l.get(P.objectId)??P.position:{x:0,y:40,z:0};t.keyLight.position.set(k.x,k.y+20,k.z)}function A(){if(!t||!i||!s)return;let P=r?.camera??i.camera,k=i.contentBounds,O=Math.max(k.width,k.depth,k.height,160),H=ka((P?.azimuth??30)+s.rotationDeg),W=ka(Hu(P?.elevation??22,-75,75)),J=Hu(2.2/Math.max(s.scale,.1),.35,7.2),ae=Hu(P?.distance??5.4,2,24),B=Hu(O*J*(ae/5.4),24,8e3),ne=Math.max(O/900,.12),ce=new t.THREE.Vector3(k.center.x-s.translateX*ne,k.center.y,k.center.z-s.translateY*ne),Me=new t.THREE.Vector3(ce.x+B*Math.cos(W)*Math.sin(H),ce.y+B*Math.sin(W),ce.z+B*Math.cos(W)*Math.cos(H)),fe=(r?.style3d??"symbolic")==="cinematic"?.16:.32;!h||!f?(h=Me.clone(),f=ce.clone()):(h.lerp(Me,fe),f.lerp(ce,fe)),t.camera.position.copy(h),t.camera.lookAt(f),P?.roll&&(t.camera.rotation.z=ka(P.roll))}function S(P){if(!t)return;let k=Math.max(1,Math.round(n.clientWidth||P.width||960)),O=Math.max(1,Math.round(n.clientHeight||P.height||560));t.renderer.setSize(k,O,!1),t.camera.aspect=k/O,t.camera.updateProjectionMatrix()}}function b2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId;let r=e.fillColor??R2(e),s=[],o=w2(n,e,r,t),a=new n.Mesh(M2(n,e),o.material);if(a.userData.objectId=e.objectId,i.add(a),s.push(o),A2(e)){let l={material:new n.MeshBasicMaterial({color:t.atmosphere,transparent:!0,opacity:.24,depthWrite:!1,side:2}),baseColor:t.atmosphere,baseOpacity:.24,hoveredOpacity:.34,selectedOpacity:.42},u=new n.Mesh(new n.SphereGeometry(Math.max(e.visualRadius,2)*1.16,20,14),l.material);u.userData.objectId=e.objectId,i.add(u),s.push(l)}if(e.object.type==="comet"){let l={material:new n.MeshBasicMaterial({color:t.cometTail,transparent:!0,opacity:.36,depthWrite:!1}),baseColor:t.cometTail,baseOpacity:.36,hoveredOpacity:.48,selectedOpacity:.56},u=new n.Mesh(new n.ConeGeometry(Math.max(e.visualRadius*.55,2),Math.max(e.visualRadius*2.8,8),12,1,!0),l.material);u.position.set(-Math.max(e.visualRadius*1.4,4),0,0),u.rotation.z=-Math.PI/2,u.userData.objectId=e.objectId,i.add(u),s.push(l)}let c=E2(n,e,t);return c&&(c.visible=!1,c.userData.objectId=e.objectId,i.add(c)),{objectId:e.objectId,root:i,halo:c,materials:s}}function _2(n,e,t){let i=new n.Group;i.userData.objectId=e.objectId,i.rotation.y=ka(e.rotationDeg),i.rotation.x=ka(e.inclinationDeg);let r=e.object.properties.color??t.orbit;if(e.band){let c={material:new n.MeshBasicMaterial({color:r,transparent:!0,opacity:t.orbitBandOpacity,side:2,depthWrite:!1}),baseColor:r,baseOpacity:t.orbitBandOpacity,hoveredOpacity:Math.min(t.orbitBandOpacity+.1,.58),selectedOpacity:Math.min(t.orbitBandOpacity+.18,.72),hoveredColor:t.accent,selectedColor:t.accentStrong},l=new n.Mesh(T2(n,e),c.material);return l.userData.objectId=e.objectId,i.add(l),{objectId:e.objectId,root:i,materials:[c]}}let s={material:new n.LineBasicMaterial({color:r,transparent:!0,opacity:t.orbitOpacity}),baseColor:r,baseOpacity:t.orbitOpacity,hoveredOpacity:Math.min(t.orbitOpacity+.18,.72),selectedOpacity:Math.min(t.orbitOpacity+.3,.88),hoveredColor:t.accent,selectedColor:t.accentStrong},o=new n.BufferGeometry().setFromPoints(Fv(n,e,120)),a=new n.LineLoop(o,s.material);return a.userData.objectId=e.objectId,i.add(a),{objectId:e.objectId,root:i,materials:[s]}}function w2(n,e,t,i){if(e.object.type==="star")return{material:new n.MeshStandardMaterial({color:t,emissive:new n.Color(i.starGlow),emissiveIntensity:1.2,roughness:.35,metalness:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:i.starCore,selectedColor:"#fff2c4",baseEmissive:i.starGlow,hoveredEmissive:i.starGlow,selectedEmissive:"#fff6cc",baseEmissiveIntensity:1.2,hoveredEmissiveIntensity:1.5,selectedEmissiveIntensity:1.8};if(e.object.type==="phenomenon")return{material:new n.MeshPhongMaterial({color:t,transparent:!0,opacity:.7,emissive:new n.Color(t),emissiveIntensity:.32,shininess:90}),baseColor:t,baseOpacity:.7,hoveredOpacity:.82,selectedOpacity:.9,hoveredColor:i.accent,selectedColor:i.selectionHalo,baseEmissive:t,hoveredEmissive:i.accent,selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.32,hoveredEmissiveIntensity:.52,selectedEmissiveIntensity:.74};let r=e.object.type==="structure"?70:e.object.type==="ring"?42:e.object.type==="belt"?26:36;return{material:new n.MeshPhongMaterial({color:t,specular:new n.Color(i.objectSpecular),shininess:r,transparent:!1,opacity:1,emissive:new n.Color(0),emissiveIntensity:.02}),baseColor:t,baseOpacity:1,hoveredOpacity:1,selectedOpacity:1,hoveredColor:Ov(n,t,.08),selectedColor:Ov(n,t,.16),hoveredEmissive:"#8fcaff",selectedEmissive:i.selectionHalo,baseEmissiveIntensity:.02,hoveredEmissiveIntensity:.12,selectedEmissiveIntensity:.22}}function M2(n,e){let t=Math.max(e.visualRadius,2);switch(e.object.type){case"star":return new n.SphereGeometry(t*1.14,34,24);case"structure":return S2(n,e,t);case"phenomenon":return new n.IcosahedronGeometry(t*1.12,1);case"belt":return new n.TorusGeometry(Math.max(t*1.15,4),Math.max(t*.28,1),10,24);case"ring":return new n.TorusGeometry(Math.max(t,4),Math.max(t*.18,.8),10,30);case"asteroid":return new n.DodecahedronGeometry(t,0);case"comet":return new n.SphereGeometry(t*.94,18,14);default:return new n.SphereGeometry(t,24,18)}}function S2(n,e,t){let i=String(e.object.properties.kind??"").toLowerCase();return i.includes("relay")?new n.OctahedronGeometry(t*1.15,0):i.includes("elevator")||i.includes("skyhook")?new n.CylinderGeometry(t*.36,t*.52,t*2.4,10):i.includes("station")?new n.TorusKnotGeometry(t*.6,Math.max(t*.18,.6),42,8):new n.BoxGeometry(t*1.45,t*1.2,t*1.45)}function E2(n,e,t){let i=Math.max(e.visualRadius,2),r=e.object.type==="structure"?new n.BoxGeometry(i*2.2,i*2.2,i*2.2):new n.SphereGeometry(i*1.38,18,14);return new n.Mesh(r,new n.MeshBasicMaterial({color:t.selectionHalo,transparent:!0,opacity:.18,depthWrite:!1,side:1}))}function A2(n){return n.object.type!=="planet"&&n.object.type!=="moon"?!1:n.object.properties.atmosphere!==void 0}function T2(n,e){let t=Math.max(e.bandThickness??8,3),i=Fv(n,e,72),r=new n.CatmullRomCurve3(i,!0);return new n.TubeGeometry(r,144,t*.18,10,!0)}function Fv(n,e,t=96){let i=[],r=Math.max(e.semiMajor,e.radius??1,1),s=Math.max(e.semiMinor,e.radius??1,1);for(let o=0;o<t;o+=1){let a=o/t*Math.PI*2;i.push(new n.Vector3(Math.cos(a)*r,0,Math.sin(a)*s))}return i}function I2(n,e){let t=new n.BufferGeometry,i=new Float32Array(e*3),r=new Float32Array(e*3);for(let s=0;s<e;s+=1){let o=s*3,a=1800+Math.random()*2600,c=Math.random()*Math.PI*2,l=Math.acos(2*Math.random()-1);i[o]=a*Math.sin(l)*Math.cos(c),i[o+1]=a*Math.cos(l)*.45,i[o+2]=a*Math.sin(l)*Math.sin(c)}return t.setAttribute("position",new n.BufferAttribute(i,3)),t.setAttribute("color",new n.BufferAttribute(r,3)),new n.Points(t,new n.PointsMaterial({size:5,transparent:!0,opacity:.84,depthWrite:!1,vertexColors:!0,sizeAttenuation:!0}))}function Lv(n,e,t){let i=t==="high"?2.4:t==="low"?1.2:1.8;n.setPixelRatio?.(Math.min(globalThis.window?.devicePixelRatio??1,i)),"outputColorSpace"in n&&"SRGBColorSpace"in e?n.outputColorSpace=e.SRGBColorSpace:"outputEncoding"in n&&"sRGBEncoding"in e&&(n.outputEncoding=e.sRGBEncoding),"ACESFilmicToneMapping"in e&&(n.toneMapping=e.ACESFilmicToneMapping)}function C2(n,e){let t=hr(e?.theme),i=e?.quality??"balanced",r=e?.style3d??"symbolic",s=i==="high"?520:i==="low"?180:320,o=new Float32Array(s*3),a=new Float32Array(s*3),c=new n.THREE.Color(t.starfield),l=new n.THREE.Color(t.starfieldDim);for(let u=0;u<s;u+=1){let d=u*3,h=1800+Math.random()*2600,f=Math.random()*Math.PI*2,p=Math.acos(2*Math.random()-1);o[d]=h*Math.sin(p)*Math.cos(f),o[d+1]=h*Math.cos(p)*.45,o[d+2]=h*Math.sin(p)*Math.sin(f);let y=Math.random()>.72?c:l;a[d]=y.r,a[d+1]=y.g,a[d+2]=y.b}n.scene3d.background=new n.THREE.Color(t.backgroundStart),n.scene3d.fog=new n.THREE.FogExp2(t.spaceFog,85e-5),n.ambientLight.intensity=r==="cinematic"?.18:.26,n.fillLight.intensity=r==="cinematic"?.32:.4,n.rimLight.intensity=r==="cinematic"?.28:.22,n.renderer.toneMappingExposure=r==="cinematic"?1.18:1.08,n.starfield.geometry.setAttribute("position",new n.THREE.BufferAttribute(o,3)),n.starfield.geometry.setAttribute("color",new n.THREE.BufferAttribute(a,3)),n.starfield.material.opacity=i==="high"?.96:i==="low"?.72:.84,n.starfield.material.size=i==="high"?5.5:i==="low"?4.25:5}function Dv(n,e,t,i){for(let r of e){let s=r.material;if(!s)continue;let o=t?r.selectedColor??r.baseColor:i?r.hoveredColor??r.baseColor:r.baseColor;s.color?.set?.(new n.Color(o)),typeof s.opacity=="number"&&(s.opacity=t?r.selectedOpacity:i?r.hoveredOpacity:r.baseOpacity,s.transparent=s.opacity<.999);let a=t?r.selectedEmissive??r.baseEmissive:i?r.hoveredEmissive??r.baseEmissive:r.baseEmissive;s.emissive?.set?.(a?new n.Color(a):new n.Color(0)),"emissiveIntensity"in s&&(s.emissiveIntensity=t?r.selectedEmissiveIntensity??r.baseEmissiveIntensity??0:i?r.hoveredEmissiveIntensity??r.baseEmissiveIntensity??0:r.baseEmissiveIntensity??0)}}function R2(n){switch(n.object.type){case"star":return"#ffd36a";case"planet":return"#73b6ff";case"moon":return"#d8dde8";case"belt":return"#b8926a";case"ring":return"#cdbf9a";case"structure":return"#ffce8a";case"phenomenon":return"#7ce6ff";case"asteroid":return"#cdb5a1";case"comet":return"#b8f2ff"}}function Ov(n,e,t){let i=new n.Color(e);return i.offsetHSL(0,0,t),`#${i.getHexString()}`}function Uv(n){for(;n.children.length>0;){let e=n.children[0];n.remove(e),e.traverse?.(t=>{t.geometry?.dispose?.(),Array.isArray(t.material)?t.material.forEach(i=>i?.dispose?.()):t.material?.dispose?.()})}}function P2(){if(typeof document>"u")throw new ri;let n=document.defaultView?.navigator??globalThis.window?.navigator??(typeof navigator<"u"?navigator:void 0);if(/jsdom/i.test(n?.userAgent??""))throw new ri("WorldOrbit 3D needs WebGL support, but this environment did not provide it.");let e=document.createElement("canvas"),t=r=>{try{return e.getContext?.(r)??null}catch{return null}};if(!(t("webgl2")??t("webgl")??t("experimental-webgl")))throw new ri("WorldOrbit 3D needs WebGL support, but this environment did not provide it.")}function L2(n){let e=n;for(;e;){if(typeof e.userData?.objectId=="string")return e.userData.objectId;e=e.parent}return null}function Hu(n,e,t){return Math.min(Math.max(n,e),t)}function ka(n){return n*Math.PI/180}function D2(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function O2(){return Np||(Np=Promise.resolve().then(()=>(Pv(),Rv))),Np}var U2=["radius","temperature","atmosphere","period","semiMajor","distance","eccentricity","angle","inclination","phase","albedo","mass","density","gravity"];function Bv(n){return{objectId:n.objectId,title:n.objectId,typeLabel:z2(n.object.type),imageHref:n.renderObject.imageHref??null,description:k2(n),tags:F2(n.object.properties.tags),fields:N2(n),parentLabel:n.parent?.objectId??null,orbitLabel:n.orbit?.parentId??null,details:n}}function zv(n,e){let t=n.tags.length?`<div class="wo-tooltip-tags">${n.tags.map(s=>`<span class="wo-tooltip-tag">${Jn(s)}</span>`).join("")}</div>`:"",i=n.fields.length?`<dl class="wo-tooltip-fields">${n.fields.map(s=>`<div class="wo-tooltip-field"><dt>${Jn(s.label)}</dt><dd>${Jn(s.value)}</dd></div>`).join("")}</dl>`:"",r=[n.parentLabel?`Parent: ${n.parentLabel}`:null,n.orbitLabel?`Orbit: ${n.orbitLabel}`:null,e==="pinned"?"Pinned tooltip":"Hover tooltip"].filter(Boolean);return`<article class="wo-tooltip-card" data-tooltip-object-id="${Jn(n.objectId)}">
3934
3934
  <div class="wo-tooltip-head">
3935
- ${n.imageHref?`<img class="wo-tooltip-image" src="${$2(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Zn(n.typeLabel.slice(0,1))}</div>`}
3935
+ ${n.imageHref?`<img class="wo-tooltip-image" src="${$2(n.imageHref)}" alt="" />`:`<div class="wo-tooltip-image wo-tooltip-image-placeholder">${Jn(n.typeLabel.slice(0,1))}</div>`}
3936
3936
  <div class="wo-tooltip-heading">
3937
- <strong>${Zn(n.title)}</strong>
3938
- <span>${Zn(n.typeLabel)}</span>
3937
+ <strong>${Jn(n.title)}</strong>
3938
+ <span>${Jn(n.typeLabel)}</span>
3939
3939
  </div>
3940
3940
  </div>
3941
- ${n.description?`<p class="wo-tooltip-description">${Zn(n.description)}</p>`:""}
3941
+ ${n.description?`<p class="wo-tooltip-description">${Jn(n.description)}</p>`:""}
3942
3942
  ${t}
3943
3943
  ${i}
3944
- ${r.length?`<p class="wo-tooltip-relations">${Zn(r.join(" - "))}</p>`:""}
3945
- </article>`}function N2(n){let e=new Map;for(let i of U2){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:V2(i),value:kv(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${kv(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function F2(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function k2(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function kv(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):B2(n)}function B2(n){return`${n.value}${n.unit??""}`}function z2(n){return n.charAt(0).toUpperCase()+n.slice(1)}function V2(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Zn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function $2(n){return Zn(n)}var eo={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Vv="worldorbit-viewer-tooltip-style";function to(n,e){if(W2(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??eo.minScale,maxScale:e.maxScale??eo.maxScale,fitPadding:e.fitPadding??eo.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??eo.panStep,zoomStep:e.zoomStep??eo.zoomStep,rotationStep:e.rotationStep??eo.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,bodyScaleMode:e.bodyScaleMode,viewMode:e.viewMode??"2d",quality:e.quality??"balanced",style3d:e.style3d??"symbolic",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:Bn(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,c=n.style.position,l=H2(e),u=Ba(l,s),d=e.spatialScene??null,h=s.viewMode==="3d"?Wr(l,s,d):null,f={...In},p=null,y=null,g=null,m=null,x=null,v=null,w=!1,N=null,C=null,R=0,F=!1,A=new Map,S=null,P=null,k=null,O=null,H=null,W=null,J=null,ae=null,B={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),X2(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),tt();let ne=L=>{if(!r.pointer||F)return;if(L.preventDefault(),n.focus(),Re()){let _=Xr(Math.exp(-L.deltaY*.002),.6,1.6);_e.zoomBy(_);return}let $=ee(L.clientX,L.clientY),b=Xr(Math.exp(-L.deltaY*.002),.6,1.6);Be(Eo(u,f,b,$,i))},ce=L=>{if(F)return;let $=L.pointerType==="touch";if($&&!r.touch||!$&&!r.pointer||!$&&L.button!==0&&!Re())return;n.focus(),n.setPointerCapture?.(L.pointerId);let b=G(L.clientX,L.clientY);if($){A.set(L.pointerId,b),A.size===2?S=Hv(u,f,A):A.size===1&&(R=0,w=!1);return}N=L.pointerId,C=b,R=0,w=!1},Me=L=>{if(F)return;if(L.pointerType==="touch"){if(Re()||!r.touch||!A.has(L.pointerId))return;let E=A.get(L.pointerId),I=G(L.clientX,L.clientY);if(A.set(L.pointerId,I),A.size===2){S||(S=Hv(u,f,A));let j=Wv(A),Q=j.distance/Math.max(S.startDistance,1),ge=Eo(u,S.startState,Q,S.startCenter,i),Se=j.center.x-S.startViewportCenter.x,Le=j.center.y-S.startViewportCenter.y;Be(os(ge,Se,Le))}else if(A.size===1){let j=I.x-E.x,Q=I.y-E.y;R+=Math.abs(j)+Math.abs(Q),R>2&&(w=!0),Be(os(f,j,Q))}return}if(Re()&&r.pointer&&N===null){he(g?.hitTest(L.clientX,L.clientY)??null);return}if(Re()&&r.pointer&&N===L.pointerId&&C){let E=G(L.clientX,L.clientY),I=E.x-C.x,j=E.y-C.y;R+=Math.abs(I)+Math.abs(j),C=E,R>2&&(w=!0),L.shiftKey||L.buttons===2?_e.panBy(I,j):(_e.rotateBy(I*.35),_e.panBy(0,j*.35)),he(g?.hitTest(L.clientX,L.clientY)??null);return}if(!r.pointer||N!==L.pointerId||!C)return;let b=G(L.clientX,L.clientY),_=b.x-C.x,M=b.y-C.y;R+=Math.abs(_)+Math.abs(M),C=b,R>2&&(w=!0),Be(os(f,_,M))},fe=L=>{if(L.pointerType==="touch"){A.delete(L.pointerId),A.size<2&&(S=null);return}N===L.pointerId&&(N=null,C=null)},$e=L=>{if(!r.selection||F)return;if(w){w=!1;return}let $=Re()?g?.hitTest(L.clientX,L.clientY)??null:$u(L.target);Z($),r.tooltipMode==="pinned"&&(k=$,Fe())},Y=L=>{if(Re())return;let $=$u(L.target);he($)},me=()=>{he(null)},te=L=>{if(Re())return;let $=$u(L.target);$&&he($)},ue=()=>{he(null)},Pe=L=>{if(!r.keyboard||F)return;let $=Re()?f.selectedObjectId:$u(L.target);if((L.key==="Enter"||L.key===" ")&&$){L.preventDefault(),Z($),r.tooltipMode==="pinned"&&(k=$,Fe());return}switch(L.key){case"Escape":r.tooltipMode==="pinned"&&k&&(L.preventDefault(),k=null,Fe());return;case"+":case"=":L.preventDefault(),_e.zoomBy(r.zoomStep);return;case"-":L.preventDefault(),_e.zoomBy(1/r.zoomStep);return;case"ArrowLeft":L.preventDefault(),_e.panBy(-r.panStep,0);return;case"ArrowRight":L.preventDefault(),_e.panBy(r.panStep,0);return;case"ArrowUp":L.preventDefault(),_e.panBy(0,-r.panStep);return;case"ArrowDown":L.preventDefault(),_e.panBy(0,r.panStep);return;case"[":L.preventDefault(),_e.rotateBy(-r.rotationStep);return;case"]":L.preventDefault(),_e.rotateBy(r.rotationStep);return;case"f":case"F":L.preventDefault(),_e.fitToSystem();return;case"0":L.preventDefault(),_e.resetView();return}};n.addEventListener("wheel",ne,{passive:!1}),n.addEventListener("pointerdown",ce),n.addEventListener("pointermove",Me),n.addEventListener("pointerup",fe),n.addEventListener("pointercancel",fe),n.addEventListener("click",$e),n.addEventListener("mouseover",Y),n.addEventListener("mouseleave",me),n.addEventListener("focusin",te),n.addEventListener("focusout",ue),n.addEventListener("keydown",Pe);let _e={setSource(L){l={kind:"source",value:L},u=Ba(l,s),d=null,h=s.viewMode==="3d"?Wr(l,s,null):null,tt(),W=null,z(!0)},setDocument(L){l={kind:"document",value:L},u=Ba(l,s),d=null,h=s.viewMode==="3d"?Wr(l,s,null):null,tt(),W=null,z(!0)},setScene(L){l={kind:"scene",value:L},u=L,d=null,h=s.viewMode==="3d"?Wr(l,s,null):null,tt(),W=null,z(!0)},getScene(){return u},getRenderOptions(){return j2(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(L){let $=s,b=h,_=Fp(s,{viewMode:L}),M=L==="3d"?Wr(l,_,d):null;s=_,h=M,tt();try{z(!1)}catch(E){throw s=$,h=b,tt(),z(!1),E}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return ve(W)},goToViewpoint(L){let $=ve(L);if(!$)return!1;let b={},_=Cd($);if($.preset!==null&&(b.preset=$.preset),l.kind!=="scene"&&$.projection!==u.projection&&(b.projection=$.projection),$.camera?b.camera={...$.camera}:s.camera&&(b.camera=null),_&&(b.layers=_),W=$.id,Object.keys(b).length>0){let E=$v(b);s=Fp(s,b),l.kind!=="scene"&&E&&(u=Ba(l,s)),z(E)}pe(Rd($),!1,!1);let M=xe($);return Be(M),Z($.selectedObjectId??$.objectId??null,!1),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),qe(),Ne(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(L){_e.setRenderOptions({activeEventId:L})},playAnimation(){if(!Re()){B={...B,playing:!1},vt();return}if(B.frozenByEvent){B={...B,playing:!1};return}B={...B,playing:!0},ft()},pauseAnimation(){B={...B,playing:!1},vt()},resetAnimation(){B={...B,playing:!1,timeSeconds:0},vt(),$t()},setAnimationSpeed(L){B={...B,speed:Xr(L,.1,64)}},getAnimationState(){return{...B}},search(L,$=12){return Ad(u,L,$)},getFilter(){return s.filter?{...s.filter}:null},setFilter(L){pe(L,!0,!0)},getVisibleObjects(){return re()},getFocusPath(L){return Ue(L)},getObjectDetails(L){return Te(L)},getSelectionDetails(){return Te(f.selectedObjectId)},getTooltipDetails(){return H},getAtlasState(){return pg(f,s,s.filter??null,W)},setAtlasState(L){let $=typeof L=="string"?Id(L):L;$.viewpointId&&_e.goToViewpoint($.viewpointId),_e.setRenderOptions($.renderOptions),pe($.filter??null,!1,!1),Be(X({...f,...$.viewerState})),Z($.viewerState.selectedObjectId??null,!1),qe(),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),Ne()},serializeAtlasState(){return Td(_e.getAtlasState())},captureBookmark(L,$){return mg(L,$,_e.getAtlasState())},applyBookmark(L){return typeof L=="string"?(_e.setAtlasState(L),!0):(_e.setAtlasState(L.atlasState),!0)},setRenderOptions(L){let $=$v(L),b=s,_=u,M=h,E=Fp(s,L),I=u;l.kind!=="scene"&&$&&(I=Ba(l,E));let j=E.viewMode==="3d"?Wr(l,E,d):null;s=E,u=I,h=j,tt();try{z($)}catch(Q){throw s=b,u=_,h=M,tt(),z($),Q}},getState(){return{...f}},setState(L){Be(X({...f,...L}))},zoomBy(L,$){Be(Eo(u,f,L,$??{x:u.width/2,y:u.height/2},i))},panBy(L,$){Be(os(f,L,$))},rotateBy(L){Be(Pd(f,L))},fitToSystem(){Be(Re()?{...In,selectedObjectId:f.selectedObjectId}:as(u,f,i))},focusObject(L){W=null,Be(Re()?ar(L):Ld(u,f,L,i)),Z(L),r.tooltipMode==="pinned"&&(k=ye(L)?.objectId??null,Fe())},pinTooltip(L){k=ye(L)?.objectId??null,Fe()},resetView(){let L=Re()?{...In}:as(u,{...In},i);W=null,Be(L),Z(null),k=null,Fe()},exportSvg(){return ri(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){F||(F=!0,n.removeEventListener("wheel",ne),n.removeEventListener("pointerdown",ce),n.removeEventListener("pointermove",Me),n.removeEventListener("pointerup",fe),n.removeEventListener("pointercancel",fe),n.removeEventListener("click",$e),n.removeEventListener("mouseover",Y),n.removeEventListener("mouseleave",me),n.removeEventListener("focusin",te),n.removeEventListener("focusout",ue),n.removeEventListener("keydown",Pe),vt(),g?.destroy(),g=null,x?.remove(),x=null,v?.remove(),v=null,m?.remove(),m=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=a,n.style.position=c,o===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",o))}};return z(!0),e.initialViewpointId?_e.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?_e.focusObject(e.initialSelectionObjectId):Ne(),_e;function z(L){if(g?.destroy(),g=null,n.innerHTML="",p=null,y=null,m=null,x=null,v=null,Re()?(h=h??Wr(l,s,d),g=Nv(n)):(n.innerHTML=ri(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),p=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(m=document.createElement("div"),m.dataset.worldorbitMinimapRoot="true",n.append(m)),x=document.createElement("div"),x.className="wo-viewer-label-root",x.dataset.worldorbitLabelRoot="true",n.append(x),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",we),n.append(v)),!Re()&&(!p||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");Yr(),f=L?Re()?{...In}:as(u,{...In},i):X(f),Z(f.selectedObjectId&&ye(f.selectedObjectId)?f.selectedObjectId:null,!1),he(P&&ye(P)?P:null,!1),k=k&&ye(k)?k:null,$t(),Oe(),qe(),e.onViewChange?.({...f}),Ne()}function Be(L){f=X(L),$t(),e.onViewChange?.({...f}),Ne()}function X(L){return{scale:Xr(L.scale,i.minScale,i.maxScale),rotationDeg:jv(L.rotationDeg),translateX:Number.isFinite(L.translateX)?L.translateX:f.translateX,translateY:Number.isFinite(L.translateY)?L.translateY:f.translateY,selectedObjectId:L.selectedObjectId&&ye(L.selectedObjectId)?L.selectedObjectId:null}}function de(){if(Re()){Et();return}y&&(y.setAttribute("transform",Dd(u,f)),rr(),Ce(),Fe())}function Z(L,$=!0){if(!Re()&&f.selectedObjectId)for(let b of n.querySelectorAll(`[data-object-id="${za(f.selectedObjectId)}"]`))b.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:L&&ye(L)?L:null},!Re()&&f.selectedObjectId)for(let b of n.querySelectorAll(`[data-object-id="${za(f.selectedObjectId)}"]`))b.classList.add("wo-object-selected");U(),Fe(),$&&(e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),e.onViewChange?.({...f}),Ne())}function he(L,$=!0){P===L&&$||(P=L&&ye(L)?L:null,U(),Fe(),$&&(e.onHoverChange?.(ye(P)),e.onHoverDetailsChange?.(Te(P))))}function ie(){return ye(f.selectedObjectId)}function ye(L){if(!L)return null;let $=oe();return u.objects.find(b=>b.objectId===L&&!b.hidden&&$.has(b.objectId))??null}function Te(L){let $=ye(L);return $?{objectId:$.objectId,object:$.object,renderObject:$,label:u.labels.find(b=>b.objectId===$.objectId&&!b.hidden)??null,group:u.groups.find(b=>b.renderId===$.groupId)??null,semanticGroups:u.semanticGroups.filter(b=>$.semanticGroupIds.includes(b.id)),orbit:u.orbitVisuals.find(b=>b.objectId===$.objectId&&!b.hidden)??null,relatedOrbits:u.orbitVisuals.filter(b=>!b.hidden&&(b.objectId===$.objectId||$.ancestorIds.includes(b.objectId)||$.childIds.includes(b.objectId))),relations:u.relations.filter(b=>!b.hidden&&(b.fromObjectId===$.objectId||b.toObjectId===$.objectId)),relatedEvents:u.events.filter(b=>!b.hidden&&(b.targetObjectId===$.objectId||b.objectIds.includes($.objectId))),parent:ye($.parentId),children:$.childIds.map(b=>ye(b)).filter(Boolean),ancestors:$.ancestorIds.map(b=>ye(b)).filter(Boolean),focusPath:Ue($.objectId)}:null}function U(){if(Re()){Et();return}for(let L of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))L.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");T(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),T(P,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function T(L,$){let b=Te(L);if(!b)return;let _=new Set([b.objectId,...b.renderObject.childIds,...b.renderObject.ancestorIds]);for(let M of _)for(let E of n.querySelectorAll(`[data-object-id="${za(M)}"]`))E.classList.add($.objectClass);for(let M of b.ancestors)for(let E of n.querySelectorAll(`[data-object-id="${za(M.objectId)}"]`))E.classList.add($.ancestorClass);for(let M of b.relatedOrbits)for(let E of n.querySelectorAll(`[data-orbit-object-id="${za(M.objectId)}"]`))E.classList.add($.orbitClass)}function G(L,$){if(Re()){let _=n.getBoundingClientRect();return!_.width||!_.height?{x:u.width/2,y:u.height/2}:{x:L-_.left,y:$-_.top}}if(!p)return{x:u.width/2,y:u.height/2};let b=p.getBoundingClientRect();return!b.width||!b.height?{x:u.width/2,y:u.height/2}:{x:(L-b.left)/b.width*u.width,y:($-b.top)/b.height*u.height}}function ee(L,$){return hr(u,f,G(L,$))}function oe(){return wc(u,s.filter??null)}function re(){let L=oe();return u.objects.filter($=>!$.hidden&&L.has($.objectId))}function Ue(L){let $=u.objects.find(b=>b.objectId===L&&!b.hidden);return $?[...$.ancestorIds,$.objectId].map(b=>ye(b)).filter(Boolean):[]}function ve(L){return u.viewpoints.find($=>$.id===L)??null}function xe(L){let $=jv(L.rotationDeg),b=L.scale!==null&&L.scale!==void 0?Xr(L.scale,i.minScale,i.maxScale):null;if(Re()){let E=L.objectId??L.selectedObjectId??null,I=E?h?.focusTargets.find(j=>j.objectId===E):null;return{scale:b??1.6,rotationDeg:$,translateX:I?-I.center.x:0,translateY:I?-I.center.z:0,selectedObjectId:L.selectedObjectId??L.objectId??null}}let _=L.objectId&&u.objects.find(E=>E.objectId===L.objectId&&!E.hidden);if(_)return He({x:_.x,y:_.y},b??Math.max(1.8,In.scale),$,L.selectedObjectId??_.objectId);let M=as(u,{...In,rotationDeg:$},i);return b===null?{...M,rotationDeg:$,selectedObjectId:L.selectedObjectId??null}:He({x:u.contentBounds.centerX,y:u.contentBounds.centerY},b,$,L.selectedObjectId??null)}function He(L,$,b,_){let M={x:u.width/2,y:u.height/2},E=rn(L,M,b);return{scale:$,rotationDeg:b,translateX:M.x-(M.x+(E.x-M.x)*$),translateY:M.y-(M.y+(E.y-M.y)*$),selectedObjectId:_}}function pe(L,$,b){s={...s,filter:Bn(L)},b&&(W=null),z(!1)}function Oe(){e.onFilterChange?.(s.filter??null,re())}function qe(){e.onViewpointChange?.(ve(W))}function Ne(){e.onAtlasStateChange?.(_e.getAtlasState())}function Ce(){!r.minimap||!m||(m.innerHTML=Sg(u,f,re()))}function Fe(){if(r.tooltipMode==="disabled"||!v){Ae(null);return}let L=Qe();if(!L){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let $=Te(L.objectId);if(!$){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let b=Bv($);O=L.objectId,v.hidden=!1,v.dataset.mode=L.mode,v.classList.toggle("is-pinned",L.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",pt(v,b,L.mode),je(v,$.renderObject),v.style.visibility="visible",Ae(b)}function Qe(){return k&&ye(k)?{objectId:k,mode:"pinned"}:P&&ye(P)?{objectId:P,mode:"hover"}:null}function pt(L,$,b){let _=e.tooltipRenderer?.($,b);L.innerHTML="",typeof _=="string"?L.innerHTML=_:_ instanceof HTMLElement?L.append(_):L.innerHTML=zv($,b);let M=document.createElement("div");if(M.className="wo-tooltip-actions",b==="pinned"){let E=document.createElement("button");E.type="button",E.className="wo-tooltip-action",E.dataset.tooltipAction="unpin",E.textContent="Unpin",M.append(E)}else{let E=document.createElement("button");E.type="button",E.className="wo-tooltip-action",E.dataset.tooltipAction="pin",E.dataset.objectId=$.objectId,E.textContent="Pin",M.append(E)}M.childElementCount>0&&L.append(M)}function je(L,$){let b=Re()?g?.projectObjectToContainer($.objectId)??null:le($);if(!b)return;let _=Math.max(n.clientWidth-L.offsetWidth-12,12),M=Math.max(n.clientHeight-L.offsetHeight-12,12),E=b.y>n.clientHeight*.48,I=Xr(b.x+18,12,_),j=Xr(E?b.y-L.offsetHeight-18:b.y+18,12,M);L.style.left=`${I}px`,L.style.top=`${j}px`}function V(L){if(Re())return L;let $={x:u.width/2,y:u.height/2},b=rn(L,$,f.rotationDeg);return{x:$.x+(b.x-$.x)*f.scale+f.translateX,y:$.y+(b.y-$.y)*f.scale+f.translateY}}function le(L){let $={x:L.anchorX??L.x,y:L.anchorY??L.y-Math.max(L.visualRadius,L.radius)};return K($)}function K(L){if(!p)return null;let $=V(L),b=p.getBoundingClientRect(),_=n.getBoundingClientRect();return{x:b.left-_.left+$.x/Math.max(u.width,1)*b.width,y:b.top-_.top+$.y/Math.max(u.height,1)*b.height}}function we(L){let $=L.target?.closest("[data-tooltip-action]");if($){switch(L.preventDefault(),L.stopPropagation(),$.dataset.tooltipAction){case"pin":k=$.dataset.objectId??O;break;case"unpin":k=null;break}Fe()}}function Ae(L){let $=H?.objectId!==L?.objectId||H?.description!==L?.description||H?.imageHref!==L?.imageHref;H=L,O=L?.objectId??null,$&&e.onTooltipChange?.(L)}function Re(){return s.viewMode==="3d"}function tt(){B={...B,frozenByEvent:h?.timeFrozen??!1},B.frozenByEvent&&(B={...B,playing:!1},vt())}function ft(){J!==null||!B.playing||F||(J=window.requestAnimationFrame(rt))}function vt(){J!==null&&(window.cancelAnimationFrame(J),J=null),ae=null}function rt(L){if(J=null,!B.playing||F){ae=null;return}let b=Math.max((L-(ae??L))/1e3,0);ae=L,B={...B,timeSeconds:B.timeSeconds+b*B.speed},Et(),ft()}function $t(){de(),Re()&&B.playing?ft():(!B.playing||!Re())&&vt()}function Et(){!Re()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:oe(),selectedObjectId:f.selectedObjectId,hoveredObjectId:P,state:f,timeSeconds:B.timeSeconds}),rr(),Ce(),Fe())}function Yr(){if(!Re()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let L of n.querySelectorAll(".wo-event-label"))L.setAttribute("display","none")}}function rr(){if(!x)return;let L=Nn();x.replaceChildren(...L.map($=>Fn($))),x.hidden=L.length===0}function Nn(){let L=[],$=oe();if(or("labels"))for(let b of u.labels){if(b.hidden||!$.has(b.objectId)||Re()&&!sr(b.objectId,$))continue;let _=Re()?g?.projectObjectToContainer(b.objectId)??null:K({x:b.x,y:b.y});_&&L.push({key:`object:${b.renderId}`,kind:"object",point:Re()?{x:_.x,y:_.y-18}:_,textAnchor:b.textAnchor,objectId:b.objectId,primaryText:b.label,secondaryText:b.secondaryLabel,secondaryOffset:Math.max(b.secondaryY-b.y,12)})}if(!Re()&&or("events"))for(let b of u.events){if(b.hidden||!An(b,$))continue;let _=K({x:b.x,y:b.y-10});_&&L.push({key:`event:${b.renderId}`,kind:"event",point:_,textAnchor:"middle",primaryText:b.event.label||b.event.id})}return L}function An(L,$){return L.objectIds.some(b=>$.has(b))}function sr(L,$){if(!Re()||L===f.selectedObjectId||L===P)return!0;let b=ye(L);if(!b||b.hidden||!$.has(L))return!1;if(b.object.type==="star")return!0;let _=f.selectedObjectId?Te(f.selectedObjectId):null,M=P?Te(P):null,E=_?new Set([_.objectId,..._.renderObject.ancestorIds,..._.renderObject.childIds]):null,I=M?new Set([M.objectId,...M.renderObject.ancestorIds,...M.renderObject.childIds]):null;return E?.has(L)||I?.has(L)||b.semanticGroupIds.length>0&&b.visualRadius>=12?!0:b.childIds.length>0&&b.visualRadius>=10}function Fn(L){let $=document.createElement("div");if($.className=`wo-viewer-label wo-viewer-label-${L.kind}`,$.dataset.worldorbitScreenLabel="true",$.dataset.labelKey=L.key,$.dataset.anchor=L.textAnchor,$.style.left=`${L.point.x}px`,$.style.top=`${L.point.y}px`,L.objectId){$.dataset.objectId=L.objectId;for(let _ of Zr(L.objectId))$.classList.add(_)}let b=document.createElement("span");if(b.className="wo-viewer-label-primary",L.kind==="object"&&(b.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),b.textContent=L.primaryText,$.append(b),L.secondaryText){let _=document.createElement("span");_.className="wo-viewer-label-secondary",_.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,_.style.marginTop=`${Math.max(L.secondaryOffset??12,10)-10}px`,_.textContent=L.secondaryText,$.append(_)}return $}function or(L){return s.layers?.[L]!==!1}function Zr(L){let $=[],b=Te(f.selectedObjectId),_=Te(P);if(f.selectedObjectId===L&&$.push("wo-object-selected"),b){let M=new Set([b.objectId,...b.renderObject.childIds,...b.renderObject.ancestorIds]),E=new Set(b.ancestors.map(I=>I.objectId));M.has(L)&&$.push("wo-chain-selected"),E.has(L)&&$.push("wo-ancestor-selected")}if(_){let M=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]),E=new Set(_.ancestors.map(I=>I.objectId));M.has(L)&&$.push("wo-chain-hover"),E.has(L)&&$.push("wo-ancestor-hover")}return $}function ar(L){let $=h?.focusTargets.find(b=>b.objectId===L);return $?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-$.center.x,translateY:-$.center.z,selectedObjectId:L}:{...In,selectedObjectId:L}}}function H2(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function Ba(n,e){switch(n.kind){case"scene":return n.value;case"document":return Gt(n.value,e);case"source":{let t=ni(n.value);return Gt(t.document,Gv(t,e))}}}function Wr(n,e,t){if(t)return t;switch(n.kind){case"scene":return G2(n.value);case"document":return ts(n.value,e);case"source":{let i=ni(n.value);return ts(i.document,Gv(i,e))}}}function j2(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d",quality:n.quality??"balanced",style3d:n.style3d??"symbolic"}}function Fp(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?Bn(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d",quality:e.quality??n.quality??"balanced",style3d:e.style3d??n.style3d??"symbolic"}}function $v(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.bodyScaleMode!==void 0||n.activeEventId!==void 0}function Gv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function G2(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Hv(n,e,t){let{center:i,distance:r}=Wv(t);return{startState:{...e},startCenter:hr(n,e,i),startViewportCenter:i,startDistance:r}}function Wv(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function $u(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function W2(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function Xr(n,e,t){return Math.min(Math.max(n,e),t)}function jv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function za(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function X2(){if(typeof document>"u"||document.getElementById(Vv))return;let n=document.createElement("style");n.id=Vv,n.textContent=`
3944
+ ${r.length?`<p class="wo-tooltip-relations">${Jn(r.join(" - "))}</p>`:""}
3945
+ </article>`}function N2(n){let e=new Map;for(let i of U2){let r=n.object.properties[i];r!==void 0&&e.set(i,{key:i,label:V2(i),value:kv(r)})}let t=n.object.placement;return n.object.groups?.length&&e.set("groups",{key:"groups",label:"Groups",value:n.object.groups.join(", ")}),n.object.epoch&&e.set("epoch",{key:"epoch",label:"Epoch",value:n.object.epoch}),n.object.referencePlane&&e.set("referencePlane",{key:"referencePlane",label:"Reference Plane",value:n.object.referencePlane}),n.object.tidalLock!==void 0&&e.set("tidalLock",{key:"tidalLock",label:"Tidal Lock",value:n.object.tidalLock?"true":"false"}),n.object.resonance&&e.set("resonance",{key:"resonance",label:"Resonance",value:`${n.object.resonance.targetObjectId} ${n.object.resonance.ratio}`}),n.relatedEvents.length>0&&e.set("events",{key:"events",label:"Events",value:n.relatedEvents.map(i=>i.event.label||i.event.id).join(", ")}),t?.mode==="at"?e.set("placement",{key:"placement",label:"Placement",value:`At ${t.target}`}):t?.mode==="surface"?e.set("placement",{key:"placement",label:"Placement",value:`Surface ${t.target}`}):t?.mode==="free"&&e.set("placement",{key:"placement",label:"Placement",value:t.distance?`Free ${kv(t.distance)}`:`Free ${t.descriptor??"custom"}`}),[...e.values()]}function F2(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}function k2(n){let e=n.object.info.description?.trim();if(e)return e;let t=n.group?.label?.trim();return t&&t!==n.objectId?t:null}function kv(n){return typeof n=="string"?n:typeof n=="number"?String(n):typeof n=="boolean"?n?"true":"false":Array.isArray(n)?n.join(", "):B2(n)}function B2(n){return`${n.value}${n.unit??""}`}function z2(n){return n.charAt(0).toUpperCase()+n.slice(1)}function V2(n){return n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").replace(/^./,e=>e.toUpperCase())}function Jn(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function $2(n){return Jn(n)}var to={minScale:.2,maxScale:8,fitPadding:48,panStep:40,zoomStep:1.2,rotationStep:15},Vv="worldorbit-viewer-tooltip-style";function no(n,e){if(W2(n),+!!e.source+ +!!e.document+ +!!e.scene!==1)throw new Error('Interactive viewer requires exactly one of "source", "document", or "scene".');let i={minScale:e.minScale??to.minScale,maxScale:e.maxScale??to.maxScale,fitPadding:e.fitPadding??to.fitPadding},r={keyboard:e.keyboard??!0,pointer:e.pointer??!0,touch:e.touch??!0,selection:e.selection??!0,tooltipMode:e.tooltipMode??"hover",minimap:e.minimap??!1,panStep:e.panStep??to.panStep,zoomStep:e.zoomStep??to.zoomStep,rotationStep:e.rotationStep??to.rotationStep},s={width:e.width,height:e.height,padding:e.padding,preset:e.preset,projection:e.projection,bodyScaleMode:e.bodyScaleMode,viewMode:e.viewMode??"2d",quality:e.quality??"balanced",style3d:e.style3d??"symbolic",camera:e.camera?{...e.camera}:null,scaleModel:e.scaleModel?{...e.scaleModel}:void 0,theme:e.theme,layers:e.layers,filter:zn(e.initialFilter),subtitle:e.subtitle},o=n.getAttribute("tabindex"),a=n.style.touchAction,c=n.style.position,l=H2(e),u=Ba(l,s),d=e.spatialScene??null,h=s.viewMode==="3d"?Yr(l,s,d):null,f={..._n},p=null,y=null,g=null,m=null,x=null,v=null,w=!1,N=null,C=null,R=0,F=!1,A=new Map,S=null,P=null,k=null,O=null,H=null,W=null,J=null,ae=null,B={playing:!1,speed:1,timeSeconds:0,frozenByEvent:h?.timeFrozen??!1};o===null&&(n.tabIndex=0),X2(),n.classList.add("wo-viewer-container"),n.style.touchAction=r.touch?"none":a,n.style.position||(n.style.position="relative"),tt();let ne=L=>{if(!r.pointer||F)return;if(L.preventDefault(),n.focus(),Re()){let _=Zr(Math.exp(-L.deltaY*.002),.6,1.6);_e.zoomBy(_);return}let $=ee(L.clientX,L.clientY),b=Zr(Math.exp(-L.deltaY*.002),.6,1.6);Be(cs(u,f,b,$,i))},ce=L=>{if(F)return;let $=L.pointerType==="touch";if($&&!r.touch||!$&&!r.pointer||!$&&L.button!==0&&!Re())return;n.focus(),n.setPointerCapture?.(L.pointerId);let b=G(L.clientX,L.clientY);if($){A.set(L.pointerId,b),A.size===2?S=Hv(u,f,A):A.size===1&&(R=0,w=!1);return}N=L.pointerId,C=b,R=0,w=!1},Me=L=>{if(F)return;if(L.pointerType==="touch"){if(Re()||!r.touch||!A.has(L.pointerId))return;let E=A.get(L.pointerId),I=G(L.clientX,L.clientY);if(A.set(L.pointerId,I),A.size===2){S||(S=Hv(u,f,A));let j=Wv(A),Q=j.distance/Math.max(S.startDistance,1),ge=cs(u,S.startState,Q,S.startCenter,i),Se=j.center.x-S.startViewportCenter.x,Le=j.center.y-S.startViewportCenter.y;Be(fr(ge,Se,Le))}else if(A.size===1){let j=I.x-E.x,Q=I.y-E.y;R+=Math.abs(j)+Math.abs(Q),R>2&&(w=!0),Be(fr(f,j,Q))}return}if(Re()&&r.pointer&&N===null){he(g?.hitTest(L.clientX,L.clientY)??null);return}if(Re()&&r.pointer&&N===L.pointerId&&C){let E=G(L.clientX,L.clientY),I=E.x-C.x,j=E.y-C.y;R+=Math.abs(I)+Math.abs(j),C=E,R>2&&(w=!0),L.shiftKey||L.buttons===2?_e.panBy(I,j):(_e.rotateBy(I*.35),_e.panBy(0,j*.35)),he(g?.hitTest(L.clientX,L.clientY)??null);return}if(!r.pointer||N!==L.pointerId||!C)return;let b=G(L.clientX,L.clientY),_=b.x-C.x,M=b.y-C.y;R+=Math.abs(_)+Math.abs(M),C=b,R>2&&(w=!0),Be(fr(f,_,M))},fe=L=>{if(L.pointerType==="touch"){A.delete(L.pointerId),A.size<2&&(S=null);return}N===L.pointerId&&(N=null,C=null)},$e=L=>{if(!r.selection||F)return;if(w){w=!1;return}let $=Re()?g?.hitTest(L.clientX,L.clientY)??null:ju(L.target);Z($),r.tooltipMode==="pinned"&&(k=$,Fe())},Y=L=>{if(Re())return;let $=ju(L.target);he($)},me=()=>{he(null)},te=L=>{if(Re())return;let $=ju(L.target);$&&he($)},ue=()=>{he(null)},Pe=L=>{if(!r.keyboard||F)return;let $=Re()?f.selectedObjectId:ju(L.target);if((L.key==="Enter"||L.key===" ")&&$){L.preventDefault(),Z($),r.tooltipMode==="pinned"&&(k=$,Fe());return}switch(L.key){case"Escape":r.tooltipMode==="pinned"&&k&&(L.preventDefault(),k=null,Fe());return;case"+":case"=":L.preventDefault(),_e.zoomBy(r.zoomStep);return;case"-":L.preventDefault(),_e.zoomBy(1/r.zoomStep);return;case"ArrowLeft":L.preventDefault(),_e.panBy(-r.panStep,0);return;case"ArrowRight":L.preventDefault(),_e.panBy(r.panStep,0);return;case"ArrowUp":L.preventDefault(),_e.panBy(0,-r.panStep);return;case"ArrowDown":L.preventDefault(),_e.panBy(0,r.panStep);return;case"[":L.preventDefault(),_e.rotateBy(-r.rotationStep);return;case"]":L.preventDefault(),_e.rotateBy(r.rotationStep);return;case"f":case"F":L.preventDefault(),_e.fitToSystem();return;case"0":L.preventDefault(),_e.resetView();return}};n.addEventListener("wheel",ne,{passive:!1}),n.addEventListener("pointerdown",ce),n.addEventListener("pointermove",Me),n.addEventListener("pointerup",fe),n.addEventListener("pointercancel",fe),n.addEventListener("click",$e),n.addEventListener("mouseover",Y),n.addEventListener("mouseleave",me),n.addEventListener("focusin",te),n.addEventListener("focusout",ue),n.addEventListener("keydown",Pe);let _e={setSource(L){l={kind:"source",value:L},u=Ba(l,s),d=null,h=s.viewMode==="3d"?Yr(l,s,null):null,tt(),W=null,z(!0)},setDocument(L){l={kind:"document",value:L},u=Ba(l,s),d=null,h=s.viewMode==="3d"?Yr(l,s,null):null,tt(),W=null,z(!0)},setScene(L){l={kind:"scene",value:L},u=L,d=null,h=s.viewMode==="3d"?Yr(l,s,null):null,tt(),W=null,z(!0)},getScene(){return u},getRenderOptions(){return j2(s)},getViewMode(){return s.viewMode??"2d"},setViewMode(L){let $=s,b=h,_=Fp(s,{viewMode:L}),M=L==="3d"?Yr(l,_,d):null;s=_,h=M,tt();try{z(!1)}catch(E){throw s=$,h=b,tt(),z(!1),E}},listViewpoints(){return u.viewpoints.slice()},getActiveViewpoint(){return ve(W)},goToViewpoint(L){let $=ve(L);if(!$)return!1;let b={},_=Pd($);if($.preset!==null&&(b.preset=$.preset),l.kind!=="scene"&&$.projection!==u.projection&&(b.projection=$.projection),$.camera?b.camera={...$.camera}:s.camera&&(b.camera=null),_&&(b.layers=_),W=$.id,Object.keys(b).length>0){let E=$v(b);s=Fp(s,b),l.kind!=="scene"&&E&&(u=Ba(l,s)),z(E)}pe(Ld($),!1,!1);let M=xe($);return Be(M),Z($.selectedObjectId??$.objectId??null,!1),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),qe(),Ne(),!0},getActiveEventId(){return s.activeEventId??null},setActiveEvent(L){_e.setRenderOptions({activeEventId:L})},playAnimation(){if(!Re()){B={...B,playing:!1},vt();return}if(B.frozenByEvent){B={...B,playing:!1};return}B={...B,playing:!0},ft()},pauseAnimation(){B={...B,playing:!1},vt()},resetAnimation(){B={...B,playing:!1,timeSeconds:0},vt(),$t()},setAnimationSpeed(L){B={...B,speed:Zr(L,.1,64)}},getAnimationState(){return{...B}},search(L,$=12){return Id(u,L,$)},getFilter(){return s.filter?{...s.filter}:null},setFilter(L){pe(L,!0,!0)},getVisibleObjects(){return re()},getFocusPath(L){return Ue(L)},getObjectDetails(L){return Te(L)},getSelectionDetails(){return Te(f.selectedObjectId)},getTooltipDetails(){return H},getAtlasState(){return pg(f,s,s.filter??null,W)},setAtlasState(L){let $=typeof L=="string"?Rd(L):L;$.viewpointId&&_e.goToViewpoint($.viewpointId),_e.setRenderOptions($.renderOptions),pe($.filter??null,!1,!1),Be(X({...f,...$.viewerState})),Z($.viewerState.selectedObjectId??null,!1),qe(),e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),Ne()},serializeAtlasState(){return Cd(_e.getAtlasState())},captureBookmark(L,$){return mg(L,$,_e.getAtlasState())},applyBookmark(L){return typeof L=="string"?(_e.setAtlasState(L),!0):(_e.setAtlasState(L.atlasState),!0)},setRenderOptions(L){let $=$v(L),b=s,_=u,M=h,E=Fp(s,L),I=u;l.kind!=="scene"&&$&&(I=Ba(l,E));let j=E.viewMode==="3d"?Yr(l,E,d):null;s=E,u=I,h=j,tt();try{z($)}catch(Q){throw s=b,u=_,h=M,tt(),z($),Q}},getState(){return{...f}},setState(L){Be(X({...f,...L}))},zoomBy(L,$){Be(cs(u,f,L,$??{x:u.width/2,y:u.height/2},i))},panBy(L,$){Be(fr(f,L,$))},rotateBy(L){Be(Dd(f,L))},fitToSystem(){Be(Re()?{..._n,selectedObjectId:f.selectedObjectId}:pr(u,f,i))},focusObject(L){W=null,Be(Re()?ar(L):Od(u,f,L,i)),Z(L),r.tooltipMode==="pinned"&&(k=ye(L)?.objectId??null,Fe())},pinTooltip(L){k=ye(L)?.objectId??null,Fe()},resetView(){let L=Re()?{..._n}:pr(u,{..._n},i);W=null,Be(L),Z(null),k=null,Fe()},exportSvg(){return Cn(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId})},destroy(){F||(F=!0,n.removeEventListener("wheel",ne),n.removeEventListener("pointerdown",ce),n.removeEventListener("pointermove",Me),n.removeEventListener("pointerup",fe),n.removeEventListener("pointercancel",fe),n.removeEventListener("click",$e),n.removeEventListener("mouseover",Y),n.removeEventListener("mouseleave",me),n.removeEventListener("focusin",te),n.removeEventListener("focusout",ue),n.removeEventListener("keydown",Pe),vt(),g?.destroy(),g=null,x?.remove(),x=null,v?.remove(),v=null,m?.remove(),m=null,n.classList.remove("wo-viewer-container"),n.style.touchAction=a,n.style.position=c,o===null?n.removeAttribute("tabindex"):n.setAttribute("tabindex",o))}};return z(!0),e.initialViewpointId?_e.goToViewpoint(e.initialViewpointId):e.initialSelectionObjectId?_e.focusObject(e.initialSelectionObjectId):Ne(),_e;function z(L){if(g?.destroy(),g=null,n.innerHTML="",p=null,y=null,m=null,x=null,v=null,Re()?(h=h??Yr(l,s,d),g=Nv(n)):(n.innerHTML=Cn(u,{...s,filter:s.filter??null,selectedObjectId:f.selectedObjectId}),p=n.querySelector('[data-worldorbit-svg="true"]'),y=n.querySelector("#worldorbit-camera-root")),r.minimap&&(m=document.createElement("div"),m.dataset.worldorbitMinimapRoot="true",n.append(m)),x=document.createElement("div"),x.className="wo-viewer-label-root",x.dataset.worldorbitLabelRoot="true",n.append(x),r.tooltipMode!=="disabled"&&(v=document.createElement("div"),v.className="wo-viewer-tooltip-root",v.dataset.worldorbitTooltip="true",v.hidden=!0,v.addEventListener("click",we),n.append(v)),!Re()&&(!p||!y))throw new Error("Interactive viewer could not locate the rendered SVG camera root.");Kr(),f=L?Re()?{..._n}:pr(u,{..._n},i):X(f),Z(f.selectedObjectId&&ye(f.selectedObjectId)?f.selectedObjectId:null,!1),he(P&&ye(P)?P:null,!1),k=k&&ye(k)?k:null,$t(),Oe(),qe(),e.onViewChange?.({...f}),Ne()}function Be(L){f=X(L),$t(),e.onViewChange?.({...f}),Ne()}function X(L){return{scale:Zr(L.scale,i.minScale,i.maxScale),rotationDeg:jv(L.rotationDeg),translateX:Number.isFinite(L.translateX)?L.translateX:f.translateX,translateY:Number.isFinite(L.translateY)?L.translateY:f.translateY,selectedObjectId:L.selectedObjectId&&ye(L.selectedObjectId)?L.selectedObjectId:null}}function de(){if(Re()){Et();return}y&&(y.setAttribute("transform",Sc(u,f)),rr(),Ce(),Fe())}function Z(L,$=!0){if(!Re()&&f.selectedObjectId)for(let b of n.querySelectorAll(`[data-object-id="${za(f.selectedObjectId)}"]`))b.classList.remove("wo-object-selected");if(f={...f,selectedObjectId:L&&ye(L)?L:null},!Re()&&f.selectedObjectId)for(let b of n.querySelectorAll(`[data-object-id="${za(f.selectedObjectId)}"]`))b.classList.add("wo-object-selected");U(),Fe(),$&&(e.onSelectionChange?.(ie()),e.onSelectionDetailsChange?.(Te(f.selectedObjectId)),e.onViewChange?.({...f}),Ne())}function he(L,$=!0){P===L&&$||(P=L&&ye(L)?L:null,U(),Fe(),$&&(e.onHoverChange?.(ye(P)),e.onHoverDetailsChange?.(Te(P))))}function ie(){return ye(f.selectedObjectId)}function ye(L){if(!L)return null;let $=oe();return u.objects.find(b=>b.objectId===L&&!b.hidden&&$.has(b.objectId))??null}function Te(L){let $=ye(L);return $?{objectId:$.objectId,object:$.object,renderObject:$,label:u.labels.find(b=>b.objectId===$.objectId&&!b.hidden)??null,group:u.groups.find(b=>b.renderId===$.groupId)??null,semanticGroups:u.semanticGroups.filter(b=>$.semanticGroupIds.includes(b.id)),orbit:u.orbitVisuals.find(b=>b.objectId===$.objectId&&!b.hidden)??null,relatedOrbits:u.orbitVisuals.filter(b=>!b.hidden&&(b.objectId===$.objectId||$.ancestorIds.includes(b.objectId)||$.childIds.includes(b.objectId))),relations:u.relations.filter(b=>!b.hidden&&(b.fromObjectId===$.objectId||b.toObjectId===$.objectId)),relatedEvents:u.events.filter(b=>!b.hidden&&(b.targetObjectId===$.objectId||b.objectIds.includes($.objectId))),parent:ye($.parentId),children:$.childIds.map(b=>ye(b)).filter(Boolean),ancestors:$.ancestorIds.map(b=>ye(b)).filter(Boolean),focusPath:Ue($.objectId)}:null}function U(){if(Re()){Et();return}for(let L of n.querySelectorAll(".wo-chain-selected, .wo-chain-hover, .wo-ancestor-selected, .wo-ancestor-hover, .wo-orbit-related-selected, .wo-orbit-related-hover"))L.classList.remove("wo-chain-selected","wo-chain-hover","wo-ancestor-selected","wo-ancestor-hover","wo-orbit-related-selected","wo-orbit-related-hover");T(f.selectedObjectId,{objectClass:"wo-chain-selected",ancestorClass:"wo-ancestor-selected",orbitClass:"wo-orbit-related-selected"}),T(P,{objectClass:"wo-chain-hover",ancestorClass:"wo-ancestor-hover",orbitClass:"wo-orbit-related-hover"})}function T(L,$){let b=Te(L);if(!b)return;let _=new Set([b.objectId,...b.renderObject.childIds,...b.renderObject.ancestorIds]);for(let M of _)for(let E of n.querySelectorAll(`[data-object-id="${za(M)}"]`))E.classList.add($.objectClass);for(let M of b.ancestors)for(let E of n.querySelectorAll(`[data-object-id="${za(M.objectId)}"]`))E.classList.add($.ancestorClass);for(let M of b.relatedOrbits)for(let E of n.querySelectorAll(`[data-orbit-object-id="${za(M.objectId)}"]`))E.classList.add($.orbitClass)}function G(L,$){if(Re()){let _=n.getBoundingClientRect();return!_.width||!_.height?{x:u.width/2,y:u.height/2}:{x:L-_.left,y:$-_.top}}if(!p)return{x:u.width/2,y:u.height/2};let b=p.getBoundingClientRect();return!b.width||!b.height?{x:u.width/2,y:u.height/2}:{x:(L-b.left)/b.width*u.width,y:($-b.top)/b.height*u.height}}function ee(L,$){return mr(u,f,G(L,$))}function oe(){return wc(u,s.filter??null)}function re(){let L=oe();return u.objects.filter($=>!$.hidden&&L.has($.objectId))}function Ue(L){let $=u.objects.find(b=>b.objectId===L&&!b.hidden);return $?[...$.ancestorIds,$.objectId].map(b=>ye(b)).filter(Boolean):[]}function ve(L){return u.viewpoints.find($=>$.id===L)??null}function xe(L){let $=jv(L.rotationDeg),b=L.scale!==null&&L.scale!==void 0?Zr(L.scale,i.minScale,i.maxScale):null;if(Re()){let E=L.objectId??L.selectedObjectId??null,I=E?h?.focusTargets.find(j=>j.objectId===E):null;return{scale:b??1.6,rotationDeg:$,translateX:I?-I.center.x:0,translateY:I?-I.center.z:0,selectedObjectId:L.selectedObjectId??L.objectId??null}}let _=L.objectId&&u.objects.find(E=>E.objectId===L.objectId&&!E.hidden);if(_)return He({x:_.x,y:_.y},b??Math.max(1.8,_n.scale),$,L.selectedObjectId??_.objectId);let M=pr(u,{..._n,rotationDeg:$},i);return b===null?{...M,rotationDeg:$,selectedObjectId:L.selectedObjectId??null}:He({x:u.contentBounds.centerX,y:u.contentBounds.centerY},b,$,L.selectedObjectId??null)}function He(L,$,b,_){let M={x:u.width/2,y:u.height/2},E=rn(L,M,b);return{scale:$,rotationDeg:b,translateX:M.x-(M.x+(E.x-M.x)*$),translateY:M.y-(M.y+(E.y-M.y)*$),selectedObjectId:_}}function pe(L,$,b){s={...s,filter:zn(L)},b&&(W=null),z(!1)}function Oe(){e.onFilterChange?.(s.filter??null,re())}function qe(){e.onViewpointChange?.(ve(W))}function Ne(){e.onAtlasStateChange?.(_e.getAtlasState())}function Ce(){!r.minimap||!m||(m.innerHTML=Sg(u,f,re()))}function Fe(){if(r.tooltipMode==="disabled"||!v){Ae(null);return}let L=Qe();if(!L){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let $=Te(L.objectId);if(!$){v.hidden=!0,v.innerHTML="",v.removeAttribute("data-mode"),Ae(null);return}let b=Bv($);O=L.objectId,v.hidden=!1,v.dataset.mode=L.mode,v.classList.toggle("is-pinned",L.mode==="pinned"),v.style.pointerEvents="auto",v.style.visibility="hidden",pt(v,b,L.mode),je(v,$.renderObject),v.style.visibility="visible",Ae(b)}function Qe(){return k&&ye(k)?{objectId:k,mode:"pinned"}:P&&ye(P)?{objectId:P,mode:"hover"}:null}function pt(L,$,b){let _=e.tooltipRenderer?.($,b);L.innerHTML="",typeof _=="string"?L.innerHTML=_:_ instanceof HTMLElement?L.append(_):L.innerHTML=zv($,b);let M=document.createElement("div");if(M.className="wo-tooltip-actions",b==="pinned"){let E=document.createElement("button");E.type="button",E.className="wo-tooltip-action",E.dataset.tooltipAction="unpin",E.textContent="Unpin",M.append(E)}else{let E=document.createElement("button");E.type="button",E.className="wo-tooltip-action",E.dataset.tooltipAction="pin",E.dataset.objectId=$.objectId,E.textContent="Pin",M.append(E)}M.childElementCount>0&&L.append(M)}function je(L,$){let b=Re()?g?.projectObjectToContainer($.objectId)??null:le($);if(!b)return;let _=Math.max(n.clientWidth-L.offsetWidth-12,12),M=Math.max(n.clientHeight-L.offsetHeight-12,12),E=b.y>n.clientHeight*.48,I=Zr(b.x+18,12,_),j=Zr(E?b.y-L.offsetHeight-18:b.y+18,12,M);L.style.left=`${I}px`,L.style.top=`${j}px`}function V(L){if(Re())return L;let $={x:u.width/2,y:u.height/2},b=rn(L,$,f.rotationDeg);return{x:$.x+(b.x-$.x)*f.scale+f.translateX,y:$.y+(b.y-$.y)*f.scale+f.translateY}}function le(L){let $={x:L.anchorX??L.x,y:L.anchorY??L.y-Math.max(L.visualRadius,L.radius)};return K($)}function K(L){if(!p)return null;let $=V(L),b=p.getBoundingClientRect(),_=n.getBoundingClientRect();return{x:b.left-_.left+$.x/Math.max(u.width,1)*b.width,y:b.top-_.top+$.y/Math.max(u.height,1)*b.height}}function we(L){let $=L.target?.closest("[data-tooltip-action]");if($){switch(L.preventDefault(),L.stopPropagation(),$.dataset.tooltipAction){case"pin":k=$.dataset.objectId??O;break;case"unpin":k=null;break}Fe()}}function Ae(L){let $=H?.objectId!==L?.objectId||H?.description!==L?.description||H?.imageHref!==L?.imageHref;H=L,O=L?.objectId??null,$&&e.onTooltipChange?.(L)}function Re(){return s.viewMode==="3d"}function tt(){B={...B,frozenByEvent:h?.timeFrozen??!1},B.frozenByEvent&&(B={...B,playing:!1},vt())}function ft(){J!==null||!B.playing||F||(J=window.requestAnimationFrame(rt))}function vt(){J!==null&&(window.cancelAnimationFrame(J),J=null),ae=null}function rt(L){if(J=null,!B.playing||F){ae=null;return}let b=Math.max((L-(ae??L))/1e3,0);ae=L,B={...B,timeSeconds:B.timeSeconds+b*B.speed},Et(),ft()}function $t(){de(),Re()&&B.playing?ft():(!B.playing||!Re())&&vt()}function Et(){!Re()||!g||!h||(g.update({spatialScene:h,renderOptions:s,visibleObjectIds:oe(),selectedObjectId:f.selectedObjectId,hoveredObjectId:P,state:f,timeSeconds:B.timeSeconds}),rr(),Ce(),Fe())}function Kr(){if(!Re()){n.querySelector('[data-layer-id="labels"]')?.setAttribute("display","none");for(let L of n.querySelectorAll(".wo-event-label"))L.setAttribute("display","none")}}function rr(){if(!x)return;let L=Fn();x.replaceChildren(...L.map($=>kn($))),x.hidden=L.length===0}function Fn(){let L=[],$=oe();if(or("labels"))for(let b of u.labels){if(b.hidden||!$.has(b.objectId)||Re()&&!sr(b.objectId,$))continue;let _=Re()?g?.projectObjectToContainer(b.objectId)??null:K({x:b.x,y:b.y});_&&L.push({key:`object:${b.renderId}`,kind:"object",point:Re()?{x:_.x,y:_.y-18}:_,textAnchor:b.textAnchor,objectId:b.objectId,primaryText:b.label,secondaryText:b.secondaryLabel,secondaryOffset:Math.max(b.secondaryY-b.y,12)})}if(!Re()&&or("events"))for(let b of u.events){if(b.hidden||!Tn(b,$))continue;let _=K({x:b.x,y:b.y-10});_&&L.push({key:`event:${b.renderId}`,kind:"event",point:_,textAnchor:"middle",primaryText:b.event.label||b.event.id})}return L}function Tn(L,$){return L.objectIds.some(b=>$.has(b))}function sr(L,$){if(!Re()||L===f.selectedObjectId||L===P)return!0;let b=ye(L);if(!b||b.hidden||!$.has(L))return!1;if(b.object.type==="star")return!0;let _=f.selectedObjectId?Te(f.selectedObjectId):null,M=P?Te(P):null,E=_?new Set([_.objectId,..._.renderObject.ancestorIds,..._.renderObject.childIds]):null,I=M?new Set([M.objectId,...M.renderObject.ancestorIds,...M.renderObject.childIds]):null;return E?.has(L)||I?.has(L)||b.semanticGroupIds.length>0&&b.visualRadius>=12?!0:b.childIds.length>0&&b.visualRadius>=10}function kn(L){let $=document.createElement("div");if($.className=`wo-viewer-label wo-viewer-label-${L.kind}`,$.dataset.worldorbitScreenLabel="true",$.dataset.labelKey=L.key,$.dataset.anchor=L.textAnchor,$.style.left=`${L.point.x}px`,$.style.top=`${L.point.y}px`,L.objectId){$.dataset.objectId=L.objectId;for(let _ of Qr(L.objectId))$.classList.add(_)}let b=document.createElement("span");if(b.className="wo-viewer-label-primary",L.kind==="object"&&(b.style.fontSize=`${14*u.scaleModel.labelMultiplier}px`),b.textContent=L.primaryText,$.append(b),L.secondaryText){let _=document.createElement("span");_.className="wo-viewer-label-secondary",_.style.fontSize=`${11*u.scaleModel.labelMultiplier}px`,_.style.marginTop=`${Math.max(L.secondaryOffset??12,10)-10}px`,_.textContent=L.secondaryText,$.append(_)}return $}function or(L){return s.layers?.[L]!==!1}function Qr(L){let $=[],b=Te(f.selectedObjectId),_=Te(P);if(f.selectedObjectId===L&&$.push("wo-object-selected"),b){let M=new Set([b.objectId,...b.renderObject.childIds,...b.renderObject.ancestorIds]),E=new Set(b.ancestors.map(I=>I.objectId));M.has(L)&&$.push("wo-chain-selected"),E.has(L)&&$.push("wo-ancestor-selected")}if(_){let M=new Set([_.objectId,..._.renderObject.childIds,..._.renderObject.ancestorIds]),E=new Set(_.ancestors.map(I=>I.objectId));M.has(L)&&$.push("wo-chain-hover"),E.has(L)&&$.push("wo-ancestor-hover")}return $}function ar(L){let $=h?.focusTargets.find(b=>b.objectId===L);return $?{scale:1.8,rotationDeg:f.rotationDeg,translateX:-$.center.x,translateY:-$.center.z,selectedObjectId:L}:{..._n,selectedObjectId:L}}}function H2(n){if(n.scene)return{kind:"scene",value:n.scene};if(n.document)return{kind:"document",value:n.document};if(n.source)return{kind:"source",value:n.source};throw new Error("Interactive viewer requires an initial render input.")}function Ba(n,e){switch(n.kind){case"scene":return n.value;case"document":return Gt(n.value,e);case"source":{let t=ii(n.value);return Gt(t.document,Gv(t,e))}}}function Yr(n,e,t){if(t)return t;switch(n.kind){case"scene":return G2(n.value);case"document":return rs(n.value,e);case"source":{let i=ii(n.value);return rs(i.document,Gv(i,e))}}}function j2(n){return{...n,camera:n.camera?{...n.camera}:null,filter:n.filter?{...n.filter}:void 0,scaleModel:n.scaleModel?{...n.scaleModel}:void 0,layers:n.layers?{...n.layers}:void 0,theme:n.theme&&typeof n.theme=="object"?{...n.theme}:n.theme,activeEventId:n.activeEventId??null,viewMode:n.viewMode??"2d",quality:n.quality??"balanced",style3d:n.style3d??"symbolic"}}function Fp(n,e){return{...n,...e,camera:e.camera!==void 0?e.camera?{...e.camera}:null:n.camera?{...n.camera}:null,filter:e.filter!==void 0?zn(e.filter):n.filter?{...n.filter}:void 0,scaleModel:e.scaleModel?{...n.scaleModel??{},...e.scaleModel}:n.scaleModel?{...n.scaleModel}:void 0,layers:e.layers?{...n.layers??{},...e.layers}:n.layers?{...n.layers}:void 0,theme:e.theme&&typeof e.theme=="object"?{...e.theme}:e.theme??n.theme,viewMode:e.viewMode??n.viewMode??"2d",quality:e.quality??n.quality??"balanced",style3d:e.style3d??n.style3d??"symbolic"}}function $v(n){return n.width!==void 0||n.height!==void 0||n.padding!==void 0||n.preset!==void 0||n.projection!==void 0||n.camera!==void 0||n.scaleModel!==void 0||n.bodyScaleMode!==void 0||n.activeEventId!==void 0}function Gv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}function G2(n){return{width:n.width,height:n.height,padding:n.padding,renderPreset:n.renderPreset,projection:n.projection,camera:n.camera,scaleModel:{orbitDistanceMultiplier:1,bodyRadiusMultiplier:1,markerSizeMultiplier:1,ringThicknessMultiplier:1,focusPadding:12,minBodyRadius:4,maxBodyRadius:40},title:n.title,subtitle:n.subtitle,systemId:n.systemId,viewMode:"3d",layoutPreset:n.layoutPreset,metadata:{...n.metadata,"viewer.mode":"3d-fallback"},contentBounds:{minX:n.contentBounds.minX-n.contentBounds.centerX,minY:-40,minZ:n.contentBounds.minY-n.contentBounds.centerY,maxX:n.contentBounds.maxX-n.contentBounds.centerX,maxY:40,maxZ:n.contentBounds.maxY-n.contentBounds.centerY,width:n.contentBounds.width,height:80,depth:n.contentBounds.height,center:{x:0,y:0,z:0}},semanticGroups:n.semanticGroups,viewpoints:n.viewpoints,activeEventId:n.activeEventId,timeFrozen:n.activeEventId!==null,objects:n.objects.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,ancestorIds:e.ancestorIds.slice(),childIds:e.childIds.slice(),groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),position:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.radius,visualRadius:e.visualRadius,label:e.label,secondaryLabel:e.secondaryLabel,fillColor:e.fillColor,imageHref:e.imageHref,hidden:e.hidden,motion:null})),orbits:n.orbitVisuals.map(e=>({objectId:e.objectId,object:e.object,parentId:e.parentId,groupId:e.groupId,semanticGroupIds:e.semanticGroupIds.slice(),center:{x:0,y:0,z:0},kind:e.kind,radius:e.radius,semiMajor:e.radius??e.rx??0,semiMinor:e.radius??e.ry??0,rotationDeg:e.rotationDeg,inclinationDeg:0,band:e.band,bandThickness:e.bandThickness,hidden:e.hidden,motion:null})),focusTargets:n.objects.map(e=>({objectId:e.objectId,center:{x:e.x-n.contentBounds.centerX,y:0,z:e.y-n.contentBounds.centerY},radius:e.visualRadius+12}))}}function Hv(n,e,t){let{center:i,distance:r}=Wv(t);return{startState:{...e},startCenter:mr(n,e,i),startViewportCenter:i,startDistance:r}}function Wv(n){let e=[...n.values()];if(e.length<2)return{center:e[0]??{x:0,y:0},distance:1};let[t,i]=e;return{center:{x:(t.x+i.x)/2,y:(t.y+i.y)/2},distance:Math.hypot(i.x-t.x,i.y-t.y)}}function ju(n){return n instanceof Element?n.closest("[data-object-id]")?.dataset.objectId??null:null}function W2(n){if(typeof window>"u"||typeof document>"u")throw new Error("createInteractiveViewer can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("Interactive viewer requires an HTMLElement container.")}function Zr(n,e,t){return Math.min(Math.max(n,e),t)}function jv(n){let e=n%360;return e>180&&(e-=360),e<=-180&&(e+=360),e}function za(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/["\\]/g,"\\$&")}function X2(){if(typeof document>"u"||document.getElementById(Vv))return;let n=document.createElement("style");n.id=Vv,n.textContent=`
3946
3946
  .wo-viewer-3d-root {
3947
3947
  position: relative;
3948
3948
  min-height: 320px;
@@ -4090,7 +4090,7 @@ void main() {
4090
4090
  padding: 6px 12px;
4091
4091
  font: 600 12px/1.3 "Segoe UI Variable", "Segoe UI", sans-serif;
4092
4092
  }
4093
- `,document.head.append(n)}function Xv(n){return encodeURIComponent(JSON.stringify(n))}function Bp(n,e,t={}){return{version:"2.0",mode:kp(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??qv(kp(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function zp(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??qv(kp(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=ri(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${Hu(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${Hu(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${Hu(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${Hu(Xv(t))}">${i}</div>`}function Hu(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kp(n){return!n||n==="interactive"?"interactive-2d":n}function qv(n){return n==="interactive-3d"?"3d":"2d"}function Va(n,e={}){try{let t=ni(n),i=Gt(t.document,Yv(t,e)),r=e.mode??"static";if(r==="interactive"||r==="interactive-2d"||r==="interactive-3d"){let s=r==="interactive"?"interactive-2d":r;return zp(Bp(i,s,{spatialScene:s==="interactive-3d"?ts(t.document,Yv(t,e)):void 0,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap}),{className:e.className??"worldorbit-block worldorbit-interactive",theme:e.theme,layers:e.layers,subtitle:e.subtitle,preset:e.preset,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap})}return`<figure class="${Y2(e.className??"worldorbit-block worldorbit-static")}">${ri(i,e)}</figure>`}catch(t){if(e.strict)throw t;return Zv(t instanceof Error?t.message:String(t))}}function Zv(n){return`<pre class="worldorbit-error">WorldOrbit error: ${Jv(n)}</pre>`}function Jv(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Y2(n){return Jv(n).replaceAll('"',"&quot;")}function Yv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}var Kv="worldorbit-editor-style",Z2=120,J2=16,K2=96,io=1495978707e-1,rx=6371,sx=695700,$p=new Set(["placement","target","reference","distance","semiMajor","eccentricity","period","angle","inclination","phase","descriptor"]),Q2=new Set(["star","planet","moon","asteroid","comet"]),Gp=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],eC=["kind","class","culture","color","image","atmosphere","on","source"],tC=["radius","mass","density","gravity","temperature","inner","outer","cycle"],nC=["albedo"],iC={"defaults-view":{description:"Sets the default camera projection for the atlas.",references:["Topdown = map-like","Isometric = angled overview","Orthographic/Perspective = 3D-ready semantic views"]},"defaults-scale":{description:"Chooses the overall spacing/style preset used by the renderer.",references:["diagram = tighter","presentation = roomier"]},"defaults-units":{description:"Stores a document-wide note about the unit style you want to use.",references:["Example: metric","Example: lore-standard"]},"viewpoint-projection":{description:"Overrides the projection for this saved viewpoint.",references:["Topdown = flat orbital map","Isometric = angled scene","Orthographic/Perspective = stored with current 2D fallback"]},"viewpoint-zoom":{description:"Controls how closely this viewpoint frames the system.",references:["1 = scene fit","2+ = close-up"]},"viewpoint-rotation":{description:"Legacy 2D screen rotation. This is separate from the Schema 2.5 camera block.",references:["90deg = quarter turn","Use camera.azimuth for semantic view direction"]},"viewpoint-camera-azimuth":{description:"Horizontal camera direction in degrees for Schema 2.5 viewpoints.",references:["0 = forward/default","90 = quarter orbit around the scene"]},"viewpoint-camera-elevation":{description:"Vertical camera tilt in degrees for 3D-ready viewpoints.",references:["0 = level","30 = gentle look down"]},"viewpoint-camera-roll":{description:"Rolls the camera around its forward axis.",references:["0 = upright","15 = slight bank"]},"viewpoint-camera-distance":{description:"Semantic camera distance for perspective viewpoints.",references:["4 = close","12 = wide framing"]},"viewpoint-events":{description:"Lists event IDs that this viewpoint should feature in its detail panel.",references:["solar-eclipse-naar","transit-window conjunction"]},"event-kind":{description:"Short semantic event type for tooling and viewer overlays.",references:["solar-eclipse","lunar-eclipse","transit"]},"event-target":{description:"Primary object this event is centered on.",references:["Naar","Seyra"]},"event-participants":{description:"Objects that participate in the event snapshot or description.",references:["Iyath Naar Seyra","Naar Seyra Orun"]},"event-timing":{description:"Free-text timing note for the event.",references:['"Every late bloom season"','"At local midyear"']},"event-visibility":{description:"Notes where or how the event is visible.",references:['"Visible from Naar"','"Southern hemisphere only"']},"event-epoch":{description:"Optional event-wide epoch that event poses inherit unless they override it.",references:['"JY-0001.0"','"Naar bloom cycle year 18"']},"event-referencePlane":{description:"Optional event-wide reference plane for all poses in this snapshot.",references:["ecliptic","naar-equatorial"]},"event-viewpoints":{description:"Viewpoint IDs that should list this event prominently.",references:["naar-system","overview inner-system"]},"placement-target":{description:"Names the body or reference this object is attached to.",references:["orbit Primary","surface Homeworld","at Naar:L4"]},"placement-free":{description:"Stores a free-placement offset or a descriptive label for loose placement.",references:["8au = far from the star",'"outer system" = descriptive note']},"placement-distance":{description:"Mean orbit distance from the target body.",references:["1 au = Earth-Sun distance","384400km = Earth-Moon distance"]},"placement-semiMajor":{description:"Semi-major axis of an orbit, used for elliptical orbits.",references:["1 au = Earth-Sun distance","Use this instead of distance when orbit shape matters"]},"placement-eccentricity":{description:"Controls how stretched the orbit is. Lower is rounder.",references:["0 = circular orbit","0.1 = mildly elliptical"]},"placement-period":{description:"How long one orbit takes.",references:["1 y = one Earth year","27.3d = Moon around Earth"]},"placement-angle":{description:"Rotates the orbit ellipse within the scene.",references:["0deg = default orientation","90deg = quarter turn"]},"placement-inclination":{description:"Tilts the orbit relative to the main orbital plane.",references:["0deg = same plane","5deg = slight tilt"]},"placement-phase":{description:"Starting position of the object along its orbit.",references:["0deg = start position","180deg = opposite side"]},"pose-epoch":{description:"Overrides the effective epoch for this pose only.",references:['"JY-0001.0"',"Falls back to event, object, then system"]},"pose-referencePlane":{description:"Overrides the effective reference plane for this pose only.",references:["naar-equatorial","Falls back to event, object, then system"]},"prop-radius":{description:"Visual body size or real-world-inspired radius value.",references:["1re = Earth radius","1sol = Sun radius"]},"prop-mass":{description:"Optional mass value for the body.",references:["1me = Earth mass","1sol = Sun mass"]},"prop-gravity":{description:"Surface gravity or a custom gravity marker.",references:["1g = Earth-like gravity","0.16g = Moon-like gravity"]},"prop-temperature":{description:"Typical temperature or narrative temperature marker.",references:["288K = Earth-like average","1200K = very hot world"]},"prop-atmosphere":{description:"Short atmosphere descriptor for the object.",references:['"nitrogen-oxygen"','"methane haze"']},"prop-inner":{description:"Inner edge for a belt, ring, or broad phenomenon.",references:["120000km = ring inner edge","2au = belt starts here"]},"prop-outer":{description:"Outer edge for a belt, ring, or broad phenomenon.",references:["190000km = ring outer edge","3au = belt ends here"]}};function ox(n,e={}){tR(n),nR();let t=rC(e),i=t.atlasDocument,r=t.source,s=r,o=r,a=t.diagnostics,c=i.objects[0]?{kind:"object",id:i.objects[0].id}:{kind:"system"},l=[],u=[],d=null,h=!1,f=!1,p=!1,y=null,g=null,m="",x="",v=new Map,w=e.showTextPane??!0,N=e.showInspector??!0,C=e.showPreview??!0,R=e.shortcuts??!0,F=e.viewMode??"2d";n.classList.add("wo-editor"),n.dataset.woShowInspector=String(N),n.dataset.woShowTextPane=String(w),n.dataset.woShowPreview=String(C),n.innerHTML=sC();let A=yn(n,"[data-editor-toolbar]"),S=yn(n,"[data-editor-outline]"),P=yn(n,"[data-editor-stage-shell]"),k=yn(n,"[data-editor-stage]"),O=yn(n,"[data-editor-overlay]"),H=yn(n,"[data-editor-diagnostics]"),W=yn(n,"[data-editor-source-diagnostics]"),J=yn(n,"[data-editor-status]"),ae=yn(n,"[data-editor-live]"),B=yn(n,"[data-editor-inspector]"),ne=yn(n,"[data-editor-source]"),ce=yn(n,"[data-editor-preview-visual]"),Me=yn(n,"[data-editor-preview-markup]"),fe=null;fe=to(k,{source:r,width:e.viewerWidth??1120,height:e.viewerHeight??680,preset:i.system?.defaults.preset??"atlas-card",projection:"document",viewMode:F,minimap:!0,tooltipMode:"hover",onSelectionChange(_){let M=c?Vp(c):null;if(h||!_){h||(c?.kind==="event-pose"&&c.id?ie({kind:"event",id:c.id},!1,!0):c?.kind==="object"?ie(M?{kind:"event",id:M}:null,!1,!0):c?.kind==="event"&&c.id&&ie({kind:"event",id:c.id},!1,!0));return}if(M&&ux(i,M,_.objectId)){ie({kind:"event-pose",id:M,key:_.objectId},!1,!0);return}ie({kind:"object",id:_.objectId},!1,!0)},onViewChange(){ve()}}),A.addEventListener("click",Oe),S.addEventListener("click",qe),O.addEventListener("pointerdown",le),B?.addEventListener("click",Ne),B?.addEventListener("input",Ce),B?.addEventListener("change",Fe),ne?.addEventListener("input",pt),ne?.addEventListener("change",je),ne?.addEventListener("blur",je),n.addEventListener("keydown",V),window.addEventListener("pointermove",K),window.addEventListener("pointerup",we),window.addEventListener("pointercancel",we);let $e={setSource(_){de(_,!1)&&(me(),U())},setAtlasDocument(_){X(_,!1,c,!1),me(),U()},getSource(){return r},getAtlasDocument(){return st(i)},getDiagnostics(){return a.map(Wu)},getSelection(){return c?{path:{...c}}:null},getViewMode(){return F},setViewMode(_){let M=F;try{fe.setViewMode(_),F=_,ve(),Fn()}catch(E){throw F=M,E}},isDirty(){return p},markSaved(){z(!0)},selectPath(_){ie(_,!0,!0)},canUndo(){return l.length>0},canRedo(){return u.length>0},undo(){let _=l.pop();return _?(u.unshift(Y()),Be(_),!0):!1},redo(){let _=u.shift();return _?(l.push(Y()),Be(_),!0):!1},addObject(_="planet"){let M=ja(_,i.objects.map(j=>j.id)),E=SC(_,M,i),I=EC(i,E);return X(I,!0,{kind:"object",id:M}),M},addEvent(){let _=ja("event",i.events.map(I=>I.id)),M={id:_,kind:"",label:Ga(_),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},E=st(i);return E.events.push(M),E.events.sort(nx),X(E,!0,{kind:"event",id:_}),_},addViewpoint(){let _=ja("viewpoint",i.system?.viewpoints.map(I=>I.id)??[]),M={id:_,label:Ga(_),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:i.system?.defaults.view??"topdown",preset:i.system?.defaults.preset??null,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null},E=st(i);return E.system?.viewpoints.push(M),E.system?.viewpoints.sort((I,j)=>I.id.localeCompare(j.id)),X(E,!0,{kind:"viewpoint",id:_}),_},addAnnotation(){let _=ja("annotation",i.system?.annotations.map(I=>I.id)??[]),M={id:_,label:Ga(_),targetObjectId:null,body:"",tags:[],sourceObjectId:null},E=st(i);return E.system?.annotations.push(M),E.system?.annotations.sort((I,j)=>I.id.localeCompare(j.id)),X(E,!0,{kind:"annotation",id:_}),_},addMetadata(_,M){let E=_?.trim()||ja("metadata",Object.keys(i.system?.atlasMetadata??{})),I=st(i);return I.system&&(I.system.atlasMetadata[E]=M??""),X(I,!0,{kind:"metadata",key:E}),E},removeSelection(){if(!c||c.kind==="system"||c.kind==="defaults")return!1;let _=IC(i,c);return X(_,!0,{kind:"system"}),!0},exportSvg(){return fe.exportSvg()},exportEmbedMarkup(){return tx(Pe(),i,F)},destroy(){f||(f=!0,A.removeEventListener("click",Oe),S.removeEventListener("click",qe),O.removeEventListener("pointerdown",le),B?.removeEventListener("click",Ne),B?.removeEventListener("input",Ce),B?.removeEventListener("change",Fe),ne?.removeEventListener("input",pt),ne?.removeEventListener("change",je),ne?.removeEventListener("blur",je),n.removeEventListener("keydown",V),window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",we),window.removeEventListener("pointercancel",we),te(),ue(),fe.destroy(),n.innerHTML="",n.classList.remove("wo-editor"))}};return Te(!0),_e(!0),$e;function Y(){return{atlasDocument:st(i),selection:c?{...c}:null,source:r}}function me(){l.length=0,u.length=0,U()}function te(){y!==null&&(window.clearTimeout(y),y=null)}function ue(){g!==null&&(window.clearTimeout(g),g=null)}function Pe(){return d?.changed?tr(i):r}function _e(_=!1){let M=s!==o||r!==o||d?.changed===!0;!_&&M===p||(p=M,Nn(),e.onDirtyChange?.(p))}function z(_=!1){s=r,re(),o=r,_e(_)}function Be(_){te(),i=st(_.atlasDocument),r=_.source,s=r,a=nr(i),c=ye(_.selection),Z({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Te(),_e(),he()}function X(_,M,E,I=!1){M&&(l.push(Y()),u.length=0),te(),i=st(_),r=tr(i),I||(s=r),a=nr(i),c=ye(E),Z({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Te(),_e(),he()}function de(_,M){s=_,ne&&ne.value!==_&&(ne.value=_);let E=So(_);if(!E.ok||!E.value)return a=E.diagnostics.map(Q=>({diagnostic:Q,path:null})),G(),ee(),T(),oe(),Nn(),An(),_e(),e.onDiagnosticsChange?.(a.map(Wu)),!1;let I=E.value.atlasDocument??ur(E.value.document),j=Mo(I,E.diagnostics);return M&&(l.push(Y()),u.length=0,s=tr(I)),i=st(I),r=tr(i),a=cx(j,nr(i)),c=ye(c),Z({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),Te(),_e(),he(),!0}function Z(_={}){if(!fe)return;let M=fe.getState(),E=fe.getRenderOptions(),I=i.system?.defaults.preset??"atlas-card",j=c?Vp(c):null;h=!0,(E.preset!==I||E.projection!=="document"||(E.activeEventId??null)!==j)&&fe.setRenderOptions({preset:I,projection:"document",activeEventId:j}),fe.setDocument(ns(i)),_.applyViewpointSelection&&c?.kind==="viewpoint"&&c.id?fe.goToViewpoint(c.id):_.preserveCamera!==!1?fe.setState({...M,selectedObjectId:c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null}):c?.kind==="object"&&c.id?fe.focusObject(c.id):c?.kind==="event-pose"&&c.key&&fe.focusObject(c.key),h=!1}function he(){let _={source:r,atlasDocument:st(i),diagnostics:a.map(Wu),selection:c?{path:{...c}}:null};e.onDiagnosticsChange?.(_.diagnostics),e.onSelectionChange?.(_.selection),e.onChange?.(_)}function ie(_,M,E=!0){c=ye(_),M&&(h=!0,fe.setRenderOptions({activeEventId:c?Vp(c):null}),c?.kind==="object"&&c.id?fe.focusObject(c.id):c?.kind==="event-pose"&&c.key?fe.focusObject(c.key):c?.kind==="viewpoint"&&c.id&&fe.goToViewpoint(c.id),h=!1),U(),T(),B?.contains(document.activeElement)||oe(),ve(),Nn(),An(),E&&e.onSelectionChange?.(c?{path:{...c}}:null)}function ye(_){if(!_)return null;let M=_d(i,_);return M==null?_.kind==="system"||_.kind==="defaults"?_:null:_}function Te(_=!1){U(),T(),G(),ee(),B?.contains(document.activeElement)||oe(),re(),Ue(_),ve(),Nn(),An()}function U(){let _=A.querySelector("[data-editor-add-object-type]")?.value??"planet";A.innerHTML=`
4093
+ `,document.head.append(n)}function Xv(n){return encodeURIComponent(JSON.stringify(n))}function Bp(n,e,t={}){return{version:"2.0",mode:kp(e),scene:n,spatialScene:t.spatialScene,options:{viewMode:t.viewMode??qv(kp(e)),initialViewpointId:t.initialViewpointId,initialSelectionObjectId:t.initialSelectionObjectId,initialFilter:t.initialFilter??null,atlasState:t.atlasState??null,minimap:t.minimap}}}function zp(n,e={}){let t={...n,options:{...n.options,theme:e.theme??n.options?.theme,layers:e.layers??n.options?.layers,subtitle:e.subtitle??n.options?.subtitle,preset:e.preset??n.options?.preset,viewMode:e.viewMode??n.options?.viewMode??qv(kp(n.mode)),initialViewpointId:e.initialViewpointId??n.options?.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId??n.options?.initialSelectionObjectId,initialFilter:e.initialFilter??n.options?.initialFilter??null,atlasState:e.atlasState??n.options?.atlasState??null,minimap:e.minimap??n.options?.minimap}},i=Cn(n.scene,{theme:t.options?.theme,layers:t.options?.layers,filter:t.options?.initialFilter??null,selectedObjectId:t.options?.initialSelectionObjectId??null,subtitle:t.options?.subtitle,preset:t.options?.preset});return`<div class="${Gu(e.className??"worldorbit-embed")}" data-worldorbit-embed="true" data-worldorbit-mode="${t.mode}" data-worldorbit-preset="${Gu(t.options?.preset??n.scene.renderPreset??"custom")}" data-worldorbit-viewpoint="${Gu(t.options?.initialViewpointId??"")}" data-worldorbit-payload="${Gu(Xv(t))}">${i}</div>`}function Gu(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function kp(n){return!n||n==="interactive"?"interactive-2d":n}function qv(n){return n==="interactive-3d"?"3d":"2d"}function Va(n,e={}){try{let t=ii(n),i=Gt(t.document,Yv(t,e)),r=e.mode??"static";if(r==="interactive"||r==="interactive-2d"||r==="interactive-3d"){let s=r==="interactive"?"interactive-2d":r;return zp(Bp(i,s,{spatialScene:s==="interactive-3d"?rs(t.document,Yv(t,e)):void 0,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap}),{className:e.className??"worldorbit-block worldorbit-interactive",theme:e.theme,layers:e.layers,subtitle:e.subtitle,preset:e.preset,viewMode:s==="interactive-3d"?"3d":"2d",initialViewpointId:e.initialViewpointId,initialSelectionObjectId:e.initialSelectionObjectId,initialFilter:e.initialFilter??null,atlasState:e.atlasState??null,minimap:e.minimap})}return`<figure class="${Y2(e.className??"worldorbit-block worldorbit-static")}">${Cn(i,e)}</figure>`}catch(t){if(e.strict)throw t;return Zv(t instanceof Error?t.message:String(t))}}function Zv(n){return`<pre class="worldorbit-error">WorldOrbit error: ${Jv(n)}</pre>`}function Jv(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function Y2(n){return Jv(n).replaceAll('"',"&quot;")}function Yv(n,e){let t=n.atlasDocument??n.draftDocument;return e.preset||!t?.system?.defaults.preset?e:{...e,preset:t.system.defaults.preset}}var Kv="worldorbit-editor-style",Z2=120,J2=16,K2=96,ro=1495978707e-1,rx=6371,sx=695700,$p=new Set(["placement","target","reference","distance","semiMajor","eccentricity","period","angle","inclination","phase","descriptor"]),Q2=new Set(["star","planet","moon","asteroid","comet"]),Gp=["star","planet","moon","belt","asteroid","comet","ring","structure","phenomenon"],eC=["kind","class","culture","color","image","atmosphere","on","source"],tC=["radius","mass","density","gravity","temperature","inner","outer","cycle"],nC=["albedo"],iC={"defaults-view":{description:"Sets the default camera projection for the atlas.",references:["Topdown = map-like","Isometric = angled overview","Orthographic/Perspective = 3D-ready semantic views"]},"defaults-scale":{description:"Chooses the overall spacing/style preset used by the renderer.",references:["diagram = tighter","presentation = roomier"]},"defaults-units":{description:"Stores a document-wide note about the unit style you want to use.",references:["Example: metric","Example: lore-standard"]},"viewpoint-projection":{description:"Overrides the projection for this saved viewpoint.",references:["Topdown = flat orbital map","Isometric = angled scene","Orthographic/Perspective = stored with current 2D fallback"]},"viewpoint-zoom":{description:"Controls how closely this viewpoint frames the system.",references:["1 = scene fit","2+ = close-up"]},"viewpoint-rotation":{description:"Legacy 2D screen rotation. This is separate from the Schema 2.5 camera block.",references:["90deg = quarter turn","Use camera.azimuth for semantic view direction"]},"viewpoint-camera-azimuth":{description:"Horizontal camera direction in degrees for Schema 2.5 viewpoints.",references:["0 = forward/default","90 = quarter orbit around the scene"]},"viewpoint-camera-elevation":{description:"Vertical camera tilt in degrees for 3D-ready viewpoints.",references:["0 = level","30 = gentle look down"]},"viewpoint-camera-roll":{description:"Rolls the camera around its forward axis.",references:["0 = upright","15 = slight bank"]},"viewpoint-camera-distance":{description:"Semantic camera distance for perspective viewpoints.",references:["4 = close","12 = wide framing"]},"viewpoint-events":{description:"Lists event IDs that this viewpoint should feature in its detail panel.",references:["solar-eclipse-naar","transit-window conjunction"]},"event-kind":{description:"Short semantic event type for tooling and viewer overlays.",references:["solar-eclipse","lunar-eclipse","transit"]},"event-target":{description:"Primary object this event is centered on.",references:["Naar","Seyra"]},"event-participants":{description:"Objects that participate in the event snapshot or description.",references:["Iyath Naar Seyra","Naar Seyra Orun"]},"event-timing":{description:"Free-text timing note for the event.",references:['"Every late bloom season"','"At local midyear"']},"event-visibility":{description:"Notes where or how the event is visible.",references:['"Visible from Naar"','"Southern hemisphere only"']},"event-epoch":{description:"Optional event-wide epoch that event poses inherit unless they override it.",references:['"JY-0001.0"','"Naar bloom cycle year 18"']},"event-referencePlane":{description:"Optional event-wide reference plane for all poses in this snapshot.",references:["ecliptic","naar-equatorial"]},"event-viewpoints":{description:"Viewpoint IDs that should list this event prominently.",references:["naar-system","overview inner-system"]},"placement-target":{description:"Names the body or reference this object is attached to.",references:["orbit Primary","surface Homeworld","at Naar:L4"]},"placement-free":{description:"Stores a free-placement offset or a descriptive label for loose placement.",references:["8au = far from the star",'"outer system" = descriptive note']},"placement-distance":{description:"Mean orbit distance from the target body.",references:["1 au = Earth-Sun distance","384400km = Earth-Moon distance"]},"placement-semiMajor":{description:"Semi-major axis of an orbit, used for elliptical orbits.",references:["1 au = Earth-Sun distance","Use this instead of distance when orbit shape matters"]},"placement-eccentricity":{description:"Controls how stretched the orbit is. Lower is rounder.",references:["0 = circular orbit","0.1 = mildly elliptical"]},"placement-period":{description:"How long one orbit takes.",references:["1 y = one Earth year","27.3d = Moon around Earth"]},"placement-angle":{description:"Rotates the orbit ellipse within the scene.",references:["0deg = default orientation","90deg = quarter turn"]},"placement-inclination":{description:"Tilts the orbit relative to the main orbital plane.",references:["0deg = same plane","5deg = slight tilt"]},"placement-phase":{description:"Starting position of the object along its orbit.",references:["0deg = start position","180deg = opposite side"]},"pose-epoch":{description:"Overrides the effective epoch for this pose only.",references:['"JY-0001.0"',"Falls back to event, object, then system"]},"pose-referencePlane":{description:"Overrides the effective reference plane for this pose only.",references:["naar-equatorial","Falls back to event, object, then system"]},"prop-radius":{description:"Visual body size or real-world-inspired radius value.",references:["1re = Earth radius","1sol = Sun radius"]},"prop-mass":{description:"Optional mass value for the body.",references:["1me = Earth mass","1sol = Sun mass"]},"prop-gravity":{description:"Surface gravity or a custom gravity marker.",references:["1g = Earth-like gravity","0.16g = Moon-like gravity"]},"prop-temperature":{description:"Typical temperature or narrative temperature marker.",references:["288K = Earth-like average","1200K = very hot world"]},"prop-atmosphere":{description:"Short atmosphere descriptor for the object.",references:['"nitrogen-oxygen"','"methane haze"']},"prop-inner":{description:"Inner edge for a belt, ring, or broad phenomenon.",references:["120000km = ring inner edge","2au = belt starts here"]},"prop-outer":{description:"Outer edge for a belt, ring, or broad phenomenon.",references:["190000km = ring outer edge","3au = belt ends here"]}};function ox(n,e={}){tR(n),nR();let t=rC(e),i=t.atlasDocument,r=t.source,s=r,o=r,a=t.diagnostics,c=i.objects[0]?{kind:"object",id:i.objects[0].id}:{kind:"system"},l=[],u=[],d=null,h=!1,f=!1,p=!1,y=null,g=null,m="",x="",v=new Map,w=e.showTextPane??!0,N=e.showInspector??!0,C=e.showPreview??!0,R=e.shortcuts??!0,F=e.viewMode??"2d";n.classList.add("wo-editor"),n.dataset.woShowInspector=String(N),n.dataset.woShowTextPane=String(w),n.dataset.woShowPreview=String(C),n.innerHTML=sC();let A=yn(n,"[data-editor-toolbar]"),S=yn(n,"[data-editor-outline]"),P=yn(n,"[data-editor-stage-shell]"),k=yn(n,"[data-editor-stage]"),O=yn(n,"[data-editor-overlay]"),H=yn(n,"[data-editor-diagnostics]"),W=yn(n,"[data-editor-source-diagnostics]"),J=yn(n,"[data-editor-status]"),ae=yn(n,"[data-editor-live]"),B=yn(n,"[data-editor-inspector]"),ne=yn(n,"[data-editor-source]"),ce=yn(n,"[data-editor-preview-visual]"),Me=yn(n,"[data-editor-preview-markup]"),fe=null;fe=no(k,{source:r,width:e.viewerWidth??1120,height:e.viewerHeight??680,preset:i.system?.defaults.preset??"atlas-card",projection:"document",viewMode:F,minimap:!0,tooltipMode:"hover",onSelectionChange(_){let M=c?Vp(c):null;if(h||!_){h||(c?.kind==="event-pose"&&c.id?ie({kind:"event",id:c.id},!1,!0):c?.kind==="object"?ie(M?{kind:"event",id:M}:null,!1,!0):c?.kind==="event"&&c.id&&ie({kind:"event",id:c.id},!1,!0));return}if(M&&ux(i,M,_.objectId)){ie({kind:"event-pose",id:M,key:_.objectId},!1,!0);return}ie({kind:"object",id:_.objectId},!1,!0)},onViewChange(){ve()}}),A.addEventListener("click",Oe),S.addEventListener("click",qe),O.addEventListener("pointerdown",le),B?.addEventListener("click",Ne),B?.addEventListener("input",Ce),B?.addEventListener("change",Fe),ne?.addEventListener("input",pt),ne?.addEventListener("change",je),ne?.addEventListener("blur",je),n.addEventListener("keydown",V),window.addEventListener("pointermove",K),window.addEventListener("pointerup",we),window.addEventListener("pointercancel",we);let $e={setSource(_){de(_,!1)&&(me(),U())},setAtlasDocument(_){X(_,!1,c,!1),me(),U()},getSource(){return r},getAtlasDocument(){return st(i)},getDiagnostics(){return a.map(qu)},getSelection(){return c?{path:{...c}}:null},getViewMode(){return F},setViewMode(_){let M=F;try{fe.setViewMode(_),F=_,ve(),kn()}catch(E){throw F=M,E}},isDirty(){return p},markSaved(){z(!0)},selectPath(_){ie(_,!0,!0)},canUndo(){return l.length>0},canRedo(){return u.length>0},undo(){let _=l.pop();return _?(u.unshift(Y()),Be(_),!0):!1},redo(){let _=u.shift();return _?(l.push(Y()),Be(_),!0):!1},addObject(_="planet"){let M=ja(_,i.objects.map(j=>j.id)),E=SC(_,M,i),I=EC(i,E);return X(I,!0,{kind:"object",id:M}),M},addEvent(){let _=ja("event",i.events.map(I=>I.id)),M={id:_,kind:"",label:Ga(_),summary:null,targetObjectId:null,participantObjectIds:[],timing:null,visibility:null,epoch:null,referencePlane:null,tags:[],color:null,hidden:!1,positions:[]},E=st(i);return E.events.push(M),E.events.sort(nx),X(E,!0,{kind:"event",id:_}),_},addViewpoint(){let _=ja("viewpoint",i.system?.viewpoints.map(I=>I.id)??[]),M={id:_,label:Ga(_),summary:"",focusObjectId:null,selectedObjectId:null,events:[],projection:i.system?.defaults.view??"topdown",preset:i.system?.defaults.preset??null,zoom:null,rotationDeg:0,camera:null,layers:{},filter:null},E=st(i);return E.system?.viewpoints.push(M),E.system?.viewpoints.sort((I,j)=>I.id.localeCompare(j.id)),X(E,!0,{kind:"viewpoint",id:_}),_},addAnnotation(){let _=ja("annotation",i.system?.annotations.map(I=>I.id)??[]),M={id:_,label:Ga(_),targetObjectId:null,body:"",tags:[],sourceObjectId:null},E=st(i);return E.system?.annotations.push(M),E.system?.annotations.sort((I,j)=>I.id.localeCompare(j.id)),X(E,!0,{kind:"annotation",id:_}),_},addMetadata(_,M){let E=_?.trim()||ja("metadata",Object.keys(i.system?.atlasMetadata??{})),I=st(i);return I.system&&(I.system.atlasMetadata[E]=M??""),X(I,!0,{kind:"metadata",key:E}),E},removeSelection(){if(!c||c.kind==="system"||c.kind==="defaults")return!1;let _=IC(i,c);return X(_,!0,{kind:"system"}),!0},exportSvg(){return fe.exportSvg()},exportEmbedMarkup(){return tx(Pe(),i,F)},destroy(){f||(f=!0,A.removeEventListener("click",Oe),S.removeEventListener("click",qe),O.removeEventListener("pointerdown",le),B?.removeEventListener("click",Ne),B?.removeEventListener("input",Ce),B?.removeEventListener("change",Fe),ne?.removeEventListener("input",pt),ne?.removeEventListener("change",je),ne?.removeEventListener("blur",je),n.removeEventListener("keydown",V),window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",we),window.removeEventListener("pointercancel",we),te(),ue(),fe.destroy(),n.innerHTML="",n.classList.remove("wo-editor"))}};return Te(!0),_e(!0),$e;function Y(){return{atlasDocument:st(i),selection:c?{...c}:null,source:r}}function me(){l.length=0,u.length=0,U()}function te(){y!==null&&(window.clearTimeout(y),y=null)}function ue(){g!==null&&(window.clearTimeout(g),g=null)}function Pe(){return d?.changed?tr(i):r}function _e(_=!1){let M=s!==o||r!==o||d?.changed===!0;!_&&M===p||(p=M,Fn(),e.onDirtyChange?.(p))}function z(_=!1){s=r,re(),o=r,_e(_)}function Be(_){te(),i=st(_.atlasDocument),r=_.source,s=r,a=nr(i),c=ye(_.selection),Z({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Te(),_e(),he()}function X(_,M,E,I=!1){M&&(l.push(Y()),u.length=0),te(),i=st(_),r=tr(i),I||(s=r),a=nr(i),c=ye(E),Z({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),ie(c,!1,!1),Te(),_e(),he()}function de(_,M){s=_,ne&&ne.value!==_&&(ne.value=_);let E=Eo(_);if(!E.ok||!E.value)return a=E.diagnostics.map(Q=>({diagnostic:Q,path:null})),G(),ee(),T(),oe(),Fn(),Tn(),_e(),e.onDiagnosticsChange?.(a.map(qu)),!1;let I=E.value.atlasDocument??ur(E.value.document),j=So(I,E.diagnostics);return M&&(l.push(Y()),u.length=0,s=tr(I)),i=st(I),r=tr(i),a=cx(j,nr(i)),c=ye(c),Z({preserveCamera:c?.kind!=="viewpoint",applyViewpointSelection:c?.kind==="viewpoint"}),Te(),_e(),he(),!0}function Z(_={}){if(!fe)return;let M=fe.getState(),E=fe.getRenderOptions(),I=i.system?.defaults.preset??"atlas-card",j=c?Vp(c):null;h=!0,(E.preset!==I||E.projection!=="document"||(E.activeEventId??null)!==j)&&fe.setRenderOptions({preset:I,projection:"document",activeEventId:j}),fe.setDocument(ss(i)),_.applyViewpointSelection&&c?.kind==="viewpoint"&&c.id?fe.goToViewpoint(c.id):_.preserveCamera!==!1?fe.setState({...M,selectedObjectId:c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null}):c?.kind==="object"&&c.id?fe.focusObject(c.id):c?.kind==="event-pose"&&c.key&&fe.focusObject(c.key),h=!1}function he(){let _={source:r,atlasDocument:st(i),diagnostics:a.map(qu),selection:c?{path:{...c}}:null};e.onDiagnosticsChange?.(_.diagnostics),e.onSelectionChange?.(_.selection),e.onChange?.(_)}function ie(_,M,E=!0){c=ye(_),M&&(h=!0,fe.setRenderOptions({activeEventId:c?Vp(c):null}),c?.kind==="object"&&c.id?fe.focusObject(c.id):c?.kind==="event-pose"&&c.key?fe.focusObject(c.key):c?.kind==="viewpoint"&&c.id&&fe.goToViewpoint(c.id),h=!1),U(),T(),B?.contains(document.activeElement)||oe(),ve(),Fn(),Tn(),E&&e.onSelectionChange?.(c?{path:{...c}}:null)}function ye(_){if(!_)return null;let M=Md(i,_);return M==null?_.kind==="system"||_.kind==="defaults"?_:null:_}function Te(_=!1){U(),T(),G(),ee(),B?.contains(document.activeElement)||oe(),re(),Ue(_),ve(),Fn(),Tn()}function U(){let _=A.querySelector("[data-editor-add-object-type]")?.value??"planet";A.innerHTML=`
4094
4094
  <div class="wo-editor-toolbar-group">
4095
4095
  <select data-editor-add-object-type>
4096
4096
  ${Gp.map(M=>`<option value="${Xe(M)}"${M===_?" selected":""}>${Xe(Ga(M))}</option>`).join("")}
@@ -4133,7 +4133,7 @@ void main() {
4133
4133
  <h3>Objects</h3>
4134
4134
  ${i.objects.length>0?i.objects.map(I=>Ai({kind:"object",id:I.id},`${I.id} - ${I.type}`,_,M)).join(""):'<p class="wo-editor-empty">No objects yet.</p>'}
4135
4135
  </div>
4136
- `}function G(){H.innerHTML=a.length===0?'<p class="wo-editor-empty">No diagnostics.</p>':a.map(_=>{let M=_.path?Gu(_.path):"Source",E=ex(_);return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Xe(_.diagnostic.severity)}">
4136
+ `}function G(){H.innerHTML=a.length===0?'<p class="wo-editor-empty">No diagnostics.</p>':a.map(_=>{let M=_.path?Xu(_.path):"Source",E=ex(_);return`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Xe(_.diagnostic.severity)}">
4137
4137
  <strong>${Xe(_.diagnostic.severity.toUpperCase())}</strong>
4138
4138
  <span>${Xe(M)}${E?` \xB7 ${Xe(E)}`:""}</span>
4139
4139
  <p>${Xe(_.diagnostic.message)}</p>
@@ -4141,21 +4141,21 @@ void main() {
4141
4141
  <strong>${Xe(M.diagnostic.severity.toUpperCase())}</strong>
4142
4142
  <span>${Xe(E)}</span>
4143
4143
  <p>${Xe(M.diagnostic.message)}</p>
4144
- </article>`}).join("")}function oe(){if(!B)return;aC(B,v);let _={selection:c?{path:{...c}}:null,system:i.system,viewpoints:i.system?.viewpoints??[],events:i.events,objects:i.objects};if(!c){B.innerHTML='<p class="wo-editor-empty">Select an atlas node or object to edit it.</p>';return}let M=$(c,a);switch(c.kind){case"system":B.innerHTML=M+dC(_),Ki(B,v),b(c,a);return;case"defaults":B.innerHTML=M+hC(_),Ki(B,v),b(c,a);return;case"metadata":B.innerHTML=M+fC(_,c.key??""),Ki(B,v),b(c,a);return;case"viewpoint":B.innerHTML=M+pC(_,c.id??""),Ki(B,v),b(c,a);return;case"event":B.innerHTML=M+mC(_,c.id??""),Ki(B,v),b(c,a);return;case"event-pose":B.innerHTML=M+gC(_,c.id??"",c.key??""),Ki(B,v),b(c,a);return;case"annotation":B.innerHTML=M+yC(_,c.id??""),Ki(B,v),b(c,a);return;case"object":B.innerHTML=M+vC(_,c.id??""),Ki(B,v),b(c,a);return}}function re(){ne&&ne.value!==s&&(ne.value=s)}function Ue(_=!1){if(_){Fn();return}sr()}function ve(){if(!fe||(O.innerHTML="",F==="3d"))return;let _=c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null;if(!_)return;let M=fe.getObjectDetails(_);if(!M)return;if(xe(M.renderObject.x,M.renderObject.y,M.renderObject.objectId),M.parent&&xe(M.parent.x,M.parent.y,`Parent: ${M.parent.objectId}`,!0),M.renderObject.anchorX!==void 0&&M.renderObject.anchorY!==void 0&&xe(M.renderObject.anchorX,M.renderObject.anchorY,"Anchor",!0),M.object.placement?.mode==="orbit"&&M.orbit){let I=pe({x:M.renderObject.x,y:M.renderObject.y});O.append(Ha("orbit-phase",M.objectId,I,"Phase"));let j=He(M);O.append(Ha("orbit-radius",M.objectId,j,"Size"))}if(M.object.placement?.mode==="at"){O.append(Ha("at-reference",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Reference"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag to an object center or nearby Lagrange point.",O.append(I)}if(M.object.placement?.mode==="surface"){O.append(Ha("surface-target",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Surface"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag onto another surface-capable body.",O.append(I)}if(M.object.placement?.mode==="free"){O.append(Ha("free-distance",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Offset"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag horizontally to change free offset.",O.append(I)}let E=L(c,a).slice(0,3);if(E.length>0){let I=document.createElement("div");I.className="wo-editor-overlay-diagnostics",I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.innerHTML=E.map(j=>`<article class="wo-editor-overlay-diagnostic wo-editor-overlay-diagnostic-${Xe(j.diagnostic.severity)}">
4144
+ </article>`}).join("")}function oe(){if(!B)return;aC(B,v);let _={selection:c?{path:{...c}}:null,system:i.system,viewpoints:i.system?.viewpoints??[],events:i.events,objects:i.objects};if(!c){B.innerHTML='<p class="wo-editor-empty">Select an atlas node or object to edit it.</p>';return}let M=$(c,a);switch(c.kind){case"system":B.innerHTML=M+dC(_),Ki(B,v),b(c,a);return;case"defaults":B.innerHTML=M+hC(_),Ki(B,v),b(c,a);return;case"metadata":B.innerHTML=M+fC(_,c.key??""),Ki(B,v),b(c,a);return;case"viewpoint":B.innerHTML=M+pC(_,c.id??""),Ki(B,v),b(c,a);return;case"event":B.innerHTML=M+mC(_,c.id??""),Ki(B,v),b(c,a);return;case"event-pose":B.innerHTML=M+gC(_,c.id??"",c.key??""),Ki(B,v),b(c,a);return;case"annotation":B.innerHTML=M+yC(_,c.id??""),Ki(B,v),b(c,a);return;case"object":B.innerHTML=M+vC(_,c.id??""),Ki(B,v),b(c,a);return}}function re(){ne&&ne.value!==s&&(ne.value=s)}function Ue(_=!1){if(_){kn();return}sr()}function ve(){if(!fe||(O.innerHTML="",F==="3d"))return;let _=c?.kind==="object"?c.id??null:c?.kind==="event-pose"?c.key??null:null;if(!_)return;let M=fe.getObjectDetails(_);if(!M)return;if(xe(M.renderObject.x,M.renderObject.y,M.renderObject.objectId),M.parent&&xe(M.parent.x,M.parent.y,`Parent: ${M.parent.objectId}`,!0),M.renderObject.anchorX!==void 0&&M.renderObject.anchorY!==void 0&&xe(M.renderObject.anchorX,M.renderObject.anchorY,"Anchor",!0),M.object.placement?.mode==="orbit"&&M.orbit){let I=pe({x:M.renderObject.x,y:M.renderObject.y});O.append(Ha("orbit-phase",M.objectId,I,"Phase"));let j=He(M);O.append(Ha("orbit-radius",M.objectId,j,"Size"))}if(M.object.placement?.mode==="at"){O.append(Ha("at-reference",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Reference"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag to an object center or nearby Lagrange point.",O.append(I)}if(M.object.placement?.mode==="surface"){O.append(Ha("surface-target",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Surface"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag onto another surface-capable body.",O.append(I)}if(M.object.placement?.mode==="free"){O.append(Ha("free-distance",M.objectId,pe({x:M.renderObject.x,y:M.renderObject.y}),"Offset"));let I=document.createElement("div");I.className="wo-editor-hint wo-editor-hint-note",I.textContent="Drag horizontally to change free offset.",O.append(I)}let E=L(c,a).slice(0,3);if(E.length>0){let I=document.createElement("div");I.className="wo-editor-overlay-diagnostics",I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.innerHTML=E.map(j=>`<article class="wo-editor-overlay-diagnostic wo-editor-overlay-diagnostic-${Xe(j.diagnostic.severity)}">
4145
4145
  <strong>${Xe(j.diagnostic.severity.toUpperCase())}</strong>
4146
4146
  <p>${Xe(j.diagnostic.message)}</p>
4147
- </article>`).join(""),O.append(I)}}function xe(_,M,E,I=!1){let j=pe({x:_,y:M}),Q=document.createElement("div");Q.className=`wo-editor-hint${I?" is-subtle":""}`,Q.style.left=`${j.x}px`,Q.style.top=`${j.y}px`,Q.textContent=E,O.append(Q)}function He(_){let M=_.orbit;if(!M)return pe({x:_.renderObject.x,y:_.renderObject.y});let E={x:M.cx+(M.kind==="circle"?M.radius??0:M.rx??0),y:M.cy},I=rn(E,{x:M.cx,y:M.cy},M.rotationDeg);return pe(I)}function pe(_){let M=fe.getScene(),E=fe.getState(),I={x:M.width/2,y:M.height/2},j=rn(_,I,E.rotationDeg),Q={x:I.x+(j.x-I.x)*E.scale+E.translateX,y:I.y+(j.y-I.y)*E.scale+E.translateY},ge=k.querySelector("svg");if(!ge)return Q;let Se=ge.getBoundingClientRect(),Le=P.getBoundingClientRect();return{x:Se.left-Le.left+Q.x/Math.max(M.width,1)*Se.width,y:Se.top-Le.top+Q.y/Math.max(M.height,1)*Se.height}}function Oe(_){let M=_.target?.closest("[data-editor-action]");if(M)switch(M.dataset.editorAction){case"add-object":{let E=A.querySelector("[data-editor-add-object-type]")?.value;$e.addObject(E??"planet");return}case"add-viewpoint":$e.addViewpoint();return;case"add-event":$e.addEvent();return;case"add-annotation":$e.addAnnotation();return;case"add-metadata":$e.addMetadata();return;case"remove":$e.removeSelection();return;case"undo":$e.undo();return;case"redo":$e.redo();return;case"format":te(),s=r,re(),_e();return}}function qe(_){let M=_.target?.closest("[data-path-kind]");M&&ie({kind:M.dataset.pathKind,id:M.dataset.pathId||void 0,key:M.dataset.pathKey||void 0},!0,!0)}function Ne(_){let M=_.target?.closest("[data-path-kind]");if(M){ie({kind:M.dataset.pathKind,id:M.dataset.pathId||void 0,key:M.dataset.pathKey||void 0},!0,!0);return}let E=_.target?.closest("[data-editor-action]");if(E&&E.dataset.editorAction==="add-event-pose"){let I=E.dataset.editorEventId||(c?.kind==="event"||c?.kind==="event-pose"?c.id??"":"");if(!I)return;let j=$C(i,I),Q=j.events.find(Se=>Se.id===I),ge=Q?.positions.at(-1)??Q?.positions[0];X(j,!0,ge?{kind:"event-pose",id:I,key:ge.objectId}:{kind:"event",id:I});return}}function Ce(){Qe(!1)}function Fe(){Qe(!0)}function Qe(_){if(!(!c||!B))switch(c.kind){case"system":X(tt(),_,c,!1);return;case"defaults":X(ft(),_,c,!1);return;case"metadata":X(vt(c.key??""),_,c,!1);return;case"viewpoint":X(rt(c.id??""),_,c,!1);return;case"event":X($t(c.id??""),_,c,!1);return;case"event-pose":X(Et(c.id??"",c.key??""),_,c,!1);return;case"annotation":X(Yr(c.id??""),_,c,!1);return;case"object":X(rr(c.id??""),_,c,!1);return}}function pt(){s=ne?.value??"",_e(),te(),y=window.setTimeout(()=>{y=null,de(s,!1)},Z2)}function je(){te(),de(ne?.value??"",!0)&&re()}function V(_){if(_.key==="Escape"&&d){_.preventDefault(),Ae();return}if(!R||_.defaultPrevented||Zr(_))return;let M=(_.ctrlKey||_.metaKey)&&!_.shiftKey&&_.key.toLowerCase()==="z",E=(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"||_.key.toLowerCase()==="y");if(M){_.preventDefault(),$e.undo();return}E&&(_.preventDefault(),$e.redo())}function le(_){let M=_.target?.closest("[data-handle-kind]");if(!M)return;let E=M.dataset.objectId,I=M.dataset.handleKind;if(!E||!["orbit-phase","orbit-radius","at-reference","surface-target","free-distance"].includes(I))return;if(te(),s!==r&&!de(s,!0)){_.preventDefault();return}let j=fe?.getObjectDetails(E)??null;d={kind:I,objectId:E,pointerId:_.pointerId,path:c?{...c}:{kind:"object",id:E},startedFrom:Y(),changed:!1,orbitRadiusContext:I==="orbit-radius"&&j?DC(i,fe.getScene(),j):null},M.setPointerCapture?.(_.pointerId),_.preventDefault()}function K(_){if(!d||d.pointerId!==_.pointerId||!c||Ti(c)!==Ti(d.path))return;let M=fe.getObjectDetails(d.objectId);if(!M)return;let E=Re(_.clientX,_.clientY),I=i;switch(d.kind){case"orbit-phase":M.object.placement?.mode==="orbit"&&M.orbit&&(I=CC(i,d.path,d.objectId,M,E));break;case"orbit-radius":M.object.placement?.mode==="orbit"&&M.orbit&&(I=RC(i,d.path,d.objectId,fe.getScene(),M,E,d.orbitRadiusContext??null));break;case"at-reference":M.object.placement?.mode==="at"&&(I=PC(i,d.path,d.objectId,fe.getScene(),E));break;case"surface-target":M.object.placement?.mode==="surface"&&(I=LC(i,d.path,d.objectId,fe.getScene(),E));break;case"free-distance":M.object.placement?.mode==="free"&&(I=OC(i,d.path,d.objectId,fe.getScene(),M,E));break}I!==i&&(d.changed=!0,i=st(I),a=nr(i),Z({preserveCamera:!0,applyViewpointSelection:!1}),G(),ee(),T(),oe(),ve(),Nn(),An(),sr(),_e())}function we(_){if(!d||d.pointerId!==_.pointerId)return;let M=d;if(!d.changed){d=null;return}l.push(d.startedFrom),u.length=0,r=tr(i),s=r,d=null,Te(),M.kind==="orbit-radius"&&or(M.objectId),_e(),he()}function Ae(){if(!d)return;let _=d.startedFrom;d=null,i=st(_.atlasDocument),r=_.source,s=r,a=nr(i),ie(_.selection,!1,!1),Z({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),Te(),_e(),he()}function Re(_,M){let E=k.querySelector("svg"),I=fe.getScene();if(!E)return{x:I.width/2,y:I.height/2};let j=E.getBoundingClientRect(),Q={x:(_-j.left)/Math.max(j.width,1)*I.width,y:(M-j.top)/Math.max(j.height,1)*I.height};return hr(I,fe.getState(),Q)}function tt(){let _=st(i),M=B?.querySelector("form[data-editor-form='system']");return!M||!_.system||(_.system.id=Kt(M,"system-id")||_.system.id,_.system.title=ke(M,"system-title")),_}function ft(){let _=st(i),M=B?.querySelector("form[data-editor-form='defaults']");return!M||!_.system||(_.system.defaults.view=Kt(M,"defaults-view")||"topdown",_.system.defaults.scale=ke(M,"defaults-scale"),_.system.defaults.units=ke(M,"defaults-units"),_.system.defaults.preset=ke(M,"defaults-preset")??null,_.system.defaults.theme=ke(M,"defaults-theme")),_}function vt(_){let M=st(i),E=B?.querySelector("form[data-editor-form='metadata']");if(!E||!M.system)return M;let I=Kt(E,"metadata-key")||_,j=ke(E,"metadata-value")??"";return I!==_?(delete M.system.atlasMetadata[_],M.system.atlasMetadata[I]=j,c={kind:"metadata",key:I},M):(M.system.atlasMetadata[_]=j,M)}function rt(_){let M=st(i),E=B?.querySelector("form[data-editor-form='viewpoint']"),I=M.system?.viewpoints.find(ge=>ge.id===_);if(!E||!I||!M.system)return M;let j=Kt(E,"viewpoint-id")||I.id,Q={...I,id:j,label:Kt(E,"viewpoint-label")||I.label,summary:ke(E,"viewpoint-summary")??"",focusObjectId:ke(E,"viewpoint-focus"),selectedObjectId:ke(E,"viewpoint-select"),projection:Kt(E,"viewpoint-projection")||I.projection,preset:ke(E,"viewpoint-preset")??null,zoom:ir(ke(E,"viewpoint-zoom")),rotationDeg:ir(ke(E,"viewpoint-rotation"))??0,camera:wC(E),layers:{background:Jn(E,"layer-background"),guides:Jn(E,"layer-guides"),"orbits-back":Jn(E,"layer-orbits-back"),"orbits-front":Jn(E,"layer-orbits-front"),events:Jn(E,"layer-events"),objects:Jn(E,"layer-objects"),labels:Jn(E,"layer-labels"),metadata:Jn(E,"layer-metadata")},events:Ei(ke(E,"viewpoint-events")),filter:{query:ke(E,"filter-query"),objectTypes:MC(ke(E,"filter-object-types")),tags:Ei(ke(E,"filter-tags")),groupIds:Ei(ke(E,"filter-groups"))}};return M.system.viewpoints=M.system.viewpoints.filter(ge=>ge.id!==I.id).concat(Q).sort((ge,Se)=>ge.id.localeCompare(Se.id)),I.id!==Q.id&&(c={kind:"viewpoint",id:Q.id}),M}function $t(_){let M=st(i),E=B?.querySelector("form[data-editor-form='event']"),I=M.events.find(ge=>ge.id===_);if(!E||!I)return M;let j=Kt(E,"event-id")||I.id,Q={...I,id:j,kind:Kt(E,"event-kind"),label:Kt(E,"event-label")||I.label,summary:ke(E,"event-summary"),targetObjectId:ke(E,"event-target"),participantObjectIds:Ei(ke(E,"event-participants")),timing:ke(E,"event-timing"),visibility:ke(E,"event-visibility"),epoch:ke(E,"event-epoch"),referencePlane:ke(E,"event-referencePlane"),tags:Ei(ke(E,"event-tags")),color:ke(E,"event-color"),hidden:Jn(E,"event-hidden")};return M.events=M.events.filter(ge=>ge.id!==I.id).concat(Q).sort(nx),jC(M,I.id,Q.id,Ei(ke(E,"event-viewpoints"))),I.id!==Q.id&&(c={kind:"event",id:Q.id}),M}function Et(_,M){let E=st(i),I=B?.querySelector("form[data-editor-form='event-pose']"),j=E.events.find(ze=>ze.id===_),Q=j?.positions.find(ze=>ze.objectId===M);if(!I||!j||!Q)return E;let Se={objectId:Kt(I,"pose-object-id")||Q.objectId,placement:bC(I,Q),epoch:ke(I,"pose-epoch"),referencePlane:ke(I,"pose-referencePlane")},Le=Qn(ke(I,"prop-inner")),Ge=Qn(ke(I,"prop-outer"));return Le&&(Se.inner=Le),Ge&&(Se.outer=Ge),j.positions=j.positions.filter(ze=>ze.objectId!==Q.objectId).concat(Se).sort(qu),j.targetObjectId!==Se.objectId&&!j.participantObjectIds.includes(Se.objectId)&&(j.participantObjectIds.push(Se.objectId),j.participantObjectIds.sort((ze,mt)=>ze.localeCompare(mt))),Q.objectId!==Se.objectId&&(c={kind:"event-pose",id:_,key:Se.objectId}),E}function Yr(_){let M=st(i),E=B?.querySelector("form[data-editor-form='annotation']"),I=M.system?.annotations.find(ge=>ge.id===_);if(!E||!I||!M.system)return M;let j=Kt(E,"annotation-id")||I.id,Q={...I,id:j,label:Kt(E,"annotation-label")||I.label,targetObjectId:ke(E,"annotation-target"),body:ke(E,"annotation-body")??"",tags:Ei(ke(E,"annotation-tags")),sourceObjectId:ke(E,"annotation-source")};return M.system.annotations=M.system.annotations.filter(ge=>ge.id!==I.id).concat(Q).sort((ge,Se)=>ge.id.localeCompare(Se.id)),I.id!==Q.id&&(c={kind:"annotation",id:Q.id}),M}function rr(_){let M=st(i),E=B?.querySelector("form[data-editor-form='object']"),I=M.objects.find(Le=>Le.id===_);if(!E||!I)return M;let j=Kt(E,"object-id")||I.id,Q={...I,id:j,type:Kt(E,"object-type")||I.type,properties:{...I.properties},info:{...I.info},placement:xC(E,I)};for(let Le of eC)ju(Q.properties,Le,ke(E,`prop-${Le}`));for(let Le of tC)ju(Q.properties,Le,_C(ke(E,`prop-${Le}`)));for(let Le of nC)ju(Q.properties,Le,ir(ke(E,`prop-${Le}`)));ju(Q.properties,"tags",Ei(ke(E,"prop-tags"))),Q.properties.hidden=Jn(E,"prop-hidden");let ge=ke(E,"info-description");ge?Q.info.description=ge:delete Q.info.description;let Se=AC(M,I.id,Q);return I.id!==Q.id&&(c={kind:"object",id:Q.id}),Se}function Nn(){let _=a.filter(I=>I.diagnostic.severity==="error").length,M=a.filter(I=>I.diagnostic.severity==="warning").length,E=c?Gu(c):"Nothing selected";J.innerHTML=`
4147
+ </article>`).join(""),O.append(I)}}function xe(_,M,E,I=!1){let j=pe({x:_,y:M}),Q=document.createElement("div");Q.className=`wo-editor-hint${I?" is-subtle":""}`,Q.style.left=`${j.x}px`,Q.style.top=`${j.y}px`,Q.textContent=E,O.append(Q)}function He(_){let M=_.orbit;if(!M)return pe({x:_.renderObject.x,y:_.renderObject.y});let E={x:M.cx+(M.kind==="circle"?M.radius??0:M.rx??0),y:M.cy},I=rn(E,{x:M.cx,y:M.cy},M.rotationDeg);return pe(I)}function pe(_){let M=fe.getScene(),E=fe.getState(),I={x:M.width/2,y:M.height/2},j=rn(_,I,E.rotationDeg),Q={x:I.x+(j.x-I.x)*E.scale+E.translateX,y:I.y+(j.y-I.y)*E.scale+E.translateY},ge=k.querySelector("svg");if(!ge)return Q;let Se=ge.getBoundingClientRect(),Le=P.getBoundingClientRect();return{x:Se.left-Le.left+Q.x/Math.max(M.width,1)*Se.width,y:Se.top-Le.top+Q.y/Math.max(M.height,1)*Se.height}}function Oe(_){let M=_.target?.closest("[data-editor-action]");if(M)switch(M.dataset.editorAction){case"add-object":{let E=A.querySelector("[data-editor-add-object-type]")?.value;$e.addObject(E??"planet");return}case"add-viewpoint":$e.addViewpoint();return;case"add-event":$e.addEvent();return;case"add-annotation":$e.addAnnotation();return;case"add-metadata":$e.addMetadata();return;case"remove":$e.removeSelection();return;case"undo":$e.undo();return;case"redo":$e.redo();return;case"format":te(),s=r,re(),_e();return}}function qe(_){let M=_.target?.closest("[data-path-kind]");M&&ie({kind:M.dataset.pathKind,id:M.dataset.pathId||void 0,key:M.dataset.pathKey||void 0},!0,!0)}function Ne(_){let M=_.target?.closest("[data-path-kind]");if(M){ie({kind:M.dataset.pathKind,id:M.dataset.pathId||void 0,key:M.dataset.pathKey||void 0},!0,!0);return}let E=_.target?.closest("[data-editor-action]");if(E&&E.dataset.editorAction==="add-event-pose"){let I=E.dataset.editorEventId||(c?.kind==="event"||c?.kind==="event-pose"?c.id??"":"");if(!I)return;let j=$C(i,I),Q=j.events.find(Se=>Se.id===I),ge=Q?.positions.at(-1)??Q?.positions[0];X(j,!0,ge?{kind:"event-pose",id:I,key:ge.objectId}:{kind:"event",id:I});return}}function Ce(){Qe(!1)}function Fe(){Qe(!0)}function Qe(_){if(!(!c||!B))switch(c.kind){case"system":X(tt(),_,c,!1);return;case"defaults":X(ft(),_,c,!1);return;case"metadata":X(vt(c.key??""),_,c,!1);return;case"viewpoint":X(rt(c.id??""),_,c,!1);return;case"event":X($t(c.id??""),_,c,!1);return;case"event-pose":X(Et(c.id??"",c.key??""),_,c,!1);return;case"annotation":X(Kr(c.id??""),_,c,!1);return;case"object":X(rr(c.id??""),_,c,!1);return}}function pt(){s=ne?.value??"",_e(),te(),y=window.setTimeout(()=>{y=null,de(s,!1)},Z2)}function je(){te(),de(ne?.value??"",!0)&&re()}function V(_){if(_.key==="Escape"&&d){_.preventDefault(),Ae();return}if(!R||_.defaultPrevented||Qr(_))return;let M=(_.ctrlKey||_.metaKey)&&!_.shiftKey&&_.key.toLowerCase()==="z",E=(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"||_.key.toLowerCase()==="y");if(M){_.preventDefault(),$e.undo();return}E&&(_.preventDefault(),$e.redo())}function le(_){let M=_.target?.closest("[data-handle-kind]");if(!M)return;let E=M.dataset.objectId,I=M.dataset.handleKind;if(!E||!["orbit-phase","orbit-radius","at-reference","surface-target","free-distance"].includes(I))return;if(te(),s!==r&&!de(s,!0)){_.preventDefault();return}let j=fe?.getObjectDetails(E)??null;d={kind:I,objectId:E,pointerId:_.pointerId,path:c?{...c}:{kind:"object",id:E},startedFrom:Y(),changed:!1,orbitRadiusContext:I==="orbit-radius"&&j?DC(i,fe.getScene(),j):null},M.setPointerCapture?.(_.pointerId),_.preventDefault()}function K(_){if(!d||d.pointerId!==_.pointerId||!c||Ti(c)!==Ti(d.path))return;let M=fe.getObjectDetails(d.objectId);if(!M)return;let E=Re(_.clientX,_.clientY),I=i;switch(d.kind){case"orbit-phase":M.object.placement?.mode==="orbit"&&M.orbit&&(I=CC(i,d.path,d.objectId,M,E));break;case"orbit-radius":M.object.placement?.mode==="orbit"&&M.orbit&&(I=RC(i,d.path,d.objectId,fe.getScene(),M,E,d.orbitRadiusContext??null));break;case"at-reference":M.object.placement?.mode==="at"&&(I=PC(i,d.path,d.objectId,fe.getScene(),E));break;case"surface-target":M.object.placement?.mode==="surface"&&(I=LC(i,d.path,d.objectId,fe.getScene(),E));break;case"free-distance":M.object.placement?.mode==="free"&&(I=OC(i,d.path,d.objectId,fe.getScene(),M,E));break}I!==i&&(d.changed=!0,i=st(I),a=nr(i),Z({preserveCamera:!0,applyViewpointSelection:!1}),G(),ee(),T(),oe(),ve(),Fn(),Tn(),sr(),_e())}function we(_){if(!d||d.pointerId!==_.pointerId)return;let M=d;if(!d.changed){d=null;return}l.push(d.startedFrom),u.length=0,r=tr(i),s=r,d=null,Te(),M.kind==="orbit-radius"&&or(M.objectId),_e(),he()}function Ae(){if(!d)return;let _=d.startedFrom;d=null,i=st(_.atlasDocument),r=_.source,s=r,a=nr(i),ie(_.selection,!1,!1),Z({preserveCamera:!0,applyViewpointSelection:c?.kind==="viewpoint"}),Te(),_e(),he()}function Re(_,M){let E=k.querySelector("svg"),I=fe.getScene();if(!E)return{x:I.width/2,y:I.height/2};let j=E.getBoundingClientRect(),Q={x:(_-j.left)/Math.max(j.width,1)*I.width,y:(M-j.top)/Math.max(j.height,1)*I.height};return mr(I,fe.getState(),Q)}function tt(){let _=st(i),M=B?.querySelector("form[data-editor-form='system']");return!M||!_.system||(_.system.id=Kt(M,"system-id")||_.system.id,_.system.title=ke(M,"system-title")),_}function ft(){let _=st(i),M=B?.querySelector("form[data-editor-form='defaults']");return!M||!_.system||(_.system.defaults.view=Kt(M,"defaults-view")||"topdown",_.system.defaults.scale=ke(M,"defaults-scale"),_.system.defaults.units=ke(M,"defaults-units"),_.system.defaults.preset=ke(M,"defaults-preset")??null,_.system.defaults.theme=ke(M,"defaults-theme")),_}function vt(_){let M=st(i),E=B?.querySelector("form[data-editor-form='metadata']");if(!E||!M.system)return M;let I=Kt(E,"metadata-key")||_,j=ke(E,"metadata-value")??"";return I!==_?(delete M.system.atlasMetadata[_],M.system.atlasMetadata[I]=j,c={kind:"metadata",key:I},M):(M.system.atlasMetadata[_]=j,M)}function rt(_){let M=st(i),E=B?.querySelector("form[data-editor-form='viewpoint']"),I=M.system?.viewpoints.find(ge=>ge.id===_);if(!E||!I||!M.system)return M;let j=Kt(E,"viewpoint-id")||I.id,Q={...I,id:j,label:Kt(E,"viewpoint-label")||I.label,summary:ke(E,"viewpoint-summary")??"",focusObjectId:ke(E,"viewpoint-focus"),selectedObjectId:ke(E,"viewpoint-select"),projection:Kt(E,"viewpoint-projection")||I.projection,preset:ke(E,"viewpoint-preset")??null,zoom:ir(ke(E,"viewpoint-zoom")),rotationDeg:ir(ke(E,"viewpoint-rotation"))??0,camera:wC(E),layers:{background:Kn(E,"layer-background"),guides:Kn(E,"layer-guides"),"orbits-back":Kn(E,"layer-orbits-back"),"orbits-front":Kn(E,"layer-orbits-front"),events:Kn(E,"layer-events"),objects:Kn(E,"layer-objects"),labels:Kn(E,"layer-labels"),metadata:Kn(E,"layer-metadata")},events:Ei(ke(E,"viewpoint-events")),filter:{query:ke(E,"filter-query"),objectTypes:MC(ke(E,"filter-object-types")),tags:Ei(ke(E,"filter-tags")),groupIds:Ei(ke(E,"filter-groups"))}};return M.system.viewpoints=M.system.viewpoints.filter(ge=>ge.id!==I.id).concat(Q).sort((ge,Se)=>ge.id.localeCompare(Se.id)),I.id!==Q.id&&(c={kind:"viewpoint",id:Q.id}),M}function $t(_){let M=st(i),E=B?.querySelector("form[data-editor-form='event']"),I=M.events.find(ge=>ge.id===_);if(!E||!I)return M;let j=Kt(E,"event-id")||I.id,Q={...I,id:j,kind:Kt(E,"event-kind"),label:Kt(E,"event-label")||I.label,summary:ke(E,"event-summary"),targetObjectId:ke(E,"event-target"),participantObjectIds:Ei(ke(E,"event-participants")),timing:ke(E,"event-timing"),visibility:ke(E,"event-visibility"),epoch:ke(E,"event-epoch"),referencePlane:ke(E,"event-referencePlane"),tags:Ei(ke(E,"event-tags")),color:ke(E,"event-color"),hidden:Kn(E,"event-hidden")};return M.events=M.events.filter(ge=>ge.id!==I.id).concat(Q).sort(nx),jC(M,I.id,Q.id,Ei(ke(E,"event-viewpoints"))),I.id!==Q.id&&(c={kind:"event",id:Q.id}),M}function Et(_,M){let E=st(i),I=B?.querySelector("form[data-editor-form='event-pose']"),j=E.events.find(ze=>ze.id===_),Q=j?.positions.find(ze=>ze.objectId===M);if(!I||!j||!Q)return E;let Se={objectId:Kt(I,"pose-object-id")||Q.objectId,placement:bC(I,Q),epoch:ke(I,"pose-epoch"),referencePlane:ke(I,"pose-referencePlane")},Le=ei(ke(I,"prop-inner")),Ge=ei(ke(I,"prop-outer"));return Le&&(Se.inner=Le),Ge&&(Se.outer=Ge),j.positions=j.positions.filter(ze=>ze.objectId!==Q.objectId).concat(Se).sort(Zu),j.targetObjectId!==Se.objectId&&!j.participantObjectIds.includes(Se.objectId)&&(j.participantObjectIds.push(Se.objectId),j.participantObjectIds.sort((ze,mt)=>ze.localeCompare(mt))),Q.objectId!==Se.objectId&&(c={kind:"event-pose",id:_,key:Se.objectId}),E}function Kr(_){let M=st(i),E=B?.querySelector("form[data-editor-form='annotation']"),I=M.system?.annotations.find(ge=>ge.id===_);if(!E||!I||!M.system)return M;let j=Kt(E,"annotation-id")||I.id,Q={...I,id:j,label:Kt(E,"annotation-label")||I.label,targetObjectId:ke(E,"annotation-target"),body:ke(E,"annotation-body")??"",tags:Ei(ke(E,"annotation-tags")),sourceObjectId:ke(E,"annotation-source")};return M.system.annotations=M.system.annotations.filter(ge=>ge.id!==I.id).concat(Q).sort((ge,Se)=>ge.id.localeCompare(Se.id)),I.id!==Q.id&&(c={kind:"annotation",id:Q.id}),M}function rr(_){let M=st(i),E=B?.querySelector("form[data-editor-form='object']"),I=M.objects.find(Le=>Le.id===_);if(!E||!I)return M;let j=Kt(E,"object-id")||I.id,Q={...I,id:j,type:Kt(E,"object-type")||I.type,properties:{...I.properties},info:{...I.info},placement:xC(E,I)};for(let Le of eC)Wu(Q.properties,Le,ke(E,`prop-${Le}`));for(let Le of tC)Wu(Q.properties,Le,_C(ke(E,`prop-${Le}`)));for(let Le of nC)Wu(Q.properties,Le,ir(ke(E,`prop-${Le}`)));Wu(Q.properties,"tags",Ei(ke(E,"prop-tags"))),Q.properties.hidden=Kn(E,"prop-hidden");let ge=ke(E,"info-description");ge?Q.info.description=ge:delete Q.info.description;let Se=AC(M,I.id,Q);return I.id!==Q.id&&(c={kind:"object",id:Q.id}),Se}function Fn(){let _=a.filter(I=>I.diagnostic.severity==="error").length,M=a.filter(I=>I.diagnostic.severity==="warning").length,E=c?Xu(c):"Nothing selected";J.innerHTML=`
4148
4148
  <span class="wo-editor-status-pill${p?" is-dirty":" is-clean"}">${p?"Unsaved changes":"Saved"}</span>
4149
4149
  <span class="wo-editor-status-pill">Schema ${Xe(i.version)}</span>
4150
4150
  <span class="wo-editor-status-pill${_>0?" is-error":M>0?" is-warning":""}">${_} errors \xB7 ${M} warnings</span>
4151
4151
  <span class="wo-editor-status-pill">${Xe(E)}</span>
4152
- `}function An(){let _=a.filter(E=>E.diagnostic.severity==="error").length,M=a.filter(E=>E.diagnostic.severity==="warning").length;ae.textContent=`${p?"Unsaved changes.":"Saved."} ${_} errors, ${M} warnings. ${c?Gu(c):"Nothing selected"}.`}function sr(){g===null&&(g=window.setTimeout(()=>{g=null,Fn()},J2))}function Fn(){if(!fe)return;let _=fe.exportSvg();ce&&_!==m&&(ce.innerHTML=_,m=_);let M=tx(Pe(),i,F);Me&&M!==x&&(Me.textContent=M,x=M)}function or(_){if(!fe)return;let M=fe.getObjectDetails(_);if(!M)return;let E=Ao(fe.getScene(),fe.getState()),I=36/Math.max(fe.getState().scale,.001),j=M.renderObject;(j.x<E.minX+I||j.x>E.maxX-I||j.y<E.minY+I||j.y>E.maxY-I)&&fe.fitToSystem()}function Zr(_){let M=_.target;if(!M)return!1;let E=M.tagName.toLowerCase();return M.isContentEditable||E==="input"||E==="textarea"||E==="select"}function ar(_,M){if(!_)return[];let E=Ti(_);return M.filter(I=>{let j=Ti(I.path);return j&&j===E?!0:_.kind==="object"&&I.diagnostic.objectId===_.id})}function L(_,M){return ar(_,M).filter(E=>{let I=E.diagnostic.field??"";return $p.has(I)||E.diagnostic.message.toLowerCase().includes("placement")||E.diagnostic.message.toLowerCase().includes("orbit")||E.diagnostic.message.toLowerCase().includes("surface")||E.diagnostic.message.toLowerCase().includes("lagrange")||E.diagnostic.message.toLowerCase().includes("anchor")})}function $(_,M){let E=ar(_,M);return E.length===0?"":`<div class="wo-editor-inspector-summary">
4152
+ `}function Tn(){let _=a.filter(E=>E.diagnostic.severity==="error").length,M=a.filter(E=>E.diagnostic.severity==="warning").length;ae.textContent=`${p?"Unsaved changes.":"Saved."} ${_} errors, ${M} warnings. ${c?Xu(c):"Nothing selected"}.`}function sr(){g===null&&(g=window.setTimeout(()=>{g=null,kn()},J2))}function kn(){if(!fe)return;let _=fe.exportSvg();ce&&_!==m&&(ce.innerHTML=_,m=_);let M=tx(Pe(),i,F);Me&&M!==x&&(Me.textContent=M,x=M)}function or(_){if(!fe)return;let M=fe.getObjectDetails(_);if(!M)return;let E=Ao(fe.getScene(),fe.getState()),I=36/Math.max(fe.getState().scale,.001),j=M.renderObject;(j.x<E.minX+I||j.x>E.maxX-I||j.y<E.minY+I||j.y>E.maxY-I)&&fe.fitToSystem()}function Qr(_){let M=_.target;if(!M)return!1;let E=M.tagName.toLowerCase();return M.isContentEditable||E==="input"||E==="textarea"||E==="select"}function ar(_,M){if(!_)return[];let E=Ti(_);return M.filter(I=>{let j=Ti(I.path);return j&&j===E?!0:_.kind==="object"&&I.diagnostic.objectId===_.id})}function L(_,M){return ar(_,M).filter(E=>{let I=E.diagnostic.field??"";return $p.has(I)||E.diagnostic.message.toLowerCase().includes("placement")||E.diagnostic.message.toLowerCase().includes("orbit")||E.diagnostic.message.toLowerCase().includes("surface")||E.diagnostic.message.toLowerCase().includes("lagrange")||E.diagnostic.message.toLowerCase().includes("anchor")})}function $(_,M){let E=ar(_,M);return E.length===0?"":`<div class="wo-editor-inspector-summary">
4153
4153
  ${E.slice(0,4).map(I=>`<article class="wo-editor-diagnostic wo-editor-diagnostic-${Xe(I.diagnostic.severity)}">
4154
4154
  <strong>${Xe(I.diagnostic.severity.toUpperCase())}</strong>
4155
- <span>${Xe(I.diagnostic.field??Gu(_))}</span>
4155
+ <span>${Xe(I.diagnostic.field??Xu(_))}</span>
4156
4156
  <p>${Xe(I.diagnostic.message)}</p>
4157
4157
  </article>`).join("")}
4158
- </div>`}function b(_,M){if(!B||!_)return;let E=ar(_,M),I=new Map;for(let j of E)for(let Q of BC(_,j.diagnostic.field)){let ge=I.get(Q)??[];ge.push(j),I.set(Q,ge)}for(let[j,Q]of I){let ge=B.querySelector(`[name="${CSS.escape(j)}"]`),Se=ge?.closest(".wo-editor-field, .wo-editor-checkbox");if(!ge||!Se)continue;let Le=Q.some(mt=>mt.diagnostic.severity==="error"),Ge=Q.some(mt=>mt.diagnostic.severity==="warning");Se.classList.add(Le?"has-error":"has-warning"),ge.setAttribute("aria-invalid",Le?"true":"false");let ze=document.createElement("div");ze.className=`wo-editor-field-note${Le?" is-error":Ge?" is-warning":""}`,ze.textContent=Q[0]?.diagnostic.message??"",Se.append(ze)}}}function rC(n){if(n.atlasDocument){let t=st(n.atlasDocument);return{atlasDocument:t,source:tr(t),diagnostics:nr(t)}}if(n.source){let t=So(n.source);if(t.ok&&t.value){let i=t.value.atlasDocument??ur(t.value.document);return{atlasDocument:i,source:tr(i),diagnostics:cx(Mo(i,t.diagnostics),nr(i))}}}let e=vc("WorldOrbit");return{atlasDocument:e,source:tr(e),diagnostics:nr(e)}}function tr(n){return hc(n,{schema:n.version})}function sC(){let n=lC();return`<section class="wo-editor-shell">
4158
+ </div>`}function b(_,M){if(!B||!_)return;let E=ar(_,M),I=new Map;for(let j of E)for(let Q of BC(_,j.diagnostic.field)){let ge=I.get(Q)??[];ge.push(j),I.set(Q,ge)}for(let[j,Q]of I){let ge=B.querySelector(`[name="${CSS.escape(j)}"]`),Se=ge?.closest(".wo-editor-field, .wo-editor-checkbox");if(!ge||!Se)continue;let Le=Q.some(mt=>mt.diagnostic.severity==="error"),Ge=Q.some(mt=>mt.diagnostic.severity==="warning");Se.classList.add(Le?"has-error":"has-warning"),ge.setAttribute("aria-invalid",Le?"true":"false");let ze=document.createElement("div");ze.className=`wo-editor-field-note${Le?" is-error":Ge?" is-warning":""}`,ze.textContent=Q[0]?.diagnostic.message??"",Se.append(ze)}}}function rC(n){if(n.atlasDocument){let t=st(n.atlasDocument);return{atlasDocument:t,source:tr(t),diagnostics:nr(t)}}if(n.source){let t=Eo(n.source);if(t.ok&&t.value){let i=t.value.atlasDocument??ur(t.value.document);return{atlasDocument:i,source:tr(i),diagnostics:cx(So(i,t.diagnostics),nr(i))}}}let e=vc("WorldOrbit");return{atlasDocument:e,source:tr(e),diagnostics:nr(e)}}function tr(n){return hc(n,{schema:n.version})}function sC(){let n=lC();return`<section class="wo-editor-shell">
4159
4159
  <div class="wo-editor-toolbar" data-editor-toolbar></div>
4160
4160
  <div class="wo-editor-status" data-editor-status role="status" aria-live="polite"></div>
4161
4161
  <div class="wo-editor-main">
@@ -4206,7 +4206,7 @@ void main() {
4206
4206
  </details>`}function kt(n,e,t,i,r=!1){let s=cC(n,e);return`<details class="wo-editor-inspector-section" data-editor-form-section="${Xe(e)}" data-editor-form-id="${Xe(n)}" data-editor-section-state="${Xe(s)}"${r?" open":""}>
4207
4207
  <summary><span>${Xe(t)}</span></summary>
4208
4208
  <div class="wo-editor-inspector-section-body">${i}</div>
4209
- </details>`}function Xu(n,e){return`<span class="wo-editor-field-label">${Xe(n)}${oC(e)}</span>`}function oC(n){let e=iC[n];return e?`<details class="wo-editor-field-help">
4209
+ </details>`}function Yu(n,e){return`<span class="wo-editor-field-label">${Xe(n)}${oC(e)}</span>`}function oC(n){let e=iC[n];return e?`<details class="wo-editor-field-help">
4210
4210
  <summary aria-label="Explain ${dx(n)}">?</summary>
4211
4211
  <div class="wo-editor-field-help-card">
4212
4212
  <p>${Xe(e.description)}</p>
@@ -4214,17 +4214,17 @@ void main() {
4214
4214
  </div>
4215
4215
  </details>`:""}function aC(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;i&&e.set(i,t.open)}}function Ki(n,e){for(let t of n.querySelectorAll("[data-editor-section-state]")){let i=t.dataset.editorSectionState;!i||!e.has(i)||(t.open=e.get(i)===!0)}}function cC(n,e){return`${n}:${e}`}function lC(){return typeof window>"u"?!0:typeof window.matchMedia=="function"?!window.matchMedia("(max-width: 1280px)").matches:window.innerWidth>1280}function Ai(n,e,t,i){let r=Ti(n),s=r?i.get(r):null,o=s&&(s.errors>0||s.warnings>0)?`<span class="wo-editor-outline-badge${s.errors>0?" is-error":" is-warning"}">${s.errors>0?s.errors:s.warnings}</span>`:"";return`<button type="button" class="wo-editor-outline-item${r===t?" is-active":""}" data-path-kind="${Xe(n.kind)}"${n.id?` data-path-id="${Xe(n.id)}"`:""}${n.key?` data-path-key="${Xe(n.key)}"`:""}><span>${Xe(e)}</span>${o}</button>`}function uC(n,e,t){return`<div class="wo-editor-outline-group">
4216
4216
  ${Ai({kind:"event",id:n.id},n.label||n.id,e,t)}
4217
- ${n.positions.length>0?`<div class="wo-editor-outline-children">${[...n.positions].sort(qu).map(i=>Ai({kind:"event-pose",id:n.id,key:i.objectId},i.objectId,e,t)).join("")}</div>`:""}
4217
+ ${n.positions.length>0?`<div class="wo-editor-outline-children">${[...n.positions].sort(Zu).map(i=>Ai({kind:"event-pose",id:n.id,key:i.objectId},i.objectId,e,t)).join("")}</div>`:""}
4218
4218
  </div>`}function dC(n){return`<form class="wo-editor-form" data-editor-form="system">
4219
4219
  <h2>System</h2>
4220
4220
  ${kt("system","basics","Basics",`${be("System ID","system-id",n.system?.id??"")}
4221
4221
  ${be("Title","system-title",n.system?.title??"")}`,!0)}
4222
4222
  </form>`}function hC(n){let e=n.system?.defaults;return`<form class="wo-editor-form" data-editor-form="defaults">
4223
4223
  <h2>Defaults</h2>
4224
- ${kt("defaults","basics","Basics",`${qr("Projection","defaults-view",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],e?.view??"topdown")}
4224
+ ${kt("defaults","basics","Basics",`${Jr("Projection","defaults-view",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],e?.view??"topdown")}
4225
4225
  ${be("Scale preset","defaults-scale",e?.scale??"")}
4226
4226
  ${be("Units","defaults-units",e?.units??"")}
4227
- ${qr("Render preset","defaults-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],e?.preset??"")}
4227
+ ${Jr("Render preset","defaults-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],e?.preset??"")}
4228
4228
  ${be("Theme","defaults-theme",e?.theme??"")}`,!0)}
4229
4229
  </form>`}function fC(n,e){let t=n.system?.atlasMetadata[e]??"";return`<form class="wo-editor-form" data-editor-form="metadata">
4230
4230
  <h2>Metadata</h2>
@@ -4237,8 +4237,8 @@ void main() {
4237
4237
  ${Xa("Summary","viewpoint-summary",t.summary)}
4238
4238
  ${be("Focus object","viewpoint-focus",t.focusObjectId??"")}
4239
4239
  ${be("Selected object","viewpoint-select",t.selectedObjectId??"")}
4240
- ${qr("Projection","viewpoint-projection",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],t.projection)}
4241
- ${qr("Preset","viewpoint-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],t.preset??"")}
4240
+ ${Jr("Projection","viewpoint-projection",[["topdown","Topdown"],["isometric","Isometric"],["orthographic","Orthographic"],["perspective","Perspective"]],t.projection)}
4241
+ ${Jr("Preset","viewpoint-preset",[["","Document default"],["diagram","Diagram"],["presentation","Presentation"],["atlas-card","Atlas Card"],["markdown","Markdown"]],t.preset??"")}
4242
4242
  ${be("Zoom","viewpoint-zoom",t.zoom===null?"":String(t.zoom))}
4243
4243
  ${be("Rotation","viewpoint-rotation",String(t.rotationDeg))}`,!0)}
4244
4244
  ${kt("viewpoint","camera","Camera",`${be("Azimuth","viewpoint-camera-azimuth",t.camera?.azimuth===null||t.camera?.azimuth===void 0?"":String(t.camera.azimuth))}
@@ -4248,14 +4248,14 @@ void main() {
4248
4248
  <p class="wo-editor-inline-note">Rotation stays a 2D screen-rotation hint. The camera block stores Schema 2.5 view direction and framing.</p>`)}
4249
4249
  ${kt("viewpoint","layers","Layers",`<fieldset class="wo-editor-fieldset">
4250
4250
  <legend>Layers</legend>
4251
- ${Kn("Background","layer-background",t.layers.background!==!1)}
4252
- ${Kn("Guides","layer-guides",t.layers.guides!==!1)}
4253
- ${Kn("Orbits back","layer-orbits-back",t.layers["orbits-back"]!==!1)}
4254
- ${Kn("Orbits front","layer-orbits-front",t.layers["orbits-front"]!==!1)}
4255
- ${Kn("Events","layer-events",t.layers.events!==!1)}
4256
- ${Kn("Objects","layer-objects",t.layers.objects!==!1)}
4257
- ${Kn("Labels","layer-labels",t.layers.labels!==!1)}
4258
- ${Kn("Metadata","layer-metadata",t.layers.metadata!==!1)}
4251
+ ${Qn("Background","layer-background",t.layers.background!==!1)}
4252
+ ${Qn("Guides","layer-guides",t.layers.guides!==!1)}
4253
+ ${Qn("Orbits back","layer-orbits-back",t.layers["orbits-back"]!==!1)}
4254
+ ${Qn("Orbits front","layer-orbits-front",t.layers["orbits-front"]!==!1)}
4255
+ ${Qn("Events","layer-events",t.layers.events!==!1)}
4256
+ ${Qn("Objects","layer-objects",t.layers.objects!==!1)}
4257
+ ${Qn("Labels","layer-labels",t.layers.labels!==!1)}
4258
+ ${Qn("Metadata","layer-metadata",t.layers.metadata!==!1)}
4259
4259
  </fieldset>`)}
4260
4260
  ${kt("viewpoint","filter","Filter",`${be("Filter query","filter-query",t.filter?.query??"")}
4261
4261
  ${be("Filter object types","filter-object-types",t.filter?.objectTypes.join(" ")??"")}
@@ -4276,7 +4276,7 @@ void main() {
4276
4276
  ${be("Reference plane","event-referencePlane",t.referencePlane??"")}
4277
4277
  ${be("Tags","event-tags",t.tags.join(" "))}
4278
4278
  ${be("Color","event-color",t.color??"")}
4279
- ${Kn("Hidden","event-hidden",t.hidden===!0)}`,!0)}
4279
+ ${Qn("Hidden","event-hidden",t.hidden===!0)}`,!0)}
4280
4280
  ${kt("event","viewpoints","Viewpoints",`${be("Viewpoints","event-viewpoints",i)}`)}
4281
4281
  ${kt("event","positions","Positions",`${t.positions.length>0?`<div class="wo-editor-inline-list">${t.positions.map(r=>Ai({kind:"event-pose",id:t.id,key:r.objectId},r.objectId,null,new Map)).join("")}</div>`:'<p class="wo-editor-empty">No event poses yet.</p>'}
4282
4282
  <div class="wo-editor-inline-actions">
@@ -4289,7 +4289,7 @@ void main() {
4289
4289
  <div class="wo-editor-inline-actions">
4290
4290
  <button type="button" data-path-kind="event" data-path-id="${Xe(i.id)}">Select event</button>
4291
4291
  </div>`,!0)}
4292
- ${kt("event-pose","placement","Placement",`${qr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],s)}
4292
+ ${kt("event-pose","placement","Placement",`${Jr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],s)}
4293
4293
  ${be("Placement target","placement-target",o)}
4294
4294
  ${be("Free value","placement-free",a)}
4295
4295
  ${be("Distance","placement-distance",r.placement?.mode==="orbit"&&r.placement.distance?Vt(r.placement.distance):"")}
@@ -4315,8 +4315,8 @@ void main() {
4315
4315
  </form>`:'<p class="wo-editor-empty">Annotation not found.</p>'}function vC(n,e){let t=n.objects.find(o=>o.id===e);if(!t)return'<p class="wo-editor-empty">Object not found.</p>';let i=t.placement?.mode??"",r=t.placement?.mode==="orbit"||t.placement?.mode==="surface"||t.placement?.mode==="at"?t.placement.target:"",s=t.placement?.mode==="free"?t.placement.distance?Vt(t.placement.distance):t.placement.descriptor??"":"";return`<form class="wo-editor-form" data-editor-form="object">
4316
4316
  <h2>Object</h2>
4317
4317
  ${kt("object","identity","Identity",`${be("ID","object-id",t.id)}
4318
- ${qr("Type","object-type",Gp.map(o=>[o,Ga(o)]),t.type)}`,!0)}
4319
- ${kt("object","placement","Placement",`${qr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],i)}
4318
+ ${Jr("Type","object-type",Gp.map(o=>[o,Ga(o)]),t.type)}`,!0)}
4319
+ ${kt("object","placement","Placement",`${Jr("Placement mode","placement-mode",[["","None"],["orbit","Orbit"],["at","At"],["surface","Surface"],["free","Free"]],i)}
4320
4320
  ${be("Placement target","placement-target",r)}
4321
4321
  ${be("Free value","placement-free",s)}
4322
4322
  ${be("Distance","placement-distance",t.placement?.mode==="orbit"&&t.placement.distance?Vt(t.placement.distance):"")}
@@ -4334,7 +4334,7 @@ void main() {
4334
4334
  ${be("Tags","prop-tags",GC(t.properties.tags))}
4335
4335
  ${be("Color","prop-color",Qi(t.properties.color))}
4336
4336
  ${be("Image","prop-image",Qi(t.properties.image))}
4337
- ${Kn("Hidden","prop-hidden",t.properties.hidden===!0)}
4337
+ ${Qn("Hidden","prop-hidden",t.properties.hidden===!0)}
4338
4338
  ${be("Radius","prop-radius",er(t.properties.radius))}
4339
4339
  ${be("Mass","prop-mass",er(t.properties.mass))}
4340
4340
  ${be("Density","prop-density",er(t.properties.density))}
@@ -4349,7 +4349,7 @@ void main() {
4349
4349
  ${be("Cycle","prop-cycle",er(t.properties.cycle))}
4350
4350
  </fieldset>`)}
4351
4351
  ${kt("object","info","Info",`${Xa("Description","info-description",t.info.description??"")}`)}
4352
- </form>`}function be(n,e,t){return`<label class="wo-editor-field">${Xu(n,e)}<input name="${Xe(e)}" value="${dx(t)}" /></label>`}function Xa(n,e,t){return`<label class="wo-editor-field">${Xu(n,e)}<textarea name="${Xe(e)}">${Xe(t)}</textarea></label>`}function qr(n,e,t,i){return`<label class="wo-editor-field">${Xu(n,e)}<select name="${Xe(e)}">${t.map(([r,s])=>`<option value="${Xe(r)}"${r===i?" selected":""}>${Xe(s)}</option>`).join("")}</select></label>`}function Kn(n,e,t){return`<label class="wo-editor-checkbox"><input type="checkbox" name="${Xe(e)}"${t?" checked":""} />${Xu(n,e)}</label>`}function Ha(n,e,t,i){let r=document.createElement("button");return r.type="button",r.className="wo-editor-handle",r.dataset.handleKind=n,r.dataset.objectId=e,r.style.left=`${t.x}px`,r.style.top=`${t.y}px`,r.textContent=i,r}function Kt(n,e){return n.elements.namedItem(e)?.value.trim()??""}function ke(n,e){let t=Kt(n,e);return t||null}function Jn(n,e){return n.elements.namedItem(e)?.checked??!1}function xC(n,e){return ax(n,e.placement,e.id)}function bC(n,e){return ax(n,e.placement,e.objectId)}function ax(n,e,t){let i=Kt(n,"placement-mode"),r=ke(n,"placement-target");switch(i){case"orbit":return{mode:i,target:r??(e?.mode==="orbit"?e.target:t),distance:Qn(ke(n,"placement-distance")),semiMajor:Qn(ke(n,"placement-semiMajor")),eccentricity:ir(ke(n,"placement-eccentricity"))??void 0,period:Qn(ke(n,"placement-period")),angle:Qn(ke(n,"placement-angle")),inclination:Qn(ke(n,"placement-inclination")),phase:Qn(ke(n,"placement-phase"))};case"at":return{mode:i,target:r??t,reference:Wa(r??t)};case"surface":return{mode:i,target:r??t};case"free":{let s=ke(n,"placement-free"),o=Qn(s);return{mode:i,distance:o??void 0,descriptor:o?void 0:s??void 0}}default:return null}}function ju(n,e,t){let i=Array.isArray(t)&&t.length===0;if(t==null||i||t===""){delete n[e];return}n[e]=t}function _C(n){return n?Qn(n)??n:null}function Qn(n){if(!n)return;let e=n.match(/^(-?\d+(?:\.\d+)?)(au|km|re|sol|me|d|y|h|deg)?$/);if(e)return{value:Number(e[1]),unit:e[2]??null}}function ir(n){if(!n)return null;let e=Number(n);return Number.isFinite(e)?e:null}function wC(n){let e={azimuth:ir(ke(n,"viewpoint-camera-azimuth")),elevation:ir(ke(n,"viewpoint-camera-elevation")),roll:ir(ke(n,"viewpoint-camera-roll")),distance:ir(ke(n,"viewpoint-camera-distance"))};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function MC(n){return Ei(n).filter(t=>Gp.includes(t))}function Ei(n){return n?.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)??[]}function SC(n,e,t){let i=t.objects.find(r=>r.type==="star")?.id??t.objects[0]?.id??e;return{type:n,id:e,properties:{},placement:n==="structure"||n==="phenomenon"?{mode:"at",target:`${i}:L4`,reference:Wa(`${i}:L4`)}:{mode:"orbit",target:i,distance:{value:1,unit:"au"}},info:{}}}function EC(n,e){let t=st(n);return t.objects=t.objects.filter(i=>i.id!==e.id).concat(e).sort(lx),t}function AC(n,e,t){let i=st(n);return i.objects=i.objects.filter(r=>r.id!==e).concat(t).sort(lx),e!==t.id&&TC(i,e,t.id),i}function TC(n,e,t){for(let i of n.objects)if(i.id!==t&&(i.placement?.mode==="orbit"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="surface"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="at")){let r=i.placement.reference;r.kind==="anchor"&&r.objectId===e&&(r.objectId=t),r.kind==="lagrange"&&(r.primary===e&&(r.primary=t),r.secondary===e&&(r.secondary=t)),i.placement.target=Hp(r)}for(let i of n.system?.viewpoints??[])i.focusObjectId===e&&(i.focusObjectId=t),i.selectedObjectId===e&&(i.selectedObjectId=t);for(let i of n.system?.annotations??[])i.targetObjectId===e&&(i.targetObjectId=t),i.sourceObjectId===e&&(i.sourceObjectId=t);for(let i of n.events){i.targetObjectId===e&&(i.targetObjectId=t),i.participantObjectIds=i.participantObjectIds.map(r=>r===e?t:r);for(let r of i.positions)if(r.objectId===e&&(r.objectId=t),r.placement?.mode==="orbit"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="surface"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="at"){let s=r.placement.reference;s.kind==="anchor"&&s.objectId===e&&(s.objectId=t),s.kind==="lagrange"&&(s.primary===e&&(s.primary=t),s.secondary===e&&(s.secondary=t)),r.placement.target=Hp(s)}i.positions.sort(qu)}}function IC(n,e){let t=wd(n,e);if(e.kind==="event"&&e.id){for(let i of t.system?.viewpoints??[])i.events=i.events.filter(r=>r!==e.id);return t}if(e.kind!=="object"||!e.id)return t;for(let i of t.objects)if(i.placement?.mode==="orbit"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="surface"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="at"){let r=i.placement.reference;(r.kind==="anchor"&&r.objectId===e.id||r.kind==="lagrange"&&(r.primary===e.id||r.secondary===e.id))&&(i.placement=null)}for(let i of t.system?.viewpoints??[])i.focusObjectId===e.id&&(i.focusObjectId=null),i.selectedObjectId===e.id&&(i.selectedObjectId=null);for(let i of t.system?.annotations??[])i.targetObjectId===e.id&&(i.targetObjectId=null),i.sourceObjectId===e.id&&(i.sourceObjectId=null);for(let i of t.events){i.targetObjectId===e.id&&(i.targetObjectId=null),i.participantObjectIds=i.participantObjectIds.filter(r=>r!==e.id),i.positions=i.positions.filter(r=>r.objectId!==e.id);for(let r of i.positions)if(r.placement?.mode==="orbit"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="surface"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="at"){let s=r.placement.reference;(s.kind==="anchor"&&s.objectId===e.id||s.kind==="lagrange"&&(s.primary===e.id||s.secondary===e.id))&&(r.placement=null)}}return t}function qa(n,e,t){if(e.kind==="event-pose"&&e.id&&e.key){let r=ux(n,e.id,e.key);return r?.placement?{placement:r.placement}:null}let i=VC(n,t);return i?.placement?{placement:i.placement}:null}function CC(n,e,t,i,r){let s=i.orbit;if(!s||i.object.placement?.mode!=="orbit")return n;let o=rn(r,{x:s.cx,y:s.cy},-s.rotationDeg),a=s.kind==="circle"?s.radius??1:s.rx??1,c=s.kind==="circle"?s.radius??1:s.ry??1,l=Math.atan2((o.y-s.cy)/Math.max(c,1),(o.x-s.cx)/Math.max(a,1)),u=qC(l*180/Math.PI),d=st(n),h=qa(d,e,t);return!h||h.placement.mode!=="orbit"?n:(h.placement.phase={value:no(u,2),unit:"deg"},d)}function RC(n,e,t,i,r,s,o){let a=r.orbit;if(!a||r.object.placement?.mode!=="orbit"||!o)return n;let c=rn(s,{x:a.cx,y:a.cy},-a.rotationDeg),l=Math.max(Math.abs(c.x-a.cx),24),u=Math.max(l-o.radiusOffsetPx,o.innerPx),d=KC(u,o.innerPx,o.stepPx,o.mode,o.pixelsPerMetric),h=st(n),f=qa(h,e,t);if(!f||f.placement.mode!=="orbit")return n;let p=f,y=p.placement.semiMajor??p.placement.distance??{value:1,unit:"au"},g=jp(Math.max(d,0),o.preferredUnit??y.unit);Qv(p,g);let m=l,x=d;for(let v=0;v<3;v+=1){let N=Gt(ns(h),{width:i.width,height:i.height,padding:i.padding,preset:i.renderPreset??void 0,projection:i.projection,camera:i.camera,scaleModel:{...i.scaleModel},bodyScaleMode:i.scaleModel.bodyScaleMode,activeEventId:i.activeEventId}).orbitVisuals.find(F=>F.objectId===t),C=N?.kind==="circle"?N.radius??0:N?.rx??0;if(C>=m-1)break;let R=m/Math.max(C,1);x*=Math.max(R,1.02),Qv(p,jp(Math.max(x,0),o.preferredUnit??y.unit))}return h}function Qv(n,e){n.placement.semiMajor?n.placement.semiMajor=e:n.placement.distance=e}function PC(n,e,t,i,r){let s=NC(i,t,r);if(!s)return n;let o=st(n),a=qa(o,e,t);return!a||a.placement.mode!=="at"?n:(a.placement.reference=s.reference,a.placement.target=Hp(s.reference),o)}function LC(n,e,t,i,r){let s=UC(i,t,r,c=>Q2.has(c.object.type));if(!s)return n;let o=st(n),a=qa(o,e,t);return!a||a.placement.mode!=="surface"?n:(a.placement.target=s.objectId,o)}function DC(n,e,t){if(t.object.placement?.mode!=="orbit"||!t.orbit||!t.parent)return null;let i=t.object.placement.target,r=e.objects.filter(y=>y.object.placement?.mode==="orbit"&&y.object.placement.target===i&&!y.hidden).length,s=QC(e.layoutPreset),o=(r>2?54:64)*s*e.scaleModel.orbitDistanceMultiplier,a=e.scaleModel.bodyScaleMode==="strict"?Math.max(2,8*s*e.scaleModel.orbitDistanceMultiplier):o*.42,c=t.parent.radius+Math.max(a*1.2,24*s),l=t.object.placement.semiMajor??t.object.placement.distance??null,u=ZC(l),d=t.orbit.kind==="circle"?t.orbit.radius??1:t.orbit.rx??1,h=u!==null&&u>0,f=h?d/Math.max(u,1e-4):null,p=h?u*Math.max(f??0,0):JC(u??0,c,o);return{mode:h?"linear":"log",innerPx:c,stepPx:o,pixelsPerMetric:f,radiusOffsetPx:d-p,preferredUnit:l?.unit??null}}function OC(n,e,t,i,r,s){if(r.object.placement?.mode!=="free")return n;let o=i.width-i.padding-140,a=Math.max(0,o-s.x),c=st(n),l=qa(c,e,t);if(!l||l.placement.mode!=="free")return n;let u=YC(l.placement.distance?.unit??null),d=a/Math.max(K2*i.scaleModel.freePlacementMultiplier,1);return d<.01?(l.placement.distance=void 0,l.placement.descriptor||delete l.placement.descriptor,c):(l.placement.distance=jp(d,u),delete l.placement.descriptor,c)}function UC(n,e,t,i=()=>!0){let r=null,s=Number.POSITIVE_INFINITY;for(let o of n.objects){if(o.hidden||o.objectId===e||!i(o))continue;let a=Math.hypot(t.x-o.x,t.y-o.y);a<s&&(r=o,s=a)}return s<=140?r:null}function NC(n,e,t){let i=null;for(let a of n.objects){if(a.hidden||a.objectId===e)continue;let c=Math.hypot(t.x-a.x,t.y-a.y),l=Math.max(a.visualRadius+16,28);c<=l&&(!i||c<i.distance)&&(i={reference:Wa(a.objectId),x:a.x,y:a.y,distance:c})}if(i)return{reference:i.reference,x:i.x,y:i.y};let r=[];for(let a of n.objects)a.hidden||a.objectId===e||r.push({reference:Wa(a.objectId),x:a.x,y:a.y});for(let a of n.orbitVisuals){if(a.hidden||a.objectId===e)continue;let c=n.objects.find(u=>u.objectId===a.parentId&&!u.hidden),l=n.objects.find(u=>u.objectId===a.objectId&&!u.hidden);if(!(!c||!l))for(let u of["L1","L2","L3","L4","L5"]){let d=FC(c,l,u);r.push({reference:Wa(`${a.objectId}:${u}`),x:d.x,y:d.y})}}let s=null,o=Number.POSITIVE_INFINITY;for(let a of r){let c=Math.hypot(t.x-a.x,t.y-a.y);c<o&&(s=a,o=c)}return o<=140?s:null}function FC(n,e,t){let i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r)||1,o=i/s,a=r/s,c=-a,l=o,u=XC(s*.25,24,68);switch(t){case"L1":return{x:e.x-o*u,y:e.y-a*u};case"L2":return{x:e.x+o*u,y:e.y+a*u};case"L3":return{x:n.x-o*u,y:n.y-a*u};case"L4":return{x:e.x+(o*.5-c*.8660254)*u,y:e.y+(a*.5-l*.8660254)*u};case"L5":return{x:e.x+(o*.5+c*.8660254)*u,y:e.y+(a*.5+l*.8660254)*u}}}function Wa(n){let e=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(e)return{kind:"lagrange",primary:e[1],secondary:e[2],point:e[3]};let t=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:null,point:t[2]};let i=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return i?{kind:"anchor",objectId:i[1],anchor:i[2]}:{kind:"named",name:n}}function Hp(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function nr(n){return Md(n)}function cx(n,e){let t=new Set,i=[];for(let r of[...n,...e]){let s=`${r.diagnostic.code}:${r.diagnostic.message}:${Ti(r.path)}`;t.has(s)||(t.add(s),i.push(Wu(r)))}return i}function kC(n){let e=new Map;for(let t of n){let i=Ti(t.path)??(t.diagnostic.objectId?Ti({kind:"object",id:t.diagnostic.objectId}):null);if(!i)continue;let r=e.get(i)??{errors:0,warnings:0};t.diagnostic.severity==="error"?r.errors+=1:t.diagnostic.severity==="warning"&&(r.warnings+=1),e.set(i,r)}return e}function ex(n){return n.diagnostic.line!==void 0&&n.diagnostic.column!==void 0?`Line ${n.diagnostic.line}:${n.diagnostic.column}`:n.diagnostic.line!==void 0?`Line ${n.diagnostic.line}`:null}function BC(n,e){if(!e)return[];switch(n.kind){case"system":return e==="id"?["system-id"]:e==="title"?["system-title"]:[];case"defaults":switch(e){case"view":return["defaults-view"];case"scale":return["defaults-scale"];case"units":return["defaults-units"];case"preset":return["defaults-preset"];case"theme":return["defaults-theme"];default:return[]}case"metadata":return e==="key"?["metadata-key"]:["metadata-value"];case"group":switch(e){case"id":return["group-id"];case"label":return["group-label"];case"summary":return["group-summary"];case"color":return["group-color"];case"tags":return["group-tags"];case"hidden":return["group-hidden"];default:return[]}case"viewpoint":switch(e){case"id":return["viewpoint-id"];case"label":return["viewpoint-label"];case"summary":return["viewpoint-summary"];case"focusObjectId":return["viewpoint-focus"];case"selectedObjectId":return["viewpoint-select"];case"projection":return["viewpoint-projection"];case"preset":return["viewpoint-preset"];case"zoom":return["viewpoint-zoom"];case"rotationDeg":return["viewpoint-rotation"];case"camera":return["viewpoint-camera-azimuth","viewpoint-camera-elevation","viewpoint-camera-roll","viewpoint-camera-distance"];case"camera.azimuth":return["viewpoint-camera-azimuth"];case"camera.elevation":return["viewpoint-camera-elevation"];case"camera.roll":return["viewpoint-camera-roll"];case"camera.distance":return["viewpoint-camera-distance"];case"events":return["viewpoint-events"];default:return[]}case"event":switch(e){case"id":return["event-id"];case"kind":return["event-kind"];case"label":return["event-label"];case"summary":return["event-summary"];case"targetObjectId":case"target":return["event-target"];case"participantObjectIds":case"participants":return["event-participants"];case"timing":return["event-timing"];case"visibility":return["event-visibility"];case"epoch":return["event-epoch"];case"referencePlane":return["event-referencePlane"];case"tags":return["event-tags"];case"color":return["event-color"];case"hidden":return["event-hidden"];default:return[]}case"event-pose":return e==="objectId"?["pose-object-id"]:e==="placement"?["placement-mode"]:e==="reference"||e==="target"?["placement-target"]:e==="descriptor"?["placement-free"]:$p.has(e)?[`placement-${e}`]:e==="inner"||e==="outer"?[`prop-${e}`]:e==="epoch"?["pose-epoch"]:e==="referencePlane"?["pose-referencePlane"]:[];case"annotation":switch(e){case"id":return["annotation-id"];case"label":return["annotation-label"];case"targetObjectId":return["annotation-target"];case"sourceObjectId":return["annotation-source"];case"body":return["annotation-body"];case"tags":return["annotation-tags"];default:return[]}case"relation":switch(e){case"id":return["relation-id"];case"from":return["relation-from"];case"to":return["relation-to"];case"kind":return["relation-kind"];case"label":return["relation-label"];case"summary":return["relation-summary"];case"tags":return["relation-tags"];case"color":return["relation-color"];case"hidden":return["relation-hidden"];default:return[]}case"object":return e==="id"?["object-id"]:e==="type"?["object-type"]:e==="placement"?["placement-mode"]:e==="description"?["info-description"]:e==="reference"?["placement-target"]:e==="descriptor"?["placement-free"]:e==="target"?["placement-target"]:$p.has(e)?[`placement-${e}`]:[`prop-${e}`]}}function tx(n,e,t){return Va(n,{mode:t==="3d"?"interactive-3d":"interactive-2d",preset:e.system?.defaults.preset??"atlas-card",projection:e.system?.defaults.view??"topdown"})}function Gu(n){switch(n.kind){case"system":return"System";case"defaults":return"Defaults";case"metadata":return`Metadata: ${n.key??""}`;case"group":return`Group: ${n.id??""}`;case"event":return`Event: ${n.id??""}`;case"event-pose":return`Event Pose: ${n.id??""} / ${n.key??""}`;case"object":return`Object: ${n.id??""}`;case"viewpoint":return`Viewpoint: ${n.id??""}`;case"annotation":return`Annotation: ${n.id??""}`;case"relation":return`Relation: ${n.id??""}`}}function Ti(n){return n?`${n.kind}:${n.id??""}:${n.key??""}`:null}function Vp(n){return n&&(n.kind==="event"||n.kind==="event-pose")?n.id??null:null}function lx(n,e){return n.id.localeCompare(e.id)}function nx(n,e){return n.id.localeCompare(e.id)}function qu(n,e){return n.objectId.localeCompare(e.objectId)}function zC(n,e){return n.events.find(t=>t.id===e)??null}function ux(n,e,t){return zC(n,e)?.positions.find(i=>i.objectId===t)??null}function VC(n,e){return n.objects.find(t=>t.id===e)??null}function $C(n,e){let t=st(n),i=t.events.find(s=>s.id===e);if(!i)return n;let r=t.objects.find(s=>!i.positions.some(o=>o.objectId===s.id))??t.objects[0];return r?(i.targetObjectId!==r.id&&!i.participantObjectIds.includes(r.id)&&(i.participantObjectIds.push(r.id),i.participantObjectIds.sort((s,o)=>s.localeCompare(o))),i.positions.push(HC(r)),i.positions.sort(qu),t):n}function HC(n){return{objectId:n.id,placement:n.placement?structuredClone(n.placement):null,inner:ix(n.properties.inner),outer:ix(n.properties.outer)}}function jC(n,e,t,i){let r=new Set(i);for(let s of n.system?.viewpoints??[]){let o=new Set(s.events);o.delete(e),o.delete(t),r.has(s.id)&&o.add(t),s.events=[...o].sort((a,c)=>a.localeCompare(c))}}function ja(n,e){let t=n.trim()||"item",i=1,r=t;for(;e.includes(r);)i+=1,r=`${t}-${i}`;return r}function Ga(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function Wu(n){return{diagnostic:{...n.diagnostic},path:n.path?{...n.path}:null}}function Qi(n){return typeof n=="string"?n:""}function GC(n){return Array.isArray(n)?n.join(" "):""}function er(n){return n&&typeof n=="object"&&"value"in n?Vt(n):""}function ix(n){return n&&typeof n=="object"&&"value"in n?n:void 0}function WC(n){return typeof n=="number"?String(n):""}function Vt(n){return`${n.value}${n.unit??""}`}function no(n,e){let t=10**e;return Math.round(n*t)/t}function XC(n,e,t){return Math.min(Math.max(n,e),t)}function qC(n){let e=n%360;return e<0&&(e+=360),e}function YC(n){switch(n){case"au":case"km":case"re":case"sol":case null:return n;default:return null}}function ZC(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/io;case"re":return n.value*rx/io;case"sol":return n.value*sx/io;default:return n.value}}function jp(n,e){switch(e){case"km":return{value:no(n*io,0),unit:e};case"re":return{value:no(n*io/rx,3),unit:e};case"sol":return{value:no(n*io/sx,4),unit:e};case"au":return{value:no(n,3),unit:e};default:return{value:no(n,2),unit:null}}}function JC(n,e,t){return e+t*eR(Math.max(n,0)+1)}function KC(n,e,t,i,r){return i==="linear"&&r!==null&&r>0?Math.max(n/r,0):n<=e?0:Math.pow(2,(n-e)/Math.max(t,1e-4))-1}function QC(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function eR(n){return Math.log(n)/Math.log(2)}function Xe(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function dx(n){return Xe(n)}function tR(n){if(typeof window>"u"||typeof document>"u")throw new Error("createWorldOrbitEditor can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("WorldOrbit editor requires an HTMLElement container.")}function yn(n,e){let t=n.querySelector(e);if(!t)throw new Error(`WorldOrbit editor failed to initialize selector "${e}".`);return t}function nR(){if(document.getElementById(Kv))return;let n=document.createElement("style");n.id=Kv,n.textContent=`
4352
+ </form>`}function be(n,e,t){return`<label class="wo-editor-field">${Yu(n,e)}<input name="${Xe(e)}" value="${dx(t)}" /></label>`}function Xa(n,e,t){return`<label class="wo-editor-field">${Yu(n,e)}<textarea name="${Xe(e)}">${Xe(t)}</textarea></label>`}function Jr(n,e,t,i){return`<label class="wo-editor-field">${Yu(n,e)}<select name="${Xe(e)}">${t.map(([r,s])=>`<option value="${Xe(r)}"${r===i?" selected":""}>${Xe(s)}</option>`).join("")}</select></label>`}function Qn(n,e,t){return`<label class="wo-editor-checkbox"><input type="checkbox" name="${Xe(e)}"${t?" checked":""} />${Yu(n,e)}</label>`}function Ha(n,e,t,i){let r=document.createElement("button");return r.type="button",r.className="wo-editor-handle",r.dataset.handleKind=n,r.dataset.objectId=e,r.style.left=`${t.x}px`,r.style.top=`${t.y}px`,r.textContent=i,r}function Kt(n,e){return n.elements.namedItem(e)?.value.trim()??""}function ke(n,e){let t=Kt(n,e);return t||null}function Kn(n,e){return n.elements.namedItem(e)?.checked??!1}function xC(n,e){return ax(n,e.placement,e.id)}function bC(n,e){return ax(n,e.placement,e.objectId)}function ax(n,e,t){let i=Kt(n,"placement-mode"),r=ke(n,"placement-target");switch(i){case"orbit":return{mode:i,target:r??(e?.mode==="orbit"?e.target:t),distance:ei(ke(n,"placement-distance")),semiMajor:ei(ke(n,"placement-semiMajor")),eccentricity:ir(ke(n,"placement-eccentricity"))??void 0,period:ei(ke(n,"placement-period")),angle:ei(ke(n,"placement-angle")),inclination:ei(ke(n,"placement-inclination")),phase:ei(ke(n,"placement-phase"))};case"at":return{mode:i,target:r??t,reference:Wa(r??t)};case"surface":return{mode:i,target:r??t};case"free":{let s=ke(n,"placement-free"),o=ei(s);return{mode:i,distance:o??void 0,descriptor:o?void 0:s??void 0}}default:return null}}function Wu(n,e,t){let i=Array.isArray(t)&&t.length===0;if(t==null||i||t===""){delete n[e];return}n[e]=t}function _C(n){return n?ei(n)??n:null}function ei(n){if(!n)return;let e=n.match(/^(-?\d+(?:\.\d+)?)(au|km|re|sol|me|d|y|h|deg)?$/);if(e)return{value:Number(e[1]),unit:e[2]??null}}function ir(n){if(!n)return null;let e=Number(n);return Number.isFinite(e)?e:null}function wC(n){let e={azimuth:ir(ke(n,"viewpoint-camera-azimuth")),elevation:ir(ke(n,"viewpoint-camera-elevation")),roll:ir(ke(n,"viewpoint-camera-roll")),distance:ir(ke(n,"viewpoint-camera-distance"))};return e.azimuth!==null||e.elevation!==null||e.roll!==null||e.distance!==null?e:null}function MC(n){return Ei(n).filter(t=>Gp.includes(t))}function Ei(n){return n?.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)??[]}function SC(n,e,t){let i=t.objects.find(r=>r.type==="star")?.id??t.objects[0]?.id??e;return{type:n,id:e,properties:{},placement:n==="structure"||n==="phenomenon"?{mode:"at",target:`${i}:L4`,reference:Wa(`${i}:L4`)}:{mode:"orbit",target:i,distance:{value:1,unit:"au"}},info:{}}}function EC(n,e){let t=st(n);return t.objects=t.objects.filter(i=>i.id!==e.id).concat(e).sort(lx),t}function AC(n,e,t){let i=st(n);return i.objects=i.objects.filter(r=>r.id!==e).concat(t).sort(lx),e!==t.id&&TC(i,e,t.id),i}function TC(n,e,t){for(let i of n.objects)if(i.id!==t&&(i.placement?.mode==="orbit"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="surface"&&i.placement.target===e&&(i.placement.target=t),i.placement?.mode==="at")){let r=i.placement.reference;r.kind==="anchor"&&r.objectId===e&&(r.objectId=t),r.kind==="lagrange"&&(r.primary===e&&(r.primary=t),r.secondary===e&&(r.secondary=t)),i.placement.target=Hp(r)}for(let i of n.system?.viewpoints??[])i.focusObjectId===e&&(i.focusObjectId=t),i.selectedObjectId===e&&(i.selectedObjectId=t);for(let i of n.system?.annotations??[])i.targetObjectId===e&&(i.targetObjectId=t),i.sourceObjectId===e&&(i.sourceObjectId=t);for(let i of n.events){i.targetObjectId===e&&(i.targetObjectId=t),i.participantObjectIds=i.participantObjectIds.map(r=>r===e?t:r);for(let r of i.positions)if(r.objectId===e&&(r.objectId=t),r.placement?.mode==="orbit"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="surface"&&r.placement.target===e&&(r.placement.target=t),r.placement?.mode==="at"){let s=r.placement.reference;s.kind==="anchor"&&s.objectId===e&&(s.objectId=t),s.kind==="lagrange"&&(s.primary===e&&(s.primary=t),s.secondary===e&&(s.secondary=t)),r.placement.target=Hp(s)}i.positions.sort(Zu)}}function IC(n,e){let t=Sd(n,e);if(e.kind==="event"&&e.id){for(let i of t.system?.viewpoints??[])i.events=i.events.filter(r=>r!==e.id);return t}if(e.kind!=="object"||!e.id)return t;for(let i of t.objects)if(i.placement?.mode==="orbit"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="surface"&&i.placement.target===e.id&&(i.placement=null),i.placement?.mode==="at"){let r=i.placement.reference;(r.kind==="anchor"&&r.objectId===e.id||r.kind==="lagrange"&&(r.primary===e.id||r.secondary===e.id))&&(i.placement=null)}for(let i of t.system?.viewpoints??[])i.focusObjectId===e.id&&(i.focusObjectId=null),i.selectedObjectId===e.id&&(i.selectedObjectId=null);for(let i of t.system?.annotations??[])i.targetObjectId===e.id&&(i.targetObjectId=null),i.sourceObjectId===e.id&&(i.sourceObjectId=null);for(let i of t.events){i.targetObjectId===e.id&&(i.targetObjectId=null),i.participantObjectIds=i.participantObjectIds.filter(r=>r!==e.id),i.positions=i.positions.filter(r=>r.objectId!==e.id);for(let r of i.positions)if(r.placement?.mode==="orbit"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="surface"&&r.placement.target===e.id&&(r.placement=null),r.placement?.mode==="at"){let s=r.placement.reference;(s.kind==="anchor"&&s.objectId===e.id||s.kind==="lagrange"&&(s.primary===e.id||s.secondary===e.id))&&(r.placement=null)}}return t}function qa(n,e,t){if(e.kind==="event-pose"&&e.id&&e.key){let r=ux(n,e.id,e.key);return r?.placement?{placement:r.placement}:null}let i=VC(n,t);return i?.placement?{placement:i.placement}:null}function CC(n,e,t,i,r){let s=i.orbit;if(!s||i.object.placement?.mode!=="orbit")return n;let o=rn(r,{x:s.cx,y:s.cy},-s.rotationDeg),a=s.kind==="circle"?s.radius??1:s.rx??1,c=s.kind==="circle"?s.radius??1:s.ry??1,l=Math.atan2((o.y-s.cy)/Math.max(c,1),(o.x-s.cx)/Math.max(a,1)),u=qC(l*180/Math.PI),d=st(n),h=qa(d,e,t);return!h||h.placement.mode!=="orbit"?n:(h.placement.phase={value:io(u,2),unit:"deg"},d)}function RC(n,e,t,i,r,s,o){let a=r.orbit;if(!a||r.object.placement?.mode!=="orbit"||!o)return n;let c=rn(s,{x:a.cx,y:a.cy},-a.rotationDeg),l=Math.max(Math.abs(c.x-a.cx),24),u=Math.max(l-o.radiusOffsetPx,o.innerPx),d=KC(u,o.innerPx,o.stepPx,o.mode,o.pixelsPerMetric),h=st(n),f=qa(h,e,t);if(!f||f.placement.mode!=="orbit")return n;let p=f,y=p.placement.semiMajor??p.placement.distance??{value:1,unit:"au"},g=jp(Math.max(d,0),o.preferredUnit??y.unit);Qv(p,g);let m=l,x=d;for(let v=0;v<3;v+=1){let N=Gt(ss(h),{width:i.width,height:i.height,padding:i.padding,preset:i.renderPreset??void 0,projection:i.projection,camera:i.camera,scaleModel:{...i.scaleModel},bodyScaleMode:i.scaleModel.bodyScaleMode,activeEventId:i.activeEventId}).orbitVisuals.find(F=>F.objectId===t),C=N?.kind==="circle"?N.radius??0:N?.rx??0;if(C>=m-1)break;let R=m/Math.max(C,1);x*=Math.max(R,1.02),Qv(p,jp(Math.max(x,0),o.preferredUnit??y.unit))}return h}function Qv(n,e){n.placement.semiMajor?n.placement.semiMajor=e:n.placement.distance=e}function PC(n,e,t,i,r){let s=NC(i,t,r);if(!s)return n;let o=st(n),a=qa(o,e,t);return!a||a.placement.mode!=="at"?n:(a.placement.reference=s.reference,a.placement.target=Hp(s.reference),o)}function LC(n,e,t,i,r){let s=UC(i,t,r,c=>Q2.has(c.object.type));if(!s)return n;let o=st(n),a=qa(o,e,t);return!a||a.placement.mode!=="surface"?n:(a.placement.target=s.objectId,o)}function DC(n,e,t){if(t.object.placement?.mode!=="orbit"||!t.orbit||!t.parent)return null;let i=t.object.placement.target,r=e.objects.filter(y=>y.object.placement?.mode==="orbit"&&y.object.placement.target===i&&!y.hidden).length,s=QC(e.layoutPreset),o=(r>2?54:64)*s*e.scaleModel.orbitDistanceMultiplier,a=e.scaleModel.bodyScaleMode==="strict"?Math.max(2,8*s*e.scaleModel.orbitDistanceMultiplier):o*.42,c=t.parent.radius+Math.max(a*1.2,24*s),l=t.object.placement.semiMajor??t.object.placement.distance??null,u=ZC(l),d=t.orbit.kind==="circle"?t.orbit.radius??1:t.orbit.rx??1,h=u!==null&&u>0,f=h?d/Math.max(u,1e-4):null,p=h?u*Math.max(f??0,0):JC(u??0,c,o);return{mode:h?"linear":"log",innerPx:c,stepPx:o,pixelsPerMetric:f,radiusOffsetPx:d-p,preferredUnit:l?.unit??null}}function OC(n,e,t,i,r,s){if(r.object.placement?.mode!=="free")return n;let o=i.width-i.padding-140,a=Math.max(0,o-s.x),c=st(n),l=qa(c,e,t);if(!l||l.placement.mode!=="free")return n;let u=YC(l.placement.distance?.unit??null),d=a/Math.max(K2*i.scaleModel.freePlacementMultiplier,1);return d<.01?(l.placement.distance=void 0,l.placement.descriptor||delete l.placement.descriptor,c):(l.placement.distance=jp(d,u),delete l.placement.descriptor,c)}function UC(n,e,t,i=()=>!0){let r=null,s=Number.POSITIVE_INFINITY;for(let o of n.objects){if(o.hidden||o.objectId===e||!i(o))continue;let a=Math.hypot(t.x-o.x,t.y-o.y);a<s&&(r=o,s=a)}return s<=140?r:null}function NC(n,e,t){let i=null;for(let a of n.objects){if(a.hidden||a.objectId===e)continue;let c=Math.hypot(t.x-a.x,t.y-a.y),l=Math.max(a.visualRadius+16,28);c<=l&&(!i||c<i.distance)&&(i={reference:Wa(a.objectId),x:a.x,y:a.y,distance:c})}if(i)return{reference:i.reference,x:i.x,y:i.y};let r=[];for(let a of n.objects)a.hidden||a.objectId===e||r.push({reference:Wa(a.objectId),x:a.x,y:a.y});for(let a of n.orbitVisuals){if(a.hidden||a.objectId===e)continue;let c=n.objects.find(u=>u.objectId===a.parentId&&!u.hidden),l=n.objects.find(u=>u.objectId===a.objectId&&!u.hidden);if(!(!c||!l))for(let u of["L1","L2","L3","L4","L5"]){let d=FC(c,l,u);r.push({reference:Wa(`${a.objectId}:${u}`),x:d.x,y:d.y})}}let s=null,o=Number.POSITIVE_INFINITY;for(let a of r){let c=Math.hypot(t.x-a.x,t.y-a.y);c<o&&(s=a,o=c)}return o<=140?s:null}function FC(n,e,t){let i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r)||1,o=i/s,a=r/s,c=-a,l=o,u=XC(s*.25,24,68);switch(t){case"L1":return{x:e.x-o*u,y:e.y-a*u};case"L2":return{x:e.x+o*u,y:e.y+a*u};case"L3":return{x:n.x-o*u,y:n.y-a*u};case"L4":return{x:e.x+(o*.5-c*.8660254)*u,y:e.y+(a*.5-l*.8660254)*u};case"L5":return{x:e.x+(o*.5+c*.8660254)*u,y:e.y+(a*.5+l*.8660254)*u}}}function Wa(n){let e=n.match(/^([A-Za-z0-9._-]+)-([A-Za-z0-9._-]+):(L[1-5])$/);if(e)return{kind:"lagrange",primary:e[1],secondary:e[2],point:e[3]};let t=n.match(/^([A-Za-z0-9._-]+):(L[1-5])$/);if(t)return{kind:"lagrange",primary:t[1],secondary:null,point:t[2]};let i=n.match(/^([A-Za-z0-9._-]+):([A-Za-z0-9._-]+)$/);return i?{kind:"anchor",objectId:i[1],anchor:i[2]}:{kind:"named",name:n}}function Hp(n){switch(n.kind){case"lagrange":return n.secondary?`${n.primary}-${n.secondary}:${n.point}`:`${n.primary}:${n.point}`;case"anchor":return`${n.objectId}:${n.anchor}`;case"named":return n.name}}function nr(n){return Ed(n)}function cx(n,e){let t=new Set,i=[];for(let r of[...n,...e]){let s=`${r.diagnostic.code}:${r.diagnostic.message}:${Ti(r.path)}`;t.has(s)||(t.add(s),i.push(qu(r)))}return i}function kC(n){let e=new Map;for(let t of n){let i=Ti(t.path)??(t.diagnostic.objectId?Ti({kind:"object",id:t.diagnostic.objectId}):null);if(!i)continue;let r=e.get(i)??{errors:0,warnings:0};t.diagnostic.severity==="error"?r.errors+=1:t.diagnostic.severity==="warning"&&(r.warnings+=1),e.set(i,r)}return e}function ex(n){return n.diagnostic.line!==void 0&&n.diagnostic.column!==void 0?`Line ${n.diagnostic.line}:${n.diagnostic.column}`:n.diagnostic.line!==void 0?`Line ${n.diagnostic.line}`:null}function BC(n,e){if(!e)return[];switch(n.kind){case"system":return e==="id"?["system-id"]:e==="title"?["system-title"]:[];case"defaults":switch(e){case"view":return["defaults-view"];case"scale":return["defaults-scale"];case"units":return["defaults-units"];case"preset":return["defaults-preset"];case"theme":return["defaults-theme"];default:return[]}case"metadata":return e==="key"?["metadata-key"]:["metadata-value"];case"group":switch(e){case"id":return["group-id"];case"label":return["group-label"];case"summary":return["group-summary"];case"color":return["group-color"];case"tags":return["group-tags"];case"hidden":return["group-hidden"];default:return[]}case"viewpoint":switch(e){case"id":return["viewpoint-id"];case"label":return["viewpoint-label"];case"summary":return["viewpoint-summary"];case"focusObjectId":return["viewpoint-focus"];case"selectedObjectId":return["viewpoint-select"];case"projection":return["viewpoint-projection"];case"preset":return["viewpoint-preset"];case"zoom":return["viewpoint-zoom"];case"rotationDeg":return["viewpoint-rotation"];case"camera":return["viewpoint-camera-azimuth","viewpoint-camera-elevation","viewpoint-camera-roll","viewpoint-camera-distance"];case"camera.azimuth":return["viewpoint-camera-azimuth"];case"camera.elevation":return["viewpoint-camera-elevation"];case"camera.roll":return["viewpoint-camera-roll"];case"camera.distance":return["viewpoint-camera-distance"];case"events":return["viewpoint-events"];default:return[]}case"event":switch(e){case"id":return["event-id"];case"kind":return["event-kind"];case"label":return["event-label"];case"summary":return["event-summary"];case"targetObjectId":case"target":return["event-target"];case"participantObjectIds":case"participants":return["event-participants"];case"timing":return["event-timing"];case"visibility":return["event-visibility"];case"epoch":return["event-epoch"];case"referencePlane":return["event-referencePlane"];case"tags":return["event-tags"];case"color":return["event-color"];case"hidden":return["event-hidden"];default:return[]}case"event-pose":return e==="objectId"?["pose-object-id"]:e==="placement"?["placement-mode"]:e==="reference"||e==="target"?["placement-target"]:e==="descriptor"?["placement-free"]:$p.has(e)?[`placement-${e}`]:e==="inner"||e==="outer"?[`prop-${e}`]:e==="epoch"?["pose-epoch"]:e==="referencePlane"?["pose-referencePlane"]:[];case"annotation":switch(e){case"id":return["annotation-id"];case"label":return["annotation-label"];case"targetObjectId":return["annotation-target"];case"sourceObjectId":return["annotation-source"];case"body":return["annotation-body"];case"tags":return["annotation-tags"];default:return[]}case"relation":switch(e){case"id":return["relation-id"];case"from":return["relation-from"];case"to":return["relation-to"];case"kind":return["relation-kind"];case"label":return["relation-label"];case"summary":return["relation-summary"];case"tags":return["relation-tags"];case"color":return["relation-color"];case"hidden":return["relation-hidden"];default:return[]}case"object":return e==="id"?["object-id"]:e==="type"?["object-type"]:e==="placement"?["placement-mode"]:e==="description"?["info-description"]:e==="reference"?["placement-target"]:e==="descriptor"?["placement-free"]:e==="target"?["placement-target"]:$p.has(e)?[`placement-${e}`]:[`prop-${e}`]}}function tx(n,e,t){return Va(n,{mode:t==="3d"?"interactive-3d":"interactive-2d",preset:e.system?.defaults.preset??"atlas-card",projection:e.system?.defaults.view??"topdown"})}function Xu(n){switch(n.kind){case"system":return"System";case"defaults":return"Defaults";case"metadata":return`Metadata: ${n.key??""}`;case"group":return`Group: ${n.id??""}`;case"event":return`Event: ${n.id??""}`;case"event-pose":return`Event Pose: ${n.id??""} / ${n.key??""}`;case"object":return`Object: ${n.id??""}`;case"viewpoint":return`Viewpoint: ${n.id??""}`;case"annotation":return`Annotation: ${n.id??""}`;case"relation":return`Relation: ${n.id??""}`}}function Ti(n){return n?`${n.kind}:${n.id??""}:${n.key??""}`:null}function Vp(n){return n&&(n.kind==="event"||n.kind==="event-pose")?n.id??null:null}function lx(n,e){return n.id.localeCompare(e.id)}function nx(n,e){return n.id.localeCompare(e.id)}function Zu(n,e){return n.objectId.localeCompare(e.objectId)}function zC(n,e){return n.events.find(t=>t.id===e)??null}function ux(n,e,t){return zC(n,e)?.positions.find(i=>i.objectId===t)??null}function VC(n,e){return n.objects.find(t=>t.id===e)??null}function $C(n,e){let t=st(n),i=t.events.find(s=>s.id===e);if(!i)return n;let r=t.objects.find(s=>!i.positions.some(o=>o.objectId===s.id))??t.objects[0];return r?(i.targetObjectId!==r.id&&!i.participantObjectIds.includes(r.id)&&(i.participantObjectIds.push(r.id),i.participantObjectIds.sort((s,o)=>s.localeCompare(o))),i.positions.push(HC(r)),i.positions.sort(Zu),t):n}function HC(n){return{objectId:n.id,placement:n.placement?structuredClone(n.placement):null,inner:ix(n.properties.inner),outer:ix(n.properties.outer)}}function jC(n,e,t,i){let r=new Set(i);for(let s of n.system?.viewpoints??[]){let o=new Set(s.events);o.delete(e),o.delete(t),r.has(s.id)&&o.add(t),s.events=[...o].sort((a,c)=>a.localeCompare(c))}}function ja(n,e){let t=n.trim()||"item",i=1,r=t;for(;e.includes(r);)i+=1,r=`${t}-${i}`;return r}function Ga(n){return n.split(/[-_]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function qu(n){return{diagnostic:{...n.diagnostic},path:n.path?{...n.path}:null}}function Qi(n){return typeof n=="string"?n:""}function GC(n){return Array.isArray(n)?n.join(" "):""}function er(n){return n&&typeof n=="object"&&"value"in n?Vt(n):""}function ix(n){return n&&typeof n=="object"&&"value"in n?n:void 0}function WC(n){return typeof n=="number"?String(n):""}function Vt(n){return`${n.value}${n.unit??""}`}function io(n,e){let t=10**e;return Math.round(n*t)/t}function XC(n,e,t){return Math.min(Math.max(n,e),t)}function qC(n){let e=n%360;return e<0&&(e+=360),e}function YC(n){switch(n){case"au":case"km":case"re":case"sol":case null:return n;default:return null}}function ZC(n){if(!n)return null;switch(n.unit){case"au":return n.value;case"km":return n.value/ro;case"re":return n.value*rx/ro;case"sol":return n.value*sx/ro;default:return n.value}}function jp(n,e){switch(e){case"km":return{value:io(n*ro,0),unit:e};case"re":return{value:io(n*ro/rx,3),unit:e};case"sol":return{value:io(n*ro/sx,4),unit:e};case"au":return{value:io(n,3),unit:e};default:return{value:io(n,2),unit:null}}}function JC(n,e,t){return e+t*eR(Math.max(n,0)+1)}function KC(n,e,t,i,r){return i==="linear"&&r!==null&&r>0?Math.max(n/r,0):n<=e?0:Math.pow(2,(n-e)/Math.max(t,1e-4))-1}function QC(n){switch(n){case"compact":return .84;case"presentation":return 1.2;default:return 1}}function eR(n){return Math.log(n)/Math.log(2)}function Xe(n){return n.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function dx(n){return Xe(n)}function tR(n){if(typeof window>"u"||typeof document>"u")throw new Error("createWorldOrbitEditor can only run in a browser environment.");if(!(n instanceof HTMLElement))throw new Error("WorldOrbit editor requires an HTMLElement container.")}function yn(n,e){let t=n.querySelector(e);if(!t)throw new Error(`WorldOrbit editor failed to initialize selector "${e}".`);return t}function nR(){if(document.getElementById(Kv))return;let n=document.createElement("style");n.id=Kv,n.textContent=`
4353
4353
  .wo-editor {
4354
4354
  --wo-editor-sidebar-width: 280px;
4355
4355
  --wo-editor-inspector-width: 360px;